zhibing.pu
2024-04-19 2e366b939271b6ea338641f8a72d1bcd2182dbe7
新增加功能
16个文件已修改
11个文件已添加
2089 ■■■■■ 已修改文件
DriverIGOTravel/guns-admin/pom.xml 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/GunsApplication.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/OrderCrossCityServiceImpl.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/dao/OrderLogisticsMapper.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/dao/mapping/OrderLogisticsMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/model/OrderLogistics.java 111 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/IOrderLogisticsService.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java 872 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/ReminderRulesMapper.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/ReminderRulesMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/ReminderRules.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/IReminderRulesService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderServiceImpl.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReminderRulesServiceImpl.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushUtil.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/quartz/QuartzUtil.java 261 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/quartz/SchedulerUtil.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/quartz/jobs/OrderTimeOutJob.java 134 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/quartz/model/QuartzEnum.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/quartz/model/QuartzJob.java 108 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/MoneyInfoWarpper.java 163 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/OrderInfoWarpper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/resources/application-dev.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/src/main/resources/quartz.properties 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DriverIGOTravel/guns-admin/pom.xml
@@ -286,6 +286,16 @@
            <artifactId>font-asian</artifactId>
            <version>7.1.13</version>
        </dependency>
        <!--任务调度框架-->
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
        </dependency>
        <dependency>
            <groupId>com.mchange</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.5.5</version>
        </dependency>
    </dependencies>
    <build>
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/GunsApplication.java
@@ -2,10 +2,13 @@
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.modular.system.util.GDFalconUtil;
import com.stylefeng.guns.modular.system.util.quartz.QuartzUtil;
import com.stylefeng.guns.modular.system.util.quartz.SchedulerUtil;
import org.apache.http.client.HttpClient;
import org.apache.http.config.SocketConfig;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.quartz.SchedulerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -23,6 +26,10 @@
import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.TimeZone;
@@ -42,6 +49,14 @@
    public static void main(String[] args) {
        SpringApplication.run(GunsApplication.class, args);
        try {
            //启动定时任务调度器
            QuartzUtil.start(GunsApplication.class.getClassLoader().getResourceAsStream("quartz.properties"));
        } catch (SchedulerException e) {
            throw new RuntimeException(e);
        }
        logger.info("GunsApplication is success!");
    }
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java
@@ -439,7 +439,7 @@
    @ApiOperation(value = "司机确认费用", tags = {"司机端-服务中"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际,4=同城小件物流)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "支付方式(1=OK平台收款,2=其他方式收款)", name = "type", required = true, dataType = "int"),
            @ApiImplicitParam(value = "行程费用(出租车必传)", name = "travelFee", required = false, dataType = "double"),
            @ApiImplicitParam(value = "停车费", name = "parkingFee", required = false, dataType = "double"),
@@ -656,7 +656,7 @@
    @ApiOperation(value = "手动确认订单完成", tags = {"司机端-服务中"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,2=出租车)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,4=同城小件物流)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil completeOrder(Integer orderId, Integer orderType, Integer language){
@@ -672,10 +672,10 @@
    @ResponseBody
    @PostMapping("/api/order/queryMoneyInfo")
    @ApiOperation(value = "获取订单费用明细", tags = {"司机端-服务中"}, notes = "")
    @ApiOperation(value = "获取订单费用明细【2.0】", tags = {"司机端-服务中"}, notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(value = "订单类型(1=专车,4=同城小件物流)", name = "orderType", required = true, dataType = "int"),
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
    })
    public ResultUtil<MoneyInfoWarpper> queryMoneyInfo(Integer orderId, Integer orderType){
@@ -688,6 +688,7 @@
        }
    }
    @ResponseBody
    @PostMapping("/api/order/fillInPickUpCode")
    @ApiOperation(value = "验证小件物流取件码", tags = {"司机端-服务中"}, notes = "")
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/crossCity/server/impl/OrderCrossCityServiceImpl.java
@@ -247,6 +247,7 @@
                orderCrossCity.setState(3);
                orderCrossCity.setSetOutTime(new Date());
                systemNoticeService.addSystemNotice(1, "司机已出发,请耐心等待", orderCrossCity.getUserId());
                pushUtil.pushDriverPosition(orderCrossCity.getId(), 3);//主动推送司机定位
                break;
            case 4://到达预约点,等待客户上车
                orderCrossCity.setState(4);
@@ -260,8 +261,6 @@
                orderCrossCity.setBoardingTime(new Date());
                orderCrossCity.setState(5);
                orderCrossCity.setStartServiceTime(new Date());
                pushUtil.pushDriverPosition(orderCrossCity.getId(), 3);//主动推送司机定位
                break;
            case 6://结束服务
                orderCrossCity.setGetoffLon(lon);
@@ -615,7 +614,6 @@
            public void run() {
                pushUtil.pushOrderState(1, orderCrossCity.getUserId(), orderCrossCity.getId(), 3, orderCrossCity.getState());
                pushUtil.pushOrderState(2, orderCrossCity.getDriverId(), orderCrossCity.getId(), 3, orderCrossCity.getState());
                pushUtil.pushDriverPosition(orderCrossCity.getId(), 3);
            }
        }).start();
@@ -752,7 +750,6 @@
                public void run() {
                    pushUtil.pushOrderState(1, orderCrossCity.getUserId(), orderCrossCity.getId(), 3, orderCrossCity.getState());
                    pushUtil.pushOrderState(2, orderCrossCity.getDriverId(), orderCrossCity.getId(), 3, orderCrossCity.getState());
                    pushUtil.pushDriverPosition(orderCrossCity.getId(), 3);
                }
            }).start();
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/dao/OrderLogisticsMapper.java
@@ -54,5 +54,12 @@
     * @return
     */
    List<OrderLogistics> query(@Param("state") List<Integer> state, @Param("driverId") Integer driverId);
    /**
     * 获取费用明细
     * @param orderId
     * @return
     */
    Map<String, Object> queryMoneyInfo(@Param("orderId") Integer orderId);
}
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/dao/mapping/OrderLogisticsMapper.xml
@@ -133,7 +133,8 @@
        if(c.userType = 1, '用户', '平台') as cancelUser,
        (select isSpecialCar from t_sys_reformist where companyId = a.companyId) as reassign,
        a.driverPay,
        a.isFrozen
        a.isFrozen,
        a.priceDifference
        from t_order_logistics a
        left join t_user b on (a.userId = b.id)
        left join t_order_cancel c on (a.id = c.orderId and c.orderType = a.type and c.state = 2)
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/model/OrderLogistics.java
@@ -6,6 +6,7 @@
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
@@ -40,6 +41,11 @@
     */
    @TableField("carId")
    private Integer carId;
    /**
     * 服务车型id
     */
    @TableField("serverCarModelId")
    private Integer serverCarModelId;
    /**
     * 订单号
     */
@@ -181,15 +187,65 @@
    @TableField("orderMoney")
    private Double orderMoney;
    /**
     * 行程费
     * 起步里程
     */
    @TableField("travelMoney")
    private Double travelMoney;
    @TableField("startMileage")
    private Double startMileage;
    /**
     * 小费
     * 起步价
     */
    @TableField("tipMoney")
    private Double tipMoney;
    @TableField("startMoney")
    private Double startMoney;
    /**
     * 里程公里
     */
    @TableField("mileageKilometers")
    private Double mileageKilometers;
    /**
     * 里程费
     */
    @TableField("mileageMoney")
    private Double mileageMoney;
    /**
     * 时长分钟
     */
    @TableField("duration")
    private Double duration;
    /**
     * 时长费
     */
    @TableField("durationMoney")
    private Double durationMoney;
    /**
     * 等待分钟
     */
    @TableField("wait")
    private Double wait;
    /**
     * 等待费
     */
    @TableField("waitMoney")
    private Double waitMoney;
    /**
     * 远途公里
     */
    @TableField("longDistance")
    private Double longDistance;
    /**
     * 远途费
     */
    @TableField("longDistanceMoney")
    private Double longDistanceMoney;
    /**
     * 停车费
     */
    @TableField("parkMoney")
    private Double parkMoney;
    /**
     * 过路费
     */
    @TableField("roadTollMoney")
    private Double roadTollMoney;
    /**
     * 红包抵扣金额
     */
@@ -204,7 +260,7 @@
     * 红包id
     */
    @TableField("redPacketId")
    private Integer redPacketId;
    private String redPacketId;
    /**
     * 优惠券id
     */
@@ -236,7 +292,7 @@
    @TableField("payMoney")
    private Double payMoney;
    /**
     * 状态(1=待接单,2=待出发,3=待到达预约地点,4=待取货,5=送货中,6=已送达,7=待支付,8=需补差价,9=已取货,10=已取消,11=改派中,12=已支付差价)
     * 状态(1=待接单,2=待出发,3=待到达预约地点,4=待取货,5=送货中,6=已送达,7=待支付,8=需补差价,9=已取货,10=已取消,11=改派中,12=已支付差价,13=取消待支付)
     */
    @TableField("state")
    private Integer state;
@@ -297,12 +353,6 @@
    @TableField("isDelete")
    private Integer isDelete;
    /**
     * 该派前的订单状态
     * @return
     */
    @TableField("oldState")
    private Integer oldState;
    /**
     * 移动小号
     * @return
     */
@@ -338,6 +388,12 @@
    @TableField("driverPay")
    private Integer driverPay;
    /**
     * 改派之前的订单状态
     * @return
     */
    @TableField("oldState")
    private Integer oldState;
    /**
     * 修改目的地经度
     */
    @TableField("destinationLon")
@@ -352,6 +408,31 @@
     */
    @TableField("destination")
    private String destination;
    private Integer isplatPay;
    /**
     * 是否首单免费1否,2是
     * @return
     */
    @TableField("isFree")
    private Integer isFree;
    private BigDecimal freeMoney;
    /**
     * 补差价金额
     */
    @TableField("priceDifference")
    private Double priceDifference;
    private Integer startDuration;
    /**
     * 收费方式(1=普通,2=夜间,3=高峰)
     */
    private Integer moneyType;
    /**
     * 收费方式时间段
     */
    private String moneyTime;
    private Date smsTime;
    private Integer smsNumber;
    
}
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/IOrderLogisticsService.java
@@ -137,4 +137,27 @@
     * @param status
     */
    void updateEndAddress(Integer orderId, Integer status);
    /**
     * 获取费用明细
     * @param orderId
     * @return
     * @throws Exception
     */
    Map<String, Object> queryMoneyInfo(Integer orderId) throws Exception;
    /**
     * 确认费用操作
     * @param orderId
     * @param type
     * @param parkingFee
     * @param crossingFee
     * @return
     * @throws Exception
     */
    ResultUtil confirmFees(Integer language, Integer orderId, Integer type, Double parkingFee, Double crossingFee) throws Exception;
}
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -13,16 +13,20 @@
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
import com.stylefeng.guns.modular.system.dao.CarMapper;
import com.stylefeng.guns.modular.system.dao.RegionMapper;
import com.stylefeng.guns.modular.system.dao.SystemPriceMapper;
import com.stylefeng.guns.modular.system.dao.UserInfoMapper;
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.*;
import com.stylefeng.guns.modular.system.util.itextpdf.HtmlToPdfUtils;
import com.stylefeng.guns.modular.system.util.quartz.QuartzUtil;
import com.stylefeng.guns.modular.system.util.quartz.jobs.OrderTimeOutJob;
import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.quartz.JobDataMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -105,6 +109,12 @@
    @Autowired
    private IOrderEvaluateService orderEvaluateService;
    @Autowired
    private IReminderRulesService reminderRulesService;
    @Resource
    private SystemPriceMapper systemPriceMapper;
@@ -152,58 +162,34 @@
        orderLogistics.setState(2);
        orderLogistics.setSnatchOrderTime(new Date());
        //调用高德创建轨迹
//        String s = gdFalconUtil.selectTerminal(driver.getPhone());
//        String track = gdFalconUtil.createTrack(s);
//        orderLogistics.setTrackId(track);
        //调用移动的小号接口
//        Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
//        Region region = regionMapper.query(geocode.get("districtCode"));
//        Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderLogistics.getRecipientPhone(), driver.getPhone(), Integer.valueOf(region.getCitycode().substring(1)));
//        if(String.valueOf(map.get("code")).equals("200")){
//            orderLogistics.setTelX(map.get("telX"));
//            orderLogistics.setBindId(map.get("bindId"));
//        }
        this.updateById(orderLogistics);
        //添加已收入明细
        Company company = companyService.selectById(driver.getCompanyId());
        Double speMoney =  orderLogistics.getType() == 4 ? company.getSameLogisticsMoney() : company.getCrossLogisticsMoney();
        BigDecimal d = null;//企业收入
        BigDecimal c = null;//司机收入
        if(company.getIsSpeFixedOrProportional() == 2){//固定
            d = new BigDecimal(speMoney);
            c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
        //todo 待翻译
        //添加定时任务(普通任务)
        ReminderRules reminderRules = reminderRulesService.selectOne(new EntityWrapper<ReminderRules>().eq("companyId", driver.getCompanyId()));
        if(null != reminderRules){
            JSONObject jsonObject = JSON.parseObject(reminderRules.getContent());
            long packageTimeoutReminderInterval = jsonObject.getInteger("packageTimeoutReminderInterval") * 60000L;
            long m = (System.currentTimeMillis() - orderLogistics.getSnatchOrderTime().getTime()) / 60000;
            JobDataMap jobDataMap = new JobDataMap();
            jobDataMap.put("driverId", uid);
            jobDataMap.put("orderId", orderLogistics.getId());
            jobDataMap.put("orderType", 4);
            jobDataMap.put("describe", "您的打车订单已超时" + m + "分钟,请抓紧!");
            QuartzUtil.addSimpleQuartzTask(
                    new OrderTimeOutJob().buildQuartzJob(UUIDUtil.getRandomCode(5) + "_" + orderLogistics.getId() + "_4", "ORDER_TIME_OUT", jobDataMap)
                    , new Date(packageTimeoutReminderInterval), packageTimeoutReminderInterval, -1);
        }
        if(company.getIsSpeFixedOrProportional() == 1){//比例
            Double price = orderLogistics.getTravelMoney();
            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(), orderLogistics.getType(), d.doubleValue());
//        incomeService.saveData(2, orderLogistics.getDriverId(), 2, orderLogistics.getId(), orderLogistics.getType(), c.doubleValue());
        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);
        //推送相关代码------------------start----------------
        new Thread(new Runnable() {
            @Override
            public void run() {
                pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                pushUtil.pushDriverPosition(orderId, orderLogistics.getType());
            }
        }).start();
@@ -275,6 +261,7 @@
                orderLogistics.setState(3);
                orderLogistics.setSetOutTime(new Date());
                systemNoticeService.addSystemNotice(1, language == 1 ? "司机已出发,请耐心等待" : language == 2 ? "The driver is on the way, please wait." : "Le chauffeur est en route. Veuillez patienter.", orderLogistics.getUserId());
                pushUtil.pushDriverPosition(orderId, 4);
                break;
            case 4://到达预约点,等待客户上车
                orderLogistics.setState(4);
@@ -288,152 +275,18 @@
                orderLogistics.setBoardingTime(new Date());
                orderLogistics.setState(5);
                orderLogistics.setStartServiceTime(new Date());
                pushUtil.pushDriverPosition(orderLogistics.getId(), orderLogistics.getType());//主动推送司机定位
                break;
            case 6://结束服务(专车可以返回继续服务)不修改状态
            case 6://结束服务
                orderLogistics.setGetoffLon(lon);
                orderLogistics.setGetoffLat(lat);
                orderLogistics.setGetoffAddress(address);
                orderLogistics.setGetoffTime(new Date());
                orderLogistics.setEndServiceTime(new Date());
                orderLogistics.setState(6);
                if(orderLogistics.getPayType() != 4){
                    //添加已收入明细
                    Company company = companyService.selectById(orderLogistics.getCompanyId());
                    Double speMoney = company.getSameLogisticsMoney();
                    BigDecimal d = null;//企业收入
                    BigDecimal c = null;//司机收入
                    if(company.getIsSameLogisticsFixedOrProportional() == 2){//固定
                        d = new BigDecimal(speMoney);
                        c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
                    }
                    if(company.getIsSameLogisticsFixedOrProportional() == 1){//比例
                        Double price = orderLogistics.getOrderMoney();
                        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);
                }
                if (orderLogistics.getPayType()==4||!orderLogisticsId.isEmpty()){
                    double sum = 0;
                    if (orderLogistics.getPayType()==4){
                        sum= orderLogistics.getOrderMoney();
                    }
                    if (!orderLogisticsId.isEmpty()){
                        for (OrderLogisticsSpread orderLogisticsSpread : orderLogisticsId) {
                            sum = sum +orderLogisticsSpread.getPrice();
                        }
                    }
                    Driver driver = driverService.selectById(orderLogistics.getDriverId());
                    if(null != orderLogistics.getCouponMoney() && 0 < orderLogistics.getCouponMoney()){
                        Double money = orderLogistics.getCouponMoney();
                        incomeService.saveData(2, orderLogistics.getDriverId(), 5, orderLogistics.getId(), orderLogistics.getType(), money);
                        driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                        driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                        driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                        driverService.updateById(driver);
                    }
                    if(null != orderLogistics.getDiscountMoney() && 0 < orderLogistics.getDiscountMoney()){
                        Double money = orderLogistics.getDiscountMoney();
                        incomeService.saveData(2, orderLogistics.getDriverId(), 6, orderLogistics.getId(), orderLogistics.getType(), money);
                        driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                        driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                        driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                        driverService.updateById(driver);
                    }
                    if(null != orderLogistics.getRedPacketMoney() && 0 < orderLogistics.getRedPacketMoney()){
                        Double money = orderLogistics.getRedPacketMoney();
                        incomeService.saveData(2, orderLogistics.getDriverId(), 7, orderLogistics.getId(), orderLogistics.getType(), money);
                        driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                        driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                        driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                        driverService.updateById(driver);
                    }
                    Company company = companyService.selectById(orderLogistics.getCompanyId());
                    Double speMoney = company.getSameLogisticsMoney();
                    BigDecimal d = null;//企业收入
                    BigDecimal c = null;//司机收入
                    if(company.getIsSameLogisticsFixedOrProportional() == 2){//固定
                        d = new BigDecimal(speMoney);
                        c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
                    }
                    if(company.getIsSameLogisticsFixedOrProportional() == 1){//比例
                        Double price = orderLogistics.getOrderMoney();
                        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);
                    }
                    //记录司机待结算金额
                    if(d.compareTo(new BigDecimal(0)) > 0){
                        SettlementDetail settlementDetail = new SettlementDetail();
                        settlementDetail.setOrderId(orderId);
                        settlementDetail.setOrderType(4);
                        settlementDetail.setDriverId(orderLogistics.getDriverId());
                        settlementDetail.setOrderMoney(sum);
                        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 type = jsonObject.getInteger("type");
                            if(type == 1){
                                List<SettlementDetail> settlementDetailList = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("driverId", orderLogistics.getDriverId()).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", type).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(type);
                                        settlementRecord.setPaymentStatus(1);
                                        settlementRecord.setPayMoney(total.doubleValue());
                                        settlementRecord.setInsertTime(new Date());
                                        settlementRecordService.insert(settlementRecord);
                                    }else{
                                        settlementRecord.setPayMoney(total.doubleValue());
                                        settlementRecordService.updateById(settlementRecord);
                                    }
                                    for (SettlementDetail detail : settlementDetailList) {
                                        detail.setSettlementRecordId(settlementRecord.getId());
                                        settlementDetailService.updateById(detail);
                                    }
                                }
                            }
                        }
                    }
                }
                break;
        }
        this.updateById(orderLogistics);
        if(6 == state && ToolUtil.isNotEmpty(pickUpCode)){
            fillInPickUpCode(orderId, pickUpCode, language);
        }
        // TODO: 2020/6/5 推送状态
        new Thread(new Runnable() {
            @Override
@@ -442,283 +295,7 @@
                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
            }
        }).start();
        if(state == 6){
            UserInfo userInfo = userInfoMapper.selectById(orderLogistics.getUserId());
            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(orderLogistics.getPayType() == 3){
                payTypeChinese = "余额支付";
                payTypeEnglish = "I-GO Wallet";
                payTypeFrench = "Portefeuille I-GO";
            }
            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");
                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 xcf_chinese = document.getElementById("xcf_chinese");
                    xcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    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");
//                    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 xcf_english = document.getElementById("xcf_english");
                    xcf_english.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    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");
//                    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 xcf_french = document.getElementById("xcf_french");
                    xcf_french.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN));
                    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");
//                    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());
                    }
                    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);
            }
        }
        return ResultUtil.success();
    }
@@ -751,29 +328,12 @@
     */
    @Override
    public ResultUtil makeUpTheDifference(Integer orderId, Double difference, Integer language) throws Exception {
        OrderLogisticsSpread query = orderLogisticsSpreadService.query(orderId);
        OrderLogistics orderLogistics = this.selectById(orderId);
        if(orderLogistics.getState() != 4 && orderLogistics.getState() != 8){
        if(orderLogistics.getState() != 4){
            return ResultUtil.error(language == 1 ? "不允许设置差价" : language == 2 ? "To set price difference is not allowed." : "Il n’est pas permis de définir une différence de prix.");
        }
        if(query != null){
            query.setPrice(difference);
            orderLogisticsSpreadService.updateById(query);
            return ResultUtil.success();
        }
        OrderLogisticsSpread orderLogisticsSpread = new OrderLogisticsSpread();
        orderLogisticsSpread.setOrderLogisticsId(orderId);
        orderLogisticsSpread.setPrice(difference);
        orderLogisticsSpreadService.insert(orderLogisticsSpread);
        orderLogistics.setState(8);
        this.updateById(orderLogistics);
        new Thread(new Runnable() {
            @Override
            public void run() {
                pushUtil.pushPayDifference(1, orderLogistics.getUserId(), orderId, orderLogistics.getType(), difference);
            }
        }).start();
        //推送给乘客,需要乘客确认后再加
        pushUtil.pushPayDifference(1, orderLogistics.getUserId(), orderId, orderLogistics.getType(), difference, 1);
        return ResultUtil.success();
    }
@@ -869,13 +429,6 @@
            public void run() {
                pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
                pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                pushUtil.pushDriverPosition(orderId, orderLogistics.getType());
            }
        }).start();
@@ -1047,4 +600,355 @@
        this.updateById(orderLogistics);
        pushUtil.pushModifyAddress(1, orderLogistics.getUserId(), orderId, 4, status);
    }
    /**
     * 获取费用明细
     * @param orderId
     * @return
     * @throws Exception
     */
    @Override
    public Map<String, Object> queryMoneyInfo(Integer orderId) throws Exception {
        OrderLogistics orderLogistics = this.selectById(orderId);
        if(orderLogistics.getState() == 5){//服务中的时候获取实时费用数据
            this.setMoney(orderLogistics, 0D, 0D);
        }
        Map<String, Object> map = new HashMap<>();
        map.put("orderMoney", orderLogistics.getOrderMoney());//订单金额
        map.put("startMileage", orderLogistics.getStartMileage());//起步价
        map.put("startMoney", orderLogistics.getStartMoney());//起步价
        map.put("mileageKilometers", orderLogistics.getMileageKilometers());//里程费
        map.put("mileageMoney", orderLogistics.getMileageMoney());//里程费
        map.put("duration", orderLogistics.getDuration());//时长费
        map.put("durationMoney", orderLogistics.getDurationMoney());//时长费
        map.put("wait", orderLogistics.getWait());//等待费
        map.put("waitMoney", orderLogistics.getWaitMoney());//等待费
        map.put("longDistance", orderLogistics.getLongDistance());//远途费
        map.put("longDistanceMoney", orderLogistics.getLongDistanceMoney());//远途费
        map.put("parkMoney", orderLogistics.getParkMoney());//停车费
        map.put("roadTollMoney", orderLogistics.getRoadTollMoney());//过路费
        map.put("redPacketMoney", orderLogistics.getRedPacketMoney());//红包抵扣金额
        map.put("couponMoney", orderLogistics.getCouponMoney());//优惠券抵扣金额
        map.put("discountMoney", orderLogistics.getDiscountMoney());//折扣抵扣金额
        map.put("discount", orderLogistics.getDiscount());//折扣
        map.put("priceDifference", orderLogistics.getPriceDifference());//补差价
        return map;
    }
    /**
     * 计算价格
     * @param orderLogistics
     * @param parkingFee
     * @param crossingFee
     * @return
     * @throws Exception
     */
    public OrderLogistics setMoney(OrderLogistics orderLogistics, Double parkingFee, Double crossingFee) throws Exception {
        Map<String, Object> query1 = systemPriceMapper.query(orderLogistics.getCompanyId(), 4, orderLogistics.getServerCarModelId());
        //开始根据不同的方式计算金额
        double amount = 0;
        JSONObject jsonObject = JSON.parseObject(query1.get("content").toString());
        Double num1 = jsonObject.getDouble("num1");//起步价(元)
        Double num2 = jsonObject.getDouble("num2");//起步公里(公里)
        Double num3 = jsonObject.getDouble("num3");//起步时间(分钟)
        Double num4 = jsonObject.getDouble("num4");//里程费(元)
        Double num5 = jsonObject.getDouble("num5");//时长费(分钟)
        Double num6 = jsonObject.getDouble("num6");//等待费(分钟)
        Double num7 = jsonObject.getDouble("num7");//等待费(元)
        Double num8 = jsonObject.getDouble("num8");//远途费(公里)
        Double num9 = jsonObject.getDouble("num9");//远途费(公里)
        Double num10 = jsonObject.getDouble("num10");//远途费(元)
        Double num11 = jsonObject.getDouble("num11");//远途费(公里)
        Double num12 = jsonObject.getDouble("num12");//远途费(公里)
        Double num13 = jsonObject.getDouble("num13");//远途费(元)
        Double num14 = jsonObject.getDouble("num14");//远途费(公里)
        Double num15 = jsonObject.getDouble("num15");//远途费(元)
//        String num16 = jsonObject.getString("num16");//夜间费(开始时间)
//        Double num17 = jsonObject.getDouble("num17");//夜间费(元)
//        Double num18 = jsonObject.getDouble("num18");//夜间费(元)
//        Double num19 = jsonObject.getDouble("num19");//夜间费(元)
//        Double num20 = jsonObject.getDouble("num20");//夜间费(元)
//        Double num21 = jsonObject.getDouble("num21");//夜间费(元)
//        Double num22 = jsonObject.getDouble("num22");//夜间费(元)
        String num23 = jsonObject.getString("num23");//高峰费(开始时间)
        String num24 = jsonObject.getString("num24");//高峰费(开始时间)
        Double num25 = jsonObject.getDouble("num25");//高峰费(元)
        Double num26 = jsonObject.getDouble("num26");//高峰费(元)
        Double num27 = jsonObject.getDouble("num27");//高峰费(元)
        Double num28 = jsonObject.getDouble("num28");//高峰费(元)
        Double num29 = jsonObject.getDouble("num29");//高峰费(元)
        Double num30 = jsonObject.getDouble("num30");//高峰费(元)
        Date date = new Date();
        double d = (null == orderLogistics.getMileage() ? 0D : orderLogistics.getMileage()) / 1000;//实际公里
        double t = ((orderLogistics.getEndServiceTime().getTime() - orderLogistics.getStartServiceTime().getTime()) / 60000) + 1;//实际时间(不满一分钟按一分钟算)
        double w = ((orderLogistics.getStartServiceTime().getTime() - orderLogistics.getArriveTime().getTime()) / 60000) + 1;//等待分钟(不满一分钟按一分钟算)
        double d1 = (d - num2) < 0 ? 0 : d - num2;//超出起步里程的公里
        double t1 = (t - num3) < 0 ? 0 : new BigDecimal(t - num3).setScale(0, BigDecimal.ROUND_UP).doubleValue();//超过起步分钟数的时间
        double w1 = (w - num6) < 0 ? 0 : new BigDecimal(w - num6).setScale(0, BigDecimal.ROUND_UP).doubleValue();//超出等待时间的时间
        double yt1 = 0;//远途1段
        double yt2 = 0;//远途2段
        double yt3 = 0;//远途3段
        //夜间服务处理逻辑
//        if(ToolUtil.isNotEmpty(num16)){
//            Calendar s = Calendar.getInstance();
//            s.setTime(date);
//            s.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num16.split(" - ")[0].split(":")[0]));
//            s.set(Calendar.MINUTE, Integer.valueOf(num16.split(" - ")[0].split(":")[1]));
//
//            Calendar e = Calendar.getInstance();
//            e.setTime(date);
//            e.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num16.split(" - ")[1].split(":")[0]));
//            e.set(Calendar.MINUTE, Integer.valueOf(num16.split(" - ")[1].split(":")[1]));
//
//            if(date.getTime() > s.getTimeInMillis() && date.getTime() < e.getTimeInMillis()){
//                if(d > num8.doubleValue() && d <= num9.doubleValue()){
//                    yt1 = num20 * (d - num8);
//                }
//                if(d > num9.doubleValue()){
//                    yt1 = num20 * (num9 - num8);
//                }
//                if(d > num11.doubleValue() && d <= num12.doubleValue()){
//                    yt2 = num21 * (d - num11);
//                }
//                if(d > num12.doubleValue()){
//                    yt2 = num21 * (num12 - num11);
//                }
//                if(d > num14.doubleValue()){
//                    yt3 = num22 * (d - num14);
//                }
//                amount = num17 + (d1 * num18) + (t1 * num19) + (w1 * num7) + yt1 + yt2 + yt3;
//                orderLogistics.setStartMileage(num2);
//                orderLogistics.setStartMoney(num17);//起步价
//                orderLogistics.setStartDuration((int)(num3.doubleValue()));
//                orderLogistics.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
//                orderLogistics.setMileageMoney(new BigDecimal(d1 * num18).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//里程费
//                orderLogistics.setDuration(new BigDecimal(t1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
//                orderLogistics.setDurationMoney(new BigDecimal(t1 * num19).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//时长费
//                orderLogistics.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
//                orderLogistics.setWaitMoney(new BigDecimal(w1 * num7).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//等待费
//                orderLogistics.setLongDistance(new BigDecimal((d > num8) ? d - num8 : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
//                orderLogistics.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//远途费
//                orderLogistics.setParkMoney(parkingFee);//停车费
//                orderLogistics.setRoadTollMoney(crossingFee);//过路费
//                orderLogistics.setRedPacketMoney(0D);//红包抵扣
//                orderLogistics.setCouponMoney(0D);//优惠券抵扣
//                orderLogistics.setDiscount(0D);//优惠抵扣
//                orderLogistics.setPayMoney(0D);//支付金额
//                orderLogistics.setOrderMoney(new BigDecimal(amount + parkingFee + crossingFee).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
//                orderLogistics.setMoneyType(2);
//                orderLogistics.setMoneyTime(num16);
//                return orderLogistics;
//            }
//        }
        //高峰时段处理逻辑
        Calendar s1 = Calendar.getInstance();
        s1.setTime(date);
        s1.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num23.split(" - ")[0].split(":")[0]));
        s1.set(Calendar.MINUTE, Integer.valueOf(num23.split(" - ")[0].split(":")[1]));
        Calendar e1 = Calendar.getInstance();
        e1.setTime(date);
        e1.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num23.split(" - ")[1].split(":")[0]));
        e1.set(Calendar.MINUTE, Integer.valueOf(num23.split(" - ")[1].split(":")[1]));
        Calendar s2 = Calendar.getInstance();
        s2.setTime(date);
        s2.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num24.split(" - ")[0].split(":")[0]));
        s2.set(Calendar.MINUTE, Integer.valueOf(num24.split(" - ")[0].split(":")[1]));
        Calendar e2 = Calendar.getInstance();
        e2.setTime(date);
        e2.set(Calendar.HOUR_OF_DAY, Integer.valueOf(num24.split(" - ")[1].split(":")[0]));
        e2.set(Calendar.MINUTE, Integer.valueOf(num24.split(" - ")[1].split(":")[1]));
        if((date.getTime() > s1.getTimeInMillis() && date.getTime() < e1.getTimeInMillis()) || (date.getTime() > s2.getTimeInMillis() && date.getTime() < e2.getTimeInMillis())){
            if(d > num8.doubleValue() && d <= num9.doubleValue()){
                yt1 = num28 * (d - num8);
            }
            if(d > num9.doubleValue()){
                yt1 = num28 * (num9 - num8);
            }
            if(d > num11.doubleValue() && d <= num12.doubleValue()){
                yt2 = num29 * (d - num11);
            }
            if(d > num12.doubleValue()){
                yt2 = num29 * (num12 - num11);
            }
            if(d > num14.doubleValue()){
                yt3 = num30 * (d - num14);
            }
            amount = num25 + (d1 * num26) + (t1 * num27) + (w1 * num7) + yt1 + yt2 + yt3;
            orderLogistics.setStartMileage(num2);
            orderLogistics.setStartDuration((int)(num3.doubleValue()));
            orderLogistics.setStartMoney(num25);//起步价
            orderLogistics.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            orderLogistics.setMileageMoney(new BigDecimal(d1 * num26).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//里程费
            orderLogistics.setDuration(new BigDecimal(t1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            orderLogistics.setDurationMoney(new BigDecimal(t1 * num27).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//时长费
            orderLogistics.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            orderLogistics.setWaitMoney(new BigDecimal(w1 * num7).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//等待费
            orderLogistics.setLongDistance(new BigDecimal((d > num8) ? d - num8 : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            orderLogistics.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//远途费
            orderLogistics.setParkMoney(parkingFee);//停车费
            orderLogistics.setRoadTollMoney(crossingFee);//过路费
            orderLogistics.setRedPacketMoney(0D);//红包抵扣
            orderLogistics.setCouponMoney(0D);//优惠券抵扣
            orderLogistics.setDiscount(0D);//优惠抵扣
            orderLogistics.setPayMoney(0D);//支付金额
            orderLogistics.setOrderMoney(new BigDecimal(amount + parkingFee + crossingFee).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            orderLogistics.setMoneyType(3);
            if((date.getTime() > s1.getTimeInMillis() && date.getTime() < e1.getTimeInMillis())){
                orderLogistics.setMoneyTime(num23);
            }else{
                orderLogistics.setMoneyTime(num24);
            }
            return orderLogistics;
        }
        //其他时间段的计算
        if(d > num8.doubleValue() && d <= num9.doubleValue()){
            yt1 = num10 * (d - num8);
        }
        if(d > num9.doubleValue()){
            yt1 = num10 * (num9 - num8);
        }
        if(d > num11.doubleValue() && d <= num12.doubleValue()){
            yt2 = num13 * (d - num11);
        }
        if(d > num12.doubleValue()){
            yt2 = num13 * (num12 - num11);
        }
        if(d > num14.doubleValue()){
            yt3 = num15 * (d - num14);
        }
        amount = num1 + (d1 * num4) + (t1 * num5) + (w1 * num7) + yt1 + yt2 + yt3;
        orderLogistics.setStartMileage(num2);
        orderLogistics.setStartDuration((int)(num3.doubleValue()));
        orderLogistics.setStartMoney(num1);//起步价
        orderLogistics.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
        orderLogistics.setMileageMoney(new BigDecimal(d1 * num4).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//里程费
        orderLogistics.setDuration(new BigDecimal(t1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
        orderLogistics.setDurationMoney(new BigDecimal(t1 * num5).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//时长费
        orderLogistics.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
        orderLogistics.setWaitMoney(new BigDecimal(w1 * num7).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//等待费
        orderLogistics.setLongDistance(new BigDecimal((d > num8) ? d - num8 : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
        orderLogistics.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());//远途费
        orderLogistics.setParkMoney(parkingFee);//停车费
        orderLogistics.setRoadTollMoney(crossingFee);//过路费
        orderLogistics.setRedPacketMoney(0D);//红包抵扣
        orderLogistics.setCouponMoney(0D);//优惠券抵扣
        orderLogistics.setDiscount(0D);//优惠抵扣
        orderLogistics.setPayMoney(0D);//支付金额
        orderLogistics.setOrderMoney(new BigDecimal(amount + parkingFee + crossingFee).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
        orderLogistics.setMoneyType(1);
        return orderLogistics;
    }
    /**
     * 确认费用操作
     * @param orderId
     * @param type
     * @param parkingFee
     * @param crossingFee
     * @return
     * @throws Exception
     */
    @Override
    public ResultUtil confirmFees(Integer language, Integer orderId, Integer type, Double parkingFee, Double crossingFee) throws Exception {
        OrderLogistics orderLogistics = this.selectById(orderId);
        if(orderLogistics.getArriveTime()==null){
            orderLogistics.setArriveTime(orderLogistics.getStartServiceTime());
        }
        orderLogistics = this.setMoney(orderLogistics, 0D, 0D);//计算费用
        orderLogistics.setPayManner(type);
        orderLogistics.setParkMoney(null == parkingFee ? 0D : parkingFee);
        orderLogistics.setRoadTollMoney(null == crossingFee ? 0D : crossingFee);
        orderLogistics.setOrderMoney(orderLogistics.getOrderMoney() + orderLogistics.getParkMoney() + orderLogistics.getRoadTollMoney() + orderLogistics.getPriceDifference());
        //判断是否首单免费-免费直接完成
        Integer orderNumber = this.selectCount(new EntityWrapper<OrderLogistics>().eq("userId",orderLogistics.getUserId()).last("and (state=8 or state=9)"));
        if(orderNumber<=0){//判断是否是首单
            //判断是否免单
            UserInfo userInfo = userInfoMapper.selectById(orderLogistics.getUserId());
            if(userInfo.getFreeMoney().doubleValue()>0d){
                if(orderLogistics.getOrderMoney()<=userInfo.getFreeMoney().doubleValue()){
                    orderLogistics.setState(8);
                    orderLogistics.setIsFree(2);
                    //添加已收入明细
                    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);
                }else{
                    orderLogistics.setState(7);
                    orderLogistics.setOrderMoney(orderLogistics.getOrderMoney()-userInfo.getFreeMoney().doubleValue());
                    orderLogistics.setFreeMoney(userInfo.getFreeMoney());
                }
            }else{
                orderLogistics.setState(7);
            }
        }else{
            orderLogistics.setState(7);
        }
        Map<String, String> map = chinaMobileUtil.midAxbUnBindSend(orderLogistics.getBindId(),orderLogistics.getTelX());
        if(String.valueOf(map.get("code")).equals("200")){
            orderLogistics.setTelX("");
            orderLogistics.setBindId("");
        }
        this.updateById(orderLogistics);
        pushUtil.removeTask(orderId, 4);//删除定时任务,结束推送数据
        systemNoticeService.addSystemNotice(1, language == 1 ? "司机已结束本次行程,谢谢使用" : language == 2 ?
                "The driver has finished the trip,thank you for using I-GO" : "Le chauffeur a terminé le trajet, merci d'utiliser I-GO", orderLogistics.getUserId());
        //回滚司机状态为空闲
        Driver driver = driverService.selectById(orderLogistics.getDriverId());
        driver.setState(2);
        driverService.updateById(driver);
        OrderLogistics finalOrderTaxi = orderLogistics;
        new Thread(new Runnable() {
            @Override
            public void run() {
                pushUtil.pushOrderState(1, finalOrderTaxi.getUserId(), finalOrderTaxi.getId(), 4, finalOrderTaxi.getState());
                pushUtil.pushOrderState(2, finalOrderTaxi.getDriverId(), finalOrderTaxi.getId(), 4, finalOrderTaxi.getState());
            }
        }).start();
        return ResultUtil.success();
    }
}
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
@@ -14,8 +14,11 @@
import com.stylefeng.guns.modular.system.model.*;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.*;
import com.stylefeng.guns.modular.system.util.quartz.QuartzUtil;
import com.stylefeng.guns.modular.system.util.quartz.jobs.OrderTimeOutJob;
import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService;
import org.quartz.JobDataMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -27,6 +30,7 @@
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -88,6 +92,9 @@
    @Value("${filePath}")
    private String filePath;
    @Autowired
    private IReminderRulesService reminderRulesService;
@@ -197,21 +204,6 @@
                driver.getCompanyId() != null && driver.getCompanyId() != 0 ? driver.getCompanyId() : 1));
        orderPrivateCar.setState(2);
        orderPrivateCar.setSnatchOrderTime(new Date());
        //调用高德创建轨迹
//        String s = gdFalconUtil.selectTerminal(driver.getPhone());
//        String track = gdFalconUtil.createTrack(s);
//        orderPrivateCar.setTrackId(track);
        //调用移动的小号接口
        /*Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderPrivateCar.getStartLon().toString(), orderPrivateCar.getStartLat().toString());
        Region region = regionMapper.query(geocode.get("districtCode"));*/
//        Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderPrivateCar.getPassengersPhone(), driver.getPhone(), null);
//        if(String.valueOf(map.get("code")).equals("200")){
//            orderPrivateCar.setTelX(map.get("telX"));
//            orderPrivateCar.setBindId(map.get("bindId"));
//        }
//        System.out.println(map);
        this.updateById(orderPrivateCar);
        //如果是预约单,则不修改司机为服务中
@@ -220,7 +212,52 @@
            driver.setState(3);
            driverService.updateById(driver);
        }
        //todo 待翻译
        //添加定时任务(普通任务)
        ReminderRules reminderRules = reminderRulesService.selectOne(new EntityWrapper<ReminderRules>().eq("companyId", driver.getCompanyId()));
        if(null != reminderRules){
            JSONObject jsonObject = JSON.parseObject(reminderRules.getContent());
            //预约单
            if(orderPrivateCar.getOrderType() == 1){
                long specialCarTimeoutReminderInterval = jsonObject.getInteger("specialCarTimeoutReminderInterval") * 60000L;
                long m = (System.currentTimeMillis() - orderPrivateCar.getSnatchOrderTime().getTime()) / 60000;
                JobDataMap jobDataMap = new JobDataMap();
                jobDataMap.put("driverId", uid);
                jobDataMap.put("orderId", orderPrivateCar.getId());
                jobDataMap.put("orderType", 1);
                jobDataMap.put("describe", "您的打车订单已超时" + m + "分钟,请抓紧!");
                QuartzUtil.addSimpleQuartzTask(
                        new OrderTimeOutJob().buildQuartzJob(UUIDUtil.getRandomCode(5) + "_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap)
                        , new Date(specialCarTimeoutReminderInterval), specialCarTimeoutReminderInterval, -1);
            }else{
                UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId());
                JSONObject reservationOrder = jsonObject.getJSONObject("reservationOrder");
                long appointmentReminder = reservationOrder.getInteger("appointmentReminder") * 60000L;
                long appointmentTimeoutReminderInterval = reservationOrder.getInteger("appointmentTimeoutReminderInterval") * 60000L;
                SimpleDateFormat sdf = new SimpleDateFormat("");
                JobDataMap jobDataMap = new JobDataMap();
                jobDataMap.put("driverId", uid);
                jobDataMap.put("orderId", orderPrivateCar.getId());
                jobDataMap.put("orderType", 1);
                jobDataMap.put("describe", "您将于" + sdf.format(orderPrivateCar.getTravelTime()) + "去接" + userInfo.getFirstName() + " " + userInfo.getLastName() + ",请准时!");
                QuartzUtil.addSimpleQuartzTask(
                        new OrderTimeOutJob().buildQuartzJob(UUIDUtil.getRandomCode(5) + "_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap)
                        , new Date(appointmentReminder), appointmentReminder, 0);
                jobDataMap = new JobDataMap();
                jobDataMap.put("driverId", uid);
                jobDataMap.put("orderId", orderPrivateCar.getId());
                jobDataMap.put("orderType", 1);
                jobDataMap.put("describe", "您将于" + sdf.format(orderPrivateCar.getTravelTime()) + "去接" + userInfo.getFirstName() + " " + userInfo.getLastName() + ",请准时!");
                QuartzUtil.addSimpleQuartzTask(
                        new OrderTimeOutJob().buildQuartzJob(UUIDUtil.getRandomCode(5) + "_" + orderPrivateCar.getId() + "_1", "ORDER_TIME_OUT", jobDataMap)
                        , new Date(appointmentReminder + appointmentTimeoutReminderInterval), appointmentTimeoutReminderInterval, -1);
            }
        }
        //推送相关代码------------------start----------------
        new Thread(new Runnable() {
            @Override
@@ -233,12 +270,6 @@
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                pushUtil.pushDriverPosition(orderId, 1);
            }
        }).start();
        systemNoticeService.addSystemNotice(2, language == 1 ? "您已成功抢得打车订单,请及时联系客户!" :
                language == 2 ? "You have grabbed the ride order, please contact the client timely."
@@ -294,6 +325,7 @@
                orderPrivateCar.setState(3);
                orderPrivateCar.setSetOutTime(new Date());
                systemNoticeService.addSystemNotice(1, language == 1 ? "司机已出发,请耐心等待" : language == 2 ? "The driver is on the way, please wait." : "Le chauffeur est en route. Veuillez patienter.", orderPrivateCar.getUserId());
                pushUtil.pushDriverPosition(orderPrivateCar.getId(), 1);//主动推送司机定位
                break;
            case 4://到达预约点,等待客户上车
                orderPrivateCar.setState(4);
@@ -309,8 +341,6 @@
                orderPrivateCar.setBoardingTime(new Date());
                orderPrivateCar.setState(5);
                orderPrivateCar.setStartServiceTime(new Date());
                pushUtil.pushDriverPosition(orderPrivateCar.getId(), 1);//主动推送司机定位
                OrderPosition orderPosition = new OrderPosition();
                orderPosition.setOrderId(orderId);
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/ReminderRulesMapper.java
New file
@@ -0,0 +1,11 @@
package com.stylefeng.guns.modular.system.dao;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.stylefeng.guns.modular.system.model.ReminderRules;
/**
 * @author zhibing.pu
 * @Date 2024/4/18 16:10
 */
public interface ReminderRulesMapper extends BaseMapper<ReminderRules> {
}
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/dao/mapping/ReminderRulesMapper.xml
New file
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.stylefeng.guns.modular.system.dao.ReminderRulesMapper">
</mapper>
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/model/ReminderRules.java
New file
@@ -0,0 +1,32 @@
package com.stylefeng.guns.modular.system.model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Data;
/**
 * 系统提醒规则
 * @author zhibing.pu
 * @Date 2024/4/18 16:09
 */
@Data
@TableName("t_sys_reminder_rules")
public class ReminderRules {
    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    /**
     * 企业id
     */
    @TableField("companyId")
    private Integer companyId;
    /**
     * 配置规则
     */
    @TableField("content")
    private String content;
}
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/IReminderRulesService.java
New file
@@ -0,0 +1,11 @@
package com.stylefeng.guns.modular.system.service;
import com.baomidou.mybatisplus.service.IService;
import com.stylefeng.guns.modular.system.model.ReminderRules;
/**
 * @author zhibing.pu
 * @Date 2024/4/18 16:11
 */
public interface IReminderRulesService extends IService<ReminderRules> {
}
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/OrderServiceImpl.java
@@ -584,7 +584,7 @@
            case 3://城际(没有此流程)
                break;
            case 4://
                break;
                return orderLogisticsService.confirmFees(language, orderId, type, parkingFee, crossingFee);
            case 5:
                break;
            case 6:
@@ -675,7 +675,7 @@
            case 3://城际(没有此流程)
                return null;
            case 4://
                break;
                return orderLogisticsService.queryOrderInfo(language, orderId);
            case 5:
                break;
            case 6:
@@ -980,6 +980,26 @@
                    redisUtil.setStrValue("VEHICLE", jsonArray.toJSONString());
                }
                break;
            case 4:
                OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId);
                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, unable to complete the order." : "La commande n’est plus en attente de paiement, il est impossible de terminer la commande.");
                }
                orderLogistics.setPayManner(2);//其他方式支付
                orderLogistics.setRedPacketMoney(0D);
                orderLogistics.setCouponMoney(0D);
                orderLogistics.setDiscount(0D);
                orderLogistics.setDiscountMoney(0D);
                orderLogistics.setPayMoney(orderLogistics.getOrderMoney());
                orderLogistics.setState(8);
                orderLogisticsService.updateById(orderLogistics);
                userId = orderLogistics.getUserId();
                driverId = orderLogistics.getDriverId();
                state = orderLogistics.getState();
                break;
        }
@@ -1011,6 +1031,8 @@
                return orderPrivateCarService.queryMoneyInfo(orderId);
            case 2:
                break;
            case 4:
                return orderLogisticsService.queryMoneyInfo(orderId);
        }
        return null;
    }
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/ReminderRulesServiceImpl.java
New file
@@ -0,0 +1,15 @@
package com.stylefeng.guns.modular.system.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.modular.system.dao.ReminderRulesMapper;
import com.stylefeng.guns.modular.system.model.ReminderRules;
import com.stylefeng.guns.modular.system.service.IReminderRulesService;
import org.springframework.stereotype.Service;
/**
 * @author zhibing.pu
 * @Date 2024/4/18 16:12
 */
@Service
public class ReminderRulesServiceImpl extends ServiceImpl<ReminderRulesMapper, ReminderRules> implements IReminderRulesService {
}
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/PushUtil.java
@@ -47,9 +47,6 @@
    private IOrderTaxiService orderTaxiService;
    @Autowired
    private GDMapElectricFenceUtil gdMapElectricFenceUtil;
    @Autowired
    private IOrderPrivateCarService orderPrivateCarService;
    @Autowired
@@ -495,8 +492,9 @@
     * @param orderId
     * @param orderType
     * @param money
     * @param status 1=申请,2=同意,3=拒绝
     */
    public void pushPayDifference(Integer type, Integer uid, Integer orderId, Integer orderType, Double money){
    public void pushPayDifference(Integer type, Integer uid, Integer orderId, Integer orderType, Double money, Integer status){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code", 200);
        jsonObject.put("msg", "SUCCESS");
@@ -505,6 +503,7 @@
        map.put("orderId", orderId);
        map.put("orderType", orderType);
        map.put("money", money);
        map.put("status", status);
        jsonObject.put("data", map);
        //调用推送
@@ -575,4 +574,41 @@
            System.err.println(jsonObject1.getString("msg"));
        }
    }
    /**
     * 司机超时推送
     * @param type
     * @param uid
     * @param orderId
     * @param orderType
     * @param describe
     */
    public void pushOrderTimeOut(Integer type, Integer uid, Integer orderId, Integer orderType, String describe){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code", 200);
        jsonObject.put("msg", "SUCCESS");
        jsonObject.put("method", "ORDER_TIME_OUT");
        Map<String, Object> map = new HashMap<>();
        map.put("orderId", orderId);
        map.put("orderType", orderType);
        map.put("describe", describe);
        jsonObject.put("data", map);
        //调用推送
        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        //将请求头部和参数合成一个请求
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        params.add("msg", jsonObject.toJSONString());
        params.add("id", String.valueOf(uid));
        params.add("type", String.valueOf(type));
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers);
        String s = internalRestTemplate.postForObject("http://zuul-gateway/netty/sendMsgToClient",requestEntity , String.class);
        JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
        if(jsonObject1.getIntValue("code") != 200){
            System.err.println(jsonObject1.getString("msg"));
        }
    }
}
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/quartz/QuartzUtil.java
New file
@@ -0,0 +1,261 @@
package com.stylefeng.guns.modular.system.util.quartz;
import com.stylefeng.guns.modular.system.util.quartz.model.QuartzEnum;
import com.stylefeng.guns.modular.system.util.quartz.model.QuartzJob;
import lombok.extern.slf4j.Slf4j;
import org.quartz.*;
import org.quartz.impl.matchers.GroupMatcher;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
 * quartz任务调度工具类
 * @author zhibing.pu
 * @Date 2024/3/20 11:12
 */
@Slf4j
public class QuartzUtil {
    /**
     * 构建调度器
     */
    public static Scheduler scheduler;
    /**
     * 启动调度器
     * @param propertiesStream 配置文件流
     * @return
     */
    public static void start(InputStream propertiesStream) throws SchedulerException {
        if(null == scheduler){
            scheduler = SchedulerUtil.getScheduler(propertiesStream);
        }
        scheduler.start();
        log.info(QuartzEnum.SCHEDULER_START_SUCCESS.getValue());
    }
    /**
     * 添加普通定时任务
     * @param quartzJob 任务类
     * @param startTime 任务开始执行时间,为空则立即执行
     * @param intervalInMilliseconds 执行间隔毫秒数
     * @param repeatCount 重复执行次数,-1表示永远执行
     * @throws SchedulerException
     */
    public static void addSimpleQuartzTask(QuartzJob quartzJob, Date startTime, long intervalInMilliseconds, int repeatCount) throws SchedulerException {
        if(null == scheduler){
            log.error("请先加载任务调取器");
            return;
        }
        JobDetail jobDetail = getJobDetail(quartzJob);
        Trigger simpleTrigger = getSimpleTrigger(quartzJob, startTime, intervalInMilliseconds, repeatCount);
        scheduler.scheduleJob(jobDetail, simpleTrigger);
        log.info(QuartzEnum.ADD_SIMPLE_TRIGGER_SUCCESS.getValue());
    }
    /**
     * 添加Cron表达式的定时任务
     * @param quartzJob 任务类
     * @param cron cron表达式
     * @throws SchedulerException
     */
    public static void addCronQuartzTask(QuartzJob quartzJob, String cron) throws SchedulerException {
        if(null == scheduler){
            log.error("请先加载任务调取器");
            return;
        }
        JobDetail jobDetail = getJobDetail(quartzJob);
        Trigger cronTrigger = getCronTrigger(quartzJob, cron);
        scheduler.scheduleJob(jobDetail, cronTrigger);
        log.info(QuartzEnum.ADD_CRON_TRIGGER_SUCCESS.getValue());
    }
    /**
     * 删除任务
     * @param name 任务名称
     * @param group 任务分组
     * @return
     */
    public static boolean deleteQuartzTask(String name, String group){
        JobKey jobKey = new JobKey(name, group);
        boolean b = false;
        try {
            b = scheduler.deleteJob(jobKey);
        } catch (SchedulerException e) {
            throw new RuntimeException(e);
        }
        return b;
    }
    /**
     * 删除任务
     * @param jobKey
     * @return
     */
    public static boolean deleteQuartzTask(JobKey jobKey){
        boolean b = false;
        try {
            b = scheduler.deleteJob(jobKey);
        } catch (SchedulerException e) {
            throw new RuntimeException(e);
        }
        return b;
    }
    /**
     * 删除分组下的所有定时任务
     * @param group 分组名称
     * @return
     */
    public static boolean deleteGroupQuartzTask(String group){
        try {
            GroupMatcher<JobKey> groupMatcher = GroupMatcher.groupEquals(group);
            Set<JobKey> jobKeys = scheduler.getJobKeys(groupMatcher);
            boolean b = scheduler.deleteJobs(jobKeys.stream().collect(Collectors.toList()));
            if(!b){
                return false;
            }
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
        return true;
    }
    /**
     * 清空所有定时任务
     * @return
     */
    public static boolean deleteAllQuartzTask(){
        try {
            List<String> jobGroupNames = scheduler.getJobGroupNames();
            for (String jobGroupName : jobGroupNames) {
                GroupMatcher<JobKey> groupMatcher = GroupMatcher.groupEquals(jobGroupName);
                Set<JobKey> jobKeys = scheduler.getJobKeys(groupMatcher);
                boolean b = scheduler.deleteJobs(jobKeys.stream().collect(Collectors.toList()));
                if(!b){
                    return false;
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
        return true;
    }
    /**
     * 构建任务描述JobDetail对象
     * @param quartzJob 任务对象
     * @return
     */
    private static JobDetail getJobDetail(QuartzJob quartzJob){
        String name = quartzJob.getName();
        String group = quartzJob.getGroup();
        if(null == name || "".equals(name)){
            name = QuartzEnum.JOB_NAME.getValue();
        }
        if(null == group || "".equals(group)){
            group = QuartzEnum.DEFAULT_GROUP.getValue();
        }
        return getJobDetail(quartzJob, name, group, quartzJob.getJobDataMap());
    }
    /**
     * 构建任务描述JobDetail对象
     * @param job 任务类
     * @param job_name 任务名称
     * @param group_name 任务分组名称
     * @param jobDataMap 自定义参数
     * @return
     */
    private static JobDetail getJobDetail(Job job, String job_name, String group_name, JobDataMap jobDataMap){
        JobDetail jobDetail = JobBuilder.newJob(job.getClass())
                .withIdentity(job_name, group_name)
                .usingJobData(jobDataMap)
                .build();
        return jobDetail;
    }
    /**
     * 构建Trigger执行器
     * @param quartzJob 任务类
     * @param startTime 任务开始执行时间,为空则立即执行
     * @param intervalInMilliseconds 执行间隔毫秒数
     * @param repeatCount 重读执行次数,-1表示永远执行
     * @return
     */
    private static Trigger getSimpleTrigger(QuartzJob quartzJob, Date startTime, long intervalInMilliseconds, int repeatCount){
        String name = quartzJob.getName();
        String group = quartzJob.getGroup();
        if(null == name || "".equals(name)){
            name = QuartzEnum.JOB_NAME.getValue();
        }
        if(null == group || "".equals(group)){
            group = QuartzEnum.DEFAULT_GROUP.getValue();
        }
        TriggerBuilder<Trigger> triggerTriggerBuilder = TriggerBuilder.newTrigger();
        if(null == startTime){
            triggerTriggerBuilder.startNow();
        }else{
            triggerTriggerBuilder.startAt(startTime);
        }
        SimpleTrigger trigger = triggerTriggerBuilder
                .withIdentity(name, group)
                .withSchedule(
                        SimpleScheduleBuilder
                                .simpleSchedule()
                                .withIntervalInMilliseconds(intervalInMilliseconds)
                                .withRepeatCount(repeatCount)
                ).build();
        return trigger;
    }
    /**
     * 构建cronExpression表达式执行器
     * @param quartzJob 任务类
     * @param cron cron表达式
     * @return
     */
    private static Trigger getCronTrigger(QuartzJob quartzJob, String cron) {
        String name = quartzJob.getName();
        String group = quartzJob.getGroup();
        if(null == name || "".equals(name)){
            name = QuartzEnum.JOB_NAME.getValue();
        }
        if(null == group || "".equals(group)){
            group = QuartzEnum.DEFAULT_GROUP.getValue();
        }
        CronTrigger trigger = TriggerBuilder.newTrigger()
                .startNow()
                .withIdentity(name, group)
                .withSchedule(
                        CronScheduleBuilder.cronSchedule(cron)
                ).build();
        return trigger;
    }
}
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/quartz/SchedulerUtil.java
New file
@@ -0,0 +1,35 @@
package com.stylefeng.guns.modular.system.util.quartz;
import org.quartz.Scheduler;
import org.quartz.impl.StdSchedulerFactory;
import java.io.InputStream;
/**
 * @author zhibing.pu
 * @Date 2024/3/20 10:56
 */
public class SchedulerUtil {
    /**
     * 获取调度器
     * 加载自定义配置文件
     * @param propertiesStream  配置文件流
     * @return
     */
    public static Scheduler getScheduler(InputStream propertiesStream) {
        try {
            StdSchedulerFactory stdSchedulerFactory = new StdSchedulerFactory();
            if(null == propertiesStream){
                stdSchedulerFactory.initialize("quartz.properties");
            }else{
                stdSchedulerFactory.initialize(propertiesStream);
            }
            return stdSchedulerFactory.getScheduler();
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/quartz/jobs/OrderTimeOutJob.java
New file
@@ -0,0 +1,134 @@
package com.stylefeng.guns.modular.system.util.quartz.jobs;
import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics;
import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService;
import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
import com.stylefeng.guns.modular.system.util.PushUtil;
import com.stylefeng.guns.modular.system.util.quartz.QuartzUtil;
import com.stylefeng.guns.modular.system.util.quartz.model.QuartzJob;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobKey;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
 * 订单司机超时提醒任务
 * @author zhibing.pu
 * @Date 2024/4/18 15:19
 */
@Slf4j
@Component
public class OrderTimeOutJob extends QuartzJob {
    @Resource
    private PushUtil pushUtil;
    @Resource
    private IOrderPrivateCarService orderPrivateCarService;
    @Resource
    private IOrderLogisticsService orderLogisticsService;
    @Override
    public QuartzJob buildQuartzJob() {
        return super.buildQuartzJob();
    }
    @Override
    public QuartzJob buildQuartzJob(String name) {
        return super.buildQuartzJob(name);
    }
    @Override
    public QuartzJob buildQuartzJob(String name, String group) {
        return super.buildQuartzJob(name, group);
    }
    @Override
    public QuartzJob buildQuartzJob(String name, String group, JobDataMap jobDataMap) {
        return super.buildQuartzJob(name, group, jobDataMap);
    }
    /**
     * 执行的业务逻辑
     * @param jobExecutionContext 定时任务上下文对象
     */
    @Override
    public void run(JobExecutionContext jobExecutionContext) {
        JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
        Integer driverId = jobDataMap.getIntegerFromString("driverId");
        Integer orderId = jobDataMap.getIntegerFromString("orderId");
        Integer orderType = jobDataMap.getIntegerFromString("orderType");
        String describe = jobDataMap.getString("describe");
        if(1 == orderType){
            OrderPrivateCar orderPrivateCar = orderPrivateCarService.selectById(orderId);
            if(2 != orderPrivateCar.getState()){
                JobKey key = jobExecutionContext.getJobDetail().getKey();
                boolean b = QuartzUtil.deleteQuartzTask(key);
                if(!b){
                    log.error("定时任务关闭失败:" + key.toString());
                }
                return;
            }
        }
        if(4 == orderType){
            OrderLogistics orderLogistics = orderLogisticsService.selectById(orderId);
            if(2 != orderLogistics.getState()){
                JobKey key = jobExecutionContext.getJobDetail().getKey();
                boolean b = QuartzUtil.deleteQuartzTask(key);
                if(!b){
                    log.error("定时任务关闭失败:" + key.toString());
                }
                return;
            }
        }
        pushUtil.pushOrderTimeOut(2, driverId, orderId, orderType, describe);
    }
    /**
     * 初始化任务对象
     * @return
     */
    public static QuartzJob init(){
        return new OrderTimeOutJob().buildQuartzJob();
    }
    /**
     * 初始化任务对象
     * @param name
     * @return
     */
    public static QuartzJob init(String name){
        return new OrderTimeOutJob().buildQuartzJob(name);
    }
    /**
     * 初始化任务对象
     * @param name
     * @param group
     * @return
     */
    public static QuartzJob init(String name, String group){
        return new OrderTimeOutJob().buildQuartzJob(name, group);
    }
    /**
     * 初始化任务对象
     * @param name
     * @param group
     * @return
     */
    public static QuartzJob init(String name, String group, JobDataMap jobDataMap){
        return new OrderTimeOutJob().buildQuartzJob(name, group, jobDataMap);
    }
}
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/quartz/model/QuartzEnum.java
New file
@@ -0,0 +1,46 @@
package com.stylefeng.guns.modular.system.util.quartz.model;
/**
 *
 * quartz枚举常量
 * @author zhibing.pu
 * @Date 2024/3/20 11:20
 */
public enum QuartzEnum {
    /**
     * 任务名称
     */
    JOB_NAME("quartz_job"),
    /**
     * 任务分组
     */
    DEFAULT_GROUP("quartz_group"),
    /**
     * quartz任务调度器启动成功
     */
    SCHEDULER_START_SUCCESS("Quartz Scheduler start success!"),
    /**
     * 任务添加到调度器成功
     */
    ADD_SIMPLE_TRIGGER_SUCCESS("add Quartz SimpleTrigger success!"),
    /**
     * 任务添加到调度器成功
     */
    ADD_CRON_TRIGGER_SUCCESS("add Quartz CronTrigger success!")
    ;
    QuartzEnum(String value) {
        this.value = value;
    }
    private String value;
    public String getValue() {
        return value;
    }
    private void setValue(String value) {
        this.value = value;
    }
}
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/util/quartz/model/QuartzJob.java
New file
@@ -0,0 +1,108 @@
package com.stylefeng.guns.modular.system.util.quartz.model;
import com.stylefeng.guns.core.util.ToolUtil;
import lombok.Data;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
/**
 * quartz任务类
 * @author zhibing.pu
 * @Date 2024/3/20 11:14
 */
@Slf4j
@Data
public abstract class QuartzJob implements Job {
    /**
     * 任务名称
     */
    @Getter
    private String name;
    /**
     * 任务分组
     */
    @Getter
    private String group;
    /**
     * 自定义参数
     */
    @Getter
    private JobDataMap jobDataMap;
    /**
     * 构建QuartzJob对象
     * @return
     */
    public QuartzJob buildQuartzJob() {
        return buildQuartzJob(QuartzEnum.JOB_NAME.getValue());
    }
    /**
     * 构建QuartzJob对象
     * @param name  任务名称
     * @return
     */
    public QuartzJob buildQuartzJob(String name) {
        return buildQuartzJob(name, QuartzEnum.DEFAULT_GROUP.getValue());
    }
    /**
     * 构建QuartzJob对象
     * @param name 任务名称
     * @param group 任务分组名称
     * @return
     */
    public QuartzJob buildQuartzJob(String name, String group) {
        return buildQuartzJob(name, QuartzEnum.DEFAULT_GROUP.getValue(), null);
    }
    /**
     * 构建QuartzJob对象
     * @param name 任务名称
     * @param group 任务分组名称
     * @param jobDataMap 自定义参数
     * @return
     */
    public QuartzJob buildQuartzJob(String name, String group, JobDataMap jobDataMap) {
        if(ToolUtil.isNotEmpty(name)){
            this.name = name;
        }else{
            this.name = QuartzEnum.JOB_NAME.getValue();
        }
        if(ToolUtil.isNotEmpty(group)){
            this.group = group;
        }else{
            this.group = QuartzEnum.DEFAULT_GROUP.getValue();
        }
        this.jobDataMap = jobDataMap;
        return this;
    }
    /**
     * 需要执行的任务的业务逻辑方法
     * @param jobExecutionContext 定时任务上下文对象
     */
    public abstract void run(JobExecutionContext jobExecutionContext);
    /**
     * 执行器执行任务调用的方式
     * @param jobExecutionContext 定时任务上下文对象
     * @throws JobExecutionException
     */
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        String name = jobExecutionContext.getJobDetail().getKey().getName();
        log.info(name + " scheduled task start!");
        run(jobExecutionContext);
    }
}
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/MoneyInfoWarpper.java
@@ -2,12 +2,14 @@
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Map;
/**
 * 费用明细
 */
@Data
@ApiModel("费用明细")
public class MoneyInfoWarpper {
    @ApiModelProperty("订单总金额")
@@ -44,164 +46,8 @@
    private Double discountMoney;
    @ApiModelProperty("折扣")
    private Double discount;
    public Double getOrderMoney() {
        return orderMoney;
    }
    public void setOrderMoney(Double orderMoney) {
        this.orderMoney = orderMoney;
    }
    public Double getStartMoney() {
        return startMoney;
    }
    public void setStartMoney(Double startMoney) {
        this.startMoney = startMoney;
    }
    public Double getMileageMoney() {
        return mileageMoney;
    }
    public void setMileageMoney(Double mileageMoney) {
        this.mileageMoney = mileageMoney;
    }
    public Double getDurationMoney() {
        return durationMoney;
    }
    public void setDurationMoney(Double durationMoney) {
        this.durationMoney = durationMoney;
    }
    public Double getWaitMoney() {
        return waitMoney;
    }
    public void setWaitMoney(Double waitMoney) {
        this.waitMoney = waitMoney;
    }
    public Double getLongDistanceMoney() {
        return longDistanceMoney;
    }
    public void setLongDistanceMoney(Double longDistanceMoney) {
        this.longDistanceMoney = longDistanceMoney;
    }
    public Double getParkMoney() {
        return parkMoney;
    }
    public void setParkMoney(Double parkMoney) {
        this.parkMoney = parkMoney;
    }
    public Double getRoadTollMoney() {
        return roadTollMoney;
    }
    public void setRoadTollMoney(Double roadTollMoney) {
        this.roadTollMoney = roadTollMoney;
    }
    public Double getRedPacketMoney() {
        return redPacketMoney;
    }
    public void setRedPacketMoney(Double redPacketMoney) {
        this.redPacketMoney = redPacketMoney;
    }
    public Double getCouponMoney() {
        return couponMoney;
    }
    public void setCouponMoney(Double couponMoney) {
        this.couponMoney = couponMoney;
    }
    public Double getDiscountMoney() {
        return discountMoney;
    }
    public void setDiscountMoney(Double discountMoney) {
        this.discountMoney = discountMoney;
    }
    public Double getDiscount() {
        return discount;
    }
    public void setDiscount(Double discount) {
        this.discount = discount;
    }
    public Double getMileage() {
        return mileage;
    }
    public void setMileage(Double mileage) {
        this.mileage = mileage;
    }
    public Double getDuration() {
        return duration;
    }
    public void setDuration(Double duration) {
        this.duration = duration;
    }
    public Double getWait() {
        return wait;
    }
    public void setWait(Double wait) {
        this.wait = wait;
    }
    public Double getLongDistance() {
        return longDistance;
    }
    public void setLongDistance(Double longDistance) {
        this.longDistance = longDistance;
    }
    public Double getStartMileage() {
        return startMileage;
    }
    public void setStartMileage(Double startMileage) {
        this.startMileage = startMileage;
    }
    @Override
    public String toString() {
        return "MoneyInfoWarpper{" +
                "orderMoney=" + orderMoney +
                ", startMoney=" + startMoney +
                ", mileageMoney=" + mileageMoney +
                ", mileage=" + mileage +
                ", durationMoney=" + durationMoney +
                ", duration=" + duration +
                ", waitMoney=" + waitMoney +
                ", wait=" + wait +
                ", longDistanceMoney=" + longDistanceMoney +
                ", longDistance=" + longDistance +
                ", parkMoney=" + parkMoney +
                ", roadTollMoney=" + roadTollMoney +
                ", redPacketMoney=" + redPacketMoney +
                ", couponMoney=" + couponMoney +
                ", discountMoney=" + discountMoney +
                ", discount=" + discount +
                '}';
    }
    @ApiModelProperty("补差价")
    private Double priceDifference;
    public static MoneyInfoWarpper getMoneyInfoWarpper(Map<String, Object> map){
        MoneyInfoWarpper moneyInfoWarpper = new MoneyInfoWarpper();
@@ -223,6 +69,7 @@
            moneyInfoWarpper.setCouponMoney(null != map.get("couponMoney") ? Double.valueOf(map.get("couponMoney").toString()) : 0D);
            moneyInfoWarpper.setDiscountMoney(null != map.get("discountMoney") ? Double.valueOf(map.get("discountMoney").toString()) : 0D);
            moneyInfoWarpper.setDiscount(null != map.get("discount") ? Double.valueOf(map.get("discount").toString()) : 0D);
            moneyInfoWarpper.setPriceDifference(null != map.get("priceDifference") ? Double.valueOf(map.get("priceDifference").toString()) : 0D);
        }
        return moneyInfoWarpper;
    }
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/warpper/OrderInfoWarpper.java
@@ -1,12 +1,9 @@
package com.stylefeng.guns.modular.system.warpper;
import com.stylefeng.guns.modular.system.model.OrderPosition;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ApiModel("订单详情22")
@@ -55,7 +52,6 @@
    private Integer payManner;
    @ApiModelProperty("支付金额")
    private Double payMoney;
    @ApiModelProperty("是否是改派单(1=否,2=是)")
    private Integer isReassign;
    @ApiModelProperty("高德猎鹰轨迹id(订单开始后需要上传坐标到指定轨迹中)")
@@ -90,10 +86,8 @@
    private String userName;
    @ApiModelProperty("司机支付状态【现金支付需要司机代支付】(1=待支付,2=已支付)")
    private Integer driverPay;
    @ApiModelProperty("轨迹")
    private String orderPositionList;
    private Integer startDuration;
    @ApiModelProperty("是否冻结(1=否,2=是)")
    private Integer isFrozen;
DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java
@@ -230,12 +230,6 @@
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                pushUtil.pushDriverPosition(orderId, 2);
            }
        }).start();
        systemNoticeService.addSystemNotice(2, "您已成功抢得出租车订单,请及时联系客户!", orderTaxi.getDriverId());
        systemNoticeService.addSystemNotice(1, "您的订单已指派给" + driver.getLastName().substring(0, 1) + "师傅,请保持电话畅通!", orderTaxi.getUserId());
@@ -315,13 +309,6 @@
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                pushUtil.pushDriverPosition(orderId, 2);
            }
        }).start();
        systemNoticeService.addSystemNotice(2, "您已成功抢得出租车订单,请及时联系客户!", orderTaxi.getDriverId());
        systemNoticeService.addSystemNotice(1, "您的订单已指派给" + driver.getLastName().substring(0, 1) + "师傅,请保持电话畅通!", orderTaxi.getUserId());
@@ -372,6 +359,7 @@
                orderTaxi.setState(3);
                orderTaxi.setSetOutTime(new Date());
                systemNoticeService.addSystemNotice(1, "司机已出发,请耐心等待", orderTaxi.getUserId());
                pushUtil.pushDriverPosition(orderTaxi.getId(), 2);//主动推送司机定位
                break;
            case 4://到达预约点,等待客户上车
                orderTaxi.setState(4);
@@ -385,8 +373,6 @@
                orderTaxi.setBoardingTime(new Date());
                orderTaxi.setState(5);
                orderTaxi.setStartServiceTime(new Date());
                pushUtil.pushDriverPosition(orderTaxi.getId(), 2);//主动推送司机定位
                break;
            case 6://结束服务
                orderTaxi.setGetoffLon(lon);
DriverIGOTravel/guns-admin/src/main/resources/application-dev.yml
@@ -42,7 +42,7 @@
---
spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/igotravel?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=Asia/Shanghai
    url: jdbc:mysql://127.0.0.1:3306/igotravel2.0?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=Asia/Shanghai
    username: root
    password: 123456
    db-name: guns #用来搜集数据库的所有表
DriverIGOTravel/guns-admin/src/main/resources/quartz.properties
New file
@@ -0,0 +1,39 @@
# Default Properties file for use by StdSchedulerFactory
# to create a Quartz Scheduler Instance, if a different
# properties file is not explicitly specified.
#
# 调度器的配置
# 实例名称,在集群环境中区分实例
org.quartz.scheduler.instanceName=MyScheduler
# 自动生成实例id,在集群环境中区分实例
org.quartz.scheduler.instanceId=AUTO
org.quartz.scheduler.rmi.export=false
org.quartz.scheduler.rmi.proxy=false
org.quartz.scheduler.wrapJobExecutionInUserTransaction=false
# 线程池的配置
# 线程实现类
org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
# 线程总数量
org.quartz.threadPool.threadCount=10
org.quartz.threadPool.threadPriority=5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread=true
# misfire阈值设置
org.quartz.jobStore.misfireThreshold=60000
# 任务存储配置
## 内存存储
#org.quartz.jobStore.class=org.quartz.simpl.RAMJobStore
# 数据库存储
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
# 驱动委托类
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
# 数据表名前缀
org.quartz.jobStore.tablePrefix=qrtz_
# 数据源配置
org.quartz.jobStore.dataSource=myDS
org.quartz.dataSource.myDS.driver=com.mysql.cj.jdbc.Driver
org.quartz.dataSource.myDS.URL=jdbc:mysql://127.0.0.1:3306/igotravel2.0?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=GMT%2B0
org.quartz.dataSource.myDS.user=root
org.quartz.dataSource.myDS.password=123456
org.quartz.dataSource.myDS.maxConnections=10