|
|
@@ -201,6 +201,16 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
|
|
|
// 交易信息
|
|
|
SecondTradeRecord trade = secondTradeRecordMapper.selectById(tradeId);
|
|
|
|
|
|
+ // 判断商品是否正在交易中
|
|
|
+ if (type == 1) {
|
|
|
+ LambdaQueryWrapper<SecondTradeRecord> recordWrapper = new LambdaQueryWrapper<>();
|
|
|
+ recordWrapper.eq(SecondTradeRecord::getGoodsId, trade.getGoodsId());
|
|
|
+ recordWrapper.eq(SecondTradeRecord::getTradeStatus, 3);
|
|
|
+ if (secondTradeRecordMapper.selectCount(recordWrapper) > 0) {
|
|
|
+ throw new BusinessException("该商品正在交易中");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 有定时任务: 超过交易时间还未确认的交易会自动取消并保存交易操作表 所以如果是已取消的交易 不需要进行这两步操作
|
|
|
if (trade.getTradeStatus() != 6) {
|
|
|
// 修改交易状态
|
|
|
@@ -548,6 +558,51 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public SecondTradeRecord hasInTradeRecord(Integer sideId) throws Exception {
|
|
|
+ try {
|
|
|
+ int userId = Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getInteger("userId");
|
|
|
+ LambdaQueryWrapper<SecondTradeRecord> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(SecondTradeRecord::getTradeStatus, 3);
|
|
|
+ wrapper.apply("((seller_id = " + userId + " and buyer_id = " + sideId + ") or " +
|
|
|
+ "(seller_id = " + sideId + " and buyer_id = " + userId + "))");
|
|
|
+ wrapper.orderByDesc(SecondTradeRecord::getTransactionTime);
|
|
|
+ return secondTradeRecordMapper.selectOne(wrapper);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("SecondTradeRecordServiceImpl.hasInTradeRecord(): Error Msg={}", e.getMessage());
|
|
|
+ throw new Exception(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean modifyTradeRecord(int type, Integer tradeId, String transactionTime, String transactionLatitudeLongitude, String transactionLatitudeLongitudeAddress, String transactionLocation, String messageId) throws Exception {
|
|
|
+ try {
|
|
|
+ if (type == 1) {
|
|
|
+ LambdaUpdateWrapper<SecondTradeRecord> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.set(SecondTradeRecord::getTransactionTime, transactionTime);
|
|
|
+ wrapper.set(SecondTradeRecord::getTransactionLatitudeLongitude, transactionLatitudeLongitude);
|
|
|
+ wrapper.set(SecondTradeRecord::getTransactionLatitudeLongitudeAddress, transactionLatitudeLongitudeAddress);
|
|
|
+ wrapper.set(SecondTradeRecord::getTransactionLocation, transactionLocation);
|
|
|
+ wrapper.eq(SecondTradeRecord::getId, tradeId);
|
|
|
+ secondTradeRecordMapper.update(null, wrapper);
|
|
|
+ }
|
|
|
+ // 修改待确认的消息
|
|
|
+ LifeMessage lastMessage = lifeMessageMapper.selectById(messageId);
|
|
|
+
|
|
|
+ JSONObject lastMessageContent = JSONObject.parseObject(lastMessage.getContent());
|
|
|
+ lastMessageContent.put("messageId", lastMessage.getId());
|
|
|
+ lastMessageContent.put("modifyStatus", type);
|
|
|
+ LifeMessage message = new LifeMessage();
|
|
|
+ message.setId(lastMessage.getId());
|
|
|
+ message.setContent(lastMessageContent.toJSONString());
|
|
|
+ lifeMessageMapper.updateById(message);
|
|
|
+ return true;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("SecondTradeRecordServiceImpl.modifyTradeRecord(): Error Msg={}", e.getMessage());
|
|
|
+ throw new Exception(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void sendSignInMessage(SecondTradeRecord tradeRecord) throws Exception {
|
|
|
log.info("二手交易平台-创建交易时间小于十分钟,直接发送交易提醒---sendSignInMessage()---");
|
|
|
try {
|