package com.stylefeng.guns.modular.smallLogistics.server.impl;
|
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
import com.stylefeng.guns.core.util.DateUtil;
|
import com.stylefeng.guns.core.util.ToolUtil;
|
import com.stylefeng.guns.modular.account.model.TEnterpriseWithdrawal;
|
import com.stylefeng.guns.modular.account.service.ITEnterpriseWithdrawalService;
|
import com.stylefeng.guns.modular.account.service.UserWithdrawalService;
|
import com.stylefeng.guns.modular.account.util.Base64Util;
|
import com.stylefeng.guns.modular.cloudPayment.example.AllocationExample;
|
import com.stylefeng.guns.modular.cloudPayment.req.AllocationReq;
|
import com.stylefeng.guns.modular.smallLogistics.dao.OrderLogisticsMapper;
|
import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics;
|
import com.stylefeng.guns.modular.smallLogistics.model.OrderLogisticsSpread;
|
import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService;
|
import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsSpreadService;
|
import com.stylefeng.guns.modular.system.dao.RegionMapper;
|
import com.stylefeng.guns.modular.system.dao.UserInfoMapper;
|
import com.stylefeng.guns.modular.system.model.*;
|
import com.stylefeng.guns.modular.system.service.*;
|
import com.stylefeng.guns.modular.system.util.*;
|
import com.stylefeng.guns.modular.system.warpper.MerchantCouponListWarpper;
|
import com.unionpay.upyzt.exception.UpyztException;
|
import com.unionpay.upyzt.resp.AllocationResp;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.math.BigDecimal;
|
import java.math.MathContext;
|
import java.math.RoundingMode;
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
|
@Service
|
public class OrderLogisticsServiceImpl extends ServiceImpl<OrderLogisticsMapper, OrderLogistics> implements IOrderLogisticsService {
|
|
@Resource
|
private OrderLogisticsMapper orderLogisticsMapper;
|
|
@Autowired
|
private IDriverService driverService;
|
|
@Autowired
|
private GDFalconUtil gdFalconUtil;
|
|
@Autowired
|
private GDMapGeocodingUtil gdMapGeocodingUtil;
|
|
@Resource
|
private RegionMapper regionMapper;
|
|
@Autowired
|
private ChinaMobileUtil chinaMobileUtil;
|
|
@Autowired
|
private PushUtil pushUtil;
|
|
@Autowired
|
private ISystemNoticeService systemNoticeService;
|
|
@Autowired
|
private IOrderLogisticsSpreadService orderLogisticsSpreadService;
|
|
@Autowired
|
private RedisUtil redisUtil;
|
|
@Autowired
|
private ICompanyService companyService;
|
|
@Autowired
|
private IIncomeService incomeService;
|
|
@Autowired
|
private ALiSendSms aLiSendSms;
|
|
@Resource
|
private UserInfoMapper userInfoMapper;
|
|
@Autowired
|
private IMerchantActivityService merchantActivityService;
|
|
@Autowired
|
private IMerchantActivitySlaveService merchantActivitySlaveService;
|
|
@Autowired
|
private IUserMerchantCouponService userMerchantCouponService;
|
|
@Autowired
|
private IMerchantCouponService merchantCouponService;
|
|
@Autowired
|
private IAgreementService agreementService;
|
@Autowired
|
private ITEnterpriseWithdrawalService enterpriseWithdrawalService;
|
@Autowired
|
private UserWithdrawalService userWithdrawalService;
|
|
|
|
|
|
|
/**
|
* 获取司机抢单界面详情
|
* @param orderId
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public Map<String, Object> queryPushOrder(Integer orderId) throws Exception {
|
return orderLogisticsMapper.queryPushOrder(orderId);
|
}
|
|
|
/**
|
* 司机抢单操作
|
* @param orderId
|
* @param uid
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public synchronized ResultUtil grabOrder(Integer orderId, Integer uid) throws Exception {
|
OrderLogistics orderLogistics = this.selectById(orderId);
|
if(orderLogistics.getState() == 10){
|
return ResultUtil.error("订单已取消");
|
}
|
if(orderLogistics.getState() != 1){
|
return ResultUtil.error("手速有点慢哦,订单已被抢啦!");
|
}
|
Driver driver = driverService.selectById(uid);
|
orderLogistics.setDriverId(uid);
|
orderLogistics.setCarId(driver.getCarId());
|
orderLogistics.setCompanyId(driver.getFranchiseeId() != null && driver.getFranchiseeId() != 0 ? driver.getFranchiseeId() : (
|
driver.getCompanyId() != null && driver.getCompanyId() != 0 ? driver.getCompanyId() : 1));
|
orderLogistics.setState(2);
|
orderLogistics.setSnatchOrderTime(new Date());
|
|
//调用高德创建轨迹
|
String s = gdFalconUtil.selectTerminal(driver.getPhone());
|
String track = gdFalconUtil.createTrack(s);
|
orderLogistics.setTrackId(track);
|
|
//调用移动的小号接口
|
Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderLogistics.getRecipientPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000));
|
if(String.valueOf(map.get("code")).equals("200")){
|
orderLogistics.setTelX(map.get("telX"));
|
orderLogistics.setBindId(map.get("bindId"));
|
}
|
UserInfo userInfo = userInfoMapper.selectById(orderLogistics.getUserId());
|
|
Map<String, String> map1 = chinaMobileUtil.midAxbBindSend(userInfo.getPhone(), driver.getPhone(), (System.currentTimeMillis() + 86400000));
|
System.out.println("二次绑定信息:"+map1);
|
if(String.valueOf(map1.get("code")).equals("200")){
|
orderLogistics.setTelXOne(map1.get("telX"));
|
orderLogistics.setBindIdOne(map1.get("bindId"));
|
}
|
|
this.updateById(orderLogistics);
|
|
//添加已收入明细
|
// Company company = companyService.selectById(driver.getCompanyId());
|
// Double speMoney = orderLogistics.getType() == 4 ? company.getSameLogisticsMoney() : company.getCrossLogisticsMoney();
|
// BigDecimal d = null;//企业收入
|
// BigDecimal c = null;//司机收入
|
// if(company.getIsSpeFixedOrProportional() == 2){//固定
|
// d = new BigDecimal(speMoney);
|
// c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
|
// }
|
// if(company.getIsSpeFixedOrProportional() == 1){//比例
|
// Double price = orderLogistics.getTravelMoney();
|
// d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100)), new MathContext(2, RoundingMode.HALF_EVEN));
|
// c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
// }
|
// incomeService.saveData(1, orderLogistics.getCompanyId(), 2, orderLogistics.getId(), orderLogistics.getType(), d.doubleValue());
|
// incomeService.saveData(2, orderLogistics.getDriverId(), 2, orderLogistics.getId(), orderLogistics.getType(), c.doubleValue());
|
// /*driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
|
// driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
|
// driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
|
// driverService.updateById(driver);*/
|
|
|
|
|
//推送相关代码------------------start----------------
|
new Thread(new Runnable() {
|
@Override
|
public void run() {
|
pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
|
pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
|
}
|
}).start();
|
|
// TODO: 2023/11/4 小件物流无服务中页面
|
// new Thread(new Runnable() {
|
// @Override
|
// public void run() {
|
// pushUtil.pushDriverPosition(orderId, orderLogistics.getType());
|
// }
|
// }).start();
|
|
|
systemNoticeService.addSystemNotice(2, "您已成功抢得小件物流订单,请及时联系客户!", orderLogistics.getDriverId(), 1);
|
systemNoticeService.addSystemNotice(1, "您的订单已指派给" + driver.getName().substring(0, 1) + "师傅,请保持电话畅通!", orderLogistics.getUserId(), 1);
|
|
|
if (this.selectList(new EntityWrapper<OrderLogistics>().eq("driverId",uid)).size() == 1){
|
return ResultUtil.success(agreementService.selectOne(new EntityWrapper<Agreement>().eq("type",17)));
|
}
|
return ResultUtil.success(String.valueOf(orderLogistics.getId()));
|
}
|
|
|
/**
|
* 获取订单详情页(服务中的页面)
|
* @param orderId
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public Map<String, Object> queryOrderInfo(Integer orderId) throws Exception {
|
return orderLogisticsMapper.queryOrderInfo(orderId);
|
}
|
|
|
/**
|
* 走订单流程
|
* @param orderId
|
* @param state
|
* @param lon
|
* @param lat
|
* @param address
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public ResultUtil process(Integer orderId, Integer state, Double lon, Double lat, String address, String driverImg) throws Exception {
|
OrderLogistics orderLogistics = this.selectById(orderId);
|
UserInfo userInfo = userInfoMapper.selectById(orderLogistics.getUserId());
|
switch (state){
|
case 3://出发前往预约点
|
orderLogistics.setState(3);
|
orderLogistics.setSetOutTime(new Date());
|
systemNoticeService.addSystemNotice(1, "司机已出发,请耐心等待", orderLogistics.getUserId(), 1);
|
break;
|
case 4://到达预约点,等待客户上车
|
orderLogistics.setState(4);
|
orderLogistics.setArriveTime(new Date());
|
systemNoticeService.addSystemNotice(1, "司机已到达您设置的预约地点。", orderLogistics.getUserId(), 1);
|
break;
|
case 5://开始服务
|
orderLogistics.setBoardingLon(lon);
|
orderLogistics.setBoardingLat(lat);
|
orderLogistics.setBoardingAddress(address);
|
orderLogistics.setBoardingTime(new Date());
|
orderLogistics.setState(5);
|
orderLogistics.setStartServiceTime(new Date());
|
|
// pushUtil.pushDriverPosition(orderLogistics.getId(), orderLogistics.getType());//主动推送司机定位
|
break;
|
case 6://结束服务(专车可以返回继续服务)不修改状态
|
if(orderLogistics.getState()!=6){
|
orderLogistics.setGetoffLon(lon);
|
orderLogistics.setGetoffLat(lat);
|
orderLogistics.setGetoffAddress(address);
|
orderLogistics.setGetoffTime(new Date());
|
orderLogistics.setEndServiceTime(new Date());
|
orderLogistics.setState(6);
|
orderLogistics.setDriverImg(driverImg);
|
|
//添加抽成及收入记录
|
Map<String, Object> map = incomeService.saveIncome(orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getOrderMoney());
|
orderLogistics.setSplitAllocation(JSON.toJSONString(map));
|
|
//记录添加用户商家优惠券
|
//订单数要加1,因为这里是后修改订单状态
|
List<OrderLogistics> list = this.selectList(new EntityWrapper<OrderLogistics>().eq("userId", userInfo.getId()).eq("type", orderLogistics.getType()).eq("state", 9).eq("isDelete", 1));
|
List<MerchantActivity> merchantActivities = merchantActivityService.selectList(new EntityWrapper<MerchantActivity>().eq("companyId", orderLogistics.getCompanyId()).eq("activityType", 1).eq("auditStatus", 2).eq("status", 1)
|
.eq("state", 1).like("orderType", "%" + orderLogistics.getType() + "%").where("((orderAmountFull is not null and orderAmountFull <= " + orderLogistics.getOrderMoney() + ") or (orderNumber is not null and orderNumber <= " + (list.size() + 1) + "))")
|
.in("id", merchantActivitySlaveService.selectList(new EntityWrapper<MerchantActivitySlave>().gt("laveNumber", 0)).stream().map(MerchantActivitySlave::getMerchantActivityId).collect(Collectors.toList()))
|
.notIn("id", userMerchantCouponService.selectList(new EntityWrapper<UserMerchantCoupon>().eq("userType", 1).eq("userId", userInfo.getId()).eq("state", 1)).stream().map(UserMerchantCoupon::getMerchantActivityId).collect(Collectors.toList()))
|
);
|
List<MerchantCouponListWarpper> listWarppers = new ArrayList<>();
|
if(merchantActivities.size() > 0){
|
for(MerchantActivity merchantActivity :merchantActivities){
|
List<MerchantActivitySlave> merchantActivitySlaves = merchantActivitySlaveService.selectList(new EntityWrapper<MerchantActivitySlave>().eq("merchantActivityId", merchantActivity.getId()).gt("laveNumber", 0));
|
|
for(MerchantActivitySlave merchantActivitySlave : merchantActivitySlaves){
|
UserMerchantCoupon userMerchantCoupon = new UserMerchantCoupon();
|
try {
|
userMerchantCoupon.setCode(UUIDUtil.getRandomCode(16));
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
userMerchantCoupon.setUserType(1);
|
userMerchantCoupon.setUserId(userInfo.getId());
|
userMerchantCoupon.setMerchantActivityId(merchantActivity.getId());
|
userMerchantCoupon.setMerchantCouponId(merchantActivitySlave.getMerchantCouponId());
|
Calendar calendar = Calendar.getInstance();
|
calendar.setTime(new Date());
|
calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + merchantActivity.getEffectiveDays());
|
userMerchantCoupon.setEndTime(calendar.getTime());
|
userMerchantCoupon.setStatus(1);
|
userMerchantCoupon.setState(1);
|
userMerchantCoupon.setCreateTime(new Date());
|
userMerchantCouponService.insert(userMerchantCoupon);
|
|
MerchantCoupon merchantCoupon = merchantCouponService.selectById(merchantActivitySlave.getMerchantCouponId());
|
MerchantCouponListWarpper merchantCouponListWarpper = new MerchantCouponListWarpper();
|
merchantCouponListWarpper.setId(merchantActivitySlave.getMerchantCouponId());
|
merchantCouponListWarpper.setName(merchantCoupon.getName());
|
merchantCouponListWarpper.setType(merchantCoupon.getType());
|
merchantCouponListWarpper.setFullAmount(merchantCoupon.getFullAmount());
|
merchantCouponListWarpper.setDiscount(merchantCoupon.getDiscount());
|
listWarppers.add(merchantCouponListWarpper);
|
|
merchantActivitySlave.setLaveNumber(merchantActivitySlave.getLaveNumber() - 1);
|
if(merchantActivitySlave.getLaveNumber() == 0){
|
merchantActivity.setStatus(2);
|
}
|
}
|
if(merchantActivitySlaves.size() > 0){
|
merchantActivitySlaveService.updateBatchById(merchantActivitySlaves);
|
}
|
}
|
merchantActivityService.updateBatchById(merchantActivities);
|
}
|
String value = redisUtil.getValue("merchantVoucher");
|
JSONObject jsonObject = JSON.parseObject(value);
|
if(null == jsonObject){
|
jsonObject = new JSONObject();
|
}
|
jsonObject.put(userInfo.getPhone(), listWarppers);
|
redisUtil.setStrValue("merchantVoucher", jsonObject.toJSONString());
|
}
|
|
break;
|
}
|
this.updateById(orderLogistics);
|
|
// TODO: 2020/6/5 推送状态
|
new Thread(new Runnable() {
|
@Override
|
public void run() {
|
pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
|
pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
|
}
|
}).start();
|
return ResultUtil.success();
|
}
|
|
|
@Autowired
|
private ISysWithdrawalPoundageService sysWithdrawalPoundageService;
|
|
@Autowired
|
private ISysTimeoutMoneyService sysTimeoutMoneyService;
|
|
/**
|
* 验证取件码(小件物流)
|
* @param orderId
|
* @param pickUpCode
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public ResultUtil fillInPickUpCode(Integer orderId, String pickUpCode) throws Exception {
|
OrderLogistics orderLogistics = this.selectById(orderId);
|
if(!orderLogistics.getPickUpCode().equals(pickUpCode)){
|
return ResultUtil.error("验证失败");
|
}
|
orderLogistics.setState(9);
|
orderLogistics.setEndServiceTime(DateUtil.parseTime(DateUtil.getTime()));
|
|
/// 超时,扣款订单的%费用
|
SysTimeoutMoney sysTimeoutMoney = sysTimeoutMoneyService.selectOne(null);
|
if(orderLogistics.getArriveTimeExpect()!=null){
|
if (new Date().getTime() > (orderLogistics.getArriveTimeExpect().getTime() + sysTimeoutMoney.getTimeOut())){
|
double timeOutMoney = sysTimeoutMoney.getDeductMoney()*orderLogistics.getOrderMoney()/100;
|
orderLogistics.setTimeOutMoney(timeOutMoney);
|
|
/// 超时扣款扣除司机余额和剩余业务金额
|
Driver driver = driverService.selectById(orderLogistics.getDriverId());
|
driver.setLaveBusinessMoney(driver.getLaveBusinessMoney() - timeOutMoney);
|
driver.setBalance(driver.getBalance() - timeOutMoney);
|
driverService.updateById(driver);
|
|
|
/// 存入平台收入
|
Income income = new Income();
|
income.setIncomeId(orderId);
|
income.setOrderType(orderLogistics.getType());
|
income.setInsertTime(new Date());
|
income.setMoney(timeOutMoney);
|
income.setUserType(1);
|
income.setType(7);
|
income.setObjectId(orderLogistics.getCompanyId());
|
incomeService.insert(income);
|
|
// TODO 司机云闪付 超时扣款 司机电子余额转账到平台
|
// 超时扣款 司机电子余额转账到平台
|
divideAccounts(orderLogistics.getDriverId(),timeOutMoney,orderLogistics.getOrderNum());
|
}
|
}
|
|
this.updateById(orderLogistics);
|
|
return ResultUtil.success();
|
}
|
|
/**
|
* 分账
|
*/
|
private void divideAccounts(Integer driverId,double amount,String orderNum){
|
try{
|
|
// 查询平台开户信息
|
TEnterpriseWithdrawal enterpriseWithdrawal = enterpriseWithdrawalService.selectOne(new EntityWrapper<TEnterpriseWithdrawal>()
|
.eq("companyId", 1)
|
.last("LIMIT 1"));
|
if(Objects.isNull(enterpriseWithdrawal)){
|
throw new RuntimeException("平台开户信息为空");
|
}
|
// 司机开户信息
|
Driver driver = driverService.selectById(driverId);
|
if(Objects.isNull(driver)){
|
throw new RuntimeException("司机信息不存在");
|
}
|
// TODO 司机进件信息
|
UserWithdrawal driverWith = userWithdrawalService.selectOne(new EntityWrapper<UserWithdrawal>()
|
.eq("phone", driver.getPhone())
|
.last("LIMIT 1"));
|
if(Objects.isNull(driverWith)){
|
throw new RuntimeException("司机开户信息为空");
|
}
|
|
AllocationReq allocationReq = new AllocationReq();
|
allocationReq.setOutOrderNo(orderNum);
|
allocationReq.setPayBalanceAcctId(driverWith.getBalanceAcctId()); // 发送方
|
allocationReq.setRecvBalanceAcctId(enterpriseWithdrawal.getBalanceAcctId()); // 接收方
|
BigDecimal multiply = new BigDecimal(100).multiply(BigDecimal.valueOf(amount));
|
allocationReq.setAmount(multiply.intValue()); // 金额
|
allocationReq.setPassword(Base64Util.decode(enterpriseWithdrawal.getTransactionAuthorizationCode())); // 密码
|
allocationReq.setOrderNo(orderNum);
|
allocationReq.setOrderAmount((long) multiply.intValue());
|
allocationReq.setProductName("小件物流超时扣款");
|
allocationReq.setProductCount(1);
|
AllocationResp allocationResp = AllocationExample.create(allocationReq);
|
System.err.println("小件物流超时扣款:"+allocationResp);
|
}catch (UpyztException e){
|
e.printStackTrace();
|
}
|
}
|
|
|
/**
|
* 司机设置补差价金额
|
* @param orderId
|
* @param difference
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public ResultUtil makeUpTheDifference(Integer orderId, Double difference) throws Exception {
|
OrderLogisticsSpread query = orderLogisticsSpreadService.query(orderId);
|
OrderLogistics orderLogistics = this.selectById(orderId);
|
if(orderLogistics.getState() != 4 && orderLogistics.getState() != 8){
|
return ResultUtil.error("不允许设置差价");
|
}
|
if(query != null){
|
query.setPrice(difference);
|
orderLogisticsSpreadService.updateById(query);
|
return ResultUtil.success();
|
}
|
OrderLogisticsSpread orderLogisticsSpread = new OrderLogisticsSpread();
|
orderLogisticsSpread.setOrderLogisticsId(orderId);
|
orderLogisticsSpread.setPrice(difference);
|
orderLogisticsSpreadService.insert(orderLogisticsSpread);
|
orderLogistics.setState(8);
|
this.updateById(orderLogistics);
|
|
new Thread(new Runnable() {
|
@Override
|
public void run() {
|
pushUtil.pushPayDifference(1, orderLogistics.getUserId(), orderId, orderLogistics.getType(), difference);
|
}
|
}).start();
|
return ResultUtil.success();
|
}
|
|
@Override
|
public List<Map<String, Object>> queryOrderList(Integer driverId) throws Exception {
|
return orderLogisticsMapper.queryOrderList(driverId);
|
}
|
|
/**
|
* 获取我的订单列表
|
* @param state 1=全部,2=待支付,3=已取消
|
* @param uid
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public List<Map<String, Object>> queryMyAllOrder(Integer state, Integer uid) throws Exception {
|
return orderLogisticsMapper.queryMyAllOrder(state, uid);
|
}
|
|
|
/**
|
* 抢单操作(车载端)
|
* @param orderId
|
* @param uid
|
* @return
|
* @throws Exception
|
*/
|
@Override
|
public synchronized ResultUtil grabOrder_(Integer orderId, Integer uid) throws Exception {
|
OrderLogistics orderLogistics = this.selectById(orderId);
|
if(orderLogistics.getState() == 10){
|
return ResultUtil.error("订单已取消");
|
}
|
if(orderLogistics.getState() != 1){
|
return ResultUtil.error("手速有点慢哦,订单已被抢啦!");
|
}
|
Driver driver = driverService.selectById(uid);
|
orderLogistics.setDriverId(uid);
|
orderLogistics.setCarId(driver.getCarId());
|
orderLogistics.setCompanyId(driver.getFranchiseeId() != null && driver.getFranchiseeId() != 0 ? driver.getFranchiseeId() : (
|
driver.getCompanyId() != null && driver.getCompanyId() != 0 ? driver.getCompanyId() : 1));
|
orderLogistics.setState(2);
|
Date date = new Date();
|
orderLogistics.setSnatchOrderTime(date);
|
orderLogistics.setSetOutTime(date);
|
orderLogistics.setArriveTime(date);
|
orderLogistics.setStartServiceTime(date);
|
orderLogistics.setBoardingTime(date);
|
|
String value = redisUtil.getValue("DRIVER" + uid);
|
if(ToolUtil.isNotEmpty(value)){
|
String[] split = value.split(",");
|
Map<String, String> geocode1 = gdMapGeocodingUtil.geocode(split[0], split[1]);
|
orderLogistics.setBoardingAddress(geocode1.get("address"));
|
orderLogistics.setBoardingLon(Double.valueOf(split[0]));
|
orderLogistics.setBoardingLat(Double.valueOf(split[1]));
|
}
|
|
//调用高德创建轨迹
|
String s = gdFalconUtil.selectTerminal(driver.getPhone());
|
String track = gdFalconUtil.createTrack(s);
|
orderLogistics.setTrackId(track);
|
|
//调用移动的小号接口 TODO 车载端使用真实号码
|
// Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderTaxi.getStartLon().toString(), orderTaxi.getStartLat().toString());
|
// Region region = regionMapper.query(geocode.get("districtCode"));
|
// Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderTaxi.getPassengersPhone(), driver.getPhone(), Integer.valueOf(region.getCitycode().substring(1)));
|
//// if(String.valueOf(map.get("code")).equals("200")){
|
//// orderTaxi.setTelX(map.get("telX"));
|
//// orderTaxi.setBindId(map.get("bindId"));
|
//// }
|
|
this.updateById(orderLogistics);
|
|
//推送相关代码------------------start----------------
|
new Thread(new Runnable() {
|
@Override
|
public void run() {
|
pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
|
pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState());
|
}
|
}).start();
|
|
// TODO: 2023/11/4 小件物流无服务中页面
|
// new Thread(new Runnable() {
|
// @Override
|
// public void run() {
|
// pushUtil.pushDriverPosition(orderId, orderLogistics.getType());
|
// }
|
// }).start();
|
|
systemNoticeService.addSystemNotice(2, "您已成功抢得出租车订单,请及时联系客户!", orderLogistics.getDriverId(), 1);
|
systemNoticeService.addSystemNotice(1, "您的订单已指派给" + driver.getName().substring(0, 1) + "师傅,请保持电话畅通!", orderLogistics.getUserId(), 1);
|
|
return ResultUtil.success();
|
}
|
|
@Override
|
public List<OrderLogistics> query(Integer driverId, Integer... state) throws Exception {
|
return orderLogisticsMapper.query(Arrays.asList(state), driverId);
|
}
|
|
@Override
|
public void sendVerificationCode(Integer orderId) throws Exception {
|
// OrderLogistics orderLogistics = this.selectById(orderId);
|
// String random = "";
|
// for(int i = 0; i < 6; i++){
|
// random += Double.valueOf(Math.random() * 10).intValue();
|
// }
|
// orderLogistics.setPickUpCode(random);
|
// this.updateById(orderLogistics);
|
//发送短信
|
// aLiSendSms.sendSms(orderLogistics.getRecipientPhone(), "SMS_229715276", "{\"code\":\"" + random + "\"}");
|
}
|
|
@Override
|
public List<OrderLogistics> queryMaturity() throws Exception {
|
return orderLogisticsMapper.queryMaturity();
|
}
|
|
@Override
|
public List<OrderLogistics> taskMidAxbUnBindSend() throws Exception {
|
return this.baseMapper.taskMidAxbUnBindSend();
|
}
|
}
|