1.优化
This commit is contained in:
		
							parent
							
								
									483a1e2595
								
							
						
					
					
						commit
						f3567b07aa
					
				| 
						 | 
					@ -171,7 +171,6 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
            Transaction transaction = checkAndParse(request, body, Transaction.class);
 | 
					            Transaction transaction = checkAndParse(request, body, Transaction.class);
 | 
				
			||||||
            if (Transaction.TradeStateEnum.SUCCESS.equals(transaction.getTradeState())) {
 | 
					            if (Transaction.TradeStateEnum.SUCCESS.equals(transaction.getTradeState())) {
 | 
				
			||||||
                // 充值成功后的业务处理
 | 
					                // 充值成功后的业务处理
 | 
				
			||||||
//                logger.info("【微信支付回调】交易对象(验签后) : " + JSON.toJSONString(transaction));
 | 
					 | 
				
			||||||
                etCallbackLog.setBody(JSON.toJSONString(transaction));
 | 
					                etCallbackLog.setBody(JSON.toJSONString(transaction));
 | 
				
			||||||
                AttachVo attachVo = JSONObject.parseObject(transaction.getAttach(),AttachVo.class);
 | 
					                AttachVo attachVo = JSONObject.parseObject(transaction.getAttach(),AttachVo.class);
 | 
				
			||||||
                businessHandle(transaction.getOutTradeNo(), attachVo, ServiceConstants.PAY_TYPE_WX);//业务处理
 | 
					                businessHandle(transaction.getOutTradeNo(), attachVo, ServiceConstants.PAY_TYPE_WX);//业务处理
 | 
				
			||||||
| 
						 | 
					@ -186,7 +185,10 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
    public void businessHandle(String outTradeNo,AttachVo attachVo,String payType) {
 | 
					    public void businessHandle(String outTradeNo,AttachVo attachVo,String payType) {
 | 
				
			||||||
        // 充值成功后的业务处理
 | 
					        // 充值成功后的业务处理
 | 
				
			||||||
        EtOrder order = orderService.selectEtOrderByOutTradeNo(outTradeNo);
 | 
					        EtOrder order = orderService.selectEtOrderByOutTradeNo(outTradeNo);
 | 
				
			||||||
 | 
					        EtOrder order1 = new EtOrder();
 | 
				
			||||||
 | 
					        order1.setOrderId(order.getOrderId());
 | 
				
			||||||
        logger.info("【微信支付回调】订单信息 : " + JSON.toJSONString(order));
 | 
					        logger.info("【微信支付回调】订单信息 : " + JSON.toJSONString(order));
 | 
				
			||||||
 | 
					        logger.info("【微信支付回调】========== orderId : " + order.getOrderId());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        AsUser asUser = asUserMapper.selectUserById(order.getUserId());
 | 
					        AsUser asUser = asUserMapper.selectUserById(order.getUserId());
 | 
				
			||||||
        /** 支付回调逻辑  1. 处理预约还是开锁  电压 */
 | 
					        /** 支付回调逻辑  1. 处理预约还是开锁  电压 */
 | 
				
			||||||
| 
						 | 
					@ -198,11 +200,11 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
            logger.info("【微信支付回调】骑行支付");
 | 
					            logger.info("【微信支付回调】骑行支付");
 | 
				
			||||||
            // 1-骑行支付  关锁
 | 
					            // 1-骑行支付  关锁
 | 
				
			||||||
            EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(order.getAreaId());
 | 
					            EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(order.getAreaId());
 | 
				
			||||||
            order.setMark("骑行支付");
 | 
					            order1.setMark("骑行支付");
 | 
				
			||||||
            logger.info("=================【微信支付回调】11111111==================");
 | 
					            logger.info("=================【微信支付回调】11111111==================");
 | 
				
			||||||
            if(ServiceConstants.RETURN_VERIFY_YES.equals(area.getReturnVerify())){
 | 
					            if(ServiceConstants.RETURN_VERIFY_YES.equals(area.getReturnVerify())){
 | 
				
			||||||
                logger.info("【微信支付回调】还车-----需要-----拍照审核");
 | 
					                logger.info("【微信支付回调】还车-----需要-----拍照审核");
 | 
				
			||||||
                order.setStatus(ServiceConstants.ORDER_STATUS_TO_BE_AUDIT);//如果还车需要拍照审核,状态为待审核
 | 
					                order1.setStatus(ServiceConstants.ORDER_STATUS_TO_BE_AUDIT);//如果还车需要拍照审核,状态为待审核
 | 
				
			||||||
                BigDecimal amount = order.getPayFee();
 | 
					                BigDecimal amount = order.getPayFee();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // 异步处理短信
 | 
					                // 异步处理短信
 | 
				
			||||||
| 
						 | 
					@ -211,7 +213,7 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }else{
 | 
					            }else{
 | 
				
			||||||
                logger.info("【微信支付回调】还车-----不需要-----拍照审核");
 | 
					                logger.info("【微信支付回调】还车-----不需要-----拍照审核");
 | 
				
			||||||
                order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
 | 
					                order1.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
 | 
				
			||||||
                // 还车结算___小时后自动退押金---创建一个定时器TimerTask,计算出退还时间后,执行退款操作
 | 
					                // 还车结算___小时后自动退押金---创建一个定时器TimerTask,计算出退还时间后,执行退款操作
 | 
				
			||||||
                logger.info("=================【微信支付回调】22222222==================");
 | 
					                logger.info("=================【微信支付回调】22222222==================");
 | 
				
			||||||
                // 退还押金处理
 | 
					                // 退还押金处理
 | 
				
			||||||
| 
						 | 
					@ -227,32 +229,32 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
            // 新增资金流水记录
 | 
					            // 新增资金流水记录
 | 
				
			||||||
            EtCapitalFlow capitalFlow = capitalFlowRecords(order, ServiceConstants.FLOW_TYPE_INCOME, ServiceConstants.ORDER_TYPE_RIDING, ServiceConstants.OWNER_TYPE_OPERATOR, null, ServiceConstants.PAY_TYPE_WX);
 | 
					            EtCapitalFlow capitalFlow = capitalFlowRecords(order, ServiceConstants.FLOW_TYPE_INCOME, ServiceConstants.ORDER_TYPE_RIDING, ServiceConstants.OWNER_TYPE_OPERATOR, null, ServiceConstants.PAY_TYPE_WX);
 | 
				
			||||||
            logger.info("=================【骑行支付回调-新增资金流水记录后】=================={}",JSON.toJSON(capitalFlow));
 | 
					            logger.info("=================【骑行支付回调-新增资金流水记录后】=================={}",JSON.toJSON(capitalFlow));
 | 
				
			||||||
            order.setHandlingCharge(capitalFlow.getHandlingCharge());
 | 
					            order1.setHandlingCharge(capitalFlow.getHandlingCharge());
 | 
				
			||||||
            order.setPlatformServiceFee(capitalFlow.getPlatformServiceFee());
 | 
					            order1.setPlatformServiceFee(capitalFlow.getPlatformServiceFee());
 | 
				
			||||||
            order.setOperatorDividend(capitalFlow.getOperatorDividend());
 | 
					            order1.setOperatorDividend(capitalFlow.getOperatorDividend());
 | 
				
			||||||
            order.setCost(getCost(order.getPayFee()));
 | 
					            order1.setCost(getCost(order.getPayFee()));
 | 
				
			||||||
            logger.info("=================【微信支付回调】4444444==================");
 | 
					            logger.info("=================【微信支付回调】4444444==================");
 | 
				
			||||||
        }else if(attachVo.getType().equals(ServiceConstants.BUSINESS_TYPE_APPOINTMENT)){
 | 
					        }else if(attachVo.getType().equals(ServiceConstants.BUSINESS_TYPE_APPOINTMENT)){
 | 
				
			||||||
            logger.info("【微信支付回调】取消预约支付");
 | 
					            logger.info("【微信支付回调】取消预约支付");
 | 
				
			||||||
            // 2-取消预约支付
 | 
					            // 2-取消预约支付
 | 
				
			||||||
            order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
 | 
					            order1.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
 | 
				
			||||||
            order.setMark("取消预约支付");
 | 
					            order1.setMark("取消预约支付");
 | 
				
			||||||
            asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);//取消预约支付后车辆正常运营
 | 
					            asDevice.setStatus(ServiceConstants.VEHICLE_STATUS_NORMAL);//取消预约支付后车辆正常运营
 | 
				
			||||||
            asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
 | 
					            asDevice.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
 | 
				
			||||||
        }else if(attachVo.getType().equals(ServiceConstants.ORDER_TYPE_COUPON)){
 | 
					        }else if(attachVo.getType().equals(ServiceConstants.ORDER_TYPE_COUPON)){
 | 
				
			||||||
            /** 优惠券订单  */
 | 
					            /** 优惠券订单  */
 | 
				
			||||||
            logger.info("【微信支付回调】优惠券支付");
 | 
					            logger.info("【微信支付回调】优惠券支付");
 | 
				
			||||||
            // 3-优惠券支付
 | 
					            // 3-优惠券支付
 | 
				
			||||||
            order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
 | 
					            order1.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
 | 
				
			||||||
            order.setMark("优惠券支付");
 | 
					            order1.setMark("优惠券支付");
 | 
				
			||||||
            // 优惠券成功处理逻辑
 | 
					            // 优惠券成功处理逻辑
 | 
				
			||||||
            couponSuccessHandle(order);
 | 
					            couponSuccessHandle(order);
 | 
				
			||||||
        }else if(attachVo.getType().equals(ServiceConstants.BUSINESS_TYPE_DEPOSIT)){
 | 
					        }else if(attachVo.getType().equals(ServiceConstants.BUSINESS_TYPE_DEPOSIT)){
 | 
				
			||||||
            logger.info("【微信支付回调】押金支付");
 | 
					            logger.info("【微信支付回调】押金支付");
 | 
				
			||||||
            // 4-押金支付
 | 
					            // 4-押金支付
 | 
				
			||||||
            order.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
 | 
					            order1.setStatus(ServiceConstants.ORDER_STATUS_ORDER_END);
 | 
				
			||||||
            asUser.setBalance(order.getTotalFee());
 | 
					            asUser.setBalance(order.getTotalFee());
 | 
				
			||||||
            order.setMark("押金支付");
 | 
					            order1.setMark("押金支付");
 | 
				
			||||||
            // 删除用户缓存
 | 
					            // 删除用户缓存
 | 
				
			||||||
            String token = attachVo.getToken();
 | 
					            String token = attachVo.getToken();
 | 
				
			||||||
            logger.info("【微信支付回调】删除用户缓存:"+token);
 | 
					            logger.info("【微信支付回调】删除用户缓存:"+token);
 | 
				
			||||||
| 
						 | 
					@ -273,10 +275,10 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Boolean execute = transactionTemplate.execute(e -> {
 | 
					        Boolean execute = transactionTemplate.execute(e -> {
 | 
				
			||||||
            order.setPaid("1");
 | 
					            order1.setPaid("1");
 | 
				
			||||||
            order.setPayTime(DateUtils.getNowDate());
 | 
					            order1.setPayTime(DateUtils.getNowDate());
 | 
				
			||||||
            order.setPayType(payType);
 | 
					            order1.setPayType(payType);
 | 
				
			||||||
            order.setLocking("0");
 | 
					            order1.setLocking("0");
 | 
				
			||||||
            // 如果使用了优惠券则扣除一次使用次数
 | 
					            // 如果使用了优惠券则扣除一次使用次数
 | 
				
			||||||
            if(ObjectUtil.isNotNull(order.getLogId())){
 | 
					            if(ObjectUtil.isNotNull(order.getLogId())){
 | 
				
			||||||
                EtCouponUserLog couponUserLog = etCouponClaimLogMapper.selectEtCouponClaimLogByLogId(order.getLogId());
 | 
					                EtCouponUserLog couponUserLog = etCouponClaimLogMapper.selectEtCouponClaimLogByLogId(order.getLogId());
 | 
				
			||||||
| 
						 | 
					@ -287,8 +289,8 @@ public class CallbackServiceImpl implements CallbackService {
 | 
				
			||||||
                    logger.info("【微信支付回调】优惠券使用次数-1");
 | 
					                    logger.info("【微信支付回调】优惠券使用次数-1");
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            logger.info("=================【微信支付回调】开始更新订单信息=================={}",JSON.toJSON(order));
 | 
					            logger.info("=================【微信支付回调】开始更新订单信息=================={}",JSON.toJSON(order1));
 | 
				
			||||||
            int updateEtOrder = orderService.updateEtOrder(order);
 | 
					            int updateEtOrder = orderService.updateEtOrder(order1);
 | 
				
			||||||
            if(updateEtOrder==0){
 | 
					            if(updateEtOrder==0){
 | 
				
			||||||
                logger.error("【微信支付回调】更新订单信息失败");
 | 
					                logger.error("【微信支付回调】更新订单信息失败");
 | 
				
			||||||
                throw new ServiceException("【微信支付回调】更新订单信息失败");
 | 
					                throw new ServiceException("【微信支付回调】更新订单信息失败");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -91,9 +91,6 @@ public class EtOrderServiceImpl implements IEtOrderService
 | 
				
			||||||
    @Autowired
 | 
					    @Autowired
 | 
				
			||||||
    private IEtTripLogService etTripLogService;
 | 
					    private IEtTripLogService etTripLogService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Autowired
 | 
					 | 
				
			||||||
    private IEtDividendDetailService dividendDetailService;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Autowired
 | 
					    @Autowired
 | 
				
			||||||
    private CallbackService callbackService;
 | 
					    private CallbackService callbackService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -462,22 +459,6 @@ public class EtOrderServiceImpl implements IEtOrderService
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//    /**
 | 
					 | 
				
			||||||
//     * 获取当前正在骑行中的订单数量
 | 
					 | 
				
			||||||
//     * @param sn
 | 
					 | 
				
			||||||
//     * @return
 | 
					 | 
				
			||||||
//     */
 | 
					 | 
				
			||||||
//    @Override
 | 
					 | 
				
			||||||
//    public boolean getCurrentOrderNum(String sn) {
 | 
					 | 
				
			||||||
//        if(ObjectUtil.isNotNull(asDeviceMapper.selectAsDeviceBySn(sn))){
 | 
					 | 
				
			||||||
//            int currentOrderNum = etOrderMapper.getCurrentOrderNum(sn);
 | 
					 | 
				
			||||||
//            if(currentOrderNum > 0){
 | 
					 | 
				
			||||||
//                return true;
 | 
					 | 
				
			||||||
//            }
 | 
					 | 
				
			||||||
//        }
 | 
					 | 
				
			||||||
//        return false;
 | 
					 | 
				
			||||||
//    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 根据userId获取当前正在骑行中的订单
 | 
					     * 根据userId获取当前正在骑行中的订单
 | 
				
			||||||
     * @param userId
 | 
					     * @param userId
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user