Pu Zhibing
4 天以前 cb7e84fe6e40f3ce3ed1fe3fb3b4c0da8c847793
DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReassignServiceImpl.java
@@ -193,8 +193,10 @@
                        orderPrivateCar.setOldState(orderPrivateCar.getState());
                        orderPrivateCar.setState(11);
                        orderPrivateCar.setReassignNotice(2);
                        orderPrivateCar.setIsReassign(2);
                        orderPrivateCarService.updateById(orderPrivateCar);
                        if(ToolUtil.isNotEmpty(orderPrivateCar.getTravelId())){
                        Company company = companyService.selectById(driver.getCompanyId());
                        //中台修改订单状态
                        ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest();
@@ -207,6 +209,7 @@
                        }
                        request.setSupplierShopId(company.getEnterCode());
                        OrderUtil.modifyTravelItinerary(request);
                        }
                        //添加已收入明细
@@ -219,8 +222,10 @@
                        orderTaxi.setOldState(orderTaxi.getState());
                        orderTaxi.setState(11);
                        orderTaxi.setReassignNotice(2);
                        orderTaxi.setIsReassign(2);
                        orderTaxiService.updateById(orderTaxi);
                        if(ToolUtil.isNotEmpty(orderTaxi.getTravelId())){
                        Company company1 = companyService.selectById(driver.getCompanyId());
                        //中台修改订单状态
                        ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest();
@@ -233,6 +238,7 @@
                        }
                        request1.setSupplierShopId(company1.getEnterCode());
                        OrderUtil.modifyTravelItinerary(request1);
                        }
                        //添加已收入明细
//                        incomeService.saveData(1, orderTaxi.getCompanyId(), 4, orderTaxi.getId(), 2, reassign.getMoney());
@@ -245,6 +251,7 @@
                        orderLogistics.setOldState(orderLogistics.getState());
                        orderLogistics.setState(11);
                        orderLogistics.setReassignNotice(2);
                        orderLogistics.setIsReassign(2);
                        orderLogisticsService.updateById(orderLogistics);
                        //添加已收入明细
@@ -255,6 +262,7 @@
                        orderLogistics1.setOldState(orderLogistics1.getState());
                        orderLogistics1.setState(11);
                        orderLogistics1.setReassignNotice(2);
                        orderLogistics1.setIsReassign(2);
                        orderLogisticsService.updateById(orderLogistics1);
                        //添加已收入明细
@@ -298,6 +306,7 @@
                orderPrivateCar.setReassignNotice(0);
                orderPrivateCarService.updateById(orderPrivateCar);
                if(ToolUtil.isNotEmpty(orderPrivateCar.getTravelId())){
                Company company = companyService.selectById(driver.getCompanyId());
                //中台修改订单状态
                ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest();
@@ -310,6 +319,7 @@
                }
                request.setSupplierShopId(company.getEnterCode());
                OrderUtil.modifyTravelItinerary(request);
                }
                break;
            case 2:
                OrderTaxi orderTaxi = orderTaxiService.selectById(reassign.getOrderId());
@@ -319,6 +329,7 @@
                orderTaxi.setState(orderTaxi.getOldState());
                orderTaxi.setReassignNotice(0);
                orderTaxiService.updateById(orderTaxi);
                if(ToolUtil.isNotEmpty(orderTaxi.getTravelId())){
                Company company1 = companyService.selectById(driver.getCompanyId());
                //中台修改订单状态
                ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest();
@@ -331,6 +342,7 @@
                }
                request1.setSupplierShopId(company1.getEnterCode());
                OrderUtil.modifyTravelItinerary(request1);
                }
                break;
        }
        reassignMapper.delete(new EntityWrapper<Reassign>().eq("orderId",reassign.getOrderId()).eq("orderType",reassign.getOrderType()));
@@ -541,6 +553,7 @@
                    orderCrossCity.setOldState(orderCrossCity.getState());
                    orderCrossCity.setState(11);
                    orderCrossCity.setReassignNotice(2);
                    orderCrossCity.setIsReassign(2);
                    orderCrossCityService.updateById(orderCrossCity);
                    //添加已收入明细
@@ -548,13 +561,13 @@
                }
                systemNoticeService.addSystemNotice(2, "您已使用余额成功支付改派申请费用!", uid, 1);
                //开始推送调度单
                Map<String, String> map = new HashMap<>();
                map.put("orderId", reassign.getOrderId().toString());
                map.put("orderType", reassign.getOrderType().toString());
                List<Dispatch> dispatches = dispatchMapper.queryDispatchs(driver.getFranchiseeId() == null ? driver.getCompanyId() : driver.getFranchiseeId(), 1);
                for (Dispatch dispatch : dispatches) {
                    jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId());
                }
//                Map<String, String> map = new HashMap<>();
//                map.put("orderId", reassign.getOrderId().toString());
//                map.put("orderType", reassign.getOrderType().toString());
//                List<Dispatch> dispatches = dispatchMapper.queryDispatchs(driver.getFranchiseeId() == null ? driver.getCompanyId() : driver.getFranchiseeId(), 1);
//                for (Dispatch dispatch : dispatches) {
//                    jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId());
//                }
            }
            if (reassign.getPayType() == 4) {
@@ -619,14 +632,14 @@
                        reassign.setPayOrder(order_id);
                        reassign.setPayTime(new Date());
                        this.updateById(reassign);
                        //开始推送调度单
                        Map<String, String> map = new HashMap<>();
                        map.put("orderId", reassign.getOrderId().toString());
                        map.put("orderType", reassign.getOrderType().toString());
                        List<Dispatch> dispatches = dispatchMapper.queryDispatchs(driver.getFranchiseeId() == null ? driver.getCompanyId() : driver.getFranchiseeId(), 1);
                        for (Dispatch dispatch : dispatches) {
                            jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId());
                        }
//                        //开始推送调度单
//                        Map<String, String> map = new HashMap<>();
//                        map.put("orderId", reassign.getOrderId().toString());
//                        map.put("orderType", reassign.getOrderType().toString());
//                        List<Dispatch> dispatches = dispatchMapper.queryDispatchs(driver.getFranchiseeId() == null ? driver.getCompanyId() : driver.getFranchiseeId(), 1);
//                        for (Dispatch dispatch : dispatches) {
//                            jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId());
//                        }
                    }
                    query.setState(2);
                    query.setCode(order_id);
@@ -638,6 +651,7 @@
                        orderCrossCity1.setOldState(orderCrossCity1.getState());
                        orderCrossCity1.setState(11);
                        orderCrossCity1.setReassignNotice(2);
                        orderCrossCity1.setIsReassign(2);
                        orderCrossCityService.updateById(orderCrossCity1);
                        System.out.println("==============跨城修改改派通知状态完毕===================" + orderCrossCity1);
@@ -683,6 +697,7 @@
                        orderPrivateCar.setOldState(orderPrivateCar.getState());
                        orderPrivateCar.setState(11);
                        orderPrivateCar.setReassignNotice(2);
                        orderPrivateCar.setIsReassign(2);
                        orderPrivateCarService.updateById(orderPrivateCar);
                        //添加已收入明细
@@ -694,6 +709,7 @@
                        orderTaxi.setOldState(orderTaxi.getState());
                        orderTaxi.setState(11);
                        orderTaxi.setReassignNotice(2);
                        orderTaxi.setIsReassign(2);
                        orderTaxiService.updateById(orderTaxi);
                        //添加已收入明细
@@ -705,6 +721,7 @@
                        orderLogistics.setOldState(orderLogistics.getState());
                        orderLogistics.setState(11);
                        orderLogistics.setReassignNotice(2);
                        orderLogistics.setIsReassign(2);
                        orderLogisticsService.updateById(orderLogistics);
                        //添加已收入明细
@@ -716,6 +733,7 @@
                        orderLogistics1.setOldState(orderLogistics1.getState());
                        orderLogistics1.setState(11);
                        orderLogistics1.setReassignNotice(2);
                        orderLogistics1.setIsReassign(2);
                        orderLogisticsService.updateById(orderLogistics1);
                        //添加已收入明细
@@ -724,14 +742,14 @@
                        break;
                }
                systemNoticeService.addSystemNotice(2, "您已使用" + (type == 1 ? "微信" : (type == 2 ? "支付宝" : "云闪付")) + "成功支付改派申请费用!", reassign.getOriginalDriverId(), 1);
                //开始推送调度单
                Map<String, String> map = new HashMap<>();
                map.put("orderId", reassign.getOrderId().toString());
                map.put("orderType", reassign.getOrderType().toString());
                List<Dispatch> dispatches = dispatchMapper.queryDispatchs(driver.getFranchiseeId() == null ? driver.getCompanyId() : driver.getFranchiseeId(), 1);
                for (Dispatch dispatch : dispatches) {
                    jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId());
                }
//                //开始推送调度单
//                Map<String, String> map = new HashMap<>();
//                map.put("orderId", reassign.getOrderId().toString());
//                map.put("orderType", reassign.getOrderType().toString());
//                List<Dispatch> dispatches = dispatchMapper.queryDispatchs(driver.getFranchiseeId() == null ? driver.getCompanyId() : driver.getFranchiseeId(), 1);
//                for (Dispatch dispatch : dispatches) {
//                    jgPushUtil.push(2, "有新的改派订单需要处理,请及时处理!", "订单改派", map, "DISPATCH" + dispatch.getId());
//                }
                System.out.println("==============其他订单完毕===================");
            } else {
                System.err.println("预支付数据异常(orderId = " + id + ")");
@@ -771,8 +789,10 @@
                    }
                    OpenCity openCity = openCityService.openCity1(orderTaxi.getStartLon().toString(), orderTaxi.getStartLat().toString());
                    List<PushOrder> querys = pushOrderService.querys(null, 2, openCity.getId());//获取需要推送的次数
                    int size=18;
                    for (int i = 1; i <= size; i++) {
                    int num = 0;
                    for (int j = 0; j < 6; j++) {
                        Boolean push = false;
                        for (int i = 1; i <= querys.size(); i++) {
                        int finalI = i;
                        PushOrder pushOrder = querys.stream().filter(s -> s.getType() == (finalI <= 3 ? finalI : 3)).findFirst().orElse(null);
                        System.out.println("pushOrder:" + pushOrder);
@@ -804,17 +824,23 @@
                        Integer state = orderTaxi1.getState();
                        if (state != 1 || state!= 11) {
                            orderIds.remove(orderTaxi.getId());
                                push = true;
                            break;
                        }
                        if (i == 18 && (state == 1 || state==11)) {
                            if (num == 18 && (state == 1 || state==11)) {
                            System.err.println("结束改派退单-------------修改订单为取消状态");
                            pushUtil.pushEndPush(1, orderTaxi.getUserId(), orderTaxi.getId(), 2);
                                pushUtil.pushEndPush(1, orderTaxi.getUserId(), orderTaxi.getId(), 2, 11);
                            pushUtil.pushOrderState(2, orderTaxi.getDriverId(), orderTaxi.getId(), 2, 10);
                            orderTaxi1.setState(10);
                            orderTaxiService.updateById(orderTaxi1);
                            orderIds.remove(orderTaxi.getId());
                        }
                    }
                        if(push){
                            break;
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
@@ -843,10 +869,14 @@
                    }
                    OpenCity openCity = openCityService.openCity1(orderPrivateCar.getStartLon().toString(), orderPrivateCar.getStartLat().toString());
                    List<PushOrder> querys = pushOrderService.querys(null, 1, openCity.getId());//获取需要推送的次数
                    int size=18;
                    for (int i = 1; i <= size; i++) {
                    int num = 0;
                    for (int j = 0; j < 6; j++) {
                        Boolean push = false;
                        for (int i = 1; i <= querys.size(); i++) {
                            num++;
                        OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(id);
                        if (null == orderPrivateCar || (orderPrivateCar.getState() > 1 && orderPrivateCar.getState() != 11)) {
                                push = true;
                            break;
                        }
                        int finalI = i;
@@ -854,6 +884,7 @@
                        System.out.println("pushOrder:" + pushOrder);
                        if (orderPrivateCar.getState() > 1 && orderPrivateCar.getState() != 11) {
                                push = true;
                            break;
                        }
                        //获取空闲司机
@@ -882,18 +913,23 @@
                        Integer state = orderPrivateCar.getState();
                        if (state > 1 && state != 11) {
                            orderIds.remove(orderPrivateCar.getId());
                                push = true;
                            return;
                        }
                        if (i == 18 && (state == 1 || state==11)) {
                            if (num == 18 && (state == 1 || state==11)) {
                            System.err.println("结束改派退单-------------修改订单为取消状态");
                            pushUtil.pushEndPush(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1);
                                pushUtil.pushEndPush(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, 11);
                            pushUtil.pushReassignEndCancel(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 1, 10);
                            orderPrivateCar.setState(10);
                            orderPrivateCarService.updateById(orderPrivateCar);
                            orderIds.remove(orderPrivateCar.getId());
                        }
                    }
                        if(push){
                            break;
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }