|
|
@@ -194,20 +194,22 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
|
|
|
try {
|
|
|
// 交易信息
|
|
|
SecondTradeRecord trade = secondTradeRecordMapper.selectById(tradeId);
|
|
|
- if (trade.getTradeStatus() == 6) throw new BusinessException("该交易已取消,不可操作");
|
|
|
|
|
|
- // 修改交易状态
|
|
|
- SecondTradeRecord tradeRecord = new SecondTradeRecord();
|
|
|
- tradeRecord.setId(tradeId);
|
|
|
- tradeRecord.setTradeStatus(type == 1 ? 3 : 2);
|
|
|
- secondTradeRecordMapper.updateById(tradeRecord);
|
|
|
-
|
|
|
- // 保存交易操作表
|
|
|
- SecondTradeOperation operation = new SecondTradeOperation();
|
|
|
- operation.setTradeId(trade.getId());
|
|
|
- operation.setUserId(Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getInteger("userId"));
|
|
|
- operation.setType(type == 1 ? 3 : 2);
|
|
|
- secondTradeOperationMapper.insert(operation);
|
|
|
+ // 有定时任务: 超过交易时间还未确认的交易会自动取消并保存交易操作表 所以如果是已取消的交易 不需要进行这两步操作
|
|
|
+ if (trade.getTradeStatus() != 6) {
|
|
|
+ // 修改交易状态
|
|
|
+ SecondTradeRecord tradeRecord = new SecondTradeRecord();
|
|
|
+ tradeRecord.setId(tradeId);
|
|
|
+ tradeRecord.setTradeStatus(type == 1 ? 3 : 2);
|
|
|
+ secondTradeRecordMapper.updateById(tradeRecord);
|
|
|
+
|
|
|
+ // 保存交易操作表
|
|
|
+ SecondTradeOperation operation = new SecondTradeOperation();
|
|
|
+ operation.setTradeId(trade.getId());
|
|
|
+ operation.setUserId(Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getInteger("userId"));
|
|
|
+ operation.setType(type == 1 ? 3 : 2);
|
|
|
+ secondTradeOperationMapper.insert(operation);
|
|
|
+ }
|
|
|
|
|
|
// 商品信息
|
|
|
SecondGoods goods = secondGoodsMapper.selectById(trade.getGoodsId());
|
|
|
@@ -217,15 +219,18 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
|
|
|
|
|
|
JSONObject lastMessageContent = JSONObject.parseObject(lastMessage.getContent());
|
|
|
lastMessageContent.put("messageId", lastMessage.getId());
|
|
|
- lastMessageContent.put("tradeStatus", type == 1 ? 3 : 2);
|
|
|
+ lastMessageContent.put("tradeStatus", trade.getTradeStatus() == 6 ? 6 : (type == 1 ? 3 : 2));
|
|
|
LifeMessage message = new LifeMessage();
|
|
|
message.setId(lastMessage.getId());
|
|
|
message.setContent(lastMessageContent.toJSONString());
|
|
|
lifeMessageMapper.updateById(message);
|
|
|
|
|
|
- // 发送消息
|
|
|
- trade.setTradeStatus(type == 1 ? 3 : 2);
|
|
|
- sendMsg(goods, trade, trade.getTradeStatus(), "4");
|
|
|
+ // 如果交易已取消 不需要发送消息
|
|
|
+ if (trade.getTradeStatus() != 6) {
|
|
|
+ // 发送消息
|
|
|
+ trade.setTradeStatus(type == 1 ? 3 : 2);
|
|
|
+ sendMsg(goods, trade, trade.getTradeStatus(), "4");
|
|
|
+ }
|
|
|
|
|
|
// 发起交易人信息
|
|
|
Integer userId = Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getInteger("userId");
|
|
|
@@ -248,6 +253,11 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
|
|
|
alienStoreFeign.sendMsgToClientByPhoneId(phoneId, JSONObject.from(webSocketVo).toJSONString());
|
|
|
alienStoreFeign.sendMsgToClientByPhoneId(receiverId, JSONObject.from(webSocketVo).toJSONString());
|
|
|
|
|
|
+ // 交易已取消
|
|
|
+ if (trade.getTradeStatus() == 6 ) {
|
|
|
+ throw new BusinessException("该交易已取消,不可操作");
|
|
|
+ }
|
|
|
+
|
|
|
// 创建交易时间小于十分钟,直接发送交易提醒
|
|
|
if (1 == type && Math.abs(Duration.between(Instant.now(), trade.getTransactionTime().toInstant()).getSeconds()) < 600) {
|
|
|
sendSignInMessage(trade);
|