Sfoglia il codice sorgente

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

plf 4 anni fa
parent
commit
6ecde45ed4
25 ha cambiato i file con 835 aggiunte e 136 eliminazioni
  1. 2 1
      src/main/java/com/caimei365/commodity/components/PriceUtilService.java
  2. 67 9
      src/main/java/com/caimei365/commodity/controller/ProductPageApi.java
  3. 83 37
      src/main/java/com/caimei365/commodity/controller/SearchIndexApi.java
  4. 26 0
      src/main/java/com/caimei365/commodity/mapper/PageMapper.java
  5. 1 1
      src/main/java/com/caimei365/commodity/mapper/PriceMapper.java
  6. 4 0
      src/main/java/com/caimei365/commodity/mapper/ShopMapper.java
  7. 42 0
      src/main/java/com/caimei365/commodity/model/dto/UpdateIndexDto.java
  8. 23 0
      src/main/java/com/caimei365/commodity/model/vo/BaseLinkVo.java
  9. 58 0
      src/main/java/com/caimei365/commodity/model/vo/CmPageVo.java
  10. 5 0
      src/main/java/com/caimei365/commodity/model/vo/FloorImageVo.java
  11. 1 0
      src/main/java/com/caimei365/commodity/model/vo/ImageLinkVo.java
  12. 4 0
      src/main/java/com/caimei365/commodity/model/vo/ProductDetailVo.java
  13. 56 0
      src/main/java/com/caimei365/commodity/model/vo/TopMenuVo.java
  14. 34 0
      src/main/java/com/caimei365/commodity/service/PageService.java
  15. 136 0
      src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java
  16. 1 1
      src/main/java/com/caimei365/commodity/service/impl/PriceServiceImpl.java
  17. 168 61
      src/main/java/com/caimei365/commodity/service/impl/SearchIndexServiceImpl.java
  18. 33 10
      src/main/java/com/caimei365/commodity/service/impl/SearchQueryServiceImpl.java
  19. 3 3
      src/main/java/com/caimei365/commodity/service/impl/ShopServiceImpl.java
  20. 16 2
      src/main/java/com/caimei365/commodity/utils/AppletsLinkUtil.java
  21. 64 6
      src/main/resources/mapper/PageMapper.xml
  22. 1 1
      src/main/resources/mapper/PriceMapper.xml
  23. 1 1
      src/main/resources/mapper/SearchMapper.xml
  24. 2 2
      src/main/resources/mapper/SecondHandMapper.xml
  25. 4 1
      src/main/resources/mapper/ShopMapper.xml

+ 2 - 1
src/main/java/com/caimei365/commodity/components/PriceUtilService.java

@@ -88,6 +88,7 @@ public class PriceUtilService {
         // 根据商品id查询商品活动
         PromotionsVo promotions = promotionsMapper.getPromotionsByProductId(price.getProductId());
         price.setRepurchaseFlag(0);
+        price.setActStatus(0);
         if (null != identity && identity > 0) {
             // 用户身份: 2-会员机构, 4-普通机构
             price.setUserIdentity(identity);
@@ -188,7 +189,7 @@ public class PriceUtilService {
         product.setUserIdentity(price.getUserIdentity());
         product.setRepurchaseFlag(price.getRepurchaseFlag());
         product.setMaxBuyNumber(price.getMaxBuyNumber());
-        List<LadderPriceVo> ladderPrices = priceMapper.getladderPricesByProductId(product.getProductId());
+        List<LadderPriceVo> ladderPrices = priceMapper.getLadderPricesByProductId(product.getProductId());
         TaxVo tax = priceMapper.getTaxByProductId(product.getProductId());
         if (!CollectionUtils.isEmpty(ladderPrices)) {
             setLadderPriceList(ladderPrices, tax);

+ 67 - 9
src/main/java/com/caimei365/commodity/controller/ProductPageApi.java

@@ -81,6 +81,73 @@ public class ProductPageApi {
         return pageService.getHomeData(userId, source);
     }
 
+    /**
+     * 首页基础数据(小程序)
+     *
+     * @param source 来源 : 1 网站 ; 2 小程序
+     */
+    @ApiOperation("首页楼层数据(旧:/home/init)")
+    @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
+    @GetMapping("/home/init")
+    public ResponseJson<Map<String, Object>> getHomeInit(Integer source) {
+        return pageService.getHomeInit(source);
+    }
+
+
+    /**
+     * 活动专题楼层数据(美博会)
+     *
+     * @param pageId 页面id
+     * @param userId 用户id
+     * @param source 来源 : 1 网站 ; 2 小程序
+     */
+    @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小程序")
+    })
+    @GetMapping("/page/floor")
+    public ResponseJson<Map<String, Object>> getPageData(Integer pageId, Integer userId, Integer source) {
+        return pageService.getPageData(pageId, userId, source);
+    }
+
+    /**
+     * 楼层详情
+     *
+     * @param floorId 楼层id
+     * @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小程序")
+    })
+    @GetMapping("/page/floor/details")
+    public ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source) {
+        return pageService.getPageFloorData(floorId, userId, source);
+    }
+
+    /**
+     * 分页详情楼层详情
+     *
+     * @param centreId 分页详情楼层id
+     * @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小程序")
+    })
+    @GetMapping("/page/floor/centre")
+    public ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source) {
+        return pageService.getPageCentreData(centreId, userId, source);
+    }
+
     /**
      * 商品详情页
      *
@@ -170,13 +237,4 @@ public class ProductPageApi {
         return pageService.getProductDetailRecommends(productId, recommendType, userId);
     }
 
-
-
-
-
-
-
-
-
-
 }

+ 83 - 37
src/main/java/com/caimei365/commodity/controller/SearchIndexApi.java

@@ -1,9 +1,9 @@
 package com.caimei365.commodity.controller;
 
 import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.dto.UpdateIndexDto;
 import com.caimei365.commodity.service.SearchIndexService;
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -89,120 +89,166 @@ public class SearchIndexApi {
      * 根据商品Id更新
      *
      * spi旧接口:/search/manage/update/product
-     * @param productId 商品Id
+     *
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      * @return int
      */
     @ApiOperation("根据商品Id更新")
-    @ApiImplicitParam(required = true, name = "productId", value = "商品Id(旧:pid)")
     @PostMapping("/update/product")
-    public ResponseJson<Integer> updateProductIndex(Integer productId){
-        return searchIndexService.updateProductIndexById(productId);
+    public ResponseJson<Integer> updateProductIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.updateProductIndexById(updateIndexDto.getProductId());
     }
 
     /**
      * 根据供应商Id更新
      *
      * spi旧接口:/search/manage/update/supplier
-     * @param shopId 供应商Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      * @return int
      */
     @ApiOperation("根据供应商Id更新")
-    @ApiImplicitParam(required = true, name = "shopId", value = "供应商Id(旧:sid)")
     @PostMapping("/update/shop")
-    public ResponseJson<Integer> updateSupplierIndex(Integer shopId){
-        return searchIndexService.updateSupplierIndexById(shopId);
+    public ResponseJson<Integer> updateSupplierIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.updateSupplierIndexById(updateIndexDto.getShopId());
     }
 
     /**
      * 根据项目仪器Id更新
      *
      * spi旧接口:/search/manage/update/equipment
-     * @param equipmentId 仪器Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      * @return int
      */
     @ApiOperation("根据仪器Id更新")
-    @ApiImplicitParam(required = true, name = "equipmentId", value = "仪器Id(旧:eid)")
     @PostMapping("/update/equipment")
-    public ResponseJson<Integer> updateEquipmentIndex(Integer equipmentId){
-        return searchIndexService.updateEquipmentIndexById(equipmentId);
+    public ResponseJson<Integer> updateEquipmentIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.updateEquipmentIndexById(updateIndexDto.getEquipmentId());
     }
 
     /**
      * 根据文章Id更新
      *
      * spi旧接口:/search/manage/update/article
-     * @param articleId 文章Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      * @return int
      */
     @ApiOperation("根据文章Id更新")
-    @ApiImplicitParam(required = true, name = "articleId", value = "文章Id(旧:aid)")
     @PostMapping("/update/article")
-    public ResponseJson<Integer> updateArticleIndex(Integer articleId){
-        return searchIndexService.updateArticleIndexById(articleId);
+    public ResponseJson<Integer> updateArticleIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.updateArticleIndexById(updateIndexDto.getArticleId());
     }
 
     /**
      * 根据商品Id删除
      *
      * spi旧接口:/search/manage/delete/product
-     * @param productId 商品Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      */
     @ApiOperation("根据商品Id删除")
-    @ApiImplicitParam(required = true, name = "productId", value = "商品Id(旧:pid)")
     @PostMapping("/delete/product")
-    public ResponseJson<Integer> deleteProductIndex(Integer productId){
-        return searchIndexService.deleteProductIndexById(productId);
+    public ResponseJson<Integer> deleteProductIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.deleteProductIndexById(updateIndexDto.getProductId());
     }
 
     /**
      * 根据供应商Id删除
      *
      * spi旧接口:/search/manage/delete/supplier
-     * @param shopId 供应商Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      */
     @ApiOperation("根据供应商Id删除")
-    @ApiImplicitParam(required = true, name = "shopId", value = "供应商Id(旧:sid)")
     @PostMapping("/delete/shop")
-    public ResponseJson<Integer> deleteSupplierIndex(Integer shopId){
-        return searchIndexService.deleteSupplierIndexById(shopId);
+    public ResponseJson<Integer> deleteSupplierIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.deleteSupplierIndexById(updateIndexDto.getShopId());
     }
 
     /**
      * 根据项目仪器Id删除
      *
      * spi旧接口:/search/manage/delete/equipment
-     * @param equipmentId 仪器Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      */
     @ApiOperation("根据项目仪器Id删除")
-    @ApiImplicitParam(required = true, name = "equipmentId", value = "仪器Id(旧:eid)")
     @PostMapping("/delete/equipment")
-    public ResponseJson<Integer> deleteEquipmentIndex(Integer equipmentId){
-        return searchIndexService.deleteEquipmentIndexById(equipmentId);
+    public ResponseJson<Integer> deleteEquipmentIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.deleteEquipmentIndexById(updateIndexDto.getEquipmentId());
     }
 
     /**
      * 根据文章Id删除
      *
      * spi旧接口:/search/manage/delete/article
-     * @param articleId 文章Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      */
     @ApiOperation("根据文章Id删除")
-    @ApiImplicitParam(required = true, name = "articleId", value = "文章Id(旧:aid)")
     @PostMapping("/delete/article")
-    public ResponseJson<Integer> deleteArticleIndex(Integer articleId){
-        return searchIndexService.deleteArticleIndexById(articleId);
+    public ResponseJson<Integer> deleteArticleIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.deleteArticleIndexById(updateIndexDto.getArticleId());
     }
 
     /**
      * 根据主文档Id删除
      *
      * spi旧接口:/search/manage/delete/main
-     * @param id 文档Id
+     * @param updateIndexDto {
+     *                          id           主键id
+     *                          productId    商品Id
+     *                          shopId       供应商Id
+     *                          equipmentId  项目仪器id
+     *                          articleId    文章id
+     *                    }
      */
     @ApiOperation("根据主文档Id删除")
-    @ApiImplicitParam(required = true, name = "id", value = "文档Id")
     @PostMapping("/delete/main")
-    public ResponseJson<Integer> deleteMainIndex(Integer id){
-        return searchIndexService.deleteMainIndexById(id);
+    public ResponseJson<Integer> deleteMainIndex(UpdateIndexDto updateIndexDto){
+        return searchIndexService.deleteMainIndexById(updateIndexDto.getId());
     }
 }

+ 26 - 0
src/main/java/com/caimei365/commodity/mapper/PageMapper.java

@@ -3,6 +3,7 @@ package com.caimei365.commodity.mapper;
 import com.caimei365.commodity.model.search.ProductListVo;
 import com.caimei365.commodity.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -97,4 +98,29 @@ public interface PageMapper {
      */
     List<ProductListVo> getProductRecommendsById(Integer productId);
     List<ProductListVo> getAutoProductRecommends(Integer productId);
+    /** 页面数据 */
+    CmPageVo findCmPageById(Integer pageId);
+    /**
+     * 获取搜索热门关键字
+     */
+    List<String> getSearchKeyword();
+
+    /**
+     * 获取头部菜单
+     */
+    List<TopMenuVo> getTopMenus(Integer source);
+    /**
+     * 获取底部链接分类
+     */
+    List<BaseLinkVo> getHelpPageTypes();
+
+    /**
+     * 根据分类获取底部链接
+     */
+    List<BaseLinkVo> getHelpPagesByType(@Param("typeId") Integer typeId);
+
+    /**
+     * 获取友情链接
+     */
+    List<BaseLinkVo> getFriendLinks();
 }

+ 1 - 1
src/main/java/com/caimei365/commodity/mapper/PriceMapper.java

@@ -31,7 +31,7 @@ public interface PriceMapper {
     /**
      * 根据商品ID查询阶梯价列表
      */
-    List<LadderPriceVo> getladderPricesByProductId(Integer productId);
+    List<LadderPriceVo> getLadderPricesByProductId(Integer productId);
     /**
      * 获取最低阶梯价(价格最低,阶梯数最大)
      */

+ 4 - 0
src/main/java/com/caimei365/commodity/mapper/ShopMapper.java

@@ -143,4 +143,8 @@ public interface ShopMapper {
      * 供应商-下架商品
      */
     void updateProductValidFlag(Integer productId, Integer validFlag);
+    /**
+     * 供应商-更新商品编码
+     */
+    void updateProductCode(String productCode, Integer productId);
 }

+ 42 - 0
src/main/java/com/caimei365/commodity/model/dto/UpdateIndexDto.java

@@ -0,0 +1,42 @@
+package com.caimei365.commodity.model.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/5/26
+ */
+@Data
+public class UpdateIndexDto implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 主键id
+     */
+    @ApiModelProperty("主键id")
+    private Integer id;
+    /**
+     * 商品id
+     */
+    @ApiModelProperty("商品id")
+    private Integer productId;
+    /**
+     * 供应商id
+     */
+    @ApiModelProperty("供应商id")
+    private Integer shopId;
+    /**
+     * 项目仪器id
+     */
+    @ApiModelProperty("项目仪器id")
+    private Integer equipmentId;
+    /**
+     * 文章id
+     */
+    @ApiModelProperty("文章id")
+    private Integer articleId;
+}

+ 23 - 0
src/main/java/com/caimei365/commodity/model/vo/BaseLinkVo.java

@@ -0,0 +1,23 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/5/27
+ */
+@Data
+public class BaseLinkVo implements Serializable{
+    private static final long serialVersionUID = 1L;
+	private Integer id;
+	private Integer typeId;
+	private String name;
+	private String link;
+	private Double sort;
+	private List<BaseLinkVo> linkList;
+}

+ 58 - 0
src/main/java/com/caimei365/commodity/model/vo/CmPageVo.java

@@ -0,0 +1,58 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/5/19
+ */
+@Data
+public class CmPageVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private Integer id;
+    /**
+     * 类型:1二级列表 2项目详情 3讲师列表 4自由页面 5分页详情
+     */
+    private Integer type;
+    /**
+     * 标题
+     */
+    private String title;
+    /**
+     * seo关键词
+     */
+    private String keywords;
+    /**
+     * 描述
+     */
+    private String description;
+    /**
+     * 首部图片
+     */
+    private String headImage;
+    /**
+     * crm首部图片
+     */
+    private String crmHeadImage;
+    /**
+     * 首层大图链接
+     */
+    private String headLink;
+    /**
+     * 首部文字
+     */
+    private String headText;
+    /**
+     * 轮播图链接类型
+     */
+    private Integer linkType;
+    /**
+     * 链接包含的参数
+     */
+    private Map<String, Object> linkParam;
+}

+ 5 - 0
src/main/java/com/caimei365/commodity/model/vo/FloorImageVo.java

@@ -48,6 +48,11 @@ public class FloorImageVo implements Serializable {
      */
     private String image;
 
+    /**
+     * 小程序图片
+     */
+    private String appletsImage;
+
     /**
      * 标签
      */

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

@@ -28,6 +28,7 @@ public class ImageLinkVo implements Serializable {
 	/** 小程序图片 */
 	private String crmImage;
 	private String image;
+	private String appletsImage;
 	/** 活动开始时间 */
 	private Date beginTime;
 	/** 活动开始时间 */

+ 4 - 0
src/main/java/com/caimei365/commodity/model/vo/ProductDetailVo.java

@@ -95,6 +95,10 @@ public class ProductDetailVo implements Serializable {
      * 启用阶梯价格标识 0否 1是
      */
     private Integer ladderPriceFlag;
+    /**
+     * 阶梯价格列表
+     */
+    private List<LadderPriceVo> ladderPriceList;
     /**
      * 成本价
      */

+ 56 - 0
src/main/java/com/caimei365/commodity/model/vo/TopMenuVo.java

@@ -0,0 +1,56 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/5/27
+ */
+@Data
+public class TopMenuVo implements Serializable {
+    private Integer id;
+
+    /**
+     * 菜单名称
+     */
+    private String name;
+
+    /**
+     * 一级导航栏类型 0启用二级导航跳转 1启用链接跳转(已废弃)
+     */
+    private String type;
+
+    /**
+     * 跳转链接
+     */
+    private String link;
+
+    /**
+     * 图标
+     */
+    private String icon;
+
+    /**
+     * 排序
+     */
+    private String sort;
+
+    /**
+     * 链接类型 -1未知类型 1二级页面 2项目仪器 3直播页面 4自由页面 5商品详情 6项目仪器详情
+     * 7供应商主页 8专题活动页 9二手市场介绍 10二手商品列表 11二手商品发布 12商品搜索 13信息详情
+     * 14品牌招商介绍页 15维修保养介绍页 16首页 17注册页 18信息中心 19供应商列表
+     */
+    private Integer linkType;
+
+    /**
+     * 链接包含的参数
+     */
+    private Map<String, Object> linkParam;
+
+    private static final long serialVersionUID = 1L;
+}

+ 34 - 0
src/main/java/com/caimei365/commodity/service/PageService.java

@@ -40,6 +40,39 @@ public interface PageService {
      */
     ResponseJson<Map<String, Object>> getHomeData(Integer userId, Integer source);
 
+    /**
+     * 首页基础数据(小程序)
+     * @param source 来源 : 1 网站 ; 2 小程序
+     */
+    ResponseJson<Map<String, Object>> getHomeInit(Integer source);
+
+    /**
+     * 活动专题楼层数据(美博会)
+     *
+     * @param pageId 页面id
+     * @param userId 用户id
+     * @param source 来源 : 1 网站 ; 2 小程序
+     */
+    ResponseJson<Map<String, Object>> getPageData(Integer pageId, Integer userId, Integer source);
+
+    /**
+     * 楼层详情
+     *
+     * @param floorId 楼层id
+     * @param userId 用户id
+     * @param source 来源 : 1 网站 ; 2 小程序
+     */
+    ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source);
+
+    /**
+     * 分页详情楼层详情
+     *
+     * @param centreId 分页详情楼层id
+     * @param userId 用户id
+     * @param source 来源 : 1 网站 ; 2 小程序
+     */
+    ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source);
+
     /**
      * 商品详情页
      *
@@ -83,4 +116,5 @@ public interface PageService {
      * @param userId    用户Id
      */
     ResponseJson<List<ProductListVo>> getProductDetailRecommends(Integer productId, Integer recommendType, Integer userId);
+
 }

+ 136 - 0
src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java

@@ -25,6 +25,7 @@ import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * Description
@@ -158,6 +159,132 @@ public class PageServiceImpl implements PageService {
         return ResponseJson.success(map);
     }
 
+    /**
+     * 首页基础数据(小程序)
+     * @param source 来源 : 1 网站 ; 2 小程序
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> getHomeInit(Integer source) {
+        Map<String, Object> map = new HashMap<>(4);
+        // 搜索热门关键字
+        List<String> searchHotWord = pageMapper.getSearchKeyword();
+        if (!CollectionUtils.isEmpty(searchHotWord) && searchHotWord.size() > 8) {
+            searchHotWord.parallelStream()
+                    .filter(str -> !StringUtils.isEmpty(str)).limit(8)
+                    .collect(Collectors.toList());
+        }
+        map.put("searchHotWord", searchHotWord);
+        // 头部菜单
+        List<TopMenuVo> menuList = pageMapper.getTopMenus(source);
+        menuList.forEach(item -> {
+            String link = item.getLink();
+            if (StringUtils.isNotBlank(link)) {
+                if (source == 1) {
+                    if (link.contains("?")) {
+                        link = link + "&name=" + item.getName();
+                    } else {
+                        link = link + "?name=" + item.getName();
+                    }
+                }
+                item.setLinkType(AppletsLinkUtil.getLinkType(link));
+                item.setLinkParam(AppletsLinkUtil.getLinkParam(item.getLinkType(), link));
+                item.setLink(link);
+            }
+        });
+        map.put("topMenuList", menuList);
+        // 底部帮助页
+        List<BaseLinkVo> helpPages = pageMapper.getHelpPageTypes();
+        helpPages.forEach(item -> {
+            List<BaseLinkVo> pageList = pageMapper.getHelpPagesByType(item.getId());
+            item.setLinkList(pageList);
+        });
+        map.put("helpPages", helpPages);
+        // 友情链接
+        List<BaseLinkVo> friendLinks = pageMapper.getFriendLinks();
+        map.put("friendLinks", friendLinks);
+        return ResponseJson.success(map);
+    }
+
+    /**
+     * 活动专题楼层数据(美博会)
+     *
+     * @param pageId 页面id
+     * @param userId 用户id
+     * @param source 来源 : 1 网站 ; 2 小程序
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> getPageData(Integer pageId, Integer userId, Integer source) {
+        if (pageId == null) {
+            return ResponseJson.error("参数异常: 页面id不能为空!", null);
+        }
+        source = source == null ? 1 : source;
+        // 页面数据
+        CmPageVo page = pageMapper.findCmPageById(pageId);
+        //轮播图设置链接类型
+        if (StringUtils.isNotBlank(page.getHeadLink())) {
+            Integer linkType = AppletsLinkUtil.getLinkType(page.getHeadLink());
+            page.setLinkType(linkType);
+            page.setLinkParam(AppletsLinkUtil.getLinkParam(linkType,page.getHeadLink()));
+        }
+        List<PageFloorVo> floorList = pageMapper.getFloorByPageId(pageId, source);
+        for (PageFloorVo floor : floorList) {
+            FloorContentVo floorContent = pageMapper.getFloorContentByCentreId(floor.getId());
+            setFloorLinkType(floorContent);
+            floor.setFloorContent(floorContent);
+            List<FloorImageVo> floorImageList = pageMapper.getFloorImageByCentreId(floor.getId(), source);
+            setFloorImageProduct(userId, floorImageList);
+            floor.setFloorImageList(floorImageList);
+        }
+        Map<String, Object> map = new HashMap<>(2);
+        map.put("page", page);
+        map.put("floorList", floorList);
+        return ResponseJson.success(map);
+    }
+
+    /**
+     * 楼层详情
+     *
+     * @param floorId 楼层id
+     * @param userId  用户id
+     * @param source  来源 : 1 网站 ; 2 小程序
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> getPageFloorData(Integer floorId, Integer userId, Integer source) {
+        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);
+        Map<String, Object> map = new HashMap<>(2);
+        map.put("floorContent", floorContent);
+        map.put("floorImageList", floorImageList);
+        return ResponseJson.success(map);
+    }
+
+    /**
+     * 分页详情楼层详情
+     *
+     * @param centreId 分页详情楼层id
+     * @param userId   用户id
+     * @param source   来源 : 1 网站 ; 2 小程序
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> getPageCentreData(Integer centreId, Integer userId, Integer source) {
+        if (centreId == null) {
+            return ResponseJson.error("参数异常: 分页详情楼层id不能为空!", null);
+        }
+        FloorContentVo floorContent = pageMapper.getFloorContentByCentreId(centreId);
+        setFloorLinkType(floorContent);
+        List<FloorImageVo> floorImageList = pageMapper.getFloorImageByCentreId(centreId, source);
+        setFloorImageProduct(userId, floorImageList);
+        Map<String, Object> map = new HashMap<>(2);
+        map.put("floorContent", floorContent);
+        map.put("floorImageList", floorImageList);
+        return ResponseJson.success(map);
+    }
+
     /**
      * 商品详情页
      *
@@ -264,6 +391,15 @@ public class PageServiceImpl implements PageService {
             product.setUserIdentity(price.getUserIdentity());
             product.setRepurchaseFlag(price.getRepurchaseFlag());
             product.setMaxBuyNumber(price.getMaxBuyNumber());
+            // 设置阶梯价格详情
+            if (1 == price.getLadderPriceFlag()) {
+                List<LadderPriceVo> ladderPrices = priceMapper.getLadderPricesByProductId(product.getProductId());
+                TaxVo tax = priceMapper.getTaxByProductId(product.getProductId());
+                if (!CollectionUtils.isEmpty(ladderPrices)) {
+                    priceUtilService.setLadderPriceList(ladderPrices, tax);
+                }
+                product.setLadderPriceList(ladderPrices);
+            }
         }
         return ResponseJson.success(product);
     }

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

@@ -86,7 +86,7 @@ public class PriceServiceImpl implements PriceService {
      */
     @Override
     public ResponseJson<List<LadderPriceVo>> getLadderPrice(Integer productId) {
-        List<LadderPriceVo> ladderPrices = priceMapper.getladderPricesByProductId(productId);
+        List<LadderPriceVo> ladderPrices = priceMapper.getLadderPricesByProductId(productId);
         TaxVo tax = priceMapper.getTaxByProductId(productId);
         if (!CollectionUtils.isEmpty(ladderPrices)) {
             priceUtilService.setLadderPriceList(ladderPrices, tax);

+ 168 - 61
src/main/java/com/caimei365/commodity/service/impl/SearchIndexServiceImpl.java

@@ -193,16 +193,20 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      */
     @Override
     public ResponseJson<Integer> updateProductIndexById(Integer productId){
+        if (null == productId) {
+            log.info(">>>更新商品,商品Id不能为空!");
+            return ResponseJson.error("商品Id不能为空", null);
+        }
         ProductDO product = searchMapper.searchProductById(productId);
         if (null != product) {
             // 定义星范商品数据
             List<DocumentDTO<MallProductDO>> mallProductList = new ArrayList<>();
-            // 星范商品设值,【必须先于商品文档设值】
-            Integer mallId = setMallProductDocument(mallProductList, productId);
+//            // 星范商品设值,【必须先于商品文档设值】
+//            Integer mallId = setMallProductDocument(mallProductList, productId);
             // 定义商品文档数据
             List<DocumentDTO<ProductDO>> productList = new ArrayList<>();
             // 商品文档设值
-            setProductDocument(productList, product, mallId);
+            setProductDocument(productList, product, null);
             // 定义主文档入口数据
             List<DocumentDTO<MainDO>> mainList = new ArrayList<>();
             // 主文档设值
@@ -210,14 +214,23 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             if (mainId == -1) {
                 mainId = searchQueryService.getIdByDocId("", null);
                 mainId = mainId == -1 ? 0 : mainId+1;
+                //  新增主文档, 商品:type=1
+                setMainDocument(1, mainList, mainId, productId);
             }
-            // 商品文档 type=1
-            setMainDocument(1, mainList, mainId, productId);
             try {
-                // 推送到阿里云
-                pushProductDocument(mainList, productList, mallProductList);
-                // 返回结果
-                return ResponseJson.success(mainList.size());
+                // 查询商品数量是否唯一,不唯一则删除后更新索引
+                Integer count = searchQueryService.getCountByDocId("product", productId);
+                if (count > 1) {
+                    log.info("商品重复,重复商品>>>>>>>>>>>" + productId +"重复数量:" + count);
+                    // 删除主文档记录
+                    deleteDocByTypeId("id", mainId, "search_main");
+                    return updateProductIndexById(productId);
+                } else {
+                    // 推送到阿里云
+                    pushProductDocument(mainList, productList, mallProductList);
+                    // 返回结果
+                    return ResponseJson.success(mainList.size());
+                }
             } catch (OpenSearchClientException | OpenSearchException | JSONException e) {
                 log.error("添加商品文档异常:" + e);
                 return ResponseJson.error("添加商品文档异常", null);
@@ -235,6 +248,10 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      */
     @Override
     public ResponseJson<Integer> updateSupplierIndexById(Integer shopId) {
+        if (null == shopId) {
+            log.info(">>>更新供应商,供应商Id不能为空!");
+            return ResponseJson.error("供应商Id不能为空", null);
+        }
         SupplierDO supplier = searchMapper.searchSupplierById(shopId);
         if(null != supplier){
              // 定义供应商文档数据
@@ -248,14 +265,23 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             if (mainId == -1) {
                 mainId = searchQueryService.getIdByDocId("", null);
                 mainId = mainId == -1 ? 0 : mainId+1;
+                //  新增主文档, 供应商:type=2
+                setMainDocument(2, mainList, mainId, shopId);
             }
-            // 供应商文档 type=2
-            setMainDocument(2, mainList, mainId, shopId);
             try {
-                // 将文档列表转换成Json串,并推送到阿里云
-                pushSupplierDocument(mainList, supplierList);
-                // 返回结果
-                return ResponseJson.success(mainList.size());
+                // 查询供应商是否唯一,不唯一则删除后重新更新索引
+                Integer count = searchQueryService.getCountByDocId("shop", shopId);
+                if (count > 1) {
+                    log.info("供应商重复,重复供应商>>>>>>>>>>>" + shopId +"重复数量:" + count);;
+                    // 删除主文档记录
+                    deleteDocByTypeId("id", mainId, "search_main");
+                    return updateSupplierIndexById(shopId);
+                } else {
+                    // 将文档列表转换成Json串,并推送到阿里云
+                    pushSupplierDocument(mainList, supplierList);
+                    // 返回结果
+                    return ResponseJson.success(mainList.size());
+                }
             } catch (OpenSearchClientException | OpenSearchException | JSONException e) {
                 log.error("添加供应商文档异常:" + e);
                 return ResponseJson.error("添加供应商文档异常", null);
@@ -273,6 +299,10 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      */
     @Override
     public ResponseJson<Integer> updateEquipmentIndexById(Integer equipmentId) {
+        if (null == equipmentId) {
+            log.info(">>>更新项目仪器,项目仪器Id不能为空!");
+            return ResponseJson.error("项目仪器Id不能为空", null);
+        }
         EquipmentDO equipment = searchMapper.searchEquipmentById(equipmentId);
         if(null != equipment){
             // 定义项目仪器文档数据
@@ -286,14 +316,23 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             if (mainId == -1) {
                 mainId = searchQueryService.getIdByDocId("", null);
                 mainId = mainId == -1 ? 0 : mainId+1;
+                // 新增主文档, 项目仪器:type=3
+                setMainDocument(3, mainList, mainId, equipmentId);
             }
-            // 项目仪器文档 type=3
-            setMainDocument(3, mainList, mainId, equipmentId);
             try {
-                // 将文档列表转换成Json串,并推送到阿里云
-                pushEquipmentDocument(mainList, equipmentList);
-                // 返回结果
-                return ResponseJson.success(mainList.size());
+                // 查询项目仪器数量是否唯一,不唯一则删除后重新更新索引
+                Integer count = searchQueryService.getCountByDocId("equipment", equipmentId);
+                if (count > 1) {
+                    log.info("项目仪器重复,重复项目仪器>>>>>>>>>>>" + equipmentId+"重复数量:" + count);
+                    // 删除主文档记录
+                    deleteDocByTypeId("id", mainId, "search_main");
+                    return updateEquipmentIndexById(equipmentId);
+                } else {
+                    // 将文档列表转换成Json串,并推送到阿里云
+                    pushEquipmentDocument(mainList, equipmentList);
+                    // 返回结果
+                    return ResponseJson.success(mainList.size());
+                }
             } catch (OpenSearchClientException | OpenSearchException | JSONException e) {
                 log.error("添加项目仪器文档异常:" + e);
                 return ResponseJson.error("添加项目仪器文档异常", null);
@@ -311,6 +350,10 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      */
     @Override
     public ResponseJson<Integer> updateArticleIndexById(Integer articleId) {
+        if (null == articleId) {
+            log.info(">>>更新文章,文章Id不能为空!");
+            return ResponseJson.error("文章Id不能为空", null);
+        }
         ArticleDO article = searchMapper.searchArticleById(articleId);
         if(null != article){
             // 定义文章文档数据
@@ -324,21 +367,24 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             if (mainId == -1) {
                 mainId = searchQueryService.getIdByDocId("", null);
                 mainId = mainId == -1 ? 0 : mainId+1;
+                // 新增主文档, 文章 type=4
+                setMainDocument(4, mainList, mainId, articleId);
             }
-            // 文章文档 type=4
-            setMainDocument(4, mainList, mainId, articleId);
+
             try {
-                // 将主文档列表转换成Json串,并推送到阿里云
-                pushArticleDocument(mainList, articleList);
                 // 查询文章数量是否唯一,不唯一则删除后重新更新索引
                 Integer count = searchQueryService.getCountByDocId("article", articleId);
                 if (count > 1) {
-                    log.info("文章重复,重复文章id>>>>>>>>>>>" + articleId);
-                    deleteArticleIndexById(articleId);
-                    updateArticleIndexById(articleId);
+                    log.info("文章重复,重复文章>>>>>>>>>>>" + articleId +"重复数量:" + count);
+                    // 删除主文档记录
+                    deleteDocByTypeId("id", mainId, "search_main");
+                    return updateArticleIndexById(articleId);
+                } else {
+                    // 将主文档列表转换成Json串,并推送到阿里云
+                    pushArticleDocument(mainList, articleList);
+                    // 返回结果
+                    return ResponseJson.success(articleList.size());
                 }
-                // 返回结果
-                return ResponseJson.success(mainList.size());
             } catch (OpenSearchClientException | OpenSearchException | JSONException e) {
                 log.error("添加文章文档异常:" + e);
                 return ResponseJson.error("添加文章文档异常", null);
@@ -364,6 +410,9 @@ public class SearchIndexServiceImpl implements SearchIndexService {
                 deleteDocByTypeId("m_id", mallId, "search_product_mall");
             }
             deleteDocByTypeId("p_id", productId, "search_product");
+            // 删除主文档记录
+            Integer mainId = searchQueryService.getIdByDocId("product", productId);
+            deleteDocByTypeId("id", mainId, "search_main");
             // 返回结果
             return ResponseJson.success(1);
         } catch (OpenSearchClientException | OpenSearchException | JSONException e) {
@@ -382,6 +431,9 @@ public class SearchIndexServiceImpl implements SearchIndexService {
     public ResponseJson<Integer> deleteSupplierIndexById(Integer shopId) {
         try {
             deleteDocByTypeId("s_id", shopId, "search_supplier");
+            // 删除主文档记录
+            Integer mainId = searchQueryService.getIdByDocId("shop", shopId);
+            deleteDocByTypeId("id", mainId, "search_main");
             // 返回结果
             return ResponseJson.success(1);
         } catch (OpenSearchClientException | OpenSearchException | JSONException e) {
@@ -400,6 +452,9 @@ public class SearchIndexServiceImpl implements SearchIndexService {
     public ResponseJson<Integer> deleteEquipmentIndexById(Integer equipmentId) {
         try {
             deleteDocByTypeId("e_id", equipmentId, "search_equipment");
+            // 删除主文档记录
+            Integer mainId = searchQueryService.getIdByDocId("equipment", equipmentId);
+            deleteDocByTypeId("id", mainId, "search_main");
             // 返回结果
             return ResponseJson.success(1);
         } catch (OpenSearchClientException | OpenSearchException | JSONException e) {
@@ -417,7 +472,11 @@ public class SearchIndexServiceImpl implements SearchIndexService {
     @Override
     public ResponseJson<Integer> deleteArticleIndexById(Integer articleId) {
         try {
+            // 删除文章文档记录
             deleteDocByTypeId("a_id", articleId, "search_article");
+            // 删除主文档记录
+            Integer mainId = searchQueryService.getIdByDocId("article", articleId);
+            deleteDocByTypeId("id", mainId, "search_main");
             // 返回结果
             return ResponseJson.success(1);
         } catch (OpenSearchClientException | OpenSearchException | JSONException e) {
@@ -488,9 +547,13 @@ public class SearchIndexServiceImpl implements SearchIndexService {
                     deleteDoc.put("m_id", mallId);
                 }
             }
-            for (Integer productId : invalidIds) {
+            for (Integer invalidId : invalidIds) {
                 // 根据ID(主键)删除文档
-                deleteDoc.put("p_id", productId);
+                deleteDoc.put("p_id", invalidId);
+                Integer mainId = searchQueryService.getIdByDocId("product", invalidId);
+                if (mainId > -1){
+                    deleteDoc.put("id", mainId);
+                }
             }
             try {
                 String deleteJsonStr = setDeleteDocument(deleteDoc);
@@ -537,10 +600,10 @@ public class SearchIndexServiceImpl implements SearchIndexService {
 
             int productMainId;
             for (ProductDO product : dbList) {
-                // 星范商品设值,【必须先于商品文档设值】
-                Integer mallId = setMallProductDocument(mallProductList, product.getP_id());
+//                // 星范商品设值,【必须先于商品文档设值】
+//                Integer mallId = setMallProductDocument(mallProductList, product.getP_id());
                 // 商品文档设值
-                setProductDocument(productList, product, mallId);
+                setProductDocument(productList, product, null);
                 // 主文档设值
                 Integer productId = product.getP_id();
                 if(initFlag){
@@ -583,14 +646,22 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      * @throws OpenSearchException exp
      */
     private void pushProductDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<ProductDO>> productList, List<DocumentDTO<MallProductDO>> mallProductList) throws OpenSearchClientException, OpenSearchException {
-        // 将主文档列表转换成Json串,并推送到阿里云
-        String mainDocStr = new JSONArray(mainList).toString();
-        String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "):" + mainResult + "】" + mainList.toString());
+        if (mainList.size()>0) {
+            // 将主文档列表转换成Json串,并推送到阿里云
+            String mainDocStr = new JSONArray(mainList).toString();
+            String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
+            log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "个):" + mainResult + "】" + mainList.toString());
+        }
         // 将商品文档推送到阿里云
         String productDocStr = new JSONArray(productList).toString();
         String productResult = searchOpenService.pushDocument(productDocStr, "search_product");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_product(" + productList.size() + "):" + productResult + "】");
+        if (mainList.size()>0) {
+            // 新增
+            log.info(">>>>>>>>>>>>>>>add document: 【search_product(" + productList.size() + "个):" + productResult + "】");
+        } else {
+            // 更新
+            log.info(">>>>>>>>>>>>>>>update document: 【search_product(" + productList.size() + "个):" + productResult + "】");
+        }
         // 将星范商品推送到阿里云
         if (mallProductList.size()>0) {
             String mallProductStr = new JSONArray(mallProductList).toString();
@@ -613,9 +684,13 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             List<Integer> invalidIds = searchMapper.findSupplierInvalidIds();
             // 删除文档只需要设置需删除文档主键值即可
             Map<String, Object> deleteDoc = Maps.newLinkedHashMap();
-            for (Integer productId : invalidIds) {
+            for (Integer invalidId : invalidIds) {
                 // 根据ID(主键)删除文档
-                deleteDoc.put("s_id", productId);
+                deleteDoc.put("s_id", invalidId);
+                Integer mainId = searchQueryService.getIdByDocId("shop", invalidId);
+                if (mainId > -1){
+                    deleteDoc.put("id", mainId);
+                }
             }
             try {
                 String deleteJsonStr = setDeleteDocument(deleteDoc);
@@ -703,14 +778,22 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      * @throws OpenSearchException exp
      */
     private void pushSupplierDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<SupplierDO>> supplierList) throws OpenSearchClientException, OpenSearchException {
-        // 将主文档列表转换成Json串,并推送到阿里云
-        String mainDocStr = new JSONArray(mainList).toString();
-        String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "):" + mainResult + "】" + mainList.toString());
+        if (mainList.size()>0) {
+            // 将主文档列表转换成Json串,并推送到阿里云
+            String mainDocStr = new JSONArray(mainList).toString();
+            String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
+            log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "个):" + mainResult + "】" + mainList.toString());
+        }
         // 将商品文档推送到阿里云
         String supplierDocStr = new JSONArray(supplierList).toString();
         String supplierResult = searchOpenService.pushDocument(supplierDocStr, "search_supplier");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_supplier(" + supplierList.size() + "):" + supplierResult + "】");
+        if (mainList.size()>0) {
+            // 新增
+            log.info(">>>>>>>>>>>>>>>add document: 【search_supplier(" + supplierList.size() + "个):" + supplierResult + "】");
+        } else {
+            // 更新
+            log.info(">>>>>>>>>>>>>>>update document: 【search_supplier(" + supplierList.size() + "个):" + supplierResult + "】");
+        }
     }
 
     /**
@@ -727,9 +810,13 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             List<Integer> invalidIds = searchMapper.findEquipmentInvalidIds();
             // 删除文档只需要设置需删除文档主键值即可
             Map<String, Object> deleteDoc = Maps.newLinkedHashMap();
-            for (Integer productId : invalidIds) {
+            for (Integer invalidId : invalidIds) {
                 // 根据ID(主键)删除文档
-                deleteDoc.put("e_id", productId);
+                deleteDoc.put("e_id", invalidId);
+                Integer mainId = searchQueryService.getIdByDocId("equipment", invalidId);
+                if (mainId > -1){
+                    deleteDoc.put("id", mainId);
+                }
             }
             try {
                 String deleteJsonStr = setDeleteDocument(deleteDoc);
@@ -817,14 +904,22 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      * @throws OpenSearchException exp
      */
     private void pushEquipmentDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<EquipmentDO>> equipmentList) throws OpenSearchClientException, OpenSearchException {
-        // 将主文档列表转换成Json串,并推送到阿里云
-        String mainDocStr = new JSONArray(mainList).toString();
-        String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "):" + mainResult + "】" + mainList.toString());
+        if (mainList.size()>0) {
+            // 将主文档列表转换成Json串,并推送到阿里云
+            String mainDocStr = new JSONArray(mainList).toString();
+            String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
+            log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "个):" + mainResult + "】" + mainList.toString());
+        }
         // 将商品文档推送到阿里云
         String equipmentDocStr = new JSONArray(equipmentList).toString();
         String equipmentResult = searchOpenService.pushDocument(equipmentDocStr, "search_equipment");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_equipment(" + equipmentList.size() + "):" + equipmentResult + "】");
+        if (mainList.size()>0) {
+            // 新增
+            log.info(">>>>>>>>>>>>>>>add document: 【search_equipment(" + equipmentList.size() + "个):" + equipmentResult + "】");
+        } else {
+            // 更新
+            log.info(">>>>>>>>>>>>>>>update document: 【search_equipment(" + equipmentList.size() + "个):" + equipmentResult + "】");
+        }
     }
 
     /**
@@ -841,9 +936,13 @@ public class SearchIndexServiceImpl implements SearchIndexService {
             List<Integer> invalidIds = searchMapper.findArticleInvalidIds();
             // 删除文档只需要设置需删除文档主键值即可
             Map<String, Object> deleteDoc = Maps.newLinkedHashMap();
-            for (Integer productId : invalidIds) {
+            for (Integer invalidId : invalidIds) {
                 // 根据ID(主键)删除文档
-                deleteDoc.put("a_id", productId);
+                deleteDoc.put("a_id", invalidId);
+                Integer mainId = searchQueryService.getIdByDocId("article", invalidId);
+                if (mainId > -1){
+                    deleteDoc.put("id", mainId);
+                }
             }
             try {
                 String deleteJsonStr = setDeleteDocument(deleteDoc);
@@ -931,14 +1030,22 @@ public class SearchIndexServiceImpl implements SearchIndexService {
      * @throws OpenSearchException exp
      */
     private void pushArticleDocument(List<DocumentDTO<MainDO>> mainList, List<DocumentDTO<ArticleDO>> articleList) throws OpenSearchClientException, OpenSearchException {
-        // 将主文档列表转换成Json串,并推送到阿里云
-        String mainDocStr = new JSONArray(mainList).toString();
-        String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "):" + mainResult + "】" + mainList.toString());
+        if (mainList.size()>0) {
+            // 将主文档列表转换成Json串,并推送到阿里云
+            String mainDocStr = new JSONArray(mainList).toString();
+            String mainResult = searchOpenService.pushDocument(mainDocStr, "search_main");
+            log.info(">>>>>>>>>>>>>>>add document: 【search_main(" + mainList.size() + "个):" + mainResult + "】" + mainList.toString());
+        }
         // 将商品文档推送到阿里云
         String articleDocStr = new JSONArray(articleList).toString();
         String articleResult = searchOpenService.pushDocument(articleDocStr, "search_article");
-        log.info(">>>>>>>>>>>>>>>add document: 【search_article(" + articleList.size() + "):" + articleResult + "】");
+        if (mainList.size()>0) {
+            // 新增
+            log.info(">>>>>>>>>>>>>>>add document: 【search_article(" + articleList.size() + "个):" + articleResult + "】");
+        } else {
+            // 更新
+            log.info(">>>>>>>>>>>>>>>update document: 【search_article(" + articleList.size() + "个):" + articleResult + "】");
+        }
     }
 
     /**

+ 33 - 10
src/main/java/com/caimei365/commodity/service/impl/SearchQueryServiceImpl.java

@@ -17,8 +17,10 @@ import com.caimei365.commodity.model.search.ProductListVo;
 import com.caimei365.commodity.model.search.ShopListVo;
 import com.caimei365.commodity.model.vo.*;
 import com.caimei365.commodity.service.SearchQueryService;
+import com.caimei365.commodity.utils.ImageUtils;
 import com.caimei365.commodity.utils.Json2PojoUtil;
 import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.util.StringUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
@@ -29,6 +31,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
 
 /**
  * Description
@@ -255,8 +258,8 @@ public class SearchQueryServiceImpl implements SearchQueryService {
         try {
             // 查询推送
             JSONObject result = searchOpenService.getResultJsonObject("count:"+docType, searchParams);
-            if (1 == result.getInt("status") && result.getJSONArray("items").length()>=0) {
-                return result.getJSONArray("items").length();
+            if (1 == result.getInt("status") && result.getInt("total")>=0) {
+                return result.getInt("total");
             } else {
                 return -1;
             }
@@ -326,6 +329,9 @@ public class SearchQueryServiceImpl implements SearchQueryService {
     @Override
     public ResponseJson<String> queryArticleByKeyword(String keyword, int pageNum, int pageSize) {
         String queryStr = "article:'" + keyword + "'";
+        if (StringUtils.isEmpty(keyword)) {
+            queryStr = "a_all:'1'";
+        }
         ArrayList<String> fetchFields = Lists.newArrayList("id", "a_id", "a_title", "a_image", "a_publisher", "a_publish_date", "a_intro", "a_pv", "a_type_id", "a_type_text", "a_label_ids", "a_label_text");
         List<Map<String, String>> summaryList = new ArrayList<>(2);
         Map<String, String> summaryField = new HashMap<>(2);
@@ -398,16 +404,16 @@ public class SearchQueryServiceImpl implements SearchQueryService {
      */
     @Override
     public ResponseJson<String> queryArticleByLabel(Integer id, int pageNum, int pageSize) {
-        String queryStr = "a_label:'" + id + "'";
-        ArrayList<String> fetchFields = Lists.newArrayList("id", "a_id", "a_title", "a_image", "a_publisher", "a_publish_date", "a_intro", "a_pv", "a_type_id", "a_type_text", "a_label_ids", "a_label_text");
-        // 阿里云搜索
-        ResponseJson<String> result = scrollArticleForParams(queryStr, fetchFields, pageNum, pageSize, "a_id", 1);
-        if (0 == result.getCode()) {
-            return result;
-        } else {
+//        String queryStr = "a_label:'" + id + "'";
+//        ArrayList<String> fetchFields = Lists.newArrayList("id", "a_id", "a_title", "a_image", "a_publisher", "a_publish_date", "a_intro", "a_pv", "a_type_id", "a_type_text", "a_label_ids", "a_label_text");
+//        // 阿里云搜索
+//        ResponseJson<String> result = scrollArticleForParams(queryStr, fetchFields, pageNum, pageSize, "a_id", 1);
+//        if (0 == result.getCode()) {
+//            return result;
+//        } else {
             // 阿里云搜索失败,再次从数据库搜索
             return queryArticleFromDatabase(pageNum, pageSize, null, null, null, id);
-        }
+//        }
     }
 
     /**
@@ -427,6 +433,23 @@ public class SearchQueryServiceImpl implements SearchQueryService {
         }
         PageHelper.startPage(num, size);
         List<ArticleListVo> articleList = searchMapper.queryArticle(keyword, articleId, typeId, labelText);
+        articleList.forEach(article -> {
+            String imagePath = ImageUtils.getImageURL("", article.getImage(), 0, domain);
+            article.setImage(imagePath);
+            // 搜索供应商文档数据
+            String[] labelTexts = article.getLabelText().split(",");
+            if(labelTexts.length > 0){
+                boolean notEmpty = StringUtil.isNotEmpty(labelTexts[0]);
+                if(notEmpty){
+                    List<Integer> labelIdList = searchMapper.findLabelIdsByName(labelTexts);
+                    StringBuilder labelIds = new StringBuilder();
+                    labelIdList.forEach(id -> {
+                        labelIds.append(",").append(id);
+                    });
+                    article.setLabelIds(labelIds.toString().replaceFirst(",",""));
+                }
+            }
+        });
         PaginationVo<ArticleListVo> pageData = new PaginationVo<>(articleList);
         int total = pageData.getTotalRecord();
         JSONObject pageObj = new JSONObject();

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

@@ -20,7 +20,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
@@ -274,12 +273,13 @@ public class ShopServiceImpl implements ShopService {
             product.setActFlag(0);
             product.setLadderPriceFlag(0);
             product.setVisibility(3);
+            shopMapper.insertProduct(product);
             if (StringUtils.isBlank(productDto.getProductCode())) {
                 String productCode = shopMapper.getCodeByTypeId(productDto.getBigTypeId(), productDto.getSmallTypeId(), productDto.getTinyTypeId());
                 productCode = productCode + product.getProductId();
                 product.setProductCode(productCode);
+                shopMapper.updateProductCode(productCode, product.getProductId());
             }
-            shopMapper.insertProduct(product);
         } else {
             shopMapper.updateProduct(product);
         }
@@ -443,6 +443,7 @@ public class ShopServiceImpl implements ShopService {
             }
         }
         BrandPo brand = new BrandPo();
+        brand.setId(brandDto.getId());
         brand.setName(brandDto.getName());
         brand.setUserId(brandDto.getUserId());
         brand.setSource(brandDto.getSource());
@@ -459,7 +460,6 @@ public class ShopServiceImpl implements ShopService {
             shopMapper.updateBrand(brand);
         }
         return ResponseJson.success(brand);
-
     }
 
     /**

+ 16 - 2
src/main/java/com/caimei365/commodity/utils/AppletsLinkUtil.java

@@ -111,6 +111,7 @@ public class AppletsLinkUtil {
      * 20分类详情
      */
     public static final Pattern pattern35 = Pattern.compile("/cmpage/info-5");
+    public static final Pattern pattern35_1 = Pattern.compile("/product/type");
     /**
      * 21美博会专题页
      */
@@ -119,6 +120,15 @@ public class AppletsLinkUtil {
      * 22美体会专题页
      */
     public static final Pattern pattern38 = Pattern.compile("/cmpage/info-5-301");
+    /**
+     * 23活动专题
+     */
+    public static final Pattern pattern39 = Pattern.compile("/cmpage/info-6");
+    public static final Pattern pattern39_1 = Pattern.compile("/activity/activityTopic");
+    /**
+     * 24美博会优惠券页
+     */
+    public static final Pattern pattern40 = Pattern.compile("/user/beautyfair");
 
     /**
      * 根据链接判断链接类型
@@ -164,13 +174,17 @@ public class AppletsLinkUtil {
                 return 18;
             } else if (pattern32.matcher(link).find()) {
                 return 19;
-            } else if (pattern35.matcher(link).find()) {
+            } else if (pattern35.matcher(link).find() || pattern35_1.matcher(link).find()) {
                 if (pattern38.matcher(link).find()) {
                     return 22;
                 }
                 return 20;
             } else if (pattern37.matcher(link).find()) {
                 return 21;
+            } else if (pattern39.matcher(link).find() || pattern39_1.matcher(link).find()) {
+                return 23;
+            } else if (pattern40.matcher(link).find()) {
+                return 24;
             } else {
                 return -1;
             }
@@ -199,7 +213,7 @@ public class AppletsLinkUtil {
                 split3 = split1[split1.length - 1].split("\\.");
             }
         }
-        if (linkType == 3 || linkType == 5 || linkType == 20 || linkType == 22) {
+        if (linkType == 3 || linkType == 5 || linkType == 20 || linkType == 22 || linkType == 23) {
             //-{id}.html
             if (split3 != null && split3.length == 2) {
                 map.put("id", split3[0]);

+ 64 - 6
src/main/resources/mapper/PageMapper.xml

@@ -52,7 +52,7 @@
     </select>
     <select id="getFloorImageById" resultType="com.caimei365.commodity.model.vo.FloorImageVo">
         select
-            id, floorId, centreId, productId, name, link, image, label, pcStatus, appletsStatus, sort, createDate
+            id, floorId, centreId, productId, name, link, image, appletsImage, label, pcStatus, appletsStatus, sort, createDate
         from new_page_floor_image
         where floorId = #{id}
         <if test="source == 1">
@@ -71,7 +71,7 @@
     </select>
     <select id="getFloorImageByCentreId" resultType="com.caimei365.commodity.model.vo.FloorImageVo">
         select
-            id, floorId, centreId, productId, name, link, image, label, pcStatus, appletsStatus, sort, createDate
+            id, floorId, centreId, productId, name, link, image, appletsImage, label, pcStatus, appletsStatus, sort, createDate
         from new_page_floor_image
         where centreId = #{id}
         <if test="source == 1">
@@ -200,10 +200,10 @@
         and type = #{typeId}
     </select>
     <select id="getImageLinkByFloorId" resultType="com.caimei365.commodity.model.vo.ImageLinkVo">
-        select  a.id as id,
-                a.title as title,
-                a.link as link,
-                a.image as image
+        select  a.id,
+                a.title,
+                a.link,
+                a.image
         from cm_page_image a
         right join cm_page_centre_image b on b.imageId=a.id
         where b.centreId=#{floorId} and  a.enabledStatus=1
@@ -235,6 +235,64 @@
 			p.tinyTypeID = (select tinyTypeID from product as p1 where p1.productID = #{productId})
         order by p.sellNumber desc limit 0,7
     </select>
+    <select id="findCmPageById" resultType="com.caimei365.commodity.model.vo.CmPageVo">
+        select
+            id,
+            type,
+            title,
+            keywords,
+            description,
+            headImage,
+            crmHeadImage,
+            headLink,
+            headText
+        from cm_page where id = #{pageId} and enabledStatus = '1'
+    </select>
+    <select id="getSearchKeyword" resultType="java.lang.String">
+        select name from keyword
+        where validFlag=1
+        order by sortIndex desc
+    </select>
+    <select id="getTopMenus" resultType="com.caimei365.commodity.model.vo.TopMenuVo">
+		select
+            id,
+            navigationName as name,
+            type,
+            link,
+            icon,
+            sort
+		from new_page_first_navigation
+		where delFlag = 0
+		<if test="source == 1">
+            and wwwEnabledStatus = 1
+        </if>
+        <if test="source == 2">
+            and crmEnabledStatus = 1
+        </if>
+		order by -sort desc,createDate desc
+		limit 8
+    </select>
+    <select id="getHelpPageTypes" resultType="com.caimei365.commodity.model.vo.BaseLinkVo">
+		select
+		c_helpPageTypeID as id,
+		c_helpPageTypeName as name
+		from c_helpPageType
+    </select>
+    <select id="getHelpPagesByType" resultType="com.caimei365.commodity.model.vo.BaseLinkVo">
+		select
+            helpPageID as id,
+            helpPageTypeID as typeId,
+            title as name
+		from helpPage
+		where validFlag = 1
+		and helpPageTypeID = #{typeId}
+		order by sortIndex
+    </select>
+    <select id="getFriendLinks" resultType="com.caimei365.commodity.model.vo.BaseLinkVo">
+		select id,name,link
+		from new_page_friendship_link
+		where delFlag = 0 order by id
+    </select>
 
 
 </mapper>

+ 1 - 1
src/main/resources/mapper/PriceMapper.xml

@@ -49,7 +49,7 @@
               #{productId}
           </foreach>
     </select>
-    <select id="getladderPricesByProductId" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
+    <select id="getLadderPricesByProductId" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
         select
         	id, productId, ladderNum, buyNum, buyPrice
         from product_ladder_price

+ 1 - 1
src/main/resources/mapper/SearchMapper.xml

@@ -387,7 +387,7 @@
             (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.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

+ 2 - 2
src/main/resources/mapper/SecondHandMapper.xml

@@ -22,12 +22,12 @@
     </insert>
     <insert id="insertProduct" keyColumn="productID" keyProperty="productId" parameterType="com.caimei365.commodity.model.po.ProductPo" useGeneratedKeys="true">
         insert into product (
-            brandId, name, price, stock, aliasName, normalPrice, mainImage, productCategory, preferredFlag, shopId,
+            brandId, name, price, price1, stock, aliasName, normalPrice, mainImage, productCategory, preferredFlag, shopId,
             sellNumber, costPrice, costCheckFlag, hasSkuFlag, validFlag, ladderPriceFlag, sortIndex, featuredFlag, byFlag,
             step, actFlag, actStatus, freePostFlag, productType, machineType, includedTax, recommendType, invoiceType,
             visibility, addTime, updateTime, onlineTime, downlineTime
         ) values (
-            #{brandId}, #{name}, #{price}, #{stock}, #{aliasName}, #{normalPrice}, #{mainImage}, #{productCategory},
+            #{brandId}, #{name}, #{price}, #{price}, #{stock}, #{aliasName}, #{normalPrice}, #{mainImage}, #{productCategory},
             #{preferredFlag}, #{shopId}, #{sellNumber}, #{costPrice}, #{costCheckFlag}, #{hasSkuFlag}, #{validFlag},
             #{ladderPriceFlag}, #{sortIndex}, #{featuredFlag}, #{byFlag}, #{step}, #{actFlag}, #{actStatus},
             #{freePostFlag}, #{productType}, #{machineType}, #{includedTax}, #{recommendType}, #{invoiceType},

+ 4 - 1
src/main/resources/mapper/ShopMapper.xml

@@ -247,7 +247,7 @@
             #{seoKeyword}, #{seoDes}
         )
     </insert>
-    <insert id="insertBrand">
+    <insert id="insertBrand" keyColumn="id" keyProperty="id"  parameterType="com.caimei365.commodity.model.po.BrandPo" useGeneratedKeys="true">
         insert into cm_brand (name, source, userID, status, delFlag, createDate, updateDate, logo, description)
         values (#{name},#{source},#{userId},#{status}, #{delFlag},#{createDate},#{updateDate},#{logo},#{description})
     </insert>
@@ -308,6 +308,9 @@
     <update id="updateProductValidFlag">
         update product set validFlag = #{validFlag} where productID = #{productId}
     </update>
+    <update id="updateProductCode">
+        update product set productCode = #{productCode} where productID = #{productId}
+    </update>
     <delete id="deleteProductImage">
         delete from productimage where productImageID = #{id}
     </delete>