From 39e9e0600ed31ee6eff5c3b1287c36c7b7196b90 Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期四, 14 八月 2025 19:11:04 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/QianYunTong --- DriverQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java | 322 +++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 226 insertions(+), 96 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 eca95fe..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 @@ -12,9 +12,13 @@ import com.stylefeng.guns.modular.system.dao.CarServiceMapper; 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.qianyuntong.OrderUtil; +import com.stylefeng.guns.modular.system.util.qianyuntong.model.CreateTravelItineraryRequest; +import com.stylefeng.guns.modular.system.util.qianyuntong.model.ModifyTravelItineraryRequest; import com.stylefeng.guns.modular.taxi.model.OrderTaxi; import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; import org.springframework.beans.factory.annotation.Autowired; @@ -35,6 +39,9 @@ @Resource private SystemPriceMapper systemPriceMapper; + + @Autowired + private ISystemPriceCityService systemPriceCityService; @Autowired private IDriverService driverService; @@ -89,11 +96,23 @@ @Resource private CarServiceMapper carServiceMapper; + + @Resource + private UserInfoMapper userInfoMapper; + + + @Autowired + private TDriverPromotionActivityService driverPromotionActivityService; @Resource private RedisTemplate<String, Object> redisTemplate; - - + + + + @Resource + private IOpenCityService openCityService; + + /** * 获取司机端首页订单列表 * @@ -141,7 +160,7 @@ * @throws Exception */ @Override - public synchronized ResultUtil grabOrder(Integer orderId, Integer uid) throws Exception { + public ResultUtil grabOrder(Integer orderId, Integer uid) throws Exception { OrderPrivateCar orderPrivateCar = this.selectById(orderId); if(null == orderPrivateCar){ return ResultUtil.error("订单已被抢了"); @@ -215,17 +234,63 @@ orderPrivateCar.setSnatchOrderTime(new Date()); //调用高德创建轨迹 - String s = gdFalconUtil.selectTerminal(driver.getPhone()); - String track = gdFalconUtil.createTrack(s); - orderPrivateCar.setTrackId(track); +// String s = gdFalconUtil.selectTerminal(driver.getPhone()); +// String track = gdFalconUtil.createTrack(s); +// orderPrivateCar.setTrackId(track); //调用移动的小号接口 - Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderPrivateCar.getPassengersPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000)); - if(String.valueOf(map.get("code")).equals("200")){ - orderPrivateCar.setTelX(map.get("telX")); - orderPrivateCar.setBindId(map.get("bindId")); - } +// Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderPrivateCar.getPassengersPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000)); +// if(String.valueOf(map.get("code")).equals("200")){ +// orderPrivateCar.setTelX(map.get("telX")); +// orderPrivateCar.setBindId(map.get("bindId")); +// } + + + // 是否推广订单 + Integer promotion = isPromotion(orderPrivateCar.getUserId()); + if(null != promotion){ + orderPrivateCar.setPromotion(2); + Driver driver1 = driverService.selectById(promotion); + orderPrivateCar.setPromotionUser(driver1.getName()); + orderPrivateCar.setPromotionPhone(driver1.getPhone()); + orderPrivateCar.setPromotionDriverId(promotion); + }else{ + orderPrivateCar.setPromotion(1); + } + + if(null == oldDriverId){ + UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId()); + Company company = companyService.selectById(driver.getCompanyId()); + //调三方订单中心创建行程单 + CreateTravelItineraryRequest request = new CreateTravelItineraryRequest(); + request.setOrderNo("PR" + orderPrivateCar.getId()); + request.setCustomerId(userInfo.getOnconUUID()); + request.setDriverId(driver.getEmpId().toString()); + request.setSupplierShopId(company.getEnterCode()); + if(2 == orderPrivateCar.getPromotion()){ + Driver driver1 = driverService.selectById(orderPrivateCar.getPromotionDriverId()); + request.setPromoterId(driver1.getEmpId().toString()); + } + request.setServiceType(2); + String travelItinerary = OrderUtil.createTravelItinerary(request); + 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()); + } + request1.setSupplierShopId(company1.getEnterCode()); + OrderUtil.modifyTravelItinerary(request1); + } + this.updateById(orderPrivateCar); //处理摆渡车的情况 @@ -293,23 +358,35 @@ systemNoticeService.addSystemNotice(2, "您已成功抢得快车订单,请及时联系客户!", orderPrivateCar.getDriverId(), 1); systemNoticeService.addSystemNotice(1, "您的订单已指派给" + driver.getName().substring(0, 1) + "师傅,请保持电话畅通!", orderPrivateCar.getUserId(), 1); - - new Thread(new Runnable() { - @Override - public void run() { - if(pushMinistryOfTransport){ + + if(pushMinistryOfTransport){ + new Thread(new Runnable() { + @Override + public void run() { //上传数据 pushMinistryOfTransportUtil.orderCreate(orderId); pushMinistryOfTransportUtil.orderMatch(orderId); } - } - }).start(); - + }).start(); + } + + return ResultUtil.success(orderPrivateCar.getId()); } + private Integer isPromotion(Integer userId){ + 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 now() between startTime and endTime AND FIND_IN_SET(" + 1 + ", bizType) limit 1")); + if(tDriverPromotionActivity!=null){ + return userInfo.getBindDriverId(); + } + } + return null; + } /** * 获取订单详情页(服务中的页面) * @param orderId @@ -331,7 +408,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); @@ -346,7 +423,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); @@ -380,7 +457,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); @@ -400,7 +477,9 @@ map.put("emergencyCall", "110"); map.put("orders", JSON.toJSONString(orders)); return map;*/ - Map<String,Object> map = orderPrivateCarMapper.queryOrderInfo2(orderId); + OrderPrivateCar orderPrivateCar1 = orderPrivateCarMapper.selectById(orderId); + OpenCity openCity = openCityService.openCity1(orderPrivateCar1.getStartLon().toString(), orderPrivateCar1.getStartLat().toString()); + Map<String,Object> map = orderPrivateCarMapper.queryOrderInfo2(orderId, openCity.getId()); OrderPrivateCar orderPrivateCar = this.baseMapper.selectById(orderId); Integer canOperation=1; if(orderPrivateCar.getState()<5){ @@ -490,6 +569,20 @@ break; } 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()); + } + request.setSupplierShopId(company.getEnterCode()); + OrderUtil.modifyTravelItinerary(request); // TODO: 2020/6/5 推送状态 OrderPrivateCar finalOrderPrivateCar = orderPrivateCar; @@ -557,20 +650,33 @@ orderPrivateCar.setOrderMoney(orderPrivateCar.getOrderMoney() + orderPrivateCar.getParkMoney() + orderPrivateCar.getRoadTollMoney()); orderPrivateCar.setState(7); 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()); + } + request.setSupplierShopId(company.getEnterCode()); + OrderUtil.modifyTravelItinerary(request); + pushUtil.removeTask(orderId, 1);//删除定时任务,结束推送数据 systemNoticeService.addSystemNotice(1, "司机已结束本次行程,谢谢使用", orderPrivateCar.getUserId(), 1); //回滚司机状态为空闲 if(orderPrivateCar.getSpellSuccess()==0){ - Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); driver.setState(2); driverService.updateById(driver); }else{ if(orderPrivateCar.getPid()==null){ Integer number = this.selectCount(new EntityWrapper<OrderPrivateCar>().eq("pid",orderPrivateCar.getPid()==null?orderPrivateCar.getId():orderPrivateCar.getPid()).lt("state",6)); if(number<=0){ - Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); driver.setState(2); driverService.updateById(driver); } @@ -578,7 +684,6 @@ Integer number = this.selectCount(new EntityWrapper<OrderPrivateCar>().eq("pid",orderPrivateCar.getPid()==null?orderPrivateCar.getId():orderPrivateCar.getPid()).lt("state",6)); Integer number1 = this.selectCount(new EntityWrapper<OrderPrivateCar>().eq("id",orderPrivateCar.getPid()).lt("state",6)); if(number<=0 && number1<=0){ - Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); driver.setState(2); driverService.updateById(driver); } @@ -739,13 +844,53 @@ orderPrivateCar.setOrderMoney(orderPrivateCar.getOrderMoney() + orderPrivateCar.getParkMoney() + orderPrivateCar.getRoadTollMoney() + orderPrivateCar.getHolidayFee() + t); orderPrivateCar.setState(7); 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()); + } + 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 driver = driverService.selectById(orderPrivateCar.getDriverId()); - driver.setState(2); driverService.updateById(driver); OrderPrivateCar finalOrderTaxi = orderPrivateCar; @@ -788,7 +933,7 @@ } Map<String, Object> map = new HashMap<>(); - map.put("orderMoney", new BigDecimal(orderPrivateCar.getOrderMoney()).setScale(2,BigDecimal.ROUND_DOWN));//订单金额 + map.put("orderMoney", orderPrivateCar.getOrderMoney()==null?0:new BigDecimal(orderPrivateCar.getOrderMoney()).setScale(2,BigDecimal.ROUND_DOWN));//订单金额 map.put("startMileage", orderPrivateCar.getStartMileage());//起步价 map.put("startMoney", orderPrivateCar.getStartMoney());//起步价 map.put("mileageKilometers", orderPrivateCar.getMileageKilometers());//里程费 @@ -935,7 +1080,9 @@ * @throws Exception */ public OrderPrivateCar setMoney(OrderPrivateCar orderPrivateCar, Double parkingFee, Double crossingFee) throws Exception { - Map<String, Object> query1 = systemPriceMapper.query(orderPrivateCar.getCompanyId(), 1, orderPrivateCar.getServerCarModelId()); + Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderPrivateCar.getStartLon().toString(), orderPrivateCar.getStartLat().toString()); + SystemPriceCity systemPriceCity = systemPriceCityService.queryOne(geocode.get("provinceCode"), geocode.get("cityCode"), geocode.get("districtCode")); + Map<String, Object> query1 = systemPriceMapper.query(systemPriceCity.getId(), 1, orderPrivateCar.getServerCarModelId()); //开始根据不同的方式计算金额 double amount = 0; JSONObject jsonObject = JSON.parseObject(String.valueOf(query1.get("content"))); @@ -951,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()); @@ -969,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); @@ -982,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()); @@ -993,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; @@ -1052,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()); @@ -1078,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);//停车费 @@ -1091,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])); @@ -1100,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])); @@ -1110,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()); @@ -1136,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);//停车费 @@ -1145,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()); @@ -1158,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()); @@ -1180,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);//停车费 @@ -1228,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()); @@ -1255,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);//停车费 @@ -1268,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])); @@ -1278,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])); @@ -1288,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()); @@ -1315,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);//停车费 @@ -1332,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()); @@ -1354,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