|
@@ -12,9 +12,11 @@ import shop.alien.entity.second.SecondTradeRecord;
|
|
|
import shop.alien.entity.second.vo.SecondTradeRecordVo;
|
|
|
import shop.alien.entity.store.LifeMessage;
|
|
|
import shop.alien.entity.store.LifeUser;
|
|
|
+import shop.alien.entity.store.StoreDictionary;
|
|
|
import shop.alien.entity.store.vo.WebsocketVo;
|
|
|
import shop.alien.mapper.LifeMessageMapper;
|
|
|
import shop.alien.mapper.LifeUserMapper;
|
|
|
+import shop.alien.mapper.StoreDictionaryMapper;
|
|
|
import shop.alien.mapper.second.SecondGoodsMapper;
|
|
|
import shop.alien.mapper.second.SecondTradeRecordMapper;
|
|
|
import shop.alien.second.feign.AlienStoreFeign;
|
|
@@ -42,20 +44,7 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
|
|
|
private final LifeMessageMapper lifeMessageMapper;
|
|
|
private final LifeUserMapper lifeUserMapper;
|
|
|
private final AlienStoreFeign alienStoreFeign;
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<SecondTradeRecordVo> getTradeRecord(int sideId) throws Exception {
|
|
|
- try {
|
|
|
- int userId = Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getInteger("userId");
|
|
|
- QueryWrapper<SecondTradeRecordVo> wrapper = new QueryWrapper<>();
|
|
|
- wrapper.apply("(trade.buyer_id = '" + sideId + "' and trade.seller_id = '" + userId + "') || (trade.buyer_id = '" + userId + "' and trade.seller_id = '" + sideId + "')");
|
|
|
- wrapper.orderByDesc("trade.created_time");
|
|
|
- return secondTradeRecordMapper.getTradeRecord(wrapper);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("SecondTradeRecordServiceImpl.getTradeRecord Error Mgs={}", e.getMessage());
|
|
|
- throw new Exception(e);
|
|
|
- }
|
|
|
- }
|
|
|
+ private final StoreDictionaryMapper storeDictionaryMapper;
|
|
|
|
|
|
/**
|
|
|
* 创建交易
|
|
@@ -77,50 +66,209 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
|
|
|
// 查询商品
|
|
|
goods = secondGoodsMapper.selectById(trade.getGoodsId());
|
|
|
|
|
|
- // 封装交易信息
|
|
|
- JSONObject message = new JSONObject();
|
|
|
- message.put("title", goods.getTitle());
|
|
|
- message.put("homeImage", goods.getHomeImage());
|
|
|
- message.put("tradeId", trade.getId());
|
|
|
- message.put("transactionAmount", trade.getTransactionAmount());
|
|
|
- message.put("transactionLatitudeLongitude", trade.getTransactionLatitudeLongitude());
|
|
|
- message.put("transactionLatitudeLongitudeAddress", trade.getTransactionLatitudeLongitudeAddress());
|
|
|
- message.put("transactionLocation", trade.getTransactionLocation());
|
|
|
- message.put("transactionTime", trade.getTransactionTime());
|
|
|
- message.put("tradeStatus", 1);
|
|
|
+ // 发送消息
|
|
|
+ sendMsg(goods, trade, 1, "4");
|
|
|
+
|
|
|
+ return true;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("SecondTradeRecordServiceImpl.createTrade Error Mgs={}", e.getMessage());
|
|
|
+ throw new Exception(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送消息
|
|
|
+ * @param goods 商品信息
|
|
|
+ * @param trade 交易信息
|
|
|
+ * @param tradeStatus 1-待确认 2-已拒绝 3-待交易 6-交易取消
|
|
|
+ */
|
|
|
+ private void sendMsg(SecondGoods goods, SecondTradeRecord trade, Integer tradeStatus, String messageType) {
|
|
|
+ // 封装交易信息
|
|
|
+ JSONObject message = new JSONObject();
|
|
|
+ message.put("title", goods.getTitle());
|
|
|
+ message.put("homeImage", goods.getHomeImage());
|
|
|
+ message.put("tradeId", trade.getId());
|
|
|
+ message.put("transactionAmount", trade.getTransactionAmount());
|
|
|
+ message.put("transactionLatitudeLongitude", trade.getTransactionLatitudeLongitude());
|
|
|
+ message.put("transactionLatitudeLongitudeAddress", trade.getTransactionLatitudeLongitudeAddress());
|
|
|
+ message.put("transactionLocation", trade.getTransactionLocation());
|
|
|
+ message.put("transactionTime", trade.getTransactionTime());
|
|
|
+ message.put("tradeStatus", tradeStatus);
|
|
|
+ if (6 == tradeStatus) {
|
|
|
+ message.put("cancelUserId", trade.getCancelUserId());
|
|
|
+ message.put("cancelReason", trade.getCancelReason());
|
|
|
+ message.put("cancelReasonSupplement", trade.getCancelReasonSupplement());
|
|
|
+
|
|
|
+ // 查询字典表
|
|
|
+ LambdaQueryWrapper<StoreDictionary> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(StoreDictionary::getTypeName, "cancelTradeReason");
|
|
|
+ wrapper.eq(StoreDictionary::getDictId, trade.getCancelReason());
|
|
|
+ StoreDictionary storeDictionary = storeDictionaryMapper.selectOne(wrapper);
|
|
|
+ message.put("cancelReasonName", null == storeDictionary ? "" : storeDictionary.getDictDetail());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 发起交易人信息
|
|
|
+ Integer userId = Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getInteger("userId");
|
|
|
+ String phoneId = JwtUtil.getCurrentUserInfo().getString("userType") + "_" + JwtUtil.getCurrentUserInfo().getString("phone");
|
|
|
+
|
|
|
+ // 获取交易对方信息
|
|
|
+ LifeUser lifeUser = lifeUserMapper.selectById(Objects.equals(userId, trade.getBuyerId()) ? trade.getSellerId() : trade.getBuyerId());
|
|
|
+ String receiverId = "user_" + lifeUser.getUserPhone();
|
|
|
+
|
|
|
+ // 消息
|
|
|
+ LifeMessage lifeMessage = new LifeMessage();
|
|
|
+ lifeMessage.setSenderId(phoneId);
|
|
|
+ lifeMessage.setReceiverId(receiverId);
|
|
|
+ lifeMessage.setType(messageType);
|
|
|
+ lifeMessage.setContent(message.toJSONString());
|
|
|
+ lifeMessageMapper.insert(lifeMessage);
|
|
|
+
|
|
|
+ // 给买家与卖家发送交易消息
|
|
|
+ alienStoreFeign.sendMsgToClientByPhoneId(phoneId, phoneId, receiverId, "message", messageType, message.toJSONString(), lifeMessage.getId());
|
|
|
+ alienStoreFeign.sendMsgToClientByPhoneId(receiverId, phoneId, receiverId, "message", messageType, message.toJSONString(), lifeMessage.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean goodsTradeConfirm(int goodsId) throws Exception {
|
|
|
+ try {
|
|
|
+ LambdaQueryWrapper<SecondTradeRecord> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(SecondTradeRecord::getGoodsId, goodsId);
|
|
|
+ queryWrapper.in(SecondTradeRecord::getTradeStatus, 1, 3, 4);
|
|
|
+ return secondTradeRecordMapper.selectCount(queryWrapper) == 0;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("SecondTradeRecordServiceImpl.goodsTrade Error Mgs={}", e.getMessage());
|
|
|
+ throw new Exception(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean tradeConfirm(int tradeId, int messageId, int type) throws Exception {
|
|
|
+ try {
|
|
|
+ // 修改交易状态
|
|
|
+ SecondTradeRecord tradeRecord = new SecondTradeRecord();
|
|
|
+ tradeRecord.setId(tradeId);
|
|
|
+ if (type == 1) {
|
|
|
+ tradeRecord.setTradeStatus(3);
|
|
|
+ } else {
|
|
|
+ tradeRecord.setTradeStatus(2);
|
|
|
+ }
|
|
|
+ secondTradeRecordMapper.updateById(tradeRecord);
|
|
|
+
|
|
|
+ // 交易信息
|
|
|
+ SecondTradeRecord trade = secondTradeRecordMapper.selectById(tradeId);
|
|
|
+
|
|
|
+ // 商品信息
|
|
|
+ SecondGoods goods = secondGoodsMapper.selectById(trade.getGoodsId());
|
|
|
+
|
|
|
+ // 发送消息
|
|
|
+ sendMsg(goods, trade, trade.getTradeStatus(), "4");
|
|
|
+
|
|
|
+// // 发起交易人信息
|
|
|
+// Integer userId = Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getInteger("userId");
|
|
|
+// String phoneId = JwtUtil.getCurrentUserInfo().getString("userType") + "_" + JwtUtil.getCurrentUserInfo().getString("phone");
|
|
|
+//
|
|
|
+// // 获取交易对方信息
|
|
|
+// LifeUser lifeUser = lifeUserMapper.selectById(Objects.equals(userId, trade.getBuyerId()) ? trade.getSellerId() : trade.getBuyerId());
|
|
|
+// String receiverId = "user_" + lifeUser.getUserPhone();
|
|
|
+//
|
|
|
+// // 封装交易信息
|
|
|
+// JSONObject message = new JSONObject();
|
|
|
+// message.put("title", goods.getTitle());
|
|
|
+// message.put("homeImage", goods.getHomeImage());
|
|
|
+// message.put("tradeId", trade.getId());
|
|
|
+// message.put("transactionAmount", trade.getTransactionAmount());
|
|
|
+// message.put("transactionLatitudeLongitude", trade.getTransactionLatitudeLongitude());
|
|
|
+// message.put("transactionLatitudeLongitudeAddress", trade.getTransactionLatitudeLongitudeAddress());
|
|
|
+// message.put("transactionLocation", trade.getTransactionLocation());
|
|
|
+// message.put("transactionTime", trade.getTransactionTime());
|
|
|
+// message.put("tradeStatus", 3);
|
|
|
+//
|
|
|
+// // 保存消息记录
|
|
|
+// LifeMessage lifeMessage = new LifeMessage();
|
|
|
+// lifeMessage.setSenderId(phoneId);
|
|
|
+// lifeMessage.setReceiverId(receiverId);
|
|
|
+// lifeMessage.setType("4");
|
|
|
+// lifeMessage.setContent(message.toJSONString());
|
|
|
+// lifeMessageMapper.insert(lifeMessage);
|
|
|
+//
|
|
|
+// // 给买家与卖家发送交易消息
|
|
|
+// alienStoreFeign.sendMsgToClientByPhoneId(phoneId, phoneId, receiverId, "message", "4", message.toJSONString(), lifeMessage.getId());
|
|
|
+// alienStoreFeign.sendMsgToClientByPhoneId(receiverId, phoneId, receiverId, "message", "4", message.toJSONString(), lifeMessage.getId());
|
|
|
|
|
|
+ return true;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("SecondTradeRecordServiceImpl.tradeConfirm Error Mgs={}", e.getMessage());
|
|
|
+ throw new Exception(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean cancelTrade(int tradeId, String cancelReason, String cancelReasonSupplement) throws Exception {
|
|
|
+ try {
|
|
|
// 发起交易人信息
|
|
|
Integer userId = Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getInteger("userId");
|
|
|
String phoneId = JwtUtil.getCurrentUserInfo().getString("userType") + "_" + JwtUtil.getCurrentUserInfo().getString("phone");
|
|
|
|
|
|
- // 获取交易对方信息
|
|
|
- LifeUser lifeUser = lifeUserMapper.selectById(Objects.equals(userId, trade.getBuyerId()) ? trade.getSellerId() : trade.getBuyerId());
|
|
|
- String receiverId = "user_" + lifeUser.getUserPhone();
|
|
|
-
|
|
|
- // 消息
|
|
|
- LifeMessage lifeMessage = new LifeMessage();
|
|
|
- lifeMessage.setSenderId(phoneId);
|
|
|
- lifeMessage.setReceiverId(receiverId);
|
|
|
- lifeMessage.setType("4");
|
|
|
- lifeMessage.setContent(message.toJSONString());
|
|
|
- lifeMessageMapper.insert(lifeMessage);
|
|
|
-
|
|
|
- // 给买家与卖家发送交易消息
|
|
|
-// WebsocketVo websocketVo = new WebsocketVo();
|
|
|
-// websocketVo.setSenderId(phoneId);
|
|
|
-// websocketVo.setReceiverId("user_" + lifeUser.getUserPhone());
|
|
|
-// websocketVo.setCategory("message");
|
|
|
-// websocketVo.setType("4");
|
|
|
-// websocketVo.setText(message.toJSONString());
|
|
|
-// websocketVo.setMessageId(lifeMessage.getId());
|
|
|
-
|
|
|
- // 给买家与卖家发送交易消息
|
|
|
- alienStoreFeign.sendMsgToClientByPhoneId(phoneId, phoneId, receiverId, "message", "4", message.toJSONString(), lifeMessage.getId());
|
|
|
- alienStoreFeign.sendMsgToClientByPhoneId(receiverId, phoneId, receiverId, "message", "4", message.toJSONString(), lifeMessage.getId());
|
|
|
+ // 修改交易状态
|
|
|
+ SecondTradeRecord tradeRecord = new SecondTradeRecord();
|
|
|
+ tradeRecord.setId(tradeId);
|
|
|
+ tradeRecord.setTradeStatus(6);
|
|
|
+ tradeRecord.setCancelUserId(userId);
|
|
|
+ tradeRecord.setCancelReason(cancelReason);
|
|
|
+ tradeRecord.setCancelReasonSupplement(cancelReasonSupplement);
|
|
|
+ secondTradeRecordMapper.updateById(tradeRecord);
|
|
|
+
|
|
|
+ // 交易信息
|
|
|
+ SecondTradeRecord trade = secondTradeRecordMapper.selectById(tradeId);
|
|
|
+
|
|
|
+ // 商品信息
|
|
|
+ SecondGoods goods = secondGoodsMapper.selectById(trade.getGoodsId());
|
|
|
+
|
|
|
+ // 发送消息
|
|
|
+ sendMsg(goods, trade, 6, "4");
|
|
|
+
|
|
|
+// // 获取交易对方信息
|
|
|
+// LifeUser lifeUser = lifeUserMapper.selectById(Objects.equals(userId, trade.getBuyerId()) ? trade.getSellerId() : trade.getBuyerId());
|
|
|
+// String receiverId = "user_" + lifeUser.getUserPhone();
|
|
|
+//
|
|
|
+// // 封装交易信息
|
|
|
+//
|
|
|
+// JSONObject message = new JSONObject();
|
|
|
+// message.put("title", goods.getTitle());
|
|
|
+// message.put("homeImage", goods.getHomeImage());
|
|
|
+// message.put("tradeId", trade.getId());
|
|
|
+// message.put("transactionAmount", trade.getTransactionAmount());
|
|
|
+// message.put("transactionLatitudeLongitude", trade.getTransactionLatitudeLongitude());
|
|
|
+// message.put("transactionLatitudeLongitudeAddress", trade.getTransactionLatitudeLongitudeAddress());
|
|
|
+// message.put("transactionLocation", trade.getTransactionLocation());
|
|
|
+// message.put("transactionTime", trade.getTransactionTime());
|
|
|
+// message.put("tradeStatus", 6);
|
|
|
+// message.put("cancelUserId", trade.getCancelUserId());
|
|
|
+// message.put("cancelReason", trade.getCancelReason());
|
|
|
+// message.put("cancelReasonSupplement", trade.getCancelReasonSupplement());
|
|
|
+//
|
|
|
+// // 查询字典表
|
|
|
+// LambdaQueryWrapper<StoreDictionary> wrapper = new LambdaQueryWrapper<>();
|
|
|
+// wrapper.eq(StoreDictionary::getTypeName, "cancelTradeReason");
|
|
|
+// wrapper.eq(StoreDictionary::getDictId, trade.getCancelReason());
|
|
|
+// StoreDictionary storeDictionary = storeDictionaryMapper.selectOne(wrapper);
|
|
|
+// message.put("cancelReasonName", null == storeDictionary ? "" : storeDictionary.getDictDetail());
|
|
|
+//
|
|
|
+// // 保存消息记录
|
|
|
+// LifeMessage lifeMessage = new LifeMessage();
|
|
|
+// lifeMessage.setSenderId(phoneId);
|
|
|
+// lifeMessage.setReceiverId(receiverId);
|
|
|
+// lifeMessage.setType("4");
|
|
|
+// lifeMessage.setContent(message.toJSONString());
|
|
|
+// lifeMessageMapper.insert(lifeMessage);
|
|
|
+//
|
|
|
+// // 给买家与卖家发送交易消息
|
|
|
+// alienStoreFeign.sendMsgToClientByPhoneId(phoneId, phoneId, receiverId, "message", "4", message.toJSONString(), lifeMessage.getId());
|
|
|
+// alienStoreFeign.sendMsgToClientByPhoneId(receiverId, phoneId, receiverId, "message", "4", message.toJSONString(), lifeMessage.getId());
|
|
|
|
|
|
return true;
|
|
|
} catch (Exception e) {
|
|
|
- log.error("SecondTradeRecordServiceImpl.createTrade Error Mgs={}", e.getMessage());
|
|
|
+ log.error("SecondTradeRecordServiceImpl.cancelTrade Error Mgs={}", e.getMessage());
|
|
|
throw new Exception(e);
|
|
|
}
|
|
|
}
|
|
@@ -129,40 +277,60 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
|
|
|
public boolean tradeSignIn(int tradeId, int messageId) throws Exception {
|
|
|
try {
|
|
|
int userId = Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getInteger("userId");
|
|
|
- SecondTradeRecord tradeRecord = secondTradeRecordMapper.selectById(tradeId);
|
|
|
+ SecondTradeRecord trade = secondTradeRecordMapper.selectById(tradeId);
|
|
|
SecondTradeRecord record = new SecondTradeRecord();
|
|
|
record.setId(tradeId);
|
|
|
- if (userId == tradeRecord.getBuyerId()) {
|
|
|
+ if (userId == trade.getBuyerId()) {
|
|
|
record.setBuyerSignIn(1);
|
|
|
- } else if (userId == tradeRecord.getSellerId()) {
|
|
|
+ } else if (userId == trade.getSellerId()) {
|
|
|
record.setSellerSignIn(1);
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
secondTradeRecordMapper.updateById(record);
|
|
|
|
|
|
-// LifeMessage message = new LifeMessage();
|
|
|
-// message.setId(messageId);
|
|
|
-// message.setContent(messageContent);
|
|
|
-// message.setType("6");
|
|
|
-// message.setCreatedTime(new Date());
|
|
|
-// lifeMessageMapper.updateById(message);
|
|
|
- lifeMessageMapper.deleteById(messageId);
|
|
|
+ // 商品信息
|
|
|
+ SecondGoods goods = secondGoodsMapper.selectById(trade.getGoodsId());
|
|
|
|
|
|
- return true;
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("SecondTradeRecordServiceImpl.tradeSignIn Error Mgs={}", e.getMessage());
|
|
|
- throw new Exception(e);
|
|
|
- }
|
|
|
- }
|
|
|
+ // 发送消息
|
|
|
+ sendMsg(goods, trade, 3, "6");
|
|
|
|
|
|
- @Override
|
|
|
- public boolean tradeConfirm(int tradeId, int type, String evaluate) throws Exception {
|
|
|
- try {
|
|
|
+ // 封装交易信息
|
|
|
+// JSONObject message = new JSONObject();
|
|
|
+// message.put("title", goods.getTitle());
|
|
|
+// message.put("homeImage", goods.getHomeImage());
|
|
|
+// message.put("tradeId", trade.getId());
|
|
|
+// message.put("transactionAmount", trade.getTransactionAmount());
|
|
|
+// message.put("transactionLatitudeLongitude", trade.getTransactionLatitudeLongitude());
|
|
|
+// message.put("transactionLatitudeLongitudeAddress", trade.getTransactionLatitudeLongitudeAddress());
|
|
|
+// message.put("transactionLocation", trade.getTransactionLocation());
|
|
|
+// message.put("transactionTime", trade.getTransactionTime());
|
|
|
+// message.put("tradeStatus", 3);
|
|
|
+//
|
|
|
+// // 发起交易人信息
|
|
|
+//// Integer userId = Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getInteger("userId");
|
|
|
+// String phoneId = JwtUtil.getCurrentUserInfo().getString("userType") + "_" + JwtUtil.getCurrentUserInfo().getString("phone");
|
|
|
+//
|
|
|
+// // 获取交易对方信息
|
|
|
+// LifeUser lifeUser = lifeUserMapper.selectById(Objects.equals(userId, trade.getBuyerId()) ? trade.getSellerId() : trade.getBuyerId());
|
|
|
+// String receiverId = "user_" + lifeUser.getUserPhone();
|
|
|
+//
|
|
|
+// // 消息
|
|
|
+// LifeMessage lifeMessage = new LifeMessage();
|
|
|
+// lifeMessage.setSenderId(phoneId);
|
|
|
+// lifeMessage.setReceiverId(receiverId);
|
|
|
+// lifeMessage.setType("6");
|
|
|
+// lifeMessage.setContent(message.toJSONString());
|
|
|
+// lifeMessageMapper.insert(lifeMessage);
|
|
|
+//
|
|
|
+// // 给买家与卖家发送交易消息
|
|
|
+// alienStoreFeign.sendMsgToClientByPhoneId(phoneId, phoneId, receiverId, "message", "6", message.toJSONString(), lifeMessage.getId());
|
|
|
+// alienStoreFeign.sendMsgToClientByPhoneId(r
|
|
|
+// eceiverId, phoneId, receiverId, "message", "6", message.toJSONString(), lifeMessage.getId());
|
|
|
|
|
|
return true;
|
|
|
} catch (Exception e) {
|
|
|
- log.error("SecondTradeRecordServiceImpl.tradeConfirm Error Mgs={}", e.getMessage());
|
|
|
+ log.error("SecondTradeRecordServiceImpl.tradeSignIn Error Mgs={}", e.getMessage());
|
|
|
throw new Exception(e);
|
|
|
}
|
|
|
}
|
|
@@ -193,31 +361,15 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean goodsTradeConfirm(int goodsId) throws Exception {
|
|
|
- try {
|
|
|
- LambdaQueryWrapper<SecondTradeRecord> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(SecondTradeRecord::getGoodsId, goodsId);
|
|
|
- queryWrapper.in(SecondTradeRecord::getTradeStatus, 0, 1);
|
|
|
- return secondTradeRecordMapper.selectCount(queryWrapper) == 0;
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("SecondTradeRecordServiceImpl.goodsTrade Error Mgs={}", e.getMessage());
|
|
|
- throw new Exception(e);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean cancelTrade(int tradeId, String cancelReason, String cancelReasonSupplement) throws Exception {
|
|
|
+ public List<SecondTradeRecordVo> getTradeRecord(int sideId) throws Exception {
|
|
|
try {
|
|
|
int userId = Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getInteger("userId");
|
|
|
- SecondTradeRecord record = new SecondTradeRecord();
|
|
|
- record.setId(tradeId);
|
|
|
- record.setTradeStatus(3);
|
|
|
- record.setCancelUserId(userId);
|
|
|
- record.setCancelReason(cancelReason);
|
|
|
- record.setCancelReasonSupplement(cancelReasonSupplement);
|
|
|
- return secondTradeRecordMapper.updateById(record) > 0;
|
|
|
+ QueryWrapper<SecondTradeRecord> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.apply("(trade.buyer_id = '" + sideId + "' and trade.seller_id = '" + userId + "') || (trade.buyer_id = '" + userId + "' and trade.seller_id = '" + sideId + "')");
|
|
|
+ wrapper.orderByDesc("trade.created_time");
|
|
|
+ return secondTradeRecordMapper.getTradeRecord(wrapper);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("SecondTradeRecordServiceImpl.cancelTrade Error Mgs={}", e.getMessage());
|
|
|
+ log.error("SecondTradeRecordServiceImpl.getTradeRecord Error Mgs={}", e.getMessage());
|
|
|
throw new Exception(e);
|
|
|
}
|
|
|
}
|