|
@@ -7,6 +7,7 @@ import cn.hutool.core.thread.ThreadUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.cron.timingwheel.SystemTimer;
|
|
import cn.hutool.cron.timingwheel.SystemTimer;
|
|
|
import cn.hutool.cron.timingwheel.TimerTask;
|
|
import cn.hutool.cron.timingwheel.TimerTask;
|
|
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -14,6 +15,7 @@ import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
|
|
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
|
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
import jakarta.annotation.PostConstruct;
|
|
import jakarta.annotation.PostConstruct;
|
|
|
|
|
+import org.dromara.common.core.domain.R;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.SpringUtils;
|
|
import org.dromara.common.core.utils.SpringUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
@@ -181,11 +183,59 @@ public class TblDzbcOrderServiceImpl implements ITblDzbcOrderService {
|
|
|
Assert.isTrue(StrUtil.isNotEmpty(areas.get(1).getLocation()),areas.get(1).getName()+"区域未设置经纬度");
|
|
Assert.isTrue(StrUtil.isNotEmpty(areas.get(1).getLocation()),areas.get(1).getName()+"区域未设置经纬度");
|
|
|
double distanceArea = DistanceCalculator.calculateDistance(areas.get(0).getLocation(),areas.get(1).getLocation());
|
|
double distanceArea = DistanceCalculator.calculateDistance(areas.get(0).getLocation(),areas.get(1).getLocation());
|
|
|
double distanceSite = DistanceCalculator.calculateDistance(startSite.getLocation(),endSite.getLocation());
|
|
double distanceSite = DistanceCalculator.calculateDistance(startSite.getLocation(),endSite.getLocation());
|
|
|
- Assert.isTrue(pathVo.getPrice()!=null,"路线价格未设置");
|
|
|
|
|
- //单价 根据区域-区域 单价及站点-站点 计算价格
|
|
|
|
|
- double price = pathVo.getPrice()*(distanceSite/distanceArea);
|
|
|
|
|
- //计算加价
|
|
|
|
|
- add.setPrice((int)Math.round(price+scheduling.getPprice()));
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ try{
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if(pathVo.getExt1()!=null && JSONUtil.parseObj(pathVo.getExt1().toString())!=null) {
|
|
|
|
|
+ JSONObject ext1 = JSONUtil.parseObj(pathVo.getExt1().toString());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //获取区域价格
|
|
|
|
|
+ JSONArray prices = ext1.getJSONArray("jgqj");
|
|
|
|
|
+ //获取距离
|
|
|
|
|
+ Double distance = ext1.getDouble("jl");
|
|
|
|
|
+ //获取价格系数
|
|
|
|
|
+ Double jgxs = ext1.getDouble("jgxs");
|
|
|
|
|
+
|
|
|
|
|
+ if (jgxs == null) jgxs = 1.0;
|
|
|
|
|
+ if (distance == null) distance = distanceArea;
|
|
|
|
|
+ double distanceSite1 = distanceSite * distanceArea / distance;
|
|
|
|
|
+
|
|
|
|
|
+ if(prices!=null||prices.size()>0) {
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < prices.size(); i++) {
|
|
|
|
|
+ JSONObject price = prices.getJSONObject(i);
|
|
|
|
|
+ Double min = price.getDouble("min");
|
|
|
|
|
+ Double max = price.getDouble("max");
|
|
|
|
|
+ Double p = price.getDouble("price");
|
|
|
|
|
+ if (min == null) min = 0.0;
|
|
|
|
|
+ if (max == null) max = Double.MAX_VALUE;
|
|
|
|
|
+ if (distanceSite1 >= min && distanceSite1 <= max) {
|
|
|
|
|
+ double jg = (p * 100) + (distanceSite1) * jgxs;
|
|
|
|
|
+ add.setPrice((int) Math.round(jg));
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ throw new RuntimeException("路线价格错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(add.getPrice()==null){
|
|
|
|
|
+ Integer price1 = pathVo.getPrice();
|
|
|
|
|
+ if(price1==null) throw new RuntimeException("路线价格错误");
|
|
|
|
|
+ //单价 根据区域-区域 单价及站点-站点 计算价格
|
|
|
|
|
+ double price = price1*(distanceSite/distanceArea);
|
|
|
|
|
+ //计算加价
|
|
|
|
|
+ add.setPrice((int)Math.round(price+scheduling.getPprice()));
|
|
|
|
|
+ }
|
|
|
|
|
+//
|
|
|
|
|
+// //单价 根据区域-区域 单价及站点-站点 计算价格
|
|
|
|
|
+// double price = pathVo.getPrice()*(distanceSite/distanceArea);
|
|
|
|
|
+// //计算加价
|
|
|
|
|
+// add.setPrice((int)Math.round(price+scheduling.getPprice()));
|
|
|
|
|
|
|
|
add.setStartInfo(JSONUtil.toJsonStr(Map.of("areaInfo", areas.get(0), "siteInfo", startSite)));
|
|
add.setStartInfo(JSONUtil.toJsonStr(Map.of("areaInfo", areas.get(0), "siteInfo", startSite)));
|
|
|
add.setEndInfo(JSONUtil.toJsonStr(Map.of("areaInfo", areas.get(1), "siteInfo", endSite)));
|
|
add.setEndInfo(JSONUtil.toJsonStr(Map.of("areaInfo", areas.get(1), "siteInfo", endSite)));
|