From 730c70af018d50a6ca5a13be2d8fa25c6c42c357 Mon Sep 17 00:00:00 2001
From: rentaiming <806181062@qq.com>
Date: 星期五, 07 六月 2024 18:17:31 +0800
Subject: [PATCH] 用户端商品

---
 ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomGoodsServiceImpl.java |  106 +++++++++++++++++++++++++++++++++++------------------
 1 files changed, 70 insertions(+), 36 deletions(-)

diff --git a/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomGoodsServiceImpl.java b/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomGoodsServiceImpl.java
index 87da14c..fed4c43 100644
--- a/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomGoodsServiceImpl.java
+++ b/ruoyi-modules/ruoyi-auction/src/main/java/com/ruoyi/auction/service/impl/AuctionSalesroomGoodsServiceImpl.java
@@ -3,9 +3,12 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.collect.Lists;
+import com.ruoyi.system.api.constants.NotificationTypeConstant;
 import com.ruoyi.system.api.domain.*;
-import com.ruoyi.system.api.domain.dto.AuctionSalesroomGoodsDTO;
+import com.ruoyi.system.api.domain.dto.AuctionSalesroomDTO;
 import com.ruoyi.system.api.domain.dto.AuctionSalesroomGoodsInfoDTO;
 import com.ruoyi.system.api.domain.vo.AuctionBidRecordVO;
 import com.ruoyi.system.api.domain.vo.AuctionSalesroomGoodsInfoVO;
@@ -38,10 +41,14 @@
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 import javax.annotation.Resource;
 
 import com.ruoyi.system.api.feignClient.SysUserClient;
+import com.ruoyi.system.api.util.WebSocketUsers;
 import org.springframework.stereotype.Service;
+
 
 /**
  * <p>
@@ -78,6 +85,8 @@
     @Resource
     private IAuctionSalesroomService  iAuctionSalesroomService;
 
+    private static final ObjectMapper objectMapper = new ObjectMapper();
+
 
 
 
@@ -87,7 +96,7 @@
      *
      */
     @Override
-    public ForepartAuctionSalesroomGoodsVO getAuctionSalesroomGoods(AuctionSalesroomGoodsDTO ationSalesroomGoodsDTO) {
+    public ForepartAuctionSalesroomGoodsVO getAuctionSalesroomGoods(AuctionSalesroomDTO ationSalesroomGoodsDTO) {
         ForepartAuctionSalesroomGoodsVO forepartAuctionSalesroomGoodsVO =new ForepartAuctionSalesroomGoodsVO();
         AuctionSalesroom auctionSalesroom = auctionSalesroomMapper.selectById(
                 ationSalesroomGoodsDTO.getAuctionSalesroomId());
@@ -121,7 +130,7 @@
                 .getData();
         forepartAuctionSalesroomGoodsVO.setGoodsSkuId(auctionSalesroomGoods.getId());
         forepartAuctionSalesroomGoodsVO.setGoodsSkuName(goodsSku.getSkuName());
-        forepartAuctionSalesroomGoodsVO.setGoodsSkustatus(auctionSalesroomGoods.getStatus().getCode());
+        forepartAuctionSalesroomGoodsVO.setGoodsSkustatus(auctionSalesroomGoods.getStatus());
         forepartAuctionSalesroomGoodsVO.setStartingPrice(auctionSalesroomGoods.getStartingPrice());
         forepartAuctionSalesroomGoodsVO.setSalesroomStock(auctionSalesroomGoods.getSalesroomStock());
         forepartAuctionSalesroomGoodsVO.setListingDuration(auctionSalesroomGoods.getListingDuration());
@@ -156,7 +165,7 @@
      *
      */
     @Override
-    public AuctionSalesroomVO getAuctionSalesroominfo(AuctionSalesroomGoodsDTO ationSalesroomGoodsDTO) {
+    public AuctionSalesroomVO getAuctionSalesroominfo(AuctionSalesroomDTO ationSalesroomGoodsDTO) {
         ForepartAuctionSalesroomGoodsVO forepartAuctionSalesroomGoodsVO =new ForepartAuctionSalesroomGoodsVO();
         AuctionSalesroom auctionSalesroom = auctionSalesroomMapper.selectById(
                 ationSalesroomGoodsDTO.getAuctionSalesroomId());
@@ -185,7 +194,7 @@
                 forepartAuctionSalesroomGoodsVO1.setCoverPic(goodsSku.getCoverPic());
                 auctionSalesroomGoodsVOS.add(forepartAuctionSalesroomGoodsVO1);
             }
-        }if (auctionSalesroom.getStatus().getCode()==2){
+        }if (auctionSalesroom.getStatus().getCode()==1){
             List list =new ArrayList();
             LambdaQueryWrapper<AuctionSalesroomGoods> wrapper=Wrappers.lambdaQuery();
             wrapper.eq(AuctionSalesroomGoods::getStatus,1);
@@ -199,6 +208,8 @@
             GoodsSku goodsSku=goodsSkuOne.getData();
             currentAuctionSalesroomGoods.setGoodsSkuName(goodsSku.getSkuName());
             currentAuctionSalesroomGoods.setCoverPic(goodsSku.getCoverPic());
+            currentAuctionSalesroomGoods.setStartTime(auctionSalesroomGoods.getStartTime());
+            currentAuctionSalesroomGoods.setListingDuration(auctionSalesroomGoods.getListingDuration());
             auctionSalesroomVO.setCurrentAuctionSalesroomGoods(currentAuctionSalesroomGoods);
 
             list.add(auctionSalesroomGoods.getSortNum());
@@ -232,37 +243,13 @@
                 GoodsSku goodsSku2=goodsSkuOne2.getData();
                 forepartAuctionSalesroomGoodsVO1.setGoodsSkuName(goodsSku2.getSkuName());
                 forepartAuctionSalesroomGoodsVO1.setCoverPic(goodsSku2.getCoverPic());
+                forepartAuctionSalesroomGoodsVO1.setGoodsSkustatus(salesroomGoods.getStatus());
                 auctionSalesroomGoodsVOS.add(forepartAuctionSalesroomGoodsVO1);
             }
 
 
         }
         auctionSalesroomVO.setElseAuctionSalesroomGoods(auctionSalesroomGoodsVOS);
-
-        LocalDateTime now = LocalDateTime.now();
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-        String formattedDate = now.format(formatter);
-        LocalDateTime parseTime = LocalDateTime.parse(formattedDate, formatter);
-        LocalDateTime newTime7 = now.minusDays(7);
-        String formattedDate7 = newTime7.format(formatter);
-        LocalDateTime parseTime7 = LocalDateTime.parse(formattedDate7, formatter);
-
-        LambdaQueryWrapper<AuctionBrowseRecord> wrapper3=Wrappers.lambdaQuery();
-        wrapper3.eq(AuctionBrowseRecord::getDelFlag,0);
-        wrapper3.eq(AuctionBrowseRecord::getTargetId,ationSalesroomGoodsDTO.getAuctionSalesroomId());
-        wrapper3.eq(AuctionBrowseRecord::getMemberId,ationSalesroomGoodsDTO.getMemberId());
-        wrapper3.ge(AuctionBrowseRecord::getCreateTime, parseTime7)
-                .le(AuctionBrowseRecord::getCreateTime, parseTime);
-        List<AuctionBrowseRecord> list = iAuctionBrowseRecordService.list(wrapper3);
-        if (list.size()==0){
-            AuctionBrowseRecord auctionBrowseRecord=new AuctionBrowseRecord();
-            auctionBrowseRecord.setBrowseType(AuctionOrderTypeEnum.AUCTION_ITEMS);
-            auctionBrowseRecord.setMemberId(ationSalesroomGoodsDTO.getMemberId());
-            auctionBrowseRecord.setTargetId(ationSalesroomGoodsDTO.getAuctionSalesroomId());
-            iAuctionBrowseRecordService.save(auctionBrowseRecord);
-        }
-
-
 
 
         return auctionSalesroomVO;
@@ -278,7 +265,7 @@
      *
      */
     @Override
-    public void auctionSalesroomStart(AuctionSalesroomGoodsDTO ationSalesroomGoodsDTO) {
+    public void auctionSalesroomStart(AuctionSalesroomDTO ationSalesroomGoodsDTO) {
         AuctionSalesroom auctionSalesroom = auctionSalesroomMapper.selectById(
                 ationSalesroomGoodsDTO.getAuctionSalesroomId());
         auctionSalesroom.setStatus(AuctionStartStatusEnum.IN_AUCTION);
@@ -293,7 +280,19 @@
         wrapper2.last("limit 1");
         AuctionSalesroomGoods auctionSalesroomGoods = this.getOne(wrapper2);
         auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.IN_PROGRESS);
+        auctionSalesroomGoods.setStartTime(LocalDateTime.now());
         this.updateById(auctionSalesroomGoods);
+
+        Map<String, Object> map = new ConcurrentHashMap<>();
+        map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM);
+        map.put("auctionSalesroomId", auctionSalesroom.getId());
+        map.put("message_type", "start");
+        String msg = null;
+        try {
+            msg = objectMapper.writeValueAsString(map);
+        } catch (JsonProcessingException e) {
+        }
+        WebSocketUsers.sendMessageToUsersByText(msg);
 
     }
 
@@ -303,7 +302,7 @@
      *
      */
     @Override
-    public void auctionSalesroomEnd(AuctionSalesroomGoodsDTO ationSalesroomGoodsDTO) {
+    public void auctionSalesroomEnd(AuctionSalesroomDTO ationSalesroomGoodsDTO) {
         AuctionSalesroom auctionSalesroom = auctionSalesroomMapper.selectById(
                 ationSalesroomGoodsDTO.getAuctionSalesroomId());
         auctionSalesroom.setStatus(AuctionStartStatusEnum.ENDED);
@@ -345,6 +344,17 @@
             orderClient.getOrderAuctionBond(orderAuctionBondDTO,
                     SecurityConstants.INNER);
         }
+
+        Map<String, Object> map = new ConcurrentHashMap<>();
+        map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM);
+        map.put("auctionSalesroomId", auctionSalesroom.getId());
+        map.put("message_type", "end");
+        String msg = null;
+        try {
+            msg = objectMapper.writeValueAsString(map);
+        } catch (JsonProcessingException e) {
+        }
+        WebSocketUsers.sendMessageToUsersByText(msg);
     }
 
 
@@ -353,7 +363,7 @@
      *
      */
     @Override
-    public List<AuctionSalesroomGoods> isAuctionSalesroom(AuctionSalesroomGoodsDTO ationSalesroomGoodsDTO) {
+    public List<AuctionSalesroomGoods> isAuctionSalesroom(AuctionSalesroomDTO ationSalesroomGoodsDTO) {
         LambdaQueryWrapper<AuctionSalesroomGoods> wrapper2=Wrappers.lambdaQuery();
         wrapper2.eq(AuctionSalesroomGoods::getStatus,0);
         wrapper2.eq(AuctionSalesroomGoods::getDelFlag,0);
@@ -368,7 +378,7 @@
      *
      */
     @Override
-    public void auctionSalesroomGoodsStart(AuctionSalesroomGoodsDTO auctionSalesroomGoodsDTO) {
+    public void auctionSalesroomGoodsStart(AuctionSalesroomDTO auctionSalesroomGoodsDTO) {
         LambdaQueryWrapper<AuctionSalesroomGoods> wrapper2=Wrappers.lambdaQuery();
         wrapper2.eq(AuctionSalesroomGoods::getAuctionSalesroomId,auctionSalesroomGoodsDTO.getAuctionSalesroomId());
         wrapper2.eq(AuctionSalesroomGoods::getDelFlag,0);
@@ -377,7 +387,18 @@
         auctionSalesroomGoods.setStatus(AuctionGoodsStatusEnum.IN_PROGRESS);
         this.updateById(auctionSalesroomGoods);
 
-
+        Map<String, Object> map = new ConcurrentHashMap<>();
+        map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM_GOODS);
+        map.put("notification_time", LocalDateTime.now());
+        map.put("goodsSkuId", auctionSalesroomGoods.getId());
+        map.put("message_type", "start");
+        String msg = null;
+        try {
+            msg = objectMapper.writeValueAsString(map);
+        } catch (JsonProcessingException e) {
+            throw new RuntimeException(e);
+        }
+        WebSocketUsers.sendMessageToUsersByText(msg);
     }
 
 
@@ -387,7 +408,7 @@
      *
      */
     @Override
-    public void auctionSalesroomGoodsEnd(AuctionSalesroomGoodsDTO auctionSalesroomGoodsDTO) {
+    public void auctionSalesroomGoodsEnd(AuctionSalesroomDTO auctionSalesroomGoodsDTO) {
         LambdaQueryWrapper<AuctionSalesroomGoods> wrapper2=Wrappers.lambdaQuery();
         wrapper2.eq(AuctionSalesroomGoods::getAuctionSalesroomId,auctionSalesroomGoodsDTO.getAuctionSalesroomId());
         wrapper2.eq(AuctionSalesroomGoods::getDelFlag,0);
@@ -435,6 +456,19 @@
         auctionSalesroomGood.setStatus(AuctionGoodsStatusEnum.ENDED);
         this.updateById(auctionSalesroomGood);
 
+        Map<String, Object> map = new ConcurrentHashMap<>();
+        map.put("notification_type", NotificationTypeConstant.AUCTION_SALESROOM_GOODS);
+        map.put("notification_time", LocalDateTime.now());
+        map.put("goodsSkuId", auctionSalesroomGoods.getId());
+        map.put("message_type", "end");
+        String msg = null;
+        try {
+            msg = objectMapper.writeValueAsString(map);
+        } catch (JsonProcessingException e) {
+            throw new RuntimeException(e);
+        }
+        WebSocketUsers.sendMessageToUsersByText(msg);
+
     }
 
     @Override

--
Gitblit v1.7.1