Преглед на файлове

消息、通知、交易

qrs преди 21 часа
родител
ревизия
6a152931a6

+ 3 - 7
alien-job/src/main/java/shop/alien/job/feign/AlienStoreFeign.java

@@ -9,12 +9,8 @@ import org.springframework.web.bind.annotation.RequestParam;
 public interface AlienStoreFeign {
 
     @GetMapping("/websocket/sendMsgToClientByPhoneId")
-    JSONObject sendMsgToClientByPhoneId(@RequestParam(value = "messageReceiverId") String messageReceiverId,
-                                        @RequestParam(value = "senderId") String senderId,
-                                        @RequestParam(value = "receiverId") String receiverId,
-                                        @RequestParam(value = "category") String category,
-                                        @RequestParam(value = "type") String type,
-                                        @RequestParam(value = "text") String text,
-                                        @RequestParam(value = "messageId") Integer messageId);
+    JSONObject sendMsgToClientByPhoneId(
+            @RequestParam(value = "messageReceiverId") String messageReceiverId,
+            @RequestParam(value = "webSocketVoStr") String webSocketVoStr);
 
 }

+ 156 - 76
alien-job/src/main/java/shop/alien/job/second/SecondGoodsTradeXxlJob.java

@@ -7,20 +7,25 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 import shop.alien.config.redis.BaseRedisService;
+import shop.alien.entity.second.SecondGoods;
 import shop.alien.entity.second.SecondTradeRecord;
 import shop.alien.entity.store.LifeMessage;
 import shop.alien.entity.store.LifeNotice;
 import shop.alien.entity.store.LifeUser;
+import shop.alien.entity.store.vo.WebSocketVo;
 import shop.alien.job.feign.AlienStoreFeign;
 import shop.alien.mapper.LifeMessageMapper;
 import shop.alien.mapper.LifeNoticeMapper;
 import shop.alien.mapper.LifeUserMapper;
+import shop.alien.mapper.second.SecondGoodsMapper;
 import shop.alien.mapper.second.SecondTradeRecordMapper;
 
 import java.time.LocalDateTime;
 import java.time.ZoneId;
+import java.util.ArrayList;
 import java.util.List;
 
 @Slf4j
@@ -40,11 +45,93 @@ public class SecondGoodsTradeXxlJob {
 
     private final BaseRedisService baseRedisService;
 
+    private final SecondGoodsMapper secondGoodsMapper;
+
     /**
-     * 商品交易时间十分钟之前发送签到提醒
+     * 二手交易平台 - 交易时间前的十分钟之前  给买家和卖家发送通知提醒
      */
     @XxlJob("secondTradeRemind")
-    public void secondTradeRemind() {
+    public void secondTradeRemind() throws Exception {
+        LocalDateTime now = LocalDateTime.now().withSecond(0).withNano(0);
+
+        // 查询所有待交易
+        LambdaQueryWrapper<SecondTradeRecord> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(SecondTradeRecord::getTradeStatus, 3);
+        List<SecondTradeRecord> tradeRecordList = secondTradeRecordMapper.selectList(wrapper);
+
+        for (SecondTradeRecord tradeRecord : tradeRecordList) {
+            LocalDateTime tenMinutesAgo = tradeRecord.getTransactionTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().withSecond(0).withNano(0);
+            if (now.isEqual(tenMinutesAgo)) {
+                LifeUser buyer = lifeUserMapper.selectById(tradeRecord.getBuyerId());
+                LifeUser seller = lifeUserMapper.selectById(tradeRecord.getSellerId());
+                SecondGoods goods = secondGoodsMapper.selectById(tradeRecord.getGoodsId());
+
+                String buyerPhoneId = null == buyer ? "" : "user_" + buyer.getUserPhone();
+                String sellerPhoneId = null == seller ? "" : "user_" + seller.getUserPhone();
+
+                // 给买家发送通知
+                LifeNotice lifeNotice = new LifeNotice();
+                lifeNotice.setSenderId("system");
+                lifeNotice.setReceiverId(buyerPhoneId);
+                lifeNotice.setBusinessId(tradeRecord.getId());
+                lifeNotice.setTitle("商品是否交易成功");
+                lifeNotice.setNoticeType(1);
+                // 封装通知信息
+                JSONObject noticeMessage = new JSONObject();
+                noticeMessage.put("goodsId", goods.getId());
+                noticeMessage.put("goodsHomeImage", goods.getHomeImage());
+                noticeMessage.put("goodsTitle", goods.getTitle());
+                noticeMessage.put("tradeId", tradeRecord.getId());
+                noticeMessage.put("transactionAmount", tradeRecord.getTransactionAmount());
+                noticeMessage.put("transactionLatitudeLongitude", tradeRecord.getTransactionLatitudeLongitude());
+                noticeMessage.put("transactionLatitudeLongitudeAddress", tradeRecord.getTransactionLatitudeLongitudeAddress());
+                noticeMessage.put("transactionLocation", tradeRecord.getTransactionLocation());
+                noticeMessage.put("transactionTime", tradeRecord.getTransactionTime());
+                noticeMessage.put("tradeStatus", tradeRecord.getTradeStatus());
+                noticeMessage.put("message", "您有一笔交易已完成, 请前往确认");
+                lifeNotice.setContext(noticeMessage.toJSONString());
+                lifeNoticeMapper.insert(lifeNotice);
+
+                // 给买家推送通知
+                WebSocketVo webSocketVo = new WebSocketVo();
+                webSocketVo.setSenderId("system");
+                webSocketVo.setReceiverId(buyerPhoneId);
+                webSocketVo.setCategory("notice");
+                webSocketVo.setNoticeType("1");
+                webSocketVo.setType("5");
+                webSocketVo.setIsRead(0);
+                webSocketVo.setText(JSONObject.from(lifeNotice).toJSONString());
+                alienStoreFeign.sendMsgToClientByPhoneId(buyerPhoneId, JSONObject.from(webSocketVo).toJSONString());
+
+                // 给卖家发送通知
+                lifeNotice = new LifeNotice();
+                lifeNotice.setSenderId("system");
+                lifeNotice.setReceiverId(sellerPhoneId);
+                lifeNotice.setBusinessId(tradeRecord.getId());
+                lifeNotice.setTitle("商品是否交易成功");
+                lifeNotice.setNoticeType(1);
+                lifeNotice.setContext(noticeMessage.toJSONString());
+                lifeNoticeMapper.insert(lifeNotice);
+
+                // 给卖家推送通知
+                webSocketVo = new WebSocketVo();
+                webSocketVo.setSenderId("system");
+                webSocketVo.setReceiverId(sellerPhoneId);
+                webSocketVo.setCategory("notice");
+                webSocketVo.setNoticeType("1");
+                webSocketVo.setType("5");
+                webSocketVo.setIsRead(0);
+                webSocketVo.setText(JSONObject.from(lifeNotice).toJSONString());
+                alienStoreFeign.sendMsgToClientByPhoneId(buyerPhoneId, JSONObject.from(webSocketVo).toJSONString());
+            }
+        }
+    }
+
+    /**
+     * 二手交易平台 - 到达交易时间时,给买家和卖家发送交易确认提醒
+     */
+    @XxlJob("secondTradeConfirm")
+    public void secondTradeConfirm() throws Exception {
         try {
             LocalDateTime now = LocalDateTime.now().withSecond(0).withNano(0);
 
@@ -54,117 +141,110 @@ public class SecondGoodsTradeXxlJob {
             List<SecondTradeRecord> tradeRecordList = secondTradeRecordMapper.selectList(wrapper);
 
             for (SecondTradeRecord tradeRecord : tradeRecordList) {
-                // 十分钟前
-                LocalDateTime tenMinutesAgo = tradeRecord.getTransactionTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().minusMinutes(10).withSecond(0).withNano(0);
-                // 交易时间的十分钟前
+                LocalDateTime tenMinutesAgo = tradeRecord.getTransactionTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().withSecond(0).withNano(0);
                 if (now.isEqual(tenMinutesAgo)) {
-                    // 封装交易信息
-                    JSONObject message = new JSONObject();
-                    message.put("tradeId", tradeRecord.getId());
-                    message.put("transactionAmount", tradeRecord.getTransactionAmount());
-                    message.put("transactionLatitudeLongitude", tradeRecord.getTransactionLatitudeLongitude());
-                    message.put("transactionLatitudeLongitudeAddress", tradeRecord.getTransactionLatitudeLongitudeAddress());
-                    message.put("transactionLocation", tradeRecord.getTransactionLocation());
-                    message.put("transactionTime", tradeRecord.getTransactionTime());
-                    message.put("tradeStatus", tradeRecord.getTradeStatus());
-
                     LifeUser buyer = lifeUserMapper.selectById(tradeRecord.getBuyerId());
                     LifeUser seller = lifeUserMapper.selectById(tradeRecord.getSellerId());
+                    SecondGoods goods = secondGoodsMapper.selectById(tradeRecord.getGoodsId());
 
                     String buyerPhoneId = null == buyer ? "" : "user_" + buyer.getUserPhone();
                     String sellerPhoneId = null == seller ? "" : "user_" + seller.getUserPhone();
 
-                    // 给买家发送消息
-                    LifeMessage lifeMessage = new LifeMessage();
-                    lifeMessage.setSenderId(sellerPhoneId);
-                    lifeMessage.setReceiverId(buyerPhoneId);
-                    lifeMessage.setContent(message.toJSONString());
-                    lifeMessage.setType("5");
-                    lifeMessageMapper.insert(lifeMessage);
-
-                    // 给买家推送消息
-//                    WebsocketVo websocketVo = new WebsocketVo();
-//                    websocketVo.setSenderId(sellerPhoneId);
-//                    websocketVo.setReceiverId(buyerPhoneId);
-//                    websocketVo.setCategory("message");
-//                    websocketVo.setType("5");
-//                    websocketVo.setText(message.toJSONString());
-//                    websocketVo.setMessageId(lifeMessage.getId());
-                    alienStoreFeign.sendMsgToClientByPhoneId(buyerPhoneId, sellerPhoneId, buyerPhoneId, "message", "5", message.toJSONString(), lifeMessage.getId());
-
                     // 给买家发送通知
                     LifeNotice lifeNotice = new LifeNotice();
                     lifeNotice.setSenderId("system");
                     lifeNotice.setReceiverId(buyerPhoneId);
                     lifeNotice.setBusinessId(tradeRecord.getId());
-                    lifeNotice.setTitle("交易签到提醒");
-                    lifeNotice.setContext("您有一笔交易即将开始, 请及时前往查看");
+                    lifeNotice.setTitle("商品是否交易成功");
                     lifeNotice.setNoticeType(1);
+                    // 封装通知信息
+                    JSONObject noticeMessage = new JSONObject();
+                    noticeMessage.put("goodsId", goods.getId());
+                    noticeMessage.put("goodsHomeImage", goods.getHomeImage());
+                    noticeMessage.put("goodsTitle", goods.getTitle());
+                    noticeMessage.put("tradeId", tradeRecord.getId());
+                    noticeMessage.put("transactionAmount", tradeRecord.getTransactionAmount());
+                    noticeMessage.put("transactionLatitudeLongitude", tradeRecord.getTransactionLatitudeLongitude());
+                    noticeMessage.put("transactionLatitudeLongitudeAddress", tradeRecord.getTransactionLatitudeLongitudeAddress());
+                    noticeMessage.put("transactionLocation", tradeRecord.getTransactionLocation());
+                    noticeMessage.put("transactionTime", tradeRecord.getTransactionTime());
+                    noticeMessage.put("tradeStatus", tradeRecord.getTradeStatus());
+                    noticeMessage.put("message", "您有一笔交易已完成, 请前往确认");
+                    lifeNotice.setContext(noticeMessage.toJSONString());
                     lifeNoticeMapper.insert(lifeNotice);
 
                     // 给买家推送通知
-//                    websocketVo = new WebsocketVo();
-//                    websocketVo.setSenderId("system");
-//                    websocketVo.setReceiverId(buyerPhoneId);
-//                    websocketVo.setCategory("notice");
-//                    websocketVo.setType("5");
-//                    websocketVo.setText(message.toJSONString());
-//                    websocketVo.setMessageId(lifeMessage.getId());
-                    alienStoreFeign.sendMsgToClientByPhoneId(buyerPhoneId, "system", buyerPhoneId, "notice", "5", message.toJSONString(), lifeMessage.getId());
-
-                    // 给卖家发送消息
-                    lifeMessage = new LifeMessage();
-                    lifeMessage.setSenderId(buyerPhoneId);
-                    lifeMessage.setReceiverId(sellerPhoneId);
-                    lifeMessage.setContent(message.toJSONString());
-                    lifeMessage.setType("5");
-                    lifeMessageMapper.insert(lifeMessage);
-
-                    // 给卖家推送消息
-//                    websocketVo = new WebsocketVo();
-//                    websocketVo.setSenderId(buyerPhoneId);
-//                    websocketVo.setReceiverId(sellerPhoneId);
-//                    websocketVo.setCategory("message");
-//                    websocketVo.setType("5");
-//                    websocketVo.setText(message.toJSONString());
-//                    websocketVo.setMessageId(lifeMessage.getId());
-                    alienStoreFeign.sendMsgToClientByPhoneId(sellerPhoneId, buyerPhoneId, sellerPhoneId, "message", "5", message.toJSONString(), lifeMessage.getId());
+                    WebSocketVo webSocketVo = new WebSocketVo();
+                    webSocketVo.setSenderId("system");
+                    webSocketVo.setReceiverId(buyerPhoneId);
+                    webSocketVo.setCategory("notice");
+                    webSocketVo.setNoticeType("1");
+                    webSocketVo.setType("5");
+                    webSocketVo.setIsRead(0);
+                    webSocketVo.setText(JSONObject.from(lifeNotice).toJSONString());
+                    alienStoreFeign.sendMsgToClientByPhoneId(buyerPhoneId, JSONObject.from(webSocketVo).toJSONString());
 
                     // 给卖家发送通知
                     lifeNotice = new LifeNotice();
                     lifeNotice.setSenderId("system");
                     lifeNotice.setReceiverId(sellerPhoneId);
                     lifeNotice.setBusinessId(tradeRecord.getId());
-                    lifeNotice.setTitle("交易签到提醒");
-                    lifeNotice.setContext("您有一笔交易即将开始, 请及时前往查看");
+                    lifeNotice.setTitle("商品是否交易成功");
                     lifeNotice.setNoticeType(1);
+                    lifeNotice.setContext(noticeMessage.toJSONString());
                     lifeNoticeMapper.insert(lifeNotice);
 
                     // 给卖家推送通知
-//                    websocketVo = new WebsocketVo();
-//                    websocketVo.setSenderId("system");
-//                    websocketVo.setReceiverId(sellerPhoneId);
-//                    websocketVo.setCategory("notice");
-//                    websocketVo.setType("5");
-//                    websocketVo.setText(message.toJSONString());
-//                    websocketVo.setMessageId(lifeMessage.getId());
-                    alienStoreFeign.sendMsgToClientByPhoneId(sellerPhoneId, "system", sellerPhoneId, "notice", "5", message.toJSONString(), lifeMessage.getId());
+                    webSocketVo = new WebSocketVo();
+                    webSocketVo.setSenderId("system");
+                    webSocketVo.setReceiverId(sellerPhoneId);
+                    webSocketVo.setCategory("notice");
+                    webSocketVo.setNoticeType("1");
+                    webSocketVo.setType("5");
+                    webSocketVo.setIsRead(0);
+                    webSocketVo.setText(JSONObject.from(lifeNotice).toJSONString());
+                    alienStoreFeign.sendMsgToClientByPhoneId(buyerPhoneId, JSONObject.from(webSocketVo).toJSONString());
                 }
             }
         } catch (Exception e) {
-            log.error("SecondGoodsTradeXxlJob.secondTradeRemind Error Mgs={}", e.getMessage());
+            log.error("SecondGoodsTradeXxlJob.secondTradeConfirm Error Mgs={}", e.getMessage());
+        }
+    }
+
+    /**
+     * 二手交易平台 - 交易超时未确认则自动取消
+     */
+    @XxlJob("secondTradeTimeoutCancel")
+    private void secondTradeTimeoutCancel() {
+        LocalDateTime now = LocalDateTime.now().withSecond(0).withNano(0);
+
+        // 查询所有待确认
+        LambdaQueryWrapper<SecondTradeRecord> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(SecondTradeRecord::getTradeStatus, 1);
+        List<SecondTradeRecord> tradeRecordList = secondTradeRecordMapper.selectList(queryWrapper);
+        List<Integer> tradeIdList = new ArrayList<>();
+        for (SecondTradeRecord tradeRecord : tradeRecordList) {
+            LocalDateTime tenMinutesAgo = tradeRecord.getTransactionTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().withSecond(0).withNano(0);
+            if (now.isEqual(tenMinutesAgo)) {
+                tradeIdList.add(tradeRecord.getId());
+            }
+        }
+        if (CollectionUtil.isNotEmpty(tradeIdList)) {
+            LambdaUpdateWrapper<SecondTradeRecord> updateWrapper = new LambdaUpdateWrapper<>();
+            updateWrapper.in(SecondTradeRecord::getId, tradeIdList)
+                    .set(SecondTradeRecord::getTradeStatus, 6);
+            secondTradeRecordMapper.update(null, updateWrapper);
         }
     }
 
     /**
-     * 每分钟从redis中读取已读的消息id 并将数据库设为已读
+     * 二手交易平台 - 每分钟从redis中读取已读的消息id 并将数据库设为已读
      */
     @XxlJob("readMessage")
+    @Scheduled(cron = "0 * * * * ?")
     public void readMessage() {
         try {
-            if (CollectionUtil.isEmpty(baseRedisService.getList("readMessageIdKey"))) {
-                return;
-            }
+            if (CollectionUtil.isEmpty(baseRedisService.getList("readMessageIdKey"))) return;
 
             List<String> dataList = baseRedisService.popBatchFromList("readMessageIdKey");
             if (CollectionUtil.isNotEmpty(dataList)) {

+ 20 - 20
alien-second/src/main/java/shop/alien/second/feign/AlienStoreFeign.java

@@ -13,27 +13,27 @@ public interface AlienStoreFeign {
                               @RequestParam(value = "friendType") int friendType,
                               @RequestParam(value = "search") String search);
 
-    /**
-     *
-     * @param messageReceiverId  消息接收者
-     * @param senderId           发送人
-     * @param receiverId         接收人
-     * @param category           消息类别(message-聊一聊消息  notice-通知)
-     * @param type               消息类型  1-文本  2-图片 3-链接分享  4-二手交易(确认/拒绝/取消)  5-二手交易签到提醒  6-二手交易已签到
-     * @param text               消息内容
-     * @param messageId          消息表存入的主键id
-     */
-    @GetMapping("/websocket/sendMsgToClientByPhoneId")
-    JSONObject sendMsgToClientByPhoneId(@RequestParam(value = "messageReceiverId") String messageReceiverId,
-                                        @RequestParam(value = "senderId") String senderId,
-                                        @RequestParam(value = "receiverId") String receiverId,
-                                        @RequestParam(value = "category") String category,
-                                        @RequestParam(value = "type") String type,
-                                        @RequestParam(value = "text") String text,
-                                        @RequestParam(value = "messageId") Integer messageId);
+//    /**
+//     *
+//     * @param messageReceiverId  消息接收者
+//     * @param senderId           发送人
+//     * @param receiverId         接收人
+//     * @param category           消息类别(message-聊一聊消息  notice-通知)
+//     * @param type               消息类型  1-文本  2-图片 3-链接分享  4-二手交易(确认/拒绝/取消)  5-二手交易签到提醒  6-二手交易已签到
+//     * @param text               消息内容
+//     * @param messageId          消息表存入的主键id
+//     */
+//    @GetMapping("/websocket/sendMsgToClientByPhoneId")
+//    JSONObject sendMsgToClientByPhoneId(@RequestParam(value = "messageReceiverId") String messageReceiverId,
+//                                        @RequestParam(value = "senderId") String senderId,
+//                                        @RequestParam(value = "receiverId") String receiverId,
+//                                        @RequestParam(value = "category") String category,
+//                                        @RequestParam(value = "type") String type,
+//                                        @RequestParam(value = "text") String text,
+//                                        @RequestParam(value = "messageId") Integer messageId);
 
-    @GetMapping("/websocket/sendMsgToClientByPhoneIdaaaa")
-    JSONObject sendMsgToClientByPhoneIdaaaa(
+    @GetMapping("/websocket/sendMsgToClientByPhoneId")
+    JSONObject sendMsgToClientByPhoneId(
                                         @RequestParam(value = "messageReceiverId") String messageReceiverId,
                                         @RequestParam(value = "webSocketVoStr") String webSocketVoStr);
 

+ 1 - 1
alien-second/src/main/java/shop/alien/second/service/impl/SecondGoodsServiceImpl.java

@@ -324,7 +324,7 @@ public class SecondGoodsServiceImpl extends ServiceImpl<SecondGoodsMapper, Secon
         webSocketVo.setNoticeType("1");
         webSocketVo.setIsRead(0);
         webSocketVo.setText(JSONObject.from(lifeNotice).toJSONString());
-        alienStoreFeign.sendMsgToClientByPhoneIdaaaa(receiverId, JSONObject.from(webSocketVo).toJSONString());
+        alienStoreFeign.sendMsgToClientByPhoneId(receiverId, JSONObject.from(webSocketVo).toJSONString());
     }
 
     /**

+ 44 - 7
alien-second/src/main/java/shop/alien/second/service/impl/SecondTradeRecordServiceImpl.java

@@ -1,6 +1,6 @@
 package shop.alien.second.service.impl;
 
-import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -14,6 +14,7 @@ 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;
@@ -126,8 +127,20 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
         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());
+        WebSocketVo webSocketVo = new WebSocketVo();
+        webSocketVo.setSenderId(phoneId);
+        webSocketVo.setReceiverId(receiverId);
+        webSocketVo.setCategory("message");
+        webSocketVo.setType(messageType);
+        webSocketVo.setIsRead(0);
+        webSocketVo.setText(message.toJSONString());
+        webSocketVo.setMessageId(lifeMessage.getId());
+
+        alienStoreFeign.sendMsgToClientByPhoneId(phoneId, JSONObject.from(webSocketVo).toJSONString());
+        alienStoreFeign.sendMsgToClientByPhoneId(receiverId, JSONObject.from(webSocketVo).toJSONString());
+
+//        alienStoreFeign.sendMsgToClientByPhoneId(phoneId, phoneId, receiverId, "message", messageType, message.toJSONString(), lifeMessage.getId());
+//        alienStoreFeign.sendMsgToClientByPhoneId(receiverId, phoneId, receiverId, "message", messageType, message.toJSONString(), lifeMessage.getId());
     }
 
     @Override
@@ -186,8 +199,20 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
             String receiverId = "user_" + lifeUser.getUserPhone();
 
             // 给买家与卖家发送交易消息
-            alienStoreFeign.sendMsgToClientByPhoneId(phoneId, phoneId, receiverId, "message", "4", lastMessageContent.toJSONString(), lastMessage.getId());
-            alienStoreFeign.sendMsgToClientByPhoneId(receiverId, phoneId, receiverId, "message", "4", lastMessageContent.toJSONString(), lastMessage.getId());
+            WebSocketVo webSocketVo = new WebSocketVo();
+            webSocketVo.setSenderId(phoneId);
+            webSocketVo.setReceiverId(receiverId);
+            webSocketVo.setCategory("message");
+            webSocketVo.setType("4");
+            webSocketVo.setIsRead(0);
+            webSocketVo.setText(lastMessageContent.toJSONString());
+            webSocketVo.setMessageId(lastMessage.getId());
+
+            alienStoreFeign.sendMsgToClientByPhoneId(phoneId, JSONObject.from(webSocketVo).toJSONString());
+            alienStoreFeign.sendMsgToClientByPhoneId(receiverId, JSONObject.from(webSocketVo).toJSONString());
+
+//            alienStoreFeign.sendMsgToClientByPhoneId(phoneId, phoneId, receiverId, "message", "4", lastMessageContent.toJSONString(), lastMessage.getId());
+//            alienStoreFeign.sendMsgToClientByPhoneId(receiverId, phoneId, receiverId, "message", "4", lastMessageContent.toJSONString(), lastMessage.getId());
 
             return true;
         } catch (Exception e) {
@@ -294,8 +319,20 @@ public class SecondTradeRecordServiceImpl extends ServiceImpl<SecondTradeRecordM
             lifeMessageMapper.insert(message);
 
             // 推送已签到消息
-            alienStoreFeign.sendMsgToClientByPhoneId(phoneId, phoneId, receiverId, "message", "6", messageContent.toJSONString(), message.getId());
-            alienStoreFeign.sendMsgToClientByPhoneId(receiverId, phoneId, receiverId, "message", "6", messageContent.toJSONString(), message.getId());
+            WebSocketVo webSocketVo = new WebSocketVo();
+            webSocketVo.setSenderId(phoneId);
+            webSocketVo.setReceiverId(receiverId);
+            webSocketVo.setCategory("message");
+            webSocketVo.setType("6");
+            webSocketVo.setIsRead(0);
+            webSocketVo.setText(messageContent.toJSONString());
+            webSocketVo.setMessageId(message.getId());
+
+            alienStoreFeign.sendMsgToClientByPhoneId(phoneId, JSONObject.from(webSocketVo).toJSONString());
+            alienStoreFeign.sendMsgToClientByPhoneId(receiverId, JSONObject.from(webSocketVo).toJSONString());
+
+//            alienStoreFeign.sendMsgToClientByPhoneId(phoneId, phoneId, receiverId, "message", "6", messageContent.toJSONString(), message.getId());
+//            alienStoreFeign.sendMsgToClientByPhoneId(receiverId, phoneId, receiverId, "message", "6", messageContent.toJSONString(), message.getId());
 
             return true;
         } catch (Exception e) {

+ 30 - 30
alien-store/src/main/java/shop/alien/store/controller/WebSocketController.java

@@ -30,39 +30,39 @@ public class WebSocketController {
 
     private final WebSocketProcess webSocketProcess;
 
-    @ApiOperationSupport(order = 1)
-    @ApiOperation("向指定客户端发消息")
-    @GetMapping(value = "/sendMsgToClientByPhoneId")
-    public R<Boolean> sendMsgToClientByPhoneId(String messageReceiverId,
-                                               String senderId,
-                                               String receiverId,
-                                               String category,
-                                               String type,
-                                               String text,
-                                               Integer messageId) {
-        log.info("WebSocketController.sendMsgToClientByPhoneId?messageReceiverId={}, senderId={}, receiverId={}, category={}, type={}, text={}, messageId={}",
-                messageReceiverId, senderId, receiverId, category, type, text, messageId);
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.put("senderId", senderId);
-        jsonObject.put("receiverId", receiverId);
-        jsonObject.put("category", category);
-        jsonObject.put("type", type);
-        jsonObject.put("text", text);
-        jsonObject.put("messageId", messageId);
-        jsonObject.put("isRead", 0);
-        try {
-            webSocketProcess.sendMessage(messageReceiverId, jsonObject.toJSONString());
-            return R.success("发送成功");
-        } catch (Exception e) {
-            log.error("WebSocketController_sendMsgToClientById Error Mgs={}", e.getMessage());
-        }
-        return R.fail("发送失败");
-    }
+//    @ApiOperationSupport(order = 1)
+//    @ApiOperation("向指定客户端发消息")
+//    @GetMapping(value = "/sendMsgToClientByPhoneId")
+//    public R<Boolean> sendMsgToClientByPhoneId(String messageReceiverId,
+//                                               String senderId,
+//                                               String receiverId,
+//                                               String category,
+//                                               String type,
+//                                               String text,
+//                                               Integer messageId) {
+//        log.info("WebSocketController.sendMsgToClientByPhoneId?messageReceiverId={}, senderId={}, receiverId={}, category={}, type={}, text={}, messageId={}",
+//                messageReceiverId, senderId, receiverId, category, type, text, messageId);
+//        JSONObject jsonObject = new JSONObject();
+//        jsonObject.put("senderId", senderId);
+//        jsonObject.put("receiverId", receiverId);
+//        jsonObject.put("category", category);
+//        jsonObject.put("type", type);
+//        jsonObject.put("text", text);
+//        jsonObject.put("messageId", messageId);
+//        jsonObject.put("isRead", 0);
+//        try {
+//            webSocketProcess.sendMessage(messageReceiverId, jsonObject.toJSONString());
+//            return R.success("发送成功");
+//        } catch (Exception e) {
+//            log.error("WebSocketController_sendMsgToClientById Error Mgs={}", e.getMessage());
+//        }
+//        return R.fail("发送失败");
+//    }
 
     @ApiOperationSupport(order = 1)
     @ApiOperation("向指定客户端发消息")
-    @GetMapping(value = "/sendMsgToClientByPhoneIdaaaa")
-    public R<Boolean> sendMsgToClientByPhoneIdaaaa(String messageReceiverId, String webSocketVoStr) {
+    @GetMapping(value = "/sendMsgToClientByPhoneId")
+    public R<Boolean> sendMsgToClientByPhoneId(String messageReceiverId, String webSocketVoStr) {
         try {
             webSocketProcess.sendMessage(messageReceiverId, webSocketVoStr);
             return R.success("发送成功");