Pu Zhibing
6 天以前 4c99ee7028c3fe58a2cd4b8273b22c75c45574fc
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -10,7 +10,6 @@
import com.stylefeng.guns.modular.smallLogistics.model.OrderLogisticsSpread;
import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService;
import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsSpreadService;
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
import com.stylefeng.guns.modular.system.dao.*;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
@@ -18,39 +17,31 @@
import com.stylefeng.guns.modular.system.util.GoogleMap.DistancematrixVo;
import com.stylefeng.guns.modular.system.util.GoogleMap.FleetEngineUtil;
import com.stylefeng.guns.modular.system.util.GoogleMap.GoogleMapUtil;
import com.stylefeng.guns.modular.system.util.itextpdf.HtmlToPdfUtils;
import com.stylefeng.guns.modular.system.util.GoogleMap.ReverseGeocodeVo;
import com.stylefeng.guns.modular.system.util.quartz.QuartzUtil;
import com.stylefeng.guns.modular.system.util.quartz.jobs.OrderTimeOutJob;
import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
import org.apache.shiro.util.StringUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.quartz.JobDataMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
public class OrderLogisticsServiceImpl extends ServiceImpl<OrderLogisticsMapper, OrderLogistics> implements IOrderLogisticsService {
    
    Logger log = LoggerFactory.getLogger(this.getClass());
    @Resource
    private OrderLogisticsMapper orderLogisticsMapper;
    
@@ -141,6 +132,9 @@
    
    @Autowired
    private IOrderPositionService orderPositionService;
    @Resource
    private QuartzUtil quartzUtil;
@@ -192,9 +186,10 @@
            orderLogistics.setTripId(UUIDUtil.getRandomCode());
        }
        String value = redisUtil.getValue("DRIVER" + driver.getId());
        String tripId = redisUtil.getValue("trip" + orderLogistics.getUserId());
        if(ToolUtil.isNotEmpty(value)) {
            String[] split = value.split(",");
            DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0]));
            DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0]), tripId);
            //超时时间
            long timeOut = System.currentTimeMillis() + (distancematrix.getDuration() * 1000);
            orderLogistics.setEstimateArriveTime(new Date(timeOut));
@@ -204,6 +199,72 @@
        //修改司机为服务中
        driver.setState(3);
        driverService.updateById(driver);
        //检查google车辆信息或者添加新的车辆信息
        Car car = carService.selectById(orderLogistics.getCarId());
        if(ToolUtil.isEmpty(car.getVehicleId())){
            car.setVehicleId(UUIDUtil.getRandomCode());
            carService.updateById(car);
        }
        String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId());
        if(ToolUtil.isEmpty(vehicles)){
            CarModel carModel = carModelMapper.selectById(car.getCarModelId());
            boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
            if(!createVehicles){
                for (int i = 0; i < 5; i++) {
                    createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
                    if(createVehicles){
                        break;
                    }
                    try {
                        Thread.sleep(3000L);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
        //修改google订单信息或者创建新的行程
        String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId());
        if(ToolUtil.isEmpty(trip)){
            JSONObject createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(),
                    orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString());
            JSONObject error = createTrip.getJSONObject("error");
            if(null != error){
                for (int i = 0; i < 5; i++) {
                    createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(),
                            orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString());
                    error = createTrip.getJSONObject("error");
                    String tripStatus = createTrip.getString("tripStatus");
                    if(null == error && "NEW".equals(tripStatus)){
                        break;
                    }
                    try {
                        Thread.sleep(3000L);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }else{
            //开始修改行程数据
            boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
            if(!updateTrip){
                for (int i = 0; i < 5; i++) {
                    updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
                    if(updateTrip){
                        break;
                    }
                    try {
                        Thread.sleep(3000L);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
    
        /**
         * 超时用户取消不收费的提醒
@@ -232,9 +293,10 @@
            jobDataMap.put("timeOut", timeOut);
            jobDataMap.put("driverTimeout", driverTimeout);
            jobDataMap.put("describe", language == 1 ? "您已超时" + driverTimeout + "分钟,用户可免费取消订单" : language == 2 ? "Reminder You are overdue for " + driverTimeout + " minutes The subscriber could cancel the order for free Confirm" : "Rappel Vous êtes en retard de " + driverTimeout + " minutes L’abonné peut annuler la commande gratuitement Confirmer");
            QuartzUtil.addSimpleQuartzTask(
                    new OrderTimeOutJob().buildQuartzJob("1_" + orderLogistics.getId() + "_4", "ORDER_TIME_OUT", jobDataMap)
            quartzUtil.addSimpleQuartzTask(OrderTimeOutJob.class,"1_" + orderLogistics.getId() + "_4", "ORDER_TIME_OUT", jobDataMap
                    , new Date(timeOut), timeOut, 0);
    
            //超时循环提醒
            jobDataMap = new JobDataMap();
@@ -246,50 +308,26 @@
            jobDataMap.put("timeOut", orderLogistics.getEstimateArriveTime().getTime());
            jobDataMap.put("driverTimeout", driverTimeout);
            jobDataMap.put("describe", "");
            QuartzUtil.addSimpleQuartzTask(
                    new OrderTimeOutJob().buildQuartzJob("3_" + orderLogistics.getId() + "_4", "ORDER_TIME_OUT", jobDataMap)
            quartzUtil.addSimpleQuartzTask(OrderTimeOutJob.class,"3_" + orderLogistics.getId() + "_4", "ORDER_TIME_OUT", jobDataMap
                    , orderLogistics.getEstimateArriveTime(), reminderRules.getCar() * 60000, -1);
        }
        new Thread(()->{
            try {
                Car car = carService.selectById(orderLogistics.getCarId());
                if(!StringUtils.hasLength(car.getVehicleId())){
                    car.setVehicleId(UUIDUtil.getRandomCode());
                    carService.updateById(car);
                }
                String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId());
                if(ToolUtil.isEmpty(trip)){
                    String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId());
                    if(ToolUtil.isEmpty(vehicles)){
                        CarModel carModel = carModelMapper.selectById(car.getCarModelId());
                        fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
                    }
                    fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(),
                            orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(),  orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString());
                }else{
                    //开始修改行程数据
                    fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null);
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }).start();
        
        //推送相关代码------------------start----------------
        new Thread(new Runnable() {
            @Override
            public void run() {
                pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
                pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "driver");
                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "driver");
            }
        }).start();
        Integer language1 = userInfoMapper.selectById(orderLogistics.getUserId()).getLanguage();
        systemNoticeService.addSystemNotice(2, language == 1 ? "您已成功抢得包裹订单,请及时联系客户!" :
                language == 2 ? "You have grabbed the delivery order, please contact the client timely."
                        : "Vous avez saisi la commande du livraison. Veuillez contacter le client en temps opportun.", orderLogistics.getDriverId());
        systemNoticeService.addSystemNotice(1, language == 1 ? "您的订单已指派给" + driver.getFirstName() + "师傅,请保持电话畅通!" :
                language == 2 ? "Your order has been assigned to the driver- " + driver.getFirstName() + ", please keep your line on."
        systemNoticeService.addSystemNotice(1, language1 == 1 ? "您的订单已指派给" + driver.getFirstName() + "师傅,请保持电话畅通!" :
                language1 == 2 ? "Your order has been assigned to the driver- " + driver.getFirstName() + ", please keep your line on."
                        : "Votre commande a été attribuée au chauffeur- " + driver.getFirstName() + ", S'il vous plaît, restez en ligne.", orderLogistics.getUserId());
        return ResultUtil.success();
    }
@@ -326,6 +364,7 @@
            long timeOutCancel = orderLogistics.getEstimateArriveTime().getTime() + driverTimeout;
            map.put("timeOutCancel", timeOutCancel);
        }
        map.put("isDispute", orderLogistics.getIsDispute());
        return map;
    }
@@ -345,13 +384,21 @@
     * @param state
     * @param lon
     * @param lat
     * @param address
     * @return
     * @throws Exception
     */
    @Override
    public ResultUtil process(Integer orderId, Integer state, Double lon, Double lat, String address, String pickUpCode, Integer language) throws Exception {
    public ResultUtil process(Integer orderId, Integer state, Double lon, Double lat, String pickUpCode, Integer language, Integer uid) throws Exception {
        OrderLogistics orderLogistics = this.selectById(orderId);
        String tripId = redisUtil.getValue("trip" + orderLogistics.getUserId());
        ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lon, tripId);
        if(null == reverseGeocode){
            return ResultUtil.error(language == 1 ? "无效的经纬度" : language == 2 ? "Invalid longitude and latitude" : "Longitude et latitude non valides");
        }
        String address = reverseGeocode.getAddress();
        if(!uid.equals(orderLogistics.getDriverId())){
            return ResultUtil.error(language == 1 ? "操作失败,请刷新订单" : language == 2 ? "Operation failed, please refresh the order" : "L’opération a échoué, veuillez actualiser la commande");
        }
        if(orderLogistics.getState().compareTo(state) == 0){
            return ResultUtil.error(language == 1 ? "不能重复操作" : language == 2 ? "Unable to recur operate" : "Impossible de récurrence des opérer");
        }
@@ -363,21 +410,21 @@
        }
        List<OrderLogisticsSpread> orderLogisticsId = spreadService.selectList(new EntityWrapper<OrderLogisticsSpread>().eq("orderLogisticsId", orderLogistics.getId()).eq("payType",4));
        Integer language1 = userInfoMapper.selectById(orderLogistics.getUserId()).getLanguage();
    
        String tripStatus = "UNKNOWN_TRIP_STATUS";
        switch (state){
            case 3://出发前往预约点
                orderLogistics.setState(3);
                orderLogistics.setSetOutTime(new Date());
                systemNoticeService.addSystemNotice(1, language == 1 ? "司机已出发,请耐心等待" : language == 2 ? "The driver is on the way, please wait." : "Le chauffeur est en route. Veuillez patienter.", orderLogistics.getUserId());
                systemNoticeService.addSystemNotice(1, language1 == 1 ? "司机已出发,请耐心等待" : language1 == 2 ? "The driver is on the way, please wait." : "Le chauffeur est en route. Veuillez patienter.", orderLogistics.getUserId());
                pushUtil.pushDriverPosition(orderId, 4);
                tripStatus = "ENROUTE_TO_PICKUP";
                break;
            case 4://到达预约点,等待客户上车
                orderLogistics.setState(4);
                orderLogistics.setArriveTime(new Date());
                systemNoticeService.addSystemNotice(1, language == 1 ? "司机已到达您设置的预约地点。" : language == 2 ? "The driver has arrived at the reserved location." : "Le chauffeur est arrivé à l'endroit prévu.", orderLogistics.getUserId());
                systemNoticeService.addSystemNotice(1, language1 == 1 ? "司机已到达您设置的预约地点。" : language1 == 2 ? "The driver has arrived at the reserved location." : "Le chauffeur est arrivé à l'endroit prévu.", orderLogistics.getUserId());
                tripStatus = "ARRIVED_AT_PICKUP";
                break;
            case 5://开始服务
@@ -396,29 +443,36 @@
                orderLogistics.setGetoffTime(new Date());
                orderLogistics.setEndServiceTime(new Date());
                orderLogistics.setState(6);
                tripStatus = "COMPLETE";
                tripStatus = "";
                break;
        }
        this.updateById(orderLogistics);
    
        Driver driver = driverService.selectById(orderLogistics.getDriverId());
        String finalTripStatus = tripStatus;
        new Thread(()->{
            Car car = carMapper.selectById(driver.getCarId());
            //修改行程数据
            try {
                fleetEngineUtil.updateTrip(finalTripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null);
            } catch (Exception e) {
                throw new RuntimeException(e);
        //修改行程数据
        if(ToolUtil.isNotEmpty(tripStatus)){
            Car car = carService.selectById(orderLogistics.getCarId());
            boolean updateTrip = fleetEngineUtil.updateTrip(tripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
            if(!updateTrip){
                for (int i = 0; i < 5; i++) {
                    updateTrip = fleetEngineUtil.updateTrip(tripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
                    if(updateTrip){
                        break;
                    }
                    try {
                        Thread.sleep(3000L);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }).start();
        }
        
        // TODO: 2020/6/5 推送状态
        new Thread(new Runnable() {
            @Override
            public void run() {
                pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
                pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "driver");
                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "driver");
            }
        }).start();
        
@@ -553,16 +607,16 @@
        new Thread(new Runnable() {
            @Override
            public void run() {
                pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "");
                pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "driver");
                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "driver");
            }
        }).start();
        Integer language1 = userInfoMapper.selectById(orderLogistics.getUserId()).getLanguage();
        systemNoticeService.addSystemNotice(2, language == 1 ? "您已成功抢得包裹订单,请及时联系客户!" :
                language == 2 ? "You have grabbed the delivery order, please contact the client timely."
                        : "Vous avez saisi la commande du livraison. Veuillez contacter le client en temps opportun.", orderLogistics.getDriverId());
        systemNoticeService.addSystemNotice(1, language == 1 ? "您的订单已指派给" + driver.getFirstName() + "师傅,请保持电话畅通!" :
                language == 2 ? "Your order has been assigned to the driver- " + driver.getFirstName() + ", please keep your line on."
        systemNoticeService.addSystemNotice(1, language1 == 1 ? "您的订单已指派给" + driver.getFirstName() + "师傅,请保持电话畅通!" :
                language1 == 2 ? "Your order has been assigned to the driver- " + driver.getFirstName() + ", please keep your line on."
                        : "Votre commande a été attribuée au chauffeur- " + driver.getFirstName() + ", S'il vous plaît, restez en ligne.", orderLogistics.getUserId());
        return ResultUtil.success();
@@ -648,15 +702,15 @@
                Element email2_user = document.getElementById("email2_user");
                email2_user.text("Bonjour " + userInfo.getFirstName() + " " + userInfo.getLastName());
                Element email2_content = document.getElementById("email2_content");
                email2_content.text("Le code de ramassage de votre colis est " + random + ", veuillez effectuer la verification dans les 5minutes.");
                email2_content.text("Le code de ramassage de votre colis est " + random + ", veuillez effectuer la verification dans les 5 minutes.");
            }
            EmailUtil.send(userInfo.getEmail(), language == 1 ? "取件码邮件" : language == 2 ? "Pickup code" : "Code de ramassage",  document.html());
            //开始生成pdf收据和html收据
            File file = new File("/usr/local/nginx/html/files/html/");
            File file = new File("/home/igotechgh/nginx/html/files/html/");
            if(!file.exists()){
                file.mkdirs();
            }
            file = new File("/usr/local/nginx/html/files/html/code_" + orderId + ".html");
            file = new File("/home/igotechgh/nginx/html/files/html/code_" + orderId + ".html");
            if(!file.exists()){
                file.createNewFile();
            }
@@ -665,7 +719,7 @@
            fileWriter.flush();
            fileWriter.close();
            String link ="http://182.160.16.251:81/files/html/code_" + orderId + ".html";
            String link ="https://igo.i-go.group/files/html/code_" + orderId + ".html";
            TEmail tEmail = new TEmail();
            tEmail.setLink(link);
            tEmail.setUserId(userInfo.getId());
@@ -715,22 +769,32 @@
    @Override
    public void updateEndAddress(Integer orderId, Integer status) {
        OrderLogistics orderLogistics = this.selectById(orderId);
        if(ToolUtil.isEmpty(orderLogistics.getDestinationLon())){
            return;
        }
        if(2 == status){
            orderLogistics.setEndLon(Double.valueOf(orderLogistics.getDestinationLon()));
            orderLogistics.setEndLat(Double.valueOf(orderLogistics.getDestinationLat()));
            orderLogistics.setEndAddress(orderLogistics.getDestination());
            //修改google地图行程终点
            try {
                fleetEngineUtil.updateTrip(null, null, null, orderLogistics.getTripId(),
                        null, null, orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString());
            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            Car car = carService.selectById(orderLogistics.getCarId());
            boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(),
                    null, null, orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString(), orderLogistics.getId(), 4);
            if(!updateTrip){
                for (int i = 0; i < 5; i++) {
                    updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(),
                            null, null, orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString(), orderLogistics.getId(), 4);
                    if(updateTrip){
                        break;
                    }
                    try {
                        Thread.sleep(3000L);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
            }
        }
        orderLogistics.setDestinationLon("");
        orderLogistics.setDestination("");
        orderLogistics.setDestinationLat("");
        this.updateById(orderLogistics);
        pushUtil.pushModifyAddress(1, orderLogistics.getUserId(), orderId, 4, status);
    }
@@ -747,6 +811,7 @@
        OrderLogistics orderLogistics = this.selectById(orderId);
        if(orderLogistics.getState() == 6){//服务中的时候获取实时费用数据
            this.setMoney(orderLogistics, 0D, 0D);
            orderLogistics.setOrderMoney(orderLogistics.getOrderMoney() + orderLogistics.getPriceDifference());
        }
    
        Map<String, Object> map = new HashMap<>();
@@ -768,6 +833,7 @@
        map.put("discountMoney", orderLogistics.getDiscountMoney());//折扣抵扣金额
        map.put("discount", orderLogistics.getDiscount());//折扣
        map.put("priceDifference", orderLogistics.getPriceDifference());//补差价
        map.put("isDispute", orderLogistics.getIsDispute());
        return map;
    }
    
@@ -783,6 +849,9 @@
     */
    public OrderLogistics setMoney(OrderLogistics orderLogistics, Double parkingFee, Double crossingFee) throws Exception {
        Map<String, Object> query1 = systemPriceMapper.query(orderLogistics.getCompanyId(), 4, orderLogistics.getServerCarModelId());
        if(null == query1){
            throw new RuntimeException("请先添加计费规则");
        }
        //开始根据不同的方式计算金额
        double amount = 0;
        JSONObject jsonObject = JSON.parseObject(query1.get("content").toString());
@@ -993,10 +1062,13 @@
     * @throws Exception
     */
    @Override
    public ResultUtil confirmFees(Integer language, Integer orderId, Integer type, Double parkingFee, Double crossingFee) throws Exception {
    public ResultUtil confirmFees(Integer language, Integer orderId, Integer type, Double parkingFee, Double crossingFee, Integer uid) throws Exception {
        OrderLogistics orderLogistics = this.selectById(orderId);
        if(!uid.equals(orderLogistics.getDriverId())){
            return ResultUtil.error(language == 1 ? "操作失败,请刷新订单" : language == 2 ? "Operation failed, please refresh the order" : "L’opération a échoué, veuillez actualiser la commande");
        }
        if(6 != orderLogistics.getState()){
            return ResultUtil.error("操作异常,请刷新订单");
            return ResultUtil.error(language == 1 ? "操作失败,请刷新订单" : language == 2 ? "Operation failed, please refresh the order" : "L’opération a échoué, veuillez actualiser la commande");
        }
        if(orderLogistics.getArriveTime()==null){
            orderLogistics.setArriveTime(orderLogistics.getStartServiceTime());
@@ -1057,10 +1129,48 @@
            orderLogistics.setBindId("");
        }
        this.updateById(orderLogistics);
        //修改行程数据
        Car car = carService.selectById(orderLogistics.getCarId());
        boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
        if(!updateTrip){
            for (int i = 0; i < 5; i++) {
                updateTrip = fleetEngineUtil.updateTrip("COMPLETE", car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null, orderLogistics.getId(), 4);
                if(updateTrip){
                    orderLogistics.setIsover(1);
                    this.updateById(orderLogistics);
                    break;
                }
                try {
                    Thread.sleep(3000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }else{
            orderLogistics.setIsover(1);
            this.updateById(orderLogistics);
        }
        //上报行程
        boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderLogistics.getTripId());
        if(!reportBillableEvent){
            for (int i = 0; i < 5; i++) {
                reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderLogistics.getTripId());
                if(reportBillableEvent){
                    break;
                }
                try {
                    Thread.sleep(3000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
        
        
        pushUtil.removeTask(orderId, 4);//删除定时任务,结束推送数据
        systemNoticeService.addSystemNotice(1, language == 1 ? "司机已结束本次行程,谢谢使用" : language == 2 ?
        UserInfo userInfo = userInfoMapper.selectById(orderLogistics.getUserId());
        Integer language1 = userInfo.getLanguage();
        systemNoticeService.addSystemNotice(1, language1 == 1 ? "司机已结束本次行程,谢谢使用" : language1 == 2 ?
                "The driver has finished the trip,thank you for using I-GO" : "Le chauffeur a terminé le trajet, merci d'utiliser I-GO", orderLogistics.getUserId());
        
        //回滚司机状态为空闲
@@ -1072,20 +1182,8 @@
        new Thread(new Runnable() {
            @Override
            public void run() {
                pushUtil.pushOrderState(1, finalOrderTaxi.getUserId(), finalOrderTaxi.getId(), 4, finalOrderTaxi.getState(), 0, "");
                pushUtil.pushOrderState(2, finalOrderTaxi.getDriverId(), finalOrderTaxi.getId(), 4, finalOrderTaxi.getState(), 0, "");
            }
        }).start();
        //上报google
        OrderLogistics finalOrderLogistics = orderLogistics;
        new Thread(()->{
            try {
                fleetEngineUtil.reportBillableEvent(finalOrderLogistics.getTripId());
                log.warn("上报时间:{},tripid:{},created_at:{},completed_at:{}", System.currentTimeMillis(), finalOrderLogistics.getTripId(),
                        finalOrderLogistics.getInsertTime().getTime(), finalOrderLogistics.getEndServiceTime().getTime());
            }catch (Exception e){
                e.printStackTrace();
                pushUtil.pushOrderState(1, finalOrderTaxi.getUserId(), finalOrderTaxi.getId(), 4, finalOrderTaxi.getState(), 0, "", "driver");
                pushUtil.pushOrderState(2, finalOrderTaxi.getDriverId(), finalOrderTaxi.getId(), 4, finalOrderTaxi.getState(), 0, "", "driver");
            }
        }).start();
        return ResultUtil.success();
@@ -1119,12 +1217,12 @@
        Map<String, Double> distance = GeodesyUtil.getDistance(now, old);
        if(null != distance){
            Double distance1 = distance.get("WGS84");
            if(distance1 > 50 &&  Arrays.asList(3, 4).contains(orderLogistics.getState())){//大于50米表示在移动
            if(distance1 > 30 &&  Arrays.asList(3, 4).contains(orderLogistics.getState())){//大于50米表示在移动
                orderLogistics.setToStartPointMileage(new BigDecimal(orderLogistics.getToStartPointMileage()).add(new BigDecimal(distance1)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                this.updateById(orderLogistics);
                return true;
            }
            if(distance1 > 50 && orderLogistics.getState()==5){//大于50米表示在移动
            if(distance1 > 30 && orderLogistics.getState()==5){//大于50米表示在移动
                orderLogistics.setMileage(new BigDecimal(orderLogistics.getMileage()).add(new BigDecimal(distance1)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                this.updateById(orderLogistics);
                return true;