|
|
@@ -10,12 +10,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import shop.alien.config.properties.RiskControlProperties;
|
|
|
import shop.alien.entity.result.BusinessException;
|
|
|
import shop.alien.entity.second.*;
|
|
|
+import shop.alien.entity.second.vo.SecondEntrustUserDTO;
|
|
|
import shop.alien.mapper.second.SecondRiskControlRecordMapper;
|
|
|
import shop.alien.entity.second.vo.SecondTradeRecordVo;
|
|
|
import shop.alien.entity.second.vo.SellerEvaluationVo;
|
|
|
@@ -68,11 +70,14 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
|
|
|
@Autowired
|
|
|
private RiskControlProperties riskControlProperties;
|
|
|
|
|
|
+ // 委托人信息
|
|
|
+ private final SecondEntrustUserMapper secondEntrustUserMapper;
|
|
|
+
|
|
|
private final Object lock = new Object();
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public boolean createTrade(SecondTradeRecord trade) throws Exception {
|
|
|
+ public boolean createTrade(SecondEntrustUserDTO trade) throws Exception {
|
|
|
try {
|
|
|
synchronized (lock) {
|
|
|
LocalDate now = LocalDate.now();
|
|
|
@@ -109,6 +114,16 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
|
|
|
// 查询商品
|
|
|
goods = secondGoodsMapper.selectById(trade.getGoodsId());
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(trade.getEntrustUserPhone()) && StringUtils.isNotBlank(trade.getEntrustUserName()) && StringUtils.isNotBlank(trade.getEntrustIdCard())) {
|
|
|
+ // 添加商家委托信息
|
|
|
+ SecondEntrustUser secondEntrustUser = new SecondEntrustUser();
|
|
|
+ secondEntrustUser.setEntrustTradeId(trade.getId());
|
|
|
+ secondEntrustUser.setEntrustUserPhone(trade.getEntrustUserPhone());
|
|
|
+ secondEntrustUser.setEntrustUserName(trade.getEntrustUserName());
|
|
|
+ secondEntrustUser.setEntrustIdCard(trade.getEntrustIdCard());
|
|
|
+ secondEntrustUserMapper.insert(secondEntrustUser);
|
|
|
+ }
|
|
|
+
|
|
|
// 发送消息
|
|
|
sendMsg(goods, trade, 1, "4");
|
|
|
|
|
|
@@ -140,6 +155,18 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
|
|
|
message.put("transactionLocation", trade.getTransactionLocation());
|
|
|
message.put("transactionTime", trade.getTransactionTime());
|
|
|
message.put("tradeStatus", tradeStatus);
|
|
|
+
|
|
|
+ // 查询商家委托信息
|
|
|
+ LambdaQueryWrapper<SecondEntrustUser> entrustWrapper = new LambdaQueryWrapper<>();
|
|
|
+ entrustWrapper.eq(SecondEntrustUser::getEntrustTradeId, trade.getId());
|
|
|
+ SecondEntrustUser entrustUser = secondEntrustUserMapper.selectOne(entrustWrapper);
|
|
|
+ if ( entrustUser != null ) {
|
|
|
+ message.put("entrustId", entrustUser.getId());
|
|
|
+ message.put("entrustUserPhone", entrustUser.getEntrustUserPhone());
|
|
|
+ message.put("entrustUserName", entrustUser.getEntrustUserName());
|
|
|
+ message.put("entrustIdCard", entrustUser.getEntrustIdCard());
|
|
|
+ }
|
|
|
+
|
|
|
if (6 == tradeStatus) {
|
|
|
message.put("cancelUserId", trade.getCancelUserId());
|
|
|
message.put("cancelReason", trade.getCancelReason());
|
|
|
@@ -601,7 +628,8 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public boolean modifyTradeRecord(int type, Integer tradeId, String transactionTime, String transactionLatitudeLongitude, String transactionLatitudeLongitudeAddress, String transactionLocation, String messageId) throws Exception {
|
|
|
+ public boolean modifyTradeRecord(int type, Integer tradeId, String transactionTime, String transactionLatitudeLongitude, String transactionLatitudeLongitudeAddress, String transactionLocation, String messageId,
|
|
|
+ String userPhone, String userName, String idCard, Integer entrustId) throws Exception {
|
|
|
try {
|
|
|
if (type == 1) {
|
|
|
LambdaUpdateWrapper<SecondTradeRecord> wrapper = new LambdaUpdateWrapper<>();
|
|
|
@@ -642,6 +670,18 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
|
|
|
LifeUser lifeUser = lifeUserMapper.selectById(Objects.equals(userId, trade.getBuyerId()) ? trade.getSellerId() : trade.getBuyerId());
|
|
|
String receiverId = "user_" + lifeUser.getUserPhone();
|
|
|
|
|
|
+ if (entrustId != null) {
|
|
|
+ // 添加商家委托信息
|
|
|
+ SecondEntrustUser secondEntrustUser = new SecondEntrustUser();
|
|
|
+ secondEntrustUser.setId(entrustId);
|
|
|
+ secondEntrustUser.setEntrustTradeId(tradeId);
|
|
|
+ secondEntrustUser.setEntrustUserPhone(userPhone);
|
|
|
+ secondEntrustUser.setEntrustUserName(userName);
|
|
|
+ secondEntrustUser.setEntrustIdCard(idCard);
|
|
|
+ secondEntrustUserMapper.updateById(secondEntrustUser);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
// 给买家与卖家发送交易消息
|
|
|
WebSocketVo webSocketVo = new WebSocketVo();
|
|
|
webSocketVo.setSenderId(phoneId);
|