yanderong
2026-07-11 1baa21c114f634b8ecc3af64efcfaab6a57a571e
UserYKDTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -5,6 +5,7 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.common.constant.state.BalanceChangeType;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.account.controller.AppOrderController;
import com.stylefeng.guns.modular.crossCity.dao.OrderCrossCityMapper;
@@ -115,6 +116,9 @@
    
    @Autowired
    private PayMoneyUtil payMoneyUtil;
    @Autowired
    private CbyzxOrderPayHelper cbyzxOrderPayHelper;
    
    @Resource
    private OrderPrivateCarMapper orderPrivateCarMapper;
@@ -462,7 +466,7 @@
        ///   新增预计送达时间
        if (ToolUtil.isNotEmpty(arriveTime)){
            orderLogistics.setArriveTimeExpect(com.stylefeng.guns.core.util.DateUtil.parseTime1(arriveTime));
            orderLogistics.setArriveTimeExpect(DateUtil.getDate(arriveTime, "yyyy-MM-dd HH:mm:ss"));
        }
        ///   生成取件码
@@ -651,9 +655,14 @@
        ResultUtil resultUtil = ResultUtil.success(new Object());
        if(payType == 1){//微信支付
            String app = type == 1 ? "APP" : "JSAPI";
            resultUtil = payMoneyUtil.weixinpay("小件物流下单支付", "", orderId + "_" + orderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5), orderMoney.toString(),  "/base/wxPayOrderTaxi", app, userInfo.getAppletsOpenId());
            paymentRecordService.saveData(1, orderLogistics.getUserId(), 1, orderId, orderLogistics.getType(), 1, orderMoney, "", 1);//添加预支付数据
            String outTradeNo = orderId + "_" + orderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5);
            JSONObject response = cbyzxOrderPayHelper.createOrder(orderLogistics.getUserId(), userInfo.getAppletsOpenId(), outTradeNo, orderMoney);
            if (!cbyzxOrderPayHelper.isCreateSuccess(response)) {
                return ResultUtil.error(cbyzxOrderPayHelper.extractMessage(response), response);
            }
            String paymentCode = ToolUtil.isNotEmpty(cbyzxOrderPayHelper.extractRecordCode(response)) ? cbyzxOrderPayHelper.extractRecordCode(response) : outTradeNo;
            resultUtil = ResultUtil.success(response);
            paymentRecordService.saveData(1, orderLogistics.getUserId(), 1, orderId, orderLogistics.getType(), 1, orderMoney, paymentCode, 1);//添加预支付数据
        }
        if(payType == 2){//支付宝支付
            resultUtil = payMoneyUtil.alipay("小件物流下单支付", "小件物流下单支付", "", orderId + "_" + orderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5), orderMoney.toString(), "/base/aliPayOrderTaxi");
@@ -663,7 +672,7 @@
            if(userInfo.getBalance() == null || userInfo.getBalance() < orderMoney){
                return ResultUtil.error("余额不足,无法完成支付", "");
            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
    
            OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
@@ -767,9 +776,14 @@
            if(orderMoney == 0){
                return ResultUtil.error("请使用余额支付");
            }
            String app = type == 1 ? "APP" : "JSAPI";
            resultUtil = payMoneyUtil.weixinpay("小件物流下单支付", "", orderId + "_" + orderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5), orderMoney.toString(),   "/base/wxPayOrderTaxi", app, userInfo.getAppletsOpenId());
            paymentRecordService.saveData(1, orderLogistics.getUserId(), 1, orderId, orderLogistics.getType(), 1, orderMoney, "", 1);//添加预支付数据
            String outTradeNo = orderId + "_" + orderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5);
            JSONObject response = cbyzxOrderPayHelper.createOrder(orderLogistics.getUserId(), userInfo.getAppletsOpenId(), outTradeNo, orderMoney);
            if (!cbyzxOrderPayHelper.isCreateSuccess(response)) {
                return ResultUtil.error(cbyzxOrderPayHelper.extractMessage(response), response);
            }
            String paymentCode = ToolUtil.isNotEmpty(cbyzxOrderPayHelper.extractRecordCode(response)) ? cbyzxOrderPayHelper.extractRecordCode(response) : outTradeNo;
            resultUtil = ResultUtil.success(response);
            paymentRecordService.saveData(1, orderLogistics.getUserId(), 1, orderId, orderLogistics.getType(), 1, orderMoney, paymentCode, 1);//添加预支付数据
        }
        if(payType == 2){//支付宝支付
            if(orderMoney == 0){
@@ -788,6 +802,7 @@
//                    return ResultUtil.error("电子余额不足,无法完成支付");
//                }
//            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
    
            OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
@@ -861,9 +876,15 @@
        ResultUtil resultUtil = ResultUtil.success(new Object());
        if(payType == 1){//微信支付
            String app = type == 1 ? "APP" : "JSAPI";
            resultUtil = payMoneyUtil.weixinpay("小件物流补差价", "", orderId + "_" + orderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5), orderMoney.toString(), "/base/wxPayOrderLogisticsSpread", app, userInfo.getAppletsOpenId());
            paymentRecordService.saveData(1, orderLogistics.getUserId(), 1, orderId, orderLogistics.getType(), 1, orderMoney, "", 1);//添加预支付数据
            String outTradeNo = "SPREAD_" + orderId + "_" + orderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5);
            JSONObject response = cbyzxOrderPayHelper.createOrder(orderLogistics.getUserId(), userInfo.getAppletsOpenId(), outTradeNo, orderMoney);
            if (!cbyzxOrderPayHelper.isCreateSuccess(response)) {
                return ResultUtil.error(cbyzxOrderPayHelper.extractMessage(response), response);
            }
            String recordCode = cbyzxOrderPayHelper.extractRecordCode(response);
            String paymentCode = ToolUtil.isNotEmpty(recordCode) ? recordCode : outTradeNo;
            paymentRecordService.saveData(1, orderLogistics.getUserId(), 1, orderId, orderLogistics.getType(), 1, orderMoney, paymentCode, 1);//添加预支付数据
            resultUtil = ResultUtil.success(response);
        }
        if(payType == 2){//支付宝支付
            resultUtil = payMoneyUtil.alipay("小件物流补差价", "小件物流补差价", "", orderId + "_" + orderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5), orderMoney.toString(), "/base/aliPayOrderLogisticsSpread");
@@ -877,7 +898,7 @@
//            if(resultUtil.getCode()==500){
//                return ResultUtil.error("电子余额不足,无法完成支付");
//            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
    
            OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
@@ -1170,6 +1191,7 @@
        if(null != orderLogistics.getPayType() && null != orderLogistics.getPayMoney()) {//已支付
            if(orderLogistics.getPayType() == 3){//余额支付
                UserInfo userInfo = userInfoService.selectById(orderLogistics.getUserId());
                userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
                userInfo.setBalance(userInfo.getBalance() + orderLogistics.getPayMoney());
                userInfoService.updateById(userInfo);
                appOrderController.createAllocationReqUser(1, orderLogistics.getUserId(), 1,orderLogistics.getPayMoney());
@@ -1192,6 +1214,7 @@
                }
                if(query.getPayType()==4){
                    UserInfo userInfo = userInfoService.selectById(orderLogistics.getUserId());
                    userInfo.setBalanceChangeType(BalanceChangeType.REFUND.getCode());
                    userInfo.setBalance(userInfo.getBalance() + orderLogistics.getPayMoney());
                    userInfoService.updateById(userInfo);
                    appOrderController.createAllocationReqUser(1, orderLogistics.getUserId(), 1,orderLogistics.getPayMoney());
@@ -1615,9 +1638,15 @@
        OrderLogistics orderLogistics = this.selectById(orderId);
        ResultUtil resultUtil = ResultUtil.success();
        if(payType == 1){//微信支付
            String app = type == 1 ? "APP" : "JSAPI";
            resultUtil = payMoneyUtil.weixinpay("感谢费", "", orderId + "_" + orderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5), money.toString(), "/base/wxPayThankYouFee", app, userInfo.getAppletsOpenId());
            paymentRecordService.saveData(3, uid, 1, orderId, orderLogistics.getType(), 1, money, "", 1);//添加预支付数据
            String outTradeNo = "THANK_" + orderId + "_" + orderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5);
            JSONObject response = cbyzxOrderPayHelper.createOrder(orderLogistics.getUserId(), userInfo.getAppletsOpenId(), outTradeNo, money);
            if (!cbyzxOrderPayHelper.isCreateSuccess(response)) {
                return ResultUtil.error(cbyzxOrderPayHelper.extractMessage(response), response);
            }
            String recordCode = cbyzxOrderPayHelper.extractRecordCode(response);
            String paymentCode = ToolUtil.isNotEmpty(recordCode) ? recordCode : outTradeNo;
            paymentRecordService.saveData(3, uid, 1, orderId, orderLogistics.getType(), 1, money, paymentCode, 1);//添加预支付数据
            resultUtil = ResultUtil.success(response);
        }
        if(payType == 2){//支付宝支付
            resultUtil = payMoneyUtil.alipay("感谢费", "感谢费", "", orderId + "_" + orderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5), money.toString(), "/base/aliPayThankYouFee");
@@ -1631,7 +1660,7 @@
//            if(resultUtil.getCode()==500){
//                return ResultUtil.error("电子余额不足,无法完成支付");
//            }
            userInfo.setBalanceChangeType(BalanceChangeType.CONSUME.getCode());
            userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
    
            OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());