Pu Zhibing
2025-04-24 818937959bb19d3669585fa87a526bffe9ce77a4
DriverOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.util.ToolUtil;
@@ -33,16 +34,20 @@
    @Autowired
    private IDriverService driverService;
    @Autowired
    private ICompanyService companyService;
    @Autowired
    private IUserRedPacketRecordService userRedPacketRecordService;
    @Resource
    private SystemPriceMapper systemPriceMapper;
    @Autowired
    private PushUtil pushUtil;
    @Autowired
    private GDMapElectricFenceUtil gdMapElectricFenceUtil;
    @Autowired
    private ITransactionDetailsService transactionDetailsService;
    @Autowired
    private GDFalconUtil gdFalconUtil;
@@ -73,6 +78,12 @@
    @Resource
    private UserInfoMapper userInfoMapper;
    @Resource
    private TUseMoneyMapper useMoneyMapper;
    @Autowired
    private TransactionDetailsMapper transactionDetailsMapper;
@@ -194,10 +205,26 @@
//        String track = gdFalconUtil.createTrack(s);
//        orderTaxi.setTrackId(track);
        if (orderTaxi.getAudioLinkUrl()!=null){
            List<TUseMoney> money = useMoneyMapper.selectList(null);
//            List<TUseMoney> money = useMoneyMapper.selectList(null);
            Company company = companyService.selectById(driver.getCompanyId());
            orderTaxi.setState(9);
            driver.setState(2);
            driver.setBalance(driver.getBalance() - money.get(0).getMoney());
//            driver.setBalance(driver.getBalance() - company.getFixedDeduction());
            if(Objects.isNull(company)){
                company = companyService.selectById(driver.getCompanyId());
            }
            // 平台收入
            double money;
            if(orderTaxi.getOrderSource() == 2 || orderTaxi.getOrderSource() == 3){
                double v = company.getPercentageDeduction() / 100;
                money = v * orderTaxi.getOrderMoney();
            }else {
                money = company.getFixedDeduction();
            }
            driver.setBalance(driver.getBalance() - money);
            // 新增扣除使用费记录
            transactionDetailsService.saveData(driver.getId(), "软件使用费", money, 2, 1, 2, 6, orderTaxi.getId(),company.getId());
            driverService.updateById(driver);
            Car car = carService.selectById(driver.getCarId());
@@ -391,13 +418,6 @@
    public Map<String, Object> queryOrderInfo(Integer orderId) throws Exception {
        return orderTaxiMapper.queryOrderInfo(orderId);
    }
    @Resource
    private TUseMoneyMapper useMoneyMapper;
    @Autowired
    private TransactionDetailsMapper transactionDetailsMapper;
    /**
     * 走订单流程操作
     * @param orderId
@@ -434,25 +454,57 @@
                orderTaxi.setGetoffLat(lat);
                orderTaxi.setGetoffAddress(address);
                orderTaxi.setGetoffTime(new Date());
                orderTaxi.setState(6);
                if(orderTaxi.getPayManner()==3){
                    orderTaxi.setState(9);
                    Driver driver = driverService.selectById(orderTaxi.getDriverId());
                    Company company = companyService.selectById(driver.getFranchiseeId());
                    if(Objects.isNull(company)){
                        company = companyService.selectById(driver.getCompanyId());
                    }
                    TransactionDetails transactionDetails = new TransactionDetails();
                    driver.setBalance(driver.getBalance() - company.getFixedDeduction());
                    transactionDetails.setMoney(company.getFixedDeduction());
                    // 新增扣除使用费记录
                    transactionDetails.setUserId(driver.getId());
                    transactionDetails.setInsertTime(new Date());
                    transactionDetails.setRemark("软件使用费");
                    transactionDetails.setState(2);
                    transactionDetails.setType(1);
                    transactionDetails.setUserType(2);
                    transactionDetails.setOrderType(6);
                    transactionDetails.setOrderId(orderTaxi.getId());
                    transactionDetailsMapper.insert(transactionDetails);
                    driverService.updateById(driver);
                }else {
                    orderTaxi.setState(6);
                }
                orderTaxi.setEndServiceTime(new Date());
                List<TUseMoney> money = useMoneyMapper.selectList(null);
                Driver driver = driverService.selectById(orderTaxi.getDriverId());
                driver.setBalance(driver.getBalance() - money.get(0).getMoney());
                // 新增扣除使用费记录
                TransactionDetails transactionDetails = new TransactionDetails();
                transactionDetails.setUserId(driver.getId());
                transactionDetails.setInsertTime(new Date());
                transactionDetails.setRemark("软件使用费");
                transactionDetails.setMoney(money.get(0).getMoney());
                transactionDetails.setState(2);
                transactionDetails.setType(1);
                transactionDetails.setUserType(2);
                transactionDetails.setOrderType(6);
                transactionDetails.setOrderId(orderTaxi.getId());
                transactionDetailsMapper.insert(transactionDetails);
                driverService.updateById(driver);
//                List<TUseMoney> money = useMoneyMapper.selectList(null);
//                Driver driver = driverService.selectById(orderTaxi.getDriverId());
//                Company company = companyService.selectById(driver.getCompanyId());
//                TransactionDetails transactionDetails = new TransactionDetails();
//                if(orderTaxi.getOrderSource() == 2 || orderTaxi.getOrderSource() == 3){
//                    double v = company.getPercentageDeduction() / 100;
//                    v = v * orderTaxi.getOrderMoney();
//                    driver.setBalance(driver.getBalance() - v);
//                    transactionDetails.setMoney(v);
//                }else {
//                    driver.setBalance(driver.getBalance() - company.getFixedDeduction());
//                    transactionDetails.setMoney(company.getFixedDeduction());
//                }
//                // 新增扣除使用费记录
//                transactionDetails.setUserId(driver.getId());
//                transactionDetails.setInsertTime(new Date());
//                transactionDetails.setRemark("软件使用费");
//                transactionDetails.setState(2);
//                transactionDetails.setType(1);
//                transactionDetails.setUserType(2);
//                transactionDetails.setOrderType(6);
//                transactionDetails.setOrderId(orderTaxi.getId());
//                transactionDetailsMapper.insert(transactionDetails);
//                driverService.updateById(driver);
                pushUtil.removeTask(orderId, 2);//删除定时任务,结束推送数据
                systemNoticeService.addSystemNotice(1, "司机已结束本次行程,谢谢使用", orderTaxi.getUserId());
                break;
@@ -486,19 +538,13 @@
        OrderTaxi orderTaxi = this.selectById(orderId);
        orderTaxi.setPayManner(type);
        if(type == 2){//其他支付,不需要操作,直接完成订单
            orderTaxi.setOrderMoney(0D);
            orderTaxi.setTravelMoney(0D);
            orderTaxi.setParkMoney(0D);
            orderTaxi.setRoadTollMoney(0D);
            orderTaxi.setRedPacketMoney(0D);
            orderTaxi.setCouponMoney(0D);
            orderTaxi.setDiscount(0D);
            orderTaxi.setDiscountMoney(0D);
            orderTaxi.setPayMoney(0D);
            orderTaxi.setState(8);
        }else{
            orderTaxi = this.setMoney(orderTaxi, travelFee, parkingFee, crossingFee);
            orderTaxi = this.setMoney1(orderTaxi, travelFee, parkingFee, crossingFee);
            orderTaxi.setState(7);
        }else if (type == 1){
            orderTaxi = this.setMoney2(orderTaxi, parkingFee, crossingFee);
            orderTaxi.setState(7);
        }else {
            orderTaxi.setState(8);
        }
        this.updateById(orderTaxi);
@@ -718,6 +764,9 @@
            System.err.println("订单数据异常:" + orderId);
            return false;
        }
        if(orderTaxi.getState() != 5){
            return false;
        }
        OrderPosition orderPosition = orderPositionService.queryNew(orderId, 2);
        String now = lon + "," + lat;
        String old = null;
@@ -766,7 +815,284 @@
        return orderTaxiMapper.taskMidAxbUnBindSend();
    }
    @Override
    public Map<String, Object> queryMoneyInfo(Integer orderId) throws Exception {
        OrderTaxi orderTaxi = this.selectById(orderId);
        if(orderTaxi.getState() == 5 || orderTaxi.getState() == 6){//服务中的时候获取实时费用数据
            if(orderTaxi.getPayManner() == 2){//其他支付,不需要操作,直接完成订单
                orderTaxi = this.setMoney1(orderTaxi, 0D, 0D, 0D);
            }else if(orderTaxi.getPayManner() == 1){
                orderTaxi = this.setMoney2(orderTaxi, 0D, 0D);
            }else {
                // 无
            }
        }
        // 查询平台服务费
        TransactionDetails transactionDetails = transactionDetailsService.selectOne(new EntityWrapper<TransactionDetails>()
                .eq("orderId", orderId)
                .eq("orderType", 6)
                .last("LIMIT 1"));
        Map<String, Object> map = new HashMap<>();
        map.put("orderMoney", orderTaxi.getOrderMoney());//订单金额
        map.put("startMileage", orderTaxi.getStartMileage());//起步价
        map.put("startMoney", orderTaxi.getStartMoney());//起步价
        map.put("mileageKilometers", orderTaxi.getMileageKilometers());//里程费
        map.put("mileageMoney", orderTaxi.getMileageMoney());//里程费
        map.put("duration", orderTaxi.getDuration());//时长费
        map.put("durationMoney", orderTaxi.getDurationMoney());//时长费
        map.put("wait", orderTaxi.getWait());//等待费
        map.put("waitMoney", orderTaxi.getWaitMoney());//等待费
        map.put("longDistance", orderTaxi.getLongDistance());//远途费
        map.put("longDistanceMoney", orderTaxi.getLongDistanceMoney());//远途费
        map.put("parkMoney", orderTaxi.getParkMoney());//停车费
        map.put("roadTollMoney", orderTaxi.getRoadTollMoney());//过路费
        map.put("redPacketMoney", orderTaxi.getRedPacketMoney());//红包抵扣金额
        map.put("couponMoney", orderTaxi.getCouponMoney());//优惠券抵扣金额
        map.put("discountMoney", orderTaxi.getDiscountMoney());//折扣抵扣金额
        map.put("discount", orderTaxi.getDiscount());//折扣
        if(Objects.isNull(transactionDetails)){
            map.put("platformFee", 0);//折扣
        }else {
            map.put("platformFee", transactionDetails.getMoney());//折扣
        }
        return map;
    }
    /**
     * 计算价格
     * @param orderTaxi
     * @param parkingFee
     * @param crossingFee
     * @return
     * @throws Exception
     */
    public OrderTaxi setMoney1(OrderTaxi orderTaxi, Double travelFee, Double parkingFee, Double crossingFee) throws Exception{
        if (travelFee!=null){
            String s = travelFee.toString();
            BigDecimal trave = new BigDecimal(s);
            orderTaxi.setTravelMoney(trave.setScale(2, BigDecimal.ROUND_DOWN).doubleValue());
        }else{
            orderTaxi.setTravelMoney(0.0);
        }
        if (parkingFee!=null){
            String s1 = parkingFee.toString();
            BigDecimal parking = new BigDecimal(s1);
            orderTaxi.setParkMoney(parking.setScale(2, BigDecimal.ROUND_DOWN).doubleValue());
        }else{
            orderTaxi.setParkMoney(0.0);
        }
        if (crossingFee!=null){
            String s2 = crossingFee.toString();
            BigDecimal crossing = new BigDecimal(s2);
            orderTaxi.setRoadTollMoney(crossing.setScale(2, BigDecimal.ROUND_DOWN).doubleValue());
        }else{
            orderTaxi.setRoadTollMoney(0.0);
        }
        BigDecimal sum = new BigDecimal(null == travelFee ? 0 : travelFee).add(new BigDecimal(null == parkingFee ? 0 : parkingFee))
                .add(new BigDecimal(null == crossingFee ? 0 : crossingFee)).add(new BigDecimal(null == orderTaxi.getTipMoney() ? 0 : orderTaxi.getTipMoney()));
        orderTaxi.setOrderMoney(sum.setScale(2, BigDecimal.ROUND_DOWN).doubleValue());
        return orderTaxi;
    }
    /**
     * 计算价格
     * @param orderTaxi
     * @param parkingFee
     * @param crossingFee
     * @return
     * @throws Exception
     */
    public OrderTaxi setMoney2(OrderTaxi orderTaxi, Double parkingFee, Double crossingFee) throws Exception {
        Map<String, Object> query1 = systemPriceMapper.query1(orderTaxi.getCompanyId(), 2);
        //开始根据不同的方式计算金额
        double amount = 0;
        JSONObject jsonObject = JSON.parseObject(String.valueOf(query1.get("content")));
        //乘车类型(1=独享,2=一口价,3=拼车)
        double d = (null == orderTaxi.getMileage() ? 0D : orderTaxi.getMileage());
        System.out.println("行驶里程数"+d);
        //在价格区间按照一口价算,不在区间按实时价格算
        System.out.println("不在区间====================");
        orderTaxi = calculationPrice(orderTaxi,jsonObject,jsonObject.getLongValue("num29"),jsonObject.getDouble("num30"),parkingFee,crossingFee);
        System.out.println("返回订单数据"+orderTaxi);
        return orderTaxi;
    }
    public OrderTaxi calculationPrice(OrderTaxi OrderTaxi,JSONObject rule, long wait,Double waitMoney, Double parkingFee, Double crossingFee) throws Exception {
        double amount = 0.0;
        //等待费
        Date date = new Date();
        if(OrderTaxi.getEndServiceTime()==null)OrderTaxi.setEndServiceTime(date);
        double d = (null == OrderTaxi.getMileage() ? 0D : OrderTaxi.getMileage()) / 1000;//实际公里
        double t = ((OrderTaxi.getEndServiceTime().getTime() - OrderTaxi.getStartServiceTime().getTime()) / 60000) + 1;//实际时间(不满一分钟按一分钟算)
        double d1 = (d - rule.getDouble("num2")) < 0 ? 0 : d - rule.getDouble("num2");//超出起步里程的公里
        double t1 = (t - rule.getDouble("num3")) < 0 ? 0 : t - rule.getDouble("num3");//超过起步分钟数的时间
        double w = ((OrderTaxi.getStartServiceTime().getTime() - OrderTaxi.getArriveTime().getTime()) / 60000) + 1;//等待分钟(不满一分钟按一分钟算)
        double w1 = (w - wait) < 0 ? 0 : new BigDecimal(w - wait).setScale(0, BigDecimal.ROUND_UP).doubleValue();//超出等待时间的时间
        double yt1 = 0;//远途1段
        double yt2 = 0;//远途2段
        double yt3 = 0;//远途3段
        //夜间服务处理逻辑
        Calendar s = Calendar.getInstance();
        s.setTime(date);
        s.set(Calendar.HOUR_OF_DAY, Integer.valueOf(rule.getString("num14").split(" - ")[0].split(":")[0]));
        s.set(Calendar.MINUTE, Integer.valueOf(rule.getString("num14").split(" - ")[0].split(":")[1]));
        Calendar e = Calendar.getInstance();
        e.setTime(date);
        e.set(Calendar.HOUR_OF_DAY, Integer.valueOf(rule.getString("num14").split(" - ")[1].split(":")[0]));
        e.set(Calendar.MINUTE, Integer.valueOf(rule.getString("num14").split(" - ")[1].split(":")[1]));
        if(date.getTime() > s.getTimeInMillis() && date.getTime() < e.getTimeInMillis()){
            if(d > rule.getDouble("num6") && d < rule.getDouble("num7")){
                yt1 = rule.getDouble("num18") * d;
//                OrderTaxi.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            }
            if(d >  rule.getDouble("num9") && d < rule.getDouble("num10")){
                yt1 = rule.getDouble("num18") * rule.getDouble("num7");
                yt2 = rule.getDouble("num19") * (d - rule.getDouble("num9"));
//                OrderTaxi.setLongDistance(new BigDecimal((d > rule.getDouble("num9")) ? d - rule.getDouble("num9") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            }
            if(d > rule.getDouble("num12")){
                yt1 = rule.getDouble("num18") * rule.getDouble("num7");
                yt2 = rule.getDouble("num19") * (rule.getDouble("num10") - rule.getDouble("num9"));
                yt3 = rule.getDouble("num20") * (d - rule.getDouble("num12"));
//                OrderTaxi.setLongDistance(new BigDecimal((d > rule.getDouble("num12")) ? d - rule.getDouble("num12") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            }
//            amount = rule.getDouble("num15") + (d1 * rule.getDouble("num16")) + (t1 * rule.getDouble("num17")) + (w1 * waitMoney) + yt1 + yt2 + yt3;
            OrderTaxi.setStartMileage(rule.getDouble("num2"));
            OrderTaxi.setStartMoney(rule.getDouble("num15"));//起步价
            OrderTaxi.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            OrderTaxi.setMileageMoney(new BigDecimal(d1 * rule.getDouble("num16")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//里程费
            OrderTaxi.setDuration(new BigDecimal(t1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            OrderTaxi.setDurationMoney(new BigDecimal(t1 * rule.getDouble("num17")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//时长费
            OrderTaxi.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            OrderTaxi.setWaitMoney(new BigDecimal(w1 * waitMoney).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//等待费
//            OrderTaxi.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            OrderTaxi.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
            OrderTaxi.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//远途费
            OrderTaxi.setParkMoney(Objects.isNull(parkingFee)?0D:parkingFee);//停车费
            OrderTaxi.setRoadTollMoney(Objects.isNull(crossingFee)?0D:crossingFee);//过路费
            OrderTaxi.setRedPacketMoney(0D);//红包抵扣
            OrderTaxi.setCouponMoney(0D);//优惠券抵扣
            OrderTaxi.setDiscount(0D);//优惠抵扣
            OrderTaxi.setPayMoney(0D);//支付金额
            amount = OrderTaxi.getStartMoney() + OrderTaxi.getMileageMoney() +
                    OrderTaxi.getDurationMoney() + OrderTaxi.getWaitMoney() + OrderTaxi.getLongDistanceMoney();
            OrderTaxi.setOrderMoney(amount+OrderTaxi.getParkMoney()+OrderTaxi.getRoadTollMoney());
        }else{
            Calendar s1 = Calendar.getInstance();
            s1.setTime(date);
            s1.set(Calendar.HOUR_OF_DAY, Integer.valueOf(rule.getString("num21").split(" - ")[0].split(":")[0]));
            s1.set(Calendar.MINUTE, Integer.valueOf(rule.getString("num21").split(" - ")[0].split(":")[1]));
            Calendar e1 = Calendar.getInstance();
            e1.setTime(date);
            e1.set(Calendar.HOUR_OF_DAY, Integer.valueOf(rule.getString("num21").split(" - ")[1].split(":")[0]));
            e1.set(Calendar.MINUTE, Integer.valueOf(rule.getString("num21").split(" - ")[1].split(":")[1]));
            Calendar s2 = Calendar.getInstance();
            s2.setTime(date);
            s2.set(Calendar.HOUR_OF_DAY, Integer.valueOf(rule.getString("num22").split(" - ")[0].split(":")[0]));
            s2.set(Calendar.MINUTE, Integer.valueOf(rule.getString("num22").split(" - ")[0].split(":")[1]));
            Calendar e2 = Calendar.getInstance();
            e2.setTime(date);
            e2.set(Calendar.HOUR_OF_DAY, Integer.valueOf(rule.getString("num22").split(" - ")[1].split(":")[0]));
            e2.set(Calendar.MINUTE, Integer.valueOf(rule.getString("num22").split(" - ")[1].split(":")[1]));
            //高峰时段处理逻辑
            if((date.getTime() > s1.getTimeInMillis() && date.getTime() < e1.getTimeInMillis()) || (date.getTime() > s2.getTimeInMillis() && date.getTime() < e2.getTimeInMillis())){
                if(d > rule.getDouble("num6") && d < rule.getDouble("num7")){
                    yt1 = rule.getDouble("num26") * d;
//                    OrderTaxi.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                }
                if(d >  rule.getDouble("num9") && d < rule.getDouble("num10")){
                    yt1 = rule.getDouble("num26") * rule.getDouble("num7");
                    yt2 = rule.getDouble("num27") * (d - rule.getDouble("num9"));
//                    OrderTaxi.setLongDistance(new BigDecimal((d > rule.getDouble("num9")) ? d - rule.getDouble("num9") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                }
                if(d > rule.getDouble("num12")){
                    yt1 = rule.getDouble("num26") * rule.getDouble("num7");
                    yt2 = rule.getDouble("num27") * (rule.getDouble("num10") - rule.getDouble("num9"));
                    yt3 = rule.getDouble("num28") * (d - rule.getDouble("num12"));
//                    OrderTaxi.setLongDistance(new BigDecimal((d > rule.getDouble("num12")) ? d - rule.getDouble("num12") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                }
//                amount = rule.getDouble("num23") + (d1 * rule.getDouble("num24")) + (t1 * rule.getDouble("num25")) + (w1 * waitMoney) + yt1 + yt2 + yt3;
                OrderTaxi.setStartMileage(rule.getDouble("num2"));
                OrderTaxi.setStartMoney(rule.getDouble("num23"));//起步价
                OrderTaxi.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                OrderTaxi.setMileageMoney(new BigDecimal(d1 * rule.getDouble("num24")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//里程费
                OrderTaxi.setDuration(new BigDecimal(t1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                OrderTaxi.setDurationMoney(new BigDecimal(t1 * rule.getDouble("num25")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//时长费
                OrderTaxi.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                OrderTaxi.setWaitMoney(new BigDecimal(w1 * waitMoney).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//等待费
//                OrderTaxi.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                OrderTaxi.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                OrderTaxi.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//远途费
                OrderTaxi.setParkMoney(Objects.isNull(parkingFee)?0D:parkingFee);//停车费
                OrderTaxi.setRoadTollMoney(Objects.isNull(crossingFee)?0D:crossingFee);//过路费
                OrderTaxi.setRedPacketMoney(0D);//红包抵扣
                OrderTaxi.setCouponMoney(0D);//优惠券抵扣
                OrderTaxi.setDiscount(0D);//优惠抵扣
                OrderTaxi.setPayMoney(0D);//支付金额
//                amount = new BigDecimal(OrderTaxi.getStartMoney())
//                        .add(new BigDecimal(OrderTaxi.getMileageMoney()))
//                        .add(new BigDecimal(OrderTaxi.getDurationMoney()))
//                        .add(new BigDecimal(OrderTaxi.getWaitMoney()))
//                        .add(new BigDecimal(OrderTaxi.getLongDistanceMoney()));
//                OrderTaxi.setOrderMoney(amount.add(new BigDecimal(parkingFee)).add(new BigDecimal(parkingFee)).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());
                amount = OrderTaxi.getStartMoney() + OrderTaxi.getMileageMoney() +
                        OrderTaxi.getDurationMoney() + OrderTaxi.getWaitMoney() + OrderTaxi.getLongDistanceMoney();
                OrderTaxi.setOrderMoney(amount+OrderTaxi.getParkMoney()+OrderTaxi.getRoadTollMoney());
            }else{
                //其他时间段的计算
                if(d > rule.getDouble("num6") && d < rule.getDouble("num7")){
                    yt1 = rule.getDouble("num8") * d;
//                    OrderTaxi.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                }
                if(d >  rule.getDouble("num9") && d < rule.getDouble("num10")){
                    yt1 = rule.getDouble("num8") * rule.getDouble("num7");
                    yt2 = rule.getDouble("num11") * (d - rule.getDouble("num9"));
//                    OrderTaxi.setLongDistance(new BigDecimal((d > rule.getDouble("num9")) ? d - rule.getDouble("num9") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                }
                if(d > rule.getDouble("num12")){
                    yt1 = rule.getDouble("num8") * rule.getDouble("num7");
                    yt2 = rule.getDouble("num11") * (rule.getDouble("num10") - rule.getDouble("num9"));
                    yt3 = rule.getDouble("num13") * (d - rule.getDouble("num12"));
//                    OrderTaxi.setLongDistance(new BigDecimal((d > rule.getDouble("num12")) ? d - rule.getDouble("num12") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                }
//                amount = rule.getDouble("num1") + (d1 * rule.getDouble("num4")) + (t1 * rule.getDouble("num5")) + (w1 * waitMoney) + yt1 + yt2 + yt3;
                OrderTaxi.setStartMileage(rule.getDouble("num2"));
                OrderTaxi.setStartMoney(rule.getDouble("num1"));//起步价
                OrderTaxi.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                OrderTaxi.setMileageMoney(new BigDecimal(d1 * rule.getDouble("num4")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//里程费
                OrderTaxi.setDuration(new BigDecimal(t1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                OrderTaxi.setDurationMoney(new BigDecimal(t1 * rule.getDouble("num5")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//时长费
                OrderTaxi.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                OrderTaxi.setWaitMoney(new BigDecimal(w1 * waitMoney).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//等待费
//                OrderTaxi.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                OrderTaxi.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                OrderTaxi.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//远途费
                OrderTaxi.setParkMoney(Objects.isNull(parkingFee)?0D:parkingFee);//停车费
                OrderTaxi.setRoadTollMoney(Objects.isNull(crossingFee)?0D:crossingFee);//过路费
                OrderTaxi.setRedPacketMoney(0D);//红包抵扣
                OrderTaxi.setCouponMoney(0D);//优惠券抵扣
                OrderTaxi.setDiscount(0D);//优惠抵扣
                OrderTaxi.setPayMoney(0D);//支付金额
                amount = OrderTaxi.getStartMoney() + OrderTaxi.getMileageMoney() +
                        OrderTaxi.getDurationMoney() + OrderTaxi.getWaitMoney() + OrderTaxi.getLongDistanceMoney();
                OrderTaxi.setOrderMoney(amount+OrderTaxi.getParkMoney()+OrderTaxi.getRoadTollMoney());
            }
        }
        return OrderTaxi;
    }
    /**
     * 计算费用
     * @param orderTaxi