package com.supersavedriving.driver.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.driver.core.util.ToolUtil;
|
import com.supersavedriving.driver.modular.system.dao.OrderMapper;
|
import com.supersavedriving.driver.modular.system.model.*;
|
import com.supersavedriving.driver.modular.system.service.*;
|
import com.supersavedriving.driver.modular.system.util.*;
|
import com.supersavedriving.driver.modular.system.util.GaoDe.MapUtil;
|
import com.supersavedriving.driver.modular.system.util.juhe.WeatherUtil;
|
import com.supersavedriving.driver.modular.system.util.mongodb.model.Location;
|
import com.supersavedriving.driver.modular.system.warpper.AddOrderWarpper;
|
import com.supersavedriving.driver.modular.system.warpper.HallOrderList;
|
import com.supersavedriving.driver.modular.system.warpper.OrderInfoWarpper;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.data.geo.Circle;
|
import org.springframework.data.geo.Distance;
|
import org.springframework.data.geo.Metrics;
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
import org.springframework.data.mongodb.core.geo.GeoJsonPoint;
|
import org.springframework.data.mongodb.core.query.Criteria;
|
import org.springframework.data.mongodb.core.query.Query;
|
import org.springframework.stereotype.Service;
|
|
import java.math.BigDecimal;
|
import java.math.MathContext;
|
import java.math.RoundingMode;
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
|
/**
|
* 订单
|
* @author pzb
|
* @Date 2023/2/16 15:57
|
*/
|
@Service
|
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {
|
|
@Autowired
|
private IDriverWorkService driverWorkService;
|
|
@Autowired
|
private IDriverService driverService;
|
|
@Autowired
|
private ISystemConfigService systemConfigService;
|
|
@Autowired
|
private PushUtil pushUtil;
|
|
@Autowired
|
private MongoTemplate mongoTemplate;
|
|
@Autowired
|
private IAppUserService appUserService;
|
|
@Autowired
|
private RedisUtil redisUtil;
|
|
@Autowired
|
private ISystemMessageService systemMessageService;
|
|
@Autowired
|
private IOrderRefusalService orderRefusalService;
|
|
@Autowired
|
private IYouTuiDriverService youTuiDriverService;
|
|
|
|
|
|
/**
|
* 获取服务中的订单id
|
* @param uid
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public Long queryDriverServerOrder(Integer uid) throws Exception {
|
Order order = this.selectOne(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", Arrays.asList(102, 103, 104, 105, 201)));
|
if(null != order){
|
return order.getId();
|
}
|
return 0L;
|
}
|
|
|
/**
|
* 司机代客下单
|
* @param uid
|
* @param addOrderWarpper
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public ResultUtil driverAddOrder(Integer uid, AddOrderWarpper addOrderWarpper) throws Exception {
|
/**
|
* 司机上线且空闲,下单直接给当前司机,其余进大厅
|
* 司机下的订单不需要创建新用户,且只能走线下支付
|
*/
|
|
int count = this.selectCount(new EntityWrapper<Order>().eq("userPhone", addOrderWarpper.getPhone()).eq("status", 1).in("state", Arrays.asList(101, 102, 103, 104, 105, 106, 201)));
|
if(count > 0){
|
return ResultUtil.error("该用户还有未完成的订单");
|
}
|
Driver driver = driverService.selectById(uid);
|
DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", uid).eq("status", 1));
|
Order order1 = this.selectOne(new EntityWrapper<Order>().eq("driverId", uid).eq("status", 1).in("state", Arrays.asList(102, 103, 104, 105, 201)));
|
Order order = new Order();
|
if(driverWork != null && null == order1){
|
order.setDriverId(uid);
|
driver.setServerStatus(2);
|
}
|
order.setCode(UUIDUtil.getTimeStr() + UUIDUtil.getNumberRandom(3));
|
order.setSource(2);
|
|
AppUser appUser = appUserService.selectOne(new EntityWrapper<AppUser>().eq("phone", addOrderWarpper.getPhone()).eq("status", 1));
|
if(null != appUser){
|
order.setUserId(appUser.getId());
|
}
|
order.setUserName(addOrderWarpper.getUserName());
|
order.setUserPhone(addOrderWarpper.getPhone());
|
order.setAgentId(driver.getAgentId());
|
order.setBranchOfficeId(driver.getBranchOfficeId());
|
order.setStartAddress(addOrderWarpper.getStartAddress());
|
order.setStartLat(addOrderWarpper.getStartLat());
|
order.setStartLng(addOrderWarpper.getStartLng());
|
order.setEndAddress(addOrderWarpper.getEndAddress());
|
order.setEndLat(addOrderWarpper.getEndLat());
|
order.setEndLng(addOrderWarpper.getEndLng());
|
Double d = 0D;
|
if(ToolUtil.isNotEmpty(addOrderWarpper.getEndAddress())){
|
Map<String, String> distance = MapUtil.getDistance(order.getStartLng() + "," + order.getStartLat(), order.getEndLng() + "," + order.getEndLat(), 1);
|
if(null == distance){
|
return ResultUtil.error("获取预估距离出错");
|
}
|
d = Double.valueOf(distance.get("distance")) / 1000;
|
order.setEstimatedMileage(d);
|
}
|
order = getOrderPrice(1, d, 0, order, "");
|
order.setHallOrder(0);
|
order.setState(null == order.getDriverId() ? 101 : 102);
|
order.setStatus(1);
|
order.setCreateTime(new Date());
|
this.insert(order);
|
driverService.updateById(driver);
|
//推送状态
|
if(null != order.getDriverId()){
|
pushUtil.pushOrderStatus(uid, 2, order.getId(), order.getStatus());
|
}else{
|
//开始推单
|
pushOrder(order);
|
}
|
return ResultUtil.success();
|
}
|
|
|
/**
|
* 获取订单价格
|
* @param type 计算类型(1=预估价,2=订单费)
|
* @param distance 行驶公里
|
* @param waitTime 等待时长
|
* @param order 订单数据
|
* @param city 查询天气的城市
|
* @return
|
*/
|
public Order getOrderPrice(Integer type, Double distance, Integer waitTime, Order order, String city){
|
order = getOrderInitialPrice(order);
|
SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 5));
|
if(null == systemConfig){
|
if(type == 1){//预估金额
|
order.setEstimatedPrice(0D);
|
}
|
if(type == 2){//订单金额
|
order.setOrderMoney(0D);
|
}
|
return order;
|
}
|
JSONObject jsonObject = JSON.parseObject(systemConfig.getContent());
|
JSONArray chargeStandard = jsonObject.getJSONArray("ChargeStandard");
|
JSONObject extraCost = jsonObject.getJSONObject("ExtraCost");
|
Date date = new Date();
|
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");//超过num3每num5公里收取num6
|
Double num7 = jsonObject1.getDouble("num7");//长途起始公里
|
Double num8 = jsonObject1.getDouble("num8");//长途结束公里
|
Double num9 = jsonObject1.getDouble("num9");//长途费
|
Double num10 = jsonObject1.getDouble("num10");//超出长途里程每num10公里
|
Double num11 = jsonObject1.getDouble("num11");//超过num8每num10公里收取num11
|
|
String[] split = num1.split(":");
|
Calendar s = Calendar.getInstance();
|
s.setTime(date);
|
s.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0]));
|
s.set(Calendar.MINUTE, Integer.valueOf(split[1]));
|
s.set(Calendar.SECOND, 0);
|
|
split = num2.split(":");
|
Calendar e = Calendar.getInstance();
|
e.setTime(date);
|
e.set(Calendar.HOUR_OF_DAY, Integer.valueOf(split[0]));
|
e.set(Calendar.MINUTE, Integer.valueOf(split[1]));
|
e.set(Calendar.SECOND, 0);
|
|
if(date.getTime() >= s.getTimeInMillis() && date.getTime() < e.getTimeInMillis()){
|
if(num3.compareTo(distance) >= 0){//起步里程内
|
order.setStartDistance(distance);//起步里程
|
order.setStartPrice(num4);//起步价
|
}else{
|
BigDecimal subtract = new BigDecimal(distance).subtract(new BigDecimal(num3));//超出起步里程
|
BigDecimal divide = subtract.divide(new BigDecimal(num5), new MathContext(2, RoundingMode.HALF_EVEN));
|
BigDecimal multiply = divide.multiply(new BigDecimal(num6));
|
order.setStartDistance(num3);//起步里程
|
order.setStartPrice(num4);//起步价
|
order.setOverDriveDistance(subtract.doubleValue());//超出起步里程
|
order.setOverDrivePrice(multiply.doubleValue());//超出起步里程费
|
|
//计算长途费
|
if(distance.compareTo(num7) > 0){
|
order.setLongDistance(num7 + "-" + num8);//长途里程
|
order.setLongDistancePrice(num9);//长途费
|
}
|
//计算长途里程超出的部分
|
if(distance.compareTo(num8) > 0){
|
BigDecimal subtract1 = new BigDecimal(distance).subtract(new BigDecimal(num8));
|
BigDecimal divide1 = subtract1.divide(new BigDecimal(num10), new MathContext(2, RoundingMode.HALF_EVEN));
|
BigDecimal multiply1 = divide1.multiply(new BigDecimal(num11));
|
order.setOverLongDistance(subtract1.doubleValue());//超出长途里程
|
order.setOverLongDistancePrice(multiply1.doubleValue());//超出长途里程费
|
}
|
}
|
break;
|
}
|
}
|
|
//计算额外费用
|
Integer num1 = extraCost.getInteger("num1");//等待时长
|
Double num2 = extraCost.getDouble("num2");//等待费
|
Integer num3 = extraCost.getInteger("num3");//等待超出时长
|
Double num4 = extraCost.getDouble("num4");//等到超出时长费用单价 X/分钟
|
Double num5 = extraCost.getDouble("num5");//恶劣天气公里
|
Double num6 = extraCost.getDouble("num6");//恶劣天气费
|
Double num7 = extraCost.getDouble("num7");//恶劣天气超出公里
|
Double num8 = extraCost.getDouble("num8");//恶劣天气超出公里单价 X/公里
|
Double num9 = extraCost.getDouble("num9");//恶劣天气最高收取金额
|
|
//等待费用
|
if(waitTime.compareTo(num1) >= 0){
|
order.setWaitTime(num1);//等待时长
|
order.setWaitTimePrice(num2);//等待费用
|
|
Integer w = waitTime - num3;
|
BigDecimal multiply = new BigDecimal(w).multiply(new BigDecimal(num4));
|
order.setOutWaitTime(w);//等待时长超出分钟
|
order.setOutWaitTimePrice(multiply.doubleValue());//等待时长超出费用
|
}
|
|
//恶劣天气
|
boolean badWeather = WeatherUtil.isBadWeather(city);
|
if(badWeather){
|
order.setBadWeatherDistance(num5);//恶劣天气公里
|
order.setBadWeatherPrice(num6);//恶劣天气费
|
if(distance.compareTo(num7) > 0){
|
BigDecimal subtract = new BigDecimal(distance).subtract(new BigDecimal(num7));
|
BigDecimal multiply = subtract.multiply(new BigDecimal(num8));
|
order.setOverBadWeatherDistance(subtract.doubleValue());//恶劣天气超出公里
|
order.setOverBadWeatherPrice(multiply.doubleValue());//恶劣天气超出公里费
|
}
|
|
double add = new BigDecimal(order.getOverBadWeatherPrice()).add(new BigDecimal(order.getBadWeatherPrice())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
|
if(num9.compareTo(add) < 0){//超出最高金额(重新调整金额)
|
if(num9.compareTo(num6) < 0){//如果恶劣天气费大于最高金额
|
order.setBadWeatherPrice(num9);//恶劣天气费
|
order.setOverBadWeatherPrice(0D);//恶劣天气超出公里费
|
}else{
|
BigDecimal subtract = new BigDecimal(num9).subtract(new BigDecimal(add));
|
order.setOverBadWeatherPrice(subtract.doubleValue());//恶劣天气超出公里费
|
}
|
}
|
}
|
|
//计算总金额
|
BigDecimal bigDecimal = new BigDecimal(order.getStartPrice() + order.getOverDrivePrice() + order.getLongDistancePrice() + order.getOverLongDistancePrice() +
|
order.getWaitTimePrice() + order.getOutWaitTimePrice() + order.getBadWeatherPrice() + order.getOverBadWeatherPrice()).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
if(type == 1){//预估价
|
order.setEstimatedPrice(bigDecimal.doubleValue());
|
}
|
if(type == 2){//订单金额
|
order.setOrderMoney(bigDecimal.doubleValue());
|
}
|
return order;
|
}
|
|
|
/**
|
* 初始订单费用
|
* @param order
|
* @return
|
*/
|
public Order getOrderInitialPrice(Order order){
|
order.setStartDistance(0D);//起步里程
|
order.setStartPrice(0D);//起步价
|
order.setOverDriveDistance(0D);//超出起步里程
|
order.setOverDrivePrice(0D);//超出起步里程费
|
order.setLongDistance("");//长途里程
|
order.setLongDistancePrice(0D);//长途里程费
|
order.setOverLongDistance(0D);//超出长途里程
|
order.setOverLongDistancePrice(0d);//超出长途里程费
|
order.setWaitTime(0);//等待时长
|
order.setWaitTimePrice(0D);//等待费
|
order.setOutWaitTime(0);//超出等待时长
|
order.setOutWaitTimePrice(0D);//超出等待时长费
|
order.setBadWeatherDistance(0D);//恶劣天气里程
|
order.setBadWeatherPrice(0D);//恶劣天气里程费
|
order.setOverBadWeatherDistance(0D);//恶劣天气超出里程
|
order.setOverBadWeatherPrice(0D);//恶劣天气超出里程费
|
order.setDiscountedPrice(0D);//优惠金额
|
order.setCouponId(null);//优惠券
|
return order;
|
}
|
|
|
/**
|
* 订单推送逻辑
|
* @param order
|
*/
|
public void pushOrder(Order order){
|
/**
|
* 1.先找最大推单范围内的优推司机 -》 距离最近
|
* 没有1 - 》
|
* 2.按照后台推送配置在范围内查找合适司机
|
* 合适司:积分 > 评分 > 距离
|
* 3.司机没有接单直接将订单置入大厅
|
*/
|
SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 1));
|
if(null == systemConfig){
|
return;
|
}
|
JSONObject jsonObject = JSON.parseObject(systemConfig.getContent());
|
Double num3 = jsonObject.getDouble("num3");//推单最大范围
|
Integer num4 = jsonObject.getInteger("num4");//接单时间
|
String startLat = order.getStartLat();
|
String startLng = order.getStartLng();
|
|
//1
|
//找到中心点
|
GeoJsonPoint geoJsonPoint = new GeoJsonPoint(Double.valueOf(startLat), Double.valueOf(startLng));
|
Double num = num3 / 1000;//范围公里
|
//构造半径
|
Distance distanceR = new Distance(num, Metrics.KILOMETERS);
|
//画圆
|
Circle circle = new Circle(geoJsonPoint, distanceR);
|
// 构造query对象
|
Query query = Query.query(Criteria.where("location").withinSphere(circle));
|
List<Location> locations = mongoTemplate.find(query, Location.class);
|
List<Integer> driverIds = locations.stream().map(Location::getDriverId).collect(Collectors.toList());
|
Integer driver = null;
|
if(driverIds.size() > 0){
|
List<YouTuiDriver> youTuiDrivers = youTuiDriverService.selectList(new EntityWrapper<YouTuiDriver>().in("driverId", driverIds).last(" and now() < failureTime"));
|
Double d = null;
|
for (YouTuiDriver youTuiDriver : youTuiDrivers) {
|
String value = redisUtil.getValue("DRIVER" + youTuiDriver.getDriverId());
|
if(ToolUtil.isEmpty(value)){
|
continue;
|
}
|
Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat());
|
Double wgs84 = distance.get("WGS84");
|
if(d == null || d.compareTo(wgs84) > 0){
|
d = wgs84;
|
driver = youTuiDriver.getDriverId();
|
}
|
}
|
}
|
|
|
//开始范围查找
|
if(null == driver){
|
for (int i = 1; i < 4; i++) {
|
num = jsonObject.getDouble("num" + i) / 1000;//范围公里
|
//构造半径
|
distanceR = new Distance(num, Metrics.KILOMETERS);
|
//画圆
|
circle = new Circle(geoJsonPoint, distanceR);
|
// 构造query对象
|
query = Query.query(Criteria.where("location").withinSphere(circle));
|
locations = mongoTemplate.find(query, Location.class);
|
|
driverIds = locations.stream().map(Location::getDriverId).collect(Collectors.toList());
|
if(driverIds.size() > 0){
|
List<Driver> drivers = driverService.selectList(new EntityWrapper<Driver>().eq("approvalStatus", 2).eq("serverStatus", 1).eq("status", 1).in("id", driverIds));
|
if(drivers.size() == 0){
|
continue;
|
}
|
|
Integer integral = null;
|
Double score = null;
|
Double d = null;
|
for (Driver driver1 : drivers) {
|
if(integral == null || integral.compareTo(driver1.getIntegral()) < 0){//积分大
|
integral = driver1.getIntegral();
|
score = driver1.getScore();
|
driver = driver1.getId();
|
continue;
|
}
|
if(integral.compareTo(driver1.getIntegral()) == 0 && score.compareTo(driver1.getScore()) < 0){//积分相同对比评分
|
integral = driver1.getIntegral();
|
score = driver1.getScore();
|
driver = driver1.getId();
|
continue;
|
}
|
if(integral.compareTo(driver1.getIntegral()) == 0 && score.compareTo(driver1.getScore()) == 0){//积分相同/评分相同对比距离
|
String value = redisUtil.getValue("DRIVER" + driver1.getId());
|
if(ToolUtil.isEmpty(value)){
|
continue;
|
}
|
Map<String, Double> distance = GeodesyUtil.getDistance(value, order.getStartLng() + "," + order.getStartLat());
|
Double wgs84 = distance.get("WGS84");
|
if(d == null || d.compareTo(wgs84) > 0){
|
d = wgs84;
|
driver = driver1.getId();
|
continue;
|
}
|
}
|
}
|
|
}
|
}
|
}
|
|
if(null != driver){
|
pushUtil.pushGrabOrder(driver, 2, order.getId(), num4);
|
//创建定时任务处理订单到大厅
|
new Timer().schedule(new TimerTask() {
|
@Override
|
public void run() {
|
Order order1 = OrderServiceImpl.this.selectById(order.getId());
|
if(order1.getState() == 101){
|
order1.setHallOrder(1);
|
OrderServiceImpl.this.updateById(order1);
|
}
|
}
|
}, num4 * 1000);
|
}else{
|
order.setHallOrder(1);
|
this.updateById(order);
|
}
|
}
|
|
|
|
/**
|
* 获取大厅订单列表
|
* @param uid
|
* @param pageNum
|
* @param pageSize
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public List<HallOrderList> queryOrderHall(Integer uid, Integer pageNum, Integer pageSize) throws Exception {
|
pageNum = (pageNum - 1) * pageSize;
|
List<HallOrderList> hallOrderLists = this.baseMapper.queryOrderHall(pageNum, pageSize);
|
hallOrderLists.forEach(hallOrderList -> {
|
Map<String, Double> distance = GeodesyUtil.getDistance(hallOrderList.getStartLng() + "," + hallOrderList.getStartLat(), hallOrderList.getEndLng() + "," + hallOrderList.getEndLat());
|
Double wgs84 = distance.get("WGS84");
|
hallOrderList.setCurrentDistance(wgs84);
|
});
|
return hallOrderLists;
|
}
|
|
|
/**
|
* 司机拒单
|
* @param uid
|
* @param orderId
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public ResultUtil rejectionOrder(Integer uid, Long orderId) throws Exception {
|
Order order = this.selectById(orderId);
|
DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", uid).eq("status", 1));
|
if(null == driverWork){
|
return ResultUtil.error("请先上班");
|
}
|
OrderRefusal orderRefusal = new OrderRefusal();
|
orderRefusal.setCode(order.getCode());
|
orderRefusal.setCreateTime(new Date());
|
orderRefusal.setDriverId(uid);
|
orderRefusal.setEndAddress(order.getEndAddress());
|
orderRefusal.setStartAddress(order.getStartAddress());
|
orderRefusal.setOrderId(orderId);
|
orderRefusalService.insert(orderRefusal);
|
return ResultUtil.success();
|
}
|
|
/**
|
* 司机接单操作
|
* @param uid
|
* @param orderId
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public ResultUtil receiveOrder(Integer uid, Long orderId) throws Exception {
|
try {
|
Driver driver = driverService.selectById(uid);
|
DriverWork driverWork = driverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", uid).eq("status", 1));
|
if(null == driverWork){
|
return ResultUtil.error("请先上班");
|
}
|
boolean lock = redisUtil.lock(5);
|
if(!lock){
|
int num1 = 1;
|
while (num1 <= 10){
|
Thread.sleep(3000);//等待3秒
|
lock = redisUtil.lock(5);
|
if(lock){
|
break;
|
}else{
|
num1++;
|
}
|
}
|
}
|
Order order = this.selectById(orderId);
|
if(order.getState() != 301){
|
redisUtil.unlock();
|
return ResultUtil.error("订单已被取消");
|
}
|
if(order.getState() != 101){
|
redisUtil.unlock();
|
return ResultUtil.error("手速慢了哦");
|
}
|
order.setDriverId(uid);
|
order.setAgentId(driver.getAgentId());
|
order.setBranchOfficeId(driver.getBranchOfficeId());
|
order.setState(102);
|
this.updateById(order);
|
redisUtil.unlock();
|
|
driver.setServerStatus(2);
|
driverService.updateById(driver);
|
|
//推动订单数据
|
new Thread(new Runnable() {
|
@Override
|
public void run() {
|
//发送系统消息
|
systemMessageService.addSystemMessage(uid, 2, "接单成功", "您已成功接到用户订单,请尽快联系客户!");
|
pushUtil.pushOrderStatus(order.getDriverId(), 2, order.getId(), order.getState());
|
if(null != order.getUserId()){
|
systemMessageService.addSystemMessage(order.getUserId(), 1, "接单成功", driver.getName() + "师傅已成功接到您的订单,请保持电话畅通!");
|
pushUtil.pushOrderStatus(order.getUserId(), 1, order.getId(), order.getState());
|
}
|
}
|
}).start();
|
}catch (Exception e){
|
redisUtil.unlock();
|
e.printStackTrace();
|
throw e;
|
}
|
return ResultUtil.success();
|
}
|
|
|
/**
|
* 获取订单详情
|
* @param orderId
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public OrderInfoWarpper queryOrderInfo(Integer uid, Long orderId) throws Exception {
|
OrderInfoWarpper orderInfoWarpper = this.baseMapper.queryOrderInfo(orderId);
|
String value = redisUtil.getValue("DRIVER" + uid);
|
Map<String, Double> distance = GeodesyUtil.getDistance(orderInfoWarpper.getStartLng() + "," + orderInfoWarpper.getStartLat(), value);
|
Double wgs84 = distance.get("WGS84");
|
orderInfoWarpper.setCurrentDistance(wgs84);
|
return orderInfoWarpper;
|
}
|
}
|