Pu Zhibing
2025-02-11 51b190f22aa8751bd9fbe5229ab5546facdef632
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderServiceImpl.java
@@ -112,6 +112,9 @@
    
    @Autowired
    private IOrderPositionService orderPositionService;
    @Autowired
    private ICarService carService;
@@ -1292,6 +1295,126 @@
            }
        }
    }
    /**
     * 结束google订单状态
     */
    @Override
    public void overGoogleOrder() {
        List<OrderPrivateCar> privateCars = orderPrivateCarService.selectList(new EntityWrapper<OrderPrivateCar>().isNotNull("tripId")
                .eq("isover", 0).in("state", Arrays.asList(7, 8, 9, 10)).eq("isDelete", 1));
        for (OrderPrivateCar privateCar : privateCars) {
            Integer state = privateCar.getState();
            String tripId = privateCar.getTripId();
            String trip = fleetEngineUtil.getTrip(tripId);
            if(ToolUtil.isNotEmpty(trip)){
                JSONObject jsonObject = JSON.parseObject(trip);
                String tripStatus = jsonObject.getString("tripStatus");
                Car car = carService.selectById(privateCar.getCarId());
                if(Arrays.asList(10, 12).contains(state) && !"CANCELED".equals(tripStatus)){
                    //修改行程信息
                    boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null);
                    if(!updateTrip){
                        for (int i = 0; i < 5; i++) {
                            updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null);
                            if(updateTrip){
                                privateCar.setIsover(1);
                                orderPrivateCarService.updateById(privateCar);
                                break;
                            }
                            try {
                                Thread.sleep(3000L);
                            } catch (InterruptedException e) {
                                throw new RuntimeException(e);
                            }
                        }
                    }else{
                        privateCar.setIsover(1);
                        orderPrivateCarService.updateById(privateCar);
                    }
                }
                if(Arrays.asList(6, 7, 8, 9).contains(state) && !"COMPLETE".equals(tripStatus)){
                    //修改行程信息
                    boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null);
                    if(!updateTrip){
                        for (int i = 0; i < 5; i++) {
                            updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null);
                            if(updateTrip){
                                privateCar.setIsover(1);
                                orderPrivateCarService.updateById(privateCar);
                                break;
                            }
                            try {
                                Thread.sleep(3000L);
                            } catch (InterruptedException e) {
                                throw new RuntimeException(e);
                            }
                        }
                    }else{
                        privateCar.setIsover(1);
                        orderPrivateCarService.updateById(privateCar);
                    }
                }
            }
        }
        List<OrderLogistics> orderLogisticsList = orderLogisticsService.selectList(new EntityWrapper<OrderLogistics>().isNotNull("tripId")
                .eq("isover", 0).in("state", Arrays.asList(7, 8, 9, 10)).eq("isDelete", 1));
        for (OrderLogistics orderLogistics : orderLogisticsList) {
            Integer state = orderLogistics.getState();
            String tripId = orderLogistics.getTripId();
            String trip = fleetEngineUtil.getTrip(tripId);
            if(ToolUtil.isNotEmpty(trip)){
                JSONObject jsonObject = JSON.parseObject(trip);
                String tripStatus = jsonObject.getString("tripStatus");
                Car car = carService.selectById(orderLogistics.getCarId());
                if(Arrays.asList(10, 12).contains(state) && !"CANCELED".equals(tripStatus)){
                    //修改行程信息
                    boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null);
                    if(!updateTrip){
                        for (int i = 0; i < 5; i++) {
                            updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null);
                            if(updateTrip){
                                orderLogistics.setIsover(1);
                                orderLogisticsService.updateById(orderLogistics);
                                break;
                            }
                            try {
                                Thread.sleep(3000L);
                            } catch (InterruptedException e) {
                                throw new RuntimeException(e);
                            }
                        }
                    }else{
                        orderLogistics.setIsover(1);
                        orderLogisticsService.updateById(orderLogistics);
                    }
                }
                if(Arrays.asList(6, 7, 8, 9).contains(state) && !"COMPLETE".equals(tripStatus)){
                    //修改行程信息
                    boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null);
                    if(!updateTrip){
                        for (int i = 0; i < 5; i++) {
                            updateTrip = fleetEngineUtil.updateTrip("COMPLETE", (null != car ? car.getVehicleId() : null), null, tripId, null, null, null, null);
                            if(updateTrip){
                                orderLogistics.setIsover(1);
                                orderLogisticsService.updateById(orderLogistics);
                                break;
                            }
                            try {
                                Thread.sleep(3000L);
                            } catch (InterruptedException e) {
                                throw new RuntimeException(e);
                            }
                        }
                    }else{
                        orderLogistics.setIsover(1);
                        orderLogisticsService.updateById(orderLogistics);
                    }
                }
            }
        }
    }
}