From 388d1eb5f87c50ede6b415950899fe8bb938ee28 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 15 八月 2025 15:05:41 +0800 Subject: [PATCH] 修改bug --- DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java | 146 ++++++++++++++++++++++++++---------------------- 1 files changed, 78 insertions(+), 68 deletions(-) diff --git a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java index b714768..bb5d5fa 100644 --- a/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java +++ b/DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java @@ -379,7 +379,7 @@ UserInfo userInfo = userInfoMapper.selectById(userId); if(userInfo.getBindDriverId()!=null && userInfo.getBindExpireDate().getTime()>System.currentTimeMillis()){ String registAreaCode = userInfo.getRegistAreaCode(); - TDriverPromotionActivity tDriverPromotionActivity = driverPromotionActivityService.selectOne(new EntityWrapper<TDriverPromotionActivity>().eq("state",1).eq("districtCode", registAreaCode).last(" and between now() startTime and endTime AND FIND_IN_SET(" + 1 + ", bizType) limit 1")); + TDriverPromotionActivity tDriverPromotionActivity = driverPromotionActivityService.selectOne(new EntityWrapper<TDriverPromotionActivity>().eq("state",1).eq("districtCode", registAreaCode).last(" and now() between startTime and endTime AND FIND_IN_SET(" + 1 + ", bizType) limit 1")); if(tDriverPromotionActivity!=null){ return userInfo.getBindDriverId(); } @@ -862,8 +862,35 @@ pushUtil.removeTask(orderId, 1);//删除定时任务,结束推送数据 systemNoticeService.addSystemNotice(1, "司机已结束本次行程,谢谢使用", orderPrivateCar.getUserId(), 1); + //根据订单类型处理司机状态 + if(3 != orderPrivateCar.getRideType()){ + driver.setState(2); + }else{ + //拼单需要所有的订单结束才修改司机状态 + //未拼成 + if(0 == orderPrivateCar.getSpellSuccess()){ + driver.setState(2); + }else{ + Integer pid = orderPrivateCar.getPid(); + if(null == pid){ + //当前订单作为主订单查询所有子订单是否都完成 + int count = this.selectCount(new EntityWrapper<OrderPrivateCar>().eq("pid", orderPrivateCar.getId()) + .in("state", Arrays.asList(2, 3, 4, 5, 6, 11)).eq("isDelete", 1)); + if(0 == count){ + driver.setState(2); + } + }else{ + //查询所有子订单和主订单是都完成 + int count = this.selectCount(new EntityWrapper<OrderPrivateCar>().eq("pid", orderPrivateCar.getPid()) + .in("state", Arrays.asList(2, 3, 4, 5, 6, 11)).eq("isDelete", 1)); + OrderPrivateCar privateCar = this.selectById(orderPrivateCar.getPid()); + if(0 == count && !Arrays.asList(2, 3, 4, 5, 6, 11).contains(privateCar.getState())){ + driver.setState(2); + } + } + } + } //回滚司机状态为空闲 - driver.setState(2); driverService.updateById(driver); OrderPrivateCar finalOrderTaxi = orderPrivateCar; @@ -1071,9 +1098,11 @@ System.out.println("一口价内容"+contentPrice); //乘车类型(1=独享,2=一口价,3=拼车) orderPrivateCar.setWaitRule(jsonObject.toJSONString()); + //独享 if(orderPrivateCar.getRideType()==1){ orderPrivateCar = calculationPrice(orderPrivateCar,contentExclusive,jsonObject.getLongValue("num1"),jsonObject.getDouble("num2"),parkingFee,crossingFee); }else if(orderPrivateCar.getRideType()==2){ + //一口价 double d = (null == orderPrivateCar.getMileage() ? 0D : orderPrivateCar.getMileage()); System.out.println("行驶里程数"+d); double estimateMileage = (null == orderPrivateCar.getEstimateMileage() ? 0D : orderPrivateCar.getEstimateMileage()); @@ -1089,7 +1118,9 @@ System.out.println("返回订单数据"+orderPrivateCar); } }else{ + //拼车 //判断是否是拼单 + //未拼成 if(orderPrivateCar.getSpellSuccess()==0){ if(orderPrivateCar.getPeopleNum()==1){ orderPrivateCar = calculationPrice(orderPrivateCar,contentNotOne,jsonObject.getLongValue("num1"),jsonObject.getDouble("num2"),parkingFee,crossingFee); @@ -1102,6 +1133,7 @@ orderPrivateCar.setChargeRules(contentPutThree.toJSONString()); } }else{ + //已拼成 if(orderPrivateCar.getPeopleNum()==1){ orderPrivateCar = calculationPrice(orderPrivateCar,contentPutOne,jsonObject.getLongValue("num1"),jsonObject.getDouble("num2"),parkingFee,crossingFee); orderPrivateCar.setChargeRules(contentNotOne.toJSONString()); @@ -1113,38 +1145,22 @@ orderPrivateCar.setChargeRules(contentNotThree.toJSONString()); } } - /*if(orderPrivateCar.getPid()==null){ - Integer number = orderPrivateCarMapper.selectCount(new EntityWrapper<OrderPrivateCar>().eq("pid",orderPrivateCar.getId()).ne("state",10).ne("state",12)); - if(number<=0){ - if(orderPrivateCar.getPeopleNum()==1){ - orderPrivateCar = calculationPrice(orderPrivateCar,contentNotOne,jsonObject.getLongValue("num1"),jsonObject.getDouble("num2"),parkingFee,crossingFee); - }else if(orderPrivateCar.getPeopleNum()==2){ - orderPrivateCar = calculationPrice(orderPrivateCar,contentNotTwo,jsonObject.getLongValue("num1"),jsonObject.getDouble("num2"),parkingFee,crossingFee); - }else{ - orderPrivateCar = calculationPrice(orderPrivateCar,contentNotThree,jsonObject.getLongValue("num1"),jsonObject.getDouble("num2"),parkingFee,crossingFee); - } - }else{ - if(orderPrivateCar.getPeopleNum()==1){ - orderPrivateCar = calculationPrice(orderPrivateCar,contentPutOne,jsonObject.getLongValue("num1"),jsonObject.getDouble("num2"),parkingFee,crossingFee); - }else if(orderPrivateCar.getPeopleNum()==2){ - orderPrivateCar = calculationPrice(orderPrivateCar,contentPutTwo,jsonObject.getLongValue("num1"),jsonObject.getDouble("num2"),parkingFee,crossingFee); - }else{ - orderPrivateCar = calculationPrice(orderPrivateCar,contentPutThree,jsonObject.getLongValue("num1"),jsonObject.getDouble("num2"),parkingFee,crossingFee); - } - } - }else{ - if(orderPrivateCar.getPeopleNum()==1){ - orderPrivateCar = calculationPrice(orderPrivateCar,contentPutOne,jsonObject.getLongValue("num1"),jsonObject.getDouble("num2"),parkingFee,crossingFee); - }else if(orderPrivateCar.getPeopleNum()==2){ - orderPrivateCar = calculationPrice(orderPrivateCar,contentPutTwo,jsonObject.getLongValue("num1"),jsonObject.getDouble("num2"),parkingFee,crossingFee); - }else{ - orderPrivateCar = calculationPrice(orderPrivateCar,contentPutThree,jsonObject.getLongValue("num1"),jsonObject.getDouble("num2"),parkingFee,crossingFee); - } - }*/ } return orderPrivateCar; } + + /** + * 公共费用计算 + * @param orderPrivateCar + * @param rule 计费规则 + * @param wait 规则-等待时长 + * @param waitMoney 规则-等待单价 + * @param parkingFee 停车费 + * @param crossingFee 过路费 + * @return + * @throws Exception + */ public OrderPrivateCar calculationPrice(OrderPrivateCar orderPrivateCar,JSONObject rule, long wait,Double waitMoney, Double parkingFee, Double crossingFee) throws Exception { orderPrivateCar.setChargeRule(rule.toJSONString()); double amount = 0.0; @@ -1172,24 +1188,26 @@ 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(s.getTimeInMillis() > e.getTimeInMillis()){ + e.add(Calendar.DAY_OF_YEAR, 1); + } if(date.getTime() > s.getTimeInMillis() && date.getTime() < e.getTimeInMillis()){ + //夜间范围内 + //远途费计算 if(d > rule.getDouble("num6") && d < rule.getDouble("num7")){ yt1 = rule.getDouble("num18") * d; -// orderPrivateCar.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")); -// orderPrivateCar.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")); -// orderPrivateCar.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; orderPrivateCar.setStartMileage(rule.getDouble("num2")); orderPrivateCar.setStartMoney(rule.getDouble("num15"));//起步价 orderPrivateCar.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); @@ -1198,7 +1216,6 @@ orderPrivateCar.setDurationMoney(new BigDecimal(t1 * rule.getDouble("num17")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//时长费 orderPrivateCar.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setWaitMoney(new BigDecimal(w1 * waitMoney).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//等待费 -// orderPrivateCar.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//远途费 orderPrivateCar.setParkMoney(parkingFee);//停车费 @@ -1211,6 +1228,7 @@ orderPrivateCar.getDurationMoney() + orderPrivateCar.getWaitMoney() + orderPrivateCar.getLongDistanceMoney(); orderPrivateCar.setOrderMoney(amount+orderPrivateCar.getParkMoney()+orderPrivateCar.getRoadTollMoney()); }else{ + //第一个高峰段 Calendar s1 = Calendar.getInstance(); s1.setTime(date); s1.set(Calendar.HOUR_OF_DAY, Integer.valueOf(rule.getString("num21").split(" - ")[0].split(":")[0])); @@ -1220,7 +1238,12 @@ 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])); + //跨天处理 + if(s1.getTimeInMillis() > e1.getTimeInMillis()){ + e1.add(Calendar.DAY_OF_YEAR, 1); + } + //第二个高峰段 Calendar s2 = Calendar.getInstance(); s2.setTime(date); s2.set(Calendar.HOUR_OF_DAY, Integer.valueOf(rule.getString("num22").split(" - ")[0].split(":")[0])); @@ -1230,24 +1253,25 @@ 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(s2.getTimeInMillis() > e2.getTimeInMillis()){ + e2.add(Calendar.DAY_OF_YEAR, 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; -// orderPrivateCar.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")); -// orderPrivateCar.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")); -// orderPrivateCar.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; orderPrivateCar.setStartMileage(rule.getDouble("num2")); orderPrivateCar.setStartMoney(rule.getDouble("num23"));//起步价 orderPrivateCar.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); @@ -1256,7 +1280,6 @@ orderPrivateCar.setDurationMoney(new BigDecimal(t1 * rule.getDouble("num25")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//时长费 orderPrivateCar.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setWaitMoney(new BigDecimal(w1 * waitMoney).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//等待费 -// orderPrivateCar.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//远途费 orderPrivateCar.setParkMoney(parkingFee);//停车费 @@ -1265,12 +1288,6 @@ orderPrivateCar.setCouponMoney(0D);//优惠券抵扣 orderPrivateCar.setDiscount(0D);//优惠抵扣 orderPrivateCar.setPayMoney(0D);//支付金额 -// amount = new BigDecimal(orderPrivateCar.getStartMoney()) -// .add(new BigDecimal(orderPrivateCar.getMileageMoney())) -// .add(new BigDecimal(orderPrivateCar.getDurationMoney())) -// .add(new BigDecimal(orderPrivateCar.getWaitMoney())) -// .add(new BigDecimal(orderPrivateCar.getLongDistanceMoney())); -// orderPrivateCar.setOrderMoney(amount.add(new BigDecimal(parkingFee)).add(new BigDecimal(parkingFee)).setScale(2, BigDecimal.ROUND_DOWN).doubleValue()); amount = orderPrivateCar.getStartMoney() + orderPrivateCar.getMileageMoney() + orderPrivateCar.getDurationMoney() + orderPrivateCar.getWaitMoney() + orderPrivateCar.getLongDistanceMoney(); orderPrivateCar.setOrderMoney(amount+orderPrivateCar.getParkMoney()+orderPrivateCar.getRoadTollMoney()); @@ -1278,20 +1295,16 @@ //其他时间段的计算 if(d > rule.getDouble("num6") && d < rule.getDouble("num7")){ yt1 = rule.getDouble("num8") * d; -// orderPrivateCar.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")); -// orderPrivateCar.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")); -// orderPrivateCar.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; orderPrivateCar.setStartMileage(rule.getDouble("num2")); orderPrivateCar.setStartMoney(rule.getDouble("num1"));//起步价 orderPrivateCar.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); @@ -1300,7 +1313,6 @@ orderPrivateCar.setDurationMoney(new BigDecimal(t1 * rule.getDouble("num5")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//时长费 orderPrivateCar.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setWaitMoney(new BigDecimal(w1 * waitMoney).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//等待费 -// orderPrivateCar.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//远途费 orderPrivateCar.setParkMoney(parkingFee);//停车费 @@ -1348,25 +1360,24 @@ 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(s.getTimeInMillis() > e.getTimeInMillis()){ + e.add(Calendar.DAY_OF_YEAR, 1); + } if(date.getTime() > s.getTimeInMillis() && date.getTime() < e.getTimeInMillis()){ - System.out.println("夜间服务处理逻辑"); if(d > rule.getDouble("num6") && d < rule.getDouble("num7")){ yt1 = rule.getDouble("num18") * d; -// orderPrivateCar.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")); -// orderPrivateCar.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")); -// orderPrivateCar.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; orderPrivateCar.setStartMileage(rule.getDouble("num2")); orderPrivateCar.setStartMoney(rule.getDouble("num15"));//起步价 orderPrivateCar.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); @@ -1375,7 +1386,6 @@ orderPrivateCar.setDurationMoney(new BigDecimal(t1 * rule.getDouble("num17")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//时长费 orderPrivateCar.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setWaitMoney(new BigDecimal(w1 * waitMoney).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//等待费 -// orderPrivateCar.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//远途费 orderPrivateCar.setParkMoney(parkingFee);//停车费 @@ -1388,7 +1398,8 @@ orderPrivateCar.getDurationMoney() + orderPrivateCar.getWaitMoney() + orderPrivateCar.getLongDistanceMoney(); orderPrivateCar.setOrderMoney(amount+orderPrivateCar.getParkMoney()+orderPrivateCar.getRoadTollMoney()); }else{ - System.out.println("非夜间服务处理逻辑"); + //非夜间处理逻辑 + //第一段高峰期 Calendar s1 = Calendar.getInstance(); s1.setTime(date); s1.set(Calendar.HOUR_OF_DAY, Integer.valueOf(rule.getString("num21").split(" - ")[0].split(":")[0])); @@ -1398,7 +1409,12 @@ 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])); + //跨天处理 + if(s1.getTimeInMillis() > e1.getTimeInMillis()){ + e1.add(Calendar.DAY_OF_YEAR, 1); + } + //第二段高峰期 Calendar s2 = Calendar.getInstance(); s2.setTime(date); s2.set(Calendar.HOUR_OF_DAY, Integer.valueOf(rule.getString("num22").split(" - ")[0].split(":")[0])); @@ -1408,25 +1424,25 @@ 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(s2.getTimeInMillis() > e2.getTimeInMillis()){ + e2.add(Calendar.DAY_OF_YEAR, 1); + } //高峰时段处理逻辑 if((date.getTime() > s1.getTimeInMillis() && date.getTime() < e1.getTimeInMillis()) || (date.getTime() > s2.getTimeInMillis() && date.getTime() < e2.getTimeInMillis())){ System.out.println("高峰时段处理逻辑"); if(d > rule.getDouble("num6") && d < rule.getDouble("num7")){ yt1 = rule.getDouble("num26") * d; -// orderPrivateCar.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")); -// orderPrivateCar.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")); -// orderPrivateCar.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; orderPrivateCar.setStartMileage(rule.getDouble("num2")); orderPrivateCar.setStartMoney(rule.getDouble("num23"));//起步价 orderPrivateCar.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); @@ -1435,7 +1451,6 @@ orderPrivateCar.setDurationMoney(new BigDecimal(t1 * rule.getDouble("num25")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//时长费 orderPrivateCar.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setWaitMoney(new BigDecimal(w1 * waitMoney).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//等待费 -// orderPrivateCar.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//远途费 orderPrivateCar.setParkMoney(parkingFee);//停车费 @@ -1452,20 +1467,16 @@ //其他时间段的计算 if(d > rule.getDouble("num6") && d < rule.getDouble("num7")){ yt1 = rule.getDouble("num8") * d; -// orderPrivateCar.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")); -// orderPrivateCar.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")); -// orderPrivateCar.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; orderPrivateCar.setStartMileage(rule.getDouble("num2")); orderPrivateCar.setStartMoney(rule.getDouble("num1"));//起步价 orderPrivateCar.setMileageKilometers(new BigDecimal(d1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); @@ -1474,7 +1485,6 @@ orderPrivateCar.setDurationMoney(new BigDecimal(t1 * rule.getDouble("num5")).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//时长费 orderPrivateCar.setWait(new BigDecimal(w1).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setWaitMoney(new BigDecimal(w1 * waitMoney).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//等待费 -// orderPrivateCar.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setLongDistance(new BigDecimal((d > rule.getDouble("num6")) ? d - rule.getDouble("num6") : 0).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); orderPrivateCar.setLongDistanceMoney(new BigDecimal(yt1 + yt2 + yt3).setScale(2, BigDecimal.ROUND_DOWN).doubleValue());//远途费 orderPrivateCar.setParkMoney(parkingFee);//停车费 -- Gitblit v1.7.1