|
@@ -1,6 +1,9 @@
|
|
|
package com.sqx.modules.order.service.impl;
|
|
package com.sqx.modules.order.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -10,6 +13,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.sqx.common.exception.SqxException;
|
|
import com.sqx.common.exception.SqxException;
|
|
|
|
|
+import com.sqx.common.sms.SmsSendResult;
|
|
|
|
|
+import com.sqx.common.utils.Constant;
|
|
|
import com.sqx.common.utils.DateUtils;
|
|
import com.sqx.common.utils.DateUtils;
|
|
|
import com.sqx.common.utils.DistanceUtil;
|
|
import com.sqx.common.utils.DistanceUtil;
|
|
|
import com.sqx.common.utils.PageUtils;
|
|
import com.sqx.common.utils.PageUtils;
|
|
@@ -48,6 +53,7 @@ import com.sqx.modules.message.entity.MessageInfo;
|
|
|
import com.sqx.modules.order.dao.AppOrderDao;
|
|
import com.sqx.modules.order.dao.AppOrderDao;
|
|
|
import com.sqx.modules.order.dao.EvaluateDao;
|
|
import com.sqx.modules.order.dao.EvaluateDao;
|
|
|
import com.sqx.modules.order.dao.OrderGoodsDao;
|
|
import com.sqx.modules.order.dao.OrderGoodsDao;
|
|
|
|
|
+import com.sqx.modules.order.dto.OrderFinishByShopDTO;
|
|
|
import com.sqx.modules.order.entity.Evaluate;
|
|
import com.sqx.modules.order.entity.Evaluate;
|
|
|
import com.sqx.modules.order.entity.OrderGoods;
|
|
import com.sqx.modules.order.entity.OrderGoods;
|
|
|
import com.sqx.modules.order.entity.TbOrder;
|
|
import com.sqx.modules.order.entity.TbOrder;
|
|
@@ -58,11 +64,14 @@ import com.sqx.modules.pay.entity.PayDetails;
|
|
|
import com.sqx.modules.pay.service.WxErrService;
|
|
import com.sqx.modules.pay.service.WxErrService;
|
|
|
import com.sqx.modules.shop.service.ShopMessageService;
|
|
import com.sqx.modules.shop.service.ShopMessageService;
|
|
|
import com.sqx.modules.sys.dao.SysUserRoleDao;
|
|
import com.sqx.modules.sys.dao.SysUserRoleDao;
|
|
|
|
|
+import com.sqx.modules.sys.entity.SysUserEntity;
|
|
|
|
|
+import com.sqx.modules.sys.service.SysUserService;
|
|
|
import com.sqx.modules.utils.SenInfoCheckUtil;
|
|
import com.sqx.modules.utils.SenInfoCheckUtil;
|
|
|
import com.sqx.modules.utils.excel.ExcelData;
|
|
import com.sqx.modules.utils.excel.ExcelData;
|
|
|
import com.sqx.modules.utils.fieYun.FeiYunUtils;
|
|
import com.sqx.modules.utils.fieYun.FeiYunUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
@@ -140,6 +149,13 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ActivityPartRecordService activityPartRecordService;
|
|
private ActivityPartRecordService activityPartRecordService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SysUserService sysUserService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private TbIndentSmsSendLogService smsSendLogService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private TbIndentSmsTemplateService smsTemplateService;
|
|
|
|
|
+
|
|
|
private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(true);
|
|
private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(true);
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -504,6 +520,69 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ public void finishOrderByShop(OrderFinishByShopDTO orderFinishByShopDTO) {
|
|
|
|
|
+ Long orderId = orderFinishByShopDTO.getOrderId();
|
|
|
|
|
+ TbOrder order = getById(orderId);
|
|
|
|
|
+
|
|
|
|
|
+ if (ObjectUtil.isNull(order)) {
|
|
|
|
|
+ throw new SqxException("无效的订单id");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(order.getAutoSendOrder()!=null && order.getAutoSendOrder()==1){
|
|
|
|
|
+ throw new SqxException("当前订单为自动派单,不能手动完成!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (order.getStatus().equals(4)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Long shopId = order.getShopId();
|
|
|
|
|
+ SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
|
+ List<SysUserShop> sysUserShops = sysUserService.selectShopId(currentUser.getUserId());
|
|
|
|
|
+ if (CollUtil.isEmpty(sysUserShops) || !sysUserShops.stream().filter(e -> e.getShopId().longValue() == shopId.longValue()).findFirst().isPresent()) {
|
|
|
|
|
+ throw new SqxException("没有操作权限,只能操作完成自己店铺订单!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (Constant.YES.equals(orderFinishByShopDTO.getSendSmsFlag())) {
|
|
|
|
|
+ TbIndent indent = tbIndentService.getOne(new QueryWrapper<TbIndent>().eq("order_id", orderId));
|
|
|
|
|
+ if (ObjectUtil.isNull(indent)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果是外卖订单
|
|
|
|
|
+ if (ObjectUtil.equal(indent.getIndentType(), "5")) {
|
|
|
|
|
+ Long smsTemplateId = orderFinishByShopDTO.getSmsTemplateId();
|
|
|
|
|
+ if (ObjectUtil.isNull(smsTemplateId)) {
|
|
|
|
|
+ throw new SqxException("短信模板id不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 收货人手机
|
|
|
|
|
+ String userPhone = indent.getUserPhone();
|
|
|
|
|
+
|
|
|
|
|
+ if (StrUtil.isBlank(userPhone)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 店铺信息
|
|
|
|
|
+ GoodsShop goodsShop = goodsShopDao.selectById(shopId);
|
|
|
|
|
+
|
|
|
|
|
+ // 发送短信并记录短信发送记录
|
|
|
|
|
+ SmsSendResult smsSendResult = smsTemplateService.sendSms(smsTemplateId, goodsShop.getPhone(), goodsShop.getShopName(), goodsShop.getShopId(), userPhone);
|
|
|
|
|
+
|
|
|
|
|
+ // sourceType 1骑手、2商家
|
|
|
|
|
+ smsSendLogService.saveLog(indent.getIndentId(), "2", smsSendResult);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (StrUtil.isNotBlank(orderFinishByShopDTO.getImgs())) {
|
|
|
|
|
+ order.setDeliveryImgs(orderFinishByShopDTO.getImgs());
|
|
|
|
|
+ updateById(order);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ accomplishOrder(orderId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
public List<OrderGoods> getOrderGoods(Long orderId) {
|
|
public List<OrderGoods> getOrderGoods(Long orderId) {
|
|
|
return orderGoodsDao.selectList(new QueryWrapper<OrderGoods>().eq("order_id", orderId));
|
|
return orderGoodsDao.selectList(new QueryWrapper<OrderGoods>().eq("order_id", orderId));
|
|
|
}
|
|
}
|