Pu Zhibing
2024-11-09 bd6b419b58eef18cfcb5da6222d00e6f88d5166c
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -774,8 +774,7 @@
        userInfo.setLanguage(language);
        userInfoService.updateById(userInfo);
        
        new Thread(() -> {
            try {
        //google创建车辆信息
                String vehicleId = null;
                if(null != orderLogistics.getDriverId()){
                    Driver driver = driverService.selectById(orderLogistics.getDriverId());
@@ -809,26 +808,40 @@
                            }
                        }
                    }
                }
                //创建行程数据
                boolean createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderLogistics.getTripId(),
        String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId());
        int count = this.selectCount(new EntityWrapper<OrderLogistics>().eq("tripId", orderLogistics.getTripId()));
        int count1 = orderPrivateCarService.selectCount(new EntityWrapper<OrderPrivateCar>().eq("tripId", orderLogistics.getTripId()));
        if(ToolUtil.isNotEmpty(trip) || (count + count1) > 0){
            String randomCode = UUIDUtil.getRandomCode();
            redisUtil.setStrValue("trip" + orderLogistics.getUserId(), randomCode);
            OrderLogistics orderLogistics1 = new OrderLogistics();
            orderLogistics1.setId(orderLogistics.getId());
            orderLogistics1.setTripId(randomCode);
            this.updateById(orderLogistics1);
            orderLogistics.setTripId(randomCode);
        }
        JSONObject createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderLogistics.getTripId(),
                        orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString());
                if(!createTrip){
        JSONObject error = createTrip.getJSONObject("error");
        if(null != error){
                    for (int i = 0; i < 5; i++) {
                        createTrip = fleetEngineUtil.createTrip(vehicleId, 1, orderLogistics.getTripId(),
                                orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString());
                        if(createTrip){
                error = createTrip.getJSONObject("error");
                String tripStatus = createTrip.getString("tripStatus");
                if(null == error && "NEW".equals(tripStatus)){
                            break;
                        }
                        Thread.sleep(5000L);
                try {
                    Thread.sleep(3000L);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }).start();
    
        if(orderSource == 2){//扫码下单
            Driver driver = driverService.selectById(orderLogistics.getDriverId());
@@ -1129,11 +1142,11 @@
                            userRedPacketRecord.setEndTime(new Date());
                            userRedPacketRecord.setState(2);
                            multiply1 = multiply1.subtract(remainingAmount).setScale(2, RoundingMode.HALF_EVEN);
                            jsonObject.put("money", remainingAmount);
                            jsonObject.put("money", remainingAmount.setScale(2, RoundingMode.HALF_EVEN));
                            jsonArray.add(jsonObject);
                        }else if(remainingAmount.compareTo(multiply1) > 0){
                            userRedPacketRecord.setRemainingAmount(remainingAmount.subtract(multiply1).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
                            jsonObject.put("money", multiply1);
                            jsonObject.put("money", multiply1.setScale(2, RoundingMode.HALF_EVEN));
                            jsonArray.add(jsonObject);
                            multiply1 = BigDecimal.ZERO;
                        }
@@ -1189,7 +1202,6 @@
            }else{
                resultUtil = ResultUtil.error(language == 1 ? "支付失败" : language == 2 ? "Payment failure" : "Paiement échoué", "");
            }
            return resultUtil;
        }
        if(payType == 2) {//银行卡支付
@@ -1212,12 +1224,12 @@
            resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest);
            if(resultUtil.getCode()==200){
                this.updateById(orderLogistics);
                paymentRecordService.saveData(1, null, null, orderId, 4, 2,
                        orderMoney.setScale(2, RoundingMode.HALF_EVEN).doubleValue(), null, 1);//添加预支付数据
            }else{
                resultUtil = ResultUtil.error(language == 1 ? "支付失败" : language == 2 ? "Payment failure" : "Paiement échoué", "");
            }
            return resultUtil;
        }
        if(payType == 3){//余额支付
@@ -1268,7 +1280,6 @@
                }
            }
    
            if(orderLogistics.getIsplatPay()==1){
                //添加已收入明细
                Company company = companyService.selectById(orderLogistics.getCompanyId());
                Double speMoney = company.getSpeMoney();
@@ -1290,7 +1301,6 @@
                driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                driverService.updateById(driver);
            }
            // TODO: 2020/5/24 这里需要给司机和用户推送订单状态
            new Thread(new Runnable() {
@@ -1314,7 +1324,7 @@
                Document document = Jsoup.parse(new File(path), "UTF-8");
                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                Driver driver = driverService.selectById(orderLogistics.getDriverId());
                driver = driverService.selectById(orderLogistics.getDriverId());
                Car car = carMapper.selectById(orderLogistics.getCarId());
                Double aDouble = 0D;
                if(null != orderLogistics.getDriverId()){
@@ -1746,7 +1756,6 @@
            }
    
    
            if(orderLogistics.getIsplatPay()==1){
                //添加已收入明细
                Company company = companyService.selectById(orderLogistics.getCompanyId());
                Double speMoney = company.getSpeMoney();
@@ -1871,7 +1880,6 @@
                                            e.printStackTrace();
                                        }
                                    }).start();
                                }
                            }
                        }
                    }
@@ -2327,7 +2335,7 @@
            }
        }
        this.updateById(orderLogistics);
        this.updateAllColumnById(orderLogistics);
        return resultUtil;
    }
@@ -2543,7 +2551,7 @@
            query.setState(2);
            query.setCode(order_id);
            paymentRecordService.updateById(query);
            if(orderLogistics.getIsplatPay()==1){
                //添加已收入明细
                Company company = companyService.selectById(orderLogistics.getCompanyId());
                Double speMoney = company.getSpeMoney();
@@ -2565,7 +2573,6 @@
                driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                driverService.updateById(driver);
            }
            // TODO: 2020/5/24 这里需要给司机和用户推送订单状态
            new Thread(new Runnable() {
@@ -2587,7 +2594,7 @@
                Document document = Jsoup.parse(new File(path), "UTF-8");
                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                Driver driver = driverService.selectById(orderLogistics.getDriverId());
                driver = driverService.selectById(orderLogistics.getDriverId());
                Car car = carMapper.selectById(orderLogistics.getCarId());
                Double aDouble = 0D;
                if(null != orderLogistics.getDriverId()){
@@ -3251,7 +3258,7 @@
            driverService.updateById(driver);
        }
        
        if((orderLogistics.getState() == 10 || orderLogistics.getState() == 12) && null != orderLogistics.getDriverId()){
        if(orderLogistics.getState() == 10 || orderLogistics.getState() == 12){
            //修改行程信息
            boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", null, null, orderLogistics.getTripId(), null, null, null, null);
            if(!updateTrip){
@@ -3260,11 +3267,10 @@
                    if(updateTrip){
                        break;
                    }
                    Thread.sleep(5000L);
                    Thread.sleep(3000L);
                }
            }
        }
        log.warn("取消订单:{}   {}", System.currentTimeMillis(), orderLogistics.getTripId());
        //添加消息
        systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功取消包裹订单,谢谢使用!" : language == 2 ? "You've cancelled the delivery order successfully, thank you for using I-GO "
                : "Vous avez annulé la commande de livraison avec succès, merci d’utiliser I-GO", orderLogistics.getUserId(), 1);