From 73ea7810ea849cac30910a627d78e0cc41a6329a Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Wed, 10 Nov 2021 15:35:28 +0800
Subject: [PATCH] 20211108

---
 gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsListVo.java    |   15 +++++++++++++++
 gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java |   13 +++++++++++++
 gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsDetailVo.java  |    6 ++++++
 3 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java b/gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java
index 69b6199..6a97396 100644
--- a/gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java
+++ b/gc-shop/src/main/java/com/xzx/gc/shop/service/GoodsService.java
@@ -46,6 +46,8 @@
     ScoreGoodsStyleMapper scoreGoodsStyleMapper;
     @Resource
     ScoreGoodsSearchMapper scoreGoodsSearchMapper;
+    @Resource
+    ScoreOrderMapper scoreOrderMapper;
 
     @Autowired
     private MqUtil mqUtil;
@@ -327,6 +329,17 @@
 
         PageHelper.startPage(xcxGoodsListDto.getPageNo(), xcxGoodsListDto.getPageSize());
         List<XcxGoodsListVo> data = scoreGoodsMapper.selectXcxGoodsList(xcxGoodsListDto);
+        if(StrUtil.isNotEmpty(xcxGoodsListDto.getUserId())){
+            if(CollUtil.isNotEmpty(data)){
+                for(XcxGoodsListVo xcxGoodsListVo : data){
+                    if(ScoreGoods.ISQG_YES == xcxGoodsListVo.getIsQg()){
+                        //抢购时间内,用户购买该商品的数量
+                        Integer sumCnt = scoreOrderMapper.selectGoodsQuotaTime(xcxGoodsListDto.getUserId(),xcxGoodsListVo.getId(),xcxGoodsListVo.getQgStartTime(),xcxGoodsListVo.getQgEndTime());
+                        xcxGoodsListVo.setAvaQuotaTime(xcxGoodsListVo.getQuotaTime() - sumCnt);
+                    }
+                }
+            }
+        }
         if(StrUtil.isNotEmpty(xcxGoodsListDto.getName())){
             Example exampleSearch = new Example(ScoreGoodsSearch.class);
             Example.Criteria criteriaSearch = exampleSearch.createCriteria();
diff --git a/gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsDetailVo.java b/gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsDetailVo.java
index 934c2e6..a0268ef 100644
--- a/gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsDetailVo.java
+++ b/gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsDetailVo.java
@@ -57,6 +57,12 @@
     @ApiModelProperty(value = "剩余时间")
     private Long remainTime;
 
+    @ApiModelProperty(value = "限购数量")
+    private Integer quotaTime;
+
+    @ApiModelProperty(value = "剩余限购数量")
+    private Integer avaQuotaTime;
+
     @ApiModelProperty(value = "样式")
     private List<XcxGoodsDetailStyleVo> styles;
 
diff --git a/gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsListVo.java b/gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsListVo.java
index ea8fce1..77f48c9 100644
--- a/gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsListVo.java
+++ b/gc-shop/src/main/java/com/xzx/gc/shop/vo/XcxGoodsListVo.java
@@ -1,8 +1,11 @@
 package com.xzx.gc.shop.vo;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+
+import java.util.Date;
 
 @Data
 @ApiModel(value = "XcxGoodsListVo", description = "小程序商品列表返回参数类")
@@ -29,6 +32,18 @@
     @ApiModelProperty(value = "库存")
     private Integer stock;
 
+    @ApiModelProperty(value = "限购数量")
+    private Integer quotaTime;
+
+    @ApiModelProperty(value = "剩余限购数量")
+    private Integer avaQuotaTime;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private Date qgStartTime;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private Date qgEndTime;
+
     @ApiModelProperty(value = "是否抢购 1-是 2-否")
     private Integer isQg;
 }

--
Gitblit v1.9.1