| | |
| | | package com.supersavedriving.user.modular.system.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.supersavedriving.user.modular.system.dao.SystemConfigMapper; |
| | | import com.supersavedriving.user.modular.system.model.SystemConfig; |
| | | import com.supersavedriving.user.modular.system.service.ISystemConfigService; |
| | | import com.supersavedriving.user.modular.system.warpper.PriceRulesWarpper; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 系统配置 |
| | |
| | | */ |
| | | @Service |
| | | public class SystemConfigServiceImpl extends ServiceImpl<SystemConfigMapper, SystemConfig> implements ISystemConfigService { |
| | | |
| | | |
| | | /** |
| | | * 获取价格表 |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public PriceRulesWarpper queryPriceRules() throws Exception { |
| | | SystemConfig systemConfig = this.selectOne(new EntityWrapper<SystemConfig>().eq("type", 5)); |
| | | PriceRulesWarpper priceRulesWarpper = new PriceRulesWarpper(); |
| | | if(null != systemConfig){ |
| | | //{"ChargeStandard":[{"num1":"06:00","num2":"08:00","num3":2,"num4":2,"num5":2,"num6":2,"num7":2,"num8":2,"num9":2,"num10":2,"num11":2},{"num1":"06:00","num2":"08:00","num3":1,"num4":1,"num5":1,"num6":1,"num7":2,"num8":2,"num9":2,"num10":2,"num11":2},{"num1":"00:00","num2":"10:00","num3":3,"num4":3,"num5":3,"num6":3,"num7":3,"num8":3,"num9":3,"num10":3,"num11":3}],"ExtraCost":{"num1":1,"num2":1,"num3":1,"num4":1,"num5":1,"num6":1,"num7":1,"num8":1,"num9":1}} |
| | | JSONObject jsonObject = JSON.parseObject(systemConfig.getContent()); |
| | | JSONArray chargeStandard = jsonObject.getJSONArray("ChargeStandard"); |
| | | List<Map<String, Object>> basePrice = new ArrayList<>(); |
| | | List<Map<String, Object>> longDistanceCharges = new ArrayList<>(); |
| | | for (int i = 0; i < chargeStandard.size(); i++) { |
| | | JSONObject jsonObject1 = chargeStandard.getJSONObject(i); |
| | | String num1 = jsonObject1.getString("num1"); |
| | | String num2 = jsonObject1.getString("num2"); |
| | | Double num3 = jsonObject1.getDouble("num3"); |
| | | Double num4 = jsonObject1.getDouble("num4"); |
| | | Double num5 = jsonObject1.getDouble("num5"); |
| | | Double num6 = jsonObject1.getDouble("num6"); |
| | | Double num7 = jsonObject1.getDouble("num7"); |
| | | Double num8 = jsonObject1.getDouble("num8"); |
| | | Double num9 = jsonObject1.getDouble("num9"); |
| | | Double num10 = jsonObject1.getDouble("num10"); |
| | | Double num11 = jsonObject1.getDouble("num11"); |
| | | |
| | | |
| | | Map<String, Object> map1 = new HashMap<>(); |
| | | map1.put("time", num1 + "-" + num2); |
| | | map1.put("startingMileage", num3 + "公里(包含" + num3 + "公里)"); |
| | | map1.put("startingPrice", num4 + "元"); |
| | | map1.put("exceedStartingPrice", num6 + "元/" + num5 + "公里"); |
| | | basePrice.add(map1); |
| | | |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("time", num1 + "-" + num2); |
| | | map2.put("startingMileage", num7 + "-" + num8 + "公里"); |
| | | map2.put("startingPrice", num9 + "元"); |
| | | map2.put("exceedStartingPrice", num11 + "元/" + num10 + "公里"); |
| | | longDistanceCharges.add(map2); |
| | | } |
| | | priceRulesWarpper.setBasePrice(JSON.toJSONString(basePrice)); |
| | | priceRulesWarpper.setLongDistanceCharges(JSON.toJSONString(longDistanceCharges)); |
| | | //额外费用 |
| | | JSONObject extraCost = jsonObject.getJSONObject("ExtraCost"); |
| | | Integer num1 = extraCost.getInteger("num1"); |
| | | Double num2 = extraCost.getDouble("num2"); |
| | | Integer num3 = extraCost.getInteger("num3"); |
| | | Double num4 = extraCost.getDouble("num4"); |
| | | Double num5 = extraCost.getDouble("num5"); |
| | | Double num6 = extraCost.getDouble("num6"); |
| | | Double num7 = extraCost.getDouble("num7"); |
| | | Double num8 = extraCost.getDouble("num8"); |
| | | Double num9 = extraCost.getDouble("num9"); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("waitTime", num1 + "分钟/" + num2 + "元"); |
| | | map.put("exceedWaitTime", "超出" + num3 + "分钟,收取" + num4 + "元/分钟"); |
| | | map.put("badWeather", num5 + "公里内加收" + num6 + "元,超过" + num7 + "公里按照订单单价的" + num8 + "倍计费,最高收取" + num9 + "元"); |
| | | priceRulesWarpper.setAdditionalFee(JSON.toJSONString(map)); |
| | | } |
| | | return priceRulesWarpper; |
| | | } |
| | | } |