From 1c40baaf9ca0183945b9881d11ceed5aeebc8290 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 23 十月 2025 11:35:44 +0800
Subject: [PATCH] 修改bug
---
DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java | 310 ++++++++++++++++++++++++++++-----------------------
1 files changed, 170 insertions(+), 140 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 a8c056e..551de07 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
@@ -15,7 +15,6 @@
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.service.impl.OpenCityServiceImpl;
import com.stylefeng.guns.modular.system.util.*;
import com.stylefeng.guns.modular.system.util.qianyuntong.OrderUtil;
import com.stylefeng.guns.modular.system.util.qianyuntong.model.CreateTravelItineraryRequest;
@@ -233,7 +232,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);
@@ -249,7 +247,7 @@
// 是否推广订单
- Integer promotion = isPromotion(orderPrivateCar.getUserId());
+ Integer promotion = isPromotion(orderPrivateCar.getUserId(), driver.getPlaceOfEmployment());
if(null != promotion){
orderPrivateCar.setPromotion(2);
Driver driver1 = driverService.selectById(promotion);
@@ -278,18 +276,20 @@
orderPrivateCar.setTravelId(travelItinerary);
}else{
//改派抢单
- Company company1 = companyService.selectById(driver.getCompanyId());
- //中台修改订单状态
- ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest();
- request1.setOrderId(orderPrivateCar.getTravelId());
- request1.setStatus(orderPrivateCar.getState());
- request1.setDriverId(driver.getEmpId().toString());
- if(2 == orderPrivateCar.getPromotion()){
- Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId());
- request1.setPromoterId(driver1.getEmpId().toString());
+ if(ToolUtil.isNotEmpty(orderPrivateCar.getTravelId())){
+ Company company1 = companyService.selectById(driver.getCompanyId());
+ //中台修改订单状态
+ ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest();
+ request1.setOrderId(orderPrivateCar.getTravelId());
+ request1.setStatus(orderPrivateCar.getState());
+ request1.setDriverId(driver.getEmpId().toString());
+ if(2 == orderPrivateCar.getPromotion()){
+ Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId());
+ request1.setPromoterId(driver1.getEmpId().toString());
+ }
+ request1.setSupplierShopId(company1.getEnterCode());
+ OrderUtil.modifyTravelItinerary(request1);
}
- request1.setSupplierShopId(company1.getEnterCode());
- OrderUtil.modifyTravelItinerary(request1);
}
this.updateById(orderPrivateCar);
@@ -376,11 +376,11 @@
}
- private Integer isPromotion(Integer userId){
+ private Integer isPromotion(Integer userId, String code){
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).ge("startTime", new Date()).lt("endTime", new Date()).last("AND FIND_IN_SET(" + 1 + ", bizType) limit 1"));
+ if(userInfo.getBindDriverId()!=null && userInfo.getBindExpireDate().getTime()>System.currentTimeMillis()){
+ TDriverPromotionActivity tDriverPromotionActivity = driverPromotionActivityService.selectOne(new EntityWrapper<TDriverPromotionActivity>().eq("state",1)
+ .eq("districtCode", code).last(" and now() between startTime and endTime AND FIND_IN_SET(" + 1 + ", bizType) limit 1"));
if(tDriverPromotionActivity!=null){
return userInfo.getBindDriverId();
}
@@ -409,7 +409,7 @@
if(order!=null){
orders.addAll(order);
}
- String value = (String) redisTemplate.opsForValue().get("DRIVER" + String.valueOf(orderPrivateCar.getDriverId()));
+ String value = (String) redisTemplate.opsForValue().get("dache:DRIVER" + String.valueOf(orderPrivateCar.getDriverId()));
order = this.baseMapper.queryOrderInfo(orderId,5,value.split(",")[0],value.split(",")[1]);
if(order!=null){
orders.addAll(order);
@@ -424,7 +424,7 @@
if(order!=null){
orders.addAll(order);
}
- String value = (String) redisTemplate.opsForValue().get("DRIVER" + String.valueOf(orderPrivateCar.getDriverId()));
+ String value = (String) redisTemplate.opsForValue().get("dache:DRIVER" + String.valueOf(orderPrivateCar.getDriverId()));
order = this.baseMapper.queryOrderInfo(orderPrivateCar.getPid(),5,value.split(",")[0],value.split(",")[1]);
if(order!=null){
orders.addAll(order);
@@ -458,7 +458,7 @@
orders.addAll(order);
}
OrderPrivateCar orderPrivateCar = this.baseMapper.selectById(orderId);
- String value = redisUtil.getValue("DRIVER" + String.valueOf(orderPrivateCar.getDriverId()));
+ String value = redisUtil.getValue("dache:DRIVER" + String.valueOf(orderPrivateCar.getDriverId()));
order = this.baseMapper.queryOrderInfo(orderId,5,value.split(",")[0],value.split(",")[1]);
if(order!=null){
orders.addAll(order);
@@ -483,23 +483,23 @@
Map<String,Object> map = orderPrivateCarMapper.queryOrderInfo2(orderId, openCity.getId());
OrderPrivateCar orderPrivateCar = this.baseMapper.selectById(orderId);
Integer canOperation=1;
- if(orderPrivateCar.getState()<5){
- if(orderPrivateCar.getPid()==null) {
- List<Map<String, Object>> order = this.baseMapper.queryOrderInfo(orderId, 4, null, null);
- if (order != null && order.size()>0) {
- if(!order.get(0).get("orderId").equals(orderId)){
- canOperation=0;
- }
- }
- }else {
- List<Map<String, Object>> order = this.baseMapper.queryOrderInfo(orderPrivateCar.getPid(),4,null,null);
- if(order!=null && order.size()>0){
- if(!order.get(0).get("orderId").equals(orderId)){
- canOperation=0;
- }
- }
- }
- }
+// if(orderPrivateCar.getState()<5){
+// if(orderPrivateCar.getPid()==null) {
+// List<Map<String, Object>> order = this.baseMapper.queryOrderInfo(orderId, 4, null, null);
+// if (order != null && order.size()>0) {
+// if(!order.get(0).get("orderId").equals(orderId)){
+// canOperation=0;
+// }
+// }
+// }else {
+// List<Map<String, Object>> order = this.baseMapper.queryOrderInfo(orderPrivateCar.getPid(),4,null,null);
+// if(order!=null && order.size()>0){
+// if(!order.get(0).get("orderId").equals(orderId)){
+// canOperation=0;
+// }
+// }
+// }
+// }
map.put("canOperation",canOperation);
System.out.println(map);
String phone = map.get("phone").toString();
@@ -518,6 +518,9 @@
@Override
public ResultUtil process(Integer orderId, Integer state, Double lon, Double lat, String address) throws Exception {
OrderPrivateCar orderPrivateCar = this.selectById(orderId);
+ if(10 == orderPrivateCar.getState()){
+ return ResultUtil.error("订单已被取消,不能继续操作");
+ }
Integer canOperation=1;
if(state<5){
if(orderPrivateCar.getPid()==null) {
@@ -571,19 +574,21 @@
}
this.updateById(orderPrivateCar);
- Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
- Company company = companyService.selectById(driver.getCompanyId());
- //中台修改订单状态
- ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest();
- request.setOrderId(orderPrivateCar.getTravelId());
- request.setStatus(orderPrivateCar.getState());
- request.setDriverId(driver.getEmpId().toString());
- if(2 == orderPrivateCar.getPromotion()){
- Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId());
- request.setPromoterId(driver1.getEmpId().toString());
+ if(ToolUtil.isNotEmpty(orderPrivateCar.getTravelId())){
+ Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
+ Company company = companyService.selectById(driver.getCompanyId());
+ //中台修改订单状态
+ ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest();
+ request.setOrderId(orderPrivateCar.getTravelId());
+ request.setStatus(orderPrivateCar.getState());
+ request.setDriverId(driver.getEmpId().toString());
+ if(2 == orderPrivateCar.getPromotion()){
+ Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId());
+ request.setPromoterId(driver1.getEmpId().toString());
+ }
+ request.setSupplierShopId(company.getEnterCode());
+ OrderUtil.modifyTravelItinerary(request);
}
- request.setSupplierShopId(company.getEnterCode());
- OrderUtil.modifyTravelItinerary(request);
// TODO: 2020/6/5 推送状态
OrderPrivateCar finalOrderPrivateCar = orderPrivateCar;
@@ -653,18 +658,20 @@
this.updateById(orderPrivateCar);
Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
- Company company = companyService.selectById(driver.getCompanyId());
- //中台修改订单状态
- ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest();
- request.setOrderId(orderPrivateCar.getTravelId());
- request.setStatus(7);
- request.setDriverId(driver.getEmpId().toString());
- if(2 == orderPrivateCar.getPromotion()){
- Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId());
- request.setPromoterId(driver1.getEmpId().toString());
+ if(ToolUtil.isNotEmpty(orderPrivateCar.getTravelId())){
+ Company company = companyService.selectById(driver.getCompanyId());
+ //中台修改订单状态
+ ModifyTravelItineraryRequest request = new ModifyTravelItineraryRequest();
+ request.setOrderId(orderPrivateCar.getTravelId());
+ request.setStatus(7);
+ request.setDriverId(driver.getEmpId().toString());
+ if(2 == orderPrivateCar.getPromotion()){
+ Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId());
+ request.setPromoterId(driver1.getEmpId().toString());
+ }
+ request.setSupplierShopId(company.getEnterCode());
+ OrderUtil.modifyTravelItinerary(request);
}
- request.setSupplierShopId(company.getEnterCode());
- OrderUtil.modifyTravelItinerary(request);
pushUtil.removeTask(orderId, 1);//删除定时任务,结束推送数据
@@ -833,6 +840,9 @@
JSONObject jsonObject = jsonArray.getJSONObject(i);
Integer id = jsonObject.getInteger("id");
Double amount = jsonObject.getDouble("amount");
+ if(amount == 0){
+ continue;
+ }
OrderAdditionalFee orderAdditionalFee = new OrderAdditionalFee();
orderAdditionalFee.setOrderType(1);
orderAdditionalFee.setOrderId(orderId);
@@ -847,24 +857,53 @@
this.updateById(orderPrivateCar);
Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
- Company company1 = companyService.selectById(driver.getCompanyId());
- //中台修改订单状态
- ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest();
- request1.setOrderId(orderPrivateCar.getTravelId());
- request1.setStatus(orderPrivateCar.getState());
- request1.setDriverId(driver.getEmpId().toString());
- if(2 == orderPrivateCar.getPromotion()){
- Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId());
- request1.setPromoterId(driver1.getEmpId().toString());
+ if(ToolUtil.isNotEmpty(orderPrivateCar.getTravelId())){
+ Company company1 = companyService.selectById(driver.getCompanyId());
+ //中台修改订单状态
+ ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest();
+ request1.setOrderId(orderPrivateCar.getTravelId());
+ request1.setStatus(orderPrivateCar.getState());
+ request1.setDriverId(driver.getEmpId().toString());
+ if(2 == orderPrivateCar.getPromotion()){
+ Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId());
+ request1.setPromoterId(driver1.getEmpId().toString());
+ }
+ request1.setSupplierShopId(company1.getEnterCode());
+ OrderUtil.modifyTravelItinerary(request1);
}
- request1.setSupplierShopId(company1.getEnterCode());
- OrderUtil.modifyTravelItinerary(request1);
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;
@@ -907,7 +946,15 @@
}
Map<String, Object> map = new HashMap<>();
- map.put("orderMoney", orderPrivateCar.getOrderMoney()==null?0:new BigDecimal(orderPrivateCar.getOrderMoney()).setScale(2,BigDecimal.ROUND_DOWN));//订单金额
+ if(orderPrivateCar.getState() == 5){
+ map.put("orderMoney", orderPrivateCar.getOrderMoney()==null?0:orderPrivateCar.getOrderMoney());//订单金额
+ }else{
+ if(orderPrivateCar.getAbnormal() == 2 && orderPrivateCar.getResponsibilityType() > 2 && orderPrivateCar.getAbnormalStatus() == 2){
+ map.put("orderMoney", orderPrivateCar.getResponsibilityMoney());
+ }else{
+ map.put("orderMoney", orderPrivateCar.getOrderMoney()==null?0:orderPrivateCar.getOrderMoney());//订单金额
+ }
+ }
map.put("startMileage", orderPrivateCar.getStartMileage());//起步价
map.put("startMoney", orderPrivateCar.getStartMoney());//起步价
map.put("mileageKilometers", orderPrivateCar.getMileageKilometers());//里程费
@@ -1072,9 +1119,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());
@@ -1090,7 +1139,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);
@@ -1103,6 +1154,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());
@@ -1114,38 +1166,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;
@@ -1173,24 +1209,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());
@@ -1199,7 +1237,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);//停车费
@@ -1212,6 +1249,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]));
@@ -1221,7 +1259,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]));
@@ -1231,24 +1274,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());
@@ -1257,7 +1301,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);//停车费
@@ -1266,12 +1309,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());
@@ -1279,20 +1316,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());
@@ -1301,7 +1334,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);//停车费
@@ -1349,25 +1381,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());
@@ -1376,7 +1407,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);//停车费
@@ -1389,7 +1419,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]));
@@ -1399,7 +1430,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]));
@@ -1409,25 +1445,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());
@@ -1436,7 +1472,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);//停车费
@@ -1453,20 +1488,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());
@@ -1475,7 +1506,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