|
|
@@ -12,6 +12,7 @@ import com.sqx.common.constant.RedisKey;
|
|
|
import com.sqx.common.exception.SqxException;
|
|
|
import com.sqx.common.sms.SmsSendResult;
|
|
|
import com.sqx.common.utils.DateUtils;
|
|
|
+import com.sqx.common.utils.MyGlobalThreadPool;
|
|
|
import com.sqx.common.utils.PageUtils;
|
|
|
import com.sqx.common.utils.Result;
|
|
|
import com.sqx.modules.address.dao.AddressDao;
|
|
|
@@ -690,8 +691,22 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
msgList.add(userEntity1.getNickName());
|
|
|
msgList.add(format);
|
|
|
msgList.add("接单成功,请及时取货!");
|
|
|
- SenInfoCheckUtil.sendRiderMsg(userEntity1.getRiderOpenId(), five.getValue(), msgList, 4);
|
|
|
- userService.pushToSingleRider("接单成功", "您已接单成功,请及时派送", userEntity1.getRiderClientid());
|
|
|
+
|
|
|
+ MyGlobalThreadPool.execute(() -> {
|
|
|
+ try {
|
|
|
+ SenInfoCheckUtil.sendRiderMsg(userEntity1.getRiderOpenId(), five.getValue(), msgList, 4);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("订单:{},您已接单成功,请及时派送通知发送失败,失败原因:{}", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ MyGlobalThreadPool.execute(() -> {
|
|
|
+ try {
|
|
|
+ userService.pushToSingleRider("接单成功", "您已接单成功,请及时派送", userEntity1.getRiderClientid());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("订单:{},您已接单成功,请及时派送通知发送失败,失败原因:{}", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
//用户推送
|
|
|
CommonInfo msg = commonInfoService.findOne(269);
|
|
|
@@ -723,7 +738,15 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
msgListUser.add(value);
|
|
|
}
|
|
|
msgListUser.add(DateUtils.format(new Date()));
|
|
|
- SenInfoCheckUtil.sendMsg(userEntity.getOpenId(), msg.getValue(), msgListUser, 1);
|
|
|
+
|
|
|
+ MyGlobalThreadPool.execute(() -> {
|
|
|
+ try {
|
|
|
+ SenInfoCheckUtil.sendMsg(userEntity.getOpenId(), msg.getValue(), msgListUser, 1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("订单:{},订单接单成功通知发送失败,失败原因:{}", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
if (tbIndent.getOrderId() != null) {
|
|
|
TbOrder order = appOrderService.getById(tbIndent.getOrderId());
|
|
|
String shopTemplate = commonInfoService.findOne(354).getValue();
|
|
|
@@ -735,7 +758,15 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
log.error("打印:" + msgListShop.toString());
|
|
|
GoodsShop goodsShop = goodsShopDao.selectById(order.getShopId());
|
|
|
UserEntity shopUser = userService.selectUserById(goodsShop.getUserId());
|
|
|
- SenInfoCheckUtil.sendShopMsg(shopUser.getShopOpenId(), shopTemplate, msgListShop, 9);
|
|
|
+
|
|
|
+ MyGlobalThreadPool.execute(() -> {
|
|
|
+ try {
|
|
|
+ SenInfoCheckUtil.sendShopMsg(shopUser.getShopOpenId(), shopTemplate, msgListShop, 9);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("订单:{},订单支付成功通知发送失败,失败原因:{}", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
} else {
|
|
|
return Result.error("你的保证金不足,请缴纳保证金后再接单");
|
|
|
@@ -767,13 +798,20 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
}
|
|
|
TbIndent tbIndent = tbIndentDao.findIndentByOrderId(acquireCode);
|
|
|
log.error("抢单:" + userId + " " + tbIndent.getIndentState());
|
|
|
+ RLock lock = redissonClient.getLock(String.format(RedisKey.UPDATE_INDENT_LOCK, tbIndent.getIndentNumber()));
|
|
|
+ lock.lock();
|
|
|
+ try {
|
|
|
// if(!"2".equals(tbIndent.getIndentState())){
|
|
|
// return Result.error("订单已被抢走!");
|
|
|
// }
|
|
|
- if ("5".equals(tbIndent.getIndentType())) {
|
|
|
- if ("2".equals(tbIndent.getIndentState()) || "3".equals(tbIndent.getIndentState())) {
|
|
|
- tbIndentDao.orderIndentReceiv(userId, acquireCode, format, "4");
|
|
|
+ if ("5".equals(tbIndent.getIndentType())) {
|
|
|
+ if ("2".equals(tbIndent.getIndentState()) || "3".equals(tbIndent.getIndentState())) {
|
|
|
+ tbIndentDao.orderIndentReceiv(userId, acquireCode, format, "4");
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ } finally {
|
|
|
+ lock.unlock();
|
|
|
}
|
|
|
//消息推送(以前写的在下面放着)
|
|
|
CommonInfo five = commonInfoService.findOne(310);
|
|
|
@@ -782,9 +820,21 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
msgList.add(userEntity1.getNickName());
|
|
|
msgList.add(format);
|
|
|
msgList.add("接单成功,请及时取货!");
|
|
|
- SenInfoCheckUtil.sendRiderMsg(userEntity1.getRiderOpenId(), five.getValue(), msgList, 4);
|
|
|
- userService.pushToSingleRider("接单成功", "您已接单成功,请及时派送", userEntity1.getRiderClientid());
|
|
|
+ MyGlobalThreadPool.execute(() -> {
|
|
|
+ try {
|
|
|
+ SenInfoCheckUtil.sendRiderMsg(userEntity1.getRiderOpenId(), five.getValue(), msgList, 4);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("订单:{},接单成功通知发送失败,失败原因:{}", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
+ MyGlobalThreadPool.execute(() -> {
|
|
|
+ try {
|
|
|
+ userService.pushToSingleRider("接单成功", "您已接单成功,请及时派送", userEntity1.getRiderClientid());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("订单:{},您已接单成功,请及时派送通知发送失败,失败原因:{}", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
//用户推送
|
|
|
CommonInfo msg = commonInfoService.findOne(269);
|
|
|
UserEntity userEntity = userService.selectUserById(tbIndent.getUserId());
|
|
|
@@ -816,7 +866,15 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
msgListUser.add(value);
|
|
|
}
|
|
|
msgListUser.add(DateUtils.format(new Date()));
|
|
|
- SenInfoCheckUtil.sendMsg(userEntity.getOpenId(), msg.getValue(), msgListUser, 1);
|
|
|
+
|
|
|
+ MyGlobalThreadPool.execute(() -> {
|
|
|
+ try {
|
|
|
+ SenInfoCheckUtil.sendMsg(userEntity.getOpenId(), msg.getValue(), msgListUser, 1);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("订单:{},订单支付成功通知发送失败,失败原因:{}", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
if (tbIndent.getOrderId() != null) {
|
|
|
TbOrder order = appOrderService.getById(tbIndent.getOrderId());
|
|
|
String shopTemplate = commonInfoService.findOne(354).getValue();
|
|
|
@@ -828,7 +886,15 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
log.error("打印:" + msgListShop.toString());
|
|
|
GoodsShop goodsShop = goodsShopDao.selectById(order.getShopId());
|
|
|
UserEntity shopUser = userService.selectUserById(goodsShop.getUserId());
|
|
|
- SenInfoCheckUtil.sendShopMsg(shopUser.getShopOpenId(), shopTemplate, msgListShop, 9);
|
|
|
+
|
|
|
+ MyGlobalThreadPool.execute(() -> {
|
|
|
+ try {
|
|
|
+ SenInfoCheckUtil.sendShopMsg(shopUser.getShopOpenId(), shopTemplate, msgListShop, 9);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("订单:{},订单支付成功通知发送失败,失败原因:{}", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
} else {
|
|
|
return Result.error("你的保证金不足,请缴纳保证金后再接单");
|
|
|
@@ -1034,11 +1100,17 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
// TbOrder tbOrder = appOrderService.getById(indentOrder.getOrderId());
|
|
|
// tbOrder.setDeliveryImgs(imgs);
|
|
|
// appOrderService.updateById(tbOrder);
|
|
|
+ MyGlobalThreadPool.execute(() -> {
|
|
|
+ try {
|
|
|
+ // 发送短信并记录短信发送记录
|
|
|
+ SmsSendResult smsSendResult = smsTemplateService.sendSms(smsTemplateId, riderUser, userPhone);
|
|
|
+ // sourceType 1骑手、2商家
|
|
|
+ smsSendLogService.saveLog(indentOrder.getIndentId(), "1", smsSendResult);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("订单:{},完成跑腿订单成功通知发送失败,失败原因:{}", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- // 发送短信并记录短信发送记录
|
|
|
- SmsSendResult smsSendResult = smsTemplateService.sendSms(smsTemplateId, riderUser, userPhone);
|
|
|
- // sourceType 1骑手、2商家
|
|
|
- smsSendLogService.saveLog(indentOrder.getIndentId(), "1", smsSendResult);
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
@@ -1323,7 +1395,14 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
msgList.add("已完成");
|
|
|
msgList.add(DateUtils.format(new Date()));
|
|
|
UserEntity riderUser = userService.selectUserById(tbIndent.getRiderUserId());
|
|
|
- SenInfoCheckUtil.sendRiderMsg(riderUser.getRiderOpenId(), riderTemplate, msgList, 2);
|
|
|
+ MyGlobalThreadPool.execute(() -> {
|
|
|
+ try {
|
|
|
+ SenInfoCheckUtil.sendRiderMsg(riderUser.getRiderOpenId(), riderTemplate, msgList, 2);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("订单:{},订单支付成功通知发送失败,失败原因:{}", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1631,11 +1710,25 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
msgList.add(2, "骑手已更换,新骑手将尽快为您送达");
|
|
|
msgList.add(3, DateUtils.format(new Date()));
|
|
|
if (org.apache.commons.lang.StringUtils.isNotEmpty(user.getOpenId())) {
|
|
|
- SenInfoCheckUtil.sendMsg(user.getOpenId(), one.getValue(), msgList, 5);
|
|
|
+ MyGlobalThreadPool.execute(() -> {
|
|
|
+ try {
|
|
|
+ SenInfoCheckUtil.sendMsg(user.getOpenId(), one.getValue(), msgList, 5);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("订单:{},转单成功通知发送失败,失败原因:{}", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
if (org.apache.commons.lang.StringUtils.isNotEmpty(user.getOpenId())) {
|
|
|
- userService.pushToSingle("更换骑手", "骑手已更换,新骑手将尽快为您送达", user.getClientid());
|
|
|
+ MyGlobalThreadPool.execute(() -> {
|
|
|
+ try {
|
|
|
+ userService.pushToSingle("更换骑手", "骑手已更换,新骑手将尽快为您送达", user.getClientid());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("订单:{},骑手已更换通知发送失败,失败原因:{}", e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1711,7 +1804,7 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageUtils selectIndentPage(Integer page, Integer limit, String acquireCode,Long userId) {
|
|
|
+ public PageUtils selectIndentPage(Integer page, Integer limit, String acquireCode, Long userId) {
|
|
|
List<Integer> states = new ArrayList<>();
|
|
|
states.add(2);
|
|
|
states.add(3);
|