puzhibing
2023-06-01 aad87bdfab3ef685a27b3540b1114b36059c8cc7
user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/OrderServiceImpl.java
@@ -12,11 +12,15 @@
import com.supersavedriving.user.modular.system.util.*;
import com.supersavedriving.user.modular.system.util.GaoDe.MapUtil;
import com.supersavedriving.user.modular.system.util.GaoDe.model.District;
import com.supersavedriving.user.modular.system.util.MallBook.model.*;
import com.supersavedriving.user.modular.system.util.MallBook.util.Transfer;
import com.supersavedriving.user.modular.system.util.MallBook.util.TrhRequest;
import com.supersavedriving.user.modular.system.util.juhe.WeatherUtil;
import com.supersavedriving.user.modular.system.util.mongodb.model.Location;
import com.supersavedriving.user.modular.system.warpper.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.geo.Circle;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Metrics;
@@ -29,6 +33,7 @@
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -90,6 +95,21 @@
    @Autowired
    private IRevenueService revenueService;
    @Autowired
    private IAgentService agentService;
    @Autowired
    private IPlatformRechargeRecordService platformRechargeRecordService;
    @Autowired
    private IDivisionRecordService divisionRecordService;
    @Value("${wx.appletsAppid}")
    private String appletsAppid;
    @Value("${callbackPath}")
    private String callbackPath;//支付回调网关地址
@@ -149,7 +169,7 @@
            }
            if(nearbyDriverWarppers.size() > 0){
                NearbyDriverWarpper nearbyDriverWarpper = nearbyDriverWarppers.get(0);
                Map<String, String> distance = MapUtil.getDistance(nearbyDriverWarpper.getLonLat(), estimatedCosts.getLng() + "," + estimatedCosts.getLat(), 1);
                Map<String, String> distance = MapUtil.getDistance(nearbyDriverWarpper.getLonLat(), estimatedCosts.getStartLng() + "," + estimatedCosts.getStartLat(), 1);
                if(null != distance){
                    distance.get("distance");//距离(M)
                    String duration = distance.get("duration");//时间(S)
@@ -370,11 +390,13 @@
        String startAddress = travelOrder.getStartAddress();
        startAddress = startAddress.replaceAll("& #40;", "(");
        startAddress = startAddress.replaceAll("& #41;", ")");
        travelOrder.setStartAddress(startAddress);;
        String endAddress = travelOrder.getEndAddress();
        endAddress = endAddress.replaceAll("& #40;", "(");
        endAddress = endAddress.replaceAll("& #41;", ")");
        travelOrder.setEndAddress(endAddress);
        travelOrder.setStartAddress(startAddress);
        if(ToolUtil.isNotEmpty(travelOrder.getEndAddress())){
            String endAddress = travelOrder.getEndAddress();
            endAddress = endAddress.replaceAll("& #40;", "(");
            endAddress = endAddress.replaceAll("& #41;", ")");
            travelOrder.setEndAddress(endAddress);
        }
        order = new Order();
        BeanUtils.copyProperties(travelOrder, order);
@@ -383,7 +405,6 @@
            order.setUserName(appUser.getNickname());
        }
        order.setUserId(uid);
        order.setCode(UUIDUtil.getTimeStr() + UUIDUtil.getNumberRandom(3));
        order.setSource(1);
        order.setHallOrder(0);
        order.setStatus(1);
@@ -397,6 +418,7 @@
            }
            d = Double.valueOf(distance.get("distance")) / 1000;
            order.setEstimatedMileage(d);
            order.setEstimatedTime(Integer.valueOf(distance.get("duration")) / 60);
        }
        String city = "";
        District geocode = MapUtil.geocode(order.getStartLng(), order.getStartLat());
@@ -412,6 +434,9 @@
                return ResultUtil.error("司机还未上班");
            }
            Driver driver = driverService.selectById(travelOrder.getDriverId());
            if(driver.getServerStatus() == 2){
                return ResultUtil.error("司机正在服务中");
            }
            order.setAgentId(driver.getAgentId());
            order.setBranchOfficeId(driver.getBranchOfficeId());
            order.setOrderTakingTime(new Date());
@@ -420,23 +445,26 @@
            driverService.updateById(driver);
            appUser.setCancelCount(0);
            appUser.setIsException(1);
            appUserService.updateById(appUser);
        }
        for (Integer i = 0; i < travelOrder.getDriverNum(); i++) {
            order.setId(null);
            this.insert(order);
            //推送状态
            pushUtil.pushOrderStatus(uid, 1, order.getId(), order.getState());
            if(null != order.getDriverId()){
                PushOrderInfoWarpper pushOrderInfoWarpper = new PushOrderInfoWarpper();
                pushOrderInfoWarpper.setId(order.getId());
                pushOrderInfoWarpper.setState(order.getState());
                pushUtil.pushOrderInfo(order.getDriverId(), 2, pushOrderInfoWarpper);
            }else{
                //推单
                pushOrder(order);
            order.setCode(UUIDUtil.getTimeStr() + UUIDUtil.getNumberRandom(3));
            boolean insert = this.insert(order);
            if(insert){
                //推送状态
                pushUtil.pushOrderStatus(uid, 1, order.getId(), order.getState());
                if(null != order.getDriverId()){
                    PushOrderInfoWarpper pushOrderInfoWarpper = new PushOrderInfoWarpper();
                    pushOrderInfoWarpper.setId(order.getId());
                    pushOrderInfoWarpper.setState(order.getState());
                    pushUtil.pushOrderInfo(order.getDriverId(), 2, pushOrderInfoWarpper);
                }else{
                    //推单
                    pushOrder(order.getId());
                }
            }
        }
        return ResultUtil.success(order.getId());
@@ -447,9 +475,9 @@
    /**
     * 订单推送逻辑
     * @param order
     */
    public void pushOrder(Order order){
    public void pushOrder(Long orderId){
        Order order = this.selectById(orderId);
        /**
         * 1.先找最大推单范围内的优推司机 -》 距离最近
         * 没有1 - 》
@@ -491,7 +519,7 @@
                    continue;
                }
                Driver driver1 = driverService.selectById(youTuiDriver.getDriverId());
                if(driver1.getServerStatus() == 2){
                if(driver1.getServerStatus() == 2 || driver1.getOpenOrderQRCode() == 1){
                    continue;
                }
                Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat());
@@ -525,13 +553,14 @@
                driverIds = locations.stream().map(Location::getDriverId).collect(Collectors.toList());
                if(driverIds.size() > 0){
                    List<Driver> drivers = driverService.selectList(new EntityWrapper<Driver>().eq("approvalStatus", 2).eq("serverStatus", 1).eq("status", 1).in("id", driverIds));
                    List<Driver> drivers = driverService.selectList(new EntityWrapper<Driver>().eq("approvalStatus", 2)
                            .eq("serverStatus", 1).eq("openOrderQRCode", 0).eq("status", 1).in("id", driverIds));
                    if(drivers.size() == 0){
                        continue;
                    }
                    Integer integral = null;
                    Double score = null;
                    Integer integral = null;//积分
                    Double score = null;//评分
                    Double d = null;
                    for (Driver driver1 : drivers) {
                        String value = redisUtil.getValue("DRIVER" + driver1.getId());
@@ -542,19 +571,27 @@
                            integral = driver1.getIntegral();
                            score = driver1.getScore();
                            driver = driver1.getId();
                            Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat());
                            Double wgs84 = distance.get("WGS84");
                            d = wgs84;
                            continue;
                        }
                        if(integral.compareTo(driver1.getIntegral()) == 0 && score.compareTo(driver1.getScore()) < 0){//积分相同对比评分
                            integral = driver1.getIntegral();
                            score = driver1.getScore();
                            driver = driver1.getId();
                            Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat());
                            Double wgs84 = distance.get("WGS84");
                            d = wgs84;
                            continue;
                        }
                        if(integral.compareTo(driver1.getIntegral()) == 0 && score.compareTo(driver1.getScore()) == 0){//积分相同/评分相同对比距离
                            Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat());
                            Double wgs84 = distance.get("WGS84");
                            if(d == null || d.compareTo(wgs84) > 0){
                            if(d.compareTo(wgs84) > 0){
                                d = wgs84;
                                integral = driver1.getIntegral();
                                score = driver1.getScore();
                                driver = driver1.getId();
                                continue;
                            }
@@ -611,6 +648,9 @@
        this.updateById(order);
        AppUser appUser = appUserService.selectById(uid);
        appUser.setCancelCount(appUser.getCancelCount() + 1);
        if(appUser.getCancelCount() >= 3){
            appUser.setIsException(2);
        }
        appUserService.updateById(appUser);
        Driver driver = driverService.selectById(order.getDriverId());
        if(null != driver){
@@ -676,6 +716,7 @@
            }
            d = Double.valueOf(distance.get("distance")) / 1000;
            order.setEstimatedMileage(d);
            order.setEstimatedTime(Integer.valueOf(distance.get("duration")) / 60);
        }
        String city = "";
        District geocode = MapUtil.geocode(order.getStartLng().toString(), order.getStartLat().toString());
@@ -689,6 +730,14 @@
        Order orderPrice = getOrderPrice(1, d, 0, order1, city);
        order.setEstimatedPrice(orderPrice.getEstimatedPrice());
        this.updateById(order);
        PushOrderInfoWarpper pushOrderInfoWarpper = new PushOrderInfoWarpper();
        pushOrderInfoWarpper.setId(order.getId());
        pushOrderInfoWarpper.setState(order.getState());
        pushOrderInfoWarpper.setEndAddress(order.getEndAddress());
        pushOrderInfoWarpper.setEndLat(order.getEndLat());
        pushOrderInfoWarpper.setEndLng(order.getEndLng());
        pushUtil.pushOrderInfo(order.getDriverId(), 2, pushOrderInfoWarpper);
        return ResultUtil.success();
    }
@@ -704,20 +753,8 @@
        Order order = this.selectById(orderId);
        OrderPriceWarpper orderPriceWarpper = new OrderPriceWarpper();
        BeanUtils.copyProperties(order, orderPriceWarpper);
        AppUser appUser = appUserService.selectById(uid);
        orderPriceWarpper.setBalance(appUser.getAccountBalance());
        Double orderMoney = order.getOrderMoney();
        //先算优惠券
        Coupon coupon = userToCouponService.queryCoupon(uid, orderMoney);
        if(null != coupon){
            orderMoney = orderMoney - coupon.getCouponPreferentialAmount();
            orderPriceWarpper.setDiscountedPrice(coupon.getCouponPreferentialAmount());
            orderPriceWarpper.setCouponId(coupon.getId());
        }
        orderPriceWarpper.setDiscount(0D);
        orderPriceWarpper.setDiscountAmount(0D);
        orderPriceWarpper.setPayType(1);//微信支付
        orderPriceWarpper.setPayMoney(orderMoney);
        orderPriceWarpper.setActualMileage(new BigDecimal(order.getActualMileage() / 1000).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
        orderPriceWarpper.setTravelTime(Double.valueOf((order.getGetoffTime().getTime() - order.getStartTime().getTime()) / 60000).intValue());
        return orderPriceWarpper;
    }
@@ -737,17 +774,23 @@
        OrderPriceWarpper orderPriceWarpper = new OrderPriceWarpper();
        BeanUtils.copyProperties(order, orderPriceWarpper);
        AppUser appUser = appUserService.selectById(uid);
        orderPriceWarpper.setActualMileage(new BigDecimal(order.getActualMileage() / 1000).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
        orderPriceWarpper.setTravelTime(Double.valueOf((order.getGetoffTime().getTime() - order.getStartTime().getTime()) / 60000).intValue());
        orderPriceWarpper.setBalance(appUser.getAccountBalance());
        orderPriceWarpper.setDiscount(0D);
        orderPriceWarpper.setDiscountAmount(0D);
        orderPriceWarpper.setPayType(1);//微信支付
        Double orderMoney = order.getOrderMoney();
        //先算优惠券
        Coupon coupon = userToCouponService.queryCoupon(uid, orderMoney);
        if(null != coupon && null == couponId){
            orderMoney = orderMoney - coupon.getCouponPreferentialAmount();
            orderPriceWarpper.setDiscountedPrice(coupon.getCouponPreferentialAmount());
            orderPriceWarpper.setCouponId(coupon.getId());
//        Coupon coupon = userToCouponService.queryCoupon(uid, orderMoney);
//        if(null != coupon && null == couponId){
//            orderPriceWarpper.setDiscountedPrice(coupon.getCouponPreferentialAmount());
//            orderPriceWarpper.setCouponId(coupon.getId());
//        }
        if(payType == 1 && null == couponId && appUser.getHavDiscount() == 1 && balance.compareTo(orderMoney) >= 0){//使用余额抵扣
            orderPriceWarpper.setDiscount(9D);
            orderPriceWarpper.setDiscountAmount(new BigDecimal(orderMoney * 0.1).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
            orderMoney = new BigDecimal(orderMoney * 0.9).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
        }
        if(null != couponId){
            UserToCoupon userToCoupon = userToCouponService.selectById(couponId);
@@ -756,20 +799,16 @@
            orderPriceWarpper.setDiscountedPrice(coupon1.getCouponPreferentialAmount());
            orderPriceWarpper.setCouponId(couponId);
        }
        if(payType == 1 && appUser.getHavDiscount() == 1){//使用余额抵扣
            orderPriceWarpper.setDiscount(9D);
            orderPriceWarpper.setDiscountAmount(orderMoney * 0.1);
            orderMoney = orderMoney * 0.9;
        }
        if(payType == 0){//不使用余额抵扣
            orderPriceWarpper.setPayType(1);
        }
        if(payType == 1 && balance >= orderMoney){//使用余额抵扣
        if(payType == 1 && balance.compareTo(orderMoney) >= 0){//使用余额抵扣
            orderPriceWarpper.setPayType(2);
        }
        if(payType == 1 && balance < orderMoney){//使用余额抵扣部分
        if(payType == 1 && balance.compareTo(orderMoney) < 0){//使用余额抵扣部分
            orderPriceWarpper.setPayType(4);
        }
        orderPriceWarpper.setPayMoney(orderMoney);
        return orderPriceWarpper;
    }
@@ -838,19 +877,72 @@
            UserToCoupon userToCoupon = userToCouponService.selectById(couponId);
            if(userToCoupon.getValidCount() > 0){
                userToCoupon.setValidCount(userToCoupon.getValidCount() - 1);
                userToCouponService.updateById(userToCoupon);
                Coupon coupon = couponService.selectById(userToCoupon.getCouponId());
                payMoney = payMoney - coupon.getCouponPreferentialAmount();
                order.setCouponId(coupon.getId());
                order.setDiscountedPrice(coupon.getCouponPreferentialAmount());
                userToCouponService.updateById(userToCoupon);
            }
        }
        order.setPayType(1);
        order.setPayMoney(payMoney);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String out_trade_no = sdf.format(new Date()) + order.getId();
        ResultUtil weixinpay = payMoneyUtil.weixinpay("代驾服务费", "", out_trade_no, payMoney.toString(), "/base/order/orderPayCallback", "JSAPI", appUser.getOpenid());
        PaymentOrder paymentOrder = new PaymentOrder();
        paymentOrder.setBizOrderId(out_trade_no);
        paymentOrder.setAmount(String.valueOf(payMoney * 100));
        paymentOrder.setOrderName("代驾服务费");
        paymentOrder.setPayType("WX_MINI");
        paymentOrder.setTransferType("0");
        paymentOrder.setAsynSplitFlag("1");
        paymentOrder.setAppid(appletsAppid);
        paymentOrder.setOpenid(appUser.getOpenid());
        paymentOrder.setTerminalIp(InetAddress.getLocalHost().getHostAddress());
        List<PaymentOrderGood> goodsDetail = new ArrayList<>();
        PaymentOrderGood paymentOrderGood = new PaymentOrderGood();
        paymentOrderGood.setGoodsName("服务费");
        goodsDetail.add(paymentOrderGood);
        paymentOrder.setGoodsDetail(goodsDetail);
        paymentOrder.setFrontUrl("");
        paymentOrder.setNotifyUrl(callbackPath + "/base/order/orderPayCallback");
        paymentOrder.setParameter1(order.getId().toString());
        TrhRequest<PaymentOrder> request = new TrhRequest();
        InterfaceResponse execute = request.execute(paymentOrder, PaymentOrder.SERVICE_CODE);
        if(!"0000".equals(execute.getCode())){
            return ResultUtil.error(execute.getMsg());
        }
        JSONObject jsonObject = JSON.parseObject(execute.getResult());
        String status = jsonObject.getString("status");
        if("2".equals(status)){
            return ResultUtil.error("失败");
        }
        if("0".equals(status)){
            return ResultUtil.error("处理中");
        }
        String payCode = jsonObject.getString("payCode");
        this.updateById(order);
        return weixinpay;
        new Thread(new Runnable() {
            @Override
            public void run() {
                QueryOrder queryOrder = new QueryOrder();
                /**
                 * 原请求订单号(必填)  字段长度最长:32位
                 */
                queryOrder.setOriginalMerOrderId("202108310351001");
                /**
                 * 1:支付查询 2:退款查询 3:确认收货查询 4:结算查询 5:充值查询 6:转账查询 7:异步分账查询(必填)  字段长度最长:1位
                 */
                queryOrder.setQueryType("1");
                TrhRequest<QueryOrder> request = new TrhRequest();
                request.execute(queryOrder, QueryOrder.SERVICE_CODE);
            }
        }).start();
        return ResultUtil.success(payCode);
    }
@@ -866,17 +958,34 @@
            UserToCoupon userToCoupon = userToCouponService.selectById(couponId);
            if(userToCoupon.getValidCount() > 0){
                userToCoupon.setValidCount(userToCoupon.getValidCount() - 1);
                userToCouponService.updateById(userToCoupon);
                Coupon coupon = couponService.selectById(userToCoupon.getCouponId());
                payMoney = payMoney - coupon.getCouponPreferentialAmount();
                order.setCouponId(coupon.getId());
                order.setDiscountedPrice(coupon.getCouponPreferentialAmount());
                Driver driver = driverService.selectById(order.getDriverId());
                AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
                accountChangeDetail.setUserType(2);
                accountChangeDetail.setUserId(order.getDriverId());
                accountChangeDetail.setCreateTime(new Date());
                accountChangeDetail.setOldData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
                accountChangeDetail.setType(1);
                accountChangeDetail.setChangeType(7);
                accountChangeDetail.setOrderId(order.getId());
                accountChangeDetail.setExplain("优惠券收入");
                driver.setCouponBalance(driver.getCouponBalance() + coupon.getCouponPreferentialAmount());
                accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
                driverService.updateById(driver);
                accountChangeDetailService.insert(accountChangeDetail);
            }
        }
        if(appUser.getHavDiscount() == 1){//9折
            payMoney = payMoney * 0.9;
            order.setDiscount(9D);
            order.setDiscountAmount(payMoney * 0.1);
            payMoney = payMoney * 0.9;
        }
        order.setPayType(2);
@@ -895,6 +1004,7 @@
        AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
        accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
        accountChangeDetail.setUserType(1);
        accountChangeDetail.setUserId(appUser.getId());
        accountChangeDetail.setCreateTime(new Date());
@@ -928,6 +1038,7 @@
            UserToCoupon userToCoupon = userToCouponService.selectById(couponId);
            if(userToCoupon.getValidCount() > 0){
                userToCoupon.setValidCount(userToCoupon.getValidCount() - 1);
                userToCouponService.updateById(userToCoupon);
                Coupon coupon = couponService.selectById(userToCoupon.getCouponId());
                payMoney = payMoney - coupon.getCouponPreferentialAmount();
                order.setCouponId(coupon.getId());
@@ -940,6 +1051,7 @@
        payMoney = payMoney > appUser.getAccountBalance() ? payMoney - appUser.getAccountBalance() : 0D;
        AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
        accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
        accountChangeDetail.setUserType(1);
        accountChangeDetail.setUserId(appUser.getId());
        accountChangeDetail.setCreateTime(new Date());
@@ -956,88 +1068,128 @@
        if(0 < payMoney){//还需要调起微信支付
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
            String out_trade_no = sdf.format(new Date()) + order.getId();
            ResultUtil weixinpay = payMoneyUtil.weixinpay("代驾服务费", "", out_trade_no, payMoney.toString(), "/base/order/orderPayCallback", "JSAPI", appUser.getOpenid());
//            ResultUtil weixinpay = payMoneyUtil.weixinpay("代驾服务费", "", out_trade_no, payMoney.toString(), "/base/order/orderPayCallback", "JSAPI", appUser.getOpenid());
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        int num = 1;
                        int wait = 0;
                        while (num <= 10){
                            int min = 5000;
                            wait += (min * num);
                            Order order1 = OrderServiceImpl.this.selectById(order.getId());
                            if(order1.getState() != 107){
                                return;
                            }
            PaymentOrder paymentOrder = new PaymentOrder();
            paymentOrder.setBizOrderId(out_trade_no);
            paymentOrder.setAmount(String.valueOf(Double.valueOf(payMoney * 100).intValue()));
            paymentOrder.setOrderName("代驾服务费");
            paymentOrder.setPayType("WX_MINI");
            paymentOrder.setTransferType("0");
            paymentOrder.setAsynSplitFlag("1");
            paymentOrder.setAppid("");
            paymentOrder.setOpenid(appUser.getOpenid());
            paymentOrder.setTerminalIp(InetAddress.getLocalHost().getHostAddress());
            List<PaymentOrderGood> goodsDetail = new ArrayList<>();
            PaymentOrderGood paymentOrderGood = new PaymentOrderGood();
            paymentOrderGood.setGoodsName("服务费");
            goodsDetail.add(paymentOrderGood);
            paymentOrder.setGoodsDetail(goodsDetail);
            paymentOrder.setFrontUrl("");
            paymentOrder.setNotifyUrl(callbackPath + "/base/order/orderPayCallback");
            paymentOrder.setParameter1(order.getId().toString());
                            /**
                             * SUCCESS--支付成功
                             * REFUND--转入退款
                             * NOTPAY--未支付
                             * CLOSED--已关闭
                             * REVOKED--已撤销(刷卡支付)
                             * USERPAYING--用户支付中
                             * PAYERROR--支付失败(其他原因,如银行返回失败)
                             * ACCEPT--已接收,等待扣款
                             */
                            ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryWXOrder(out_trade_no, "");
                            if(resultUtil.getCode() == 200){
                                Map<String, String> map = resultUtil.getData();
                                String trade_type = map.get("trade_type");
                                String trade_state = map.get("trade_state");
                                String transaction_id = map.get("transaction_id");
                                if("REFUND".equals(trade_state) || "NOTPAY".equals(trade_state) || "CLOSED".equals(trade_state) || "REVOKED".equals(trade_state) || "PAYERROR".equals(trade_state)){
                                    AccountChangeDetail accountChangeDetail1 = accountChangeDetailService.selectById(accountChangeDetail.getId());
                                    AppUser appUser1 = appUserService.selectById(accountChangeDetail1.getUserId());
                                    Double b = accountChangeDetail1.getOldData() - accountChangeDetail1.getNewData();
                                    appUser1.setAccountBalance(appUser1.getAccountBalance() + b);
                                    appUserService.updateById(appUser1);
            TrhRequest<PaymentOrder> request = new TrhRequest();
            InterfaceResponse execute = request.execute(paymentOrder, PaymentOrder.SERVICE_CODE);
            if(!"0000".equals(execute.getCode())){
                return ResultUtil.error(execute.getMsg());
            }
            JSONObject jsonObject = JSON.parseObject(execute.getResult());
            String status = jsonObject.getString("status");
            if("2".equals(status)){
                return ResultUtil.error("失败");
            }
            if("0".equals(status)){
                return ResultUtil.error("处理中");
            }
            String payCode = jsonObject.getString("payCode");
            this.updateById(order);
            return ResultUtil.success(payCode);
                                    accountChangeDetailService.deleteById(accountChangeDetail.getId());
                                    return;
                                }
                                if("SUCCESS".equals(trade_state)){
                                    order1.setPayTime(new Date());
                                    order1.setState(108);
                                    order1.setOrderNo(transaction_id);
                                    OrderServiceImpl.this.updateById(order1);
                                    //处理抽成及收入
                                    saveCommission(order1);
                                    return;
                                }
                                if("USERPAYING".equals(trade_state) || "ACCEPT".equals(trade_state)){
                                    Thread.sleep(wait);
                                    num++;
                                }
                            }else{
                                Thread.sleep(wait);
                                num++;
                            }
                            if(10 == num){
                                AccountChangeDetail accountChangeDetail1 = accountChangeDetailService.selectById(accountChangeDetail.getId());
                                AppUser appUser1 = appUserService.selectById(accountChangeDetail1.getUserId());
                                Double b = accountChangeDetail1.getOldData() - accountChangeDetail1.getNewData();
                                appUser1.setAccountBalance(appUser1.getAccountBalance() + b);
                                appUserService.updateById(appUser1);
                                accountChangeDetailService.deleteById(accountChangeDetail.getId());
                            }
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }
            }).start();
            return weixinpay;
            // TODO: 2023/5/18 取消支付后需要处理优惠券数据回退
//
//
//            new Thread(new Runnable() {
//                @Override
//                public void run() {
//                    try {
//                        int num = 1;
//                        int wait = 0;
//                        while (num <= 10){
//                            int min = 5000;
//                            wait += (min * num);
//                            Order order1 = OrderServiceImpl.this.selectById(order.getId());
//                            if(order1.getState() != 107){
//                                return;
//                            }
//
//                            /**
//                             * SUCCESS--支付成功
//                             * REFUND--转入退款
//                             * NOTPAY--未支付
//                             * CLOSED--已关闭
//                             * REVOKED--已撤销(刷卡支付)
//                             * USERPAYING--用户支付中
//                             * PAYERROR--支付失败(其他原因,如银行返回失败)
//                             * ACCEPT--已接收,等待扣款
//                             */
//                            ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryWXOrder(out_trade_no, "");
//                            if(resultUtil.getCode() == 200){
//                                Map<String, String> map = resultUtil.getData();
//                                String trade_type = map.get("trade_type");
//                                String trade_state = map.get("trade_state");
//                                String transaction_id = map.get("transaction_id");
//                                if("REFUND".equals(trade_state) || "NOTPAY".equals(trade_state) || "CLOSED".equals(trade_state) || "REVOKED".equals(trade_state) || "PAYERROR".equals(trade_state)){
//                                    AccountChangeDetail accountChangeDetail1 = accountChangeDetailService.selectById(accountChangeDetail.getId());
//                                    AppUser appUser1 = appUserService.selectById(accountChangeDetail1.getUserId());
//                                    Double b = accountChangeDetail1.getOldData() - accountChangeDetail1.getNewData();
//                                    appUser1.setAccountBalance(appUser1.getAccountBalance() + b);
//                                    appUserService.updateById(appUser1);
//
//                                    accountChangeDetailService.deleteById(accountChangeDetail.getId());
//                                    return;
//                                }
//                                if("SUCCESS".equals(trade_state)){
//                                    order1.setPayTime(new Date());
//                                    order1.setState(108);
//                                    order1.setOrderNo(transaction_id);
//                                    OrderServiceImpl.this.updateById(order1);
//
//                                    //处理抽成及收入
//                                    saveCommission(order1);
//                                    return;
//                                }
//                                if("USERPAYING".equals(trade_state) || "ACCEPT".equals(trade_state)){
//                                    Thread.sleep(wait);
//                                    num++;
//                                }
//                            }else{
//                                Thread.sleep(wait);
//                                num++;
//                            }
//                            if(10 == num){
//                                AccountChangeDetail accountChangeDetail1 = accountChangeDetailService.selectById(accountChangeDetail.getId());
//                                AppUser appUser1 = appUserService.selectById(accountChangeDetail1.getUserId());
//                                Double b = accountChangeDetail1.getOldData() - accountChangeDetail1.getNewData();
//                                appUser1.setAccountBalance(appUser1.getAccountBalance() + b);
//                                appUserService.updateById(appUser1);
//
//                                accountChangeDetailService.deleteById(accountChangeDetail.getId());
//                            }
//                        }
//                    }catch (Exception e){
//                        e.printStackTrace();
//                    }
//                }
//            }).start();
//            return weixinpay;
        }
        order.setPayTime(new Date());
        this.updateById(order);
//        order.setPayTime(new Date());
//        this.updateById(order);
        return ResultUtil.success();
    }
    /**
@@ -1066,8 +1218,144 @@
            pushOrderInfoWarpper.setState(order.getState());
            pushUtil.pushOrderInfo(order.getDriverId(), 2, pushOrderInfoWarpper);
        }
        //支付成功---->异步分账----->10s钟后再进行确认收货
        //确认收货后才能进行提现(结算接口)
        //异步分账
        List<Revenue> revenues = revenueService.selectList(new EntityWrapper<Revenue>().eq("orderId", order.getId()));
        Complete complete = new Complete();
        complete.setOriginalMerOrderId(transaction_id);
        complete.setNotifyUrl(callbackPath + "/base/order/ledgerCallback");
        List<PamentOrderUser> splitList = new ArrayList<>();
        for (Revenue revenue : revenues) {
            if(revenue.getUserType() == 2){//司机
                Driver driver = driverService.selectById(revenue.getUserId());
                PamentOrderUser pamentOrderUser = new PamentOrderUser();
                pamentOrderUser.setSplitUserId(driver.getMerchantNumber());
                pamentOrderUser.setSplitAmount(revenue.getAmount().toString());
                pamentOrderUser.setSplitType("2");
                splitList.add(pamentOrderUser);
                DivisionRecord divisionRecord = new DivisionRecord();
                divisionRecord.setUserType(1);
                divisionRecord.setUserId(revenue.getUserId());
                divisionRecord.setOrderId(order.getId());
                divisionRecord.setMerOrderId(transaction_id);
                divisionRecord.setSourceType(1);
                divisionRecord.setAmount(revenue.getAmount());
                divisionRecord.setMerchantNumber(driver.getMerchantNumber());
                divisionRecord.setState(1);
                divisionRecord.setCreateTime(new Date());
                divisionRecordService.insert(divisionRecord);
            }
            if(revenue.getUserType() == 3){//代理商
                Agent agent = agentService.selectById(revenue.getUserId());
                PamentOrderUser pamentOrderUser = new PamentOrderUser();
                pamentOrderUser.setSplitUserId(agent.getMerchantNumber());
                pamentOrderUser.setSplitAmount(revenue.getAmount().toString());
                pamentOrderUser.setSplitType("2");
                splitList.add(pamentOrderUser);
                DivisionRecord divisionRecord = new DivisionRecord();
                divisionRecord.setUserType(2);
                divisionRecord.setUserId(revenue.getUserId());
                divisionRecord.setOrderId(order.getId());
                divisionRecord.setMerOrderId(transaction_id);
                divisionRecord.setSourceType(1);
                divisionRecord.setAmount(revenue.getAmount());
                divisionRecord.setMerchantNumber(agent.getMerchantNumber());
                divisionRecord.setState(1);
                divisionRecord.setCreateTime(new Date());
                divisionRecordService.insert(divisionRecord);
            }
        }
        complete.setSplitList(splitList);
        TrhRequest<Complete> request = new TrhRequest();
        InterfaceResponse execute = request.execute(complete, Complete.SERVICE_CODE);
        if(!"0000".equals(execute.getCode())){
            return ResultUtil.error(execute.getMsg());
        }
        JSONObject jsonObject = JSON.parseObject(execute.getResult());
        String status = jsonObject.getString("status");
        if("2".equals(status)){
            return ResultUtil.error("失败");
        }
        if("0".equals(status)){
            return ResultUtil.error("处理中");
        }
        //使用优惠券的情况,通过转账接口将优惠券的收入转到司机电子账簿
        if(null != order.getCouponId()){
            List<PlatformRechargeRecord> platformRechargeRecords = platformRechargeRecordService.selectList(new EntityWrapper<PlatformRechargeRecord>().eq("state", 2).last(" and balance > 0 order by payTime"));
            Double discountedPrice = order.getDiscountedPrice();
            Driver driver = driverService.selectById(order.getDriverId());
            UserToCoupon userToCoupon = userToCouponService.selectById(order.getCouponId());
            Coupon coupon = couponService.selectById(userToCoupon.getCouponId());
            AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
            accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
            accountChangeDetail.setUserType(2);
            accountChangeDetail.setUserId(order.getDriverId());
            accountChangeDetail.setCreateTime(new Date());
            accountChangeDetail.setOldData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
            accountChangeDetail.setType(1);
            accountChangeDetail.setChangeType(7);
            accountChangeDetail.setOrderId(order.getId());
            accountChangeDetail.setExplain("优惠券收入");
            driver.setCouponBalance(driver.getCouponBalance() + coupon.getCouponPreferentialAmount());
            accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
            driverService.updateById(driver);
            accountChangeDetailService.insert(accountChangeDetail);
            for (PlatformRechargeRecord platformRechargeRecord : platformRechargeRecords) {
                if(discountedPrice == 0){
                    break;
                }
                if(platformRechargeRecord.getBalance().compareTo(discountedPrice) >= 0){
                    discountedPrice = 0D;
                    platformRechargeRecord.setBalance(platformRechargeRecord.getBalance() - discountedPrice);
                    platformRechargeRecordService.updateById(platformRechargeRecord);
                }else{
                }
                Transfer transfer = new Transfer();
                transfer.setDepositMerOrderId("6831518911582834611");
                transfer.setToUserId(driver.getMerchantNumber());
                transfer.setAmount(discountedPrice.toString());
                transfer.setOrderName("");
                transfer.setNotifyUrl("");
                transfer.setParameter1(order.getId().toString());
                TrhRequest<Transfer> request1 = new TrhRequest();
                InterfaceResponse execute1 = request1.execute(transfer, Transfer.SERVICE_CODE);
                if(!"0000".equals(execute1.getCode())){
                    return ResultUtil.error(execute1.getMsg());
                }
                JSONObject jsonObject1 = JSON.parseObject(execute1.getResult());
                String status1 = jsonObject1.getString("status");
                if("2".equals(status1)){
                    return ResultUtil.error("失败");
                }
                if("0".equals(status1)){
                    return ResultUtil.error("处理中");
                }
            }
        }
        return ResultUtil.success();
    }
    /**
@@ -1106,6 +1394,7 @@
                //增加积分变动记录
                AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
                accountChangeDetail.setUserType(2);
                accountChangeDetail.setUserId(order.getDriverId());
                accountChangeDetail.setCreateTime(new Date());
@@ -1126,6 +1415,7 @@
                //增加积分变动记录
                AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
                accountChangeDetail.setUserType(2);
                accountChangeDetail.setUserId(order.getDriverId());
                accountChangeDetail.setCreateTime(new Date());
@@ -1174,15 +1464,16 @@
                        if(num1 > 0){
                            Driver driver1 = driverService.selectById(appUser.getInviterId());
                            AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                            accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
                            accountChangeDetail.setUserType(2);
                            accountChangeDetail.setUserId(driver1.getId());
                            accountChangeDetail.setType(1);
                            accountChangeDetail.setChangeType(5);
                            accountChangeDetail.setOldData(driver1.getCommission());
                            accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                            accountChangeDetail.setExplain("订单分佣收入");
                            accountChangeDetail.setCreateTime(new Date());
                            driver1.setCommission(driver1.getCommission() + num1);
                            accountChangeDetail.setNewData(driver1.getCommission());
                            accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                            driverService.updateById(driver1);
                            accountChangeDetailService.saveData(accountChangeDetail);
@@ -1199,17 +1490,17 @@
                    }
                    //开始处理层级抽佣
                    if(null != driver.getInviterType() && driver.getInviterType() == 2){
                    if(null != driver & null != driver.getInviterType() && driver.getInviterType() == 2){
                        Driver driver1 = driverService.selectById(driver.getInviterId());//一级司机
                        if(null != driver1.getInviterType() && driver1.getInviterType() == 2){
                        if(null != driver1 && null != driver1.getInviterType() && driver1.getInviterType() == 2){
                            Driver driver2 = driverService.selectById(driver1.getInviterId());//二级司机
                            if(null != driver2.getInviterType() && driver2.getInviterType() == 2){
                            if(null != driver2 && null != driver2.getInviterType() && driver2.getInviterType() == 2){
                                Driver driver3 = driverService.selectById(driver2.getInviterId());//三级级司机
                                Double num5 = jsonObject1.getDouble("num5");
                                Double num6 = jsonObject1.getDouble("num6");
                                Double num7 = jsonObject1.getDouble("num7");
                                num5 = (num3 >= num5 ? num5 : num3);
                                if(num5 > 0){
                                if(num5 > 0 && null != driver1){
                                    Revenue revenue = new Revenue();
                                    revenue.setType(2);
                                    revenue.setUserType(2);
@@ -1220,21 +1511,22 @@
                                    revenueService.insert(revenue);
                                    AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                                    accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
                                    accountChangeDetail.setUserType(2);
                                    accountChangeDetail.setUserId(driver1.getId());
                                    accountChangeDetail.setType(1);
                                    accountChangeDetail.setChangeType(5);
                                    accountChangeDetail.setOldData(driver1.getCommission());
                                    accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                                    accountChangeDetail.setExplain("订单分佣收入");
                                    accountChangeDetail.setCreateTime(new Date());
                                    driver1.setCommission(driver1.getCommission() + num5);
                                    accountChangeDetail.setNewData(driver1.getCommission());
                                    accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                                    driverService.updateById(driver1);
                                    accountChangeDetailService.saveData(accountChangeDetail);
                                    num3 = (num3 >= num5 ? num3 - num5 : 0);
                                }
                                num6 = (num3 >= num6 ? num6 : num3);
                                if(num6 > 0){
                                if(num6 > 0 && null != driver2){
                                    Revenue revenue = new Revenue();
                                    revenue.setType(2);
                                    revenue.setUserType(2);
@@ -1245,21 +1537,22 @@
                                    revenueService.insert(revenue);
                                    AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                                    accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
                                    accountChangeDetail.setUserType(2);
                                    accountChangeDetail.setUserId(driver2.getId());
                                    accountChangeDetail.setType(1);
                                    accountChangeDetail.setChangeType(5);
                                    accountChangeDetail.setOldData(driver2.getCommission());
                                    accountChangeDetail.setOldData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
                                    accountChangeDetail.setExplain("订单分佣收入");
                                    accountChangeDetail.setCreateTime(new Date());
                                    driver2.setCommission(driver2.getCommission() + num6);
                                    accountChangeDetail.setNewData(driver2.getCommission());
                                    accountChangeDetail.setNewData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
                                    driverService.updateById(driver2);
                                    accountChangeDetailService.saveData(accountChangeDetail);
                                    num3 = (num3 >= num6 ? num3 - num6 : 0);
                                }
                                num7 = (num3 >= num7 ? num7 : num3);
                                if(num7 > 0){
                                if(num7 > 0 && null != driver3){
                                    Revenue revenue = new Revenue();
                                    revenue.setType(2);
                                    revenue.setUserType(2);
@@ -1270,15 +1563,16 @@
                                    revenueService.insert(revenue);
                                    AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                                    accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
                                    accountChangeDetail.setUserType(2);
                                    accountChangeDetail.setUserId(driver3.getId());
                                    accountChangeDetail.setType(1);
                                    accountChangeDetail.setChangeType(5);
                                    accountChangeDetail.setOldData(driver3.getCommission());
                                    accountChangeDetail.setOldData(driver3.getBalance() + driver3.getBackgroundBalance() + driver3.getCouponBalance() + driver3.getCommission());
                                    accountChangeDetail.setExplain("订单分佣收入");
                                    accountChangeDetail.setCreateTime(new Date());
                                    driver3.setCommission(driver3.getCommission() + num7);
                                    accountChangeDetail.setNewData(driver3.getCommission());
                                    accountChangeDetail.setNewData(driver3.getBalance() + driver3.getBackgroundBalance() + driver3.getCouponBalance() + driver3.getCommission());
                                    driverService.updateById(driver3);
                                    accountChangeDetailService.saveData(accountChangeDetail);
                                    num3 = (num3 >= num7 ? num3 - num7 : 0);
@@ -1287,7 +1581,7 @@
                                Double num3_ = jsonObject1.getDouble("num3");
                                Double num4 = jsonObject1.getDouble("num4");
                                num3_ = (num3 >= num3_ ? num3_ : num3);
                                if(num3_ > 0){
                                if(num3_ > 0 && null != driver1){
                                    Revenue revenue = new Revenue();
                                    revenue.setType(2);
                                    revenue.setUserType(2);
@@ -1298,21 +1592,22 @@
                                    revenueService.insert(revenue);
                                    AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                                    accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
                                    accountChangeDetail.setUserType(2);
                                    accountChangeDetail.setUserId(driver1.getId());
                                    accountChangeDetail.setType(1);
                                    accountChangeDetail.setChangeType(5);
                                    accountChangeDetail.setOldData(driver1.getCommission());
                                    accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                                    accountChangeDetail.setExplain("订单分佣收入");
                                    accountChangeDetail.setCreateTime(new Date());
                                    driver1.setCommission(driver1.getCommission() + num3_);
                                    accountChangeDetail.setNewData(driver1.getCommission());
                                    accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                                    driverService.updateById(driver1);
                                    accountChangeDetailService.saveData(accountChangeDetail);
                                    num3 = (num3 >= num3_ ? num3 - num3_ : 0);
                                }
                                num4 = (num3 >= num4 ? num4 : num3);
                                if(num4 > 0){
                                if(num4 > 0 && null != driver2){
                                    Revenue revenue = new Revenue();
                                    revenue.setType(2);
                                    revenue.setUserType(2);
@@ -1323,15 +1618,16 @@
                                    revenueService.insert(revenue);
                                    AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                                    accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
                                    accountChangeDetail.setUserType(2);
                                    accountChangeDetail.setUserId(driver2.getId());
                                    accountChangeDetail.setType(1);
                                    accountChangeDetail.setChangeType(5);
                                    accountChangeDetail.setOldData(driver2.getCommission());
                                    accountChangeDetail.setOldData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
                                    accountChangeDetail.setExplain("订单分佣收入");
                                    accountChangeDetail.setCreateTime(new Date());
                                    driver2.setCommission(driver2.getCommission() + num4);
                                    accountChangeDetail.setNewData(driver2.getCommission());
                                    accountChangeDetail.setNewData(driver2.getBalance() + driver2.getBackgroundBalance() + driver2.getCouponBalance() + driver2.getCommission());
                                    driverService.updateById(driver2);
                                    accountChangeDetailService.saveData(accountChangeDetail);
                                    num3 = (num3 >= num4 ? num3 - num4 : 0);
@@ -1340,7 +1636,7 @@
                        }else{
                            Double num2_ = jsonObject1.getDouble("num2");
                            num2_ = (num3 >= num2_ ? num2_ : num3);
                            if(num2_ > 0){
                            if(num2_ > 0 && null != driver1){
                                Revenue revenue = new Revenue();
                                revenue.setType(2);
                                revenue.setUserType(2);
@@ -1351,15 +1647,16 @@
                                revenueService.insert(revenue);
                                AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
                                accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
                                accountChangeDetail.setUserType(2);
                                accountChangeDetail.setUserId(driver1.getId());
                                accountChangeDetail.setType(1);
                                accountChangeDetail.setChangeType(5);
                                accountChangeDetail.setOldData(driver1.getCommission());
                                accountChangeDetail.setOldData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                                accountChangeDetail.setExplain("订单分佣收入");
                                accountChangeDetail.setCreateTime(new Date());
                                driver1.setCommission(driver1.getCommission() + num2_);
                                accountChangeDetail.setNewData(driver1.getCommission());
                                accountChangeDetail.setNewData(driver1.getBalance() + driver1.getBackgroundBalance() + driver1.getCouponBalance() + driver1.getCommission());
                                driverService.updateById(driver1);
                                accountChangeDetailService.saveData(accountChangeDetail);
                                num3 = (num3 >= num2_ ? num3 - num2_ : 0);
@@ -1367,7 +1664,7 @@
                        }
                    }
                    //处理代理商抽佣
                    if(num3 > 0){
                    if(num3 > 0 && null != driver){
                        Revenue revenue = new Revenue();
                        revenue.setType(1);
                        revenue.setUserType(3);
@@ -1391,19 +1688,20 @@
        revenueService.insert(revenue);
        AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
        accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
        accountChangeDetail.setUserType(2);
        accountChangeDetail.setUserId(driver.getId());
        accountChangeDetail.setType(1);
        accountChangeDetail.setChangeType(1);
        accountChangeDetail.setOrderId(order.getId());
        accountChangeDetail.setOldData(driver.getBalance() + driver.getCouponBalance());
        accountChangeDetail.setOldData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
        accountChangeDetail.setExplain("订单收入");
        accountChangeDetail.setCreateTime(new Date());
        driver.setBalance(driver.getBalance() + payMoney);
        if(null != order.getCouponId()){
            driver.setCouponBalance(driver.getCouponBalance() + order.getDiscountedPrice());
        }
        accountChangeDetail.setNewData(driver.getBalance() + driver.getCouponBalance());
        accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
        driverService.updateById(driver);
        accountChangeDetailService.saveData(accountChangeDetail);
    }
@@ -1435,4 +1733,6 @@
        notInvoiceOrder.setPageNum((notInvoiceOrder.getPageNum() - 1) * notInvoiceOrder.getPageSize());;
        return this.baseMapper.queryNotInvoiceOrder(uid, notInvoiceOrder);
    }
}