From ebe36b26782231d6d6f40a76c6e3cbb23d1b2714 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期三, 02 七月 2025 18:58:29 +0800
Subject: [PATCH] update 修改商品发布支持预售
---
seller-api/src/main/java/cn/lili/controller/goods/GoodsStoreController.java | 3 +
framework/src/main/java/cn/lili/modules/search/entity/dto/EsGoodsSearchDTO.java | 3 +
framework/src/main/java/cn/lili/modules/goods/mapper/GoodsSkuMapper.java | 2
framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java | 23 +++++++++++
framework/src/main/java/cn/lili/modules/goods/entity/enums/GoodsSalesModeEnum.java | 1
framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java | 17 ++++++++
framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java | 15 +++++++
framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java | 8 ++++
framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java | 24 ++++++++++--
framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSkuDTO.java | 16 ++++++++
consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java | 2 +
11 files changed, 108 insertions(+), 6 deletions(-)
diff --git a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java
index 555d3d4..78a065f 100644
--- a/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java
+++ b/consumer/src/main/java/cn/lili/listener/GoodsMessageListener.java
@@ -406,6 +406,8 @@
}
goodsIndex.setAuthFlag(goods.getAuthFlag());
goodsIndex.setMarketEnable(goods.getMarketEnable());
+ goodsIndex.setPreSaleBeginDate(goods.getPreSaleBeginDate());
+ goodsIndex.setPreSaleEndDate(goods.getPreSaleEndDate());
this.settingUpGoodsIndexOtherParam(goodsIndex);
return goodsIndex;
}
diff --git a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java
index e597687..0b2d077 100644
--- a/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java
+++ b/framework/src/main/java/cn/lili/elasticsearch/BaseElasticsearchService.java
@@ -168,6 +168,14 @@
" \"type\": \"date\",\n" +
" \"format\": \"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis\"\n" +
" },\n" +
+ " \"preSaleEndDate\": {\n" +
+ " \"type\": \"date\",\n" +
+ " \"format\": \"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis\"\n" +
+ " },\n" +
+ " \"preSaleBeginDate\": {\n" +
+ " \"type\": \"date\",\n" +
+ " \"format\": \"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis\"\n" +
+ " },\n" +
" \"categoryPath\": {\n" +
" \"type\": \"text\",\n" +
" \"fielddata\": true,\n" +
diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java
index d8b663a..f233523 100644
--- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java
+++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java
@@ -17,17 +17,21 @@
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
import com.xkcoding.http.util.StringUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
+import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+import java.util.Date;
import java.util.Map;
/**
@@ -157,7 +161,17 @@
@ApiModelProperty(value = "鍟嗗搧鍙傛暟json", hidden = true)
private String params;
+ @ApiModelProperty(value = "棰勫敭缁撴潫鏃堕棿")
+ @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
+ private Date preSaleEndDate;
+ @ApiModelProperty(value = "棰勫敭寮�濮嬫椂闂�")
+ @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
+ private Date preSaleBeginDate;
+ @ApiModelProperty(value = "鎶芥垚姣斾緥")
+ private BigDecimal commission;
public Goods() {
}
@@ -175,6 +189,9 @@
this.mobileIntro = goodsOperationDTO.getMobileIntro();
this.goodsVideo = goodsOperationDTO.getGoodsVideo();
this.price = goodsOperationDTO.getPrice();
+ this.preSaleEndDate = goodsOperationDTO.getPreSaleEndDate();
+ this.preSaleBeginDate = goodsOperationDTO.getPreSaleBeginDate();
+ this.commission = goodsOperationDTO.getCommission();
if (goodsOperationDTO.getGoodsParamsDTOList() != null && goodsOperationDTO.getGoodsParamsDTOList().isEmpty()) {
this.params = JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsDTOList());
}
diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java
index b795f16..d96d861 100644
--- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java
+++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsOperationDTO.java
@@ -3,17 +3,17 @@
import cn.lili.common.validation.EnumValue;
import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum;
import cn.lili.modules.goods.entity.enums.GoodsTypeEnum;
+import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.hibernate.validator.constraints.Length;
+import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.Valid;
import javax.validation.constraints.*;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.math.BigDecimal;
+import java.util.*;
/**
* 鍟嗗搧鎿嶄綔DTO
@@ -141,6 +141,22 @@
@ApiModelProperty(value = "娴忚鏉冮檺")
private String browsePermissions;
+
+ @ApiModelProperty(value = "棰勫敭缁撴潫鏃堕棿")
+ @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
+ private Date preSaleEndDate;
+
+ @ApiModelProperty(value = "棰勫敭寮�濮嬫椂闂�")
+ @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
+ private Date preSaleBeginDate;
+
+ @ApiModelProperty(value = "鎶芥垚姣斾緥")
+ @DecimalMax(value = "100",message = "鎶芥垚姣斾緥蹇呴』灏忎簬100")
+ @DecimalMin(value = "0",message = "鎶芥垚姣斾緥蹇呴』澶т簬0")
+ private BigDecimal commission;
+
public String getGoodsName() {
//瀵瑰晢鍝佸鍚嶇О鍋氫竴涓瀬闄愬鐞嗐�傝繖閲屾病鏈夌敤xss杩囨护鏄洜涓簒ss杩囨护涓哄叏灞�杩囨护锛屽奖鍝嶅緢澶с��
// 涓氬姟涓紝鍏ㄥ眬浠g爜涓彧鏈夊晢鍝佸悕绉颁笉鑳芥嫢鏈夎嫳鏂囬�楀彿锛屾槸鐢变簬鍟嗗搧鍚嶇О瀛樺湪涓�涓暟鎹簱鑱斿悎鏌ヨ锛岀粨鏋滆鏍规嵁閫楀彿鍒嗙粍
diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSkuDTO.java b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSkuDTO.java
index a93db09..2d105d4 100644
--- a/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSkuDTO.java
+++ b/framework/src/main/java/cn/lili/modules/goods/entity/dto/GoodsSkuDTO.java
@@ -1,11 +1,15 @@
package cn.lili.modules.goods.entity.dto;
import cn.lili.modules.goods.entity.dos.GoodsSku;
+import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
/**
* @author paulG
@@ -22,4 +26,16 @@
@ApiModelProperty(value = "鍟嗗搧鍙傛暟json")
private String params;
+
+ @ApiModelProperty(value = "棰勫敭缁撴潫鏃堕棿")
+ @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
+ private Date preSaleEndDate;
+
+ @ApiModelProperty(value = "棰勫敭寮�濮嬫椂闂�")
+ @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
+ private Date preSaleBeginDate;
+
+
}
diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/enums/GoodsSalesModeEnum.java b/framework/src/main/java/cn/lili/modules/goods/entity/enums/GoodsSalesModeEnum.java
index b6d03aa..21e7a3f 100644
--- a/framework/src/main/java/cn/lili/modules/goods/entity/enums/GoodsSalesModeEnum.java
+++ b/framework/src/main/java/cn/lili/modules/goods/entity/enums/GoodsSalesModeEnum.java
@@ -9,6 +9,7 @@
public enum GoodsSalesModeEnum {
RETAIL("闆跺敭"),
+ PRESALE("棰勫敭"),
WHOLESALE("鎵瑰彂");
private final String description;
diff --git a/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsSkuMapper.java b/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsSkuMapper.java
index 6b65a74..189fa33 100644
--- a/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsSkuMapper.java
+++ b/framework/src/main/java/cn/lili/modules/goods/mapper/GoodsSkuMapper.java
@@ -114,7 +114,7 @@
* @param queryWrapper 鏌ヨ鏉′欢
* @return 鍞悗VO鍒嗛〉
*/
- @Select("SELECT *,g.params as params FROM li_goods_sku gs inner join li_goods g on gs.goods_id = g.id ${ew.customSqlSegment}")
+ @Select("SELECT *,g.params as params,g.pre_sale_end_date,g.pre_sale_begin_date FROM li_goods_sku gs inner join li_goods g on gs.goods_id = g.id ${ew.customSqlSegment}")
IPage<GoodsSkuDTO> queryByParams(IPage<GoodsSkuDTO> page, @Param(Constants.WRAPPER) Wrapper<GoodsSkuDTO> queryWrapper);
@Select("SELECT id as sku_id, quantity, goods_id,simple_specs,sn,goods_name FROM li_goods_sku ${ew.customSqlSegment}")
diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java
index 493f594..acb53be 100644
--- a/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java
+++ b/framework/src/main/java/cn/lili/modules/search/entity/dos/EsGoodsIndex.java
@@ -6,6 +6,8 @@
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
import cn.lili.modules.promotion.tools.PromotionTools;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -15,6 +17,7 @@
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
+import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.ArrayList;
@@ -271,6 +274,18 @@
@Field(type = FieldType.Nested)
private List<EsGoodsAttribute> attrList;
+
+ @ApiModelProperty(value = "棰勫敭缁撴潫鏃堕棿")
+ @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
+ @Field(type = FieldType.Date)
+ private Date preSaleEndDate;
+
+ @ApiModelProperty(value = "棰勫敭寮�濮嬫椂闂�")
+ @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
+ @Field(type = FieldType.Date)
+ private Date preSaleBeginDate;
/**
* 鍟嗗搧淇冮攢娲诲姩闆嗗悎
* key 涓� 淇冮攢娲诲姩绫诲瀷
diff --git a/framework/src/main/java/cn/lili/modules/search/entity/dto/EsGoodsSearchDTO.java b/framework/src/main/java/cn/lili/modules/search/entity/dto/EsGoodsSearchDTO.java
index ba73b62..0563531 100644
--- a/framework/src/main/java/cn/lili/modules/search/entity/dto/EsGoodsSearchDTO.java
+++ b/framework/src/main/java/cn/lili/modules/search/entity/dto/EsGoodsSearchDTO.java
@@ -79,6 +79,9 @@
@ApiModelProperty("鏄惁寮�鍚晢鍝佽繃婊�")
private Boolean canFilter;
+ @ApiModelProperty("鏄惁闇�瑕佸紑鍚繃婊ら鍞晢鍝�")
+ private Boolean needFilterPre;
+
//杩囨护鎼滅储鍏抽敭瀛�
diff --git a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java
index 0cadc1c..79d904b 100644
--- a/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/search/serviceimpl/EsGoodsSearchServiceImpl.java
@@ -48,6 +48,10 @@
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.stereotype.Service;
+import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@@ -93,7 +97,7 @@
cache.incrementScore(CachePrefix.HOT_WORD.getPrefix(), searchDTO.getKeyword());
}
NativeSearchQueryBuilder searchQueryBuilder = createSearchQueryBuilder(searchDTO, pageVo);
- if (Objects.nonNull(searchDTO.getCanFilter())&&searchDTO.getCanFilter()){
+ if (Objects.nonNull(searchDTO.getCanFilter()) && searchDTO.getCanFilter()) {
searchQueryBuilder.withCollapseField("goodsId.keyword");
}
NativeSearchQuery searchQuery = searchQueryBuilder.build();
@@ -557,6 +561,23 @@
if (CharSequenceUtil.isNotEmpty(searchDTO.getPromotionsId()) && CharSequenceUtil.isNotEmpty(searchDTO.getPromotionType())) {
filterBuilder.must(QueryBuilders.wildcardQuery("promotionMapJson", "*" + searchDTO.getPromotionType() + "-" + searchDTO.getPromotionsId() + "*"));
}
+
+ if (Objects.nonNull(searchDTO.getNeedFilterPre()) && searchDTO.getNeedFilterPre()) {
+ // 杞崲涓哄綋澶� 00:00:00 鐨勬椂闂存埑锛堟绉掞級
+ long time = LocalDate.now().atStartOfDay(ZoneId.systemDefault())
+ .toInstant()
+ .toEpochMilli();
+ // 鏉′欢2锛氶鍞粨鏉熸椂闂� >= 褰撳墠鏃堕棿 OR 缁撴潫鏃堕棿涓虹┖
+ filterBuilder.must(QueryBuilders.boolQuery()
+ .should(QueryBuilders.rangeQuery("preSaleEndDate").gte(time))
+ .should(QueryBuilders.boolQuery()
+ .mustNot(QueryBuilders.existsQuery("preSaleEndDate"))));
+ // 鏉′欢1锛氶鍞紑濮嬫椂闂� <= 褰撳墠鏃堕棿 OR 寮�濮嬫椂闂翠负绌�
+ filterBuilder.must(QueryBuilders.boolQuery()
+ .should(QueryBuilders.rangeQuery("preSaleBeginDate").lte(time))
+ .should(QueryBuilders.boolQuery()
+ .mustNot(QueryBuilders.existsQuery("preSaleBeginDate"))));
+ }
//浠锋牸鍖洪棿鍒ゅ畾
if (CharSequenceUtil.isNotEmpty(searchDTO.getPrice())) {
String[] prices = searchDTO.getPrice().split("_");
diff --git a/seller-api/src/main/java/cn/lili/controller/goods/GoodsStoreController.java b/seller-api/src/main/java/cn/lili/controller/goods/GoodsStoreController.java
index 8142cdf..ef7bfb9 100644
--- a/seller-api/src/main/java/cn/lili/controller/goods/GoodsStoreController.java
+++ b/seller-api/src/main/java/cn/lili/controller/goods/GoodsStoreController.java
@@ -27,6 +27,7 @@
import cn.lili.modules.store.entity.dos.StoreDetail;
import cn.lili.modules.store.service.StoreDetailService;
import cn.lili.utils.COSUtil;
+import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -148,6 +149,7 @@
@ApiOperation(value = "鏂板鍟嗗搧")
@PostMapping(value = "/create", consumes = "application/json", produces = "application/json")
public ResultMessage<GoodsOperationDTO> save(@Valid @RequestBody GoodsOperationDTO goodsOperationDTO) {
+ System.err.println(JSONObject.toJSONString(goodsOperationDTO));
goodsService.addGoods(goodsOperationDTO);
return ResultUtil.success();
}
@@ -155,6 +157,7 @@
@ApiOperation(value = "淇敼鍟嗗搧")
@PutMapping(value = "/update/{goodsId}", consumes = "application/json", produces = "application/json")
public ResultMessage<GoodsOperationDTO> update(@Valid @RequestBody GoodsOperationDTO goodsOperationDTO, @PathVariable String goodsId) {
+ System.err.println(JSONObject.toJSONString(goodsOperationDTO));
goodsService.editGoods(goodsOperationDTO, goodsId);
return ResultUtil.success();
}
--
Gitblit v1.8.0