| | |
| | | private SystemPriceMapper systemPriceMapper; |
| | | |
| | | @Autowired |
| | | private ISystemPriceCityService systemPriceCityService; |
| | | |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Resource |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private IOpenCityService openCityService; |
| | | |
| | | |
| | | /** |
| | | * 获取司机端首页订单列表 |
| | | * |
| | |
| | | |
| | | // 是否推广订单 |
| | | Integer promotion = isPromotion(orderPrivateCar.getUserId()); |
| | | if(promotion!=null){ |
| | | 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); |
| | | } |
| | | |
| | | orderPrivateCar.setPromotion(promotion); |
| | | |
| | | if(null == oldDriverId){ |
| | | UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId()); |
| | |
| | | |
| | | private Integer isPromotion(Integer userId){ |
| | | UserInfo userInfo = userInfoMapper.selectById(userId); |
| | | if(userInfo.getBindDriverId()!=null && userInfo.getBindExpireDate().getTime()<=System.currentTimeMillis()){ |
| | | if(userInfo.getBindDriverId()!=null && userInfo.getBindExpireDate().getTime()>System.currentTimeMillis()){ |
| | | String registAreaCode = userInfo.getRegistAreaCode(); |
| | | TDriverPromotionActivity tDriverPromotionActivity = driverPromotionActivityService.selectOne(new EntityWrapper<TDriverPromotionActivity>().eq("districtCode", registAreaCode).ge("startTime", new Date()).lt("endTime", new Date()).last("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 2; |
| | | return userInfo.getBindDriverId(); |
| | | } |
| | | } |
| | | return null; |
| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | 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){ |
| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | 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());//里程费 |
| | |
| | | * @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"))); |
| | |
| | | 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()); |
| | |
| | | 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); |
| | |
| | | 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()); |
| | |
| | | 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; |
| | |
| | | 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()); |
| | |
| | | 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);//停车费 |
| | |
| | | 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])); |
| | |
| | | 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])); |
| | |
| | | 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()); |
| | |
| | | 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);//停车费 |
| | |
| | | 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()); |
| | |
| | | //其他时间段的计算 |
| | | 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()); |
| | |
| | | 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);//停车费 |
| | |
| | | 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()); |
| | |
| | | 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);//停车费 |
| | |
| | | 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])); |
| | |
| | | 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])); |
| | |
| | | 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()); |
| | |
| | | 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);//停车费 |
| | |
| | | //其他时间段的计算 |
| | | 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()); |
| | |
| | | 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);//停车费 |