Commit fc1e6778 authored by libin's avatar libin

Merge remote-tracking branch 'origin/holiday-price' into holiday-price

parents 0bed8101 03857ab8
......@@ -28,6 +28,7 @@ public class RabbitConstant {
public static final String KEY_ORDER_PAY = "order.pay";
public static final String KEY_ORDER_FINLISH = "order.finlish";
public static final String KEY_ORDER_CANCEL = "order.cancel";
public static final String KEY_ORDER_PART_DEPOSIT = "order.partDeposit";
//钱包
public static final String KEY_WALLET_ADD = "wallet.add";
......
......@@ -60,6 +60,11 @@ public class AppUserManageDTO {
*/
private Set<Integer> citySet;
/**
* 用户id
*/
private Integer userId;
// /**
// * 接收前台时间范围
// */
......
......@@ -63,6 +63,9 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
@Autowired
private AppUserRelationBiz appUserRelationBiz;
@Autowired
private AppUserSellingWaterBiz appUserSellingWaterBiz;
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
@Override
public void insertSelective(AppUserLogin entity) {
......@@ -417,11 +420,10 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
leaderId = appUserLogins.get(0).getId();
//2.根据leader userId查询下级 userid
if (Objects.nonNull(leaderId)) {
List<AppUserRelation> appUserRelationList = appUserRelationBiz.findMemberPageByLeaderId(leaderId);
if(CollectionUtils.isEmpty(appUserRelationList)){
memberIds = appUserSellingWaterBiz.findMemberIdByLeaderIdAndOrdreType(leaderId,3);
if(CollectionUtils.isEmpty(memberIds)){
return Collections.EMPTY_LIST;
}
memberIds = appUserRelationList.stream().map(AppUserRelation::getUserId).collect(Collectors.toList());
}
}
List<Integer> userIds = mapper.findAppUser(phone, name, memberIds);
......
......@@ -184,4 +184,14 @@ public class AppUserManageBiz extends BaseBiz<AppUserDetailMapper, AppUserDetail
}
}
public AppUserManageVo findUserInfoById(Integer userId) {
AppUserManageVo appUserManageVo = new AppUserManageVo();
AppUserManageDTO appUserManageDTO = new AppUserManageDTO();
appUserManageDTO.setUserId(userId);
List<AppUserManageVo> appUserManageVos = mapper.selectAppUserManage(appUserManageDTO);
if (CollectionUtils.isEmpty(appUserManageVos)){
return appUserManageVo;
}
return appUserManageVos.get(0);
}
}
......@@ -217,6 +217,9 @@ public class AppUserRelationBiz extends BaseBiz<AppUserRelationMapper,AppUserRel
return null;
}
log.info("---userId==="+userId+"-----isForever==="+userRelation.getIsForever());
if (validTime==null||validTime==0){
return userRelation;
}
Long time=System.currentTimeMillis()-validTime;
if (userRelation.getIsForever()==1||userRelation.getBindTime()>time){
return userRelation;
......
......@@ -439,6 +439,18 @@ public class AppUserSellingWaterBiz extends BaseBiz<AppUserSellingWaterMapper, A
return sellingWalletPagVo;
}
public List<Integer> findMemberIdByLeaderIdAndOrdreType(Integer leaderId, int orderType) {
Example example = new Example(AppUserSellingWater.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("userId", leaderId);
criteria.andEqualTo("orderType", orderType);
List<AppUserSellingWater> appUserSellingWaters = mapper.selectByExample(example);
if (CollectionUtils.isEmpty(appUserSellingWaters)){
return Collections.EMPTY_LIST;
}
return appUserSellingWaters.stream().map(AppUserSellingWater::getSourceId).collect(Collectors.toList());
}
public PageDataVO<UserSellingWaterAdminDTO> findSellingWaterWithPage(UserSellingWaterFindDTO userSellingWaterFindDTO) {
PageDataVO<UserSellingWaterAdminDTO> pageDataVO = PageDataVO.pageInfo(userSellingWaterFindDTO.getPage(),
userSellingWaterFindDTO.getLimit(),
......
......@@ -36,6 +36,7 @@ public class RabbitAdminConfig extends RabbitCommonConfig {
add(new BindDTO(ORDER_WATER_QUEUE, ORDER_TOPIC, KEY_ORDER_PAY));
add(new BindDTO(ORDER_WATER_QUEUE, ORDER_TOPIC, KEY_ORDER_FINLISH));
add(new BindDTO(ORDER_WATER_QUEUE, ORDER_TOPIC, KEY_ORDER_CANCEL));
add(new BindDTO(ORDER_WATER_QUEUE, ORDER_TOPIC, KEY_ORDER_PART_DEPOSIT));
add(new BindDTO(ORDER_FINLISH_USER_RE_QUEUE, ORDER_TOPIC, KEY_ORDER_FINLISH));
//钱包
add(new BindDTO(WALLET_ADD_QUEUE, ADMIN_TOPIC, KEY_WALLET_ADD));
......
......@@ -63,6 +63,9 @@ public class WaterMQHandler {
case ORDER_FINISH:
orderWaterDTO.setStatus(2);
break;
case ORDER_PART_DEPOSIT:
orderWaterDTO.setStatus(2);
break;
case ORDER_CANCEL:
orderWaterDTO.setStatus(3);
break;
......@@ -71,13 +74,18 @@ public class WaterMQHandler {
}
switch (OrderTypeEnum.get(orderMQDTO.getType())) {
case RENT_VEHICLE:
//租车订单finlish不处理,退还第一部分押金后再处理
if(orderMQDTO.getSign().equals(ORDER_FINISH)) {
break;
}
orderMQDTO.getItemByTypeEnum(ItemTypeEnum.VEHICLE_MODEL);
orderWaterDTO.setGoodsDTOList(
new ArrayList<OrderGoodsDTO>() {{
add(new OrderGoodsDTO() {{
setGoodId(orderMQDTO.getOrderRentVehicleDetail().getModelId());
setGoodNumber(1);
setImg(orderMQDTO.getPicture());
setPrice(orderMQDTO.getItemByTypeEnum(ItemTypeEnum.VEHICLE_MODEL).getRealAmount());
setPrice(orderMQDTO.getItemByTypeEnum(ItemTypeEnum.VEHICLE_MODEL).getLastAmount());
setTitle(orderMQDTO.getName());
setType(OrderGoodsDTO.TYPE_RENT);
}});
......
......@@ -19,13 +19,12 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.msg.TableResultResponse;
import com.github.wxiaoqi.security.common.rest.CommonBaseController;
import com.github.wxiaoqi.security.common.util.Query;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.xxfc.platform.order.feign.OrderFeign;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -164,6 +163,7 @@ public class AppUserController extends CommonBaseController{
String icon=memberLevel.getIcon();
userDTO.setIcon(icon);
userDTO.setBigIcon(memberLevel.getBigIcon());
userDTO.setItemImg(memberLevel.getItemImg());
}
}
}
......@@ -171,20 +171,7 @@ public class AppUserController extends CommonBaseController{
if (userPosition!=null&&userPosition.getLevel()>0){
userDTO.setPositionName(userPosition.getName());
}
AppUserRelation relation=relationBiz.getRelationByIdUserIdAndTime(userid);
Integer parentId=0;
if (relation!=null){
parentId=relation.getParentId();
}
userDTO.setParentId(parentId);
List<AppUserAlipay> appUserAlipays = appUserAlipayBiz.getByUserId(request);
long count = appUserAlipays.stream().filter(appUserAlipay -> appUserAlipay.getType() == 1).count();
userDTO.setIsBindAliPay(count>0);
userDTO.setId(id);
userDTO.setAliPayNickName(userDTO.getIsBindAliPay()?appUserAlipays.get(0).getNickname():"");
AppUserLogin appUserLogin = appUserLoginBiz.selectById(userid);
userDTO.setIsBindWx(StringUtils.isNotEmpty(appUserLogin.getWxOpenid()));
userDTO.setIsBindQQ(StringUtils.isNotEmpty(appUserLogin.getOpenid()));
return ObjectRestResponse.succ(userDTO);
}
......@@ -234,7 +221,7 @@ public class AppUserController extends CommonBaseController{
appUserLogin.setOpenid(userVo.getOpenid());
appUserLogin.setId(userid);
appUserLogin.setUsername(userVo.getUsername());
appUserLoginBiz.bindOpenid(appUserLogin);
appUserLoginBiz.updateAppuserLogin(appUserLogin);
//支付宝绑定
if (StringUtils.isNotEmpty(userVo.getAliCode()) && userVo.getAliCode().trim().length()>0){
appUserAlipayBiz.getUserInfo(userVo.getAliCode(),request);
......@@ -348,8 +335,6 @@ public class AppUserController extends CommonBaseController{
return appUserLoginBiz.test();
}
@PostMapping("/bind")
private ObjectRestResponse accountBinding(@RequestBody AccountBindDTO accountBindDTO, HttpServletRequest request){
try {
......
......@@ -45,8 +45,10 @@ public class AppUserRelationController extends BaseController<AppUserRelationBiz
@RequestParam(value = "code",defaultValue = "")String code,
HttpServletRequest request){
try {
Integer userid = Integer.parseInt(userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request)).getId());
return baseBiz.appBindRelation(userid,code);
//屏蔽分享绑定
/*Integer userid = Integer.parseInt(userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request)).getId());
return baseBiz.appBindRelation(userid,code);*/
return ObjectRestResponse.succ();
} catch (Exception e) {
e.printStackTrace();
throw new BaseException(e);
......
......@@ -19,7 +19,6 @@ import com.xxfc.platform.vehicle.feign.VehicleFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Set;
/**
......@@ -66,6 +65,12 @@ public class AppUsersManageController extends BaseController<AppUserManageBiz,Ap
appUserManageDTO.setCitySet(cityList);
return ObjectRestResponse.succ(baseBiz.findAllByQueryAndCity(appUserManageDTO));
}
@GetMapping("/user_info/{id}")
public ObjectRestResponse<AppUserManageVo> findUserInfo(@PathVariable(value = "id") Integer userId){
AppUserManageVo appUserManageVo = baseBiz.findUserInfoById(userId);
return ObjectRestResponse.succ(appUserManageVo);
}
/**
* 查询一条
* @param id
......
package com.github.wxiaoqi.security.admin.rest;
import com.github.wxiaoqi.security.admin.biz.AppUserSellingWaterBiz;
import com.github.wxiaoqi.security.admin.dto.OrderWaterDTO;
import com.github.wxiaoqi.security.admin.vo.SellingWalletPagVo;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.auth.client.jwt.UserAuthUtil;
......@@ -8,10 +9,7 @@ import com.github.wxiaoqi.security.auth.common.util.jwt.IJWTInfo;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
......@@ -34,6 +32,9 @@ public class UserSellingWaterController {
@Autowired
private UserAuthConfig userAuthConfig;
@Autowired
private AppUserSellingWaterBiz waterBiz;
@GetMapping("/page")
public ObjectRestResponse<SellingWalletPagVo> findSellingWaterPage(@RequestParam(required = false,value = "type") Integer wating,
@RequestParam("pageNo") Integer pageNo,
......@@ -61,4 +62,14 @@ public class UserSellingWaterController {
throw new BaseException(e);
}
}
@PostMapping("app/unauth/order")
public ObjectRestResponse order(@RequestBody OrderWaterDTO orderWaterDTO) {
try {
waterBiz.orderWater(orderWaterDTO);
return ObjectRestResponse.succ();
} catch (Exception e) {
throw new BaseException(e);
}
}
}
......@@ -434,13 +434,14 @@ public class AppPermissionService {
if(type!=null&&type==1){
try {
Integer parentId=0;
if (StringUtils.isNotBlank(code)) {
//屏蔽app登录的绑定关系
/*if (StringUtils.isNotBlank(code)) {
parentId = appUserDetailBiz.getUserByCode(code);
}
//绑定上下线关系
if (parentId != null && parentId > 0) {
relationBiz.bindRelation(userid, parentId, 1);
}
}*/
//活动消息
Integer state=userVo.getState();
log.info("-----------autoLogin----state==="+state);
......
......@@ -165,6 +165,9 @@
<if test="source !=null ">
and d.source = #{source}
</if>
<if test="userId!=null">
and l.id=#{userId}
</if>
<if test="citySet != null ">
and d.city_code in
<foreach collection="citySet" item="item" index="index" open="(" separator="," close=")" >
......
......@@ -137,6 +137,10 @@ public class OrderItem implements Serializable {
@ApiModelProperty(value = "描述、详情")
private String detail;
@Column(name = "change_amount")
@ApiModelProperty(value = "下单后导致改变的价格")
private BigDecimal changeAmount;
public Integer getCalculateNum() {
return buyNum - cutNum;
......@@ -176,4 +180,8 @@ public class OrderItem implements Serializable {
public BigDecimal getTotalAmount() {
return realAmount.add(couponAmount);
}
public BigDecimal getLastAmount() {
return realAmount.add(changeAmount);
}
}
......@@ -15,6 +15,7 @@ public class OrderMQDTO extends BaseOrder implements OrderItemInter {
public static final int ORDER_CANCEL = 2;
public static final int ORDER_PAY = 4;
public static final int ORDER_FINISH = 6;
public static final int ORDER_PART_DEPOSIT = 101;
OrderRentVehicleDetail orderRentVehicleDetail;
......@@ -42,6 +43,8 @@ public class OrderMQDTO extends BaseOrder implements OrderItemInter {
* 4--已支付"
*
* 6--已完成
*
* 101--部分押金退还
*/
Integer sign;
}
......@@ -745,15 +745,15 @@ public class BaseOrderBiz extends BaseBiz<BaseOrderMapper, BaseOrder> implements
switch (sign) {
case 2:
sendMsgDTO.setRoutKey(KEY_ORDER_CANCEL);
// mqSenderFeign.sendMessage(ORDER_TOPIC, KEY_ORDER_CANCEL, JSONUtil.toJsonStr(orderMQDTO));
break;
case 4:
sendMsgDTO.setRoutKey(KEY_ORDER_PAY);
// mqSenderFeign.sendMessage(ORDER_TOPIC, KEY_ORDER_PAY, JSONUtil.toJsonStr(orderMQDTO));
break;
case 6:
sendMsgDTO.setRoutKey(KEY_ORDER_FINLISH);
// mqSenderFeign.sendMessage(ORDER_TOPIC, KEY_ORDER_FINLISH, JSONUtil.toJsonStr(orderMQDTO));
break;
case 101:
sendMsgDTO.setRoutKey(KEY_ORDER_PART_DEPOSIT);
break;
default:
break;
......
......@@ -156,6 +156,9 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
if(null != orderViolateCoverAmount) {
depositDeductAmount = orderViolateCoverAmount;
}
if (null != depositViolateCoverAmount) {
depositDeductAmount = depositViolateCoverAmount;
}
if(topAmount.compareTo(depositDeductAmount) > 0) {
totalDeductAmount = totalDeductAmount.add(depositDeductAmount);
topAmount = topAmount.subtract(depositDeductAmount);
......@@ -215,6 +218,23 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
orv.setOrderNo(baseOrder.getNo());
orv.setRefundDesc(refundDesc+ refundAmount.toString());
orv.setRefundAmount(refundAmount.multiply(new BigDecimal("100")).intValue());
// originalRefundAmount - refundAmount
Integer freeze2PayAmount = originalRefundAmount.subtract(refundAmount).multiply(new BigDecimal("100")).intValue();
if(AccountTypeEnum.OUT_PART_DEPOSIT.getCode().equals(refundType)) {
// freeze2PayAmount - 违章保证金
for(OrderAccountDeduction deduction : oad.getDeductions()) {
if(DeductionTypeEnum.VIOLATE_TRAFFIC_KEEP.getCode().equals(deduction.getType())) {
freeze2PayAmount -= deduction.getAmount().multiply(new BigDecimal("100")).intValue();
break;
}
}
}
orv.setFreeze2PayAmount(freeze2PayAmount);
orv.setFreeze2PayDesc("");
ObjectRestResponse<String> result = thirdFeign.refund(orv);
refundTradeNo = result.getData();
if(null == refundTradeNo) {
......@@ -399,9 +419,7 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
BigDecimal originalRefundAmount = oad.getOriginDepositAmount().add(oad.getOriginOrderAmount());
//crosstown.getRestDeposit().add(crosstown.getDeductionCost()).subtract(illegalReserve);
String refundDesc = "退还押金:"+ refundAmont.toString()+ "(已扣除 违章预备金:"+ illegalReserve.toString();
refundDesc += handleDedRefundDesc;
refundDesc += ")";
String refundDesc = "退还车辆押金:"+ refundAmont.toString();
//还车扣除款 剩余的 钱,再减去违章预备金
oad.getDeductions().add(
......@@ -470,6 +488,13 @@ public class OrderAccountBiz extends BaseBiz<OrderAccountMapper,OrderAccount> {
orderMQDTO.setOrderRentVehicleDetail(orderRentVehicleBiz.selectById(orderMQDTO.getDetailId()));
//根据商品消费金额 设置changeAmount
vehicleItemDTO.setChangeAmount(inProgressVO.getConsumeAmount().subtract(vehicleItemDTO.getRealAmount()));
orderItemBiz.updateSelectiveByIdRe(vehicleItemDTO);
//发送押金退还完成队列消息
baseOrderBiz.sendOrderMq(orderMQDTO.getOrderRentVehicleDetail(), null, null, orderMQDTO, OrderMQDTO.ORDER_CANCEL);
//捕捉异常
try {
orderMsgBiz.handelMsgDeposit(orderMQDTO.getOrderRentVehicleDetail(), orderMQDTO, userFeign.userDetailById(orderMQDTO.getUserId()).getData());
......
......@@ -170,7 +170,7 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
OrderRentVehicleDetail orderRentVehicleDetail = orderRentVehicleBiz.selectById(baseOrder.getDetailId());
if (orderVehicleCrosstownDto.getType() == CrosstownTypeEnum.DEPARTURE.getCode()) {
boolean flag = getTodayTime(orderRentVehicleDetail.getStartTime());
boolean flag = getTodayTime(orderRentVehicleDetail.getStartTime(), orderRentVehicleDetail.getEndTime());
if (!flag) {
return ObjectRestResponse.createFailedResult(3502, "已超过预定还车时间,不能进行交车操作!");
}
......@@ -438,9 +438,15 @@ public class OrderVehicleCrosstownBiz extends BaseBiz<OrderVehicaleCrosstownMapp
return illegalReserve;
}
public boolean getTodayTime(Long time) {
/**
* 当前时间大于预定开始时间当天0点,小于结束时间当天时间24点 2019.11.04
* @param startTime
* @param endTime
* @return
*/
public boolean getTodayTime(Long startTime, Long endTime) {
long current = System.currentTimeMillis();
if (current <= (getDayStart(time) + 24 * 60 * 60 * 1000 - 1) && current >= getDayStart(time)) {
if (getDayStart(startTime) <= (current) && current <= getDayStart(endTime) + 1000 * 3600 * 24 - 1) {
return true;
}
return false;
......
......@@ -87,6 +87,8 @@ public class OrderCalculateBiz {
public InProgressVO inProgressCalculate(BaseOrder baseOrder, VehicleItemDTO vehicleItemDTO, Integer freeDays, Integer useDays, OrderAccountDetail oad, Boolean isCancel) {
BigDecimal refundAmount = BigDecimal.ZERO;
BigDecimal consumeAmount = BigDecimal.ZERO;
BigDecimal topViolateAmount = BigDecimal.ZERO;
BigDecimal itemChangeAmount = BigDecimal.ZERO;
//融入日期价格
List<VehicleModelCalendarPriceDTO> vmcpds = JSONUtil.toList(JSONUtil.parseArray(vehicleItemDTO.getDetail()), VehicleModelCalendarPriceDTO.class);
......@@ -203,7 +205,7 @@ public class OrderCalculateBiz {
residueAmount = residueAmount.add(vmcpds.get(i).getPrice());
}
String violateDesc = StrUtil.format("{}元", residueAmount.toString());
if(residueDays > 2) {
if(residueDays >= 2) {
residueDays = 2;
residueAmount = BigDecimal.ZERO;
for(int i = useDays; i < (useDays + residueDays + 1); i++) {
......@@ -216,6 +218,7 @@ public class OrderCalculateBiz {
OrderAccountDeduction violateDeduction = orderAccountBiz.initDeduction(inProgressVO.getViolateAmount(), violateDesc, DeductionTypeEnum.VIOLATE_ADVANCE, OrderAccountDeduction.ORIGIN_DEPOSIT);
oad.getDeductions().add(violateDeduction);
}else if(residueDays < 0 && !isCancel){
//isCancel 表示是否为取消,取消则不计算延期还车(因为没有出车)
//设置消耗费用列表
useAmountList.addAll(Convert.toList(VMCalendarPriceCostDTO.class, vmcpds));
//如果订单 出发中 或者 已完成 或者定损中
......@@ -311,8 +314,6 @@ public class OrderCalculateBiz {
public OrderRefundPriceVO getPriceCalculate (String no, OrderPageVO orderPageVO) {
//根据no 查订单
OrderTypeEnum orderTypeEnum = OrderTypeEnum.get(orderPageVO.getType());
BigDecimal totalRefundAmount = BigDecimal.ZERO;
......@@ -324,22 +325,24 @@ public class OrderCalculateBiz {
switch (orderTypeEnum) {
case RENT_VEHICLE:
DateTime nowTime = DateTime.parse(DateTime.now().toString(CommonConstants.YMR_SLASH_FORMATTER_JODA), CommonConstants.YMR_SLASH_FORMATTER_JODA);
DateTime startTime = DateTime.parse(new DateTime(orderPageVO.getOrderRentVehicleDetail().getStartTime()).toString(CommonConstants.YMR_SLASH_FORMATTER_JODA), CommonConstants.YMR_SLASH_FORMATTER_JODA);
DateTime endTime = DateTime.parse(new DateTime(orderPageVO.getOrderRentVehicleDetail().getEndTime()).toString(CommonConstants.YMR_SLASH_FORMATTER_JODA), CommonConstants.YMR_SLASH_FORMATTER_JODA);
Long timeLag = orderPageVO.getOrderRentVehicleDetail().getStartTime() - System.currentTimeMillis();
OrderItem vehicleItem = orderItemBiz.selectOne(new OrderItem(){{
VehicleItemDTO vehicleItemDTO = BeanUtil.toBean(orderItemBiz.selectOne(new OrderItem(){{
setType(ItemTypeEnum.VEHICLE_MODEL.getCode());
setOrderId(orderPageVO.getId());
}});
topAmount = vehicleItem.getUnitPrice().multiply(new BigDecimal(2+ ""));
}}), VehicleItemDTO.class);
//融入日期价格
List<VehicleModelCalendarPriceDTO> vmcpds = JSONUtil.toList(JSONUtil.parseArray(vehicleItemDTO.getDetail()), VehicleModelCalendarPriceDTO.class);
if(timeLag < 0 ) {
Integer useDays = getIncludeDays(orderPageVO.getOrderRentVehicleDetail().getStartTime(), DateTime.now().getMillis());
OrderAccountDetail oad = new OrderAccountDetail();
Integer freeDays = (null == vehicleItem.getCutNum())?0 :vehicleItem.getCutNum();
//inProgressVO = inProgressCalculate(orderPageVO, vehicleItem, freeDays, baseOrderBiz.getDaysBetweenDateTime(startTime, nowTime), new OrderAccountDetail(), Boolean.FALSE);
Integer freeDays = (null == vehicleItemDTO.getCutNum())?0 :vehicleItemDTO.getCutNum();
inProgressVO = inProgressCalculate(orderPageVO, vehicleItemDTO, freeDays, useDays, new OrderAccountDetail(), Boolean.FALSE);
topAmount = vehicleItemDTO.getTopAmount(useDays);
totalDeductAmount = oad.realTotalDeduct();
totalRefundAmount = oad.getOrderAmount().add(oad.getDepositAmount());
refundDesc = inProgressVO.getViolateDesc();
......@@ -347,11 +350,12 @@ public class OrderCalculateBiz {
String key = RENT_REFUND;
BigDecimal deductionAmount = orderAccountBiz.calculateDeduction(vehicleItem.getBuyAmount()
BigDecimal deductionAmount = orderAccountBiz.calculateDeduction(vehicleItemDTO.getBuyAmount()
, orderPageVO.getOrderRentVehicleDetail().getStartTime() - System.currentTimeMillis()
, DictionaryKey.APP_ORDER+ "_"+ key
, refundDescBuilder);
topAmount = vehicleItemDTO.getTopAmount(0);
totalDeductAmount = deductionAmount;
totalRefundAmount = orderPageVO.getRealAmount().subtract(deductionAmount);
refundDesc = refundDescBuilder.toString();
......@@ -377,13 +381,13 @@ public class OrderCalculateBiz {
BigDecimal adultItemAmount = (null == adultItem)? BigDecimal.ZERO: adultItem.getRealAmount();
BigDecimal childItemAmount = (null == childItem)? BigDecimal.ZERO: childItem.getRealAmount();
topAmount = adultItemAmount.add(childItemAmount);
BigDecimal deductionAmount = orderAccountBiz.calculateDeduction(adultItemAmount.add(childItemAmount)
, orderPageVO.getOrderTourDetail().getStartTime() - System.currentTimeMillis()
, DictionaryKey.APP_ORDER+ "_"+ key
, refundDescBuilder);
topAmount = adultItemAmount.add(childItemAmount);
totalDeductAmount = deductionAmount;
totalRefundAmount = orderPageVO.getRealAmount().subtract(deductionAmount);
refundDesc = refundDescBuilder.toString();
......@@ -399,4 +403,8 @@ public class OrderCalculateBiz {
orpv.setTopAmount(topAmount);
return orpv;
}
public static void main(String[] args) {
System.out.println(DateTime.now().getMillis());
}
}
\ No newline at end of file
......@@ -32,7 +32,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
......@@ -150,6 +149,9 @@ public class OrderCancelBiz {
Long timeLag = orvd.getStartTime() - System.currentTimeMillis();
if(timeLag < 0 ) {
Integer useDays = orderCalculateBiz.getIncludeDays(orvd.getStartTime(), System.currentTimeMillis());
if(useDays > orvd.getDayNum()) {
useDays = orvd.getUsedDay();
}
inProgressVO = orderCalculateBiz.calculateOrderComplete(baseOrder, orvd, oad, vehicleItemDTO, useDays, Boolean.TRUE);
//判断是否修改违约金
......@@ -194,9 +196,18 @@ public class OrderCancelBiz {
//orderTemplateBiz.handleCostDetailExtend(csv);
orvd.handelCostDetailExtend(csv);
orderRentVehicleBiz.updateSelectiveByIdRe(orvd);
//根据商品消费金额 设置changeAmount
vehicleItemDTO.setChangeAmount(inProgressVO.getConsumeAmount().subtract(vehicleItemDTO.getRealAmount()));
orderItemBiz.updateSelectiveByIdRe(vehicleItemDTO);
}else {
// //没到出车时间
//判断是否修改违约金
if(null != changeViolateAmount) {
oad.changeCancelViolate(changeViolateAmount);
}
//退款流程
//违约金封顶 租车身份价 * 2天
orderAccountBiz.rentRefundProcessCancel(baseOrder, BigDecimal.ZERO, timeLag, APP_ORDER+ "_"+ RENT_REFUND, orvd.getDeposit(), vehicleItemDTO.getBuyAmount(), oad, vehicleItemDTO.getTopAmount(0), null, changeViolateAmount);
......
......@@ -110,7 +110,7 @@ public class RentDepositJobHandler extends IJobHandler {
OrderAccountDetail oad = new OrderAccountDetail();
String refundDesc = "退还押金:";
String refundDesc = "退还违章押金:";
BigDecimal refundAmont;
if(null != orderViolation) {
//设置扣款项
......@@ -120,8 +120,7 @@ public class RentDepositJobHandler extends IJobHandler {
//还车扣除款 剩余的 钱,再减去违章预备金
refundAmont = orvd.getReturnPayResidue().subtract(orderViolation.getPrice());
refundDesc += refundAmont.toString()+ "(已扣除 违章扣款:"+ refundAmont.toString();
refundDesc += ")";
refundDesc += refundAmont.toString();
}else {
refundAmont = orvd.getReturnPayResidue();
refundDesc += refundAmont.toString();
......
......@@ -12,7 +12,7 @@ import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
/**;
*
*
* @author zjw
......
......@@ -3,7 +3,9 @@ package com.xxfc.platform.order.rest;
import cn.hutool.core.bean.BeanUtil;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreClientToken;
import com.github.wxiaoqi.security.auth.client.annotation.IgnoreUserToken;
import com.github.wxiaoqi.security.common.context.BaseContextHandler;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.order.biz.OrderMemberDetailBiz;
......@@ -20,7 +22,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Base64;
@Controller
@RequestMapping("orderMember")
......@@ -69,6 +76,16 @@ public class OrderMemberController extends BaseController<OrderMemberDetailBiz,
@PostMapping("/export")
@ResponseBody
public void exportMemberOrders(@RequestBody MemberOrderFindDTO memberOrderFindDTO, HttpServletResponse response){
// orderMemberService.exportMemberOrderData(memberOrderFindDTO);
try {
String name = DateTimeFormatter.ofPattern("YYYYMMddHHmmss").format(LocalDateTime.now());
response.setContentType("application/vnd.ms-excel;charset=utf-8");
String filename = String.format("%s-MemberOrder.xlsx",name);
response.setHeader("Content-Disposition","attachment;filename="+ new String(filename.getBytes(), "iso8859-1"));
ServletOutputStream outputStream = response.getOutputStream();
orderMemberService.exportMemberOrderData(memberOrderFindDTO, name, outputStream);
response.setCharacterEncoding("UTF-8");
}catch (Exception ex){
throw new BaseException("导出数据失败");
}
}
}
\ No newline at end of file
......@@ -73,93 +73,13 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
setLimit(1);
setPage(1);
}}){{put("no", no); }}.getSuper()).get(0);
OrderTypeEnum orderTypeEnum = OrderTypeEnum.get(orderPageVO.getType());
BigDecimal totalRefundAmount = BigDecimal.ZERO;
BigDecimal totalDeductAmount = BigDecimal.ZERO;
StringBuilder refundDescBuilder = new StringBuilder("");
String refundDesc = "";
InProgressVO inProgressVO = new InProgressVO();
switch (orderTypeEnum) {
case RENT_VEHICLE:
DateTime nowTime = DateTime.parse(DateTime.now().toString(CommonConstants.YMR_SLASH_FORMATTER_JODA), CommonConstants.YMR_SLASH_FORMATTER_JODA);
DateTime startTime = DateTime.parse(new DateTime(orderPageVO.getOrderRentVehicleDetail().getStartTime()).toString(CommonConstants.YMR_SLASH_FORMATTER_JODA), CommonConstants.YMR_SLASH_FORMATTER_JODA);
DateTime endTime = DateTime.parse(new DateTime(orderPageVO.getOrderRentVehicleDetail().getEndTime()).toString(CommonConstants.YMR_SLASH_FORMATTER_JODA), CommonConstants.YMR_SLASH_FORMATTER_JODA);
Long timeLag = orderPageVO.getOrderRentVehicleDetail().getStartTime() - System.currentTimeMillis();
VehicleItemDTO vehicleItemDTO = BeanUtil.toBean(orderItemBiz.selectOne(new OrderItem(){{
setType(ItemTypeEnum.VEHICLE_MODEL.getCode());
setOrderId(orderPageVO.getId());
}}), VehicleItemDTO.class);
if(timeLag < 0 ) {
OrderAccountDetail oad = new OrderAccountDetail();
Integer freeDays = (null == vehicleItemDTO.getCutNum())?0 :vehicleItemDTO.getCutNum();
inProgressVO = orderCalculateBiz.inProgressCalculate(orderPageVO, vehicleItemDTO, freeDays, baseOrderBiz.getDaysBetweenDateTime(startTime, nowTime), new OrderAccountDetail(), Boolean.FALSE);
//.inProgressCalculate(orderPageVO, baseOrderBiz.getDaysBetweenDateTime(startTime, nowTime));
totalDeductAmount = oad.realTotalDeduct();
totalRefundAmount = oad.getOrderAmount().add(oad.getDepositAmount());
refundDesc = inProgressVO.getViolateDesc();
}else {
String key = RENT_REFUND;
BigDecimal deductionAmount = orderAccountBiz.calculateDeduction(vehicleItemDTO.getBuyAmount()
, orderPageVO.getOrderRentVehicleDetail().getStartTime() - System.currentTimeMillis()
, DictionaryKey.APP_ORDER+ "_"+ key
, refundDescBuilder);
totalDeductAmount = deductionAmount;
totalRefundAmount = orderPageVO.getRealAmount().subtract(deductionAmount);
refundDesc = refundDescBuilder.toString();
}
break;
case TOUR:
//判断是省内还是省外
String key = TOUR_IN_REFUND;
if(SYS_TRUE.equals(orderPageVO.getOrderTourDetail().getIsOutside())) {
key = TOUR_REFUND;
}
OrderItem adultItem = orderItemBiz.selectOne(new OrderItem(){{
setType(ItemTypeEnum.TOUR_ADULT.getCode());
setOrderId(orderPageVO.getId());
}});
OrderItem childItem = orderItemBiz.selectOne(new OrderItem(){{
setType(ItemTypeEnum.TOUR_CHILD.getCode());
setOrderId(orderPageVO.getId());
}});
BigDecimal adultItemAmount = (null == adultItem)? BigDecimal.ZERO: adultItem.getRealAmount();
BigDecimal childItemAmount = (null == childItem)? BigDecimal.ZERO: childItem.getRealAmount();
BigDecimal deductionAmount = orderAccountBiz.calculateDeduction(adultItemAmount.add(childItemAmount)
, orderPageVO.getOrderTourDetail().getStartTime() - System.currentTimeMillis()
, DictionaryKey.APP_ORDER+ "_"+ key
, refundDescBuilder);
totalDeductAmount = deductionAmount;
totalRefundAmount = orderPageVO.getRealAmount().subtract(deductionAmount);
refundDesc = refundDescBuilder.toString();
break;
default:
break;
}
OrderRefundPriceVO orpv = new OrderRefundPriceVO();
orpv.setRealAmount(orderPageVO.getRealAmount());
orpv.setRefundAmount(totalRefundAmount);
OrderRefundPriceVO orpv = orderCalculateBiz.getPriceCalculate(no, orderPageVO);
if(orderPageVO.getStatus().equals(OrderStatusEnum.ORDER_UNPAY.getCode())
|| orderPageVO.getStatus().equals(OrderStatusEnum.ORDER_CRT.getCode())
|| orpv.getRefundAmount().compareTo(BigDecimal.ZERO) <= 0) {
orpv.setRefundDesc("是否确定取消订单");
}else {
orpv.setRefundDesc(StrUtil.format("本次取消操作需要扣除{}元违约金,实际退款金额为{}元,您确定要取消订单吗?", totalDeductAmount, totalRefundAmount));
orpv.setRefundDesc(StrUtil.format("本次取消操作需要扣除{}元违约金,实际退款金额为{}元,您确定要取消订单吗?", orpv.getRealAmount(), orpv.getRefundAmount()));
}
return ObjectRestResponse.succ(orpv);
}
......@@ -169,7 +89,7 @@ public class OrderRefundController extends BaseController<OrderRefundBiz,OrderRe
@ResponseBody
@IgnoreClientToken
public ObjectRestResponse<BigDecimal> getViolatePrice(@PathVariable(value = "no") String no) {
checkAppUser();
checkAdminUser();
OrderPageVO orderPageVO = baseOrderBiz.pageByParm(new Query(new PageParam(){{
setLimit(1);
setPage(1);
......
package com.xxfc.platform.order.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.github.wxiaoqi.security.admin.bo.UserBo;
import com.github.wxiaoqi.security.admin.entity.BaseUserMemberLevel;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.rest.UserRestInterface;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.util.excel.ExcelExport;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.activity.feign.ActivityFeign;
......@@ -20,7 +17,6 @@ import com.xxfc.platform.order.biz.OrderTemplateBiz;
import com.xxfc.platform.order.contant.enumerate.ItemTypeEnum;
import com.xxfc.platform.order.contant.enumerate.OrderStatusEnum;
import com.xxfc.platform.order.contant.enumerate.OrderTypeEnum;
import com.xxfc.platform.order.entity.BaseOrder;
import com.xxfc.platform.order.entity.OrderItem;
import com.xxfc.platform.order.pojo.dto.MemberOrderBo;
import com.xxfc.platform.order.pojo.dto.MemberOrderFindDTO;
......@@ -37,19 +33,20 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -96,6 +93,10 @@ public class OrderMemberService extends AbstractOrderHandle<OrderMemberDetailBiz
@Autowired
public HttpServletRequest request;
private SimpleDateFormat simleFormatter = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
private DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("YYYYMMddHHmmss");
@PostConstruct
public void init() {
this.orderTypeEnum = OrderTypeEnum.MEMBER;
......@@ -197,56 +198,95 @@ public class OrderMemberService extends AbstractOrderHandle<OrderMemberDetailBiz
* 导出数据
* @param memberOrderFindDTO
*/
public void exportMemberOrderData(MemberOrderFindDTO memberOrderFindDTO) throws Exception{
public void exportMemberOrderData(MemberOrderFindDTO memberOrderFindDTO,String name,OutputStream outputStream) throws Exception{
MemberOrderPageVo memberOrderPageVo = listMemberOrderPage(memberOrderFindDTO);
List<MemberOrderBo> memberOrderBoList = memberOrderPageVo.getMemberOrderPage().getData();
MemberOrderStatisticsBo memberOrderStatisticsBo = memberOrderPageVo.getMemberOrderStatisticsBo();
FileOutputStream fileOutputStream = new FileOutputStream("ts.xlsx");
ExcelExport excelExport = new ExcelExport();
Workbook workbook = excelExport.getWorkbook();
Sheet sheet = workbook.createSheet();
CellStyle cellStyleHeader01 = workbook.createCellStyle();
cellStyleHeader01.setAlignment(HorizontalAlignment.CENTER);
sheet.autoSizeColumn(9);
XSSFWorkbook hssfWorkbook = new XSSFWorkbook();
XSSFSheet sheet = hssfWorkbook.createSheet(name+"会员订单列表");
CellStyle headerCellStyle = createHeaderCellStyle(hssfWorkbook);
CellStyle generalCellStyle = createGeneralCellStyle(hssfWorkbook);
Row row1 = sheet.createRow(0);
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("YYYYMMddHHmmss");
createHeader(row1,0,new String[]{dateTimeFormatter.format(LocalDateTime.now())+"会员订单列表"},cellStyleHeader01);
createHeader(row1,0,new String[]{name+"会员订单列表"},headerCellStyle);
CellRangeAddress cellRangeAddress = new CellRangeAddress(0,0,0,11);
sheet.addMergedRegion(cellRangeAddress);
Row row2 = sheet.createRow(1);
Cell row2_cell1 = row2.createCell(0);
row2_cell1.setCellValue("统计");
row2_cell1.setCellStyle(cellStyleHeader01);
row2_cell1.setCellStyle(headerCellStyle);
CellRangeAddress cellRangeAddress2 = new CellRangeAddress(1,2,0,0);
sheet.addMergedRegion(cellRangeAddress2);
String[] header2 = new String[]{"会员订单总数(单)","会员订单总额(元)","钻石会员订单(单)","钻石会员订单总额(元)","黄金会员订单(单)","黄金会员订单总额(元)","普通会员订单(单)","普通会员订单总额(元)"};
createHeader(row2,1,header2,cellStyleHeader01);
createHeader(row2,1,header2,headerCellStyle);
String[] countData = getData(memberOrderStatisticsBo);
Row row4 = sheet.createRow(2);
createCellCount(row4,1,countData,cellStyleHeader01);
createCellCount(row4,1,countData,generalCellStyle);
Row row5 = sheet.createRow(4);
String[] header3 = new String[]{"订单号","创建时间","订单状态","名称","用户姓名","手机号","上级姓名/手机号","促成人姓名/手机号","订单价格(元)","优惠金额(元)","实付金额(元)","支付时间"};
CellRangeAddress cellRangeAddress3 = new CellRangeAddress(3,3,0,header3.length);
sheet.addMergedRegion(cellRangeAddress3);
createHeader(row5,0,header3,cellStyleHeader01);
createHeader(row5,0,header3,headerCellStyle);
workbook.write(fileOutputStream);
fileOutputStream.close();
workbook.close();
for(int i=0;i<header3.length;i++){
sheet.setColumnWidth(i,24*256);
}
List<String[]> orderDataList = getMemberOrderDataList(memberOrderBoList, 12);
createMemberOrderCellData(sheet,5,generalCellStyle,orderDataList);
hssfWorkbook.write(outputStream);
hssfWorkbook.close();
}
private List<String[]> getMemberOrderDataList(List<MemberOrderBo> memberOrderBoList,Integer size){
List<String[]> memerOrderData = new ArrayList<>();
String[] data = null;
String[] data;
for (MemberOrderBo memberOrderBo : memberOrderBoList) {
data = new String[size];
data[0]=memberOrderBo.getOrderNo();
data[1]=simleFormatter.format(memberOrderBo.getCreatTime());
data[2]=memberOrderBo.getStatus()==2?"取消":memberOrderBo.getStatus()==3?"待支付":memberOrderBo.getStatus()==6?"已完成":"";
data[3]=memberOrderBo.getName();
data[4]=memberOrderBo.getUserName();
data[5]=memberOrderBo.getPhone()==null?"":memberOrderBo.getPhone();
data[6]=String.format("%s/%s",memberOrderBo.getLeaderName()==null?"":memberOrderBo.getLeaderName(),memberOrderBo.getLeaderPhone()==null?"":memberOrderBo.getLeaderPhone());
data[7]=String.format("%s/%s",memberOrderBo.getFacilitateName()==null?"":memberOrderBo.getFacilitateName(),memberOrderBo.getFacilitatePhone()==null?"":memberOrderBo.getFacilitatePhone());
data[8]=memberOrderBo.getOrderAmount().toString();
data[9]=memberOrderBo.getCouponAmount().toString();
data[10]=memberOrderBo.getRealAmount().toString();
data[11]=memberOrderBo.getPayTime()==null?"":simleFormatter.format(new Date(memberOrderBo.getPayTime()));
memerOrderData.add(data);
}
return null;
return memerOrderData;
}
private CellStyle createGeneralCellStyle(XSSFWorkbook hssfWorkbook){
CellStyle cellStyleGeneral = createHeaderCellStyle(hssfWorkbook);
cellStyleGeneral.setWrapText(true);
XSSFFont generalFont = createFont(hssfWorkbook);
generalFont.setBold(false);
cellStyleGeneral.setFont(generalFont);
return cellStyleGeneral;
}
private CellStyle createHeaderCellStyle(XSSFWorkbook hssfWorkbook){
XSSFCellStyle cellStyleHeader = hssfWorkbook.createCellStyle();
cellStyleHeader.setAlignment(HorizontalAlignment.CENTER);
cellStyleHeader.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyleHeader.setLocked(false);
XSSFFont headerFont = createFont(hssfWorkbook);
cellStyleHeader.setFont(headerFont);
return cellStyleHeader;
}
private XSSFFont createFont(XSSFWorkbook hssfWorkbook){
XSSFFont font = hssfWorkbook.createFont();
font.setFontName("黑体");
font.setBold(true);
return font;
}
private String[] getData(MemberOrderStatisticsBo memberOrderStatisticsBo){
......@@ -270,11 +310,18 @@ public class OrderMemberService extends AbstractOrderHandle<OrderMemberDetailBiz
}
}
private void createMemberOrderCellData(Sheet sheet,int startRowIndex,CellStyle cellStyle,List<String[]> memberOrderList){
for (String[] data : memberOrderList) {
Row row = sheet.createRow(startRowIndex++);
createCellCount(row,0,data,cellStyle);
}
}
private void createCellCount(Row row,int CellStartIndex,String[] data,CellStyle cellStyle){
for(int i=CellStartIndex,y=0;y<data.length;i++,y++){
Cell cell = row.createCell(i);
cell.setCellValue(Objects.toString(data[y]));
cell.setCellStyle(cellStyle);
cell.setCellValue(data[y]);
}
}
......
package com.xxfc.platform.universal.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 解析出的身份证信息
* @author Administrator
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class IDCardInformation {
/**
* 住址
*/
private String address;
/**
* 出生年月日(yyyyMMdd格式)
*/
private String birthday;
/**
* 姓名
*/
private String name;
/**
* 证件号
*/
private String code;
/**
* 性别
*/
private String sex;
/**
* 民族
*/
private String nation;
/**
* 证件签发机构
*/
private String issue;
/**
* 签发时间
*/
private String issueDate;
/**
*失效时间
*/
private String expiryDate;
}
package com.xxfc.platform.universal.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
/**
* 订单支付
......@@ -45,6 +48,10 @@ public class OrderPay implements Serializable {
@ApiModelProperty(value = "1:微信公众号支付 2.支付宝即时到账,3,银联")
private Integer payWay;
@Column(name = "pay_type")
@ApiModelProperty(value = "1:支付宝APP支付,2:支付宝预授权支付")
private Integer payType;
//渠道:1-租车;2-旅游
@Column(name = "channel")
@ApiModelProperty(value = "渠道:1-租车;2-旅游")
......
......@@ -4,10 +4,6 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
/**
......@@ -69,5 +65,11 @@ public class OrderPayVo{
private String tradeNo;
//支付接口返回的流水号
@Column(name = "serial_number")
@ApiModelProperty(value = "支付接口返回的流水号")
private String serialNumber;
@ApiModelProperty(value = "1:支付宝APP支付,2:支付宝预授权支付")
private Integer payType;
}
......@@ -8,6 +8,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
/**
......@@ -37,5 +38,12 @@ public class OrderRefundVo{
@ApiModelProperty(value = "退款描述")
private String refundDesc;
//冻结转支付描述 只用于预支付相关
@ApiModelProperty(value = "冻结转支付描述")
private String freeze2PayDesc;
//冻结转支付金额 只用于预支付相关
@ApiModelProperty(value = "冻结转支付金额")
private Integer freeze2PayAmount;
}
......@@ -5,7 +5,6 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import com.xxfc.platform.universal.entity.Dictionary;
import com.xxfc.platform.universal.entity.OrderPay;
import com.xxfc.platform.universal.entity.OrderRefund;
import com.xxfc.platform.universal.mapper.OrderRefundMapper;
......@@ -21,10 +20,6 @@ import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
import java.util.Map;
import static com.xxfc.platform.universal.constant.DictionaryKey.PAY_DEMOTION;
import static com.xxfc.platform.universal.constant.DictionaryKey.UNIVERSAL_PAY;
/**
* 订单支付退款表
......@@ -59,17 +54,17 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper, OrderRefund> {
Integer refundAmount = orderRefundVo.getRefundAmount();
//临时处理
Map<String, Dictionary> dictionaryMap = dictionaryBiz.getAll4Map();
Integer demotion = Integer.valueOf(dictionaryMap.get(UNIVERSAL_PAY + "_" + PAY_DEMOTION).getDetail());
payAmount = payAmount / demotion;
if (payAmount <= 0) {
payAmount = 1;
}
refundAmount = refundAmount / demotion;
if (refundAmount <= 0) {
refundAmount = 1;
}
// Map<String, Dictionary> dictionaryMap = dictionaryBiz.getAll4Map();
// Integer demotion = Integer.valueOf(dictionaryMap.get(UNIVERSAL_PAY + "_" + PAY_DEMOTION).getDetail());
// payAmount = payAmount / demotion;
// if (payAmount <= 0) {
// payAmount = 1;
// }
//
// refundAmount = refundAmount / demotion;
// if (refundAmount <= 0) {
// refundAmount = 1;
// }
String refundDesc = StringUtils.isNotBlank(orderRefundVo.getRefundDesc()) ? orderRefundVo.getRefundDesc() : "审核通过,退款";
String out_refund_no = Snowflake.build() + "";
......@@ -89,9 +84,19 @@ public class OrderRefundBiz extends BaseBiz<OrderRefundMapper, OrderRefund> {
OrderPay orderPay = list.get(0);
String out_trade_no = orderPay.getTradeNo();
boolean flag = false;
if (orderPay.getPayWay() == 2) {
log.info("======支付宝退款中===========");
if (orderPay.getPayWay() == 2 && orderPay.getPayType() == 1) {
log.info("======支付宝APP支付退款中===========");
flag = payBiz.alipayOrderRefund(out_trade_no, orderPay.getSerialNumber(), refundAmount, refundDesc, out_trade_no + System.currentTimeMillis());
} else if (orderPay.getPayWay() == 2 && orderPay.getPayType() == 2) {
log.info("======支付宝预授权支付退款中===========");
//需要根据实际传过来的参数类型来进行解冻或者预授权转支付
if (orderRefundVo.getRefundAmount() != 0) { //解冻金额
flag = payBiz.fundAuthOrderUnFreeze(orderPay.getTradeNo() + System.currentTimeMillis(), orderPay.getSerialNumber(), orderRefundVo.getRefundAmount(), orderRefundVo.getRefundDesc());
}
//预授权转支付
if(orderRefundVo.getFreeze2PayAmount() != 0) {
flag = payBiz.tradePay(orderPay.getTradeNo() + System.currentTimeMillis(), orderPay.getSerialNumber(), orderRefundVo.getFreeze2PayAmount(), orderRefundVo.getFreeze2PayDesc(), orderRefundVo.getFreeze2PayDesc());
}
} else if(orderPay.getPayWay() == 1){
log.info("======微信退款中===========");
flag = WxPayRefundUtils.refund(appid, mchId, partnerKey, out_trade_no, out_refund_no, payAmount + "",
......
package com.xxfc.platform.universal.service.PictureParsing;
import com.xxfc.platform.universal.entity.IDCardInformation;
/**
* @author Administrator
*/
public interface UserPictureParsing {
IDCardInformation analysis(String front ,String back);
}
package com.xxfc.platform.universal.service.PictureParsing.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.xxfc.platform.universal.entity.IDCardInformation;
import com.xxfc.platform.universal.service.PictureParsing.UserPictureParsing;
import com.xxfc.platform.universal.utils.CertifHttpUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* 调用四川涪擎图片解析接口
*
* @author Administrator
*/
@Service
@Slf4j
public class XCFQPictureParsingImpl implements UserPictureParsing {
// private String appcode = "acea1c8811f748b3a65815f11db357c4";
private String appcode2 = "ee7710ce92054cae9f6c040f6864e6a7";
/**
* 认证相关的数据
*/
private String host = "https://ocridcards.market.alicloudapi.com";
private String path = "/idimages";
private String method = "POST";
private String dataNam = "result";
/**
* 照片解析
*
* @param frontImage 正面照片
* @param backImage 反面照片
* @return
*/
@Override
public IDCardInformation analysis(String frontImage, String backImage) {
Map<String,String> front = judgeAccordingToAnalyticalData(frontImage, "front");
if (MapUtils.isEmpty(front)) {
log.error("正面解析失败,请重新上传");
throw new BaseException("正面解析失败,请重新上传");
}
Map<String,String> back = judgeAccordingToAnalyticalData(backImage, "back");
if (MapUtils.isEmpty(back)) {
log.error("反面解析失败,请重新上传");
throw new BaseException("反面解析失败,请重新上传");
}
return new IDCardInformation(
front.get("address"),
front.get("birthday"),
front.get("name"),
front.get("code"),
front.get("sex"),
front.get("nation"),
back.get("issue"),
back.get("issueDate"),
back.get("expiryDate"));
}
private Map<String,String> judgeAccordingToAnalyticalData(String imageUrl, String type) {
String json = imageParse(imageUrl);
log.info("json:" + json);
if (StringUtils.isBlank(json)) {
return null;
}
Map reuslt = (Map) JSONObject.parse(json);
//判断是否调用图片解析的接口是否异常,若果两个次认证都没结果
if ("front".equals(type)) {
if (MapUtil.isEmpty(reuslt)
|| !(reuslt.get("code").equals("1"))
) {
return null;
}
}
if ("back".equals(type)) {
if (MapUtil.isEmpty(reuslt)
|| !(reuslt.get("code").equals("2"))
) {
return null;
}
}
Map<String,String> map = (Map) reuslt.get(dataNam);
log.info("map:" + map);
if (MapUtils.isNotEmpty(map)) {
return map;
}
return null;
}
//身份证照片解析
private String imageParse(String imageUrl) {
Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "APPCODE " + appcode2);
Map<String, String> querys = new HashMap<String, String>();
Map<String, String> bodys = new HashMap<String, String>();
bodys.put("image", imageUrl);
try {
return callExternalRequest(headers,querys,bodys,1);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private String callExternalRequest(Map<String, String> headers,
Map<String, String> querys,
Map<String, String> bodys,
int type) throws Exception {
HttpResponse response = CertifHttpUtils.doPost(host, path, method, headers, querys, bodys);
log.info("response:"+response);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
/**
* 状态码: 200 正常;400 URL无效;401 appCode错误; 403 次数用完; 500 API网管错误
*/
log.info("外部接口响应状态码:"+statusCode);
//获取response的body
if (statusCode == 200) {
return EntityUtils.toString(response.getEntity());
}
if (403==statusCode){
log.error("验证次数已用完");
}
return null;
}
}
......@@ -28,16 +28,17 @@ import java.util.Map;
@Primary
public class XCFQAuthentication implements UserAuthentication {
private String cAppcode="acea1c8811f748b3a65815f11db357c4";
// private String appcode="acea1c8811f748b3a65815f11db357c4";
private String appcode2 = "ee7710ce92054cae9f6c040f6864e6a7";
/**
* 认证相关的数据
*/
private String cHost = "https://idcert.market.alicloudapi.com";
private String hsot = "https://idcert.market.alicloudapi.com";
private String cPath = "/idcard";
private String path = "/idcard";
private String cMethod = "GET";
private String method = "GET";
//响应:认证错误码字段名
private String certifRet = "status";
......@@ -53,37 +54,51 @@ public class XCFQAuthentication implements UserAuthentication {
@Override
public boolean certificate(UserMessage message) {
Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "APPCODE " + appcode2);
try {
return callExternalRequest(message, headers, 1);
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
private boolean callExternalRequest(UserMessage message, Map<String, String> headers, int type) throws Exception {
//map携带身份证和姓名进行认证
Map<String, String> querys = new HashMap<>();
querys.put(idCardName, message.getIdNumber());
querys.put(cName, message.getName());
Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "APPCODE " + cAppcode);
try {
log.info("----querys=========" + querys);
HttpResponse response = HttpUtils.doGet(cHost, cPath, cMethod, headers, querys);
HttpResponse response = HttpUtils.doGet(hsot, path, method, headers, querys);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
/**
* 状态码: 200 正常;400 URL无效;401 appCode错误; 403 次数用完; 500 API网管错误
*/
log.info("外部接口响应状态码:"+statusCode);
log.info("外部接口响应状态码:" + statusCode);
//获取response的body
if (statusCode == 200) {
String result = EntityUtils.toString(response.getEntity());
log.info("----认证结果result=========" + result);
//认证返回的参数是否为空
if (!StringUtils.isBlank(result)) {
Map<String, Object> map = (Map<String, Object>) JSONObject.parse(result);
log.info("----certifRet=========" + certifRet);
if (MapUtil.isNotEmpty(map) || certifResultCode.equals(map.get(certifRet))) {
Map<String,String> map = (Map<String, String>) JSONObject.parse(result);
log.info("----响应数据=========" + map);
if (MapUtil.isNotEmpty(map) && certifResultCode.equals(map.get("status"))) {
log.info("认证成功");
return true;
}
}
}
} catch (Exception e) {
e.printStackTrace();
if (403 == statusCode) {
log.error("验证次数已用完");
}
return false;
}
}
......@@ -17,7 +17,6 @@
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
......
......@@ -64,11 +64,17 @@ public class Vehicle {
*/
private Integer insuranceCompany;
private Integer strongInsuranceCompany;
/**
* 保险单号
*/
private String insuranceNo;
/**
* 强险单号
*/
private String strongInsuranceNo;
/**
* 保险开始时间
......@@ -80,6 +86,11 @@ public class Vehicle {
*/
private Date insuranceEndDate;
/**
* 强险的结束时间
*/
private Date strongInsuranceEndDate;
/**
* 年审时间
*/
......@@ -151,6 +162,24 @@ public class Vehicle {
@Column(name = "travel_status")
private Integer travelStatus;
/**
* 终端号
*/
@Column(name = "terminal_number")
private String terminalNumber;
/**
* SIM卡号
*/
@Column(name = "sim_number")
private String simNumber;
/**
* 通讯类型
*/
@Column(name = "communication_type")
private String communicationType;
/**
* 是否删除;0-正常;1-删除
*/
......
......@@ -68,12 +68,14 @@ public class AddOrUpdateVehicleVo {
* 保险公司,见常量表
*/
private Integer insuranceCompany;
private Integer strongInsuranceCompany;
/**
* 保险单号
*/
private String insuranceNo;
private String strongInsuranceNo;
/**
* 保险开始时间
......@@ -84,6 +86,7 @@ public class AddOrUpdateVehicleVo {
* 保险结束时间
*/
private Date insuranceEndDate;
private Date strongInsuranceEndDate;
/**
* 年审时间
......
......@@ -26,6 +26,12 @@ public class ResultVehicleVo {
*/
private String numberPlate;
/**
* 车型
*/
private String vehicleType;
/**
* 品牌(编码,对应关系见相关常量),0-未填写
*/
......@@ -49,6 +55,8 @@ public class ResultVehicleVo {
*/
private String parkBranchCompanyName;
/**
* 目的地分支机构(id)
*/
......@@ -64,6 +72,12 @@ public class ResultVehicleVo {
*/
private Integer useType;
/**
* 用途名称
*/
private String useTypeName;
/**
* 备注信息
*/
......
package com.xxfc.platform.vehicle.pojo;
import lombok.Data;
@Data
public class VehicleExcelVo {
/**
* 车牌号,空字符串-没有
*/
private String numberPlate;
/**
* 车辆编号,0-没有
*/
private Integer code;
/**
* 车型
*/
private String vehicleType;
/**
* 用途名称
*/
private String useTypeName;
/**
* 停靠分支机构(名)
*/
private String parkBranchCompanyName;
}
......@@ -138,4 +138,6 @@ public class VehiclePageQueryVo {
*/
private Integer modelId;
}
......@@ -85,8 +85,12 @@ public class VehicleActiveService {
// 写入车辆公里数,预计目的地
vehicle.setMileageLastUpdate(MileageLift1);
// 修改车辆状态,确认是空闲状态
int result = vehicleMapper.updateStatusByIdAndStatus(departureVo.getVehicleId(), VehicleStatus.DEPARTURE.getCode(),
VehicleStatus.NORMAL.getCode());
if (vehicle.getStatus().equals(VehicleStatus.NORMAL.getCode())) {
vehicle.setStatus(VehicleStatus.DEPARTURE.getCode());
}
vehicleMapper.updateByPrimaryKeySelective(vehicle);
//修改预约记录状态
VehicleBookRecord vehicleBookRecord = null;
......@@ -211,7 +215,10 @@ public class VehicleActiveService {
}
// 写入车辆公里数,还车分公司id
vehicle.setMileageLastUpdate(MileageRest1);
vehicleMapper.updateByPrimaryKeySelective(vehicle);
if (vehicleBookRecord != null) {
vehicle.setParkBranchCompanyId(vehicleBookRecord.getRetCompany());
}
// 出车记录
VehicleDepartureLogVo departureLogVo = vehicleDepartureLogMapper.selectByBookRecordId(arrivalVo.getBookRecordId());
......@@ -230,13 +237,13 @@ public class VehicleActiveService {
}
}
if (flag) { //如果此条记录后面还有未收车记录,就不修改车辆状态
int result = vehicleMapper.updateStatus(arrivalVo.getVehicleId(), VehicleStatus.NORMAL.getCode());
// if (result == 0) {
vehicle.setStatus(VehicleStatus.NORMAL.getCode());
// if (result == 0) {
// throw new BaseException(ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getDesc(),
// ResCode.VEHICLE_DEPARTURE_VEHICLE_UNDEPARTURE.getCode());
// }
}
vehicleMapper.updateByPrimaryKeySelective(vehicle);
DateTime arrivalDate = new DateTime(vehicleBookRecord.getBookEndDate());
DateTime actualArrivalDate = new DateTime(new Date());
//提前还车处理
......
......@@ -1173,7 +1173,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
public PageDataVO<UsableVehicleModelVO> searchUsableModel(UsableVeicleDTO dto) {
Map<String, Object> params = BeanUtil.beanToMap(dto);
if (StrUtil.isNotBlank(dto.getStartDate()) && StrUtil.isNotBlank(dto.getEndDate())) {
initBookSearchParam(dto, params, Boolean.TRUE);
initBookSearchParam(dto, params, Boolean.FALSE);
}
return PageDataVO.pageInfo(dto.getPage(), dto.getLimit(), () -> mapper.searchUsableModel(params));
}
......@@ -1233,10 +1233,10 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
List<String> notBookedDates = Lists.newArrayList();
if (StringUtils.isNotBlank(dto.getBookEndDate()) &&
StringUtils.isNotBlank(dto.getBookEndDate())) {
// notBookedDates = convertDatePeriod2List(dto.getBookStartDate(),
// dto.getBookEndDate());
notBookedDates = convertDatePeriod2List(dto.getStartDateExtend(),
dto.getEndDateExtend());
notBookedDates = convertDatePeriod2List(dto.getBookStartDate(),
dto.getBookEndDate());
// notBookedDates = convertDatePeriod2List(dto.getStartDateExtend(),
// dto.getEndDateExtend());
}
//若传入预定信息查询条件,则查询对应月份预定信息查询条件(不超过3个月)
......
package com.xxfc.platform.vehicle.biz;
import com.alibaba.fastjson.JSON;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.google.common.collect.Lists;
import com.xxfc.platform.vehicle.entity.Vehicle;
import com.xxfc.platform.vehicle.mapper.VehicleMapper;
import com.xxfc.platform.vehicle.pojo.ResultVehicleVo;
import com.xxfc.platform.vehicle.pojo.VehicleExcelVo;
import com.xxfc.platform.vehicle.pojo.VehiclePageQueryVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@Service
@Slf4j
public class VehicleInformationDownloadBiz extends BaseBiz<VehicleMapper, Vehicle> {
@Autowired
private VehicleBiz vehicleBiz;
public List getByPageNotAllData(VehiclePageQueryVo vehiclePageQueryVo, List<Integer> companyList) throws Exception {
Map<String, Object> params = PropertyUtils.describe(vehiclePageQueryVo);
//处理预定日期相关参数
vehicleBiz.adjustBookedInfoParam(params, vehiclePageQueryVo);
if (companyList != null && companyList.size() > 0) {
params.put("companyList", companyList);
} else {
params.put("companyList", Arrays.asList(-1));
}
return mapper.getByPageNotAllData(params);
}
public List getByPage(VehiclePageQueryVo vehiclePageQueryVo) throws Exception {
Map<String, Object> params = PropertyUtils.describe(vehiclePageQueryVo);
//处理预定日期相关参数
vehicleBiz.adjustBookedInfoParam(params, vehiclePageQueryVo);
params.get("yearMonthAndParam");
if (vehiclePageQueryVo.getModelId() == null) {
params.remove("modelId");
}
return mapper.getByPage(params);
}
//getResultVehicleVoList
public List<ResultVehicleVo> getResultVehicleVoList(String vehiclePageQueryVoJson, UserDTO userDTO) {
VehiclePageQueryVo vehiclePageQueryVo = new VehiclePageQueryVo();
try {
if (StringUtils.isNotBlank(vehiclePageQueryVoJson)){
vehiclePageQueryVo = JSON.parseObject(vehiclePageQueryVoJson, VehiclePageQueryVo.class);
}
if (userDTO.getDataAll() == 2) {
List<Integer> companyList = vehicleBiz.dataCompany(userDTO.getDataZone(), userDTO.getDataCompany());
return getByPageNotAllData(vehiclePageQueryVo, companyList);
}
return getByPage(vehiclePageQueryVo);
} catch (Exception e) {
e.printStackTrace();
}
return new ArrayList();
}
public List<VehicleExcelVo> getList(String vehiclePageQueryVoJson, UserDTO userDTO) throws Exception {
List<ResultVehicleVo> resultVehicleVoList = getResultVehicleVoList(vehiclePageQueryVoJson, userDTO);
ArrayList<VehicleExcelVo> arrayList = Lists.newArrayList();
resultVehicleVoList.parallelStream().forEach(result->{
try {
VehicleExcelVo vehicleExcelVo = new VehicleExcelVo();
BeanUtilsBean.getInstance().copyProperties(vehicleExcelVo,result);
arrayList.add(vehicleExcelVo);
} catch (Exception e) {
log.error(e.getMessage());
e.printStackTrace();
}
});
return arrayList;
}
}
......@@ -16,6 +16,8 @@ public interface VehicleMapper extends Mapper<Vehicle> {
public List<ResultVehicleVo> getByPageNotAllData(Map<String, Object> params);
public int updateStatusById(Map<String, Object> params);
/**
......
package com.xxfc.platform.vehicle.rest.admin;
import cn.hutool.core.io.IoUtil;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.admin.feign.dto.UserDTO;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.xxfc.platform.vehicle.biz.VehicleBiz;
import com.xxfc.platform.vehicle.biz.VehicleInformationDownloadBiz;
import com.xxfc.platform.vehicle.common.BaseController;
import com.xxfc.platform.vehicle.pojo.VehicleExcelVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@RestController
@RequestMapping("VehicleInformationDownload")
@Slf4j
public class VehicleInformationDownloadController extends BaseController<VehicleInformationDownloadBiz> {
@Autowired
UserFeign userFeign;
@Autowired
private UserAuthConfig userAuthConfig;
@Autowired
private VehicleBiz vehicleBiz;
@Autowired
HttpServletResponse response;
@GetMapping("/excel")
public void downloadExcel(@RequestParam(value = "vehiclePageQueryVoJson",required = false) String vehiclePageQueryVoJson) throws Exception {
UserDTO userDTO = userFeign.userinfoByToken(userAuthConfig.getToken(request)).getData();
if (userDTO==null) {
throw new BaseException("token已失效");
}
List<VehicleExcelVo> rows = baseBiz.getList(vehiclePageQueryVoJson, userDTO);
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.addHeaderAlias("numberPlate", "车牌号");
writer.addHeaderAlias("code", "车辆编码");
writer.addHeaderAlias("vehicleType", "车型");
writer.addHeaderAlias("useTypeName", "用途");
writer.addHeaderAlias("parkBranchCompanyName", "停靠分公司");
// 一次性写出内容,使用默认样式,强制输出标题
writer.write(rows, true);
//response为HttpServletResponse对象
response.setContentType("application/vnd.ms-excel;charset=utf-8");
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
response.setHeader("Content-Disposition", "attachment;filename=clxx.xlsx");
//out为OutputStream,需要写出到的目标流
ServletOutputStream out = response.getOutputStream();
writer.flush(out, true);
// 关闭writer,释放内存
writer.close();
//此处记得关闭输出Servlet流
IoUtil.close(out);
}
}
......@@ -31,7 +31,7 @@
from branch_company
<where>
<if test="addrCity != null">
and addr_city = #{addrCity}
and (addr_city = #{addrCity} or addr_province = #{addrCity} or addr_town = #{addrCity})
</if>
<if test="lon != null and lat != null">
and longitude is not null and latitude is not null
......
......@@ -487,7 +487,7 @@
and (v3.number_plate like concat('%', #{keywords}, '%') or v3.code like concat('%', #{keywords}, '%'))
</if>
<if test="zoneId != null">
and bc3.zone_id = #{zoneId}
and bc1.zone_id = #{zoneId}
</if>
<if test="companyIds != null and companyIds.size > 0">
and (v1.lift_company in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment