Pu Zhibing
6 天以前 4c99ee7028c3fe58a2cd4b8273b22c75c45574fc
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -41,12 +41,15 @@
import org.jsoup.nodes.Element;
import org.jsoup.nodes.FormElement;
import org.jsoup.select.Elements;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
@@ -59,10 +62,13 @@
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class OrderLogisticsServiceImpl extends ServiceImpl<OrderLogisticsMapper, OrderLogistics> implements IOrderLogisticsService {
    private Logger log = LoggerFactory.getLogger(OrderLogisticsServiceImpl.class);
    @Resource
    private SystemPriceMapper systemPriceMapper;
@@ -209,7 +215,7 @@
    private ICarService carService;
    
    @Resource
    private DriverWorkMapper driverWorkMapper;
    private IDriverWorkService driverWorkService;
    
    
    @Value("${filePath}")
@@ -254,7 +260,7 @@
        String[] split = endLonLat.split(",");
        Double lng = Double.valueOf(split[0]);
        Double lat = Double.valueOf(split[1]);
        ResultUtil<Map<String, Object>> price = this.getPrice1(type, startLonLat.split(",")[0], startLonLat.split(",")[1], lng.toString(), lat.toString(), language);
        ResultUtil<Map<String, Object>> price = this.getPrice1(uid, type, startLonLat.split(",")[0], startLonLat.split(",")[1], lng.toString(), lat.toString(), language);
        if(price.getCode() != 200){
            return price;
        }
@@ -273,11 +279,11 @@
     * @return
     * @throws Exception
     */
    public ResultUtil queryPayMoney(Integer number, Integer type, String startLonLat, String endLonLat, String endAddress, Integer language) throws Exception{
    public ResultUtil queryPayMoney(Integer uid, Integer number, Integer type, String startLonLat, String endLonLat, String endAddress, Integer language) throws Exception{
        String[] split = endLonLat.split(",");
        Double lng = Double.valueOf(split[0]);
        Double lat = Double.valueOf(split[1]);
        ResultUtil<Map<String, Object>> price = this.getPrice1(type, startLonLat.split(",")[0], startLonLat.split(",")[1], lng.toString(), lat.toString(), language);
        ResultUtil<Map<String, Object>> price = this.getPrice1(uid, type, startLonLat.split(",")[0], startLonLat.split(",")[1], lng.toString(), lat.toString(), language);
        if(price.getCode() == 200 && type == 5){
            Map<String, Object> data = price.getData();
            Double ordinary = Double.valueOf(data.get("ordinary").toString());
@@ -327,7 +333,7 @@
        endAddress = endAddress.replaceAll("& #40;", "(");
        endAddress = endAddress.replaceAll("& #41;", ")");
        OrderLogistics orderLogistics = new OrderLogistics();
        Company query = companyCityService.query1(placementLon, placementLat);
        Company query = companyCityService.query1(uid, placementLon, placementLat);
        if(null == query){
            return ResultUtil.error(language == 1 ? "该地点暂无企业服务" : language == 2 ? "No service yet at this area" : "Pas encore de service dans cette zone");
        }
@@ -340,7 +346,8 @@
        orderLogistics.setRemark(remark);
        orderLogistics.setPlacementLon(Double.valueOf(placementLon));
        orderLogistics.setPlacementLat(Double.valueOf(placementLat));
        ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(Double.valueOf(placementLat), Double.valueOf(placementLon));
        String tripId = redisUtil.getValue("trip" + uid);
        ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(Double.valueOf(placementLat), Double.valueOf(placementLon), tripId);
        if(null == reverseGeocode){
            return ResultUtil.error(language == 1 ? "解析地址出错" : language == 2 ? "Address resolution error" : "Erreur de résolution d’adresse");
        }
@@ -363,7 +370,7 @@
        orderLogistics.setMileage(0D);
        orderLogistics.setIsReassign(1);
        orderLogistics.setReassignNotice(0);
        ResultUtil<Map<String, Object>> price = this.getPrice1(type, String.valueOf(startLon), String.valueOf(startLat), lng.toString(), lat.toString(), language);
        ResultUtil<Map<String, Object>> price = this.getPrice1(uid, type, String.valueOf(startLon), String.valueOf(startLat), lng.toString(), lat.toString(), language);
        if(price.getCode() != 200){
            return price;
        }
@@ -393,6 +400,8 @@
        orderLogistics.setTravelTime(null == travelTime ? new Date() : travelTime);
        orderLogistics.setOrderSource(orderSource);
        orderLogistics.setIsDelete(1);
        orderLogistics.setTripId(tripId);
        orderLogistics.setIsover(0);
        this.insert(orderLogistics);
        //添加消息
@@ -412,52 +421,52 @@
     * @return
     * @throws Exception
     */
    public ResultUtil<Map<String, Double>> getPrice(Integer type, String startLon, String startLat, String endLon, String endLat) throws Exception{
        Company query = companyCityService.query1(startLon, startLat);
        if(null == query){
            return ResultUtil.error("预约取货点暂无企业服务");
        }
        Double price1 = 0D;
        Double price2 = 0D;
        if(type == 4){//同城
            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null);
            Map<String, String> distance = gdMapElectricFenceUtil.getDistance(startLon + "," + startLat, endLon + "," + endLat, 1);
            String content = String.valueOf(query1.get("content"));
            JSONObject jsonObject = JSON.parseObject(content);
            String distance1 = distance.get("distance");
            Double dist = Double.valueOf(distance1) / 1000;
            if(dist.compareTo(0D) >= 0 && dist.compareTo(jsonObject.getDouble("num1")) < 0){
                price1 = jsonObject.getDouble("num2");
            }
            if(dist.compareTo(jsonObject.getDouble("num3")) >= 0 && dist.compareTo(jsonObject.getDouble("num4")) < 0){
                price1 = jsonObject.getDouble("num5");
            }
            if(dist.compareTo(jsonObject.getDouble("num6")) >= 0 && dist.compareTo(jsonObject.getDouble("num7")) < 0){
                price1 = jsonObject.getDouble("num8");
            }
            if(dist.compareTo(jsonObject.getDouble("num9")) >= 0 && dist.compareTo(jsonObject.getDouble("num10")) < 0){
                price1 = jsonObject.getDouble("num11");
            }
        }else{
            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null);
            String content = String.valueOf(query1.get("content"));
            JSONObject jsonObject = JSON.parseObject(content);
            price1 = jsonObject.getDouble("num1");
            price2 = jsonObject.getDouble("num2");
        }
        Map<String, Double> map = new HashMap<>();
        map.put("ordinary", price1);//普通
        map.put("precious", price2);//贵重
        return ResultUtil.success(map);
    }
//    public ResultUtil<Map<String, Double>> getPrice(Integer uid, Integer type, String startLon, String startLat, String endLon, String endLat) throws Exception{
//        Company query = companyCityService.query1(uid, startLon, startLat);
//        if(null == query){
//            return ResultUtil.error("预约取货点暂无企业服务");
//        }
//        Double price1 = 0D;
//        Double price2 = 0D;
//        if(type == 4){//同城
//            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null);
//            Map<String, String> distance = gdMapElectricFenceUtil.getDistance(startLon + "," + startLat, endLon + "," + endLat, 1);
//            String content = String.valueOf(query1.get("content"));
//            JSONObject jsonObject = JSON.parseObject(content);
//            String distance1 = distance.get("distance");
//            Double dist = Double.valueOf(distance1) / 1000;
//            if(dist.compareTo(0D) >= 0 && dist.compareTo(jsonObject.getDouble("num1")) < 0){
//                price1 = jsonObject.getDouble("num2");
//            }
//
//            if(dist.compareTo(jsonObject.getDouble("num3")) >= 0 && dist.compareTo(jsonObject.getDouble("num4")) < 0){
//                price1 = jsonObject.getDouble("num5");
//            }
//
//            if(dist.compareTo(jsonObject.getDouble("num6")) >= 0 && dist.compareTo(jsonObject.getDouble("num7")) < 0){
//                price1 = jsonObject.getDouble("num8");
//            }
//
//            if(dist.compareTo(jsonObject.getDouble("num9")) >= 0 && dist.compareTo(jsonObject.getDouble("num10")) < 0){
//                price1 = jsonObject.getDouble("num11");
//            }
//        }else{
//            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null);
//            String content = String.valueOf(query1.get("content"));
//            JSONObject jsonObject = JSON.parseObject(content);
//            price1 = jsonObject.getDouble("num1");
//            price2 = jsonObject.getDouble("num2");
//        }
//        Map<String, Double> map = new HashMap<>();
//        map.put("ordinary", price1);//普通
//        map.put("precious", price2);//贵重
//        return ResultUtil.success(map);
//    }
    public ResultUtil<Map<String, Object>> getPrice1(Integer type, String startLon, String startLat, String endLon, String endLat, Integer language) throws Exception{
        Company query = companyCityService.query1(startLon, startLat);
    public ResultUtil<Map<String, Object>> getPrice1(Integer uid, Integer type, String startLon, String startLat, String endLon, String endLat, Integer language) throws Exception{
        Company query = companyCityService.query1(uid, startLon, startLat);
        if(null == query){
            return ResultUtil.error(language == 1 ? "预约取货点暂无企业服务" : language == 2 ?
                    "No service yet at the reserved pickup point." : "Les points de ramassage prévus ne sont pas disponibles pour le moment.");
@@ -468,8 +477,9 @@
        Double discountMoney = 0D;
        Integer activityId = null;
        if(type == 4){//同城
            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null);
            DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(startLat), Double.valueOf(startLon), Double.valueOf(endLat), Double.valueOf(endLon));
            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null, language);
            String tripId = redisUtil.getValue("trip" + uid);
            DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(startLat), Double.valueOf(startLon), Double.valueOf(endLat), Double.valueOf(endLon), tripId);
            if(null == distancematrix){
                return ResultUtil.error(language == 1 ? "计算距离出错" : language == 2 ? "Errors in computing distance" : "Erreurs dans le calcul de la distance");
            }
@@ -496,7 +506,7 @@
                return ResultUtil.error(language == 1 ? "超出可服务范围" : language == 2 ? "Beyond service range" : "Au-delà de la portée de service");
            }
        }else{
            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null);
            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null, language);
            String content = String.valueOf(query1.get("content"));
            JSONObject jsonObject = JSON.parseObject(content);
            price1 = jsonObject.getDouble("num1");
@@ -540,12 +550,12 @@
                    if(ToolUtil.isNotEmpty(vehicle)){
                        integers = JSON.parseArray(vehicle).toJavaList(Integer.class);
                    }
                    Company query = companyCityService.query1(String.valueOf(orderLogistics.getStartLon()), String.valueOf(orderLogistics.getStartLat()));//获取起点所属分公司
                    Company query = companyCityService.query1(orderLogistics.getUserId(), String.valueOf(orderLogistics.getStartLon()), String.valueOf(orderLogistics.getStartLat()));//获取起点所属分公司
                    List<PushOrder> querys = pushOrderService.querys(null, 1, query.getId());//用专车的推单配置
                    for(int i = 1; i <= querys.size(); i++){
                        PushOrder pushOrder = pushOrderService.querys(i, 1, query.getId()).get(0);
                        //获取空闲司机
                        List<Driver> list = driverService.queryIdleDriver(orderLogistics.getType(), orderLogistics.getServerCarModelId(), orderLogistics.getStartLon(), orderLogistics.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机
                        List<Driver> list = driverService.queryIdleDriver(orderLogistics.getUserId(), orderLogistics.getType(), orderLogistics.getServerCarModelId(), orderLogistics.getStartLon(), orderLogistics.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机
                        System.err.println("【" + orderLogistics.getId() + "】空闲司机:" + JSON.toJSONString(list));
                        if(list.size() > 0){
                            double driverProportion = pushOrder.getDriverProportion() / 100;//推送占比计算成小数
@@ -564,8 +574,8 @@
                                }
    
                                Driver driver1 = driverService.selectById(driver.getId());
                                DriverWork driverWork = driverWorkMapper.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driver1.getId())
                                        .eq("state", 1).like("type", "4").getEntity());
                                DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driver1.getId())
                                        .eq("state", 1).like("type", "4"));
                                if(null == driverWork || driver1.getState() != 2){
                                    continue;
                                }
@@ -594,18 +604,25 @@
                                new Timer().schedule(new TimerTask() {
                                    @Override
                                    public void run() {
                                        Process process = null;
                                        try {
                                            process = Runtime.getRuntime().exec("rm -rf /usr/local/nginx/html/files/audio/" + fileName);
                                        } catch (IOException e) {
                                            throw new RuntimeException(e);
                                        }
                                        if (process != null) {
                                            process.destroy();
                                            // 使用Runtime执行命令
                                            Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName);
                                            // 读取命令的输出
                                            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                                            String line;
                                            while ((line = reader.readLine()) != null) {
                                                System.out.println(line);
                                            }
                                            // 等待命令执行完成
                                            process.waitFor();
                                            // 关闭流
                                            reader.close();
                                        } catch (IOException | InterruptedException e) {
                                            e.printStackTrace();
                                        }
                                    }
                                }, 30000);
                                pushUtil.pushOrderState(2, driver.getId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), pushOrder.getPushTime(), audioUrl);
                                pushUtil.pushOrderState(2, driver.getId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), pushOrder.getPushTime(), audioUrl, "user");
                            }
                        }
                        Thread.sleep(pushOrder.getPushTime() * 1000);//设置等待时间
@@ -650,6 +667,16 @@
    public ResultUtil placeOrderPackage(String remark, String placementLon, String placementLat, String startLon, String startLat, String startAddress,
                                        String recipient, String recipientPhone, String endLon, String endLat, String endAddress,
                                        Integer serverCarModelId, Integer driverId, Integer orderSource, Integer uid, Integer language) throws Exception {
        UserInfo userInfo = userInfoService.selectById(uid);
        if(ToolUtil.isEmpty(userInfo.getPhone())){
            return ResultUtil.error(language == 1 ? "请先绑定手机号码" : language == 2 ? "Please bind your mobile phone number first." : "Veuillez d’abord vous inscrire en liant votre numéro de téléphone portable.");
        }
        Company company = companyCityService.query1(uid, placementLon, placementLat);
        if(null != userInfo && null != company){
            userInfo.setCompanyId(company.getId());
            userInfoService.updateById(userInfo);
        }
        /**
         * 1.下了即时单就不能下预约单和即时单
         * 2.下了预约单和再下一张即时单不能再下预约单
@@ -671,6 +698,8 @@
            return ResultUtil.error(language == 1 ? "请选择服务车型" : language == 2 ? "Please select vehicle-type" : "Veuillez sélectionner le type de véhicule");
        }
    
        userInfo.setLanguage(language);
        userInfoService.updateById(userInfo);
        OrderLogistics orderLogistics = new OrderLogistics();
        orderLogistics.setType(4);
        orderLogistics.setUserId(uid);
@@ -682,7 +711,8 @@
        orderLogistics.setUrgent(1);
        orderLogistics.setCargoNumber(1);
    
        ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(Double.valueOf(placementLat), Double.valueOf(placementLon));
        String tripId = redisUtil.getValue("trip" + uid);
        ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(Double.valueOf(placementLat), Double.valueOf(placementLon), tripId);
        orderLogistics.setPlacementAddress(reverseGeocode.getAddress());
        orderLogistics.setStartLon(Double.valueOf(startLon));
        orderLogistics.setStartLat(Double.valueOf(startLat));
@@ -737,7 +767,7 @@
            String value = redisUtil.getValue("DRIVER" + driver.getId());
            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));
@@ -749,43 +779,81 @@
    
        orderLogistics.setIsReassign(1);
        orderLogistics.setIsDelete(1);
        orderLogistics.setTripId(UUIDUtil.getRandomCode());
        DistancematrixVo distancematrix1 = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), orderLogistics.getEndLat(), orderLogistics.getEndLon());
        orderLogistics.setTripId(tripId);
        orderLogistics.setIsover(0);
        DistancematrixVo distancematrix1 = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), orderLogistics.getEndLat(), orderLogistics.getEndLon(), tripId);
        Long distance1 = distancematrix1.getDistance();
        orderLogistics.setEstimatedMileage(new BigDecimal(distance1).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
        this.insert(orderLogistics);
    
        UserInfo userInfo = userInfoService.selectById(uid);
        userInfo.setLanguage(language);
        userInfoService.updateById(userInfo);
        new Thread(() -> {
            try {
                String vehicleId = null;
                if(null != orderLogistics.getDriverId()){
                    Driver driver = driverService.selectById(orderLogistics.getDriverId());
                    Car car = carMapper.selectById(driver.getCarId());
                    if(!StringUtils.hasLength(car.getVehicleId())){
                        car.setVehicleId(UUIDUtil.getRandomCode());
                        carMapper.updateById(car);
                    }
                    //查询车辆信息,没有则创建信息
                    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.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
                    }
                }
                //创建行程数据
                fleetEngineUtil.createTrip(vehicleId, 1, orderLogistics.getTripId(),
                        orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString());
            }catch (Exception e){
                e.printStackTrace();
        //google创建车辆信息
        String vehicleId = null;
        if(null != orderLogistics.getDriverId()){
            Driver driver = driverService.selectById(orderLogistics.getDriverId());
            Car car = carMapper.selectById(driver.getCarId());
            if(!StringUtils.hasLength(car.getVehicleId())){
                car.setVehicleId(UUIDUtil.getRandomCode());
                carMapper.updateById(car);
            }
        }).start();
            //查询车辆信息,没有则创建信息
            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;
                        }
                        Thread.sleep(5000L);
                    }
                }
                boolean updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
                if(!updateVehicles){
                    for (int i = 0; i < 5; i++) {
                        updateVehicles = fleetEngineUtil.updateVehicles("ONLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
                        if(updateVehicles){
                            break;
                        }
                        Thread.sleep(5000L);
                    }
                }
            }
        }
        //创建行程数据
        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());
        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());
                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);
                }
            }
        }
    
        if(orderSource == 2){//扫码下单
            Driver driver = driverService.selectById(orderLogistics.getDriverId());
@@ -814,14 +882,21 @@
            new Timer().schedule(new TimerTask() {
                @Override
                public void run() {
                    Process process = null;
                    try {
                        process = Runtime.getRuntime().exec("rm -rf /usr/local/nginx/html/files/audio/" + fileName);
                    } catch (IOException e) {
                        throw new RuntimeException(e);
                    }
                    if (process != null) {
                        process.destroy();
                        // 使用Runtime执行命令
                        Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName);
                        // 读取命令的输出
                        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                        String line;
                        while ((line = reader.readLine()) != null) {
                            System.out.println(line);
                        }
                        // 等待命令执行完成
                        process.waitFor();
                        // 关闭流
                        reader.close();
                    } catch (IOException | InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }, 30000);
@@ -829,8 +904,8 @@
            new Thread(new Runnable() {
                @Override
                public void run() {
                    pushUtil.pushOrderState(1, uid, orderLogistics.getId(), 4, 2, 0, "");
                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, 2, 0, finalAudioUrl);
                    pushUtil.pushOrderState(1, uid, orderLogistics.getId(), 4, 2, 0, "", "user");
                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, 2, 0, finalAudioUrl, "user");
                }
            }).start();
        }
@@ -838,14 +913,14 @@
    
        // TODO: 2021/5/11 修改,根据后台设定的派单范围查询范围内有无司机,将单子指派给距离最近的司机(距离相同随机取),范围内没有司机再进行推单流程
        if(orderLogistics.getState() == 1){
            Company query = companyCityService.query1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
            Company query = companyCityService.query1(uid, orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
            if(null == query){
                return ResultUtil.error(language == 1 ? "起点暂未企业提供服务" : language == 2 ? "Starting point no enterprise to provide services" : "Point de départ pas encore disponible pour les entreprises");
            }
            AssignOrder assignOrder = assignOrderService.selectOne(new EntityWrapper<AssignOrder>().eq("companyId", query.getId()).eq("type", 1));
            if(null != assignOrder && assignOrder.getPeople() > 0){//配置了指派规则才处理
                //获取空闲司机
                List<Driver> drivers = driverService.queryIdleDriver(4, orderLogistics.getServerCarModelId(), orderLogistics.getStartLon(), orderLogistics.getStartLat(), assignOrder.getDistance(), null);//获取范围内空闲司机
                List<Driver> drivers = driverService.queryIdleDriver(uid, 4, orderLogistics.getServerCarModelId(), orderLogistics.getStartLon(), orderLogistics.getStartLat(), assignOrder.getDistance(), null);//获取范围内空闲司机
                if(drivers.size() > 0){//有司机,直接指派给司机
                    Driver dr = null;
                    if(drivers.size() > 1){
@@ -858,7 +933,7 @@
                                String value = redisUtil.getValue("DRIVER" + drivers.get(j).getId());
                                if(null != 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 distance = distancematrix.getDistance();
                                    if((0 == m && null == driver) || (distance < m)){
                                        driver = drivers.get(j);
@@ -877,7 +952,7 @@
                            String value = redisUtil.getValue("DRIVER" + driver.getId());
                            if(null != 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 d = distancematrix.getDistance();
                                if((0 == m && null == dr) || (d.intValue() < m.intValue())){
                                    dr = driver;
@@ -890,18 +965,28 @@
                    }
    
                    Driver driver1 = driverService.selectById(dr.getId());
                    DriverWork driverWork = driverWorkMapper.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driver1.getId())
                            .eq("state", 1).like("type", "4").getEntity());
                    DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", driver1.getId())
                            .eq("state", 1).like("type", "4"));
                    if(driver1.getState() == 2 || null != driverWork){
                        orderLogistics.setDriverId(dr.getId());
                        orderLogistics.setCompanyId(dr.getFranchiseeId() != null && dr.getFranchiseeId() != 0 ? dr.getFranchiseeId() : (
                                dr.getCompanyId() != null && dr.getCompanyId() != 0 ? dr.getCompanyId() : 1));
                        orderLogistics.setState(2);
                        orderLogistics.setCarId(dr.getCarId());
                        CarService query1 = carServiceMapper.query(1, dr.getCarId());
                        CarService query1 = carServiceMapper.query(4, dr.getCarId());
                        orderLogistics.setServerCarModelId(query1.getServerCarModelId());
                        orderLogistics.setSnatchOrderTime(new Date());
    
                        String value = redisUtil.getValue("DRIVER" + driver1.getId());
                        if(ToolUtil.isNotEmpty(value)) {
                            String[] split = value.split(",");
                            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));
                            orderLogistics.setEstimateArriveMileage(distancematrix.getDistance());
                        }
                        dr.setState(3);
                        driverService.updateById(dr);
                        this.updateById(orderLogistics);
@@ -931,14 +1016,21 @@
                        new Timer().schedule(new TimerTask() {
                            @Override
                            public void run() {
                                Process process = null;
                                try {
                                    process = Runtime.getRuntime().exec("rm -rf /usr/local/nginx/html/files/audio/" + fileName);
                                } catch (IOException e) {
                                    throw new RuntimeException(e);
                                }
                                if (process != null) {
                                    process.destroy();
                                    // 使用Runtime执行命令
                                    Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName);
                                    // 读取命令的输出
                                    BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                                    String line;
                                    while ((line = reader.readLine()) != null) {
                                        System.out.println(line);
                                    }
                                    // 等待命令执行完成
                                    process.waitFor();
                                    // 关闭流
                                    reader.close();
                                } catch (IOException | InterruptedException e) {
                                    e.printStackTrace();
                                }
                            }
                        }, 30000);
@@ -946,10 +1038,12 @@
                        new Thread(new Runnable() {
                            @Override
                            public void run() {
                                pushUtil.pushOrderState(1, uid, orderLogistics.getId(), 4, 2, 0, "");
                                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, 2, 0, finalAudioUrl);
                                System.err.println("直推司机后推送司机订单状态");
                                pushUtil.pushOrderState(1, uid, orderLogistics.getId(), 4, 2, 0, "", "user");
                                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, 2, 0, finalAudioUrl, "user");
                            }
                        }).start();
                    }
                }
            }
@@ -983,10 +1077,14 @@
     * @throws Exception
     */
    @Override
    @Transactional
    public ResultUtil payLogisticsOrder(Integer payType, Integer bankCardId, Integer orderId,Integer couponId, Integer redDeduction, Integer type, Integer language) throws Exception {
        OrderLogistics orderLogistics = this.selectById(orderId);
        if(orderLogistics.getState() != 7){
        if(orderLogistics.getState() == 8 || orderLogistics.getState() == 9){
            return ResultUtil.error(language == 1 ? "订单已完成支付,不允许重复支付" : language == 2 ? "The order has been paid, recurring payments is not allowed." : "La commande a été payée, les paiements récurrents ne sont pas autorisés.", "");
        }
        if(orderLogistics.getState() != 7){
            return ResultUtil.error(language == 1 ? "订单不在待支付状态,不允许支付" : language == 2 ? "The order is no longer with Pending Payment, making payments is not allowed." : "La commande n’est plus en attente de paiement, il n’est pas permis d’effectuer des paiements.", "");
        }
        Integer uid = orderLogistics.getUserId();
        BigDecimal orderMoney = new BigDecimal(orderLogistics.getOrderMoney());
@@ -1016,7 +1114,6 @@
        //计算优惠券
        UserCouponRecord userCouponRecord = null;
        if(null != couponId){
            //TODO 待翻译
            if(null != redDeduction && 1 == redDeduction){
                return ResultUtil.error(language == 1 ? "优惠券和红包不能同时使用" : language == 2 ? "Coupons and lucky-promo cannot be used at the same time." : "Les coupons et les bonus ne peuvent pas être utilisés en même temps", "");
            }
@@ -1042,13 +1139,12 @@
        }
    
        //计算红包
        if(null != redDeduction && 1 == redDeduction){
        if(null != redDeduction && 1 == redDeduction && null == orderLogistics.getRedPacketId()){
            RedEnvelopePaymentSettings redEnvelopePaymentSettings = redEnvelopePaymentSettingsService.getRedEnvelopePaymentSettings();
            if(null != redEnvelopePaymentSettings){
                Double total = userRedPacketRecordService.queryRemainingAmount(uid);
                List<UserRedPacketRecord> userRedPacketRecords = userRedPacketRecordService.selectList(new EntityWrapper<UserRedPacketRecord>().eq("userId", uid)
                        .eq("state", 1).eq("companyId", orderLogistics.getCompanyId()).gt("remainingAmount", 0).orderBy("insertTime", false));
                Double total = userRedPacketRecords.stream().mapToDouble(UserRedPacketRecord::getRemainingAmount).sum();
                BigDecimal deductionRatio = redEnvelopePaymentSettings.getDeductionRatio();
                BigDecimal multiply1 = orderMoney.multiply(deductionRatio.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_EVEN);
                if(total > 0 && multiply1.doubleValue() > 0 && total.compareTo(multiply1.doubleValue()) >= 0){
@@ -1058,58 +1154,47 @@
                    //获取红包id
                    JSONArray jsonArray = new JSONArray();
                    for (UserRedPacketRecord userRedPacketRecord : userRedPacketRecords) {
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("id", userRedPacketRecord.getId());
                        BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount());
                        if(multiply1.compareTo(BigDecimal.ZERO) == 0){
                            break;
                        }
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("id", userRedPacketRecord.getId());
                        BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount());
                        if(multiply1.compareTo(remainingAmount) >= 0){
                            userRedPacketRecord.setRemainingAmount(0D);
                            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);
                            userRedPacketRecordService.updateById(userRedPacketRecord);
                        }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);
                            userRedPacketRecordService.updateById(userRedPacketRecord);
                            multiply1 = BigDecimal.ZERO;
                        }
                    }
                    if(userRedPacketRecords.size() > 0){
                        userRedPacketRecordService.updateBatchById(userRedPacketRecords);
                    }
                    orderLogistics.setRedPacketId(jsonArray.toJSONString());
                }
                if(total > 0 && total.compareTo(multiply1.doubleValue()) < 0){
                }else if(total > 0 && total.compareTo(multiply1.doubleValue()) < 0){
                    orderLogistics.setRedPacketMoney(total);
                    orderMoney = orderMoney.subtract(new BigDecimal(total)).setScale(2, RoundingMode.HALF_EVEN);
                    //获取红包id
                    JSONArray jsonArray = new JSONArray();
                    BigDecimal multiply = new BigDecimal(total);
                    for (UserRedPacketRecord userRedPacketRecord : userRedPacketRecords) {
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("id", userRedPacketRecord.getId());
                        BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount());
                        if(multiply.compareTo(BigDecimal.ZERO) == 0){
                            break;
                        }
                        if(multiply.compareTo(remainingAmount) >= 0){
                            userRedPacketRecord.setRemainingAmount(0D);
                            userRedPacketRecord.setEndTime(new Date());
                            userRedPacketRecord.setState(2);
                            multiply = multiply.subtract(remainingAmount).setScale(2, RoundingMode.HALF_EVEN);
                            jsonObject.put("money", remainingAmount);
                            jsonArray.add(jsonObject);
                            userRedPacketRecordService.updateById(userRedPacketRecord);
                        }else if(remainingAmount.compareTo(multiply) > 0){
                            userRedPacketRecord.setRemainingAmount(remainingAmount.subtract(multiply).setScale(2, RoundingMode.HALF_EVEN).doubleValue());
                            jsonObject.put("money", multiply);
                            jsonArray.add(jsonObject);
                            userRedPacketRecordService.updateById(userRedPacketRecord);
                            multiply = BigDecimal.ZERO;
                        }
                        jsonObject.put("money", userRedPacketRecord.getRemainingAmount());
                        jsonArray.add(jsonObject);
                        userRedPacketRecord.setRemainingAmount(0D);
                        userRedPacketRecord.setEndTime(new Date());
                        userRedPacketRecord.setState(2);
                    }
                    if(userRedPacketRecords.size() > 0){
                        userRedPacketRecordService.updateBatchById(userRedPacketRecords);
                    }
                    orderLogistics.setRedPacketId(jsonArray.toJSONString());
                }
@@ -1130,8 +1215,8 @@
            checkoutRequest.setRequestDescription("Travel completion payment");
            checkoutRequest.setCallbackUrl(callbackPath + "/base/wxPayOrderTaxi");
            checkoutRequest.setPendingRedirectUrl("");
            checkoutRequest.setSuccessRedirectUrl("http://182.160.16.251:81/payMoney/pages/success.html");
            checkoutRequest.setFailRedirectUrl("http://182.160.16.251:81/payMoney/pages/fail.html");
            checkoutRequest.setSuccessRedirectUrl("https://igo.i-go.group/payMoney/pages/success.html");
            checkoutRequest.setFailRedirectUrl("https://igo.i-go.group/payMoney/pages/fail.html");
            resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest);
            if(resultUtil.getCode()==200){
                paymentRecordService.saveData(1, null, null, orderId, 4, 1,
@@ -1139,7 +1224,6 @@
            }else{
                resultUtil = ResultUtil.error(language == 1 ? "支付失败" : language == 2 ? "Payment failure" : "Paiement échoué", "");
            }
            return resultUtil;
        }
        if(payType == 2) {//银行卡支付
@@ -1157,17 +1241,17 @@
            checkoutRequest.setRequestDescription("Travel completion payment");
            checkoutRequest.setCallbackUrl(callbackPath + "/base/wxPayOrderTaxi");
            checkoutRequest.setPendingRedirectUrl("");
            checkoutRequest.setSuccessRedirectUrl("http://182.160.16.251:81/payMoney/pages/success.html");
            checkoutRequest.setFailRedirectUrl("http://182.160.16.251:81/payMoney/pages/fail.html");
            checkoutRequest.setSuccessRedirectUrl("https://igo.i-go.group/payMoney/pages/success.html");
            checkoutRequest.setFailRedirectUrl("https://igo.i-go.group/payMoney/pages/fail.html");
            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){//余额支付
@@ -1202,52 +1286,50 @@
                userCouponRecord.setEndTime(new Date());
                userCouponRecordService.updateById(userCouponRecord);
            }
            if(null != orderLogistics.getRedPacketId()){
                JSONArray jsonArray = JSON.parseArray(orderLogistics.getRedPacketId());
                for (int i = 0; i < jsonArray.size(); i++) {
                    JSONObject jsonObject = jsonArray.getJSONObject(i);
                    Integer id1 = jsonObject.getInteger("id");
                    Double money = jsonObject.getDouble("money");
                    UserRedPacketRecord userRedPacketRecord = userRedPacketRecordService.selectById(id1);
                    userRedPacketRecord.setRemainingAmount(userRedPacketRecord.getRemainingAmount() - money);
                    if(0 == userRedPacketRecord.getRemainingAmount()){
                        userRedPacketRecord.setState(2);
                        userRedPacketRecord.setEndTime(new Date());
                    }
                    userRedPacketRecordService.updateById(userRedPacketRecord);
                }
            }
//            if(null != orderLogistics.getRedPacketId()){
//                JSONArray jsonArray = JSON.parseArray(orderLogistics.getRedPacketId());
//                for (int i = 0; i < jsonArray.size(); i++) {
//                    JSONObject jsonObject = jsonArray.getJSONObject(i);
//                    Integer id1 = jsonObject.getInteger("id");
//                    Double money = jsonObject.getDouble("money");
//                    UserRedPacketRecord userRedPacketRecord = userRedPacketRecordService.selectById(id1);
//                    userRedPacketRecord.setRemainingAmount(userRedPacketRecord.getRemainingAmount() - money);
//                    if(0 == userRedPacketRecord.getRemainingAmount()){
//                        userRedPacketRecord.setState(2);
//                        userRedPacketRecord.setEndTime(new Date());
//                    }
//                    userRedPacketRecordService.updateById(userRedPacketRecord);
//                }
//            }
    
            if(orderLogistics.getIsplatPay()==1){
                //添加已收入明细
                Company company = companyService.selectById(orderLogistics.getCompanyId());
                Double speMoney = company.getSpeMoney();
                BigDecimal d = null;//企业收入
                BigDecimal c = null;//司机收入
                if(company.getIsSpeFixedOrProportional() == 2){//固定
                    d = new BigDecimal(speMoney);
                    c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
                }
                if(company.getIsSpeFixedOrProportional() == 1){//比例
                    Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney();
                    d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN)));
                    c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
                }
                incomeService.saveData(1, orderLogistics.getCompanyId(), 2, orderLogistics.getId(), 4, d.doubleValue());
                incomeService.saveData(2, orderLogistics.getDriverId(), 2, orderLogistics.getId(), 4, c.doubleValue());
                Driver driver = driverService.selectById(orderLogistics.getDriverId());
                driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                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);
            //添加已收入明细
            Company company = companyService.selectById(orderLogistics.getCompanyId());
            Double speMoney = company.getSpeMoney();
            BigDecimal d = null;//企业收入
            BigDecimal c = null;//司机收入
            if(company.getIsSpeFixedOrProportional() == 2){//固定
                d = new BigDecimal(speMoney);
                c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
            }
            if(company.getIsSpeFixedOrProportional() == 1){//比例
                Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney();
                d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN)));
                c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
            }
            incomeService.saveData(1, orderLogistics.getCompanyId(), 2, orderLogistics.getId(), 4, d.doubleValue());
            incomeService.saveData(2, orderLogistics.getDriverId(), 2, orderLogistics.getId(), 4, c.doubleValue());
            Driver driver = driverService.selectById(orderLogistics.getDriverId());
            driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            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() {
                @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, "", "user");
                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
                }
            }).start();
@@ -1258,384 +1340,413 @@
    
    
            language = userInfo.getLanguage();
            String payTypeChinese = "";
            String payTypeEnglish = "";
            String payTypeFrench = "";
            if(orderLogistics.getPayType() == 3){
                payTypeChinese = "余额支付";
                payTypeEnglish = "I-GO Wallet";
                payTypeFrench = "Portefeuille I-GO";
            }
    
            if(ToolUtil.isNotEmpty(userInfo.getEmail())){
                String path = templatePath + "user/receiptLogistics.html";
                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());
                Car car = carMapper.selectById(orderLogistics.getCarId());
                Double aDouble = 0D;
                if(null != orderLogistics.getDriverId()){
                    aDouble = orderEvaluateService.queryDriverScore(orderLogistics.getDriverId());
                }
                if(1 == language){
                    document.getElementById("english").remove();
                    document.getElementById("french").remove();
                    document.getElementsByTag("title").get(0).text("I-GO电子收据");
                    Element title_chinese = document.getElementById("title_chinese");
                    title_chinese.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",您在I-GO此订单消费GHS " + orderLogistics.getPayMoney());
                    Element qbj_chinese = document.getElementById("qbj_chinese");
                    qbj_chinese.text("GHS " + new BigDecimal(orderLogistics.getStartMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element scf_chinese = document.getElementById("scf_chinese");
                    if(null != orderLogistics.getDurationMoney() && orderLogistics.getDurationMoney() > 0){
                        scf_chinese.text("GHS " + new BigDecimal(orderLogistics.getDurationMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element scf_chinese_div = document.getElementById("scf_chinese_div");
                        scf_chinese_div.remove();
                    }
                    Element lcf_chinese = document.getElementById("lcf_chinese");
                    if(null != orderLogistics.getMileageMoney() && orderLogistics.getMileageMoney() > 0){
                        lcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getMileageMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element lcf_chinese_div = document.getElementById("lcf_chinese_div");
                        lcf_chinese_div.remove();
                    }
                    Element ddf_chinese = document.getElementById("ddf_chinese");
                    if(null != orderLogistics.getWaitMoney() && orderLogistics.getWaitMoney() > 0){
                        ddf_chinese.text("GHS " + new BigDecimal(orderLogistics.getWaitMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element ddf_chinese_div = document.getElementById("ddf_chinese_div");
                        ddf_chinese_div.remove();
                    }
                    Element glf_chinese = document.getElementById("glf_chinese");
                    if(null != orderLogistics.getRoadTollMoney() && orderLogistics.getRoadTollMoney() > 0){
                        glf_chinese.text("GHS " + new BigDecimal(orderLogistics.getRoadTollMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element glf_chinese_div = document.getElementById("glf_chinese_div");
                        glf_chinese_div.remove();
                    }
                    Element tcf_chinese = document.getElementById("tcf_chinese");
                    if(null != orderLogistics.getParkMoney() && orderLogistics.getParkMoney() > 0){
                        tcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getParkMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element tcf_chinese_div = document.getElementById("tcf_chinese_div");
                        tcf_chinese_div.remove();
                    }
                    Element bcj_chinese = document.getElementById("bcj_chinese");
                    if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                        bcj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element bcj_chinese_div = document.getElementById("bcj_chinese_div");
                        bcj_chinese_div.remove();
                    }
                    if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                        Element yhq_chinese = document.getElementById("yhq_chinese");
                        yhq_chinese.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element yhq_chinese_div = document.getElementById("yhq_chinese_div");
                        yhq_chinese_div.remove();
                    }
                    if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){
                        Element zk_chinese = document.getElementById("zk_chinese");
                        zk_chinese.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element zk_chinese_div = document.getElementById("zk_chinese_div");
                        zk_chinese_div.remove();
                    }
                    if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){
                        Element hb_chinese = document.getElementById("hb_chinese");
                        hb_chinese.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element hb_chinese_div = document.getElementById("hb_chinese_div");
                        hb_chinese_div.remove();
                    }
                    Element xj_chinese = document.getElementById("xj_chinese");
                    xj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element pay_type_chinese = document.getElementById("pay_type_chinese");
                    pay_type_chinese.text(payTypeChinese);
                    Element pay_money_chinese = document.getElementById("pay_money_chinese");
                    pay_money_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element pdf_chinese = document.getElementById("pdf_chinese");
                    pdf_chinese.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4");
                    Element lost_item_chinese = document.getElementById("lost_item_chinese");
                    lost_item_chinese.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + orderId + "&orderType=4");
            Integer finalLanguage1 = language;
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        if(ToolUtil.isNotEmpty(userInfo.getEmail())){
                            String path = templatePath + "user/receiptLogistics.html";
                            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());
                            Car car = carMapper.selectById(orderLogistics.getCarId());
                            Double aDouble = 0D;
                            if(null != orderLogistics.getDriverId()){
                                aDouble = orderEvaluateService.queryDriverScore(orderLogistics.getDriverId());
                            }
                            Double aDouble1 = new BigDecimal(orderLogistics.getMileage()).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
                            Long serviceTime = new BigDecimal(orderLogistics.getEndServiceTime().getTime() - orderLogistics.getStartServiceTime().getTime()).divide(new BigDecimal(60000)).setScale(0, RoundingMode.HALF_EVEN).longValue();
                            if(1 == finalLanguage1){
                                document.getElementById("english").remove();
                                document.getElementById("french").remove();
                                document.getElementsByTag("title").get(0).text("包裹收据");
                                Element title_chinese = document.getElementById("title_chinese");
                                title_chinese.text(DateUtil.conversionFormat(finalLanguage1, sdf2.format(orderLogistics.getTravelTime())) + ",您在I-GO此订单消费GHS " + orderLogistics.getPayMoney());
                                Element qbj_chinese = document.getElementById("qbj_chinese");
                                qbj_chinese.text("GHS " + new BigDecimal(orderLogistics.getStartMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element scf_chinese = document.getElementById("scf_chinese");
                                if(null != orderLogistics.getDurationMoney() && orderLogistics.getDurationMoney() > 0){
                                    scf_chinese.text("GHS " + new BigDecimal(orderLogistics.getDurationMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element scf_chinese_div = document.getElementById("scf_chinese_div");
                                    scf_chinese_div.remove();
                                }
                                Element lcf_chinese = document.getElementById("lcf_chinese");
                                if(null != orderLogistics.getMileageMoney() && orderLogistics.getMileageMoney() > 0){
                                    lcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getMileageMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element lcf_chinese_div = document.getElementById("lcf_chinese_div");
                                    lcf_chinese_div.remove();
                                }
                                Element ddf_chinese = document.getElementById("ddf_chinese");
                                if(null != orderLogistics.getWaitMoney() && orderLogistics.getWaitMoney() > 0){
                                    ddf_chinese.text("GHS " + new BigDecimal(orderLogistics.getWaitMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element ddf_chinese_div = document.getElementById("ddf_chinese_div");
                                    ddf_chinese_div.remove();
                                }
                                Element glf_chinese = document.getElementById("glf_chinese");
                                if(null != orderLogistics.getRoadTollMoney() && orderLogistics.getRoadTollMoney() > 0){
                                    glf_chinese.text("GHS " + new BigDecimal(orderLogistics.getRoadTollMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element glf_chinese_div = document.getElementById("glf_chinese_div");
                                    glf_chinese_div.remove();
                                }
                                Element tcf_chinese = document.getElementById("tcf_chinese");
                                if(null != orderLogistics.getParkMoney() && orderLogistics.getParkMoney() > 0){
                                    tcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getParkMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element tcf_chinese_div = document.getElementById("tcf_chinese_div");
                                    tcf_chinese_div.remove();
                                }
                                Element bcj_chinese = document.getElementById("bcj_chinese");
                                if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                                    bcj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element bcj_chinese_div = document.getElementById("bcj_chinese_div");
                                    bcj_chinese_div.remove();
                                }
                                if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                                    Element yhq_chinese = document.getElementById("yhq_chinese");
                                    yhq_chinese.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element yhq_chinese_div = document.getElementById("yhq_chinese_div");
                                    yhq_chinese_div.remove();
                                }
                                if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){
                                    Element zk_chinese = document.getElementById("zk_chinese");
                                    zk_chinese.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element zk_chinese_div = document.getElementById("zk_chinese_div");
                                    zk_chinese_div.remove();
                                }
                                if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){
                                    Element hb_chinese = document.getElementById("hb_chinese");
                                    hb_chinese.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element hb_chinese_div = document.getElementById("hb_chinese_div");
                                    hb_chinese_div.remove();
                                }
                                Element xj_chinese = document.getElementById("xj_chinese");
                                xj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element pay_type_chinese = document.getElementById("pay_type_chinese");
                                pay_type_chinese.text("余额支付");
                                Element pay_money_chinese = document.getElementById("pay_money_chinese");
                                pay_money_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element dispute_chinese = document.getElementById("dispute_chinese");
                                if(null != orderLogistics.getIsDispute() && orderLogistics.getIsDispute() == 1){
                                    dispute_chinese.text("(注意: 争议订单,经过三方协商,平台最终定价为 GHS" + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN) + ")");
                                }else{
                                    dispute_chinese.remove();
                                }
                                Element pdf_chinese = document.getElementById("pdf_chinese");
                                pdf_chinese.attr("href", "https://igo.i-go.group/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4");
                                Element lost_item_chinese = document.getElementById("lost_item_chinese");
                                lost_item_chinese.attr("href", "https://igo.i-go.group/mailbox/user/lossGoods.html?language=" + finalLanguage1 + "&orderId=" + orderId + "&orderType=4");
//                    Element track_chinese = document.getElementById("track_chinese");
//                    track_chinese.attr("href", "http://182.160.16.251:81/mailbox/user/location.html");
                    Element pay_time_chinese = document.getElementById("pay_time_chinese");
                    pay_time_chinese.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime())));
                    Elements driver_chinese = document.getElementsByClass("driver_chinese");
                    for (int i = 0; i < driver_chinese.size(); i++) {
                        Element element = driver_chinese.get(i);
                        element.text(" " + driver.getFirstName() + "." + driver.getLastName());
                    }
                    Element cp_chinese = document.getElementById("cp_chinese");
                    cp_chinese.text("车牌:" + car.getCarLicensePlate());
                    Element pf_chinese = document.getElementById("pf_chinese");
                    pf_chinese.text("司机评分:" + aDouble);
                    Element start_address_chinese = document.getElementById("start_address_chinese");
                    start_address_chinese.text(orderLogistics.getStartAddress());
                    Element end_address_chinese = document.getElementById("end_address_chinese");
                    end_address_chinese.text(orderLogistics.getEndAddress());
                    Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId()));
                    Element server_tel_chinese = document.getElementById("server_tel_chinese");
                    server_tel_chinese.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
                }
                if(2 == language){
                    document.getElementById("chinese").remove();
                    document.getElementById("french").remove();
                    document.getElementsByTag("title").get(0).text("Receipt");
                    Element title_english = document.getElementById("title_english");
                    title_english.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",You spent GHS " + orderLogistics.getPayMoney() + " on the trip ");
                    Element qbj_english = document.getElementById("qbj_english");
                    qbj_english.text("GHS " + new BigDecimal(orderLogistics.getStartMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element scf_english = document.getElementById("scf_english");
                    if(null != orderLogistics.getDurationMoney() && orderLogistics.getDurationMoney() > 0){
                        scf_english.text("GHS " + new BigDecimal(orderLogistics.getDurationMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element scf_english_div = document.getElementById("scf_english_div");
                        scf_english_div.remove();
                    }
                    Element lcf_english = document.getElementById("lcf_english");
                    if(null != orderLogistics.getMileageMoney() && orderLogistics.getMileageMoney() > 0){
                        lcf_english.text("GHS " + new BigDecimal(orderLogistics.getMileageMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element lcf_english_div = document.getElementById("lcf_english_div");
                        lcf_english_div.remove();
                    }
                    Element ddf_english = document.getElementById("ddf_english");
                    if(null != orderLogistics.getWaitMoney() && orderLogistics.getWaitMoney() > 0){
                        ddf_english.text("GHS " + new BigDecimal(orderLogistics.getWaitMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element ddf_english_div = document.getElementById("ddf_english_div");
                        ddf_english_div.remove();
                    }
                    Element glf_english = document.getElementById("glf_english");
                    if(null != orderLogistics.getRoadTollMoney() && orderLogistics.getRoadTollMoney() > 0){
                        glf_english.text("GHS " + new BigDecimal(orderLogistics.getRoadTollMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element glf_english_div = document.getElementById("glf_english_div");
                        glf_english_div.remove();
                    }
                    Element tcf_english = document.getElementById("tcf_english");
                    if(null != orderLogistics.getParkMoney() && orderLogistics.getParkMoney() > 0){
                        tcf_english.text("GHS " + new BigDecimal(orderLogistics.getParkMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element tcf_english_div = document.getElementById("tcf_english_div");
                        tcf_english_div.remove();
                    }
                    Element bcj_english = document.getElementById("bcj_english");
                    if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                        bcj_english.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element bcj_english_div = document.getElementById("bcj_english_div");
                        bcj_english_div.remove();
                    }
                    if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                        Element yhq_english = document.getElementById("yhq_english");
                        yhq_english.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element yhq_english_div = document.getElementById("yhq_english_div");
                        yhq_english_div.remove();
                    }
                    if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){
                        Element zk_english = document.getElementById("zk_english");
                        zk_english.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element zk_english_div = document.getElementById("zk_english_div");
                        zk_english_div.remove();
                    }
                    if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){
                        Element hb_english = document.getElementById("hb_english");
                        hb_english.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element hb_english_div = document.getElementById("hb_english_div");
                        hb_english_div.remove();
                    }
                    Element xj_english = document.getElementById("xj_english");
                    xj_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element pay_type_english = document.getElementById("pay_type_english");
                    pay_type_english.text(payTypeEnglish);
                    Element pay_money_english = document.getElementById("pay_money_english");
                    pay_money_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element pdf_english = document.getElementById("pdf_english");
                    pdf_english.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4");
                    Element lost_item_english = document.getElementById("lost_item_english");
                    lost_item_english.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + orderId + "&orderType=4");
//                    track_chinese.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                                Element pay_time_chinese = document.getElementById("pay_time_chinese");
                                pay_time_chinese.text(DateUtil.conversionFormat(finalLanguage1, sdf1.format(orderLogistics.getTravelTime())));
                                Elements driver_chinese = document.getElementsByClass("driver_chinese");
                                for (int i = 0; i < driver_chinese.size(); i++) {
                                    Element element = driver_chinese.get(i);
                                    element.text(" " + driver.getFirstName() + "." + driver.getLastName());
                                }
                                Element cp_chinese = document.getElementById("cp_chinese");
                                cp_chinese.text("车牌:" + car.getCarLicensePlate());
                                Element pf_chinese = document.getElementById("pf_chinese");
                                pf_chinese.text("司机评分:" + aDouble);
                                Element lc_chinese = document.getElementById("lc_chinese");
                                lc_chinese.text("里程:" + aDouble1 + "公里 /" + serviceTime + "分钟");
                                Element start_address_chinese = document.getElementById("start_address_chinese");
                                start_address_chinese.text(orderLogistics.getStartAddress());
                                Element end_address_chinese = document.getElementById("end_address_chinese");
                                end_address_chinese.text(orderLogistics.getEndAddress());
                                Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId()));
                                Element server_tel_chinese = document.getElementById("server_tel_chinese");
                                server_tel_chinese.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
                            }
                            if(2 == finalLanguage1){
                                document.getElementById("chinese").remove();
                                document.getElementById("french").remove();
                                document.getElementsByTag("title").get(0).text("Delivery receipt");
                                Element title_english = document.getElementById("title_english");
                                title_english.text(DateUtil.conversionFormat(finalLanguage1, sdf2.format(orderLogistics.getTravelTime())) + ",You spent GHS " + orderLogistics.getPayMoney() + " on the trip ");
                                Element qbj_english = document.getElementById("qbj_english");
                                qbj_english.text("GHS " + new BigDecimal(orderLogistics.getStartMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element scf_english = document.getElementById("scf_english");
                                if(null != orderLogistics.getDurationMoney() && orderLogistics.getDurationMoney() > 0){
                                    scf_english.text("GHS " + new BigDecimal(orderLogistics.getDurationMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element scf_english_div = document.getElementById("scf_english_div");
                                    scf_english_div.remove();
                                }
                                Element lcf_english = document.getElementById("lcf_english");
                                if(null != orderLogistics.getMileageMoney() && orderLogistics.getMileageMoney() > 0){
                                    lcf_english.text("GHS " + new BigDecimal(orderLogistics.getMileageMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element lcf_english_div = document.getElementById("lcf_english_div");
                                    lcf_english_div.remove();
                                }
                                Element ddf_english = document.getElementById("ddf_english");
                                if(null != orderLogistics.getWaitMoney() && orderLogistics.getWaitMoney() > 0){
                                    ddf_english.text("GHS " + new BigDecimal(orderLogistics.getWaitMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element ddf_english_div = document.getElementById("ddf_english_div");
                                    ddf_english_div.remove();
                                }
                                Element glf_english = document.getElementById("glf_english");
                                if(null != orderLogistics.getRoadTollMoney() && orderLogistics.getRoadTollMoney() > 0){
                                    glf_english.text("GHS " + new BigDecimal(orderLogistics.getRoadTollMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element glf_english_div = document.getElementById("glf_english_div");
                                    glf_english_div.remove();
                                }
                                Element tcf_english = document.getElementById("tcf_english");
                                if(null != orderLogistics.getParkMoney() && orderLogistics.getParkMoney() > 0){
                                    tcf_english.text("GHS " + new BigDecimal(orderLogistics.getParkMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element tcf_english_div = document.getElementById("tcf_english_div");
                                    tcf_english_div.remove();
                                }
                                Element bcj_english = document.getElementById("bcj_english");
                                if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                                    bcj_english.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element bcj_english_div = document.getElementById("bcj_english_div");
                                    bcj_english_div.remove();
                                }
                                if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                                    Element yhq_english = document.getElementById("yhq_english");
                                    yhq_english.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element yhq_english_div = document.getElementById("yhq_english_div");
                                    yhq_english_div.remove();
                                }
                                if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){
                                    Element zk_english = document.getElementById("zk_english");
                                    zk_english.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element zk_english_div = document.getElementById("zk_english_div");
                                    zk_english_div.remove();
                                }
                                if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){
                                    Element hb_english = document.getElementById("hb_english");
                                    hb_english.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element hb_english_div = document.getElementById("hb_english_div");
                                    hb_english_div.remove();
                                }
                                Element xj_english = document.getElementById("xj_english");
                                xj_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element pay_type_english = document.getElementById("pay_type_english");
                                pay_type_english.text("I-GO Wallet");
                                Element pay_money_english = document.getElementById("pay_money_english");
                                pay_money_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element dispute_english = document.getElementById("dispute_english");
                                if(null != orderLogistics.getIsDispute() && orderLogistics.getIsDispute() == 1){
                                    dispute_english.text("(Note: Disputed order, after tripartite negotiation, the final pricing of the platform is GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN) + ")");
                                }else{
                                    dispute_english.remove();
                                }
                                Element pdf_english = document.getElementById("pdf_english");
                                pdf_english.attr("href", "https://igo.i-go.group/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4");
                                Element lost_item_english = document.getElementById("lost_item_english");
                                lost_item_english.attr("href", "https://igo.i-go.group/mailbox/user/lossGoods.html?language=" + finalLanguage1 + "&orderId=" + orderId + "&orderType=4");
//                    Element track_english = document.getElementById("track_english");
//                    track_english.attr("href", "http://182.160.16.251:81/mailbox/user/location.html");
                    Element pay_time_english = document.getElementById("pay_time_english");
                    pay_time_english.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime())));
                    Elements driver_english = document.getElementsByClass("driver_english");
                    for (int i = 0; i < driver_english.size(); i++) {
                        Element element = driver_english.get(i);
                        element.text(" " + driver.getFirstName() + "." + driver.getLastName());
                    }
                    Element cp_english = document.getElementById("cp_english");
                    cp_english.text("Number Plate:" + car.getCarLicensePlate());
                    Element pf_english = document.getElementById("pf_english");
                    pf_english.text("Driver Rating:" + aDouble);
                    Element start_address_english = document.getElementById("start_address_english");
                    start_address_english.text(orderLogistics.getStartAddress());
                    Element end_address_english = document.getElementById("end_address_english");
                    end_address_english.text(orderLogistics.getEndAddress());
                    Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId()));
                    Element server_tel_english = document.getElementById("server_tel_english");
                    server_tel_english.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
                }
                if(3 == language){
                    document.getElementById("chinese").remove();
                    document.getElementById("english").remove();
                    document.getElementsByTag("title").get(0).text("Reçu");
                    Element title_french = document.getElementById("title_french");
                    title_french.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande i-go1 le ");
                    Element qbj_french = document.getElementById("qbj_french");
                    qbj_french.text("GHS " + new BigDecimal(orderLogistics.getStartMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element scf_french = document.getElementById("scf_french");
                    if(null != orderLogistics.getDurationMoney() && orderLogistics.getDurationMoney() > 0){
                        scf_french.text("GHS " + new BigDecimal(orderLogistics.getDurationMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element scf_french_div = document.getElementById("scf_french_div");
                        scf_french_div.remove();
                    }
                    Element lcf_french = document.getElementById("lcf_french");
                    if(null != orderLogistics.getMileageMoney() && orderLogistics.getMileageMoney() > 0){
                        lcf_french.text("GHS " + new BigDecimal(orderLogistics.getMileageMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element lcf_french_div = document.getElementById("lcf_french_div");
                        lcf_french_div.remove();
                    }
                    Element ddf_french = document.getElementById("ddf_french");
                    if(null != orderLogistics.getWaitMoney() && orderLogistics.getWaitMoney() > 0){
                        ddf_french.text("GHS " + new BigDecimal(orderLogistics.getWaitMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element ddf_french_div = document.getElementById("ddf_french_div");
                        ddf_french_div.remove();
                    }
                    Element glf_french = document.getElementById("glf_french");
                    if(null != orderLogistics.getRoadTollMoney() && orderLogistics.getRoadTollMoney() > 0){
                        glf_french.text("GHS " + new BigDecimal(orderLogistics.getRoadTollMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element glf_french_div = document.getElementById("glf_french_div");
                        glf_french_div.remove();
                    }
                    Element tcf_french = document.getElementById("tcf_french");
                    if(null != orderLogistics.getParkMoney() && orderLogistics.getParkMoney() > 0){
                        tcf_french.text("GHS " + new BigDecimal(orderLogistics.getParkMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element tcf_french_div = document.getElementById("tcf_french_div");
                        tcf_french_div.remove();
                    }
                    Element bcj_french = document.getElementById("bcj_french");
                    if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                        bcj_french.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element bcj_french_div = document.getElementById("bcj_french_div");
                        bcj_french_div.remove();
                    }
                    if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                        Element yhq_french = document.getElementById("yhq_french");
                        yhq_french.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element yhq_french_div = document.getElementById("yhq_french_div");
                        yhq_french_div.remove();
                    }
                    if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){
                        Element zk_french = document.getElementById("zk_french");
                        zk_french.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element zk_french_div = document.getElementById("zk_french_div");
                        zk_french_div.remove();
                    }
                    if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){
                        Element hb_french = document.getElementById("hb_french");
                        hb_french.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element hb_french_div = document.getElementById("hb_french_div");
                        hb_french_div.remove();
                    }
                    Element xj_french = document.getElementById("xj_french");
                    xj_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element pay_type_french = document.getElementById("pay_type_french");
                    pay_type_french.text(payTypeFrench);
                    Element pay_money_french = document.getElementById("pay_money_french");
                    pay_money_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element pdf_french = document.getElementById("pdf_french");
                    pdf_french.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4");
                    Element lost_item_french = document.getElementById("lost_item_french");
                    lost_item_french.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + orderId + "&orderType=4");
//                    track_english.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                                Element pay_time_english = document.getElementById("pay_time_english");
                                pay_time_english.text(DateUtil.conversionFormat(finalLanguage1, sdf1.format(orderLogistics.getTravelTime())));
                                Elements driver_english = document.getElementsByClass("driver_english");
                                for (int i = 0; i < driver_english.size(); i++) {
                                    Element element = driver_english.get(i);
                                    element.text(" " + driver.getFirstName() + "." + driver.getLastName());
                                }
                                Element cp_english = document.getElementById("cp_english");
                                cp_english.text("Number Plate:" + car.getCarLicensePlate());
                                Element pf_english = document.getElementById("pf_english");
                                pf_english.text("Driver Rating:" + aDouble);
                                Element lc_english = document.getElementById("lc_english");
                                lc_english.text("Mileage:" + aDouble1 + "KM / " + serviceTime + "Minutes");
                                Element start_address_english = document.getElementById("start_address_english");
                                start_address_english.text(orderLogistics.getStartAddress());
                                Element end_address_english = document.getElementById("end_address_english");
                                end_address_english.text(orderLogistics.getEndAddress());
                                Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId()));
                                Element server_tel_english = document.getElementById("server_tel_english");
                                server_tel_english.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
                            }
                            if(3 == finalLanguage1){
                                document.getElementById("chinese").remove();
                                document.getElementById("english").remove();
                                document.getElementsByTag("title").get(0).text("Reçu de livraison");
                                Element title_french = document.getElementById("title_french");
                                title_french.text(DateUtil.conversionFormat(finalLanguage1, sdf2.format(orderLogistics.getTravelTime())) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande I-GO ");
                                Element qbj_french = document.getElementById("qbj_french");
                                qbj_french.text("GHS " + new BigDecimal(orderLogistics.getStartMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element scf_french = document.getElementById("scf_french");
                                if(null != orderLogistics.getDurationMoney() && orderLogistics.getDurationMoney() > 0){
                                    scf_french.text("GHS " + new BigDecimal(orderLogistics.getDurationMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element scf_french_div = document.getElementById("scf_french_div");
                                    scf_french_div.remove();
                                }
                                Element lcf_french = document.getElementById("lcf_french");
                                if(null != orderLogistics.getMileageMoney() && orderLogistics.getMileageMoney() > 0){
                                    lcf_french.text("GHS " + new BigDecimal(orderLogistics.getMileageMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element lcf_french_div = document.getElementById("lcf_french_div");
                                    lcf_french_div.remove();
                                }
                                Element ddf_french = document.getElementById("ddf_french");
                                if(null != orderLogistics.getWaitMoney() && orderLogistics.getWaitMoney() > 0){
                                    ddf_french.text("GHS " + new BigDecimal(orderLogistics.getWaitMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element ddf_french_div = document.getElementById("ddf_french_div");
                                    ddf_french_div.remove();
                                }
                                Element glf_french = document.getElementById("glf_french");
                                if(null != orderLogistics.getRoadTollMoney() && orderLogistics.getRoadTollMoney() > 0){
                                    glf_french.text("GHS " + new BigDecimal(orderLogistics.getRoadTollMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element glf_french_div = document.getElementById("glf_french_div");
                                    glf_french_div.remove();
                                }
                                Element tcf_french = document.getElementById("tcf_french");
                                if(null != orderLogistics.getParkMoney() && orderLogistics.getParkMoney() > 0){
                                    tcf_french.text("GHS " + new BigDecimal(orderLogistics.getParkMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element tcf_french_div = document.getElementById("tcf_french_div");
                                    tcf_french_div.remove();
                                }
                                Element bcj_french = document.getElementById("bcj_french");
                                if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                                    bcj_french.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element bcj_french_div = document.getElementById("bcj_french_div");
                                    bcj_french_div.remove();
                                }
                                if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                                    Element yhq_french = document.getElementById("yhq_french");
                                    yhq_french.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element yhq_french_div = document.getElementById("yhq_french_div");
                                    yhq_french_div.remove();
                                }
                                if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){
                                    Element zk_french = document.getElementById("zk_french");
                                    zk_french.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element zk_french_div = document.getElementById("zk_french_div");
                                    zk_french_div.remove();
                                }
                                if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){
                                    Element hb_french = document.getElementById("hb_french");
                                    hb_french.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element hb_french_div = document.getElementById("hb_french_div");
                                    hb_french_div.remove();
                                }
                                Element xj_french = document.getElementById("xj_french");
                                xj_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element pay_type_french = document.getElementById("pay_type_french");
                                pay_type_french.text("Portefeuille I-GO");
                                Element pay_money_french = document.getElementById("pay_money_french");
                                pay_money_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element dispute_french = document.getElementById("dispute_french");
                                if(null != orderLogistics.getIsDispute() && orderLogistics.getIsDispute() == 1){
                                    dispute_french.text("(Remarque: Il s’agit d’une commande contestée, et après des négociations entre trois parties, la plateforme l’a finalement tarifée à GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN) + ")");
                                }else{
                                    dispute_french.remove();
                                }
                                Element pdf_french = document.getElementById("pdf_french");
                                pdf_french.attr("href", "https://igo.i-go.group/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4");
                                Element lost_item_french = document.getElementById("lost_item_french");
                                lost_item_french.attr("href", "https://igo.i-go.group/mailbox/user/lossGoods.html?language=" + finalLanguage1 + "&orderId=" + orderId + "&orderType=4");
//                    Element track_french = document.getElementById("track_french");
//                    track_french.attr("href", "http://182.160.16.251:81/mailbox/user/location.html");
                    Element pay_time_french = document.getElementById("pay_time_french");
                    pay_time_french.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime())));
                    Elements driver_french = document.getElementsByClass("driver_french");
                    for (int i = 0; i < driver_french.size(); i++) {
                        Element element = driver_french.get(i);
                        element.text(" " + driver.getFirstName() + "." + driver.getLastName());
//                    track_french.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                                Element pay_time_french = document.getElementById("pay_time_french");
                                pay_time_french.text(DateUtil.conversionFormat(finalLanguage1, sdf1.format(orderLogistics.getTravelTime())));
                                Elements driver_french = document.getElementsByClass("driver_french");
                                for (int i = 0; i < driver_french.size(); i++) {
                                    Element element = driver_french.get(i);
                                    element.text(" " + driver.getFirstName() + "." + driver.getLastName());
                                }
                                Element cp_french = document.getElementById("cp_french");
                                cp_french.text("Plaque: GS " + car.getCarLicensePlate());
                                Element pf_french = document.getElementById("pf_french");
                                pf_french.text("Note du chauffeur: " + aDouble);
                                Element lc_french = document.getElementById("lc_french");
                                lc_french.text("Distance: " + aDouble1 + "km / " + serviceTime + "minutes");
                                Element start_address_french = document.getElementById("start_address_french");
                                start_address_french.text(orderLogistics.getStartAddress());
                                Element end_address_french = document.getElementById("end_address_french");
                                end_address_french.text(orderLogistics.getEndAddress());
                                Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId()));
                                Element server_tel_french = document.getElementById("server_tel_french");
                                server_tel_french.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
                            }
                            EmailUtil.send(userInfo.getEmail(), finalLanguage1 == 1 ? "包裹收据" : finalLanguage1 == 2 ? "Delivery receipt" : "Reçu de livraison",  document.html());
                            //开始生成pdf收据和html收据
                            File file = new File("/home/igotechgh/nginx/html/files/html/");
                            if(!file.exists()){
                                file.mkdirs();
                            }
                            file = new File("/home/igotechgh/nginx/html/files/html/parcel_receipt_" + orderId + ".html");
                            if(!file.exists()){
                                file.createNewFile();
                            }
                            FileWriter fileWriter = new FileWriter(file);
                            fileWriter.write(document.html());
                            fileWriter.flush();
                            fileWriter.close();
                            File file1 = new File("/home/igotechgh/nginx/html/files/pdf/");
                            if(!file1.exists()){
                                file1.mkdirs();
                            }
                            file1 = new File("/home/igotechgh/nginx/html/files/pdf/parcel_receipt_" + orderId + ".pdf");
                            if(!file1.exists()){
                                file1.createNewFile();
                            }
                            try{
                                FileOutputStream fileOutputStream = new FileOutputStream(file1);
                                HtmlToPdfUtils.convertToPdf("/home/igotechgh/nginx/html/files/html/parcel_receipt_" + orderId + ".html", "I-GO", fileOutputStream);
                            }catch (Exception e){
                                e.printStackTrace();
                                System.out.println("html转pdf异常");
                            }
                            String link ="https://igo.i-go.group/files/html/parcel_receipt_" + orderId + ".html";
                            TEmail tEmail = new TEmail();
                            tEmail.setLink(link);
                            tEmail.setUserId(userInfo.getId());
                            tEmail.setType(1);
                            tEmail.setName(finalLanguage1 == 1 ? "包裹收据" : finalLanguage1 == 2 ? "Delivery receipt" : "Reçu de livraison");
                            tEmail.setOrderId(orderId);
                            tEmail.setCreateTime(new Date());
                            int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1;
                            String week = EmailUtil.getWeek(finalLanguage1, i);
                            tEmail.setWeek(week);
                            boolean am = cn.hutool.core.date.DateUtil.isAM(new Date());
                            if(am){
                                tEmail.setAmOrPm(finalLanguage1 ==1?"上午": finalLanguage1 ==2?"morning":"matin");
                            }else {
                                tEmail.setAmOrPm(finalLanguage1 ==1?"下午": finalLanguage1 ==2?"afternoon":"après-midi");
                            }
                            emailService.insert(tEmail);
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    Element cp_french = document.getElementById("cp_french");
                    cp_french.text("Plaque: GS " + car.getCarLicensePlate());
                    Element pf_french = document.getElementById("pf_french");
                    pf_french.text("Note du chauffeur: " + aDouble);
                    Element start_address_french = document.getElementById("start_address_french");
                    start_address_french.text(orderLogistics.getStartAddress());
                    Element end_address_french = document.getElementById("end_address_french");
                    end_address_french.text(orderLogistics.getEndAddress());
                    Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId()));
                    Element server_tel_french = document.getElementById("server_tel_french");
                    server_tel_french.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
                }
                EmailUtil.send(userInfo.getEmail(), language == 1 ? "I-GO电子收据" : language == 2 ? "Receipt" : "Reçu",  document.html());
                //开始生成pdf收据和html收据
                File file = new File("/usr/local/nginx/html/files/html/");
                if(!file.exists()){
                    file.mkdirs();
                }
                file = new File("/usr/local/nginx/html/files/html/parcel_receipt_" + orderId + ".html");
                if(!file.exists()){
                    file.createNewFile();
                }
                FileWriter fileWriter = new FileWriter(file);
                fileWriter.write(document.html());
                fileWriter.flush();
                fileWriter.close();
                File file1 = new File("/usr/local/nginx/html/files/pdf/");
                if(!file1.exists()){
                    file1.mkdirs();
                }
                file1 = new File("/usr/local/nginx/html/files/pdf/parcel_receipt_" + orderId + ".pdf");
                if(!file1.exists()){
                    file1.createNewFile();
                }
                try{
                    FileOutputStream fileOutputStream = new FileOutputStream(file1);
                    HtmlToPdfUtils.convertToPdf("/usr/local/nginx/html/files/html/parcel_receipt_" + orderId + ".html", "I-GO", fileOutputStream);
                }catch (Exception e){
                    e.printStackTrace();
                    System.out.println("html转pdf异常");
                }
                String link ="http://182.160.16.251:81/files/html/parcel_receipt_" + orderId + ".html";
                TEmail tEmail = new TEmail();
                tEmail.setLink(link);
                tEmail.setUserId(userInfo.getId());
                tEmail.setType(1);
                tEmail.setName(language == 1 ? "I-GO电子收据" : language == 2 ? "Receipt" : "Reçu");
                tEmail.setOrderId(orderId);
                tEmail.setCreateTime(new Date());
                int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1;
                String week = EmailUtil.getWeek(language, i);
                tEmail.setWeek(week);
                boolean am = cn.hutool.core.date.DateUtil.isAM(new Date());
                if(am){
                    tEmail.setAmOrPm(language==1?"上午":language==2?"morning":"matin");
                }else {
                    tEmail.setAmOrPm(language==1?"下午":language==2?"afternoon":"après-midi");
                }
                emailService.insert(tEmail);
            }
            }).start();
            
        }
@@ -1686,21 +1797,20 @@
            }
    
    
            if(orderLogistics.getIsplatPay()==1){
                //添加已收入明细
                Company company = companyService.selectById(orderLogistics.getCompanyId());
                Double speMoney = company.getSpeMoney();
                BigDecimal d = null;//企业收入
                BigDecimal c = null;//司机收入
                if(company.getIsSpeFixedOrProportional() == 2){//固定
                    d = new BigDecimal(speMoney);
                    c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
                }
                if(company.getIsSpeFixedOrProportional() == 1){//比例
                    Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney();
                    d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN)));
                    c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
                }
            //添加已收入明细
            Company company = companyService.selectById(orderLogistics.getCompanyId());
            Double speMoney = company.getSpeMoney();
            BigDecimal d = null;//企业收入
            BigDecimal c = null;//司机收入
            if(company.getIsSpeFixedOrProportional() == 2){//固定
                d = new BigDecimal(speMoney);
                c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
            }
            if(company.getIsSpeFixedOrProportional() == 1){//比例
                Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney();
                d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN)));
                c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
            }
//                incomeService.saveData(1, orderPrivateCar.getCompanyId(), 2, orderPrivateCar.getId(), 1, d.doubleValue());
//                incomeService.saveData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue());
@@ -1708,50 +1818,109 @@
//                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);
            //记录司机待结算金额
            if(d.compareTo(new BigDecimal(0)) > 0){
                SettlementDetail settlementDetail = new SettlementDetail();
                settlementDetail.setOrderId(orderId);
                settlementDetail.setOrderType(4);
                settlementDetail.setDriverId(driver.getId());
                settlementDetail.setOrderMoney(orderLogistics.getOrderMoney());
                settlementDetail.setPrice(d.doubleValue());
                settlementDetail.setCreateTime(new Date());
                settlementDetailService.insert(settlementDetail);
        
                //记录司机待结算金额
                if(d.compareTo(new BigDecimal(0)) > 0){
                    SettlementDetail settlementDetail = new SettlementDetail();
                    settlementDetail.setOrderId(orderId);
                    settlementDetail.setOrderType(1);
                    settlementDetail.setDriverId(driver.getId());
                    settlementDetail.setOrderMoney(orderLogistics.getOrderMoney());
                    settlementDetail.setPrice(d.doubleValue());
                    settlementDetail.setCreateTime(new Date());
                    settlementDetailService.insert(settlementDetail);
                    SettlementAllocation settlementAllocation = settlementAllocationService.selectOne(null);
                    if(null != settlementAllocation){
                        JSONObject jsonObject = JSON.parseObject(settlementAllocation.getContent());
                        Double maxPrice = jsonObject.getDouble("maxPrice");
                        Integer type1 = jsonObject.getInteger("type");
                        if(1 == type1){
                            List<SettlementDetail> settlementDetailList = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("driverId", driver.getId()).isNull("settlementRecordId").last(" and DATE_FORMAT(now(), '%Y-%m-%d') = DATE_FORMAT(createTime, '%Y-%m-%d')"));
                            BigDecimal total = new BigDecimal(0);
                            for (SettlementDetail detail : settlementDetailList) {
                                total = total.add(new BigDecimal(detail.getPrice()));
                SettlementAllocation settlementAllocation = settlementAllocationService.selectOne(null);
                if(null != settlementAllocation){
                    JSONObject jsonObject = JSON.parseObject(settlementAllocation.getContent());
                    Double maxPrice = jsonObject.getDouble("maxPrice");
                    Integer type1 = jsonObject.getInteger("type");
                    if(null != maxPrice){
                        List<SettlementDetail> settlementDetailList = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("driverId", driver.getId())
                                .isNull("settlementRecordId").last(" and DATE_FORMAT(now(), '%Y-%m-%d') = DATE_FORMAT(createTime, '%Y-%m-%d')"));
                        BigDecimal total = new BigDecimal(0);
                        for (SettlementDetail detail : settlementDetailList) {
                            total = total.add(new BigDecimal(detail.getPrice()));
                        }
                        //日结算
                        if(maxPrice.compareTo(total.doubleValue()) <= 0){
                            SettlementRecord settlementRecord = settlementRecordService.selectOne(new EntityWrapper<SettlementRecord>().eq("driverId", orderLogistics.getDriverId())
                                    .eq("type", type1).eq("paymentStatus", 1).last(" and day = DATE_FORMAT(now(), '%Y-%m-%d')"));
                            if(null == settlementRecord){
                                settlementRecord = new SettlementRecord();
                                settlementRecord.setDay(new Date());
                                settlementRecord.setDriverId(orderLogistics.getDriverId());
                                settlementRecord.setType(type1);
                                settlementRecord.setPaymentStatus(1);
                                settlementRecord.setPayMoney(total.doubleValue());
                                settlementRecord.setInsertTime(new Date());
                                settlementRecordService.insert(settlementRecord);
                            }else{
                                settlementRecord.setPayMoney(settlementRecord.getPayMoney() + total.doubleValue());
                                settlementRecordService.updateById(settlementRecord);
                            }
                            if(maxPrice.compareTo(total.doubleValue()) <= 0){
                                SettlementRecord settlementRecord = settlementRecordService.selectOne(new EntityWrapper<SettlementRecord>().eq("driverId", orderLogistics.getDriverId())
                                        .eq("type", type1).eq("paymentStatus", 1).last(" and day = DATE_FORMAT(now(), '%Y-%m-%d')"));
                                if(null == settlementRecord){
                                    settlementRecord = new SettlementRecord();
                                    settlementRecord.setDay(new Date());
                                    settlementRecord.setDriverId(orderLogistics.getDriverId());
                                    settlementRecord.setType(type1);
                                    settlementRecord.setPaymentStatus(1);
                                    settlementRecord.setPayMoney(total.doubleValue());
                                    settlementRecord.setInsertTime(new Date());
                                    settlementRecordService.insert(settlementRecord);
                                }else{
                                    settlementRecord.setPayMoney(settlementRecord.getPayMoney() + total.doubleValue());
                                    settlementRecordService.updateById(settlementRecord);
                            for (SettlementDetail detail : settlementDetailList) {
                                detail.setSettlementRecordId(settlementRecord.getId());
                                settlementDetailService.updateById(detail);
                            }
                            //强制司机下班
                            DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>()
                                    .eq("driverId", orderLogistics.getDriverId()).eq("state", 1));
                            if(null != driverWork){
                                driverWork.setEndTime(new Date());
                                driverWork.setState(2);
                                driverWorkService.updateById(driverWork);
                                driver.setState(1);
                                driverService.updateById(driver);
                                Car car = carService.selectById(driver.getCarId());
                                if(!org.apache.shiro.util.StringUtils.hasLength(car.getVehicleId())){
                                    car.setVehicleId(UUIDUtil.getRandomCode());
                                    carService.updateById(car);
                                }
                                for (SettlementDetail detail : settlementDetailList) {
                                    detail.setSettlementRecordId(settlementRecord.getId());
                                    settlementDetailService.updateById(detail);
                                }
                                //司机下班,修改谷歌上的车辆信息
                                new Thread(()->{
                                    try {
                                        CarModel carModel = carModelMapper.selectById(car.getCarModelId());
                                        String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId());
                                        if(ToolUtil.isEmpty(vehicles)){
                                            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;
                                                    }
                                                    Thread.sleep(5000L);
                                                }
                                            }
                                            boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
                                            if(!updateVehicles){
                                                for (int i = 0; i < 5; i++) {
                                                    updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
                                                    if(updateVehicles){
                                                        break;
                                                    }
                                                    Thread.sleep(5000L);
                                                }
                                            }
                                        }else{
                                            boolean updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
                                            if(!updateVehicles){
                                                for (int i = 0; i < 5; i++) {
                                                    updateVehicles = fleetEngineUtil.updateVehicles("OFFLINE", carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId());
                                                    if(updateVehicles){
                                                        break;
                                                    }
                                                    Thread.sleep(5000L);
                                                }
                                            }
                                        }
                                    }catch (Exception e){
                                        e.printStackTrace();
                                    }
                                }).start();
                            }
                        }
                    }
@@ -1765,9 +1934,52 @@
            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.pushOfflinePayment(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getPayMoney());
                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
                    Integer language1 = driver.getLanguage();
                    String text = "";
                    switch (language1){
                        case 1:
                            text = "客户已选择支付现金,因此您必须收款。确定您已收到此订单费用:现金GHS " + orderLogistics.getPayMoney();
                            break;
                        case 2:
                            text = "The client chose to pay in cash, so you must collect the payment.Confirm if you received the charge for this order: Cash GHS " + orderLogistics.getPayMoney();
                            break;
                        case 3:
                            text = "Le client a choisi de payer en espèces, vous devez donc encaisser le paiement.Confirmez si vous avez reçu les frais pour cette commande : Espèces GHS " + orderLogistics.getPayMoney();
                            break;
                    }
                    String audioUrl = "";
                    String fileName = "offlinePayment" + orderLogistics.getDriverId() + UUIDUtil.getRandomCode(5) + ".mp3";
                    try {
                        audioUrl = TextToSpeechUtil.create(language1 == 1 ? "cmn-CN" : language1 == 2 ? "en-US" : "fr-FR", text, fileName);
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                    //定时任务删除语音文件
                    new Timer().schedule(new TimerTask() {
                        @Override
                        public void run() {
                            try {
                                // 使用Runtime执行命令
                                Process process = Runtime.getRuntime().exec("sudo rm -rf /home/igotechgh/nginx/html/files/audio/" + fileName);
                                // 读取命令的输出
                                BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                                String line;
                                while ((line = reader.readLine()) != null) {
                                    System.out.println(line);
                                }
                                // 等待命令执行完成
                                process.waitFor();
                                // 关闭流
                                reader.close();
                            } catch (IOException | InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    }, 30000);
                    pushUtil.pushOfflinePayment(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getPayMoney(), audioUrl);
                }
            }).start();
@@ -1776,386 +1988,413 @@
                    "Vous avez payé la commande de livraison avec succès, merci d’utiliser I-GO", uid, 1);
    
            language = userInfo.getLanguage();
            String payTypeChinese = "";
            String payTypeEnglish = "";
            String payTypeFrench = "";
            if(orderLogistics.getPayType() == 3){
                payTypeChinese = "现金";
                payTypeEnglish = "Cash";
                payTypeFrench = "En espèces";
            }
            if(ToolUtil.isNotEmpty(userInfo.getEmail())){
                String path = templatePath + "user/receiptLogistics.html";
                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");
                Car car = carMapper.selectById(orderLogistics.getCarId());
                Double aDouble = 0D;
                if(null != orderLogistics.getDriverId()){
                    aDouble = orderEvaluateService.queryDriverScore(orderLogistics.getDriverId());
                }
                if(1 == language){
                    document.getElementById("english").remove();
                    document.getElementById("french").remove();
                    document.getElementsByTag("title").get(0).text("I-GO电子收据");
                    Element title_chinese = document.getElementById("title_chinese");
                    title_chinese.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",您在I-GO此订单消费GHS " + orderLogistics.getPayMoney());
                    Element qbj_chinese = document.getElementById("qbj_chinese");
                    qbj_chinese.text("GHS " + new BigDecimal(orderLogistics.getStartMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element scf_chinese = document.getElementById("scf_chinese");
                    if(null != orderLogistics.getDurationMoney() && orderLogistics.getDurationMoney() > 0){
                        scf_chinese.text("GHS " + new BigDecimal(orderLogistics.getDurationMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element scf_chinese_div = document.getElementById("scf_chinese_div");
                        scf_chinese_div.remove();
                    }
                    Element lcf_chinese = document.getElementById("lcf_chinese");
                    if(null != orderLogistics.getMileageMoney() && orderLogistics.getMileageMoney() > 0){
                        lcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getMileageMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element lcf_chinese_div = document.getElementById("lcf_chinese_div");
                        lcf_chinese_div.remove();
                    }
                    Element ddf_chinese = document.getElementById("ddf_chinese");
                    if(null != orderLogistics.getWaitMoney() && orderLogistics.getWaitMoney() > 0){
                        ddf_chinese.text("GHS " + new BigDecimal(orderLogistics.getWaitMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element ddf_chinese_div = document.getElementById("ddf_chinese_div");
                        ddf_chinese_div.remove();
                    }
                    Element glf_chinese = document.getElementById("glf_chinese");
                    if(null != orderLogistics.getRoadTollMoney() && orderLogistics.getRoadTollMoney() > 0){
                        glf_chinese.text("GHS " + new BigDecimal(orderLogistics.getRoadTollMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element glf_chinese_div = document.getElementById("glf_chinese_div");
                        glf_chinese_div.remove();
                    }
                    Element tcf_chinese = document.getElementById("tcf_chinese");
                    if(null != orderLogistics.getParkMoney() && orderLogistics.getParkMoney() > 0){
                        tcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getParkMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element tcf_chinese_div = document.getElementById("tcf_chinese_div");
                        tcf_chinese_div.remove();
                    }
                    Element bcj_chinese = document.getElementById("bcj_chinese");
                    if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                        bcj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element bcj_chinese_div = document.getElementById("bcj_chinese_div");
                        bcj_chinese_div.remove();
                    }
                    if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                        Element yhq_chinese = document.getElementById("yhq_chinese");
                        yhq_chinese.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element yhq_chinese_div = document.getElementById("yhq_chinese_div");
                        yhq_chinese_div.remove();
                    }
                    if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){
                        Element zk_chinese = document.getElementById("zk_chinese");
                        zk_chinese.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element zk_chinese_div = document.getElementById("zk_chinese_div");
                        zk_chinese_div.remove();
                    }
                    if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){
                        Element hb_chinese = document.getElementById("hb_chinese");
                        hb_chinese.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element hb_chinese_div = document.getElementById("hb_chinese_div");
                        hb_chinese_div.remove();
                    }
                    Element xj_chinese = document.getElementById("xj_chinese");
                    xj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element pay_type_chinese = document.getElementById("pay_type_chinese");
                    pay_type_chinese.text(payTypeChinese);
                    Element pay_money_chinese = document.getElementById("pay_money_chinese");
                    pay_money_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element pdf_chinese = document.getElementById("pdf_chinese");
                    pdf_chinese.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4");
                    Element lost_item_chinese = document.getElementById("lost_item_chinese");
                    lost_item_chinese.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + orderId + "&orderType=4");
            Integer finalLanguage = language;
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        if(ToolUtil.isNotEmpty(userInfo.getEmail())){
                            String path = templatePath + "user/receiptLogistics.html";
                            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");
                            Car car = carMapper.selectById(orderLogistics.getCarId());
                            Double aDouble = 0D;
                            if(null != orderLogistics.getDriverId()){
                                aDouble = orderEvaluateService.queryDriverScore(orderLogistics.getDriverId());
                            }
                            Double aDouble1 = new BigDecimal(orderLogistics.getMileage()).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
                            Long serviceTime = new BigDecimal(orderLogistics.getEndServiceTime().getTime() - orderLogistics.getStartServiceTime().getTime()).divide(new BigDecimal(60000)).setScale(0, RoundingMode.HALF_EVEN).longValue();
                            if(1 == finalLanguage){
                                document.getElementById("english").remove();
                                document.getElementById("french").remove();
                                document.getElementsByTag("title").get(0).text("包裹收据");
                                Element title_chinese = document.getElementById("title_chinese");
                                title_chinese.text(DateUtil.conversionFormat(finalLanguage, sdf2.format(orderLogistics.getTravelTime())) + ",您在I-GO此订单消费GHS " + orderLogistics.getPayMoney());
                                Element qbj_chinese = document.getElementById("qbj_chinese");
                                qbj_chinese.text("GHS " + new BigDecimal(orderLogistics.getStartMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element scf_chinese = document.getElementById("scf_chinese");
                                if(null != orderLogistics.getDurationMoney() && orderLogistics.getDurationMoney() > 0){
                                    scf_chinese.text("GHS " + new BigDecimal(orderLogistics.getDurationMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element scf_chinese_div = document.getElementById("scf_chinese_div");
                                    scf_chinese_div.remove();
                                }
                                Element lcf_chinese = document.getElementById("lcf_chinese");
                                if(null != orderLogistics.getMileageMoney() && orderLogistics.getMileageMoney() > 0){
                                    lcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getMileageMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element lcf_chinese_div = document.getElementById("lcf_chinese_div");
                                    lcf_chinese_div.remove();
                                }
                                Element ddf_chinese = document.getElementById("ddf_chinese");
                                if(null != orderLogistics.getWaitMoney() && orderLogistics.getWaitMoney() > 0){
                                    ddf_chinese.text("GHS " + new BigDecimal(orderLogistics.getWaitMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element ddf_chinese_div = document.getElementById("ddf_chinese_div");
                                    ddf_chinese_div.remove();
                                }
                                Element glf_chinese = document.getElementById("glf_chinese");
                                if(null != orderLogistics.getRoadTollMoney() && orderLogistics.getRoadTollMoney() > 0){
                                    glf_chinese.text("GHS " + new BigDecimal(orderLogistics.getRoadTollMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element glf_chinese_div = document.getElementById("glf_chinese_div");
                                    glf_chinese_div.remove();
                                }
                                Element tcf_chinese = document.getElementById("tcf_chinese");
                                if(null != orderLogistics.getParkMoney() && orderLogistics.getParkMoney() > 0){
                                    tcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getParkMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element tcf_chinese_div = document.getElementById("tcf_chinese_div");
                                    tcf_chinese_div.remove();
                                }
                                Element bcj_chinese = document.getElementById("bcj_chinese");
                                if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                                    bcj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element bcj_chinese_div = document.getElementById("bcj_chinese_div");
                                    bcj_chinese_div.remove();
                                }
                                if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                                    Element yhq_chinese = document.getElementById("yhq_chinese");
                                    yhq_chinese.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element yhq_chinese_div = document.getElementById("yhq_chinese_div");
                                    yhq_chinese_div.remove();
                                }
                                if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){
                                    Element zk_chinese = document.getElementById("zk_chinese");
                                    zk_chinese.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element zk_chinese_div = document.getElementById("zk_chinese_div");
                                    zk_chinese_div.remove();
                                }
                                if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){
                                    Element hb_chinese = document.getElementById("hb_chinese");
                                    hb_chinese.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element hb_chinese_div = document.getElementById("hb_chinese_div");
                                    hb_chinese_div.remove();
                                }
                                Element xj_chinese = document.getElementById("xj_chinese");
                                xj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element pay_type_chinese = document.getElementById("pay_type_chinese");
                                pay_type_chinese.text("现金");
                                Element pay_money_chinese = document.getElementById("pay_money_chinese");
                                pay_money_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element dispute_chinese = document.getElementById("dispute_chinese");
                                if(null != orderLogistics.getIsDispute() && orderLogistics.getIsDispute() == 1){
                                    dispute_chinese.text("(注意: 争议订单,经过三方协商,平台最终定价为 GHS" + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN) + ")");
                                }else{
                                    dispute_chinese.remove();
                                }
                                Element pdf_chinese = document.getElementById("pdf_chinese");
                                pdf_chinese.attr("href", "https://igo.i-go.group/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4");
                                Element lost_item_chinese = document.getElementById("lost_item_chinese");
                                lost_item_chinese.attr("href", "https://igo.i-go.group/mailbox/user/lossGoods.html?language=" + finalLanguage + "&orderId=" + orderId + "&orderType=4");
//                    Element track_chinese = document.getElementById("track_chinese");
//                    track_chinese.attr("href", "http://182.160.16.251:81/mailbox/user/location.html");
                    Element pay_time_chinese = document.getElementById("pay_time_chinese");
                    pay_time_chinese.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime())));
                    Elements driver_chinese = document.getElementsByClass("driver_chinese");
                    for (int i = 0; i < driver_chinese.size(); i++) {
                        Element element = driver_chinese.get(i);
                        element.text(" " + driver.getFirstName() + "." + driver.getLastName());
                    }
                    Element cp_chinese = document.getElementById("cp_chinese");
                    cp_chinese.text("车牌:" + car.getCarLicensePlate());
                    Element pf_chinese = document.getElementById("pf_chinese");
                    pf_chinese.text("司机评分:" + aDouble);
                    Element start_address_chinese = document.getElementById("start_address_chinese");
                    start_address_chinese.text(orderLogistics.getStartAddress());
                    Element end_address_chinese = document.getElementById("end_address_chinese");
                    end_address_chinese.text(orderLogistics.getEndAddress());
                    Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId()));
                    Element server_tel_chinese = document.getElementById("server_tel_chinese");
                    server_tel_chinese.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
                }
                if(2 == language){
                    document.getElementById("chinese").remove();
                    document.getElementById("french").remove();
                    document.getElementsByTag("title").get(0).text("Receipt");
                    Element title_english = document.getElementById("title_english");
                    title_english.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",You spent GHS " + orderLogistics.getPayMoney() + " on the trip ");
                    Element qbj_english = document.getElementById("qbj_english");
                    qbj_english.text("GHS " + new BigDecimal(orderLogistics.getStartMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element scf_english = document.getElementById("scf_english");
                    if(null != orderLogistics.getDurationMoney() && orderLogistics.getDurationMoney() > 0){
                        scf_english.text("GHS " + new BigDecimal(orderLogistics.getDurationMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element scf_english_div = document.getElementById("scf_english_div");
                        scf_english_div.remove();
                    }
                    Element lcf_english = document.getElementById("lcf_english");
                    if(null != orderLogistics.getMileageMoney() && orderLogistics.getMileageMoney() > 0){
                        lcf_english.text("GHS " + new BigDecimal(orderLogistics.getMileageMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element lcf_english_div = document.getElementById("lcf_english_div");
                        lcf_english_div.remove();
                    }
                    Element ddf_english = document.getElementById("ddf_english");
                    if(null != orderLogistics.getWaitMoney() && orderLogistics.getWaitMoney() > 0){
                        ddf_english.text("GHS " + new BigDecimal(orderLogistics.getWaitMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element ddf_english_div = document.getElementById("ddf_english_div");
                        ddf_english_div.remove();
                    }
                    Element glf_english = document.getElementById("glf_english");
                    if(null != orderLogistics.getRoadTollMoney() && orderLogistics.getRoadTollMoney() > 0){
                        glf_english.text("GHS " + new BigDecimal(orderLogistics.getRoadTollMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element glf_english_div = document.getElementById("glf_english_div");
                        glf_english_div.remove();
                    }
                    Element tcf_english = document.getElementById("tcf_english");
                    if(null != orderLogistics.getParkMoney() && orderLogistics.getParkMoney() > 0){
                        tcf_english.text("GHS " + new BigDecimal(orderLogistics.getParkMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element tcf_english_div = document.getElementById("tcf_english_div");
                        tcf_english_div.remove();
                    }
                    Element bcj_english = document.getElementById("bcj_english");
                    if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                        bcj_english.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element bcj_english_div = document.getElementById("bcj_english_div");
                        bcj_english_div.remove();
                    }
                    if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                        Element yhq_english = document.getElementById("yhq_english");
                        yhq_english.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element yhq_english_div = document.getElementById("yhq_english_div");
                        yhq_english_div.remove();
                    }
                    if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){
                        Element zk_english = document.getElementById("zk_english");
                        zk_english.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element zk_english_div = document.getElementById("zk_english_div");
                        zk_english_div.remove();
                    }
                    if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){
                        Element hb_english = document.getElementById("hb_english");
                        hb_english.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element hb_english_div = document.getElementById("hb_english_div");
                        hb_english_div.remove();
                    }
                    Element xj_english = document.getElementById("xj_english");
                    xj_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element pay_type_english = document.getElementById("pay_type_english");
                    pay_type_english.text(payTypeEnglish);
                    Element pay_money_english = document.getElementById("pay_money_english");
                    pay_money_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element pdf_english = document.getElementById("pdf_english");
                    pdf_english.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4");
                    Element lost_item_english = document.getElementById("lost_item_english");
                    lost_item_english.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + orderId + "&orderType=4");
//                    track_chinese.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                                Element pay_time_chinese = document.getElementById("pay_time_chinese");
                                pay_time_chinese.text(DateUtil.conversionFormat(finalLanguage, sdf1.format(orderLogistics.getTravelTime())));
                                Elements driver_chinese = document.getElementsByClass("driver_chinese");
                                for (int i = 0; i < driver_chinese.size(); i++) {
                                    Element element = driver_chinese.get(i);
                                    element.text(" " + driver.getFirstName() + "." + driver.getLastName());
                                }
                                Element cp_chinese = document.getElementById("cp_chinese");
                                cp_chinese.text("车牌:" + car.getCarLicensePlate());
                                Element pf_chinese = document.getElementById("pf_chinese");
                                pf_chinese.text("司机评分:" + aDouble);
                                Element lc_chinese = document.getElementById("lc_chinese");
                                lc_chinese.text("里程:" + aDouble1 + "公里 /" + serviceTime + "分钟");
                                Element start_address_chinese = document.getElementById("start_address_chinese");
                                start_address_chinese.text(orderLogistics.getStartAddress());
                                Element end_address_chinese = document.getElementById("end_address_chinese");
                                end_address_chinese.text(orderLogistics.getEndAddress());
                                Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId()));
                                Element server_tel_chinese = document.getElementById("server_tel_chinese");
                                server_tel_chinese.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
                            }
                            if(2 == finalLanguage){
                                document.getElementById("chinese").remove();
                                document.getElementById("french").remove();
                                document.getElementsByTag("title").get(0).text("Delivery receipt");
                                Element title_english = document.getElementById("title_english");
                                title_english.text(DateUtil.conversionFormat(finalLanguage, sdf2.format(orderLogistics.getTravelTime())) + ",You spent GHS " + orderLogistics.getPayMoney() + " on the trip ");
                                Element qbj_english = document.getElementById("qbj_english");
                                qbj_english.text("GHS " + new BigDecimal(orderLogistics.getStartMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element scf_english = document.getElementById("scf_english");
                                if(null != orderLogistics.getDurationMoney() && orderLogistics.getDurationMoney() > 0){
                                    scf_english.text("GHS " + new BigDecimal(orderLogistics.getDurationMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element scf_english_div = document.getElementById("scf_english_div");
                                    scf_english_div.remove();
                                }
                                Element lcf_english = document.getElementById("lcf_english");
                                if(null != orderLogistics.getMileageMoney() && orderLogistics.getMileageMoney() > 0){
                                    lcf_english.text("GHS " + new BigDecimal(orderLogistics.getMileageMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element lcf_english_div = document.getElementById("lcf_english_div");
                                    lcf_english_div.remove();
                                }
                                Element ddf_english = document.getElementById("ddf_english");
                                if(null != orderLogistics.getWaitMoney() && orderLogistics.getWaitMoney() > 0){
                                    ddf_english.text("GHS " + new BigDecimal(orderLogistics.getWaitMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element ddf_english_div = document.getElementById("ddf_english_div");
                                    ddf_english_div.remove();
                                }
                                Element glf_english = document.getElementById("glf_english");
                                if(null != orderLogistics.getRoadTollMoney() && orderLogistics.getRoadTollMoney() > 0){
                                    glf_english.text("GHS " + new BigDecimal(orderLogistics.getRoadTollMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element glf_english_div = document.getElementById("glf_english_div");
                                    glf_english_div.remove();
                                }
                                Element tcf_english = document.getElementById("tcf_english");
                                if(null != orderLogistics.getParkMoney() && orderLogistics.getParkMoney() > 0){
                                    tcf_english.text("GHS " + new BigDecimal(orderLogistics.getParkMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element tcf_english_div = document.getElementById("tcf_english_div");
                                    tcf_english_div.remove();
                                }
                                Element bcj_english = document.getElementById("bcj_english");
                                if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                                    bcj_english.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element bcj_english_div = document.getElementById("bcj_english_div");
                                    bcj_english_div.remove();
                                }
                                if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                                    Element yhq_english = document.getElementById("yhq_english");
                                    yhq_english.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element yhq_english_div = document.getElementById("yhq_english_div");
                                    yhq_english_div.remove();
                                }
                                if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){
                                    Element zk_english = document.getElementById("zk_english");
                                    zk_english.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element zk_english_div = document.getElementById("zk_english_div");
                                    zk_english_div.remove();
                                }
                                if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){
                                    Element hb_english = document.getElementById("hb_english");
                                    hb_english.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element hb_english_div = document.getElementById("hb_english_div");
                                    hb_english_div.remove();
                                }
                                Element xj_english = document.getElementById("xj_english");
                                xj_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element pay_type_english = document.getElementById("pay_type_english");
                                pay_type_english.text("Cash");
                                Element pay_money_english = document.getElementById("pay_money_english");
                                pay_money_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element dispute_english = document.getElementById("dispute_english");
                                if(null != orderLogistics.getIsDispute() && orderLogistics.getIsDispute() == 1){
                                    dispute_english.text("(Note: Disputed order, after tripartite negotiation, the final pricing of the platform is GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN) + ")");
                                }else{
                                    dispute_english.remove();
                                }
                                Element pdf_english = document.getElementById("pdf_english");
                                pdf_english.attr("href", "https://igo.i-go.group/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4");
                                Element lost_item_english = document.getElementById("lost_item_english");
                                lost_item_english.attr("href", "https://igo.i-go.group/mailbox/user/lossGoods.html?language=" + finalLanguage + "&orderId=" + orderId + "&orderType=4");
//                    Element track_english = document.getElementById("track_english");
//                    track_english.attr("href", "http://182.160.16.251:81/mailbox/user/location.html");
                    Element pay_time_english = document.getElementById("pay_time_english");
                    pay_time_english.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime())));
                    Elements driver_english = document.getElementsByClass("driver_english");
                    for (int i = 0; i < driver_english.size(); i++) {
                        Element element = driver_english.get(i);
                        element.text(" " + driver.getFirstName() + "." + driver.getLastName());
                    }
                    Element cp_english = document.getElementById("cp_english");
                    cp_english.text("Number Plate:" + car.getCarLicensePlate());
                    Element pf_english = document.getElementById("pf_english");
                    pf_english.text("Driver Rating:" + aDouble);
                    Element start_address_english = document.getElementById("start_address_english");
                    start_address_english.text(orderLogistics.getStartAddress());
                    Element end_address_english = document.getElementById("end_address_english");
                    end_address_english.text(orderLogistics.getEndAddress());
                    Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId()));
                    Element server_tel_english = document.getElementById("server_tel_english");
                    server_tel_english.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
                }
                if(3 == language){
                    document.getElementById("chinese").remove();
                    document.getElementById("english").remove();
                    document.getElementsByTag("title").get(0).text("Reçu");
                    Element title_french = document.getElementById("title_french");
                    title_french.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande i-go1 le ");
                    Element qbj_french = document.getElementById("qbj_french");
                    qbj_french.text("GHS " + new BigDecimal(orderLogistics.getStartMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element scf_french = document.getElementById("scf_french");
                    if(null != orderLogistics.getDurationMoney() && orderLogistics.getDurationMoney() > 0){
                        scf_french.text("GHS " + new BigDecimal(orderLogistics.getDurationMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element scf_french_div = document.getElementById("scf_french_div");
                        scf_french_div.remove();
                    }
                    Element lcf_french = document.getElementById("lcf_french");
                    if(null != orderLogistics.getMileageMoney() && orderLogistics.getMileageMoney() > 0){
                        lcf_french.text("GHS " + new BigDecimal(orderLogistics.getMileageMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element lcf_french_div = document.getElementById("lcf_french_div");
                        lcf_french_div.remove();
                    }
                    Element ddf_french = document.getElementById("ddf_french");
                    if(null != orderLogistics.getWaitMoney() && orderLogistics.getWaitMoney() > 0){
                        ddf_french.text("GHS " + new BigDecimal(orderLogistics.getWaitMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element ddf_french_div = document.getElementById("ddf_french_div");
                        ddf_french_div.remove();
                    }
                    Element glf_french = document.getElementById("glf_french");
                    if(null != orderLogistics.getRoadTollMoney() && orderLogistics.getRoadTollMoney() > 0){
                        glf_french.text("GHS " + new BigDecimal(orderLogistics.getRoadTollMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element glf_french_div = document.getElementById("glf_french_div");
                        glf_french_div.remove();
                    }
                    Element tcf_french = document.getElementById("tcf_french");
                    if(null != orderLogistics.getParkMoney() && orderLogistics.getParkMoney() > 0){
                        tcf_french.text("GHS " + new BigDecimal(orderLogistics.getParkMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element tcf_french_div = document.getElementById("tcf_french_div");
                        tcf_french_div.remove();
                    }
                    Element bcj_french = document.getElementById("bcj_french");
                    if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                        bcj_french.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element bcj_french_div = document.getElementById("bcj_french_div");
                        bcj_french_div.remove();
                    }
                    if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                        Element yhq_french = document.getElementById("yhq_french");
                        yhq_french.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element yhq_french_div = document.getElementById("yhq_french_div");
                        yhq_french_div.remove();
                    }
                    if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){
                        Element zk_french = document.getElementById("zk_french");
                        zk_french.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element zk_french_div = document.getElementById("zk_french_div");
                        zk_french_div.remove();
                    }
                    if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){
                        Element hb_french = document.getElementById("hb_french");
                        hb_french.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    }else{
                        Element hb_french_div = document.getElementById("hb_french_div");
                        hb_french_div.remove();
                    }
                    Element xj_french = document.getElementById("xj_french");
                    xj_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element pay_type_french = document.getElementById("pay_type_french");
                    pay_type_french.text(payTypeFrench);
                    Element pay_money_french = document.getElementById("pay_money_french");
                    pay_money_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element pdf_french = document.getElementById("pdf_french");
                    pdf_french.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4");
                    Element lost_item_french = document.getElementById("lost_item_french");
                    lost_item_french.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + orderId + "&orderType=4");
//                    track_english.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                                Element pay_time_english = document.getElementById("pay_time_english");
                                pay_time_english.text(DateUtil.conversionFormat(finalLanguage, sdf1.format(orderLogistics.getTravelTime())));
                                Elements driver_english = document.getElementsByClass("driver_english");
                                for (int i = 0; i < driver_english.size(); i++) {
                                    Element element = driver_english.get(i);
                                    element.text(" " + driver.getFirstName() + "." + driver.getLastName());
                                }
                                Element cp_english = document.getElementById("cp_english");
                                cp_english.text("Number Plate:" + car.getCarLicensePlate());
                                Element pf_english = document.getElementById("pf_english");
                                pf_english.text("Driver Rating:" + aDouble);
                                Element lc_english = document.getElementById("lc_english");
                                lc_english.text("Mileage:" + aDouble1 + "KM / " + serviceTime + "Minutes");
                                Element start_address_english = document.getElementById("start_address_english");
                                start_address_english.text(orderLogistics.getStartAddress());
                                Element end_address_english = document.getElementById("end_address_english");
                                end_address_english.text(orderLogistics.getEndAddress());
                                Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId()));
                                Element server_tel_english = document.getElementById("server_tel_english");
                                server_tel_english.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
                            }
                            if(3 == finalLanguage){
                                document.getElementById("chinese").remove();
                                document.getElementById("english").remove();
                                document.getElementsByTag("title").get(0).text("Reçu de livraison");
                                Element title_french = document.getElementById("title_french");
                                title_french.text(DateUtil.conversionFormat(finalLanguage, sdf2.format(orderLogistics.getTravelTime())) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande I-GO ");
                                Element qbj_french = document.getElementById("qbj_french");
                                qbj_french.text("GHS " + new BigDecimal(orderLogistics.getStartMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element scf_french = document.getElementById("scf_french");
                                if(null != orderLogistics.getDurationMoney() && orderLogistics.getDurationMoney() > 0){
                                    scf_french.text("GHS " + new BigDecimal(orderLogistics.getDurationMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element scf_french_div = document.getElementById("scf_french_div");
                                    scf_french_div.remove();
                                }
                                Element lcf_french = document.getElementById("lcf_french");
                                if(null != orderLogistics.getMileageMoney() && orderLogistics.getMileageMoney() > 0){
                                    lcf_french.text("GHS " + new BigDecimal(orderLogistics.getMileageMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element lcf_french_div = document.getElementById("lcf_french_div");
                                    lcf_french_div.remove();
                                }
                                Element ddf_french = document.getElementById("ddf_french");
                                if(null != orderLogistics.getWaitMoney() && orderLogistics.getWaitMoney() > 0){
                                    ddf_french.text("GHS " + new BigDecimal(orderLogistics.getWaitMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element ddf_french_div = document.getElementById("ddf_french_div");
                                    ddf_french_div.remove();
                                }
                                Element glf_french = document.getElementById("glf_french");
                                if(null != orderLogistics.getRoadTollMoney() && orderLogistics.getRoadTollMoney() > 0){
                                    glf_french.text("GHS " + new BigDecimal(orderLogistics.getRoadTollMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element glf_french_div = document.getElementById("glf_french_div");
                                    glf_french_div.remove();
                                }
                                Element tcf_french = document.getElementById("tcf_french");
                                if(null != orderLogistics.getParkMoney() && orderLogistics.getParkMoney() > 0){
                                    tcf_french.text("GHS " + new BigDecimal(orderLogistics.getParkMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element tcf_french_div = document.getElementById("tcf_french_div");
                                    tcf_french_div.remove();
                                }
                                Element bcj_french = document.getElementById("bcj_french");
                                if(null != orderLogistics.getPriceDifference() && orderLogistics.getPriceDifference() > 0){
                                    bcj_french.text("GHS " + new BigDecimal(orderLogistics.getPriceDifference()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element bcj_french_div = document.getElementById("bcj_french_div");
                                    bcj_french_div.remove();
                                }
                                if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
                                    Element yhq_french = document.getElementById("yhq_french");
                                    yhq_french.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element yhq_french_div = document.getElementById("yhq_french_div");
                                    yhq_french_div.remove();
                                }
                                if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){
                                    Element zk_french = document.getElementById("zk_french");
                                    zk_french.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element zk_french_div = document.getElementById("zk_french_div");
                                    zk_french_div.remove();
                                }
                                if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){
                                    Element hb_french = document.getElementById("hb_french");
                                    hb_french.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                }else{
                                    Element hb_french_div = document.getElementById("hb_french_div");
                                    hb_french_div.remove();
                                }
                                Element xj_french = document.getElementById("xj_french");
                                xj_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element pay_type_french = document.getElementById("pay_type_french");
                                pay_type_french.text("En espèces");
                                Element pay_money_french = document.getElementById("pay_money_french");
                                pay_money_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                                Element dispute_french = document.getElementById("dispute_french");
                                if(null != orderLogistics.getIsDispute() && orderLogistics.getIsDispute() == 1){
                                    dispute_french.text("(Remarque: Il s’agit d’une commande contestée, et après des négociations entre trois parties, la plateforme l’a finalement tarifée à GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN) + ")");
                                }else{
                                    dispute_french.remove();
                                }
                                Element pdf_french = document.getElementById("pdf_french");
                                pdf_french.attr("href", "https://igo.i-go.group/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4");
                                Element lost_item_french = document.getElementById("lost_item_french");
                                lost_item_french.attr("href", "https://igo.i-go.group/mailbox/user/lossGoods.html?language=" + finalLanguage + "&orderId=" + orderId + "&orderType=4");
//                    Element track_french = document.getElementById("track_french");
//                    track_french.attr("href", "http://182.160.16.251:81/mailbox/user/location.html");
                    Element pay_time_french = document.getElementById("pay_time_french");
                    pay_time_french.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime())));
                    Elements driver_french = document.getElementsByClass("driver_french");
                    for (int i = 0; i < driver_french.size(); i++) {
                        Element element = driver_french.get(i);
                        element.text(" " + driver.getFirstName() + "." + driver.getLastName());
//                    track_french.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                                Element pay_time_french = document.getElementById("pay_time_french");
                                pay_time_french.text(DateUtil.conversionFormat(finalLanguage, sdf1.format(orderLogistics.getTravelTime())));
                                Elements driver_french = document.getElementsByClass("driver_french");
                                for (int i = 0; i < driver_french.size(); i++) {
                                    Element element = driver_french.get(i);
                                    element.text(" " + driver.getFirstName() + "." + driver.getLastName());
                                }
                                Element cp_french = document.getElementById("cp_french");
                                cp_french.text("Plaque: GS " + car.getCarLicensePlate());
                                Element pf_french = document.getElementById("pf_french");
                                pf_french.text("Note du chauffeur: " + aDouble);
                                Element lc_french = document.getElementById("lc_french");
                                lc_french.text("Distance: " + aDouble1 + "km / " + serviceTime + "minutes");
                                Element start_address_french = document.getElementById("start_address_french");
                                start_address_french.text(orderLogistics.getStartAddress());
                                Element end_address_french = document.getElementById("end_address_french");
                                end_address_french.text(orderLogistics.getEndAddress());
                                Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId()));
                                Element server_tel_french = document.getElementById("server_tel_french");
                                server_tel_french.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
                            }
                            EmailUtil.send(userInfo.getEmail(), finalLanguage == 1 ? "包裹收据" : finalLanguage == 2 ? "Delivery receipt" : "Reçu de livraison",  document.html());
                            //开始生成pdf收据和html收据
                            File file = new File("/home/igotechgh/nginx/html/files/html/");
                            if(!file.exists()){
                                file.mkdirs();
                            }
                            file = new File("/home/igotechgh/nginx/html/files/html/parcel_receipt_" + orderId + ".html");
                            if(!file.exists()){
                                file.createNewFile();
                            }
                            FileWriter fileWriter = new FileWriter(file);
                            fileWriter.write(document.html());
                            fileWriter.flush();
                            fileWriter.close();
                            File file1 = new File("/home/igotechgh/nginx/html/files/pdf/");
                            if(!file1.exists()){
                                file1.mkdirs();
                            }
                            file1 = new File("/home/igotechgh/nginx/html/files/pdf/parcel_receipt_" + orderId + ".pdf");
                            if(!file1.exists()){
                                file1.createNewFile();
                            }
                            try{
                                FileOutputStream fileOutputStream = new FileOutputStream(file1);
                                HtmlToPdfUtils.convertToPdf("/home/igotechgh/nginx/html/files/html/parcel_receipt_" + orderId + ".html", "I-GO", fileOutputStream);
                            }catch (Exception e){
                                e.printStackTrace();
                                System.out.println("html转pdf异常");
                            }
                            String link ="https://igo.i-go.group/files/html/parcel_receipt_" + orderId + ".html";
                            TEmail tEmail = new TEmail();
                            tEmail.setLink(link);
                            tEmail.setUserId(userInfo.getId());
                            tEmail.setType(1);
                            tEmail.setName(finalLanguage == 1 ? "包裹收据" : finalLanguage == 2 ? "Delivery receipt" : "Reçu de livraison");
                            tEmail.setOrderId(orderId);
                            tEmail.setCreateTime(new Date());
                            int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1;
                            String week = EmailUtil.getWeek(finalLanguage, i);
                            tEmail.setWeek(week);
                            boolean am = cn.hutool.core.date.DateUtil.isAM(new Date());
                            if(am){
                                tEmail.setAmOrPm(finalLanguage ==1?"上午": finalLanguage ==2?"morning":"matin");
                            }else {
                                tEmail.setAmOrPm(finalLanguage ==1?"下午": finalLanguage ==2?"afternoon":"après-midi");
                            }
                            emailService.insert(tEmail);
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                    Element cp_french = document.getElementById("cp_french");
                    cp_french.text("Plaque: GS " + car.getCarLicensePlate());
                    Element pf_french = document.getElementById("pf_french");
                    pf_french.text("Note du chauffeur: " + aDouble);
                    Element start_address_french = document.getElementById("start_address_french");
                    start_address_french.text(orderLogistics.getStartAddress());
                    Element end_address_french = document.getElementById("end_address_french");
                    end_address_french.text(orderLogistics.getEndAddress());
                    Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId()));
                    Element server_tel_french = document.getElementById("server_tel_french");
                    server_tel_french.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
                }
                EmailUtil.send(userInfo.getEmail(), language == 1 ? "I-GO电子收据" : language == 2 ? "Receipt" : "Reçu",  document.html());
                //开始生成pdf收据和html收据
                File file = new File("/usr/local/nginx/html/files/html/");
                if(!file.exists()){
                    file.mkdirs();
                }
                file = new File("/usr/local/nginx/html/files/html/parcel_receipt_" + orderId + ".html");
                if(!file.exists()){
                    file.createNewFile();
                }
                FileWriter fileWriter = new FileWriter(file);
                fileWriter.write(document.html());
                fileWriter.flush();
                fileWriter.close();
                File file1 = new File("/usr/local/nginx/html/files/pdf/");
                if(!file1.exists()){
                    file1.mkdirs();
                }
                file1 = new File("/usr/local/nginx/html/files/pdf/parcel_receipt_" + orderId + ".pdf");
                if(!file1.exists()){
                    file1.createNewFile();
                }
                try{
                    FileOutputStream fileOutputStream = new FileOutputStream(file1);
                    HtmlToPdfUtils.convertToPdf("/usr/local/nginx/html/files/html/parcel_receipt_" + orderId + ".html", "I-GO", fileOutputStream);
                }catch (Exception e){
                    e.printStackTrace();
                    System.out.println("html转pdf异常");
                }
                String link ="http://182.160.16.251:81/files/html/parcel_receipt_" + orderId + ".html";
                TEmail tEmail = new TEmail();
                tEmail.setLink(link);
                tEmail.setUserId(userInfo.getId());
                tEmail.setType(1);
                tEmail.setName(language == 1 ? "I-GO电子收据" : language == 2 ? "Receipt" : "Reçu");
                tEmail.setOrderId(orderId);
                tEmail.setCreateTime(new Date());
                int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1;
                String week = EmailUtil.getWeek(language, i);
                tEmail.setWeek(week);
                boolean am = cn.hutool.core.date.DateUtil.isAM(new Date());
                if(am){
                    tEmail.setAmOrPm(language==1?"上午":language==2?"morning":"matin");
                }else {
                    tEmail.setAmOrPm(language==1?"下午":language==2?"afternoon":"après-midi");
                }
                emailService.insert(tEmail);
            }
            }).start();
        }
        this.updateById(orderLogistics);
        this.updateAllColumnById(orderLogistics);
        return resultUtil;
    }
@@ -2192,8 +2431,8 @@
            checkoutRequest.setRequestDescription("Travel completion payment");
            checkoutRequest.setCallbackUrl(callbackPath + "/base/wxPayOrderLogisticsSpread");
            checkoutRequest.setPendingRedirectUrl("");
            checkoutRequest.setSuccessRedirectUrl("http://182.160.16.251:81/payMoney/pages/success.html");
            checkoutRequest.setFailRedirectUrl("http://182.160.16.251:81/payMoney/pages/fail.html");
            checkoutRequest.setSuccessRedirectUrl("https://igo.i-go.group/payMoney/pages/success.html");
            checkoutRequest.setFailRedirectUrl("https://igo.i-go.group/payMoney/pages/fail.html");
            return TinggPayUtil.checkoutRequest(checkoutRequest);
        }
        if(payType == 2){//银行卡支付
@@ -2211,8 +2450,8 @@
            checkoutRequest.setRequestDescription("Travel completion payment");
            checkoutRequest.setCallbackUrl(callbackPath + "/base/wxPayOrderLogisticsSpread");
            checkoutRequest.setPendingRedirectUrl("");
            checkoutRequest.setSuccessRedirectUrl("http://182.160.16.251:81/payMoney/pages/success.html");
            checkoutRequest.setFailRedirectUrl("http://182.160.16.251:81/payMoney/pages/fail.html");
            checkoutRequest.setSuccessRedirectUrl("https://igo.i-go.group/payMoney/pages/success.html");
            checkoutRequest.setFailRedirectUrl("https://igo.i-go.group/payMoney/pages/fail.html");
            return TinggPayUtil.checkoutRequest(checkoutRequest);
        }
@@ -2268,8 +2507,8 @@
            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, "", "user");
                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
                }
            }).start();
@@ -2326,8 +2565,8 @@
            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, "", "user");
                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
                }
            }).start();
@@ -2371,13 +2610,35 @@
            query.setState(2);
            query.setCode(order_id);
            paymentRecordService.updateById(query);
            //添加已收入明细
            Company company = companyService.selectById(orderLogistics.getCompanyId());
            Double speMoney = company.getSpeMoney();
            BigDecimal d = null;//企业收入
            BigDecimal c = null;//司机收入
            if(company.getIsSpeFixedOrProportional() == 2){//固定
                d = new BigDecimal(speMoney);
                c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
            }
            if(company.getIsSpeFixedOrProportional() == 1){//比例
                Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney();
                d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN)));
                c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
            }
            incomeService.saveData(1, orderLogistics.getCompanyId(), 2, orderLogistics.getId(), 4, d.doubleValue());
            incomeService.saveData(2, orderLogistics.getDriverId(), 2, orderLogistics.getId(), 4, c.doubleValue());
            Driver driver = driverService.selectById(orderLogistics.getDriverId());
            driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            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() {
                @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, "", "user");
                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
                }
            }).start();
@@ -2387,35 +2648,23 @@
                    "Vous avez payé la commande de livraison avec succès, merci d’utiliser I-GO", orderLogistics.getUserId(), 1);
    
            language = userInfo.getLanguage();
            String payTypeChinese = "";
            String payTypeEnglish = "";
            String payTypeFrench = "";
            if(orderLogistics.getPayType() == 1){
                payTypeChinese = "手机支付";
                payTypeEnglish = "Mobile money";
                payTypeFrench = "Argent mobile";
            }
            if(orderLogistics.getPayType() == 2){
                payTypeChinese = "银行卡支付";
                payTypeEnglish = "Bank card";
                payTypeFrench = "Carte bancaire";
            }
            if(ToolUtil.isNotEmpty(userInfo.getEmail())){
                String path = templatePath + "user/receiptLogistics.html";
                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()){
                    aDouble = orderEvaluateService.queryDriverScore(orderLogistics.getDriverId());
                }
                Double aDouble1 = new BigDecimal(orderLogistics.getMileage()).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
                Long serviceTime = new BigDecimal(orderLogistics.getEndServiceTime().getTime() - orderLogistics.getStartServiceTime().getTime()).divide(new BigDecimal(60000)).setScale(0, RoundingMode.HALF_EVEN).longValue();
                if(1 == language){
                    document.getElementById("english").remove();
                    document.getElementById("french").remove();
                    document.getElementsByTag("title").get(0).text("I-GO电子收据");
                    document.getElementsByTag("title").get(0).text("包裹收据");
                    Element title_chinese = document.getElementById("title_chinese");
                    title_chinese.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",您在I-GO此订单消费GHS " + orderLogistics.getPayMoney());
                    Element qbj_chinese = document.getElementById("qbj_chinese");
@@ -2486,15 +2735,21 @@
                    Element xj_chinese = document.getElementById("xj_chinese");
                    xj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element pay_type_chinese = document.getElementById("pay_type_chinese");
                    pay_type_chinese.text(payTypeChinese);
                    pay_type_chinese.text(orderLogistics.getPayType() == 1 ? "手机支付" : (orderLogistics.getPayType() == 2?"银行卡支付":(orderLogistics.getPayType() == 3?"余额支付":"现金支付")));
                    Element pay_money_chinese = document.getElementById("pay_money_chinese");
                    pay_money_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element dispute_chinese = document.getElementById("dispute_chinese");
                    if(null != orderLogistics.getIsDispute() && orderLogistics.getIsDispute() == 1){
                        dispute_chinese.text("(注意: 争议订单,经过三方协商,平台最终定价为 GHS" + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN) + ")");
                    }else{
                        dispute_chinese.remove();
                    }
                    Element pdf_chinese = document.getElementById("pdf_chinese");
                    pdf_chinese.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + id + "&orderType=4");
                    pdf_chinese.attr("href", "https://igo.i-go.group/user/base/order/uploadReceiptPdf?orderId=" + id + "&orderType=4");
                    Element lost_item_chinese = document.getElementById("lost_item_chinese");
                    lost_item_chinese.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + id + "&orderType=4");
                    lost_item_chinese.attr("href", "https://igo.i-go.group/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + id + "&orderType=4");
//                    Element track_chinese = document.getElementById("track_chinese");
//                    track_chinese.attr("href", "http://182.160.16.251:81/mailbox/user/location.html");
//                    track_chinese.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                    Element pay_time_chinese = document.getElementById("pay_time_chinese");
                    pay_time_chinese.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime())));
                    Elements driver_chinese = document.getElementsByClass("driver_chinese");
@@ -2506,6 +2761,8 @@
                    cp_chinese.text("车牌:" + car.getCarLicensePlate());
                    Element pf_chinese = document.getElementById("pf_chinese");
                    pf_chinese.text("司机评分:" + aDouble);
                    Element lc_chinese = document.getElementById("lc_chinese");
                    lc_chinese.text("里程:" + aDouble1 + "公里 /" + serviceTime + "分钟");
                    Element start_address_chinese = document.getElementById("start_address_chinese");
                    start_address_chinese.text(orderLogistics.getStartAddress());
                    Element end_address_chinese = document.getElementById("end_address_chinese");
@@ -2517,7 +2774,7 @@
                if(2 == language){
                    document.getElementById("chinese").remove();
                    document.getElementById("french").remove();
                    document.getElementsByTag("title").get(0).text("Receipt");
                    document.getElementsByTag("title").get(0).text("Delivery receipt");
                    Element title_english = document.getElementById("title_english");
                    title_english.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",You spent GHS " + orderLogistics.getPayMoney() + " on the trip ");
                    Element qbj_english = document.getElementById("qbj_english");
@@ -2588,15 +2845,21 @@
                    Element xj_english = document.getElementById("xj_english");
                    xj_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element pay_type_english = document.getElementById("pay_type_english");
                    pay_type_english.text(payTypeEnglish);
                    pay_type_english.text(orderLogistics.getPayType() == 1 ? "Mobile money" :(orderLogistics.getPayType() == 2?"Bank card":(orderLogistics.getPayType() == 3?"I-GO Wallet":"Cash")));
                    Element pay_money_english = document.getElementById("pay_money_english");
                    pay_money_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element dispute_english = document.getElementById("dispute_english");
                    if(null != orderLogistics.getIsDispute() && orderLogistics.getIsDispute() == 1){
                        dispute_english.text("(Note: Disputed order, after tripartite negotiation, the final pricing of the platform is GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN) + ")");
                    }else{
                        dispute_english.remove();
                    }
                    Element pdf_english = document.getElementById("pdf_english");
                    pdf_english.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + id + "&orderType=4");
                    pdf_english.attr("href", "https://igo.i-go.group/user/base/order/uploadReceiptPdf?orderId=" + id + "&orderType=4");
                    Element lost_item_english = document.getElementById("lost_item_english");
                    lost_item_english.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + id + "&orderType=4");
                    lost_item_english.attr("href", "https://igo.i-go.group/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + id + "&orderType=4");
//                    Element track_english = document.getElementById("track_english");
//                    track_english.attr("href", "http://182.160.16.251:81/mailbox/user/location.html");
//                    track_english.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                    Element pay_time_english = document.getElementById("pay_time_english");
                    pay_time_english.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime())));
                    Elements driver_english = document.getElementsByClass("driver_english");
@@ -2608,6 +2871,8 @@
                    cp_english.text("Number Plate:" + car.getCarLicensePlate());
                    Element pf_english = document.getElementById("pf_english");
                    pf_english.text("Driver Rating:" + aDouble);
                    Element lc_english = document.getElementById("lc_english");
                    lc_english.text("Mileage:" + aDouble1 + "KM / " + serviceTime + "Minutes");
                    Element start_address_english = document.getElementById("start_address_english");
                    start_address_english.text(orderLogistics.getStartAddress());
                    Element end_address_english = document.getElementById("end_address_english");
@@ -2619,9 +2884,9 @@
                if(3 == language){
                    document.getElementById("chinese").remove();
                    document.getElementById("english").remove();
                    document.getElementsByTag("title").get(0).text("Reçu");
                    document.getElementsByTag("title").get(0).text("Reçu de livraison");
                    Element title_french = document.getElementById("title_french");
                    title_french.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande i-go1 le ");
                    title_french.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande I-GO ");
                    Element qbj_french = document.getElementById("qbj_french");
                    qbj_french.text("GHS " + new BigDecimal(orderLogistics.getStartMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element scf_french = document.getElementById("scf_french");
@@ -2690,15 +2955,21 @@
                    Element xj_french = document.getElementById("xj_french");
                    xj_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element pay_type_french = document.getElementById("pay_type_french");
                    pay_type_french.text(payTypeFrench);
                    pay_type_french.text(orderLogistics.getPayType() == 1 ? "Argent mobile" : (orderLogistics.getPayType() == 2?"Carte bancaire":(orderLogistics.getPayType() == 3?"Portefeuille I-GO":"En espèces")));
                    Element pay_money_french = document.getElementById("pay_money_french");
                    pay_money_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    Element dispute_french = document.getElementById("dispute_french");
                    if(null != orderLogistics.getIsDispute() && orderLogistics.getIsDispute() == 1){
                        dispute_french.text("(Remarque: Il s’agit d’une commande contestée, et après des négociations entre trois parties, la plateforme l’a finalement tarifée à GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN) + ")");
                    }else{
                        dispute_french.remove();
                    }
                    Element pdf_french = document.getElementById("pdf_french");
                    pdf_french.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + id + "&orderType=4");
                    pdf_french.attr("href", "https://igo.i-go.group/user/base/order/uploadReceiptPdf?orderId=" + id + "&orderType=4");
                    Element lost_item_french = document.getElementById("lost_item_french");
                    lost_item_french.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + id + "&orderType=4");
                    lost_item_french.attr("href", "https://igo.i-go.group/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + id + "&orderType=4");
//                    Element track_french = document.getElementById("track_french");
//                    track_french.attr("href", "http://182.160.16.251:81/mailbox/user/location.html");
//                    track_french.attr("href", "https://igo.i-go.group/mailbox/user/location.html");
                    Element pay_time_french = document.getElementById("pay_time_french");
                    pay_time_french.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime())));
                    Elements driver_french = document.getElementsByClass("driver_french");
@@ -2710,6 +2981,8 @@
                    cp_french.text("Plaque: GS " + car.getCarLicensePlate());
                    Element pf_french = document.getElementById("pf_french");
                    pf_french.text("Note du chauffeur: " + aDouble);
                    Element lc_french = document.getElementById("lc_french");
                    lc_french.text("Distance: " + aDouble1 + "km / " + serviceTime + "minutes");
                    Element start_address_french = document.getElementById("start_address_french");
                    start_address_french.text(orderLogistics.getStartAddress());
                    Element end_address_french = document.getElementById("end_address_french");
@@ -2719,14 +2992,14 @@
                    server_tel_french.attr("href", "tel:" + (null != phone ? phone.getPhone() : ""));
                }
        
                EmailUtil.send(userInfo.getEmail(), language == 1 ? "I-GO电子收据" : language == 2 ? "Receipt" : "Reçu",  document.html());
                EmailUtil.send(userInfo.getEmail(), language == 1 ? "包裹收据" : language == 2 ? "Delivery receipt" : "Reçu de livraison",  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/parcel_receipt_" + id + ".html");
                file = new File("/home/igotechgh/nginx/html/files/html/parcel_receipt_" + id + ".html");
                if(!file.exists()){
                    file.createNewFile();
                }
@@ -2735,28 +3008,28 @@
                fileWriter.flush();
                fileWriter.close();
        
                File file1 = new File("/usr/local/nginx/html/files/pdf/");
                File file1 = new File("/home/igotechgh/nginx/html/files/pdf/");
                if(!file1.exists()){
                    file1.mkdirs();
                }
                file1 = new File("/usr/local/nginx/html/files/pdf/parcel_receipt_" + id + ".pdf");
                file1 = new File("/home/igotechgh/nginx/html/files/pdf/parcel_receipt_" + id + ".pdf");
                if(!file1.exists()){
                    file1.createNewFile();
                }
                try{
                    FileOutputStream fileOutputStream = new FileOutputStream(file1);
                    HtmlToPdfUtils.convertToPdf("/usr/local/nginx/html/files/html/parcel_receipt_" + id + ".html", "I-GO", fileOutputStream);
                    HtmlToPdfUtils.convertToPdf("/home/igotechgh/nginx/html/files/html/parcel_receipt_" + id + ".html", "I-GO", fileOutputStream);
                }catch (Exception e){
                    e.printStackTrace();
                    System.out.println("html转pdf异常");
                }
        
                String link ="http://182.160.16.251:81/files/html/parcel_receipt_" + id + ".html";
                String link ="https://igo.i-go.group/files/html/parcel_receipt_" + id + ".html";
                TEmail tEmail = new TEmail();
                tEmail.setLink(link);
                tEmail.setUserId(userInfo.getId());
                tEmail.setType(1);
                tEmail.setName(language == 1 ? "I-GO电子收据" : language == 2 ? "Receipt" : "Reçu");
                tEmail.setName(language == 1 ? "包裹收据" : language == 2 ? "Delivery receipt" : "Reçu de livraison");
                tEmail.setOrderId(id);
                tEmail.setCreateTime(new Date());
                int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1;
@@ -2835,8 +3108,8 @@
            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, "", "user");
                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0, "", "user");
                }
            }).start();
@@ -2888,7 +3161,7 @@
            Integer orderId = Integer.valueOf(String.valueOf(map.get("orderId")));
            Integer state = Integer.valueOf(String.valueOf(map.get("state")));
            if(state == 6){
                map.put("receipt", "http://182.160.16.251:81/files/html/parcel_receipt_" + orderId + ".html");
                map.put("receipt", "https://igo.i-go.group/files/html/parcel_receipt_" + orderId + ".html");
            }else{
                map.put("receipt", "");
            }
@@ -2913,17 +3186,20 @@
            }
    
            OrderLogistics orderLogistics = this.selectById(orderId);
            long timeOutCancel = 0L;
            long driverTimeOut = 0L;
            map.put("driverTimeOutTime", 0);
            map.put("driverTimeOut", 0);
            if(null != orderLogistics.getEstimateArriveTime()){
                CancleOrder cancleOrder = cancleOrderService.selectOne(new EntityWrapper<CancleOrder>().eq("companyId", orderLogistics.getCompanyId()));
                JSONObject jsonObject = JSON.parseObject(cancleOrder.getContent());
                int driverTimeout = jsonObject.getIntValue("driverTimeout") * 60000;
                timeOutCancel = orderLogistics.getEstimateArriveTime().getTime() + driverTimeout;
                driverTimeOut = orderLogistics.getEstimateArriveTime().getTime();
                int driverTimeout1 = jsonObject.getIntValue("driverTimeout");
                long time = orderLogistics.getEstimateArriveTime().getTime() + driverTimeout1 * 60000;
                if(System.currentTimeMillis() > time){
                    Integer driverTimeOutTime = Double.valueOf((System.currentTimeMillis() - time) / 60000).intValue();
                    driverTimeOutTime = driverTimeOutTime == 0 ? 1 : driverTimeOutTime;
                    map.put("driverTimeOutTime", driverTimeOutTime);
                    map.put("driverTimeOut", 1);
                }
            }
            map.put("driverTimeOut", driverTimeOut);
            map.put("timeOutCancel", timeOutCancel);
        }
        return maps;
    }
@@ -2968,9 +3244,10 @@
    public ResultUtil addCancle(Integer id, String reason, String remark, Integer uid, Double lon, Double lat, String address, Integer language) throws Exception {
        if(ToolUtil.isNotEmpty(remark)){
            if(ToolUtil.isNotEmpty(remark)){
                remark = remark.toLowerCase();
                List<SensitiveWords> sensitiveWords = sensitiveWordsMapper.selectList(null);
                for(SensitiveWords s : sensitiveWords){
                    remark = remark.replaceAll(s.getContent(), "***");
                for(SensitiveWords s : sensitiveWords) {
                    remark = remark.replaceAll(s.getContent().toLowerCase(), "***");
                }
            }
        }
@@ -2981,19 +3258,19 @@
        if(null == orderLogistics){
            return ResultUtil.error(language == 1 ? "取消订单失败,订单信息有误" : language == 2 ? "Failed to cancel order, order-information error." : "Échec de l’annulation de la commande, erreur d’information de commande.");
        }
        if(orderLogistics.getState() > 5 && orderLogistics.getState() != 12){
        if(orderLogistics.getState() > 5 && orderLogistics.getState() != 11 && orderLogistics.getState() != 12){
            return ResultUtil.error(language == 1 ? "取消订单失败,不合法的操作" : language == 2 ? "Failed to cancel order, illegal operation." : "Échec de l’annulation de la commande, opération illégale.");
        }
        orderCancelService.delete(new EntityWrapper<OrderCancel>().eq("orderId", orderLogistics.getId()).eq("orderType", 4));
        if(null == orderLogistics.getDriverId()){//没有接单的情况
            integer = orderCancelService.saveData(id, 4, language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", null, null, 2, 1, uid);
            integer = orderCancelService.saveData(id, 4, language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", null, 0D, 2, 1, uid);
            orderLogistics.setState(10);
            this.updateById(orderLogistics);
        }else {
            BaseWarpper data = queryCancleAmount(id, language).getData();
            Double amount = data.getAmount();
            if(0 == amount){
                integer = orderCancelService.saveData(id, 4, reason, remark, null, null, 2, 1, uid);
                integer = orderCancelService.saveData(id, 4, reason, remark, null, 0D, 2, 1, uid);
                if(5 == orderLogistics.getState()){
                    orderLogistics.setState(6);
                    orderLogistics.setGetoffLon(lon);
@@ -3032,17 +3309,17 @@
                    String audioUrl = "";
                    switch (language1){
                        case 1:
                            audioUrl = "http://182.160.16.251:81/files/audio/system/UserCancelledOrder-CN.mp3";
                            audioUrl = "https://igo.i-go.group/files/audio/system/UserCancelledOrder-CN.mp3";
                            break;
                        case 2:
                            audioUrl = "http://182.160.16.251:81/files/audio/system/UserCancelledOrder-EN.mp3";
                            audioUrl = "https://igo.i-go.group/files/audio/system/UserCancelledOrder-EN.mp3";
                            break;
                        case 3:
                            audioUrl = "http://182.160.16.251:81/files/audio/system/UserCancelledOrder-FR.mp3";
                            audioUrl = "https://igo.i-go.group/files/audio/system/UserCancelledOrder-FR.mp3";
                            break;
                    }
                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "");
                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState() == 12 ? orderLogistics.getState() : 10, 0, audioUrl);
                    pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "", "user");
                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState() == 12 ? orderLogistics.getState() : 10, 0, audioUrl, "user");
                }
            }).start();
            driver.setState(2);
@@ -3050,10 +3327,24 @@
        }
        
        if(orderLogistics.getState() == 10 || orderLogistics.getState() == 12){
            Car car = carService.selectById(orderLogistics.getCarId());
            //修改行程信息
            fleetEngineUtil.updateTrip("CANCELED", null, null, orderLogistics.getTripId(), null, null, null, null);
            boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, orderLogistics.getTripId(), null, null, null, null);
            if(!updateTrip){
                for (int i = 0; i < 5; i++) {
                    updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, orderLogistics.getTripId(), null, null, null, null);
                    if(updateTrip){
                        orderLogistics.setIsover(1);
                        this.updateById(orderLogistics);
                        break;
                    }
                    Thread.sleep(3000L);
                }
            }else{
                orderLogistics.setIsover(1);
                this.updateById(orderLogistics);
            }
        }
        //添加消息
        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);
@@ -3176,7 +3467,7 @@
        map.put("device", ToolUtil.isNotEmpty(driverId) ? 2 : 1);
        map.put("orderType", orderLogistics.getType());
        if(state == 8 || state == 9){
            map.put("receipt", "http://182.160.16.251:81/files/html/parcel_receipt_" + orderId + ".html");
            map.put("receipt", "https://igo.i-go.group/files/html/parcel_receipt_" + orderId + ".html");
        }else{
            map.put("receipt", "");
        }
@@ -3184,22 +3475,27 @@
        if(null != map.get("driverId")){
            companyId = Integer.valueOf(String.valueOf(map.get("companyId")));
        }
        map.put("timeOutCancel", 0);
        map.put("driverTimeOutTime", 0);
        map.put("driverTimeOut", 0);
        if(null != orderLogistics.getEstimateArriveTime()){
            CancleOrder cancleOrder = cancleOrderService.selectOne(new EntityWrapper<CancleOrder>().eq("companyId", companyId));
            JSONObject jsonObject = JSON.parseObject(cancleOrder.getContent());
            int driverTimeout = jsonObject.getIntValue("driverTimeout");
            long timeOutCancel = orderLogistics.getEstimateArriveTime().getTime() + driverTimeout;
            map.put("timeOutCancel", timeOutCancel);
            map.put("driverTimeOut", orderLogistics.getEstimateArriveTime().getTime());
            int driverTimeout1 = jsonObject.getIntValue("driverTimeout");
            long time = orderLogistics.getEstimateArriveTime().getTime() + driverTimeout1 * 60000;
            if(System.currentTimeMillis() > time){
                Integer driverTimeOutTime = Double.valueOf((System.currentTimeMillis() - time) / 60000).intValue();
                driverTimeOutTime = driverTimeOutTime == 0 ? 1 : driverTimeOutTime;
                map.put("driverTimeOutTime", driverTimeOutTime);
                map.put("driverTimeOut", 1);
            }
        }
        map.put("isDispute", orderLogistics.getIsDispute());
        return map;
    }
    public synchronized String getOrderNum() throws Exception{
        int size = this.selectCount(null);
        return "LOGISTICS" + String.valueOf(1000000 + size + 1).substring(1);
        return "DELIVERY" + String.valueOf(1000000 + size + 1).substring(1);
    }
@@ -3241,7 +3537,10 @@
        BaseWarpper baseWarpper = new BaseWarpper();
        double amount = 0;
        CancleOrder query = cancleOrderService.query(orderLogistics.getCompanyId());
        if(null == query || null == orderLogistics.getDriverId()){
        if(null == query){
            return ResultUtil.error("请先添加取消规则");
        }
        if(null == orderLogistics.getDriverId() || orderLogistics.getState() == 11){
            baseWarpper.setAmount(amount);
            return ResultUtil.success(baseWarpper);
        }
@@ -3308,10 +3607,7 @@
    @Override
    public ResultUtil cancleOrderPrivateCar(Integer id, Integer payType, Integer bankCardId, Integer cancleId, Integer type, Integer language) throws Exception {
        OrderLogistics orderLogistics = this.selectById(id);
        Integer uid = orderLogistics.getUserId();
        UserInfo userInfo = userInfoService.selectById(uid);
        ResultUtil resultUtil = ResultUtil.success("");
        if(null == orderLogistics){
            return ResultUtil.error(language == 1 ? "取消订单失败,订单信息有误" : language == 2 ? "Failed to cancel order, order-information error." : "Échec de l’annulation de la commande, erreur d’information de commande.", "");
        }
@@ -3324,7 +3620,9 @@
        }else{
            orderCancel = orderCancelService.selectById(cancleId);
        }
        Integer uid = orderLogistics.getUserId();
        UserInfo userInfo = userInfoService.selectById(uid);
        Double amount = orderCancel.getMoney();
        if(0 < amount){
            if(payType == 1){//手机支付
@@ -3343,8 +3641,8 @@
                checkoutRequest.setRequestDescription("Cancel a trip");
                checkoutRequest.setCallbackUrl(callbackPath + "/base/wxCancelOrderTaxi");
                checkoutRequest.setPendingRedirectUrl("");
                checkoutRequest.setSuccessRedirectUrl("http://182.160.16.251:81/payMoney/pages/success.html");
                checkoutRequest.setFailRedirectUrl("http://182.160.16.251:81/payMoney/pages/fail.html");
                checkoutRequest.setSuccessRedirectUrl("https://igo.i-go.group/payMoney/pages/success.html");
                checkoutRequest.setFailRedirectUrl("https://igo.i-go.group/payMoney/pages/fail.html");
                resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest);
                if(resultUtil.getCode()==200){
                    paymentRecordService.saveData(1, null, null, id, 4, 1, amount, null, 1);//添加预支付数据
@@ -3368,8 +3666,8 @@
                checkoutRequest.setRequestDescription("Cancel a trip");
                checkoutRequest.setCallbackUrl(callbackPath + "/base/wxCancelOrderTaxi");
                checkoutRequest.setPendingRedirectUrl("");
                checkoutRequest.setSuccessRedirectUrl("http://182.160.16.251:81/payMoney/pages/success.html");
                checkoutRequest.setFailRedirectUrl("http://182.160.16.251:81/payMoney/pages/fail.html");
                checkoutRequest.setSuccessRedirectUrl("https://igo.i-go.group/payMoney/pages/success.html");
                checkoutRequest.setFailRedirectUrl("https://igo.i-go.group/payMoney/pages/fail.html");
                resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest);
                if(resultUtil.getCode()==200){
                    paymentRecordService.saveData(1, null, null, id, 4, 2, amount, null, 1);//添加预支付数据
@@ -3391,11 +3689,7 @@
                    ChinaMobileUtil.midAxbUnBindSend(orderLogistics.getBindId(),orderLogistics.getTelX());
                }
    
                if(5 == orderLogistics.getOldState()){
                    orderLogistics.setState(6);
                }else{
                    orderLogistics.setState(10);
                }
                orderLogistics.setState(10);
                orderLogistics.setTelX("");
                orderLogistics.setBindId("");
                this.updateById(orderLogistics);
@@ -3429,11 +3723,11 @@
                    }
    
                    this.deleteTask(id);//删除定时任务
                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "");
                    pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "", "user");
                }else{
                    incomeService.saveData(1, orderLogistics.getCompanyId(), 3, orderLogistics.getId(), 4, amount.doubleValue());
                }
                pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "");
                pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "", "user");
    
    
                //添加消息
@@ -3465,11 +3759,7 @@
            if(orderLogistics.getBindId() != null){
                ChinaMobileUtil.midAxbUnBindSend(orderLogistics.getBindId(),orderLogistics.getTelX());
            }
            if(5 == orderLogistics.getOldState()){
                orderLogistics.setState(6);
            }else{
                orderLogistics.setState(10);
            }
            orderLogistics.setState(10);
            orderLogistics.setBindId("");
            orderLogistics.setTelX("");
            this.updateById(orderLogistics);
@@ -3510,11 +3800,11 @@
                }
                this.deleteTask(orderLogistics.getId());//删除定时任务
                
                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "");
                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "", "user");
            }else{
                incomeService.saveData(1, orderLogistics.getCompanyId(), 3, orderLogistics.getId(), 4, amount.doubleValue());
            }
            pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "");
            pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0, "", "user");
            
            //添加消息
            systemNoticeService.addSystemNotice(1, language == 1 ? "您已使用余额成功支付取消订单费用,谢谢使用!" : language == 2
@@ -3547,13 +3837,13 @@
            String audioUrl = "";
            switch (language1){
                case 1:
                    audioUrl = "http://182.160.16.251:81/files/audio/system/ChangeAddress-CN.mp3";
                    audioUrl = "https://igo.i-go.group/files/audio/system/ChangeAddress-CN.mp3";
                    break;
                case 2:
                    audioUrl = "http://182.160.16.251:81/files/audio/system/ChangeAddress-EN.mp3";
                    audioUrl = "https://igo.i-go.group/files/audio/system/ChangeAddress-EN.mp3";
                    break;
                case 3:
                    audioUrl = "http://182.160.16.251:81/files/audio/system/ChangeAddress-FR.mp3";
                    audioUrl = "https://igo.i-go.group/files/audio/system/ChangeAddress-FR.mp3";
                    break;
            }
            pushUtil.pushModifyAddress(2, orderLogistics.getDriverId(), orderId, 4, 1, audioUrl);
@@ -3668,16 +3958,16 @@
                    Element user_french = document.getElementById("user_french");
                    user_french.text("Bonjour " + userInfo.getNickName() + ",");
                    Element time_french = document.getElementById("time_french");
                    time_french.text("Cette promotion est valable du " + DateUtil.conversionFormat(language, sdf.format(id.getStartTime())) + " au " + DateUtil.conversionFormat(language, sdf.format(id.getEndTime())) + ". Veuillez consulter la plateforme i-go pour plus de détails.");
                    time_french.text("Cette promotion est valable du " + DateUtil.conversionFormat(language, sdf.format(id.getStartTime())) + " au " + DateUtil.conversionFormat(language, sdf.format(id.getEndTime())) + ". Veuillez consulter la plateforme I-GO pour plus de détails.");
                }
                
                EmailUtil.send(userInfo.getEmail(), language == 1 ? "红包活动" : language == 2 ? "Lucky-promo activities" : "Activités bonus",  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/redpacket_" + orderId + ".html");
                file = new File("/home/igotechgh/nginx/html/files/html/redpacket_" + orderId + ".html");
                if(!file.exists()){
                    file.createNewFile();
                }
@@ -3686,7 +3976,7 @@
                fileWriter.flush();
                fileWriter.close();
                
                String link ="http://182.160.16.251:81/files/html/redpacket_" + orderId + ".html";
                String link ="https://igo.i-go.group/files/html/redpacket_" + orderId + ".html";
                TEmail tEmail = new TEmail();
                tEmail.setLink(link);
                tEmail.setUserId(userInfo.getId());
@@ -3766,13 +4056,14 @@
                }
            }
        }
        String tripId = redisUtil.getValue("trip" + uid);
        String lnt = "0";
        String lat = "0";
        if(ToolUtil.isNotEmpty(value)){
            lnt = value.split(",")[0];
            lat = value.split(",")[1];
            DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), Double.valueOf(lat), Double.valueOf(lnt));
            DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), Double.valueOf(lat), Double.valueOf(lnt), tripId);
            
            if(null == distancematrix){
                System.err.println("查询距离出错了");
@@ -3800,7 +4091,7 @@
            orderServerWarpper.setLaveTime("0");
        }
        if(orderLogistics.getState() == 5 || orderLogistics.getState() == 6){//服务中
            DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(lat), Double.valueOf(lnt), orderLogistics.getEndLat(), orderLogistics.getEndLon());
            DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(lat), Double.valueOf(lnt), orderLogistics.getEndLat(), orderLogistics.getEndLon(), tripId);
            if(null == distancematrix){
                System.err.println("查询距离出错了");
            }else if(distancematrix.getDistance() == 0){