Quellcode durchsuchen

Merge remote-tracking branch 'remotes/origin/developer' into developerA

Aslee vor 3 Jahren
Ursprung
Commit
a128aca9e7
31 geänderte Dateien mit 1295 neuen und 709 gelöschten Zeilen
  1. 20 10
      src/main/java/com/caimei365/commodity/components/PriceUtilService.java
  2. 72 37
      src/main/java/com/caimei365/commodity/components/SearchOpenService.java
  3. 81 50
      src/main/java/com/caimei365/commodity/controller/ProductPageApi.java
  4. 16 15
      src/main/java/com/caimei365/commodity/controller/ProductPriceApi.java
  5. 29 11
      src/main/java/com/caimei365/commodity/controller/ProductSellerApi.java
  6. 81 51
      src/main/java/com/caimei365/commodity/controller/SearchProductApi.java
  7. 3 0
      src/main/java/com/caimei365/commodity/mapper/PromotionsMapper.java
  8. 60 15
      src/main/java/com/caimei365/commodity/mapper/SearchMapper.java
  9. 6 0
      src/main/java/com/caimei365/commodity/mapper/SellerMapper.java
  10. 3 0
      src/main/java/com/caimei365/commodity/model/search/ProductDO.java
  11. 4 0
      src/main/java/com/caimei365/commodity/model/search/ProductListVo.java
  12. 1 1
      src/main/java/com/caimei365/commodity/model/vo/PriceVo.java
  13. 2 0
      src/main/java/com/caimei365/commodity/model/vo/PromotionsVo.java
  14. 27 18
      src/main/java/com/caimei365/commodity/service/PageService.java
  15. 7 5
      src/main/java/com/caimei365/commodity/service/PriceService.java
  16. 6 2
      src/main/java/com/caimei365/commodity/service/SearchProductService.java
  17. 20 8
      src/main/java/com/caimei365/commodity/service/SellerService.java
  18. 1 1
      src/main/java/com/caimei365/commodity/service/impl/CouponServiceImpl.java
  19. 47 33
      src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java
  20. 10 11
      src/main/java/com/caimei365/commodity/service/impl/PriceServiceImpl.java
  21. 152 121
      src/main/java/com/caimei365/commodity/service/impl/SearchIndexServiceImpl.java
  22. 234 52
      src/main/java/com/caimei365/commodity/service/impl/SearchProductServiceImpl.java
  23. 44 2
      src/main/java/com/caimei365/commodity/service/impl/SellerServiceImpl.java
  24. 2 2
      src/main/java/com/caimei365/commodity/service/impl/ShopServiceImpl.java
  25. 2 2
      src/main/java/com/caimei365/commodity/service/impl/UserLikeServiceImpl.java
  26. 10 5
      src/main/java/com/caimei365/commodity/utils/Json2PojoUtil.java
  27. 1 3
      src/main/resources/mapper/PageMapper.xml
  28. 70 66
      src/main/resources/mapper/PromotionsMapper.xml
  29. 158 108
      src/main/resources/mapper/SearchMapper.xml
  30. 111 63
      src/main/resources/mapper/SellerMapper.xml
  31. 15 17
      src/test/java/com/caimei365/commodity/ProductApplicationTests.java

+ 20 - 10
src/main/java/com/caimei365/commodity/components/PriceUtilService.java

@@ -31,12 +31,14 @@ public class PriceUtilService {
     private PromotionsMapper promotionsMapper;
     @Value("${caimei.wwwDomain}")
     private String domain;
+
     /**
      * 根据价格返回价格等级
+     *
      * @param price 价格
      * @return priceGrade 价格等级
      */
-    public Integer getPriceGrade(Double price){
+    public Integer getPriceGrade(Double price) {
         int grade = 1;
         price = price != null ? price : 0d;
         if (price > 50 * 10000) {
@@ -53,8 +55,9 @@ public class PriceUtilService {
 
     /**
      * 设置阶梯价展示数据
-     * @param ladderPrices  List<LadderPriceVo>
-     * @param tax           TaxVo
+     *
+     * @param ladderPrices List<LadderPriceVo>
+     * @param tax          TaxVo
      */
     public void setLadderPriceList(List<LadderPriceVo> ladderPrices, TaxVo tax) {
         IntStream.range(0, ladderPrices.size()).forEach(i -> {
@@ -63,7 +66,7 @@ public class PriceUtilService {
             //添加税费
             if (taxFlag) {
                 BigDecimal taxFee = MathUtil.div(MathUtil.mul(ladderPrices.get(i).getBuyPrice(), tax.getTaxPoint()), 100, 2);
-                ladderPrices.get(i).setBuyPrice(MathUtil.add(ladderPrices.get(i).getBuyPrice(),taxFee).doubleValue());
+                ladderPrices.get(i).setBuyPrice(MathUtil.add(ladderPrices.get(i).getBuyPrice(), taxFee).doubleValue());
             }
             if (i == ladderPrices.size() - 1) {
                 ladderPrices.get(i).setMaxNum(0);
@@ -79,10 +82,10 @@ public class PriceUtilService {
     /**
      * 根据用户id设置详细价格
      *
-     * @param price 商品价格类
+     * @param price  商品价格类
      * @param userId 用户Id
      */
-    public void setPriceByUserId(PriceVo price, Integer userId) {
+    public void setPriceByUserId(PriceVo price, Integer userId, Integer flag) {
         // 根据用户Id查询用户身份
         Integer identity = priceMapper.getIdentityByUserId(userId);
         // 根据用户Id查询超级会员id
@@ -91,6 +94,12 @@ public class PriceUtilService {
         boolean svipUserFlag = null != svipUserId;
         // 根据商品id查询商品活动
         PromotionsVo promotions = promotionsMapper.getPromotionsByProductId(price.getProductId());
+        // 如果身份不是机构,并且促销活动不可见,直接把促销置空
+        if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 2 && flag == 1) {
+            promotions = null;
+        }else if (promotions != null && promotions.getSeen() != null && identity!=null && promotions.getSeen() == 2 && identity == 1) {
+            promotions = null;
+        }
         price.setRepurchaseFlag(0);
         price.setActStatus(0);
         if (null != identity && identity > 0) {
@@ -146,10 +155,10 @@ public class PriceUtilService {
                         LadderPriceVo lowerPrice = priceMapper.findLowerLadderPrice(price.getProductId());
                         LadderPriceVo lowerBuyNum = priceMapper.findMaxLadderPrice(price.getProductId());
                         if (null != lowerPrice) {
-                            price.setPrice(lowerPrice.getBuyPrice());
                             price.setMaxBuyNumber(lowerPrice.getBuyNum());
-                            if (null != lowerBuyNum){
+                            if (null != lowerBuyNum) {
                                 price.setMinBuyNumber(lowerBuyNum.getBuyNum());
+                                price.setPrice(lowerBuyNum.getBuyPrice());
                             }
                         } else {
                             price.setLadderPriceFlag(0);
@@ -194,10 +203,11 @@ public class PriceUtilService {
 
     /**
      * 设置商品主图及价格
+     *
      * @param userId  用户Id
      * @param product ProductItemVo
      */
-    public void setProductDetails(Integer userId, ProductItemVo product) {
+    public void setProductDetails(Integer userId, ProductItemVo product, Integer flag) {
         // 设置图片
         product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
         // 设置价格等级
@@ -205,7 +215,7 @@ public class PriceUtilService {
         // 数据库获取基本价格信息
         PriceVo price = priceMapper.getDetailPrice(product.getProductId());
         // 根据用户id设置详细价格
-        setPriceByUserId(price, userId);
+        setPriceByUserId(price, userId, flag);
         // 设置价格
         product.setActStatus(price.getActStatus());
         product.setPrice(price.getPrice());

+ 72 - 37
src/main/java/com/caimei365/commodity/components/SearchOpenService.java

@@ -42,16 +42,17 @@ public class SearchOpenService {
     @Value("${aliyunConfig.searchHost}")
     private String host;
 
-    public String getAppName(){
+    public String getAppName() {
         return this.appName;
     }
+
     /**
      * 推送操作
      *
      * @param document doc
      * @return result
      * @throws OpenSearchClientException exp
-     * @throws OpenSearchException exp
+     * @throws OpenSearchException       exp
      */
     public String pushDocument(String document, String tableName) throws OpenSearchClientException, OpenSearchException {
         // 创建并构造OpenSearch对象
@@ -69,13 +70,14 @@ public class SearchOpenService {
     /**
      * 获取查询结果
      *
-     * @param queryStr      查询类型及参数串
-     * @param searchParams  搜索参数obj
+     * @param queryStr     查询类型及参数串
+     * @param searchParams 搜索参数obj
      * @return JSONObject
      * @throws OpenSearchClientException exp
      * @throws OpenSearchException       exp
      */
     public JSONObject getResultJsonObject(String queryStr, SearchParams searchParams) throws OpenSearchClientException, OpenSearchException {
+        log.info("【阿里云开放搜索】查询参数:"+ searchParams.toString());
         // 创建并构造OpenSearch对象
         OpenSearch openSearch = new OpenSearch(accesskey, secret, host);
         // 创建OpenSearchClient对象,并以OpenSearch对象作为构造参数
@@ -98,7 +100,7 @@ public class SearchOpenService {
         String tracer = jsonObj.getString("tracer");
         JSONObject result = jsonObj.getJSONObject("result");
         JSONArray errors = jsonObj.getJSONArray("errors");
-        log.info(">>>>>>query("+queryStr+"): " + status + ",request_id=" +requestId+ ",errors=" + errors.toString() + ",tracer="+tracer);
+        log.info(">>>>>>query(" + queryStr + "): " + status + ",request_id=" + requestId + ",errors=" + errors.toString() + ",tracer=" + tracer);
         if ("OK".equals(status)) {
             result.put("status", 1);
         } else {
@@ -120,7 +122,7 @@ public class SearchOpenService {
     public SearchParams getSearchParams(String queryStr, ArrayList<String> fetchFields, List<Map<String, String>> summaryFields, String rankName, int num, int size, String sortField, Integer sortType) {
         // 定义Config对象,用于设定config子句参数,指定应用名,分页,数据返回格式等等
         Config config = new Config(Lists.newArrayList(appName));
-        config.setStart(num-1);
+        config.setStart(num - 1);
         config.setHits(size);
         // 设置搜索结果返回应用中哪些字段
         config.setFetchFields(fetchFields);
@@ -177,9 +179,9 @@ public class SearchOpenService {
     /**
      * 获取默认滚动查询参数
      *
-     * @param queryStr      查询类型及参数
-     * @param fetchFields   返回字段
-     * @param size          每页数量
+     * @param queryStr    查询类型及参数
+     * @param fetchFields 返回字段
+     * @param size        每页数量
      * @return searchParams
      */
     public SearchParams getScrollParams(String queryStr, ArrayList<String> fetchFields, int size, String sortField, Integer sortType) {
@@ -219,10 +221,10 @@ public class SearchOpenService {
     public SearchParams getProductParams(String queryStr, String filter, Integer identity, int num, int size, String sortField, Integer sortType) {
         // 定义Config对象,用于设定config子句参数,指定应用名,分页,数据返回格式等等
         Config config = new Config(Lists.newArrayList(appName));
-        config.setStart(num-1);
+        config.setStart(num - 1);
         config.setHits(size);
         // 设置搜索结果返回应用中哪些字段
-        config.setFetchFields(Lists.newArrayList("id", "p_id", "p_name", "p_image", "p_brand_name", "p_unit", "p_code", "p_price_flag", "p_price_grade", "p_supplier_id", "p_keyword", "p_act_flag"));
+        config.setFetchFields(Lists.newArrayList("id", "p_id", "p_name", "p_image", "p_brand_name", "p_unit", "p_code", "p_price_flag", "p_price_grade", "p_supplier_id", "p_keyword", "p_act_flag", "p_brand_id"));
         // 注意:config子句中的rerank_size参数,在Rank类对象中设置
         // 设置返回格式为json格式
         config.setSearchFormat(SearchFormat.JSON);
@@ -285,7 +287,7 @@ public class SearchOpenService {
         if (StringUtils.isNotEmpty(sortField) && Arrays.asList(sortFields).contains(sortField)) {
             Order order = (1 == sortType) ? Order.DECREASE : Order.INCREASE;
             // 设置排序字段
-            sorter.addToSortFields(new SortField("p_"+sortField, order));
+            sorter.addToSortFields(new SortField("p_" + sortField, order));
         }
         // 以RANK相关性算分降序
         sorter.addToSortFields(new SortField("RANK", Order.DECREASE));
@@ -326,7 +328,7 @@ public class SearchOpenService {
         // config.setStart(0) scroll该参数不起作用,默认为0
         config.setHits(size);
         // 设置搜索结果返回应用中哪些字段
-        config.setFetchFields(Lists.newArrayList("id", "p_id", "p_name", "p_image", "p_brand_name", "p_unit", "p_code", "p_price_flag", "p_price_grade", "p_supplier_id", "p_keyword", "p_act_flag"));
+        config.setFetchFields(Lists.newArrayList("id", "p_id", "p_name", "p_image", "p_brand_name", "p_unit", "p_code", "p_price_flag", "p_price_grade", "p_supplier_id", "p_keyword", "p_act_flag", "p_brand_id"));
         // 设置返回格式为json格式
         config.setSearchFormat(SearchFormat.JSON);
         // 创建参数对象
@@ -361,7 +363,7 @@ public class SearchOpenService {
             Order order = (1 == sortType) ? Order.DECREASE : Order.INCREASE;
             // 设置排序字段
             sorter.addToSortFields(new SortField(sortField, order));
-        }else{
+        } else {
             // 默认商品ID倒序
             sorter.addToSortFields(new SortField("p_id", Order.DECREASE));
         }
@@ -374,16 +376,16 @@ public class SearchOpenService {
     /**
      * 滚动查询
      *
-     * @param searchParams  查询参数对象
-     * @param queryStr 查询类型及参数串
-     * @param pageNum       页码
-     * @param pageSize      每页数量
-     * @param requestPageSize  每次scroll数量
+     * @param searchParams    查询参数对象
+     * @param queryStr        查询类型及参数串
+     * @param pageNum         页码
+     * @param pageSize        每页数量
+     * @param requestPageSize 每次scroll数量
      * @return list
      */
     public JSONObject deepPagingForParams(SearchParams searchParams, String queryStr, int maxSearchNum, int requestPageSize, int pageNum, int pageSize) throws OpenSearchClientException, OpenSearchException {
         //设置scroll方式查询
-        DeepPaging deep =new DeepPaging();
+        DeepPaging deep = new DeepPaging();
         //不设置默认为1m表示1分钟,该参数表示本次返回的scrollid的有效期
         deep.setScrollExpire("3m");
         //添加DeepPaging对象参数
@@ -394,12 +396,12 @@ public class SearchOpenService {
         int status = result.getInt("status");
         pageObj.put("status", status);
         if (1 == status) {
-            int requestSize = pageNum*pageSize;
+            int requestSize = pageNum * pageSize;
             int total = result.getInt("total");
-            int totalPage = (int) Math.ceil( (double)total/pageSize);
+            int totalPage = (int) Math.ceil((double) total / pageSize);
             JSONArray pageData = new JSONArray();
-            int loop = (int)Math.ceil((double) requestSize / requestPageSize);
-            for (int l=1; l<=loop; l++) {
+            int loop = (int) Math.ceil((double) requestSize / requestPageSize);
+            for (int l = 1; l <= loop; l++) {
                 //第一次执行不返回数据,主要返回scroll_id值,第二次调用查询时设置scroll_id
                 deep.setScrollId(result.getString("scroll_id"));
                 //不设置默认为1m表示1分钟,如不想使用默认值,每次重新调用前必须要重新设置下
@@ -408,15 +410,15 @@ public class SearchOpenService {
                 result = getResultJsonObject(queryStr, searchParams);
                 if (1 == status) {
                     JSONArray resultArr = result.getJSONArray("items");
-                    if (resultArr.length()>0){
-                        if (requestSize > maxSearchNum){
-                            if (l==loop) {
-                                int baseSize = Math.min(requestSize - (requestPageSize*(loop-1)), resultArr.length());
+                    if (resultArr.length() > 0) {
+                        if (requestSize > maxSearchNum) {
+                            if (l == loop) {
+                                int baseSize = Math.min(requestSize - (requestPageSize * (loop - 1)), resultArr.length());
                                 // 上一页数量往前总数量 - 上一轮循环后总数量 = 当前循环的上一页之前数量
-                                int baseNum = pageSize*(pageNum-1) - requestPageSize*(loop-1);
-                                for (int i=0; i<pageSize; i++) {
+                                int baseNum = pageSize * (pageNum - 1) - requestPageSize * (loop - 1);
+                                for (int i = 0; i < pageSize; i++) {
                                     int index = baseNum + i;
-                                    if (index<baseSize){
+                                    if (index < baseSize) {
                                         JSONObject item = resultArr.getJSONObject(index);
                                         pageData.put(i, item);
                                     } else {
@@ -425,14 +427,14 @@ public class SearchOpenService {
                                 }
                             }
                         } else {
-                            int baseNum = (pageNum-1)*pageSize;
+                            int baseNum = (pageNum - 1) * pageSize;
                             int currentTotal = requestSize;
-                            if (totalPage == pageNum){
+                            if (totalPage == pageNum) {
                                 currentTotal = total;
                             }
-                            for (int i=0; i<pageSize; i++) {
+                            for (int i = 0; i < pageSize; i++) {
                                 int index = baseNum + i;
-                                if (index<currentTotal){
+                                if (index < currentTotal) {
                                     JSONObject item = resultArr.getJSONObject(index);
                                     pageData.put(i, item);
                                 } else {
@@ -445,12 +447,45 @@ public class SearchOpenService {
             }
             pageObj.put("total", total);
             pageObj.put("items", pageData);
-            log.info(">>>>>>pageResult("+queryStr+"): pageSize(" + pageSize +"),pageNum("+pageNum+"),total("+total+")");
+            log.info(">>>>>>pageResult(" + queryStr + "): pageSize(" + pageSize + "),pageNum(" + pageNum + "),total(" + total + ")");
         }
         return pageObj;
     }
 
 
-
+    public SearchParams getParams(String queryStr, Integer identity, String filter) {
+        // 定义Config对象,用于设定config子句参数,指定应用名,分页,数据返回格式等等
+        Config config = new Config(Lists.newArrayList(appName));
+        // 设置搜索结果返回应用中哪些字段
+        config.setFetchFields(Lists.newArrayList("p_brand_name", "p_brand_id"));
+        // 设置返回格式为json格式
+        config.setSearchFormat(SearchFormat.JSON);
+        // 创建参数对象
+        SearchParams searchParams = new SearchParams(config);
+        // 设置查询子句,若需多个索引组合查询,需要setQuery处合并,否则若设置多个setQuery后面的会替换前面查询
+        searchParams.setQuery(queryStr);
+        // identity: 0个人,1协销,2会员机构,3供应商,4普通机构
+        // p_valid:0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已隐身 10已冻结
+        // p_visibility:3:所有人可见,2:普通机构可见,1:会员机构可见
+        String thisFilter = "";
+        if (identity == 1) {
+            // 协销 | 综合供应商
+            thisFilter += "(p_valid=2 OR p_valid=3 OR p_valid=9) AND p_type=1";
+        } else if (identity == 2) {
+            // 会员机构
+            thisFilter += "p_valid=2 AND p_type=1";
+        } else if (identity == 4) {
+            // 普通机构
+            thisFilter += "(p_visibility=2 OR p_visibility=3) AND p_valid=2 AND p_type=1";
+        } else {
+            // 游客|所有人
+            thisFilter += "p_visibility=3 AND p_valid=2 AND p_type=1";
+        }
+        if (StringUtils.isNotEmpty(filter)) {
+            thisFilter = thisFilter + " AND " + filter;
+        }
+        searchParams.setFilter(thisFilter);
+        return searchParams;
+    }
 
 }

+ 81 - 50
src/main/java/com/caimei365/commodity/controller/ProductPageApi.java

@@ -22,13 +22,14 @@ import java.util.Map;
  * @author : Charles
  * @date : 2021/4/12
  */
-@Api(tags="商品页面数据API")
+@Api(tags = "商品页面数据API")
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/commodity")
 public class ProductPageApi {
 
     private final PageService pageService;
+
     /**
      * 获取分类列表
      *
@@ -37,8 +38,8 @@ public class ProductPageApi {
      */
     @ApiOperation("获取分类菜单(旧:/product/classify)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = true, name = "typeSort", value = "分类类型:1产品,2仪器,0全部"),
-        @ApiImplicitParam(required = false, name = "source", value = "请求来源:www,crm")
+            @ApiImplicitParam(required = true, name = "typeSort", value = "分类类型:1产品,2仪器,0全部"),
+            @ApiImplicitParam(required = false, name = "source", value = "请求来源:www,crm")
     })
     @GetMapping("/classify")
     public ResponseJson<List<BigTypeVo>> getClassify(Integer typeSort, String source) {
@@ -54,16 +55,18 @@ public class ProductPageApi {
      */
     @ApiOperation("产品/仪器页面数据(旧:/home/instrumentData)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = true, name = "pageId", value = "页面信息id"),
-        @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-        @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
+            @ApiImplicitParam(required = true, name = "pageId", value = "页面信息id"),
+            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
+            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序"),
+            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
     })
     @GetMapping("/classify/product")
-    public ResponseJson<Map<String, Object>> getClassifyData(Integer pageId, Integer userId, Integer source) {
+    public ResponseJson<Map<String, Object>> getClassifyData(Integer pageId, Integer userId, Integer source,
+                                                             @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
         if (pageId == null) {
             return ResponseJson.error("参数异常", null);
         }
-        return pageService.getClassifyData(pageId, userId, source);
+        return pageService.getClassifyData(pageId, userId, source, flag);
     }
 
     /**
@@ -74,12 +77,14 @@ public class ProductPageApi {
      */
     @ApiOperation("首页楼层数据(旧:/home/data)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-        @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
+            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
+            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序"),
+            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
     })
     @GetMapping("/home/floor")
-    public ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source) {
-        return pageService.getHomeData(userId, source);
+    public ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source,
+                                                         @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
+        return pageService.getHomeData(userId, source, flag);
     }
 
     /**
@@ -140,49 +145,55 @@ public class ProductPageApi {
      */
     @ApiOperation("活动专题楼层数据(美博会)(旧:/home/activity/data)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = false, name = "pageId", value = "页面id"),
-        @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-        @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
+            @ApiImplicitParam(required = false, name = "pageId", value = "页面id"),
+            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
+            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序"),
+            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
     })
     @GetMapping("/page/beauty")
-    public ResponseJson<Map<String, Object>> getPageBeautyData(Integer pageId, Integer userId, Integer source) {
-        return pageService.getPageBeautyData(pageId, userId, source);
+    public ResponseJson<Map<String, Object>> getPageBeautyData(Integer pageId, Integer userId, Integer source,
+                                                               @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
+        return pageService.getPageBeautyData(pageId, userId, source,flag);
     }
 
     /**
      * 楼层详情
      *
      * @param floorId 楼层id
-     * @param userId 用户id
-     * @param source 来源 : 1 网站 ; 2 小程序
+     * @param userId  用户id
+     * @param source  来源 : 1 网站 ; 2 小程序
      */
     @ApiOperation("楼层详情(旧:/home/floorContentDetails)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = false, name = "floorId", value = "楼层id"),
-        @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-        @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
+            @ApiImplicitParam(required = false, name = "floorId", value = "楼层id"),
+            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
+            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序"),
+            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
     })
     @GetMapping("/page/floor/details")
-    public ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source) {
-        return pageService.getPageFloorData(floorId, userId, source);
+    public ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source,
+                                                              @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
+        return pageService.getPageFloorData(floorId, userId, source, flag);
     }
 
     /**
      * 分页详情楼层详情
      *
      * @param centreId 分页详情楼层id
-     * @param userId 用户id
-     * @param source 来源 : 1 网站 ; 2 小程序
+     * @param userId   用户id
+     * @param source   来源 : 1 网站 ; 2 小程序
      */
     @ApiOperation("分页详情楼层详情(旧:/home/pageFloorDetails)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = false, name = "centreId", value = "分页详情楼层id"),
-        @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-        @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
+            @ApiImplicitParam(required = false, name = "centreId", value = "分页详情楼层id"),
+            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
+            @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序"),
+            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
     })
     @GetMapping("/page/floor/centre")
-    public ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source) {
-        return pageService.getPageCentreData(centreId, userId, source);
+    public ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source,
+                                                               @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
+        return pageService.getPageCentreData(centreId, userId, source, flag);
     }
 
     /**
@@ -193,12 +204,13 @@ public class ProductPageApi {
      */
     @ApiOperation("商品详情页(旧:/product/details)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
-        @ApiImplicitParam(required = false, name = "productId", value = "商品Id")
+            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
+            @ApiImplicitParam(required = false, name = "productId", value = "商品Id"),
+            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
     })
     @GetMapping("/product/details")
-    public ResponseJson<ProductDetailVo> getProductDetails(Integer productId, Integer userId) {
-        return pageService.getProductDetails(productId, userId);
+    public ResponseJson<ProductDetailVo> getProductDetails(Integer productId, Integer userId, @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
+        return pageService.getProductDetails(productId, userId, flag);
     }
 
     /**
@@ -208,15 +220,17 @@ public class ProductPageApi {
      */
     @ApiOperation("再次购买商品列表(旧:/repeat/buyAgain)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = false, name = "userId", value = "用户Id"),
-        @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-        @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+            @ApiImplicitParam(required = false, name = "userId", value = "用户Id"),
+            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
     @GetMapping("/product/repeat")
     public ResponseJson<PaginationVo<ProductItemVo>> getBuyAgainProducts(Integer userId,
+                                                                         @RequestParam(value = "flag", defaultValue = "2") Integer flag,
                                                                          @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                                          @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
-        return pageService.getBuyAgainProducts(userId, pageNum, pageSize);
+        return pageService.getBuyAgainProducts(userId, flag, pageNum, pageSize);
     }
 
 
@@ -259,15 +273,15 @@ public class ProductPageApi {
     /**
      * 商品详情页-相关推荐
      *
-     * @param productId 商品Id
+     * @param productId     商品Id
      * @param recommendType 相关推荐类型: 0自动选择, 1手动推荐
-     * @param userId    用户Id
+     * @param userId        用户Id
      */
     @ApiOperation("商品详情-相关推荐(旧:/product/detail/recommend)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = false, name = "productId", value = "商品Id"),
-        @ApiImplicitParam(required = false, name = "recommendType", value = "相关推荐类型: 0自动选择, 1手动推荐"),
-        @ApiImplicitParam(required = false, name = "userId", value = "用户id")
+            @ApiImplicitParam(required = false, name = "productId", value = "商品Id"),
+            @ApiImplicitParam(required = false, name = "recommendType", value = "相关推荐类型: 0自动选择, 1手动推荐"),
+            @ApiImplicitParam(required = false, name = "userId", value = "用户id")
     })
     @GetMapping("/detail/recommend")
     public ResponseJson<List<ProductListVo>> getProductDetailRecommends(Integer productId, Integer recommendType, Integer userId) {
@@ -276,6 +290,7 @@ public class ProductPageApi {
 
     /**
      * 商品维修(链接分享数据)
+     *
      * @param code 维修code
      */
     @ApiOperation("商品维修(链接分享)")
@@ -314,15 +329,16 @@ public class ProductPageApi {
     @GetMapping("/product/archive/detail")
     public ResponseJson<ArchiveDetailVo> getArchiveDetail(Integer archiveId, Integer userId) {
         if (null == archiveId || null == userId) {
-            return ResponseJson.error("参数错误",  null);
+            return ResponseJson.error("参数错误", null);
         }
         return pageService.getArchiveDetail(archiveId, userId);
     }
 
     /**
      * 超级会员优惠商品页面
-     * @param userId    用户id
-     * @param source    来源 : 1 网站 ; 2 小程序
+     *
+     * @param userId 用户id
+     * @param source 来源 : 1 网站 ; 2 小程序
      * @return
      */
     @ApiOperation("超级会员优惠商品页面")
@@ -330,15 +346,30 @@ public class ProductPageApi {
             @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
             @ApiImplicitParam(required = false, name = "source", value = "来源 : 1 网站 ; 2 小程序"),
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),
+            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
     })
     @GetMapping("/svip/product/page")
     public ResponseJson<Map<String, Object>> getSvipProductPage(Integer userId, Integer source,
                                                                 @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                                                @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+                                                                @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
+                                                                @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
         if (null == userId || source == null) {
             return ResponseJson.error("参数错误", null);
         }
-        return pageService.getSvipProductPage(userId, source, pageNum, pageSize);
+        return pageService.getSvipProductPage(userId, source, pageNum, pageSize, flag);
+    }
+
+    /**
+     * 充值商品详情
+     */
+    @ApiOperation("充值商品详情(旧:/product/rechargeGoods)")
+    @ApiImplicitParam(required = false, name = "productId", value = "商品Id")
+    @GetMapping("/recharge/details")
+    public ResponseJson<ProductDetailVo> getRechargeGoods(Integer productId) {
+        if (productId == null) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return pageService.getRechargeGoods(productId);
     }
 }

+ 16 - 15
src/main/java/com/caimei365/commodity/controller/ProductPriceApi.java

@@ -11,10 +11,7 @@ import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.lang.StringUtils;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -41,14 +38,15 @@ public class ProductPriceApi {
     @ApiOperation("获取商品详情价格(旧:/product/detail/price)(注意:supplierId更改为shopId)")
     @ApiImplicitParams({
             @ApiImplicitParam(required = true, name = "userId", value = "用户Id"),
-            @ApiImplicitParam(required = true, name = "productId", value = "商品Id")
+            @ApiImplicitParam(required = true, name = "productId", value = "商品Id"),
+            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
     })
     @GetMapping("/detail")
-    public ResponseJson<PriceVo> getDetailPrice(Integer userId, Integer productId) {
+    public ResponseJson<PriceVo> getDetailPrice(Integer userId, Integer productId, @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
         if (null == userId || null == productId) {
             return ResponseJson.error("参数错误", null);
         }
-        return priceService.getDetailPrice(userId, productId);
+        return priceService.getDetailPrice(userId, productId, flag);
     }
 
     /**
@@ -61,14 +59,16 @@ public class ProductPriceApi {
     @ApiImplicitParams({
             @ApiImplicitParam(required = true, name = "userId", value = "用户Id"),
             @ApiImplicitParam(required = true, name = "productIds", value = "商品Ids,逗号拼接"),
-            @ApiImplicitParam(required = true, name = "source", value = "来源 : 1 网站 ; 2 小程序")
+            @ApiImplicitParam(required = true, name = "source", value = "来源 : 1 网站 ; 2 小程序"),
+            @ApiImplicitParam(required = false, name = "flag", value = "协销身份标记: 1 协销 2机构 3供应商")
     })
     @GetMapping("/list")
-    public ResponseJson<List<PriceVo>> getProductPrice(Integer userId, String productIds, Integer source) {
+    public ResponseJson<List<PriceVo>> getProductPrice(Integer userId, String productIds, Integer source,
+                                                       @RequestParam(value = "flag", defaultValue = "2") Integer flag) {
         if (null == userId || StringUtils.isEmpty(productIds) || source == null) {
             return ResponseJson.error("参数错误", null);
         }
-        return priceService.getListPrice(userId, productIds, source);
+        return priceService.getListPrice(userId, productIds, source, flag);
     }
 
     /**
@@ -88,16 +88,17 @@ public class ProductPriceApi {
 
     /**
      * 更新商品销量
+     *
      * @param productSalesDto {productInfo: [ // 商品id,数量
-     *                                      {"productId": 2789, "productCount": 1},
-     *                                      {"productId": 2790, "productCount": 2}
-     *                                       ]
+     *                        {"productId": 2789, "productCount": 1},
+     *                        {"productId": 2790, "productCount": 2}
+     *                        ]
      *                        }
      */
     @ApiOperation("更新商品销量")
     @PostMapping("/sales/update")
-    public ResponseJson<Void> productSaleUpdate(ProductSalesDto productSalesDto){
-        if (StringUtils.isEmpty(productSalesDto.getProductInfo())){
+    public ResponseJson<Void> productSaleUpdate(ProductSalesDto productSalesDto) {
+        if (StringUtils.isEmpty(productSalesDto.getProductInfo())) {
             return ResponseJson.error("商品数据不能为空!", null);
         }
         return priceService.productSaleUpdate(productSalesDto.getProductInfo());

+ 29 - 11
src/main/java/com/caimei365/commodity/controller/ProductSellerApi.java

@@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
  * @author : Charles
  * @date : 2021/4/23
  */
-@Api(tags="协销商品API")
+@Api(tags = "协销商品API")
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/commodity/seller")
@@ -33,15 +33,15 @@ public class ProductSellerApi {
      */
     @ApiOperation("协销搜索单一商品(旧:/seller/product/search)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = false, name = "searchWord", value = "搜索关键字"),
-        @ApiImplicitParam(required = false, name = "clubUserId", value = "机构用户Id"),
-        @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-        @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+            @ApiImplicitParam(required = false, name = "searchWord", value = "搜索关键字"),
+            @ApiImplicitParam(required = false, name = "clubUserId", value = "机构用户Id"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
     @GetMapping("/product/single")
     public ResponseJson<PaginationVo<ProductItemVo>> searchSingleProducts(String searchWord, Integer clubUserId,
-                                                                            @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                                                            @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+                                                                          @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                          @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
         return sellerService.searchSingleProducts(searchWord, clubUserId, pageNum, pageSize);
     }
 
@@ -50,10 +50,10 @@ public class ProductSellerApi {
      */
     @ApiOperation("协销搜索组合商品(旧:/seller/combinationProduct/search)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = false, name = "searchWord", value = "搜索关键字"),
-        @ApiImplicitParam(required = false, name = "clubUserId", value = "机构用户Id"),
-        @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-        @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+            @ApiImplicitParam(required = false, name = "searchWord", value = "搜索关键字"),
+            @ApiImplicitParam(required = false, name = "clubUserId", value = "机构用户Id"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
     @GetMapping("/product/combination")
     public ResponseJson<PaginationVo<CombinationVo>> searchCombinationProducts(String searchWord, Integer clubUserId,
@@ -62,4 +62,22 @@ public class ProductSellerApi {
         return sellerService.searchCombinationProducts(searchWord, clubUserId, pageNum, pageSize);
     }
 
+    /**
+     * 组合商品列表
+     */
+    @ApiOperation("组合商品列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, name = "productId", value = "本商品id"),
+            @ApiImplicitParam(required = true, name = "userId", value = "用户Id"),
+            @ApiImplicitParam(required = true, name = "source", value = "来源 : 1 网站 ; 2 小程序"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+    })
+    @GetMapping("/combination/list")
+    public ResponseJson<PaginationVo<ProductItemVo>> searchCombinationList(Integer productId, Integer userId, Integer source,
+                                                                           @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                           @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+        return sellerService.searchCombinationList(productId, userId, source, pageNum, pageSize);
+    }
+
 }

+ 81 - 51
src/main/java/com/caimei365/commodity/controller/SearchProductApi.java

@@ -14,8 +14,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * 搜索商品(阿里云搜索)
@@ -23,7 +25,7 @@ import java.util.Map;
  * @author : Charles
  * @date : 2021/4/7
  */
-@Api(tags="搜索商品API")
+@Api(tags = "搜索商品API")
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/commodity/search/query")
@@ -31,9 +33,27 @@ public class SearchProductApi {
 
     private final SearchProductService searchProductService;
 
+
+    @ApiOperation("根据keyword或分类搜品牌")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = false, name = "keyword", value = "搜索关键字"),
+            @ApiImplicitParam(required = false, name = "id", value = "bigTypeID/smallTypeID/tinyTypeID"),
+            @ApiImplicitParam(required = false, name = "newFlag", value = "查询新品标记,默认0,新品1"),
+            @ApiImplicitParam(required = false, name = "promotionFlag", value = "查询促销标记,默认0,促销1"),
+            @ApiImplicitParam(required = false, name = "idType", value = "id类型:1一级分类,2二级分类,3三级分类"),
+            @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构")
+    })
+    @GetMapping("/brand")
+    public ResponseJson<Set<HashMap<String, Object>>> queryBrand(String keyword, Integer id, Integer idType,
+                                                                 @RequestParam(value = "newFlag", defaultValue = "0") Integer newFlag,
+                                                                 @RequestParam(value = "promotionFlag", defaultValue = "0") Integer promotionFlag,
+                                                                 @RequestParam(value = "identity", defaultValue = "0") Integer identity) {
+        return searchProductService.queryBrand(keyword, id, idType, newFlag, promotionFlag, identity);
+    }
+
     /**
      * 根据关键词搜索商品
-     *
+     * <p>
      * spi旧接口:/search/query/product
      *
      * @param keyword 搜索关键字
@@ -41,25 +61,30 @@ public class SearchProductApi {
      */
     @ApiOperation("根据keyword搜索商品")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = false, name = "keyword", value = "搜索关键字"),
-        @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构"),
-        @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-        @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),
-        @ApiImplicitParam(required = false, name = "sortField", value = "排序字段:价格price,销量sales,人气favorite"),
-        @ApiImplicitParam(required = false, name = "sortType", value = "排序规则:1降序,其他升序")
+            @ApiImplicitParam(required = false, name = "keyword", value = "搜索关键字"),
+            @ApiImplicitParam(required = false, name = "brandIds", value = "品牌id字符串,逗号隔开"),
+            @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构"),
+            @ApiImplicitParam(required = false, name = "newFlag", value = "查询新品标记,默认0,新品1"),
+            @ApiImplicitParam(required = false, name = "promotionFlag", value = "查询促销标记,默认0,促销1"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),
+            @ApiImplicitParam(required = false, name = "sortField", value = "排序字段:价格price,销量sales,人气favorite"),
+            @ApiImplicitParam(required = false, name = "sortType", value = "排序规则:1降序,其他升序")
     })
     @GetMapping("/product")
-    public ResponseJson<String> queryProductByKeyword(String keyword,
+    public ResponseJson<String> queryProductByKeyword(String keyword, String brandIds,
                                                       @RequestParam(value = "identity", defaultValue = "0") Integer identity,
+                                                      @RequestParam(value = "newFlag", defaultValue = "0") Integer newFlag,
+                                                      @RequestParam(value = "promotionFlag", defaultValue = "0") Integer promotionFlag,
                                                       @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                       @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
                                                       String sortField, Integer sortType) {
-        return searchProductService.queryProductByKeyword(keyword, identity, pageNum, pageSize, sortField, sortType);
+        return searchProductService.queryProductByKeyword(keyword, brandIds, identity, newFlag, promotionFlag, pageNum, pageSize, sortField, sortType);
     }
 
     /**
      * 根据分类Id搜索商品
-     *
+     * <p>
      * spi旧接口:/search/query/product/type
      *
      * @param id     bigTypeID/smallTypeID/tinyTypeID
@@ -67,73 +92,78 @@ public class SearchProductApi {
      */
     @ApiOperation("根据分类Id搜索商品")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = true, name = "id", value = "bigTypeID/smallTypeID/tinyTypeID"),
-        @ApiImplicitParam(required = true, name = "idType", value = "id类型:1一级分类,2二级分类,3三级分类"),
-        @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构"),
-        @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-        @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),
-        @ApiImplicitParam(required = false, name = "sortField", value = "排序字段:价格price,销量sales,人气favorite"),
-        @ApiImplicitParam(required = false, name = "sortType", value = "排序规则:1降序,其他升序")
+            @ApiImplicitParam(required = true, name = "id", value = "bigTypeID/smallTypeID/tinyTypeID"),
+            @ApiImplicitParam(required = true, name = "idType", value = "id类型:1一级分类,2二级分类,3三级分类"),
+            @ApiImplicitParam(required = false, name = "brandIds", value = "品牌id字符串,逗号隔开"),
+            @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构"),
+            @ApiImplicitParam(required = false, name = "newFlag", value = "查询新品标记,默认0,新品1"),
+            @ApiImplicitParam(required = false, name = "promotionFlag", value = "查询促销标记,默认0,促销1"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),
+            @ApiImplicitParam(required = false, name = "sortField", value = "排序字段:价格price,销量sales,人气favorite"),
+            @ApiImplicitParam(required = false, name = "sortType", value = "排序规则:1降序,其他升序")
     })
     @GetMapping("/product/type")
-    public ResponseJson<String> queryProductByType(Integer id, Integer idType,
-                                            @RequestParam(value = "identity", defaultValue = "0") Integer identity,
-                                            @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                            @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
-                                            String sortField, Integer sortType) {
-        return searchProductService.queryProductByType(id, idType, identity, pageNum, pageSize, sortField, sortType);
+    public ResponseJson<String> queryProductByType(Integer id, Integer idType, String brandIds,
+                                                   @RequestParam(value = "identity", defaultValue = "0") Integer identity,
+                                                   @RequestParam(value = "newFlag", defaultValue = "0") Integer newFlag,
+                                                   @RequestParam(value = "promotionFlag", defaultValue = "0") Integer promotionFlag,
+                                                   @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                   @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
+                                                   String sortField, Integer sortType) {
+        return searchProductService.queryProductByType(id, idType, brandIds, identity, newFlag, promotionFlag, pageNum, pageSize, sortField, sortType);
     }
 
     /**
      * 根据小程序运营分类Id搜索商品
-     *
+     * <p>
      * spi旧接口:/search/query/product/classify
      *
-     * @param id        运营级分类Id
-     * @param identity  用户身份 1:协销, 2:会员机构
+     * @param id       运营级分类Id
+     * @param identity 用户身份 1:协销, 2:会员机构
      */
     @ApiOperation("根据小程序运营分类Id搜索商品")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = true, name = "id", value = "运营级分类Id"),
-        @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构"),
-        @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-        @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),
-        @ApiImplicitParam(required = false, name = "sortField", value = "排序字段:价格price,销量sales,人气favorite"),
-        @ApiImplicitParam(required = false, name = "sortType", value = "排序规则:1降序,其他升序")
+            @ApiImplicitParam(required = true, name = "id", value = "运营级分类Id"),
+            @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),
+            @ApiImplicitParam(required = false, name = "sortField", value = "排序字段:价格price,销量sales,人气favorite"),
+            @ApiImplicitParam(required = false, name = "sortType", value = "排序规则:1降序,其他升序")
     })
     @GetMapping("/product/classify")
     public ResponseJson<String> queryProductByClassify(Integer id,
-                                            @RequestParam(value = "identity", defaultValue = "0") Integer identity,
-                                            @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                            @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
-                                            String sortField, Integer sortType) {
+                                                       @RequestParam(value = "identity", defaultValue = "0") Integer identity,
+                                                       @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                       @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
+                                                       String sortField, Integer sortType) {
         return searchProductService.queryProductByClassify(id, identity, pageNum, pageSize, sortField, sortType);
     }
 
     /**
      * 根据供应商Id搜索商品(商铺内搜索)
-     *
+     * <p>
      * spi旧接口:/search/query/product/supplier
      *
-     * @param id       供应商Id
-     * @param keyword  搜索关键字
+     * @param id      供应商Id
+     * @param keyword 搜索关键字
      */
     @ApiOperation("根据供应商Id搜索商品(商铺内搜索)")
     @ApiImplicitParams({
-        @ApiImplicitParam(required = true, name = "id", value = "供应商Id"),
-        @ApiImplicitParam(required = false, name = "keyword", value = "搜索关键字"),
-        @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构"),
-        @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
-        @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),
-        @ApiImplicitParam(required = false, name = "sortField", value = "排序字段:价格price,销量sales,人气favorite"),
-        @ApiImplicitParam(required = false, name = "sortType", value = "排序规则:1降序,其他升序")
+            @ApiImplicitParam(required = true, name = "id", value = "供应商Id"),
+            @ApiImplicitParam(required = false, name = "keyword", value = "搜索关键字"),
+            @ApiImplicitParam(required = false, name = "identity", value = "用户身份: 0个人,1协销,2会员机构,3供应商,4普通机构"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量"),
+            @ApiImplicitParam(required = false, name = "sortField", value = "排序字段:价格price,销量sales,人气favorite"),
+            @ApiImplicitParam(required = false, name = "sortType", value = "排序规则:1降序,其他升序")
     })
     @GetMapping("/product/shop")
     public ResponseJson<String> querySupplierProduct(Integer id, String keyword,
-                                           @RequestParam(value = "identity", defaultValue = "0") Integer identity,
-                                           @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
-                                           @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
-                                           String sortField, Integer sortType) {
+                                                     @RequestParam(value = "identity", defaultValue = "0") Integer identity,
+                                                     @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                     @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,
+                                                     String sortField, Integer sortType) {
         return searchProductService.querySupplierProduct(id, keyword, identity, pageNum, pageSize, sortField, sortType);
     }
 

+ 3 - 0
src/main/java/com/caimei365/commodity/mapper/PromotionsMapper.java

@@ -44,4 +44,7 @@ public interface PromotionsMapper {
      * @return
      */
     PromotionsVo getPromotionGiftsByProductId(Integer productId);
+
+    Integer findUserIdentity(Integer userId);
+
 }

+ 60 - 15
src/main/java/com/caimei365/commodity/mapper/SearchMapper.java

@@ -2,10 +2,6 @@ package com.caimei365.commodity.mapper;
 
 import com.caimei365.commodity.model.po.SearchHistoryPo;
 import com.caimei365.commodity.model.search.*;
-import com.caimei365.commodity.model.search.ArticleListVo;
-import com.caimei365.commodity.model.search.EquipmentListVo;
-import com.caimei365.commodity.model.search.ProductListVo;
-import com.caimei365.commodity.model.search.ShopListVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -22,41 +18,51 @@ import java.util.List;
 public interface SearchMapper {
     /**
      * 根据商品id查找文档数据
+     *
      * @param productId
      */
     ProductDO searchProductById(Integer productId);
+
     /**
      * 获取商品数量
      */
     Integer findProductCount();
+
     /**
      * 获取商品列表
      */
     List<ProductDO> searchProductList();
+
     /**
      * 根据商品id查找 星范商品数量
      */
     Integer countMallProduct(Integer productId);
+
     /**
      * 根据商品id查找 星范商品
      */
     MallProductDO searchMallProductByProductId(Integer productId);
+
     /**
      * 根据商品id查找 星范阶梯价标志
      */
     Integer getMallLadderPriceFlag(Integer productId);
+
     /**
      * 根据商品id查找 星范最小阶梯价
      */
     Double getMallLowerLadderPrice(Integer productId);
+
     /**
      * 获取供应商数量
      */
     Integer findSupplierCount();
+
     /**
      * 获取供应商列表
      */
     List<SupplierDO> searchSupplierList();
+
     /**
      * 根据供应商Id查找文档数据
      */
@@ -66,10 +72,12 @@ public interface SearchMapper {
      * 获取项目仪器数量
      */
     Integer findEquipmentCount();
+
     /**
      * 获取项目仪器列表
      */
     List<EquipmentDO> searchEquipmentList();
+
     /**
      * 根据项目仪器Id查找文档数据
      */
@@ -79,73 +87,89 @@ public interface SearchMapper {
      * 获取文章数量
      */
     Integer findArticleCount();
+
     /**
      * 获取文章列表
      */
     List<ArticleDO> searchArticleList();
+
     /**
      * 根据文章Id查找文档数据
      */
     ArticleDO searchArticleById(Integer articleId);
+
     /**
      * 根据文章标签查找标签Id
      */
     List<Integer> findLabelIdsByName(@Param("labelTexts") String[] labelTexts);
+
     /**
      * 根据文章Id查找标签文本
      */
     String findLabelNameById(@Param("labelId") Integer labelId);
+
     /**
      * 获取所有失效商品数量
      */
     Integer findProductInvalidCount();
+
     /**
      * 获取失效商品IDs
      */
     List<Integer> findProductInvalidIds();
+
     /**
      * 根据商品ID获取星范ID
      */
     Integer findMallIdByProductId(Integer productId);
+
     /**
      * 根据商品IDs获取星范IDs
      */
     List<Integer> findMallInvalidIdsByProductIds(@Param("invalidIds") List<Integer> invalidIds);
+
     /**
      * 获取所有失效供应商数量
      */
     Integer findSupplierInvalidCount();
+
     /**
      * 获取失效供应商IDs
      */
     List<Integer> findSupplierInvalidIds();
+
     /**
      * 获取所有失效项目仪器数量
      */
     Integer findEquipmentInvalidCount();
+
     /**
      * 获取失效项目仪器IDs
      */
     List<Integer> findEquipmentInvalidIds();
+
     /**
      * 获取所有失效文章数量
      */
     Integer findArticleInvalidCount();
+
     /**
      * 获取失效文章IDs
      */
     List<Integer> findArticleInvalidIds();
+
     /**
      * 获取数据库商品
-     * @param identity  用户身份
-     * @param keyword   关键词
-     * @param shopId    供应商id
-     * @param bigTypeId 一级分类id
+     *
+     * @param identity    用户身份
+     * @param keyword     关键词
+     * @param shopId      供应商id
+     * @param bigTypeId   一级分类id
      * @param smallTypeId 二级分类id
-     * @param tinyTypeId 三级分类id
-     * @param classifyId 运营分类id
-     * @param sortField 排序类型
-     * @param sortType  排序顺序
+     * @param tinyTypeId  三级分类id
+     * @param classifyId  运营分类id
+     * @param sortField   排序类型
+     * @param sortType    排序顺序
      * @return list
      */
     List<ProductListVo> queryProduct(@Param("identity") Integer identity,
@@ -157,51 +181,72 @@ public interface SearchMapper {
                                      @Param("classifyId") Integer classifyId,
                                      @Param("sortField") String sortField,
                                      @Param("sortType") Integer sortType);
+
     /**
      * 获取数据库供应商
-     * @param keyword   关键词
+     *
+     * @param keyword 关键词
      * @return list
      */
     List<ShopListVo> querySupplier(@Param("keyword") String keyword);
+
     /**
      * 获取数据库项目仪器
-     * @param keyword   关键词
+     *
+     * @param keyword 关键词
      * @return list
      */
     List<EquipmentListVo> queryEquipment(@Param("keyword") String keyword);
+
     /**
      * 获取数据库文章
-     * @param keyword   关键词
+     *
+     * @param keyword 关键词
      * @return list
      */
     List<ArticleListVo> queryArticle(@Param("keyword") String keyword, @Param("articleId") Integer articleId, @Param("typeId") Integer typeId, @Param("labelText") String labelText);
+
     /**
      * 根据用户ID查找历史记录
      */
     List<SearchHistoryPo> getHistoryList(Integer userId);
+
     /**
      * 根据关键字获取历史记录Id
+     *
      * @param keyword 关键词
      */
     Integer getHistoryIdByWord(String keyword);
+
     /**
      * 更新历史记录
      */
     void updateSearchHistoryById(SearchHistoryPo historyRecord);
+
     /**
      * 新增取历史记录
      */
     void insertSearchHistory(SearchHistoryPo historyRecord);
+
     /**
      * 历史记录数量
      */
     int getHistoryCount(Integer userId);
+
     /**
      * 删除大于10条的历史记录
      */
     void deleteSearchHistory(Integer userId);
+
     /**
      * 删除用户所有历史记录
      */
     void deleteAllSearchHistory(Integer userId);
+
+    List<Integer> findNew(@Param("productIds") List<Integer> productIds, @Param("n") String n);
+
+    List<Integer> findPromotion(List<Integer> productIds);
+
+    List<Integer> findPromotionId(Integer p_id);
+
 }

+ 6 - 0
src/main/java/com/caimei365/commodity/mapper/SellerMapper.java

@@ -29,4 +29,10 @@ public interface SellerMapper {
      * @param id 组合id
      */
     List<ProductItemVo> getCombinationProductList(Integer id);
+
+    Integer findCombination(Integer productId);
+
+    List<Integer> findProductList(Integer combinationId);
+
+    List<ProductItemVo> getProductList(List<Integer> productIds);
 }

+ 3 - 0
src/main/java/com/caimei365/commodity/model/search/ProductDO.java

@@ -71,5 +71,8 @@ public class ProductDO implements Serializable {
     /** 美博会商品活动状态 */
     private Integer p_act_flag;
 
+    private Integer p_time;
+
+    private Integer p_promotions_id;
     private static final long serialVersionUID = 1L;
 }

+ 4 - 0
src/main/java/com/caimei365/commodity/model/search/ProductListVo.java

@@ -12,6 +12,10 @@ import java.io.Serializable;
  */
 @Data
 public class ProductListVo implements Serializable {
+    /**
+     * 品牌id
+     */
+    private Integer brandId;
     /**
      * 阿里云索引Id
      */

+ 1 - 1
src/main/java/com/caimei365/commodity/model/vo/PriceVo.java

@@ -17,7 +17,7 @@ public class PriceVo implements Serializable {
     /**
      * 促销活动可见性 0所有人,1仅对机构
      */
-    private String promotionsSeen;
+    private Integer seen;
     /**
      * 商品productID
      */

+ 2 - 0
src/main/java/com/caimei365/commodity/model/vo/PromotionsVo.java

@@ -16,6 +16,8 @@ import java.util.List;
 @Data
 public class PromotionsVo implements Serializable {
     private static final long serialVersionUID = 1L;
+
+    private Integer seen;
     private Integer id;
     /**
      * 促销名称

+ 27 - 18
src/main/java/com/caimei365/commodity/service/PageService.java

@@ -30,7 +30,7 @@ public interface PageService {
      * @param userId 用户id
      * @param source 来源:1网站,2小程序
      */
-    ResponseJson<Map<String, Object>> getClassifyData(Integer pageId, Integer userId, Integer source);
+    ResponseJson<Map<String, Object>> getClassifyData(Integer pageId, Integer userId, Integer source, Integer flag);
 
     /**
      * 首页楼层数据
@@ -38,7 +38,7 @@ public interface PageService {
      * @param userId 用户id
      * @param source 来源:1网站,2小程序
      */
-    ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source);
+    ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source, Integer flag);
 
     /**
      * 首页基础数据(小程序)
@@ -49,6 +49,7 @@ public interface PageService {
 
     /**
      * 首页侧边栏数据
+     *
      * @param source 来源 : 1 网站 ; 2 小程序
      */
     ResponseJson<Map<String, Object>> getHomesideBar(Integer source);
@@ -60,6 +61,7 @@ public interface PageService {
 
     /**
      * 二级专题页楼层数据
+     *
      * @param pageId 页面id
      * @param source 来源 : 1 网站 ; 2 小程序
      */
@@ -72,7 +74,7 @@ public interface PageService {
      * @param userId 用户id
      * @param source 来源 : 1 网站 ; 2 小程序
      */
-    ResponseJson<Map<String, Object>> getPageBeautyData(Integer pageId, Integer userId, Integer source);
+    ResponseJson<Map<String, Object>> getPageBeautyData(Integer pageId, Integer userId, Integer source, Integer flag);
 
     /**
      * 楼层详情
@@ -81,7 +83,7 @@ public interface PageService {
      * @param userId  用户id
      * @param source  来源 : 1 网站 ; 2 小程序
      */
-    ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source);
+    ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source, Integer flag);
 
     /**
      * 分页详情楼层详情
@@ -90,7 +92,7 @@ public interface PageService {
      * @param userId   用户id
      * @param source   来源 : 1 网站 ; 2 小程序
      */
-    ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source);
+    ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source, Integer flag);
 
     /**
      * 商品详情页
@@ -98,14 +100,14 @@ public interface PageService {
      * @param productId 商品Id
      * @param userId    用户Id
      */
-    ResponseJson<ProductDetailVo> getProductDetails(Integer productId, Integer userId);
+    ResponseJson<ProductDetailVo> getProductDetails(Integer productId, Integer userId, Integer flag);
 
     /**
      * 再次购买商品列表
      *
      * @param userId 用户Id
      */
-    ResponseJson<PaginationVo<ProductItemVo>> getBuyAgainProducts(Integer userId, int pageNum, int pageSize);
+    ResponseJson<PaginationVo<ProductItemVo>> getBuyAgainProducts(Integer userId, Integer flag, int pageNum, int pageSize);
 
     /**
      * 项目仪器详情页
@@ -156,18 +158,20 @@ public interface PageService {
 
     /**
      * 商品资料列表
-     * @param keyword       搜索关键词
-     * @param productType   商品属性:1产品,2仪器
-     * @param pageNum       页码
-     * @param pageSize      每页数量
+     *
+     * @param keyword     搜索关键词
+     * @param productType 商品属性:1产品,2仪器
+     * @param pageNum     页码
+     * @param pageSize    每页数量
      * @return
      */
     ResponseJson<PaginationVo<ArchiveVo>> getProductArchive(String keyword, Integer productType, Integer pageNum, Integer pageSize);
 
     /**
      * 商品资料详情
-     * @param archiveId     商品资料id
-     * @param userId        用户id
+     *
+     * @param archiveId 商品资料id
+     * @param userId    用户id
      * @return
      */
     ResponseJson<ArchiveDetailVo> getArchiveDetail(Integer archiveId, Integer userId);
@@ -175,12 +179,17 @@ public interface PageService {
     /**
      * 超级会员优惠商品页面
      *
-     * @param userId    用户id
-     * @param source    来源 : 1 网站 ; 2 小程序
-     * @param pageNum   页码
-     * @param pageSize  每页数量
+     * @param userId   用户id
+     * @param source   来源 : 1 网站 ; 2 小程序
+     * @param pageNum  页码
+     * @param pageSize 每页数量
      * @return
      */
-    ResponseJson<Map<String, Object>> getSvipProductPage(Integer userId, Integer source, Integer pageNum, Integer pageSize);
+    ResponseJson<Map<String, Object>> getSvipProductPage(Integer userId, Integer source, Integer pageNum, Integer pageSize, Integer flag);
 
+    /**
+     * 充值商品详情
+     * @param productId 商品id
+     */
+    ResponseJson<ProductDetailVo> getRechargeGoods(Integer productId);
 }

+ 7 - 5
src/main/java/com/caimei365/commodity/service/PriceService.java

@@ -20,7 +20,7 @@ public interface PriceService {
      * @param productId 商品Id
      * @return PriceVo
      */
-    ResponseJson<PriceVo> getDetailPrice(Integer userId, Integer productId);
+    ResponseJson<PriceVo> getDetailPrice(Integer userId, Integer productId, Integer flag);
 
     /**
      * 获取商品列表价格
@@ -30,7 +30,7 @@ public interface PriceService {
      * @param source     来源 : 1 网站 ; 2 小程序
      * @return List<PriceVo>
      */
-    ResponseJson<List<PriceVo>> getListPrice(Integer userId, String productIds, Integer source);
+    ResponseJson<List<PriceVo>> getListPrice(Integer userId, String productIds, Integer source, Integer flag);
 
     /**
      * 获取阶梯价格
@@ -39,12 +39,14 @@ public interface PriceService {
      * @return LadderPriceVo
      */
     ResponseJson<List<LadderPriceVo>> getLadderPrice(Integer productId);
+
     /**
      * 更新商品销量
+     *
      * @param productInfo [ // 商品id,数量
-     *                   {"productId": 2789, "productCount": 1},
-     *                   {"productId": 2790, "productCount": 2}
-     *                 ]
+     *                    {"productId": 2789, "productCount": 1},
+     *                    {"productId": 2790, "productCount": 2}
+     *                    ]
      */
     ResponseJson<Void> productSaleUpdate(String productInfo);
 }

+ 6 - 2
src/main/java/com/caimei365/commodity/service/SearchProductService.java

@@ -3,8 +3,10 @@ package com.caimei365.commodity.service;
 import com.caimei365.commodity.model.ResponseJson;
 import com.caimei365.commodity.model.po.SearchHistoryPo;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
  * Description
@@ -24,7 +26,7 @@ public interface SearchProductService {
      * @param sortType  升降序0/1
      * @return JsonStr(list)
      */
-    ResponseJson<String> queryProductByKeyword(String keyword, Integer identity, int pageNum, int pageSize, String sortField, Integer sortType);
+    ResponseJson<String> queryProductByKeyword(String keyword, String brandIds,Integer identity,Integer newFlag,Integer promotionFlag, int pageNum, int pageSize, String sortField, Integer sortType);
 
     /**
      * 根据分类Id搜索商品
@@ -38,7 +40,7 @@ public interface SearchProductService {
      * @param sortType  升降序0/1
      * @return JsonStr(list)
      */
-    ResponseJson<String> queryProductByType(Integer id, Integer idType, Integer identity, int pageNum, int pageSize, String sortField, Integer sortType);
+    ResponseJson<String> queryProductByType(Integer id, Integer idType, String brandIds,Integer identity,Integer newFlag,Integer promotionFlag, int pageNum, int pageSize, String sortField, Integer sortType);
 
     /**
      * 根据小程序运营分类Id搜索商品
@@ -87,4 +89,6 @@ public interface SearchProductService {
      * 产品仪器热搜词
      */
     ResponseJson<Map<String, Object>> getHotSearchTerms();
+
+    ResponseJson<Set<HashMap<String, Object>>> queryBrand(String keyword, Integer id, Integer idType, Integer newFlag , Integer promotionFlag, Integer identity);
 }

+ 20 - 8
src/main/java/com/caimei365/commodity/service/SellerService.java

@@ -14,19 +14,31 @@ import com.caimei365.commodity.model.vo.ProductItemVo;
 public interface SellerService {
     /**
      * 协销搜索商品(单一)
-     * @param searchWord  搜索关键字
-     * @param clubUserId  机构用户Id
-     * @param pageNum     页码
-     * @param pageSize    每页数量
+     *
+     * @param searchWord 搜索关键字
+     * @param clubUserId 机构用户Id
+     * @param pageNum    页码
+     * @param pageSize   每页数量
      */
     ResponseJson<PaginationVo<ProductItemVo>> searchSingleProducts(String searchWord, Integer clubUserId, int pageNum, int pageSize);
 
     /**
      * 协销搜索商品(组合)
-     * @param searchWord  搜索关键字
-     * @param clubUserId  机构用户Id
-     * @param pageNum     页码
-     * @param pageSize    每页数量
+     *
+     * @param searchWord 搜索关键字
+     * @param clubUserId 机构用户Id
+     * @param pageNum    页码
+     * @param pageSize   每页数量
      */
     ResponseJson<PaginationVo<CombinationVo>> searchCombinationProducts(String searchWord, Integer clubUserId, int pageNum, int pageSize);
+
+    /**
+     * 配套商品列表
+     *
+     * @param productId
+     * @param userId
+     * @param source
+     * @return
+     */
+    ResponseJson<PaginationVo<ProductItemVo>> searchCombinationList(Integer productId, Integer userId, Integer source, int pageNum, int pageSize);
 }

+ 1 - 1
src/main/java/com/caimei365/commodity/service/impl/CouponServiceImpl.java

@@ -100,7 +100,7 @@ public class CouponServiceImpl implements CouponService {
         List<ProductItemVo> productList = couponMapper.findCouponProduct(couponId, source);
         productList.forEach(p -> {
             p.setCouponsLogo(true);
-            priceUtilService.setProductDetails(userId, p);
+            priceUtilService.setProductDetails(userId, p,2);
         });
         PageInfo<ProductItemVo> pageInfo = new PageInfo<>(productList);
         map.put("coupon", coupon);

+ 47 - 33
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -106,7 +106,7 @@ public class PageServiceImpl implements PageService {
      */
     @Override
     @Cacheable(value = "insCommodityData", key = "#pageId+'-'+#userId+'-'+#source", unless = "#result == null")
-    public ResponseJson<Map<String, Object>> getClassifyData(Integer pageId, Integer userId, Integer source) {
+    public ResponseJson<Map<String, Object>> getClassifyData(Integer pageId, Integer userId, Integer source, Integer flag) {
         source = source == null ? 1 : source;
         Map<String, Object> map = new HashMap<>(3);
         Integer typeSort = pageMapper.getPageTypeSort(pageId);
@@ -117,7 +117,7 @@ public class PageServiceImpl implements PageService {
             setFloorLinkType(floorContent);
             floor.setFloorContent(floorContent);
             List<FloorImageVo> floorImageList = pageMapper.getFloorImageByCentreId(floor.getId(), source);
-            setFloorImageProduct(userId, floorImageList, source);
+            setFloorImageProduct(userId, floorImageList, source, flag);
             floor.setFloorImageList(floorImageList);
         }
         map.put("typeSort", typeSort);
@@ -134,7 +134,7 @@ public class PageServiceImpl implements PageService {
      */
     @Cacheable(value = "getHomeCommodityData", key = "#userId +'-'+ #source", unless = "#result == null")
     @Override
-    public ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source) {
+    public ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source, Integer flag) {
         Map<String, Object> map = new HashMap<>(2);
         //楼层管理
         source = source == null ? 1 : source;
@@ -150,7 +150,7 @@ public class PageServiceImpl implements PageService {
                 floorIterator.remove();
                 continue;
             }
-            setFloorImageProduct(userId, floorImageList, source);
+            setFloorImageProduct(userId, floorImageList, source, flag);
             floor.setFloorImageList(floorImageList);
         }
         map.put("homePageFloor", homePageFloor);
@@ -352,7 +352,7 @@ public class PageServiceImpl implements PageService {
      */
     @Cacheable(value = "getPageBeautyData", key = "#userId +'-'+ #pageId +'-'+ #source", unless = "#result == null")
     @Override
-    public ResponseJson<Map<String, Object>> getPageBeautyData(Integer pageId, Integer userId, Integer source) {
+    public ResponseJson<Map<String, Object>> getPageBeautyData(Integer pageId, Integer userId, Integer source, Integer flag) {
         if (pageId == null) {
             return ResponseJson.error("参数异常: 页面id不能为空!", null);
         }
@@ -375,7 +375,7 @@ public class PageServiceImpl implements PageService {
             } else {
                 setFloorLinkType(floorContent);
                 List<FloorImageVo> floorImageList = pageMapper.getFloorImageByCentreId(floor.getId(), source);
-                setFloorImageProduct(userId, floorImageList, source);
+                setFloorImageProduct(userId, floorImageList, source, flag);
                 floor.setFloorImageList(floorImageList);
                 String templateTypeStr = floorContent.getTemplateType();
                 if (StringUtils.isNotEmpty(templateTypeStr)) {
@@ -426,14 +426,14 @@ public class PageServiceImpl implements PageService {
      * @param source  来源 : 1 网站 ; 2 小程序
      */
     @Override
-    public ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source) {
+    public ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source, Integer flag) {
         if (floorId == null) {
             return ResponseJson.error("参数异常: 页面id不能为空!", null);
         }
         FloorContentVo floorContent = pageMapper.getFloorContentById(floorId);
         setFloorLinkType(floorContent);
         List<FloorImageVo> floorImageList = pageMapper.getFloorImageById(floorId, source);
-        setFloorImageProduct(userId, floorImageList, source);
+        setFloorImageProduct(userId, floorImageList, source, flag);
         Map<String, Object> map = new HashMap<>(2);
         map.put("floorContent", floorContent);
         map.put("floorImageList", floorImageList);
@@ -448,7 +448,7 @@ public class PageServiceImpl implements PageService {
      * @param source   来源 : 1 网站 ; 2 小程序
      */
     @Override
-    public ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source) {
+    public ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source, Integer flag) {
         if (centreId == null) {
             return ResponseJson.error("参数异常: 分页详情楼层id不能为空!", null);
         }
@@ -471,7 +471,7 @@ public class PageServiceImpl implements PageService {
             }
         }
         List<FloorImageVo> floorImageList = pageMapper.getFloorImageByCentreId(centreId, source);
-        setFloorImageProduct(userId, floorImageList, source);
+        setFloorImageProduct(userId, floorImageList, source, flag);
         Map<String, Object> map = new HashMap<>(2);
         map.put("floorContent", floorContent);
         map.put("floorImageList", floorImageList);
@@ -485,7 +485,7 @@ public class PageServiceImpl implements PageService {
      * @param userId    用户Id
      */
     @Override
-    public ResponseJson<ProductDetailVo> getProductDetails(Integer productId, Integer userId) {
+    public ResponseJson<ProductDetailVo> getProductDetails(Integer productId, Integer userId, Integer flag) {
         ProductDetailVo product = pageMapper.getProductDetails(productId);
         if (product == null) {
             //商品不存在
@@ -586,7 +586,7 @@ public class PageServiceImpl implements PageService {
             // 数据库获取基本价格信息
             PriceVo price = priceMapper.getDetailPrice(productId);
             // 根据用户id设置详细价格
-            priceUtilService.setPriceByUserId(price, userId);
+            priceUtilService.setPriceByUserId(price, userId, flag);
             // 设置价格
             product.setActStatus(price.getActStatus());
             product.setPrice(price.getPrice());
@@ -624,7 +624,7 @@ public class PageServiceImpl implements PageService {
      * @param pageSize
      */
     @Override
-    public ResponseJson<PaginationVo<ProductItemVo>> getBuyAgainProducts(Integer userId, int pageNum, int pageSize) {
+    public ResponseJson<PaginationVo<ProductItemVo>> getBuyAgainProducts(Integer userId, Integer flag, int pageNum, int pageSize) {
         if (null == userId) {
             return ResponseJson.error("参数错误:用户Id不能为空!", null);
         }
@@ -634,12 +634,12 @@ public class PageServiceImpl implements PageService {
             double price = product.getPrice() != null ? product.getPrice() : 0d;
             double costPrice = product.getCostPrice() != null ? product.getCostPrice() : 0d;
             double discountPrice = product.getDiscountPrice() != null ? product.getDiscountPrice() : 0d;
-            Integer costFlag = product.getCostCheckFlag();
+            Integer costFlag = product.getCostCheckFlag() != null ? product.getCostCheckFlag() : 1;
             // 成本大于等于复购价 或 复购价大于机构价
             boolean state = (costFlag == 1 && MathUtil.compare(costPrice, discountPrice) >= 0) || MathUtil.compare(discountPrice, price) > 0;
             product.setRepurchasePriceState(state);
             // 设置商品主图及价格
-            priceUtilService.setProductDetails(userId, product);
+            priceUtilService.setProductDetails(userId, product, flag);
             //优惠券标识
             Boolean couponsLogo = pageService.setCouponsLogo(userId, product.getProductId(), 2);
             product.setCouponsLogo(couponsLogo);
@@ -893,7 +893,7 @@ public class PageServiceImpl implements PageService {
     /**
      * 设置楼层相关图片的商品信息
      */
-    private void setFloorImageProduct(Integer userId, List<FloorImageVo> floorImageList, Integer source) {
+    private void setFloorImageProduct(Integer userId, List<FloorImageVo> floorImageList, Integer source, Integer flag) {
         Iterator<FloorImageVo> iterator = floorImageList.iterator();
         while (iterator.hasNext()) {
             FloorImageVo image = iterator.next();
@@ -909,7 +909,7 @@ public class PageServiceImpl implements PageService {
                 ProductItemVo product = pageMapper.getProductItemById(image.getProductId());
                 if (product != null) {
                     // 商品价格
-                    priceUtilService.setProductDetails(userId, product);
+                    priceUtilService.setProductDetails(userId, product, flag);
                     // 设置商品主图
                     image.setListType(1);
                     image.setName(product.getName());
@@ -993,17 +993,18 @@ public class PageServiceImpl implements PageService {
 
     /**
      * 商品资料列表
-     * @param keyword       搜索关键词
-     * @param productType   商品属性:1产品,2仪器
-     * @param pageNum       页码
-     * @param pageSize      每页数量
+     *
+     * @param keyword     搜索关键词
+     * @param productType 商品属性:1产品,2仪器
+     * @param pageNum     页码
+     * @param pageSize    每页数量
      * @return
      */
     @Override
     public ResponseJson<PaginationVo<ArchiveVo>> getProductArchive(String keyword, Integer productType, Integer pageNum, Integer pageSize) {
         PageHelper.startPage(pageNum, pageSize);
         List<ArchiveVo> archiveList = pageMapper.getProductArchiveList(keyword, productType);
-        archiveList.forEach(archive->{
+        archiveList.forEach(archive -> {
             if (null != archive.getProductId()) {
                 String imageURL = ImageUtils.getImageURL("product", archive.getProductImage(), 0, domain);
                 archive.setProductImage(imageURL);
@@ -1015,8 +1016,9 @@ public class PageServiceImpl implements PageService {
 
     /**
      * 商品资料内容
-     * @param archiveId     商品资料id
-     * @param userId        用户id
+     *
+     * @param archiveId 商品资料id
+     * @param userId    用户id
      * @return
      */
     @Override
@@ -1035,21 +1037,21 @@ public class PageServiceImpl implements PageService {
             permission = 0;
         }
         int finalPermission = permission;
-        imageArchiveList.forEach(imageArchive->{
+        imageArchiveList.forEach(imageArchive -> {
             List<String> imageList = pageMapper.getArchiveImageList(imageArchive.getArchiveContentId());
             if (0 == finalPermission) {
                 imageArchive.setImageList(imageList);
             }
             imageArchive.setImageNum(imageList.size());
         });
-        videoArchiveList.forEach(videoArchive->{
+        videoArchiveList.forEach(videoArchive -> {
             ArchiveFilePo archiveFile = pageMapper.getArchiveFile(videoArchive.getArchiveContentId());
             if (0 == finalPermission) {
                 String fileUrl = generateFileUrl(archiveFile);
                 videoArchive.setFileUrl(fileUrl);
             }
         });
-        fileArchiveList.forEach(fileArchive->{
+        fileArchiveList.forEach(fileArchive -> {
             ArchiveFilePo archiveFile = pageMapper.getArchiveFile(fileArchive.getArchiveContentId());
             fileArchive.setFileName(archiveFile.getFileName());
             if (0 == finalPermission) {
@@ -1105,7 +1107,7 @@ public class PageServiceImpl implements PageService {
                 if (1 == productClassify && (0 == clubType || 2 == clubType)) {
                     // 三级医美资料,生美会员机构
                     permission = 3;
-                } else if (null == historyId){
+                } else if (null == historyId) {
                     permission = 4;
                 } else {
                     permission = 0;
@@ -1113,7 +1115,7 @@ public class PageServiceImpl implements PageService {
             } else {
                 permission = 0;
             }
-        } else{
+        } else {
             permission = 5;
         }
         return permission;
@@ -1131,7 +1133,7 @@ public class PageServiceImpl implements PageService {
             Date dateTwo = format.parse("2021-09-17 18:00:00");
             if (archiveFile.getUploadTime() != null && archiveFile.getUploadTime().compareTo(dateOne) > 0 && archiveFile.getUploadTime().compareTo(dateTwo) < 0) {
                 ossName = active + "/" + ossName;
-            } else if (archiveFile.getUploadTime() != null && archiveFile.getUploadTime().compareTo(dateTwo)>0){
+            } else if (archiveFile.getUploadTime() != null && archiveFile.getUploadTime().compareTo(dateTwo) > 0) {
                 ossName = active + "/archiveFile/" + ossName;
             }
         } catch (ParseException e) {
@@ -1143,13 +1145,13 @@ public class PageServiceImpl implements PageService {
     }
 
     @Override
-    public ResponseJson<Map<String, Object>> getSvipProductPage(Integer userId, Integer source, Integer pageNum, Integer pageSize) {
+    public ResponseJson<Map<String, Object>> getSvipProductPage(Integer userId, Integer source, Integer pageNum, Integer pageSize, Integer flag) {
         Map<String, Object> svipProductPageData = new HashMap<>(2);
         String adsImage = pageMapper.getSvipProductAdsImage(userId, source);
         PageHelper.startPage(pageNum, pageSize);
         List<ProductItemVo> svipProductList = pageMapper.getSvipProductList();
-        svipProductList.forEach(svipProduct->{
-            priceUtilService.setProductDetails(userId, svipProduct);
+        svipProductList.forEach(svipProduct -> {
+            priceUtilService.setProductDetails(userId, svipProduct, flag);
             svipProduct.setImage(ImageUtils.getImageURL("product", svipProduct.getImage(), 0, domain));
         });
         PaginationVo<ProductItemVo> svipProductPage = new PaginationVo<>(svipProductList);
@@ -1158,4 +1160,16 @@ public class PageServiceImpl implements PageService {
         return ResponseJson.success(svipProductPageData);
     }
 
+    /**
+     * 充值商品详情
+     *
+     * @param productId 商品id
+     */
+    @Override
+    public ResponseJson<ProductDetailVo> getRechargeGoods(Integer productId) {
+        ProductDetailVo product = pageMapper.getProductDetails(productId);
+        // 主图
+        product.setMainImage(ImageUtils.getImageURL("product", product.getMainImage(), 0, domain));
+        return ResponseJson.success(product);
+    }
 }

+ 10 - 11
src/main/java/com/caimei365/commodity/service/impl/PriceServiceImpl.java

@@ -7,9 +7,9 @@ import com.caimei365.commodity.components.PriceUtilService;
 import com.caimei365.commodity.mapper.PriceMapper;
 import com.caimei365.commodity.mapper.ShopMapper;
 import com.caimei365.commodity.model.ResponseJson;
-import com.caimei365.commodity.model.vo.ProductSalesVo;
 import com.caimei365.commodity.model.vo.LadderPriceVo;
 import com.caimei365.commodity.model.vo.PriceVo;
+import com.caimei365.commodity.model.vo.ProductSalesVo;
 import com.caimei365.commodity.model.vo.TaxVo;
 import com.caimei365.commodity.service.PageService;
 import com.caimei365.commodity.service.PriceService;
@@ -22,7 +22,6 @@ import javax.annotation.Resource;
 import java.util.List;
 
 import static com.alibaba.fastjson.JSON.parseArray;
-import static com.alibaba.fastjson.JSON.parseObject;
 
 /**
  * Description
@@ -50,11 +49,11 @@ public class PriceServiceImpl implements PriceService {
      * @return PriceVo
      */
     @Override
-    public ResponseJson<PriceVo> getDetailPrice(Integer userId, Integer productId) {
+    public ResponseJson<PriceVo> getDetailPrice(Integer userId, Integer productId,Integer flag) {
         // 数据库获取基本价格信息
         PriceVo price = priceMapper.getDetailPrice(productId);
         // 根据用户id设置详细价格
-        priceUtilService.setPriceByUserId(price, userId);
+        priceUtilService.setPriceByUserId(price, userId,flag);
         log.info(">>>读取商品价格,商品ID:" + productId + ",用户ID:" + userId);
         return ResponseJson.success(price);
     }
@@ -67,7 +66,7 @@ public class PriceServiceImpl implements PriceService {
      * @return List<PriceVo>
      */
     @Override
-    public ResponseJson<List<PriceVo>> getListPrice(Integer userId, String productIds, Integer source) {
+    public ResponseJson<List<PriceVo>> getListPrice(Integer userId, String productIds, Integer source, Integer flag) {
         List<Integer> productIdList = Lists.newArrayList();
         if (productIds.contains(",")) {
             String[] productArr = productIds.split(",");
@@ -84,7 +83,7 @@ public class PriceServiceImpl implements PriceService {
         List<PriceVo> priceList = priceMapper.getListPriceByProductIds(productIdList);
         for (PriceVo price : priceList) {
             // 根据用户id设置详细价格
-            priceUtilService.setPriceByUserId(price, userId);
+            priceUtilService.setPriceByUserId(price, userId, flag);
             Boolean couponsLogo = pageService.setCouponsLogo(userId, price.getProductId(), source);
             price.setCouponsLogo(couponsLogo);
         }
@@ -135,7 +134,7 @@ public class PriceServiceImpl implements PriceService {
             Integer productCount = (Integer) productTemp.get("productCount");
             // 获取商品销量信息
             ProductSalesVo salesVo = priceMapper.getProductSalesInfo(productId);
-            if (null == salesVo || ObjectUtils.isEmpty(salesVo)){
+            if (null == salesVo || ObjectUtils.isEmpty(salesVo)) {
                 return ResponseJson.error("商品数据异常!", null);
             }
             int dbCount = (null == salesVo.getProductCount()) ? 0 : salesVo.getProductCount();
@@ -145,10 +144,10 @@ public class PriceServiceImpl implements PriceService {
             salesVo.setShopName(shopName);
             // 分类名称
             String typeName = shopMapper.getTypeName(salesVo.getBigTypeId(), salesVo.getSmallTypeId(), salesVo.getTinyTypeId());
-            if (null != salesVo.getCommodityType() && 2 == salesVo.getCommodityType()){
-                salesVo.setProperty("仪器-"+typeName);
+            if (null != salesVo.getCommodityType() && 2 == salesVo.getCommodityType()) {
+                salesVo.setProperty("仪器-" + typeName);
             } else {
-                salesVo.setProperty("产品-"+typeName);
+                salesVo.setProperty("产品-" + typeName);
             }
             if (null == salesVo.getId()) {
                 // 新商品
@@ -157,7 +156,7 @@ public class PriceServiceImpl implements PriceService {
                 // 更新销量
                 priceMapper.updateProductSales(salesVo);
             }
-            log.info("【更新商品销量】:"+salesVo.toString());
+            log.info("【更新商品销量】:" + salesVo.toString());
         }
         return ResponseJson.success(null);
     }

+ 152 - 121
src/main/java/com/caimei365/commodity/service/impl/SearchIndexServiceImpl.java

@@ -8,6 +8,7 @@ import com.aliyun.opensearch.sdk.generated.commons.OpenSearchClientException;
 import com.aliyun.opensearch.sdk.generated.commons.OpenSearchException;
 import com.aliyun.opensearch.sdk.generated.document.Command;
 import com.aliyun.opensearch.sdk.generated.document.DocumentConstants;
+import com.caimei365.commodity.components.PriceUtilService;
 import com.caimei365.commodity.components.SearchOpenService;
 import com.caimei365.commodity.mapper.SearchMapper;
 import com.caimei365.commodity.model.ResponseJson;
@@ -15,7 +16,6 @@ import com.caimei365.commodity.model.search.*;
 import com.caimei365.commodity.service.SearchIndexService;
 import com.caimei365.commodity.service.SearchQueryService;
 import com.caimei365.commodity.utils.ImageUtils;
-import com.caimei365.commodity.components.PriceUtilService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.util.StringUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -46,6 +46,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
     private SearchQueryService searchQueryService;
     @Resource
     private PriceUtilService priceUtilService;
+
     /**
      * 初始化(添加)所有索引
      *
@@ -61,7 +62,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
         if (productCount > productRecord) {
             log.warn("【初始化】批量添加商品文档异常,部分商品未添加。");
         }
-        log.info(">>>>>>【商品】应加:"+productCount+",实加:"+productRecord);
+        log.info(">>>>>>【商品】应加:" + productCount + ",实加:" + productRecord);
         mainId += productRecord;
         // 从数据库获取供应商数量
         Integer supplierCount = searchMapper.findSupplierCount();
@@ -69,7 +70,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
         if (supplierCount > supplierRecord) {
             log.warn("【初始化】批量添加供应商文档异常,部分供应商未添加。");
         }
-        log.info(">>>>>>【供应商】应加:"+supplierCount+",实加:"+supplierRecord);
+        log.info(">>>>>>【供应商】应加:" + supplierCount + ",实加:" + supplierRecord);
         mainId += supplierRecord;
         // 从数据库获取项目仪器数量
         Integer equipmentCount = searchMapper.findEquipmentCount();
@@ -77,7 +78,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
         if (equipmentCount > equipmentRecord) {
             log.warn("批量添加项目仪器文档异常,部分项目仪器未添加。");
         }
-        log.info(">>>>>>【项目仪器】应加:"+equipmentCount+",实加:"+equipmentRecord);
+        log.info(">>>>>>【项目仪器】应加:" + equipmentCount + ",实加:" + equipmentRecord);
         mainId += equipmentRecord;
         // 从数据库获取文章数量
         Integer articleCount = searchMapper.findArticleCount();
@@ -85,7 +86,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
         if (articleCount > articleRecord) {
             log.warn("批量添加文章文档异常,部分文章未添加。");
         }
-        log.info(">>>>>>【文章】应加:"+articleCount+",实加:"+articleRecord);
+        log.info(">>>>>>【文章】应加:" + articleCount + ",实加:" + articleRecord);
         mainId += articleRecord;
 
         log.info(">>>>>>>>>>>>添加总记录:" + mainId);
@@ -94,6 +95,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 更新所有商品
+     *
      * @return json
      */
     @Override
@@ -112,12 +114,13 @@ public class SearchIndexServiceImpl implements SearchIndexService {
         if (productCount > productRecord) {
             log.warn("批量添加商品文档异常,部分商品未添加。");
         }
-        log.info(">>>>>>【商品】应加:"+productCount+",实加:"+productRecord);
+        log.info(">>>>>>【商品】应加:" + productCount + ",实加:" + productRecord);
         return ResponseJson.success(productRecord);
     }
 
     /**
      * 更新所有供应商
+     *
      * @return json
      */
     @Override
@@ -141,6 +144,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 更新所有项目仪器
+     *
      * @return json
      */
     @Override
@@ -165,6 +169,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 更新所有文章
+     *
      * @return json
      */
     @Override
@@ -188,16 +193,22 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 根据商品Id更新
+     *
      * @param productId int
      * @return json
      */
     @Override
-    public ResponseJson<Integer> updateProductIndexById(Integer productId){
+    public ResponseJson<Integer> updateProductIndexById(Integer productId) {
         if (null == productId) {
             log.info(">>>更新商品,商品Id不能为空!");
             return ResponseJson.error("商品Id不能为空", null);
         }
         ProductDO product = searchMapper.searchProductById(productId);
+        List<Integer> promotionIds = searchMapper.findPromotionId(product.getP_id());
+        if (promotionIds != null && promotionIds.size() > 0) {
+            product.setP_promotions_id(promotionIds.get(0));
+        }
+        // product p_promotions_id
         if (null != product) {
             // 定义星范商品数据
             List<DocumentDTO<MallProductDO>> mallProductList = new ArrayList<>();
@@ -213,7 +224,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             Integer mainId = searchQueryService.getIdByDocId("product", productId);
             if (mainId == -1) {
                 mainId = searchQueryService.getIdByDocId("", null);
-                mainId = mainId == -1 ? 0 : mainId+1;
+                mainId = mainId == -1 ? 0 : mainId + 1;
                 //  新增主文档, 商品:type=1
                 setMainDocument(1, mainList, mainId, productId);
             }
@@ -221,7 +232,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
                 // 查询商品数量是否唯一,不唯一则删除后更新索引
                 Integer count = searchQueryService.getCountByDocId("product", productId);
                 if (count > 1) {
-                    log.info("商品重复,重复商品>>>>>>>>>>>" + productId +"重复数量:" + count);
+                    log.info("商品重复,重复商品>>>>>>>>>>>" + productId + "重复数量:" + count);
                     // 删除主文档记录
                     deleteDocByTypeId("id", mainId, "search_main");
                     return updateProductIndexById(productId);
@@ -253,8 +264,8 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             return ResponseJson.error("供应商Id不能为空", null);
         }
         SupplierDO supplier = searchMapper.searchSupplierById(shopId);
-        if(null != supplier){
-             // 定义供应商文档数据
+        if (null != supplier) {
+            // 定义供应商文档数据
             List<DocumentDTO<SupplierDO>> supplierList = new ArrayList<>();
             // 供应商文档设值
             setSupplierDocument(supplierList, supplier);
@@ -264,7 +275,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             Integer mainId = searchQueryService.getIdByDocId("shop", shopId);
             if (mainId == -1) {
                 mainId = searchQueryService.getIdByDocId("", null);
-                mainId = mainId == -1 ? 0 : mainId+1;
+                mainId = mainId == -1 ? 0 : mainId + 1;
                 //  新增主文档, 供应商:type=2
                 setMainDocument(2, mainList, mainId, shopId);
             }
@@ -272,7 +283,8 @@ public class SearchIndexServiceImpl implements SearchIndexService {
                 // 查询供应商是否唯一,不唯一则删除后重新更新索引
                 Integer count = searchQueryService.getCountByDocId("shop", shopId);
                 if (count > 1) {
-                    log.info("供应商重复,重复供应商>>>>>>>>>>>" + shopId +"重复数量:" + count);;
+                    log.info("供应商重复,重复供应商>>>>>>>>>>>" + shopId + "重复数量:" + count);
+                    ;
                     // 删除主文档记录
                     deleteDocByTypeId("id", mainId, "search_main");
                     return updateSupplierIndexById(shopId);
@@ -286,7 +298,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
                 log.error("添加供应商文档异常:" + e);
                 return ResponseJson.error("添加供应商文档异常", null);
             }
-        }else{
+        } else {
             return deleteSupplierIndexById(shopId);
         }
     }
@@ -304,7 +316,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             return ResponseJson.error("项目仪器Id不能为空", null);
         }
         EquipmentDO equipment = searchMapper.searchEquipmentById(equipmentId);
-        if(null != equipment){
+        if (null != equipment) {
             // 定义项目仪器文档数据
             List<DocumentDTO<EquipmentDO>> equipmentList = new ArrayList<>();
             // 项目仪器文档设值
@@ -315,7 +327,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             Integer mainId = searchQueryService.getIdByDocId("equipment", equipmentId);
             if (mainId == -1) {
                 mainId = searchQueryService.getIdByDocId("", null);
-                mainId = mainId == -1 ? 0 : mainId+1;
+                mainId = mainId == -1 ? 0 : mainId + 1;
                 // 新增主文档, 项目仪器:type=3
                 setMainDocument(3, mainList, mainId, equipmentId);
             }
@@ -323,7 +335,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
                 // 查询项目仪器数量是否唯一,不唯一则删除后重新更新索引
                 Integer count = searchQueryService.getCountByDocId("equipment", equipmentId);
                 if (count > 1) {
-                    log.info("项目仪器重复,重复项目仪器>>>>>>>>>>>" + equipmentId+"重复数量:" + count);
+                    log.info("项目仪器重复,重复项目仪器>>>>>>>>>>>" + equipmentId + "重复数量:" + count);
                     // 删除主文档记录
                     deleteDocByTypeId("id", mainId, "search_main");
                     return updateEquipmentIndexById(equipmentId);
@@ -337,7 +349,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
                 log.error("添加项目仪器文档异常:" + e);
                 return ResponseJson.error("添加项目仪器文档异常", null);
             }
-        }else{
+        } else {
             return deleteEquipmentIndexById(equipmentId);
         }
     }
@@ -355,7 +367,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             return ResponseJson.error("文章Id不能为空", null);
         }
         ArticleDO article = searchMapper.searchArticleById(articleId);
-        if(null != article){
+        if (null != article) {
             // 定义文章文档数据
             List<DocumentDTO<ArticleDO>> articleList = new ArrayList<>();
             // 文章文档设值
@@ -366,7 +378,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             Integer mainId = searchQueryService.getIdByDocId("article", articleId);
             if (mainId == -1) {
                 mainId = searchQueryService.getIdByDocId("", null);
-                mainId = mainId == -1 ? 0 : mainId+1;
+                mainId = mainId == -1 ? 0 : mainId + 1;
                 // 新增主文档, 文章 type=4
                 setMainDocument(4, mainList, mainId, articleId);
             }
@@ -375,7 +387,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
                 // 查询文章数量是否唯一,不唯一则删除后重新更新索引
                 Integer count = searchQueryService.getCountByDocId("article", articleId);
                 if (count > 1) {
-                    log.info("文章重复,重复文章>>>>>>>>>>>" + articleId +"重复数量:" + count);
+                    log.info("文章重复,重复文章>>>>>>>>>>>" + articleId + "重复数量:" + count);
                     // 删除主文档记录
                     deleteDocByTypeId("id", mainId, "search_main");
                     return updateArticleIndexById(articleId);
@@ -389,7 +401,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
                 log.error("添加文章文档异常:" + e);
                 return ResponseJson.error("添加文章文档异常", null);
             }
-        }else{
+        } else {
             return deleteArticleIndexById(articleId);
         }
     }
@@ -406,7 +418,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
         // 根据商品ID获取星范ID
         Integer mallId = searchMapper.findMallIdByProductId(productId);
         try {
-            if (null != mallId){
+            if (null != mallId) {
                 deleteDocByTypeId("m_id", mallId, "search_product_mall");
             }
             deleteDocByTypeId("p_id", productId, "search_product");
@@ -505,11 +517,12 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 根据文档类型key与类型Id删除
-     * @param type 类型key
-     * @param id 类型Id
+     *
+     * @param type  类型key
+     * @param id    类型Id
      * @param table 表名
      * @throws OpenSearchClientException exp
-     * @throws OpenSearchException exp
+     * @throws OpenSearchException       exp
      */
     private void deleteDocByTypeId(String type, Integer id, String table) throws OpenSearchClientException, OpenSearchException {
         // 删除文档只需要设置需删除文档主键值即可
@@ -519,19 +532,18 @@ public class SearchIndexServiceImpl implements SearchIndexService {
         String deleteJsonStr = setDeleteDocument(deleteDoc);
         // 推送到阿里云
         String deleteResult = searchOpenService.pushDocument(deleteJsonStr, table);
-        log.info(">>>>>>>>>>>>>>>delete document: 【"+ table +"("+ type +":" + id + "):" + deleteResult + "】");
+        log.info(">>>>>>>>>>>>>>>delete document: 【" + table + "(" + type + ":" + id + "):" + deleteResult + "】");
     }
 
 
-
-
     /**
      * 批量删除失效商品
+     *
      * @param invalidCount int
      */
     private void batchDeleteProductDoc(Integer invalidCount) {
         // 批量推送,每100条推送一次
-        int loop = (int)Math.ceil(invalidCount.doubleValue() / 100);
+        int loop = (int) Math.ceil(invalidCount.doubleValue() / 100);
         // 定义返回结果
         for (int i = 1; i <= loop; i++) {
             PageHelper.startPage(i, 100);
@@ -551,7 +563,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
                 // 根据ID(主键)删除文档
                 deleteDoc.put("p_id", invalidId);
                 Integer mainId = searchQueryService.getIdByDocId("product", invalidId);
-                if (mainId > -1){
+                if (mainId > -1) {
                     deleteDoc.put("id", mainId);
                 }
             }
@@ -568,18 +580,19 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 设置所有商品数据
-     * @param mainId int
+     *
+     * @param mainId       int
      * @param productCount int
-     * @param initFlag int
+     * @param initFlag     int
      * @return int
      */
     private Integer setAllProductData(Integer mainId, Integer productCount, boolean initFlag) {
         // 批量推送,每100条推送一次
-        int loop = (int)Math.ceil(productCount.doubleValue() / 100);
+        int loop = (int) Math.ceil(productCount.doubleValue() / 100);
         Map<Integer, Integer> idsMap = Maps.newLinkedHashMap();
         if (!initFlag) {
             Integer record = searchQueryService.getRecordByDocType("product");
-            int l = (int)Math.ceil(record.doubleValue() / 500);
+            int l = (int) Math.ceil(record.doubleValue() / 500);
             for (int i = 1; i <= l; i++) {
                 Map<Integer, Integer> idsTemp = searchQueryService.getMainIdsByDocType("product", i, 500);
                 idsMap.putAll(idsTemp);
@@ -591,6 +604,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             PageHelper.startPage(i, 100);
             // 获取数据库商品列表的分页数据
             List<ProductDO> dbList = searchMapper.searchProductList();
+
             // 定义星范商品数据
             List<DocumentDTO<MallProductDO>> mallProductList = new ArrayList<>();
             // 定义商品文档数据
@@ -606,19 +620,19 @@ public class SearchIndexServiceImpl implements SearchIndexService {
                 setProductDocument(productList, product, null);
                 // 主文档设值
                 Integer productId = product.getP_id();
-                if(initFlag){
-                    productMainId = mainId+1;
-                    mainId+=1;
-                }else{
+                if (initFlag) {
+                    productMainId = mainId + 1;
+                    mainId += 1;
+                } else {
                     Integer tempId = idsMap.get(productId);
-                    if (null==tempId || tempId<=0){
+                    if (null == tempId || tempId <= 0) {
                         tempId = searchQueryService.getIdByDocId("product", productId);
                     }
-                    if (null!=tempId && tempId>0) {
+                    if (null != tempId && tempId > 0) {
                         productMainId = tempId;
-                    }else{
-                        productMainId = mainId+1;
-                        mainId+=1;
+                    } else {
+                        productMainId = mainId + 1;
+                        mainId += 1;
                     }
                 }
                 // 商品文档 type=1
@@ -639,14 +653,15 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 推送所有商品
-     * @param mainList list
-     * @param productList list
+     *
+     * @param mainList        list
+     * @param productList     list
      * @param mallProductList list
      * @throws OpenSearchClientException exp
-     * @throws OpenSearchException exp
+     * @throws OpenSearchException       exp
      */
     private void pushProductDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<ProductDO>> productList, List<DocumentDTO<MallProductDO>> mallProductList) throws OpenSearchClientException, OpenSearchException {
-        if (mainList.size()>0) {
+        if (mainList.size() > 0) {
             // 将主文档列表转换成Json串,并推送到阿里云
             String mainDocStr = new JSONArray(mainList).toString();
             String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
@@ -655,7 +670,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
         // 将商品文档推送到阿里云
         String productDocStr = new JSONArray(productList).toString();
         String productResult = searchOpenService.pushDocument(productDocStr, "search_product");
-        if (mainList.size()>0) {
+        if (mainList.size() > 0) {
             // 新增
             log.info(">>>>>>>>>>>>>>>add document: 【search_product(" + productList.size() + "个):" + productResult + "】");
         } else {
@@ -663,7 +678,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             log.info(">>>>>>>>>>>>>>>update document: 【search_product(" + productList.size() + "个):" + productResult + "】");
         }
         // 将星范商品推送到阿里云
-        if (mallProductList.size()>0) {
+        if (mallProductList.size() > 0) {
             String mallProductStr = new JSONArray(mallProductList).toString();
             String mallProductResult = searchOpenService.pushDocument(mallProductStr, "search_product_mall");
             log.info(">>>>>>>>>>>>>>>add document: 【search_product_mall(" + mallProductList.size() + "):" + mallProductResult + "】");
@@ -672,11 +687,12 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 批量删除失效供应商
+     *
      * @param invalidCount int
      */
     private void batchDeleteSupplierDoc(Integer invalidCount) {
         // 批量推送,每100条推送一次
-        int loop = (int)Math.ceil(invalidCount.doubleValue() / 100);
+        int loop = (int) Math.ceil(invalidCount.doubleValue() / 100);
         // 定义返回结果
         for (int i = 1; i <= loop; i++) {
             PageHelper.startPage(i, 100);
@@ -688,7 +704,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
                 // 根据ID(主键)删除文档
                 deleteDoc.put("s_id", invalidId);
                 Integer mainId = searchQueryService.getIdByDocId("shop", invalidId);
-                if (mainId > -1){
+                if (mainId > -1) {
                     deleteDoc.put("id", mainId);
                 }
             }
@@ -705,18 +721,19 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 设置所有供应商数据
-     * @param mainId int
+     *
+     * @param mainId        int
      * @param supplierCount int
-     * @param initFlag int
+     * @param initFlag      int
      * @return int
      */
     private Integer setAllSupplierData(Integer mainId, Integer supplierCount, boolean initFlag) {
         // 批量推送,每100条推送一次
-        int loop = (int)Math.ceil(supplierCount.doubleValue() / 100);
+        int loop = (int) Math.ceil(supplierCount.doubleValue() / 100);
         Map<Integer, Integer> idsMap = Maps.newLinkedHashMap();
         if (!initFlag) {
             Integer record = searchQueryService.getRecordByDocType("shop");
-            int l = (int)Math.ceil(record.doubleValue() / 500);
+            int l = (int) Math.ceil(record.doubleValue() / 500);
             for (int i = 1; i <= l; i++) {
                 Map<Integer, Integer> idsTemp = searchQueryService.getMainIdsByDocType("shop", i, 500);
                 idsMap.putAll(idsTemp);
@@ -734,24 +751,24 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             List<DocumentDTO<MainDO>> mainList = new ArrayList<>();
 
             int supplierMainId;
-            for (SupplierDO supplier: dbList){
+            for (SupplierDO supplier : dbList) {
                 // 供应商文档设值
                 setSupplierDocument(supplierList, supplier);
                 // 主文档设值
                 Integer shopId = supplier.getS_id();
-                if(initFlag){
-                    supplierMainId = mainId+1;
-                    mainId+=1;
-                }else{
+                if (initFlag) {
+                    supplierMainId = mainId + 1;
+                    mainId += 1;
+                } else {
                     Integer tempId = idsMap.get(shopId);
-                    if (null==tempId || tempId<=0){
+                    if (null == tempId || tempId <= 0) {
                         tempId = searchQueryService.getIdByDocId("shop", shopId);
                     }
-                    if (null!=tempId && tempId>0) {
+                    if (null != tempId && tempId > 0) {
                         supplierMainId = tempId;
-                    }else{
-                        supplierMainId = mainId+1;
-                        mainId+=1;
+                    } else {
+                        supplierMainId = mainId + 1;
+                        mainId += 1;
                     }
                 }
                 // 供应商文档 type=2
@@ -772,13 +789,14 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 推送所有供应商
-     * @param mainList list
+     *
+     * @param mainList     list
      * @param supplierList list
      * @throws OpenSearchClientException exp
-     * @throws OpenSearchException exp
+     * @throws OpenSearchException       exp
      */
     private void pushSupplierDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<SupplierDO>> supplierList) throws OpenSearchClientException, OpenSearchException {
-        if (mainList.size()>0) {
+        if (mainList.size() > 0) {
             // 将主文档列表转换成Json串,并推送到阿里云
             String mainDocStr = new JSONArray(mainList).toString();
             String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
@@ -787,7 +805,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
         // 将商品文档推送到阿里云
         String supplierDocStr = new JSONArray(supplierList).toString();
         String supplierResult = searchOpenService.pushDocument(supplierDocStr, "search_supplier");
-        if (mainList.size()>0) {
+        if (mainList.size() > 0) {
             // 新增
             log.info(">>>>>>>>>>>>>>>add document: 【search_supplier(" + supplierList.size() + "个):" + supplierResult + "】");
         } else {
@@ -798,11 +816,12 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 批量删除失效项目仪器
+     *
      * @param invalidCount int
      */
     private void batchDeleteEquipmentDoc(Integer invalidCount) {
         // 批量推送,每100条推送一次
-        int loop = (int)Math.ceil(invalidCount.doubleValue() / 100);
+        int loop = (int) Math.ceil(invalidCount.doubleValue() / 100);
         // 定义返回结果
         for (int i = 1; i <= loop; i++) {
             PageHelper.startPage(i, 100);
@@ -814,7 +833,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
                 // 根据ID(主键)删除文档
                 deleteDoc.put("e_id", invalidId);
                 Integer mainId = searchQueryService.getIdByDocId("equipment", invalidId);
-                if (mainId > -1){
+                if (mainId > -1) {
                     deleteDoc.put("id", mainId);
                 }
             }
@@ -831,18 +850,19 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 设置所有项目仪器数据
-     * @param mainId int
+     *
+     * @param mainId         int
      * @param equipmentCount int
-     * @param initFlag int
+     * @param initFlag       int
      * @return int
      */
     private Integer setAllEquipmentData(Integer mainId, Integer equipmentCount, boolean initFlag) {
         // 批量推送,每100条推送一次
-        int loop = (int)Math.ceil(equipmentCount.doubleValue() / 100);
+        int loop = (int) Math.ceil(equipmentCount.doubleValue() / 100);
         Map<Integer, Integer> idsMap = Maps.newLinkedHashMap();
         if (!initFlag) {
             Integer record = searchQueryService.getRecordByDocType("equipment");
-            int l = (int)Math.ceil(record.doubleValue() / 500);
+            int l = (int) Math.ceil(record.doubleValue() / 500);
             for (int i = 1; i <= l; i++) {
                 Map<Integer, Integer> idsTemp = searchQueryService.getMainIdsByDocType("equipment", i, 500);
                 idsMap.putAll(idsTemp);
@@ -860,24 +880,24 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             List<DocumentDTO<MainDO>> mainList = new ArrayList<>();
 
             int equipmentMainId;
-            for (EquipmentDO equipment: dbList){
+            for (EquipmentDO equipment : dbList) {
                 // 项目仪器文档设值
                 setEquipmentDocument(equipmentList, equipment);
                 // 主文档设值
                 Integer equipmentId = equipment.getE_id();
-                if(initFlag){
-                    equipmentMainId = mainId+1;
-                    mainId+=1;
-                }else{
+                if (initFlag) {
+                    equipmentMainId = mainId + 1;
+                    mainId += 1;
+                } else {
                     Integer tempId = idsMap.get(equipmentId);
-                    if (null==tempId || tempId<=0){
+                    if (null == tempId || tempId <= 0) {
                         tempId = searchQueryService.getIdByDocId("equipment", equipmentId);
                     }
-                    if (null!=tempId && tempId>0) {
+                    if (null != tempId && tempId > 0) {
                         equipmentMainId = tempId;
-                    }else{
-                        equipmentMainId = mainId+1;
-                        mainId+=1;
+                    } else {
+                        equipmentMainId = mainId + 1;
+                        mainId += 1;
                     }
                 }
                 // 项目仪器文档 type=3
@@ -898,13 +918,14 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 推送所有项目仪器
-     * @param mainList list
+     *
+     * @param mainList      list
      * @param equipmentList list
      * @throws OpenSearchClientException exp
-     * @throws OpenSearchException exp
+     * @throws OpenSearchException       exp
      */
     private void pushEquipmentDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<EquipmentDO>> equipmentList) throws OpenSearchClientException, OpenSearchException {
-        if (mainList.size()>0) {
+        if (mainList.size() > 0) {
             // 将主文档列表转换成Json串,并推送到阿里云
             String mainDocStr = new JSONArray(mainList).toString();
             String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
@@ -913,7 +934,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
         // 将商品文档推送到阿里云
         String equipmentDocStr = new JSONArray(equipmentList).toString();
         String equipmentResult = searchOpenService.pushDocument(equipmentDocStr, "search_equipment");
-        if (mainList.size()>0) {
+        if (mainList.size() > 0) {
             // 新增
             log.info(">>>>>>>>>>>>>>>add document: 【search_equipment(" + equipmentList.size() + "个):" + equipmentResult + "】");
         } else {
@@ -924,11 +945,12 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 批量删除失效文章
+     *
      * @param invalidCount int
      */
     private void batchDeleteArticleDoc(Integer invalidCount) {
         // 批量推送,每100条推送一次
-        int loop = (int)Math.ceil(invalidCount.doubleValue() / 100);
+        int loop = (int) Math.ceil(invalidCount.doubleValue() / 100);
         // 定义返回结果
         for (int i = 1; i <= loop; i++) {
             PageHelper.startPage(i, 100);
@@ -940,7 +962,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
                 // 根据ID(主键)删除文档
                 deleteDoc.put("a_id", invalidId);
                 Integer mainId = searchQueryService.getIdByDocId("article", invalidId);
-                if (mainId > -1){
+                if (mainId > -1) {
                     deleteDoc.put("id", mainId);
                 }
             }
@@ -957,18 +979,19 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 设置所有文章数据
-     * @param mainId int
+     *
+     * @param mainId       int
      * @param articleCount int
-     * @param initFlag int
+     * @param initFlag     int
      * @return int
      */
     private Integer setAllArticleData(Integer mainId, Integer articleCount, boolean initFlag) {
         // 批量推送,每100条推送一次
-        int loop = (int)Math.ceil(articleCount.doubleValue() / 100);
+        int loop = (int) Math.ceil(articleCount.doubleValue() / 100);
         Map<Integer, Integer> idsMap = Maps.newLinkedHashMap();
         if (!initFlag) {
             Integer record = searchQueryService.getRecordByDocType("article");
-            int l = (int)Math.ceil(record.doubleValue() / 500);
+            int l = (int) Math.ceil(record.doubleValue() / 500);
             for (int i = 1; i <= l; i++) {
                 Map<Integer, Integer> idsTemp = searchQueryService.getMainIdsByDocType("article", i, 500);
                 idsMap.putAll(idsTemp);
@@ -986,24 +1009,24 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             List<DocumentDTO<MainDO>> mainList = new ArrayList<>();
 
             int articleMainId;
-            for (ArticleDO article: dbList){
+            for (ArticleDO article : dbList) {
                 // 文章文档设值
                 setArticleDocument(articleList, article);
                 // 主文档设值
                 Integer articleId = article.getA_id();
-                if(initFlag){
-                    articleMainId = mainId+1;
-                    mainId+=1;
-                }else{
+                if (initFlag) {
+                    articleMainId = mainId + 1;
+                    mainId += 1;
+                } else {
                     Integer tempId = idsMap.get(articleId);
-                    if (null==tempId || tempId<=0){
+                    if (null == tempId || tempId <= 0) {
                         tempId = searchQueryService.getIdByDocId("article", articleId);
                     }
-                    if (null!=tempId && tempId>0) {
+                    if (null != tempId && tempId > 0) {
                         articleMainId = tempId;
-                    }else{
-                        articleMainId = mainId+1;
-                        mainId+=1;
+                    } else {
+                        articleMainId = mainId + 1;
+                        mainId += 1;
                     }
                 }
                 // 文章文档 type=4
@@ -1024,13 +1047,14 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 推送所有文章数据
-     * @param mainList list
+     *
+     * @param mainList    list
      * @param articleList list
      * @throws OpenSearchClientException exp
-     * @throws OpenSearchException exp
+     * @throws OpenSearchException       exp
      */
     private void pushArticleDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<ArticleDO>> articleList) throws OpenSearchClientException, OpenSearchException {
-        if (mainList.size()>0) {
+        if (mainList.size() > 0) {
             // 将主文档列表转换成Json串,并推送到阿里云
             String mainDocStr = new JSONArray(mainList).toString();
             String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
@@ -1039,7 +1063,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
         // 将商品文档推送到阿里云
         String articleDocStr = new JSONArray(articleList).toString();
         String articleResult = searchOpenService.pushDocument(articleDocStr, "search_article");
-        if (mainList.size()>0) {
+        if (mainList.size() > 0) {
             // 新增
             log.info(">>>>>>>>>>>>>>>add document: 【search_article(" + articleList.size() + "个):" + articleResult + "】");
         } else {
@@ -1050,6 +1074,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 删除文档设值
+     *
      * @return docsJson
      */
     private String setDeleteDocument(Map<String, Object> deleteDoc) {
@@ -1066,7 +1091,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      * 商品星范商品设值
      *
      * @param mallProductList list
-     * @param productId int
+     * @param productId       int
      */
     private Integer setMallProductDocument(List<DocumentDTO<MallProductDO>> mallProductList, Integer productId) {
         // 是否是星范商品
@@ -1093,9 +1118,10 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
     /**
      * 商品文档设值
-     *  @param productList list
-     * @param product ProductDO
-     * @param mallId int
+     *
+     * @param productList list
+     * @param product     ProductDO
+     * @param mallId      int
      */
     private void setProductDocument(List<DocumentDTO<ProductDO>> productList, ProductDO product, Integer mallId) {
         String imagePath = ImageUtils.getImageURL("product", product.getP_image(), 0, domain);
@@ -1106,6 +1132,11 @@ public class SearchIndexServiceImpl implements SearchIndexService {
         // 价格等级
         product.setP_price_grade(priceUtilService.getPriceGrade(product.getP_price().doubleValue()));
         DocumentDTO<ProductDO> productDoc = new DocumentDTO<>();
+        // 设促销id
+        List<Integer> promotionIds = searchMapper.findPromotionId(product.getP_id());
+        if (promotionIds != null && promotionIds.size() > 0) {
+            product.setP_promotions_id(promotionIds.get(0));
+        }
         productDoc.setCmd("add");
         productDoc.setFields(product);
         productList.add(productDoc);
@@ -1115,7 +1146,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      * 供应商文档设值
      *
      * @param supplierList list
-     * @param supplier supplierDO
+     * @param supplier     supplierDO
      */
     private void setSupplierDocument(List<DocumentDTO<SupplierDO>> supplierList, SupplierDO supplier) {
         String imagePath = ImageUtils.getImageURL("supplierLogo", supplier.getS_logo(), 0, domain);
@@ -1132,7 +1163,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      * 项目仪器文档设值
      *
      * @param equipmentList list
-     * @param equipment EquipmentDO
+     * @param equipment     EquipmentDO
      */
     private void setEquipmentDocument(List<DocumentDTO<EquipmentDO>> equipmentList, EquipmentDO equipment) {
         // 搜索供应商文档数据
@@ -1147,15 +1178,15 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      * 文章文档设值
      *
      * @param articleList list
-     * @param article ArticleDO
+     * @param article     ArticleDO
      */
     private void setArticleDocument(List<DocumentDTO<ArticleDO>> articleList, ArticleDO article) {
         String imagePath = ImageUtils.getImageURL("", article.getA_image(), 0, domain);
         // 搜索供应商文档数据
         String[] labelTexts = article.getA_label().split(",");
-        if(labelTexts.length > 0){
+        if (labelTexts.length > 0) {
             boolean notEmpty = StringUtil.isNotEmpty(labelTexts[0]);
-            if(notEmpty){
+            if (notEmpty) {
                 List<Integer> labelIdList = searchMapper.findLabelIdsByName(labelTexts);
                 Integer[] labelIds = labelIdList.toArray(new Integer[labelTexts.length]);
                 article.setA_label_text(labelTexts);
@@ -1174,8 +1205,8 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      * 商品主文档设值
      *
      * @param mainList list
-     * @param mainId int
-     * @param docId int
+     * @param mainId   int
+     * @param docId    int
      */
     private void setMainDocument(Integer type, List<DocumentDTO<MainDO>> mainList, Integer mainId, Integer docId) {
         // 搜索主文档数据

+ 234 - 52
src/main/java/com/caimei365/commodity/service/impl/SearchProductServiceImpl.java

@@ -6,18 +6,18 @@ import com.aliyun.opensearch.sdk.dependencies.org.json.JSONObject;
 import com.aliyun.opensearch.sdk.generated.commons.OpenSearchClientException;
 import com.aliyun.opensearch.sdk.generated.commons.OpenSearchException;
 import com.aliyun.opensearch.sdk.generated.search.SearchParams;
+import com.caimei365.commodity.components.PriceUtilService;
 import com.caimei365.commodity.components.SearchOpenService;
 import com.caimei365.commodity.mapper.PageMapper;
 import com.caimei365.commodity.mapper.SearchMapper;
 import com.caimei365.commodity.model.ResponseJson;
 import com.caimei365.commodity.model.po.SearchHistoryPo;
+import com.caimei365.commodity.model.search.ProductListVo;
 import com.caimei365.commodity.model.vo.HotSearchVo;
 import com.caimei365.commodity.model.vo.PaginationVo;
-import com.caimei365.commodity.model.search.ProductListVo;
 import com.caimei365.commodity.service.SearchProductService;
 import com.caimei365.commodity.utils.AppletsLinkUtil;
 import com.caimei365.commodity.utils.Json2PojoUtil;
-import com.caimei365.commodity.components.PriceUtilService;
 import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -48,24 +49,75 @@ public class SearchProductServiceImpl implements SearchProductService {
     private SearchOpenService searchOpenService;
     @Resource
     private PriceUtilService priceUtilService;
+
     /**
      * 根据关键词搜索商品
      *
-     * @param keyword   搜索关键字
-     * @param pageNum   页码
-     * @param pageSize  每页数量
-     * @param sortField 排序字段
-     * @param sortType  升降序0/1
+     * @param keyword       搜索关键字
+     * @param brandIds      品牌id字符串,逗号隔开
+     * @param newFlag       查询新品标记
+     * @param promotionFlag 查询促销活动标记
+     * @param pageNum       页码
+     * @param pageSize      每页数量
+     * @param sortField     排序字段
+     * @param sortType      升降序0/1
      * @return JsonStr(list)
      */
     @Override
-    public ResponseJson<String> queryProductByKeyword(String keyword, Integer identity, int pageNum, int pageSize, String sortField, Integer sortType) {
+    public ResponseJson<String> queryProductByKeyword(String keyword, String brandIds, Integer identity, Integer newFlag, Integer promotionFlag,
+                                                      int pageNum, int pageSize, String sortField, Integer sortType) {
         String queryStr = "product:'" + keyword + "'";
+        StringBuilder filter = new StringBuilder();
         if (StringUtils.isEmpty(keyword)) {
             queryStr = "p_all:'1'";
         }
+        if (!StringUtils.isEmpty(brandIds)) {
+            if (brandIds.contains(",")) {
+                String[] split = brandIds.split(",");
+                for (int i = 0; i < split.length; i++) {
+                    if (i == 0) {
+                        filter.append("p_brand:'").append(split[i]).append("'");
+                    } else {
+                        filter.append(" OR p_brand:'").append(split[i]).append("'");
+                    }
+                }
+            } else {
+                filter.append("p_brand:'").append(brandIds).append("'");
+            }
+        }
+        if (!StringUtils.isEmpty(brandIds)) {
+            if (newFlag == 1) {
+                Calendar c = Calendar.getInstance();
+                c.setTime(new Date());
+                c.add(Calendar.YEAR, -1);
+                String time = new SimpleDateFormat("yyyyMMdd").format(c.getTime());
+                filter.append(" AND p_time > ").append(time);
+            }
+            if (promotionFlag == 1) {
+                if (newFlag == 1) {
+                    filter.append(" AND p_promotions_id > 0");
+                } else {
+                    filter.append("p_promotions_id > 0");
+                }
+            }
+        }else{
+            if (newFlag == 1) {
+                Calendar c = Calendar.getInstance();
+                c.setTime(new Date());
+                c.add(Calendar.YEAR, -1);
+                String time = new SimpleDateFormat("yyyyMMdd").format(c.getTime());
+                filter.append("p_time > ").append(time);
+            }
+            if (promotionFlag == 1) {
+                if (newFlag == 1) {
+                    filter.append(" AND p_promotions_id > 0");
+                } else {
+                    filter.append("p_promotions_id > 0");
+                }
+            }
+        }
         // 阿里云搜索
-        ResponseJson<String> result = queryProduct(queryStr, "", identity, pageNum, pageSize, sortField, sortType);
+        ResponseJson<String> result = queryProduct(queryStr, filter.toString(), identity, pageNum, pageSize, sortField, sortType);
         if (0 == result.getCode()) {
             return result;
         } else {
@@ -74,6 +126,84 @@ public class SearchProductServiceImpl implements SearchProductService {
         }
     }
 
+
+    @Override
+    public ResponseJson<Set<HashMap<String, Object>>> queryBrand(String keyword, Integer id, Integer idType, Integer newFlag, Integer promotionFlag, Integer identity) {
+        String queryStr = "";
+        String filter = "";
+        if (!StringUtils.isEmpty(keyword) && idType == null && id == null) {
+            queryStr = "product:'" + keyword + "'";
+        } else if (StringUtils.isEmpty(keyword) && idType != null && id != null) {
+            if (idType == 1) {
+                queryStr = "p_bigtype:'" + id + "'";
+            } else if (idType == 2) {
+                queryStr = "p_smalltype:'" + id + "'";
+            } else if (idType == 3) {
+                queryStr = "p_tinytype:'" + id + "'";
+            }
+        } else if ((!StringUtils.isEmpty(keyword)) && idType != null && id != null) {
+            if (idType == 1) {
+                queryStr = "product:'" + keyword + "' AND " + "p_bigtype:'" + id + "'";
+            }
+            if (idType == 2) {
+                queryStr = "product:'" + keyword + "' AND " + "p_smalltype:'" + id + "'";
+            }
+            if (idType == 3) {
+                queryStr = "product:'" + keyword + "' AND " + "p_tinytype:'" + id + "'";
+            }
+        } else {
+            queryStr = "p_all:'1'";
+        }
+        if (newFlag == 1) {
+//            p_time=20201105
+            Calendar c = Calendar.getInstance();
+            c.setTime(new Date());
+            c.add(Calendar.YEAR, -1);
+            String time = new SimpleDateFormat("yyyyMMdd").format(c.getTime());
+            filter += "p_time > " + time;
+        }
+        if (promotionFlag == 1) {
+            if (newFlag == 1) {
+                filter += "AND p_promotions_id > 0";
+            } else {
+                filter += "p_promotions_id > 0";
+            }
+        }
+        SearchParams searchParams = searchOpenService.getParams(queryStr, identity, filter);
+        ResponseJson<Set<HashMap<String, Object>>> result = getBrandResult(searchParams, queryStr);
+        return result;
+    }
+
+    private ResponseJson<Set<HashMap<String, Object>>> getBrandResult(SearchParams searchParams, String queryStr) {
+        ResponseJson<Set<HashMap<String, Object>>> result;
+        try {
+            JSONObject resultJson = searchOpenService.getResultJsonObject(queryStr, searchParams);
+            Set<HashMap<String, Object>> maps = new HashSet<>();
+            if (1 == resultJson.getInt("status")) {
+                JSONArray pageData = resultJson.getJSONArray("items");
+                for (int i = 0; i < pageData.length(); i++) {
+                    JSONObject json = pageData.getJSONObject(i);
+                    int brandId = json.getInt("p_brand_id");
+                    String brandName = json.getString("p_brand_name");
+                    if (brandId > 0 && StringUtils.isNotEmpty(brandName)) {
+                        HashMap<String, Object> map = new HashMap<>();
+                        map.put("id", brandId);
+                        map.put("name", brandName);
+                        maps.add(map);
+                    }
+                }
+                // 阿里云查询出json转换成商品pojo
+                result = ResponseJson.success(maps);
+            } else {
+                result = ResponseJson.error("未查询到文档记录", null);
+            }
+        } catch (Exception e) {
+            log.error("查询文档异常:" + e.getMessage());
+            result = ResponseJson.error("查询文档异常:" + e.getMessage(), null);
+        }
+        return result;
+    }
+
     /**
      * 根据分类Id搜索商品
      *
@@ -87,8 +217,9 @@ public class SearchProductServiceImpl implements SearchProductService {
      * @return JsonStr(list)
      */
     @Override
-    public ResponseJson<String> queryProductByType(Integer id, Integer idType, Integer identity, int pageNum, int pageSize, String sortField, Integer sortType) {
+    public ResponseJson<String> queryProductByType(Integer id, Integer idType, String brandIds, Integer identity, Integer newFlag, Integer promotionFlag, int pageNum, int pageSize, String sortField, Integer sortType) {
         String queryStr = "";
+        StringBuilder filter = new StringBuilder();
         if (idType == 1) {
             queryStr = "p_bigtype:'" + id + "'";
         } else if (idType == 2) {
@@ -98,12 +229,62 @@ public class SearchProductServiceImpl implements SearchProductService {
         } else {
             return ResponseJson.error("idType参数错误", null);
         }
-        int requestSize = pageNum*pageSize;
+        int requestSize = pageNum * pageSize;
         int requestPageSize = requestSize;
-        if (requestSize > SEARCH_MAX_NUM){
-            requestPageSize = (int) Math.floor(SEARCH_MAX_NUM/pageSize) * pageSize;
+        if (requestSize > SEARCH_MAX_NUM) {
+            requestPageSize = (int) Math.floor(SEARCH_MAX_NUM / pageSize) * pageSize;
+        }
+        if (!StringUtils.isEmpty(brandIds)) {
+            if (brandIds.contains(",")) {
+                String[] split = brandIds.split(",");
+                for (int i = 0; i < split.length; i++) {
+                    if (i == 0) {
+                        filter.append("p_brand:'").append(split[i]).append("'");
+                    } else {
+                        filter.append(" OR p_brand:'").append(split[i]).append("'");
+                    }
+                }
+            } else {
+                filter.append("p_brand:'").append(brandIds).append("'");
+            }
+        }
+        if (!StringUtils.isEmpty(brandIds)) {
+            if (newFlag == 1) {
+                Calendar c = Calendar.getInstance();
+                c.setTime(new Date());
+                c.add(Calendar.YEAR, -1);
+                String time = new SimpleDateFormat("yyyyMMdd").format(c.getTime());
+                filter.append(" AND p_time > ").append(time);
+            }
+            if (promotionFlag == 1) {
+                if (newFlag == 1) {
+                    filter.append(" AND p_promotions_id > 0");
+                } else {
+                    filter.append("p_promotions_id > 0");
+                }
+            }
+        }else{
+            if (newFlag == 1) {
+                Calendar c = Calendar.getInstance();
+                c.setTime(new Date());
+                c.add(Calendar.YEAR, -1);
+                String time = new SimpleDateFormat("yyyyMMdd").format(c.getTime());
+                filter.append("p_time > ").append(time);
+            }
+            if (promotionFlag == 1) {
+                if (newFlag == 1) {
+                    filter.append(" AND p_promotions_id > 0");
+                } else {
+                    filter.append("p_promotions_id > 0");
+                }
+            }
         }
         SearchParams searchParams = searchOpenService.getScrollProductParams(queryStr, identity, requestPageSize, sortField, sortType);
+        String thisFilter = searchParams.getFilter();
+        if (StringUtils.isNotEmpty(String.valueOf(filter))) {
+            thisFilter = thisFilter + " AND " + filter;
+        }
+        searchParams.setFilter(thisFilter);
         // 阿里云搜索(滚动查询)
         ResponseJson<String> result = getScrollProductResult(searchParams, queryStr, requestPageSize, pageNum, pageSize);
         if (0 == result.getCode()) {
@@ -134,10 +315,10 @@ public class SearchProductServiceImpl implements SearchProductService {
     @Override
     public ResponseJson<String> queryProductByClassify(Integer id, Integer identity, int pageNum, int pageSize, String sortField, Integer sortType) {
         String queryStr = "p_classify:'" + id + "'";
-        int requestSize = pageNum*pageSize;
+        int requestSize = pageNum * pageSize;
         int requestPageSize = requestSize;
-        if (requestSize > SEARCH_MAX_NUM){
-            requestPageSize = (int) Math.floor(SEARCH_MAX_NUM/pageSize) * pageSize;
+        if (requestSize > SEARCH_MAX_NUM) {
+            requestPageSize = (int) Math.floor(SEARCH_MAX_NUM / pageSize) * pageSize;
         }
         SearchParams searchParams = searchOpenService.getScrollProductParams(queryStr, identity, requestPageSize, sortField, sortType);
         // 阿里云搜索(滚动查询)
@@ -164,16 +345,16 @@ public class SearchProductServiceImpl implements SearchProductService {
      */
     @Override
     public ResponseJson<String> querySupplierProduct(Integer id, String keyword, Integer identity, int pageNum, int pageSize, String sortField, Integer sortType) {
-        if (null == id){
-            return ResponseJson.error("请提供供应商id" ,null);
+        if (null == id) {
+            return ResponseJson.error("请提供供应商id", null);
         }
         ResponseJson<String> result;
         if (StringUtils.isEmpty(keyword)) {
             String queryStr = "p_supplier:'" + id + "'";
-            int requestSize = pageNum*pageSize;
+            int requestSize = pageNum * pageSize;
             int requestPageSize = requestSize;
-            if (requestSize > SEARCH_MAX_NUM){
-                requestPageSize = (int) Math.floor(SEARCH_MAX_NUM/pageSize) * pageSize;
+            if (requestSize > SEARCH_MAX_NUM) {
+                requestPageSize = (int) Math.floor(SEARCH_MAX_NUM / pageSize) * pageSize;
             }
             SearchParams searchParams = searchOpenService.getScrollProductParams(queryStr, identity, requestPageSize, sortField, sortType);
             result = getScrollProductResult(searchParams, queryStr, requestPageSize, pageNum, pageSize);
@@ -193,20 +374,20 @@ public class SearchProductServiceImpl implements SearchProductService {
     /**
      * 获取数据库商品
      *
-     * @param num       页码
-     * @param size      每页数量
-     * @param identity  用户身份
-     * @param keyword   关键词
-     * @param shopId    供应商id
-     * @param bigTypeId 一级分类id
+     * @param num         页码
+     * @param size        每页数量
+     * @param identity    用户身份
+     * @param keyword     关键词
+     * @param shopId      供应商id
+     * @param bigTypeId   一级分类id
      * @param smallTypeId 二级分类id
-     * @param tinyTypeId 三级分类id
-     * @param classifyId 小程序运营分类id
-     * @param sortField 排序类型
-     * @param sortType  排序顺序
+     * @param tinyTypeId  三级分类id
+     * @param classifyId  小程序运营分类id
+     * @param sortField   排序类型
+     * @param sortType    排序顺序
      */
     private ResponseJson<String> queryProductFromDatabase(int num, int size, Integer identity, String keyword, Integer shopId,
-                             Integer bigTypeId, Integer smallTypeId, Integer tinyTypeId, Integer classifyId, String sortField, Integer sortType){
+                                                          Integer bigTypeId, Integer smallTypeId, Integer tinyTypeId, Integer classifyId, String sortField, Integer sortType) {
         PageHelper.startPage(num, size);
         List<ProductListVo> productList = searchMapper.queryProduct(identity, keyword, shopId, bigTypeId, smallTypeId, tinyTypeId, classifyId, sortField, sortType);
         productList.forEach(product -> {
@@ -218,8 +399,8 @@ public class SearchProductServiceImpl implements SearchProductService {
         JSONObject pageObj = new JSONObject();
         pageObj.put("total", total);
         pageObj.put("items", productList);
-        log.info(">>>>>>数据库容错查询: pageSize(" + size +"),pageNum("+size+"),total("+total+")");
-        if (productList.size()>0) {
+        log.info(">>>>>>数据库容错查询: pageSize(" + size + "),pageNum(" + size + "),total(" + total + ")");
+        if (productList.size() > 0) {
             return ResponseJson.success(pageObj.toString());
         } else {
             return ResponseJson.error("未查询到文档记录(数据库)", null);
@@ -237,33 +418,33 @@ public class SearchProductServiceImpl implements SearchProductService {
      */
     private ResponseJson<String> queryProduct(String queryStr, String filter, Integer identity, int num, int size, String sortField, Integer sortType) {
         SearchParams searchParams;
-        int requestSize = num*size;
-        if (requestSize > SEARCH_MAX_NUM){
-            searchParams = searchOpenService.getProductParams(queryStr, filter, identity,num, size, sortField, sortType);
+        int requestSize = num * size;
+        if (requestSize > SEARCH_MAX_NUM) {
+            searchParams = searchOpenService.getProductParams(queryStr, filter, identity, num, size, sortField, sortType);
         } else {
             // 由于阿里云搜索机制问题(分页数据重复),搜索500条以内数据手动分页。
-            searchParams = searchOpenService.getProductParams(queryStr, filter, identity,1, requestSize, sortField, sortType);
+            searchParams = searchOpenService.getProductParams(queryStr, filter, identity, 1, requestSize, sortField, sortType);
         }
         try {
             // 查询推送
             JSONObject result = searchOpenService.getResultJsonObject(queryStr, searchParams);
             if (1 == result.getInt("status")) {
                 int total = result.getInt("total");
-                int totalPage = (int) Math.ceil( (double)total/size);
+                int totalPage = (int) Math.ceil((double) total / size);
                 JSONArray resultArr = result.getJSONArray("items");
                 JSONArray pageData = new JSONArray();
                 if (requestSize > SEARCH_MAX_NUM) {
                     pageData = resultArr;
                 } else {
-                    if (resultArr.length()>0){
-                        int baseNum = (num-1)*size;
-                        for (int i=0; i<size; i++) {
+                    if (resultArr.length() > 0) {
+                        int baseNum = (num - 1) * size;
+                        for (int i = 0; i < size; i++) {
                             int index = baseNum + i;
                             int currentTotal = requestSize;
-                            if (totalPage == num){
+                            if (totalPage == num) {
                                 currentTotal = total;
                             }
-                            if (index<currentTotal){
+                            if (index < currentTotal) {
                                 JSONObject item = resultArr.getJSONObject(index);
                                 pageData.put(i, item);
                             } else {
@@ -277,7 +458,7 @@ public class SearchProductServiceImpl implements SearchProductService {
                 JSONObject pageObj = new JSONObject();
                 pageObj.put("total", total);
                 pageObj.put("items", productList);
-                log.info(">>>>>>pageResult("+queryStr+"): pageSize(" + size +"),pageNum("+num+"),total("+total+")");
+                log.info(">>>>>>pageResult(" + queryStr + "): pageSize(" + size + "),pageNum(" + num + "),total(" + total + ")");
                 return ResponseJson.success(pageObj.toString());
             } else {
                 return ResponseJson.error("未查询到文档记录", null);
@@ -291,18 +472,18 @@ public class SearchProductServiceImpl implements SearchProductService {
     /**
      * 滚动查询
      *
-     * @param searchParams  查询参数对象
-     * @param queryStr      查询类型及参数串
-     * @param requestPageSize  每次scroll数量
-     * @param pageNum       页码
-     * @param pageSize      每页数量
+     * @param searchParams    查询参数对象
+     * @param queryStr        查询类型及参数串
+     * @param requestPageSize 每次scroll数量
+     * @param pageNum         页码
+     * @param pageSize        每页数量
      * @return list
      */
     private ResponseJson<String> getScrollProductResult(SearchParams searchParams, String queryStr, int requestPageSize, int pageNum, int pageSize) {
         ResponseJson<String> result;
         try {
             JSONObject pageObj = searchOpenService.deepPagingForParams(searchParams, queryStr, SEARCH_MAX_NUM, requestPageSize, pageNum, pageSize);
-            if (1 == pageObj.getInt("status")){
+            if (1 == pageObj.getInt("status")) {
                 JSONArray pageData = pageObj.getJSONArray("items");
                 // 阿里云查询出json转换成商品pojo
                 List<ProductListVo> productList = Json2PojoUtil.toProductList(pageData);
@@ -353,7 +534,7 @@ public class SearchProductServiceImpl implements SearchProductService {
             searchMapper.insertSearchHistory(historyRecord);
         }
         int count = searchMapper.getHistoryCount(userId);
-        if (count>10){
+        if (count > 10) {
             // 删除大于10条的历史记录
             searchMapper.deleteSearchHistory(userId);
         }
@@ -387,6 +568,7 @@ public class SearchProductServiceImpl implements SearchProductService {
         return ResponseJson.success(map);
     }
 
+
     private List<HotSearchVo> getHotSearch(Integer typeSort, Integer source) {
         List<Integer> pageIds = pageMapper.getPageIdByTypeSort(typeSort);
         List<HotSearchVo> productHotSearch = new ArrayList<>();

+ 44 - 2
src/main/java/com/caimei365/commodity/service/impl/SellerServiceImpl.java

@@ -1,7 +1,9 @@
 package com.caimei365.commodity.service.impl;
 
 import com.caimei365.commodity.components.PriceUtilService;
+import com.caimei365.commodity.mapper.PriceMapper;
 import com.caimei365.commodity.mapper.SellerMapper;
+import com.caimei365.commodity.mapper.ShopMapper;
 import com.caimei365.commodity.model.ResponseJson;
 import com.caimei365.commodity.model.vo.CombinationVo;
 import com.caimei365.commodity.model.vo.PaginationVo;
@@ -14,6 +16,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -32,6 +35,10 @@ public class SellerServiceImpl implements SellerService {
     private PriceUtilService priceUtilService;
     @Resource
     private PageService pageService;
+    @Resource
+    private PriceMapper priceMapper;
+    @Resource
+    private ShopMapper shopMapper;
 
     /**
      * 协销搜索商品(单一)
@@ -50,7 +57,7 @@ public class SellerServiceImpl implements SellerService {
         List<ProductItemVo> productList = sellerMapper.getSingleProductList(searchWord);
         productList.forEach(product -> {
             // 设置商品主图及价格
-            priceUtilService.setProductDetails(clubUserId, product);
+            priceUtilService.setProductDetails(clubUserId, product, 1);
         });
         PaginationVo<ProductItemVo> pageData = new PaginationVo<>(productList);
         return ResponseJson.success(pageData);
@@ -83,7 +90,7 @@ public class SellerServiceImpl implements SellerService {
                 product.setInitProductNum(0);
                 product.setTotalPrice(0d);
                 // 设置商品主图及价格
-                priceUtilService.setProductDetails(clubUserId, product);
+                priceUtilService.setProductDetails(clubUserId, product, 1);
                 //优惠券标识
                 Boolean couponsLogo = pageService.setCouponsLogo(clubUserId, product.getProductId(), 2);
                 product.setCouponsLogo(couponsLogo);
@@ -94,4 +101,39 @@ public class SellerServiceImpl implements SellerService {
         return ResponseJson.success(pageData);
     }
 
+    @Override
+    public ResponseJson<PaginationVo<ProductItemVo>> searchCombinationList(Integer productId, Integer userId, Integer source, int pageNum, int pageSize) {
+        Integer combinationId = sellerMapper.findCombination(productId);
+        List<ProductItemVo> productList = new ArrayList<>();
+        PaginationVo<ProductItemVo> productItemVoPaginationVo = new PaginationVo<>(productList);
+        if (combinationId != null) {
+            List<Integer> productIdList = sellerMapper.findProductList(combinationId);
+            List<Integer> p = new ArrayList<>();
+            p.add(productId);
+            List<ProductItemVo> pd = sellerMapper.getProductList(p);
+            ProductItemVo productItemVo = pd.get(0);
+            PageHelper.startPage(pageNum, pageSize);
+            productList = sellerMapper.getProductList(productIdList);
+            //本商品设置首位
+            productList.remove(productItemVo);
+            productList.add(0, productItemVo);
+            Integer userIdentity = shopMapper.getUserIdentityById(userId);
+            // 如果非会员身份剔除会员可见商品
+            if (userIdentity != null) {
+                if (userIdentity == 0 || userIdentity == 4 || userIdentity == 6) {
+                    productList.removeIf(c -> "1".equals(c.getVisibility()));
+                }
+            }
+            productList.forEach(product -> {
+                // 设置商品主图及价格
+                priceUtilService.setProductDetails(userId, product, 2);
+                //优惠券标识
+                Boolean couponsLogo = pageService.setCouponsLogo(userId, product.getProductId(), source);
+                product.setCouponsLogo(couponsLogo);
+            });
+            productItemVoPaginationVo = new PaginationVo<>(productList);
+        }
+        return ResponseJson.success(productItemVoPaginationVo);
+    }
+
 }

+ 2 - 2
src/main/java/com/caimei365/commodity/service/impl/ShopServiceImpl.java

@@ -112,7 +112,7 @@ public class ShopServiceImpl implements ShopService {
                 product.setIsChecked(false);
                 // 设置商品主图及价格
                 Integer userId = shopMapper.getUserIdByshopId(shopId);
-                priceUtilService.setProductDetails(userId, product);
+                priceUtilService.setProductDetails(userId, product, 3);
             }
         }
         PaginationVo<ProductItemVo> productPage = new PaginationVo<>(productList);
@@ -252,7 +252,7 @@ public class ShopServiceImpl implements ShopService {
         product.setTaxPoint(productDto.getTaxPoint());
         product.setAllAreaFlag(productDto.getAllAreaFlag());
         product.setProvinceIds(productDto.getProvinceIds());*/
-        BeanUtils.copyProperties(productDto,product);
+        BeanUtils.copyProperties(productDto, product);
         product.setUpdateTime(current);
         product.setValidFlag(1);
         product.setProductCategory(1);

+ 2 - 2
src/main/java/com/caimei365/commodity/service/impl/UserLikeServiceImpl.java

@@ -58,7 +58,7 @@ public class UserLikeServiceImpl implements UserLikeService {
         List<ProductItemVo> productList = likeMapper.findLikeList(userId);
         productList.forEach(product -> {
             // 设置商品主图及价格
-            priceUtilService.setProductDetails(userId, product);
+            priceUtilService.setProductDetails(userId, product, 2);
             //优惠券标识
             Boolean couponsLogo = pageService.setCouponsLogo(userId, product.getProductId(), 2);
             product.setCouponsLogo(couponsLogo);
@@ -76,7 +76,7 @@ public class UserLikeServiceImpl implements UserLikeService {
         if (productIds.contains(",")) {
             String[] productArr = productIds.split(",");
             for (String id : productArr) {
-                Integer ids=Integer.parseInt(id);
+                Integer ids = Integer.parseInt(id);
                 productIdList.add(ids);
             }
         } else {

+ 10 - 5
src/main/java/com/caimei365/commodity/utils/Json2PojoUtil.java

@@ -19,12 +19,13 @@ import java.util.List;
 public class Json2PojoUtil {
     /**
      * 阿里云查询出json转换成商品pojo
+     *
      * @param jsonArray json
      * @return ProductListVo
      */
     public static List<ProductListVo> toProductList(JSONArray jsonArray) {
         List<ProductListVo> productList = new ArrayList<>();
-        for (int i=0; i<jsonArray.length(); i++) {
+        for (int i = 0; i < jsonArray.length(); i++) {
             JSONObject json = jsonArray.getJSONObject(i);
             ProductListVo product = new ProductListVo();
             /* 主键Id */
@@ -51,7 +52,8 @@ public class Json2PojoUtil {
             product.setShopId(json.getInt("p_supplier_id"));
             /* 美博会商品活动状态 */
             product.setBeautyActFlag(json.getInt("p_act_flag"));
-
+            /* 品牌id*/
+            product.setBrandId(json.getInt("p_brand_id"));
             productList.add(product);
         }
         return productList;
@@ -59,12 +61,13 @@ public class Json2PojoUtil {
 
     /**
      * 阿里云查询出json转换成供应商pojo
+     *
      * @param jsonArray json
      * @return ShopListVo
      */
     public static List<ShopListVo> toShopList(JSONArray jsonArray) {
         List<ShopListVo> shopList = new ArrayList<>();
-        for (int i=0; i<jsonArray.length(); i++) {
+        for (int i = 0; i < jsonArray.length(); i++) {
             ShopListVo shop = new ShopListVo();
             JSONObject json = jsonArray.getJSONObject(i);
             /* 主键Id */
@@ -94,12 +97,13 @@ public class Json2PojoUtil {
 
     /**
      * 阿里云查询出json转换项目仪器pojo
+     *
      * @param jsonArray json
      * @return ShopListVo
      */
     public static List<EquipmentListVo> toEquipmentList(JSONArray jsonArray) {
         List<EquipmentListVo> equipmentList = new ArrayList<>();
-        for (int i=0; i<jsonArray.length(); i++) {
+        for (int i = 0; i < jsonArray.length(); i++) {
             EquipmentListVo equipment = new EquipmentListVo();
             JSONObject json = jsonArray.getJSONObject(i);
             /* 阿里云索引Id */
@@ -118,12 +122,13 @@ public class Json2PojoUtil {
 
     /**
      * 阿里云查询出json转换成文章pojo
+     *
      * @param jsonArray json
      * @return ShopListVo
      */
     public static List<ArticleListVo> toArticleList(JSONArray jsonArray) {
         List<ArticleListVo> articleList = new ArrayList<>();
-        for (int i=0; i<jsonArray.length(); i++) {
+        for (int i = 0; i < jsonArray.length(); i++) {
             ArticleListVo article = new ArticleListVo();
             JSONObject json = jsonArray.getJSONObject(i);
             /* 阿里云索引Id */

+ 1 - 3
src/main/resources/mapper/PageMapper.xml

@@ -194,8 +194,7 @@
             p.price1TextFlag as priceFlag,
             p.price1 as price,
             p.costPrice,
-            p.costCheckFlag,
-            p.shopID as shopId,
+            ifnull(p.costCheckFlag,1) as costCheckFlag,
             p.searchKey as keyword,
             p.price8Text as beautyActFlag,
             p.minBuyNumber as minBuyNumber,
@@ -294,7 +293,6 @@
 		select
             id,
             navigationName as name,
-            type,
             link,
             icon,
             sort

+ 70 - 66
src/main/resources/mapper/PromotionsMapper.xml

@@ -2,23 +2,20 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.commodity.mapper.PromotionsMapper">
     <select id="getPromotionsById" resultType="com.caimei365.commodity.model.vo.PromotionsVo">
-        select
-          id,
-          name,
-          description,
-          type,
-          mode,
-          touchPrice,
-          reducedPrice,
-          beginTime,
-          endTime,
-          status
-        from
-          cm_promotions
-        where
-          id = #{promotionsId}
+        select id,
+               name,
+               description,
+               type,
+               mode,
+               touchPrice,
+               reducedPrice,
+               beginTime,
+               endTime,
+               status
+        from cm_promotions
+        where id = #{promotionsId}
           and (status = 1 or (status = 2 and (NOW() between beginTime and endTime)))
-          and delFlag not in (1,2)
+          and delFlag not in (1, 2)
     </select>
     <select id="getPromotionsByProductId" resultType="com.caimei365.commodity.model.vo.PromotionsVo">
         select pr.id,
@@ -33,54 +30,55 @@
                pr.status,
                prp.productId,
                prp.supplierId as shopId,
-               pr.seen as promotionsSeen
+               pr.seen        as seen
         from cm_promotions pr
                  left join cm_promotions_product prp on pr.id = prp.promotionsId
         where (prp.productId = #{productId} or
                prp.supplierId = (select p.shopID from product p where p.productID = #{productId})
             )
           and (pr.status = 1 or (pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
-          and pr.delFlag not in (1,2)
+          and pr.delFlag not in (1, 2)
         order by pr.type desc
         limit 1
     </select>
     <select id="getPromotionGifts" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
-		select
-			cpg.id as id,
-			p.productID as productId,
-            p.actStatus,
-			p.shopID as shopId,
-			p.`name` as `name`,
-			p.mainImage as image,
-			cpg.number as number,
-			0 as price,
-			2 as productType,
-			p.price1 as originalPrice,
-			p.unit as unit,
-			p.validFlag as validFlag,
-			p.stock as stock
-		from product p
-		left join cm_promotions_gift cpg on cpg.productId = p.productID
-		where cpg.promotionsId = #{promotionsId}
-		order by cpg.addTime desc
+        select cpg.id      as id,
+               p.productID as productId,
+               p.actStatus,
+               p.shopID    as shopId,
+               p.`name`    as `name`,
+               p.mainImage as image,
+               cpg.number  as number,
+               0           as price,
+               2           as productType,
+               p.price1    as originalPrice,
+               p.unit      as unit,
+               p.validFlag as validFlag,
+               p.stock     as stock
+        from product p
+                 left join cm_promotions_gift cpg on cpg.productId = p.productID
+        where cpg.promotionsId = #{promotionsId}
+        order by cpg.addTime desc
     </select>
     <select id="getPromotionsList" resultType="com.caimei365.commodity.model.vo.ImageLinkVo">
-        select  a.id as id,
-                a.title as title,
-                a.link as link,
-                a.image as image,
-                a.beginTime as beginTime,
-                a.endTime as endTime,
-                a.appletsImage as crmImage,
-                a.appletsLink as crmLink,
-                (case
-                when a.beginTime>NOW() and <![CDATA[a.beginTime < a.endTime ]]> then 1
-                when <![CDATA[a.beginTime<NOW()]]> and a.endTime >NOW() and <![CDATA[a.beginTime < a.endTime ]]> then 2
-                else 3 end) as status,
-                (case
-                when a.beginTime>NOW() and <![CDATA[a.beginTime < a.endTime ]]>  then concat(DATE_FORMAT(a.beginTime,'%Y-%m-%d'),'~',DATE_FORMAT(a.endTime,'%Y-%m-%d'))
-                when <![CDATA[a.beginTime<NOW()]]> and a.endTime >NOW() and <![CDATA[a.beginTime < a.endTime ]]> then concat(DATE_FORMAT(a.beginTime,'%Y-%m-%d'),'~',DATE_FORMAT(a.endTime,'%Y-%m-%d'))
-                else null end) as detail
+        select a.id as id,
+        a.title as title,
+        a.link as link,
+        a.image as image,
+        a.beginTime as beginTime,
+        a.endTime as endTime,
+        a.appletsImage as crmImage,
+        a.appletsLink as crmLink,
+        (case
+        when a.beginTime>NOW() and <![CDATA[a.beginTime < a.endTime ]]> then 1
+        when <![CDATA[a.beginTime<NOW()]]> and a.endTime >NOW() and <![CDATA[a.beginTime < a.endTime ]]> then 2
+        else 3 end) as status,
+        (case
+        when a.beginTime>NOW() and <![CDATA[a.beginTime < a.endTime ]]>  then
+        concat(DATE_FORMAT(a.beginTime,'%Y-%m-%d'),'~',DATE_FORMAT(a.endTime,'%Y-%m-%d'))
+        when <![CDATA[a.beginTime<NOW()]]> and a.endTime >NOW() and <![CDATA[a.beginTime < a.endTime ]]> then
+        concat(DATE_FORMAT(a.beginTime,'%Y-%m-%d'),'~',DATE_FORMAT(a.endTime,'%Y-%m-%d'))
+        else null end) as detail
         from cm_page_image a
         where a.type=4
         <choose>
@@ -94,16 +92,16 @@
         order by case when <![CDATA[status<3]]> then 0 when status>=3 then 1 end asc,a.sort desc,a.createDate desc
     </select>
     <select id="getProductListByPromotions" resultType="com.caimei365.commodity.model.search.ProductListVo">
-		select
-			p.productID as productId,
-			p.`name` as `name`,
-			p.mainImage as image,
-			p.price1 as price,
-			p.unit as unit,
-			p.price1TextFlag as priceFlag,
-            IFNULL(p.visibility,3) as visibility
-		from product p
-		left join cm_promotions_product cpp on cpp.productId = p.productID
+        select
+        p.productID as productId,
+        p.`name` as `name`,
+        p.mainImage as image,
+        p.price1 as price,
+        p.unit as unit,
+        p.price1TextFlag as priceFlag,
+        IFNULL(p.visibility,3) as visibility
+        from product p
+        left join cm_promotions_product cpp on cpp.productId = p.productID
         where cpp.promotionsId = #{promotionsId}
         and p.visibility in
         <foreach collection="visibilityList" item="visibility" index="index" open="(" separator="," close=")">
@@ -125,12 +123,18 @@
                pr.status,
                cpg.productId
         from cm_promotions pr
-        left join cm_promotions_gift cpg on pr.id = cpg.promotionsId
+                 left join cm_promotions_gift cpg on pr.id = cpg.promotionsId
         where cpg.productId = #{productId}
-        and (pr.status = 1 or ( pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
-        and pr.mode = 3
-        and pr.delFlag not in (1,2)
+          and (pr.status = 1 or (pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
+          and pr.mode = 3
+          and pr.delFlag not in (1, 2)
         order by pr.type desc
         limit 1
     </select>
+
+    <select id="findUserIdentity" resultType="java.lang.Integer">
+        select userIdentity
+        from user
+        where userID = #{userId}
+    </select>
 </mapper>

+ 158 - 108
src/main/resources/mapper/SearchMapper.xml

@@ -14,7 +14,7 @@
         p.unit as p_unit,
         p.sellNumber as p_sales,
         p.favoriteTimes as p_favorite,
-        p.brandID as p_brand_id,
+        br.id as p_brand_id,
         br.name as p_brand_name,
         p.shopID as p_supplier_id,
         sh.name as p_supplier_name,
@@ -24,11 +24,10 @@
         s.name as p_category2_name,
         p.tinyTypeID as p_category3_id,
         t.name as p_category3_name,
-        p.classifyId as p_classify_id,
-        c.classifyName as p_classify_name,
         p.preferredFlag as p_preferred,
         p.productCategory as p_type,
         p.validFlag as p_valid,
+        DATE_FORMAT(p.ADDTIME,'%Y%m%d') as p_time,
         IFNULL(p.visibility,3) as p_visibility,
         IFNULL(p.price8Text,0) as p_act_flag
     </sql>
@@ -36,7 +35,6 @@
         left join tinytype as t on p.tinyTypeID = t.tinyTypeID
         left join smalltype as s on p.smallTypeID = s.smallTypeID
         left join bigtype as b on p.bigTypeID = b.bigTypeID
-        left join cm_products_classify as c on p.classifyId = c.id
         left join cm_brand as br on p.brandID = br.id
         left join shop as sh on p.shopID = sh.shopID
     </sql>
@@ -50,54 +48,61 @@
     <select id="findProductCount" resultType="java.lang.Integer">
         select count(*)
         from product
-        where validFlag in (2,3,9) and productCategory = 1
+        where validFlag in (2, 3, 9)
+          and productCategory = 1
     </select>
     <select id="findProductInvalidCount" resultType="java.lang.Integer">
         select count(*)
         from product
-        where validFlag not in (2,3,9) or productCategory != 1
+        where validFlag not in (2, 3, 9)
+           or productCategory != 1
     </select>
     <select id="findProductInvalidIds" resultType="java.lang.Integer">
         select productID
         from product
-        where validFlag not in (2,3,9) or productCategory != 1
+        where validFlag not in (2, 3, 9)
+           or productCategory != 1
     </select>
     <select id="searchProductList" resultType="com.caimei365.commodity.model.search.ProductDO">
-        select <include refid="Search_Product_List"/>
+        select
+        <include refid="Search_Product_List"/>
         from product p
         <include refid="Product_Joins"/>
         where p.validFlag in (2,3,9) and productCategory = 1
         order by productID desc
     </select>
     <select id="countMallProduct" resultType="java.lang.Integer">
-        select COUNT(*) from cm_mall_organize_products
-        where productID=#{productId} and organizeID=1
+        select COUNT(*)
+        from cm_mall_organize_products
+        where productID = #{productId}
+          and organizeID = 1
     </select>
     <select id="searchMallProductByProductId" resultType="com.caimei365.commodity.model.search.MallProductDO">
-        select
-        m.id as m_id,
-        m.organizeID as m_organize_id,
-        m.productID as m_product_id,
-        m.retailPrice as m_price,
-        m.classifyID as m_classify_id,
-        m.delFlag as m_valid,
-        c.classifyName as m_classify_name
+        select m.id           as m_id,
+               m.organizeID   as m_organize_id,
+               m.productID    as m_product_id,
+               m.retailPrice  as m_price,
+               m.classifyID   as m_classify_id,
+               m.delFlag      as m_valid,
+               c.classifyName as m_classify_name
         from cm_mall_organize_products as m
-        left join cm_mall_products_classify as c on m.classifyId = c.id
-        where m.productID = #{productId} and m.organizeID = 1
+                 left join cm_mall_products_classify as c on m.classifyId = c.id
+        where m.productID = #{productId}
+          and m.organizeID = 1
         limit 1
     </select>
     <select id="getMallLadderPriceFlag" resultType="java.lang.Integer">
         select ladderPriceFlag
         from cm_mall_organize_products
-        where productID = #{productId} and organizeID=1
+        where productID = #{productId}
+          and organizeID = 1
         limit 1
     </select>
     <select id="getMallLowerLadderPrice" resultType="java.lang.Double">
         select MIN(buyPrice)
         from cm_mall_product_ladder_price
         where delFlag = '0'
-        and productId = #{productId}
+          and productId = #{productId}
     </select>
     <select id="findMallIdByProductId" resultType="java.lang.Integer">
         select id
@@ -109,9 +114,9 @@
         select id
         from cm_mall_organize_products
         where productID IN
-          <foreach collection="invalidIds" open="(" separator="," close=")" item="productId">
-              #{productId}
-          </foreach>
+        <foreach collection="invalidIds" open="(" separator="," close=")" item="productId">
+            #{productId}
+        </foreach>
     </select>
 
     <!-- 供应商 -->
@@ -135,28 +140,31 @@
         select count(*)
         from shop
         where (status = 90 or status = 9)
-        and shopID != 1252
+          and shopID != 1252
     </select>
     <select id="findSupplierInvalidCount" resultType="java.lang.Integer">
         select count(*)
         from shop
-        where status not in (90,9) or shopID = 1252
+        where status not in (90, 9)
+           or shopID = 1252
     </select>
     <select id="findSupplierInvalidIds" resultType="java.lang.Integer">
         select shopID
         from shop
-        where status not in (90,9) or shopID = 1252
+        where status not in (90, 9)
+           or shopID = 1252
     </select>
     <select id="searchSupplierList" resultType="com.caimei365.commodity.model.search.SupplierDO">
-        select <include refid="Search_Supplier_List"/>
+        select
+        <include refid="Search_Supplier_List"/>
         from shop as s
         <include refid="Supplier_Joins"/>
         where (status = 90 or status = 9)
         and shopID != 1252
-        order by s.sortIndex
     </select>
     <select id="searchSupplierById" resultType="com.caimei365.commodity.model.search.SupplierDO">
-        select <include refid="Search_Supplier_List"/>
+        select
+        <include refid="Search_Supplier_List"/>
         from shop as s
         <include refid="Supplier_Joins"/>
         where (status = 90 or status = 9)
@@ -175,26 +183,31 @@
     <select id="findEquipmentCount" resultType="java.lang.Integer">
         select count(*)
         from cm_page
-        where type = 2 and enabledStatus = 1
+        where type = 2
+          and enabledStatus = 1
     </select>
     <select id="findEquipmentInvalidCount" resultType="java.lang.Integer">
         select count(*)
         from cm_page
-        where type != 2 or enabledStatus != 1
+        where type != 2
+           or enabledStatus != 1
     </select>
     <select id="findEquipmentInvalidIds" resultType="java.lang.Integer">
         select id
         from cm_page
-        where type != 2 or enabledStatus != 1
+        where type != 2
+           or enabledStatus != 1
     </select>
     <select id="searchEquipmentList" resultType="com.caimei365.commodity.model.search.EquipmentDO">
-        select <include refid="Search_Equipment_List"/>
+        select
+        <include refid="Search_Equipment_List"/>
         from cm_page as e
         where e.type = 2 and e.enabledStatus = 1
         order by e.docBoost desc
     </select>
     <select id="searchEquipmentById" resultType="com.caimei365.commodity.model.search.EquipmentDO">
-        select <include refid="Search_Equipment_List"/>
+        select
+        <include refid="Search_Equipment_List"/>
         from cm_page as e
         where e.id = #{equipmentId}
         and e.type = 2 and e.enabledStatus = 1
@@ -215,10 +228,10 @@
         b.name as a_type_text,
         a.priorityIndex as a_sort
     </sql>
-	<sql id="Article_Joins">
-		left join info_type b on a.typeId = b.id
+    <sql id="Article_Joins">
+        left join info_type b on a.typeId = b.id
 		left join info_praise c on a.id = c.infoId
-	</sql>
+    </sql>
     <select id="findArticleCount" resultType="java.lang.Integer">
         select count(*)
         from info
@@ -235,52 +248,54 @@
         where enabledStatus != 1
     </select>
     <select id="searchArticleList" resultType="com.caimei365.commodity.model.search.ArticleDO">
-        select <include refid="Search_Article_List"/>
+        select
+        <include refid="Search_Article_List"/>
         from info as a
         <include refid="Article_Joins"/>
         where a.enabledStatus = 1
         order by a.priorityIndex desc
     </select>
     <select id="searchArticleById" resultType="com.caimei365.commodity.model.search.ArticleDO">
-        select <include refid="Search_Article_List"/>
+        select
+        <include refid="Search_Article_List"/>
         from info as a
         <include refid="Article_Joins"/>
         where a.id = #{articleId}
         and a.enabledStatus = 1
     </select>
     <select id="findLabelIdsByName" resultType="java.lang.Integer">
-		select id
-		from info_label
-		where  infoLabelStatus = 1
-		and name in
-		<foreach collection="labelTexts" item="label" open="(" close=")" index="index" separator=",">
-			#{label}
-		</foreach>
-		group by name
-		order by clickRate desc
+        select id
+        from info_label
+        where infoLabelStatus = 1
+        and name in
+        <foreach collection="labelTexts" item="label" open="(" close=")" index="index" separator=",">
+            #{label}
+        </foreach>
+        group by name
+        order by clickRate desc
     </select>
     <select id="findLabelNameById" resultType="java.lang.String">
-		select name
-		from info_label
-		where  infoLabelStatus = 1
-		and id = #{labelId}
-		limit 1
+        select name
+        from info_label
+        where infoLabelStatus = 1
+          and id = #{labelId}
+        limit 1
     </select>
     <!-- 搜索容错 商品列表 -->
     <select id="queryProduct" resultType="com.caimei365.commodity.model.search.ProductListVo">
         select
-            p.productID as productId,
-            p.actStatus,
-            p.`name` as name,
-            p.mainImage as image,
-            br.name as brandName,
-            p.unit as unit,
-            p.productCode as code,
-            p.price1TextFlag as priceFlag,
-            p.price1 as price,
-            p.shopID as shopId,
-            p.searchKey as keyword,
-            IFNULL(p.price8Text,0) as beautyActFlag
+        p.productID as productId,
+        p.actStatus,
+        p.`name` as name,
+        p.mainImage as image,
+        br.name as brandName,
+        p.unit as unit,
+        p.productCode as code,
+        p.price1TextFlag as priceFlag,
+        p.price1 as price,
+        p.shopID as shopId,
+        p.searchKey as keyword,
+        IFNULL(p.price8Text,0) as beautyActFlag
         from product p
         left join cm_brand as br on p.brandID = br.id
         where p.productCategory = 1
@@ -310,9 +325,6 @@
         <if test="tinyTypeId != null and tinyTypeId != ''">
             and p.tinyTypeID = #{tinyTypeId}
         </if>
-        <if test="classifyId != null and classifyId != ''">
-            and p.classifyId = #{classifyId}
-        </if>
         <if test="keyword != null and keyword != ''">
             and p.name like concat('%',#{keyword},'%')
         </if>
@@ -348,49 +360,48 @@
     </select>
     <!-- 搜索容错 供应商列表 -->
     <select id="querySupplier" resultType="com.caimei365.commodity.model.search.ShopListVo">
-        select
-            s.shopID as shopId,
-            s.name as name,
-            s.logo as logo,
-            s.authorizationCertificateImage as license,
-            s.businessScope as business,
-            CONCAT(p.name, c.name) as address
+        select s.shopID                        as shopId,
+               s.name                          as name,
+               s.logo                          as logo,
+               s.authorizationCertificateImage as license,
+               s.businessScope                 as business,
+               CONCAT(p.name, c.name)          as address
         from shop as s
-        left join town as t on s.townId = t.townID
-        left join city as c on t.cityID = c.cityID
-        left join province as p on c.provinceID = p.provinceID
+                 left join town as t on s.townId = t.townID
+                 left join city as c on t.cityID = c.cityID
+                 left join province as p on c.provinceID = p.provinceID
         where (status = 90 or status = 9)
-        and shopID != 1252
-        and s.name like concat('%',#{keyword},'%')
+          and shopID != 1252
+          and s.name like concat('%', #{keyword}, '%')
     </select>
     <!-- 搜索容错 项目仪器列表 -->
     <select id="queryEquipment" resultType="com.caimei365.commodity.model.search.EquipmentListVo">
-        select
-            e.id as id,
-            e.title as name,
-            e.precisehKey as keyword,
-            e.headImage as image
+        select e.id          as id,
+               e.title       as name,
+               e.precisehKey as keyword,
+               e.headImage   as image
         from cm_page as e
-        where e.type = 2 and e.enabledStatus = 1
-        and e.title like concat('%',#{keyword},'%')
+        where e.type = 2
+          and e.enabledStatus = 1
+          and e.title like concat('%', #{keyword}, '%')
         order by e.docBoost desc
     </select>
     <!-- 搜索容错 文章列表 -->
     <select id="queryArticle" resultType="com.caimei365.commodity.model.search.ArticleListVo">
         select
-            a.id as articleId,
-            a.title as title,
-            a.guidanceImage as image,
-            a.publisher as publisher,
-            a.pubdate as publishDate,
-            a.recommendContent as intro,
-            (IFNULL(c.pv, 0) +IFNULL(c.num, 0) + IFNULL(a.basePv, 0) + IFNULL(a.basePraise, 0)) as pv,
-            a.typeId as typeId,
-            b.name as typeText,
-            a.label as labelText
+        a.id as articleId,
+        a.title as title,
+        a.guidanceImage as image,
+        a.publisher as publisher,
+        a.pubdate as publishDate,
+        a.recommendContent as intro,
+        (IFNULL(c.pv, 0) +IFNULL(c.num, 0) + IFNULL(a.basePv, 0) + IFNULL(a.basePraise, 0)) as pv,
+        a.typeId as typeId,
+        b.name as typeText,
+        a.label as labelText
         from info as a
-		left join info_type b on a.typeId = b.id
-		left join info_praise c on a.id = c.infoId
+        left join info_type b on a.typeId = b.id
+        left join info_praise c on a.id = c.infoId
         <where>
             a.enabledStatus = 1
             <if test="articleId != null">
@@ -422,11 +433,16 @@
         order by id desc
     </select>
     <select id="getHistoryIdByWord" resultType="java.lang.Integer">
-        select id from user_search_history where searchWord = #{keyword} limit 1
+        select id
+        from user_search_history
+        where searchWord = #{keyword}
+        limit 1
     </select>
     <select id="getHistoryCount" resultType="java.lang.Integer">
-        select COUNT(*) from user_search_history
-        where userId = #{userId} AND delFlag = 0
+        select COUNT(*)
+        from user_search_history
+        where userId = #{userId}
+          AND delFlag = 0
     </select>
     <update id="updateSearchHistoryById">
         update user_search_history
@@ -478,12 +494,46 @@
         </trim>
     </insert>
     <delete id="deleteSearchHistory">
-        DELETE FROM user_search_history
-        WHERE userId=#{userId} AND id NOT IN (
-            SELECT temp.id FROM ( SELECT id FROM user_search_history WHERE userId=#{userId} ORDER BY searchDate DESC LIMIT 10 ) AS temp
+        DELETE
+        FROM user_search_history
+        WHERE userId = #{userId}
+          AND id NOT IN (
+            SELECT temp.id
+            FROM (SELECT id FROM user_search_history WHERE userId = #{userId} ORDER BY searchDate DESC LIMIT 10) AS temp
         )
     </delete>
     <delete id="deleteAllSearchHistory">
-        DELETE FROM user_search_history WHERE userId=#{userId}
+        DELETE
+        FROM user_search_history
+        WHERE userId = #{userId}
     </delete>
+
+    <select id="findNew" resultType="java.lang.Integer">
+        select productID from product
+        where TIMESTAMP(ADDTIME) <![CDATA[ > ]]> TIMESTAMP(#{n})
+        <if test="productIds != null">
+            and productID in
+            <foreach collection="productIds" item="productId" index="index" open="(" separator="," close=")">
+                #{productId}
+            </foreach>
+        </if>
+    </select>
+    <select id="findPromotion" resultType="java.lang.Integer">
+        select cpp.productID from cm_promotions_product cpp
+        left join cm_promotions cp on cpp.promotionsId = cp.id
+        where cpp.productId in
+        <foreach collection="productIds" item="productId" index="index" open="(" separator="," close=")">
+            #{productId}
+        </foreach>
+        and cp.endTime>now() or (cp.status='1')
+        and cp.delflag = 0
+    </select>
+    <select id="findPromotionId" resultType="java.lang.Integer">
+        select cpp.promotionsId
+        from cm_promotions_product cpp
+        left join cm_promotions cp on cp.id=cpp.promotionsId
+        where cpp.productId = #{p_id}
+        and cp.endTime>now() or (cp.status='1')
+        and cp.delflag = 0
+    </select>
 </mapper>

+ 111 - 63
src/main/resources/mapper/SellerMapper.xml

@@ -2,39 +2,37 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.commodity.mapper.SellerMapper">
     <select id="getSingleProductList" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
-        select
-            p.productID as productId,
-            p.actStatus,
-            p.name,
-            p.aliasName,
-            p.mainImage as image,
-            p.unit,
-            p.productCode as code,
-            p.price1TextFlag as priceFlag,
-            p.price1 as price,
-            p.shopID as shopId,
-            p.searchKey as keyword,
-            p.price8Text as beautyActFlag,
-            p.minBuyNumber as minBuyNumber,
-            p.maxBuyNumber as maxBuyNumber,
-            p.ladderPriceFlag,
-            p.normalPrice,
-            p.step,
-            p.shopID as shopId,
-            p.taxPoint as taxRate,
-            p.includedTax,
-            p.invoiceType,
-            p.productCategory as productCategory,
-            p.validFlag,
-            p.featuredFlag,
-            p.commodityType,
-            p.bigTypeID as bigTypeId,
-            p.smallTypeID as smallTypeId,
-            p.tinyTypeID as tinyTypeId
+        select p.productID       as productId,
+               p.actStatus,
+               p.name,
+               p.aliasName,
+               p.mainImage       as image,
+               p.unit,
+               p.productCode     as code,
+               p.price1TextFlag  as priceFlag,
+               p.price1          as price,
+               p.shopID          as shopId,
+               p.searchKey       as keyword,
+               p.price8Text      as beautyActFlag,
+               p.minBuyNumber    as minBuyNumber,
+               p.maxBuyNumber    as maxBuyNumber,
+               p.ladderPriceFlag,
+               p.normalPrice,
+               p.step,
+               p.shopID          as shopId,
+               p.taxPoint        as taxRate,
+               p.includedTax,
+               p.invoiceType,
+               p.productCategory as productCategory,
+               p.validFlag,
+               p.featuredFlag,
+               p.commodityType,
+               p.bigTypeID       as bigTypeId,
+               p.smallTypeID     as smallTypeId,
+               p.tinyTypeID      as tinyTypeId
         from product p
-        where
-        (name LIKE CONCAT('%',#{searchWord},'%') or productCode LIKE CONCAT('%',#{searchWord},'%'))
-        and validFlag in (2,3,9)
+        where (name LIKE CONCAT('%', #{searchWord}, '%') or productCode LIKE CONCAT('%', #{searchWord}, '%'))
+          and validFlag in (2, 3, 9)
     </select>
     <select id="getCombinationList" resultType="com.caimei365.commodity.model.vo.CombinationVo">
         select c.id, c.name, c.addTime, c.updateTime
@@ -49,37 +47,87 @@
         order by c.addTime desc
     </select>
     <select id="getCombinationProductList" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
-        select
-            p.productID as productId,
-            p.actStatus,
-            p.name,
-            p.aliasName,
-            p.mainImage as image,
-            p.unit,
-            p.productCode as code,
-            p.price1TextFlag as priceFlag,
-            p.price1 as price,
-            p.shopID as shopId,
-            p.searchKey as keyword,
-            p.price8Text as beautyActFlag,
-            p.minBuyNumber as minBuyNumber,
-            p.maxBuyNumber as maxBuyNumber,
-            p.ladderPriceFlag,
-            p.normalPrice,
-            p.step,
-            p.shopID as shopId,
-            p.taxPoint as taxRate,
-            p.includedTax,
-            p.invoiceType,
-            p.productCategory as productCategory,
-            p.validFlag,
-            p.featuredFlag,
-            p.commodityType,
-            p.bigTypeID as bigTypeId,
-            p.smallTypeID as smallTypeId,
-            p.tinyTypeID as tinyTypeId
+        select p.productID       as productId,
+               p.actStatus,
+               p.name,
+               p.aliasName,
+               p.mainImage       as image,
+               p.unit,
+               p.productCode     as code,
+               p.price1TextFlag  as priceFlag,
+               p.price1          as price,
+               p.shopID          as shopId,
+               p.searchKey       as keyword,
+               p.price8Text      as beautyActFlag,
+               p.minBuyNumber    as minBuyNumber,
+               p.maxBuyNumber    as maxBuyNumber,
+               p.ladderPriceFlag,
+               p.normalPrice,
+               p.step,
+               p.shopID          as shopId,
+               p.taxPoint        as taxRate,
+               p.includedTax,
+               p.invoiceType,
+               p.productCategory as productCategory,
+               p.validFlag,
+               p.featuredFlag,
+               p.commodityType,
+               p.bigTypeID       as bigTypeId,
+               p.smallTypeID     as smallTypeId,
+               p.tinyTypeID      as tinyTypeId
         from product p
-        where p.validFlag = 2 and p.combinationID = #{id}
-        order by p.combinationSort!= 0 desc,p.combinationSort asc
+        where p.validFlag = 2
+          and p.combinationID = #{id}
+        order by p.combinationSort != 0 desc, p.combinationSort asc
+    </select>
+
+    <select id="findCombination" resultType="java.lang.Integer">
+        select c.id
+        from cm_product_combination c
+                 left join product p on p.combinationID = c.id
+        where p.productID = #{productId}
+    </select>
+    <select id="findProductList" resultType="java.lang.Integer">
+        select productID
+        from product
+        where combinationID = #{combinationId}
+    </select>
+    <select id="getProductList" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
+        select p.productID as productId,
+        p.actStatus,
+        p.name,
+        p.aliasName,
+        p.visibility,
+        p.mainImage as image,
+        p.unit,
+        p.productCode as code,
+        p.price1TextFlag as priceFlag,
+        p.price1 as price,
+        p.shopID as shopId,
+        p.searchKey as keyword,
+        p.price8Text as beautyActFlag,
+        p.minBuyNumber as minBuyNumber,
+        p.maxBuyNumber as maxBuyNumber,
+        p.ladderPriceFlag,
+        p.normalPrice,
+        p.step,
+        p.shopID as shopId,
+        p.taxPoint as taxRate,
+        p.includedTax,
+        p.invoiceType,
+        p.productCategory as productCategory,
+        p.validFlag,
+        p.featuredFlag,
+        p.commodityType,
+        p.bigTypeID as bigTypeId,
+        p.smallTypeID as smallTypeId,
+        p.tinyTypeID as tinyTypeId
+        from product p
+        where
+        p.productID in
+        <foreach collection="productIds" open="(" separator="," close=")" item="productId">
+            #{productId}
+        </foreach>
+        and validFlag = '2'
     </select>
 </mapper>

+ 15 - 17
src/test/java/com/caimei365/commodity/ProductApplicationTests.java

@@ -1,20 +1,18 @@
-package com.caimei365.commodity;
-
-import org.apache.commons.lang.StringUtils;
-import org.junit.jupiter.api.Test;
-import org.springframework.boot.test.context.SpringBootTest;
-
-import java.util.Arrays;
-
-@SpringBootTest
-class ProductApplicationTests {
-
+//package com.caimei365.commodity;
+//
+//import org.junit.jupiter.api.Test;
+//import org.springframework.boot.test.context.SpringBootTest;
+//
+//@SpringBootTest
+//class ProductApplicationTests {
+//
 //    @Test
 //    void contextLoads() {
-//        String[] split = new String[]{"wwe","dsfsdf","","","dsfds"};
-//        Object[] objects = Arrays.stream(split).filter(StringUtils::isNotEmpty).toArray();
-//        System.out.println(Arrays.toString(objects));
+////        String[] split = new String[]{"wwe","dsfsdf","","","dsfds"};
+////        Object[] objects = Arrays.stream(split).filter(StringUtils::isNotEmpty).toArray();
+////        System.out.println(Arrays.toString(objects));
+//
 //    }
-
-
-}
+//
+//
+//}