| | |
| | | } |
| | | |
| | | XpPricingCardVo xpPricingCardVo = new XpPricingCardVo(); |
| | | double amount = 0; |
| | | |
| | | double realDistance = distance / 1000;//实际公里 |
| | | double realTime = duration / 60;//实际时间 |
| | | double exceedDistance = (realDistance - rule.getDouble("num2")) < 0 ? 0 : realDistance - rule.getDouble("num2");//超出起步里程的公里 |
| | | double exceedTime = (realTime - rule.getDouble("num3")) < 0 ? 0 : realTime - rule.getDouble("num3");//超过起步分钟数的时间 |
| | | |
| | | // 起步价 |
| | | Double startPrice = rule.getDouble("num1"); |
| | | Double startPrice = rule.getDouble("num1") * priceRate; |
| | | |
| | | // 超出公里数价格 |
| | | Double distancePrice = rule.getDouble("num4") * exceedDistance; |
| | | Double distancePrice = rule.getDouble("num4") * exceedDistance * priceRate; |
| | | |
| | | // 超出时间价格 |
| | | Double durationPrice = rule.getDouble("num5") * exceedTime; |
| | | Double durationPrice = rule.getDouble("num5") * exceedTime * priceRate; |
| | | |
| | | startPrice = new BigDecimal(startPrice).multiply(BigDecimal.valueOf(priceRate)).setScale(2, RoundingMode.HALF_UP).doubleValue(); |
| | | |
| | |
| | | // 里程 |
| | | xpPricingCardVo.setDistance(realDistance); |
| | | xpPricingCardVo.setDuration(realTime); |
| | | |
| | | return xpPricingCardVo; |
| | | } |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | public XpPricingCardVo calculationPrice(String uid,JSONObject rule, JSONArray startingFareJson, double distance, long duration, long wait, Double waitMoney,Integer isDynamicPriceStatus,Long openCityId,String dynamicPricingJson) { |
| | | |
| | | |
| | | // 默认费率1 |
| | | double priceRate=1; |
| | | if(isDynamicPriceStatus==1){ |
| | |
| | | |
| | | |
| | | XpPricingCardVo xpPricingCardVo = new XpPricingCardVo(); |
| | | double amount = 0; |
| | | //等待费 |
| | | Date date = new Date(); |
| | | // 计算出是在那个时间段内 |
| | |
| | | if (realDistance > rule.getDouble("num12")) { |
| | | longDistanceThree = rule.getDouble("num34") * (realDistance - rule.getDouble("num12")); |
| | | } |
| | | amount = rule.getDouble("num29") + (exceedDistance * rule.getDouble("num30")) + (exceedTime * rule.getDouble("num31")) + (wait * waitMoney) + longDistanceOne + longDistanceTwo + longDistanceThree; |
| | | |
| | | |
| | | // 起步价 |
| | | xpPricingCardVo.setStartPrice(rule.getDouble("num29")); |
| | |
| | | if (realDistance > rule.getDouble("num12")) { |
| | | longDistanceThree = rule.getDouble("num20") * (realDistance - rule.getDouble("num12")); |
| | | } |
| | | amount = rule.getDouble("num15") + (exceedDistance * rule.getDouble("num16")) + (exceedTime * rule.getDouble("num17")) + (wait * waitMoney) + longDistanceOne + longDistanceTwo + longDistanceThree; |
| | | |
| | | |
| | | // 起步价 |
| | | xpPricingCardVo.setStartPrice(rule.getDouble("num15")); |
| | |
| | | if (realDistance > rule.getDouble("num12")) { |
| | | longDistanceThree = rule.getDouble("num28") * (realDistance - rule.getDouble("num12")); |
| | | } |
| | | amount = rule.getDouble("num23") + (exceedDistance * rule.getDouble("num24")) + (exceedTime * rule.getDouble("num25")) + (wait * waitMoney) + longDistanceOne + longDistanceTwo + longDistanceThree; |
| | | |
| | | |
| | | // 起步价 |
| | | xpPricingCardVo.setStartPrice(rule.getDouble("num23")); |
| | |
| | | if (realDistance > rule.getDouble("num12")) { |
| | | longDistanceThree = rule.getDouble("num13") * (realDistance - rule.getDouble("num12")); |
| | | } |
| | | amount = rule.getDouble("num1") + (exceedDistance * rule.getDouble("num4")) + (exceedTime * rule.getDouble("num5")) + (wait * waitMoney) + longDistanceOne + longDistanceTwo + longDistanceThree; |
| | | |
| | | |
| | | // 起步价 |
| | | xpPricingCardVo.setStartPrice(rule.getDouble("num1")); |
| | |
| | | } |
| | | |
| | | // 订单总额 |
| | | Double startPrice = xpPricingCardVo.getStartPrice(); |
| | | // 先减去起步价重新计算 |
| | | amount = amount - startPrice; |
| | | // 动态计算费用 |
| | | startPrice= new BigDecimal(startPrice).multiply(new BigDecimal(priceRate)).setScale(2, RoundingMode.HALF_UP).doubleValue(); |
| | | amount = amount+startPrice; |
| | | xpPricingCardVo.setTotalPrice(amount); |
| | | |
| | | |
| | | double amount = xpPricingCardVo.getStartPrice() + xpPricingCardVo.getDistancePrice() + xpPricingCardVo.getDurationPrice(); |
| | | xpPricingCardVo.setTotalPrice(new BigDecimal(amount).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | return xpPricingCardVo; |
| | | } |
| | | /** |