|
@@ -25,6 +25,7 @@ import com.sqx.modules.common.service.CommonInfoService;
|
|
|
import com.sqx.modules.errand.dao.ErrandEvaluateDao;
|
|
import com.sqx.modules.errand.dao.ErrandEvaluateDao;
|
|
|
import com.sqx.modules.errand.dao.TbIndentDao;
|
|
import com.sqx.modules.errand.dao.TbIndentDao;
|
|
|
import com.sqx.modules.errand.dto.RiderDeliveryDTO;
|
|
import com.sqx.modules.errand.dto.RiderDeliveryDTO;
|
|
|
|
|
+import com.sqx.modules.errand.dto.RiderTransferOrderDTO;
|
|
|
import com.sqx.modules.errand.dto.WaitForAcceptOrderQueryDTO;
|
|
import com.sqx.modules.errand.dto.WaitForAcceptOrderQueryDTO;
|
|
|
import com.sqx.modules.errand.entity.ErrandAddress;
|
|
import com.sqx.modules.errand.entity.ErrandAddress;
|
|
|
import com.sqx.modules.errand.entity.ErrandEvaluate;
|
|
import com.sqx.modules.errand.entity.ErrandEvaluate;
|
|
@@ -795,6 +796,22 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
return tbIndent;
|
|
return tbIndent;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void transferOfOrder(Long userId, RiderTransferOrderDTO transferOrderDTO) {
|
|
|
|
|
+ // 获取待转单
|
|
|
|
|
+ TbIndent indent = getTransferOrder(userId, transferOrderDTO);
|
|
|
|
|
+
|
|
|
|
|
+ // 获取新的骑手
|
|
|
|
|
+ UserEntity userEntity = getNewRicher(userId, transferOrderDTO);
|
|
|
|
|
+
|
|
|
|
|
+ // 开始转单
|
|
|
|
|
+ indent.setRiderUserId(userEntity.getUserId());
|
|
|
|
|
+ indent.setIsRider(1);
|
|
|
|
|
+ updateById(indent);
|
|
|
|
|
+
|
|
|
|
|
+ // 消息通知
|
|
|
|
|
+ noticeAfterTransfer(indent);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
|
@Override
|
|
@Override
|
|
@@ -1332,7 +1349,103 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
return Result.success().put("data", indent1);
|
|
return Result.success().put("data", indent1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 转单后通知
|
|
|
|
|
+ * @param indent
|
|
|
|
|
+ */
|
|
|
|
|
+ private void noticeAfterTransfer(TbIndent indent) {
|
|
|
|
|
+ CommonInfo one = commonInfoService.findOne(335);
|
|
|
|
|
+ UserEntity user = userService.getById(indent.getUserId());
|
|
|
|
|
+ List<String> msgList=new ArrayList<>();
|
|
|
|
|
+ msgList.add(0, indent.getIndentNumber());
|
|
|
|
|
+ String indentState = indent.getIndentState();
|
|
|
|
|
+ if("3".equals(indentState)){
|
|
|
|
|
+ msgList.add(1,"已接单");
|
|
|
|
|
+ }else if("4".equals(indentState)){
|
|
|
|
|
+ msgList.add(1,"已取货");
|
|
|
|
|
+ }else{
|
|
|
|
|
+ msgList.add(1,"进行中");
|
|
|
|
|
+ }
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(org.apache.commons.lang.StringUtils.isNotEmpty(user.getOpenId())){
|
|
|
|
|
+ userService.pushToSingle("更换骑手","骑手已更换,新骑手将尽快为您送达", user.getClientid());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取待转单配送单
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param currentUserId 当前用户
|
|
|
|
|
+ * @param transferOrderDTO
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private TbIndent getTransferOrder(Long currentUserId, RiderTransferOrderDTO transferOrderDTO) {
|
|
|
|
|
+ // 开始转单
|
|
|
|
|
+ TbIndent indent = getById(transferOrderDTO.getIndentId());
|
|
|
|
|
+ if (ObjectUtil.isNull(indent)) {
|
|
|
|
|
+ throw new SqxException("无效的配送单id");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (indent.getRiderUserId() != currentUserId) {
|
|
|
|
|
+ throw new SqxException("不能操作非自己的订单");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(!"3".equals(indent.getIndentState())){
|
|
|
|
|
+ throw new SqxException("订单状态发生变更,请刷新后重试!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return indent;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取新骑手
|
|
|
|
|
+ * @param currentUserId 当前用户id
|
|
|
|
|
+ * @param transferOrderDTO dto
|
|
|
|
|
+ * @return 新骑手
|
|
|
|
|
+ */
|
|
|
|
|
+ private UserEntity getNewRicher(Long currentUserId, RiderTransferOrderDTO transferOrderDTO) {
|
|
|
|
|
+ String phone = transferOrderDTO.getPhone();
|
|
|
|
|
+ String realName = transferOrderDTO.getRealName();
|
|
|
|
|
+
|
|
|
|
|
+ UserEntity userEntity = null;
|
|
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotBlank(phone)) {
|
|
|
|
|
+ userEntity = userService.queryByPhone(phone);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ List<UserEntity> userEntities = userService.queryByRealName(realName);
|
|
|
|
|
+ if (userEntities.size() > 1) {
|
|
|
|
|
+ throw new SqxException("根据姓名查到了多个骑手,其输入手机号码精确查询");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (userEntities.size() == 1) {
|
|
|
|
|
+ userEntity = userEntities.get(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(userEntity == null){
|
|
|
|
|
+ throw new SqxException("用户不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (currentUserId == userEntity.getUserId()) {
|
|
|
|
|
+ throw new SqxException("不能转单给自己!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 校验当前骑手实名认证、保证金等信息
|
|
|
|
|
+ CommonInfo one1 = commonInfoService.findOne(273);
|
|
|
|
|
+ Double cashDeposit = Double.parseDouble(one1.getValue());
|
|
|
|
|
+ if(!"1".equals(userEntity.getCheckCertification())){
|
|
|
|
|
+ throw new SqxException("骑手未进行实名认证!");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ if(userEntity.getCashDeposit().doubleValue() < cashDeposit){
|
|
|
|
|
+ throw new SqxException("骑手保证金不足!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return userEntity;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|