소스 검색

Merge remote-tracking branch 'origin/developerC' into developerB

zhijiezhao 3 년 전
부모
커밋
3a9530f28a
22개의 변경된 파일1152개의 추가작업 그리고 30개의 파일을 삭제
  1. 21 0
      src/main/java/com/caimei365/commodity/controller/ProductPageApi.java
  2. 1 1
      src/main/java/com/caimei365/commodity/controller/ProductPriceApi.java
  3. 58 4
      src/main/java/com/caimei365/commodity/controller/SearchProductApi.java
  4. 10 10
      src/main/java/com/caimei365/commodity/controller/SearchQueryApi.java
  5. 32 4
      src/main/java/com/caimei365/commodity/controller/SecondHandApi.java
  6. 36 1
      src/main/java/com/caimei365/commodity/mapper/PageMapper.java
  7. 30 1
      src/main/java/com/caimei365/commodity/mapper/SearchMapper.java
  8. 9 1
      src/main/java/com/caimei365/commodity/mapper/SecondHandMapper.java
  9. 34 0
      src/main/java/com/caimei365/commodity/model/po/SearchHistoryPo.java
  10. 78 0
      src/main/java/com/caimei365/commodity/model/vo/AfterSaleVo.java
  11. 136 0
      src/main/java/com/caimei365/commodity/model/vo/InfoVo.java
  12. 82 0
      src/main/java/com/caimei365/commodity/model/vo/LiveVo.java
  13. 126 0
      src/main/java/com/caimei365/commodity/model/vo/PageImageVo.java
  14. 11 0
      src/main/java/com/caimei365/commodity/service/PageService.java
  15. 25 0
      src/main/java/com/caimei365/commodity/service/SearchProductService.java
  16. 12 0
      src/main/java/com/caimei365/commodity/service/SecondHandService.java
  17. 67 0
      src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java
  18. 90 6
      src/main/java/com/caimei365/commodity/service/impl/SearchProductServiceImpl.java
  19. 77 1
      src/main/java/com/caimei365/commodity/service/impl/SecondHandServiceImpl.java
  20. 126 1
      src/main/resources/mapper/PageMapper.xml
  21. 71 0
      src/main/resources/mapper/SearchMapper.xml
  22. 20 0
      src/main/resources/mapper/SecondHandMapper.xml

+ 21 - 0
src/main/java/com/caimei365/commodity/controller/ProductPageApi.java

@@ -94,6 +94,27 @@ public class ProductPageApi {
         return pageService.getHomeInit(source);
     }
 
+    /**
+     * 首页侧边栏数据(小程序)
+     *
+     * @param source 来源 : 1 网站 ; 2 小程序
+     */
+    @ApiOperation("首页侧边栏数据(旧:/home/top/data)")
+    @ApiImplicitParam(required = false, name = "source", value = "来源:1网站,2小程序")
+    @GetMapping("/home/sidebar")
+    public ResponseJson<Map<String, Object>> getHomesideBar(Integer source) {
+        return pageService.getHomesideBar(source);
+    }
+
+    /**
+     * 售后无忧,购物须知
+     */
+    @ApiOperation("售后无忧,购物须知(旧:/home/afterSale")
+    @GetMapping("/home/sale/tips")
+    public ResponseJson<AfterSaleVo> getAfterSale() {
+        return pageService.getAfterSale();
+    }
+
     /**
      * 二级专题页楼层数据
      *

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

@@ -43,7 +43,7 @@ public class ProductPriceApi {
             @ApiImplicitParam(required = true, name = "userId", value = "用户Id"),
             @ApiImplicitParam(required = true, name = "productId", value = "商品Id")
     })
-    @GetMapping("detail")
+    @GetMapping("/detail")
     public ResponseJson<PriceVo> getDetailPrice(Integer userId, Integer productId) {
         if (null == userId || null == productId) {
             return ResponseJson.error("参数错误", null);

+ 58 - 4
src/main/java/com/caimei365/commodity/controller/SearchProductApi.java

@@ -1,17 +1,22 @@
 package com.caimei365.commodity.controller;
 
 import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.po.SearchHistoryPo;
 import com.caimei365.commodity.service.SearchProductService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * 搜索商品(阿里云搜索)
  *
@@ -43,7 +48,7 @@ public class SearchProductApi {
         @ApiImplicitParam(required = false, name = "sortField", value = "排序字段:价格price,销量sales,人气favorite"),
         @ApiImplicitParam(required = false, name = "sortType", value = "排序规则:1降序,其他升序")
     })
-    @GetMapping("product")
+    @GetMapping("/product")
     public ResponseJson<String> queryProductByKeyword(String keyword,
                                                       @RequestParam(value = "identity", defaultValue = "0") Integer identity,
                                                       @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
@@ -70,7 +75,7 @@ public class SearchProductApi {
         @ApiImplicitParam(required = false, name = "sortField", value = "排序字段:价格price,销量sales,人气favorite"),
         @ApiImplicitParam(required = false, name = "sortType", value = "排序规则:1降序,其他升序")
     })
-    @GetMapping("product/type")
+    @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,
@@ -96,7 +101,7 @@ public class SearchProductApi {
         @ApiImplicitParam(required = false, name = "sortField", value = "排序字段:价格price,销量sales,人气favorite"),
         @ApiImplicitParam(required = false, name = "sortType", value = "排序规则:1降序,其他升序")
     })
-    @GetMapping("product/classify")
+    @GetMapping("/product/classify")
     public ResponseJson<String> queryProductByClassify(Integer id,
                                             @RequestParam(value = "identity", defaultValue = "0") Integer identity,
                                             @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
@@ -123,7 +128,7 @@ public class SearchProductApi {
         @ApiImplicitParam(required = false, name = "sortField", value = "排序字段:价格price,销量sales,人气favorite"),
         @ApiImplicitParam(required = false, name = "sortType", value = "排序规则:1降序,其他升序")
     })
-    @GetMapping("product/shop")
+    @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,
@@ -132,4 +137,53 @@ public class SearchProductApi {
         return searchProductService.querySupplierProduct(id, keyword, identity, pageNum, pageSize, sortField, sortType);
     }
 
+    /**
+     * 根据用户ID查找历史记录
+     */
+    @ApiOperation("查找搜索历史记录(旧:/product/searchHistory)")
+    @ApiImplicitParam(required = true, name = "userId", value = "用户Id")
+    @GetMapping("/history")
+    public ResponseJson<List<SearchHistoryPo>> getSearchHistory(Integer userId) {
+        if (null == userId) {
+            return ResponseJson.error("用户Id不能为空!", null);
+        }
+        return searchProductService.getSearchHistory(userId);
+    }
+
+    /**
+     * 保存搜索历史记录
+     */
+    @ApiOperation("保存搜索历史记录(旧:/product/history/add)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, name = "userId", value = "用户Id"),
+            @ApiImplicitParam(required = true, name = "keyword", value = "搜索关键字")
+    })
+    @GetMapping("/history/add")
+    public ResponseJson<Void> addProductSearchHistory(Integer userId, String keyword) {
+        if (null == userId || StringUtils.isEmpty(keyword)) {
+            return ResponseJson.error("用户Id或关键字不能为空!", null);
+        }
+        return searchProductService.addSearchHistory(userId, keyword);
+    }
+
+    /**
+     * 根据用户ID删除历史记录
+     */
+    @ApiOperation("删除搜索历史记录(旧:/product/searchHistory/delete )")
+    @ApiImplicitParam(required = true, name = "userId", value = "用户Id")
+    @GetMapping("/history/delete")
+    public ResponseJson<Void> deleteSearchHistory(Integer userId) {
+        if (null == userId) {
+            return ResponseJson.error("用户Id不能为空!", null);
+        }
+        return searchProductService.deleteSearchHistory(userId);
+    }
+
+    /**
+     * 产品仪器热搜词
+     */
+    @GetMapping("/hot/keyword")
+    public ResponseJson<Map<String, Object>> getHotSearchTerms() {
+        return searchProductService.getHotSearchTerms();
+    }
 }

+ 10 - 10
src/main/java/com/caimei365/commodity/controller/SearchQueryApi.java

@@ -36,7 +36,7 @@ public class SearchQueryApi {
         @ApiImplicitParam(required = false, name = "docType", value = "文档类型(product,shop,equipment,article)"),
         @ApiImplicitParam(required = false, name = "docId", value = "文档Id")
     })
-    @GetMapping("id")
+    @GetMapping("/id")
     public Integer getIdByDocId(String docType, Integer docId) {
         return searchQueryService.getIdByDocId(docType, docId);
     }
@@ -53,7 +53,7 @@ public class SearchQueryApi {
         @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
         @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
-    @GetMapping("ids")
+    @GetMapping("/ids")
     public Map<Integer, Integer> getMainIdsByDocType(String docType,
                                                      @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                      @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
@@ -68,7 +68,7 @@ public class SearchQueryApi {
      */
     @ApiOperation("根据文档类型获取数量")
     @ApiImplicitParam(required = true, name = "docType", value = "文档类型(product,shop,equipment,article)")
-    @GetMapping("record")
+    @GetMapping("/record")
     public Integer getRecordByDocType(String docType) {
         return searchQueryService.getRecordByDocType(docType);
     }
@@ -84,7 +84,7 @@ public class SearchQueryApi {
         @ApiImplicitParam(required = false, name = "docType", value = "文档类型(product,shop,equipment,article)"),
         @ApiImplicitParam(required = false, name = "docId", value = "文档Id")
     })
-    @GetMapping("count")
+    @GetMapping("/count")
     public Integer getCountByDocId(String docType, Integer docId) {
         return searchQueryService.getCountByDocId(docType, docId);
     }
@@ -103,7 +103,7 @@ public class SearchQueryApi {
         @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
         @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
-    @GetMapping("shop")
+    @GetMapping("/shop")
     public ResponseJson<String> querySupplierByKeyword(String keyword,
                                                        @RequestParam(value = "identity", defaultValue = "0") Integer identity,
                                                        @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
@@ -124,7 +124,7 @@ public class SearchQueryApi {
         @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
         @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
-    @GetMapping("equipment")
+    @GetMapping("/equipment")
     public ResponseJson<String> queryEquipmentByKeyword(String keyword,
                                              @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                              @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
@@ -144,7 +144,7 @@ public class SearchQueryApi {
         @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
         @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
-    @GetMapping("article")
+    @GetMapping("/article")
     public ResponseJson<String> queryArticleByKeyword(String keyword,
                                            @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                            @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
@@ -159,7 +159,7 @@ public class SearchQueryApi {
      * @param id 文章id
      */
     @ApiOperation("根据文章ID搜索文章")
-    @GetMapping("article/{id}")
+    @GetMapping("/article/{id}")
     public ResponseJson<String> queryArticleByArticleId(@PathVariable("id") Integer id) {
         return searchQueryService.queryArticleByArticleId(id);
     }
@@ -178,7 +178,7 @@ public class SearchQueryApi {
         @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
         @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
-    @GetMapping("article/type")
+    @GetMapping("/article/type")
     public ResponseJson<String> queryArticleByType(Integer id,
                                         @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                         @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
@@ -199,7 +199,7 @@ public class SearchQueryApi {
         @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
         @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
-    @GetMapping("article/label")
+    @GetMapping("/article/label")
     public ResponseJson<String> queryArticleByLabel(Integer id,
                                          @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                          @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {

+ 32 - 4
src/main/java/com/caimei365/commodity/controller/SecondHandApi.java

@@ -44,7 +44,7 @@ public class SecondHandApi {
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
             @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
-    @GetMapping("list")
+    @GetMapping("/list")
     public ResponseJson<PaginationVo<SecondListVo>> getSecondHandList(Integer userId, Integer secondHandType, Integer instrumentType, String name,
                                                                       @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                                       @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
@@ -61,7 +61,7 @@ public class SecondHandApi {
             @ApiImplicitParam(required = true, name = "userId", value = "机构用户id"),
             @ApiImplicitParam(required = true, name = "productId", value = "商品Id")
     })
-    @GetMapping("detail")
+    @GetMapping("/detail")
     public ResponseJson<SecondDetailVo> getSecondDetail(Integer userId, Integer productId) {
         return secondHandService.getSecondHandDetail(userId, productId);
     }
@@ -116,7 +116,7 @@ public class SecondHandApi {
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
             @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
-    @GetMapping("order/products")
+    @GetMapping("/order/products")
     public ResponseJson<PaginationVo<SecondListVo>> getOrderPageSecondList(String searchKeyword, Integer secondHandType, Integer instrumentType,
                                                                            @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                                            @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
@@ -127,9 +127,37 @@ public class SecondHandApi {
      * 二手发布页-品牌列表
      */
     @ApiOperation("二手发布页-品牌列表(旧:/product/brandList)")
-    @GetMapping("brands")
+    @GetMapping("/brands")
     public ResponseJson<List<BrandVo>> getBrandList() {
         return secondHandService.getBrandList();
     }
 
+
+    /**
+     * 计算二手商品浏览量
+     */
+    @ApiOperation("计算二手商品浏览量(旧:/product/updateSecondHandProductCount)")
+    @ApiImplicitParam(required = true, name = "productId", value = "商品Id")
+    @GetMapping("/views")
+    public ResponseJson<Integer> updateSecondHandViews(Integer productId){
+        if (null == productId) {
+            return ResponseJson.error("商品Id不能为空!", null);
+        }
+        return secondHandService.updateSecondHandViews(productId);
+    }
+
+    /**
+     * 二手商品-相关推荐
+     *
+     * @param productId 商品Id
+     */
+    @ApiOperation("二手商品-相关推荐(旧:/product/getSecondHandProductRecommend)")
+    @ApiImplicitParam(required = false, name = "productId", value = "商品Id")
+    @GetMapping("/recommend")
+    public ResponseJson<List<SecondListVo>> getSecondRecommends(Integer productId) {
+        if (null == productId) {
+            return ResponseJson.error("商品Id不能为空!", null);
+        }
+        return secondHandService.getSecondRecommends(productId);
+    }
 }

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

@@ -25,12 +25,19 @@ public interface PageMapper {
     Integer getPageTypeSort(Integer pageId);
 
     /**
-     * 查询分页详情热搜词
+     * 查询热搜词(单个页面)
      *
      * @param pageId
      */
     List<HotSearchVo> getHotSearchByPageId(Integer pageId, Integer source);
 
+    /**
+     * 查询热搜词(多个页面Id)
+     *
+     * @param pageIds
+     */
+    List<HotSearchVo> getHotSearchByPageIds(@Param("pageIds") List<Integer> pageIds, @Param("source") Integer source);
+
     /**
      * 首页楼层
      *
@@ -281,4 +288,32 @@ public interface PageMapper {
      * @return
      */
     Integer getSvipUserIdByUserId(Integer userId);
+    /**
+     * banner图
+     */
+    List<ImageLinkVo> getBannerImages();
+    /**
+     * 售后无忧,购物须知
+     */
+    AfterSaleVo getAfterSale();
+    /**
+     * 查询产品,仪器页面信息
+     */
+    List<Integer> getPageIdByTypeSort(Integer typeSort);
+    /**
+     * 查询首页置顶直播信息
+     */
+    List<LiveVo> getSidebarLive(Integer source);
+    /**
+     * 查询首页置顶文章信息
+     */
+    List<InfoVo> getSidebarInfo();
+    /**
+     * 查询首页置顶活动
+     */
+    List<PageImageVo> getSidebarPageImage(Integer source);
+    /**
+     * 查询首页直播宣传图
+     */
+    String getLiveAdvertisingImage();
 }

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

@@ -1,5 +1,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;
@@ -174,5 +175,33 @@ public interface SearchMapper {
      * @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);
 }

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

@@ -81,9 +81,17 @@ public interface SecondHandMapper {
      * @param secondHandType 二手商品分类,1二手仪器,2临期产品,3其他
      */
     List<SecondListVo> getSecondListByLimit(Integer secondHandType);
-
     /**
      * 商品品牌列表
      */
     List<BrandVo> getBrandList();
+    /**
+     * 更新二手商品浏览量
+     */
+    int updateSecondHandViews(SecondDetailVo second);
+
+    /**
+     * 二手商品-相关推荐
+     */
+    List<SecondListVo> getSecondRecommends(Integer productId);
 }

+ 34 - 0
src/main/java/com/caimei365/commodity/model/po/SearchHistoryPo.java

@@ -0,0 +1,34 @@
+package com.caimei365.commodity.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/10/20
+ */
+@Data
+public class SearchHistoryPo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private Integer id;
+    /**
+     * 用户ID
+     */
+    private Integer userId;
+    /**
+     * 搜索关键词
+     */
+    private String searchWord;
+    /**
+     * 搜索时间
+     */
+    private Date searchDate;
+    /**
+     * 删除标记 0 否,其余是
+     */
+    private Integer delFlag;
+}

+ 78 - 0
src/main/java/com/caimei365/commodity/model/vo/AfterSaleVo.java

@@ -0,0 +1,78 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 售后无忧,购物须知
+ *
+ * @author : Charles
+ * @date : 2021/10/20
+ */
+@Data
+public class AfterSaleVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private Integer id;
+
+    /**
+     * 组织名称
+     */
+    private String organizeName;
+
+    /**
+     * 组织联系人
+     */
+    private String organizeLinkName;
+
+    /**
+     * 手机号码
+     */
+    private String mobile;
+
+    /**
+     * 联系我们,手机或者座机号码
+     */
+    private String contactNumber;
+
+    /**
+     * 后台系统名称
+     */
+    private String systemName;
+
+    /**
+     * 后台系统图标
+     */
+    private String systemImage;
+
+    /**
+     * 关于我们:组织介绍信息
+     */
+    private String introduction;
+
+    /**
+     * 售后无忧
+     */
+    private String afterSale;
+
+    /**
+     * 购物须知
+     */
+    private String shoppingNotes;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    /**
+     * 添加时间
+     */
+    private Date addTime;
+
+    /**
+     *  0 有效  其它无效
+     */
+    private String delFlag;
+}

+ 136 - 0
src/main/java/com/caimei365/commodity/model/vo/InfoVo.java

@@ -0,0 +1,136 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/10/21
+ */
+@Data
+public class InfoVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private Integer id;
+
+    /**
+     * 信息分类
+     */
+    private Integer typeId;
+
+    /**
+     * 标题
+     */
+    private String title;
+
+    /**
+     * 信息标签
+     */
+    private String label;
+
+    /**
+     * 发布人
+     */
+    private String publisher;
+
+    /**
+     * 来源
+     */
+    private String source;
+
+    /**
+     * 关键字
+     */
+    private String keyword;
+
+    /**
+     * 推荐语
+     */
+    private String recommendContent;
+
+    /**
+     * 信息内容
+     */
+    private String infoContent;
+
+    /**
+     * 引导图
+     */
+    private String guidanceImage;
+
+    /**
+     * 商城首页图
+     */
+    private String homePageImage;
+
+    /**
+     * 发布时间
+     */
+    private String pubdate;
+
+    /**
+     * 推荐状态 0停用 1启用
+     */
+    private String recommendStatus;
+
+    /**
+     * 启用/禁用状态
+     */
+    private String enabledStatus;
+
+    /**
+     * 基础点赞
+     */
+    private Integer basePraise;
+
+    /**
+     * 基础浏览量
+     */
+    private Integer basePv;
+
+    /**
+     * 优先级
+     */
+    private Integer priorityIndex;
+
+    /**
+     * 创建人
+     */
+    private String createBy;
+
+    /**
+     * 创建时间
+     */
+    private String createDate;
+
+    /**
+     * 最后更新人
+     */
+    private String updateBy;
+
+    /**
+     * 最后更新时间
+     */
+    private String updateDate;
+
+    /**
+     * 置顶位
+     */
+    private Integer topPosition;
+    /**
+     * 文章链接
+     */
+    private String link;
+    /**
+     * 链接类型
+     */
+    private Integer linkType;
+    /**
+     * 链接参数
+     */
+    private Map<String, Object> linkParam;
+}

+ 82 - 0
src/main/java/com/caimei365/commodity/model/vo/LiveVo.java

@@ -0,0 +1,82 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/10/21
+ */
+@Data
+public class LiveVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 直播id
+     */
+    private Integer id;
+
+    /**
+     * 直播标题
+     */
+    private String liveTitle;
+
+    /**
+     * 首页图片
+     */
+    private String homePageImage;
+
+    /**
+     * 小程序内容宣传图
+     */
+    private String advertisingImage;
+
+    /**
+     * 直播链接
+     */
+    private String link;
+
+    /**
+     * 网站状态:0停用,1已启用
+     */
+    private String wwwValidFlag;
+
+    /**
+     * 小程序状态:0停用,1已启用
+     */
+    private String crmValidFlag;
+
+    /**
+     * 首页置顶位
+     */
+    private Integer topPosition;
+
+    /**
+     * 创建时间
+     */
+    private String createTime;
+
+    /**
+     * 开始时间
+     */
+    private Date startTime;
+
+    /**
+     * 结束时间
+     */
+    private Date endTime;
+
+    /**
+     * 首页置顶位
+     */
+    private Integer liveStatus;
+
+    /**
+     * 删除标识:0未删除,1已删除
+     */
+    private String delFlag;
+
+}

+ 126 - 0
src/main/java/com/caimei365/commodity/model/vo/PageImageVo.java

@@ -0,0 +1,126 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/10/21
+ */
+@Data
+public class PageImageVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private Integer id;
+
+    /**
+     * 标题
+     */
+    private String title;
+
+    /**
+     * 链接
+     */
+    private String link;
+
+    /**
+     * APP链接
+     */
+    private String appLink;
+
+    /**
+     * 图片
+     */
+    private String image;
+
+    /**
+     * 商城首页图
+     */
+    private String homePageImage;
+
+    /**
+     * 小程序图片
+     */
+    private String appletsImage;
+
+    /**
+     * 小程序链接
+     */
+    private String appletsLink;
+
+    /**
+     * 小程序端状态
+     */
+    private String appletsEnabledStatus;
+
+    /**
+     * 排序
+     */
+    private Integer sort;
+
+    /**
+     * 类型1二级列表 ,2项目详情 ,3讲师轮播,4活动专区 , 5顶层广告, 6首页轮播 ,7小专题
+     */
+    private String type;
+
+    /**
+     * 状态 0停用 1启用
+     */
+    private String enabledStatus;
+
+    /**
+     * CRM端状态 0停用 1启用
+     */
+    private String crmEnabledStatus;
+
+    /**
+     * 活动开始时间
+     */
+    private String beginTime;
+
+    /**
+     * 活动开始时间
+     */
+    private String endTime;
+
+    /**
+     * 活动分类
+     */
+    private Integer actType;
+
+    /**
+     * 创建人
+     */
+    private Integer createBy;
+
+    /**
+     * 创建时间
+     */
+    private String createDate;
+
+    /**
+     * 最后更新人
+     */
+    private Integer updateBy;
+
+    /**
+     * 最后更新时间
+     */
+    private String updateDate;
+
+    /**
+     * 首页置顶位
+     */
+    private Integer topPosition;
+    /**
+     * 链接类型
+     */
+    private Integer linkType;
+    /**
+     * 链接参数
+     */
+    private Map<String, Object> linkParam;
+}

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

@@ -47,6 +47,17 @@ public interface PageService {
      */
     ResponseJson<Map<String, Object>> getHomeInit(Integer source);
 
+    /**
+     * 首页侧边栏数据
+     * @param source 来源 : 1 网站 ; 2 小程序
+     */
+    ResponseJson<Map<String, Object>> getHomesideBar(Integer source);
+
+    /**
+     * 售后无忧,购物须知
+     */
+    ResponseJson<AfterSaleVo> getAfterSale();
+
     /**
      * 二级专题页楼层数据
      * @param pageId 页面id

+ 25 - 0
src/main/java/com/caimei365/commodity/service/SearchProductService.java

@@ -1,6 +1,10 @@
 package com.caimei365.commodity.service;
 
 import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.po.SearchHistoryPo;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -62,4 +66,25 @@ public interface SearchProductService {
      * @return JsonStr(list)
      */
     ResponseJson<String> querySupplierProduct(Integer id, String keyword, Integer identity, int pageNum, int pageSize, String sortField, Integer sortType);
+
+    /**
+     * 根据用户ID查找历史记录
+     * @param userId 用户Id
+     */
+    ResponseJson<List<SearchHistoryPo>> getSearchHistory(Integer userId);
+    /**
+     * 保存搜索历史记录
+     * @param userId  用户Id
+     * @param keyword 搜索关键字
+     */
+    ResponseJson<Void> addSearchHistory(Integer userId, String keyword);
+    /**
+     * 根据用户ID删除历史记录
+     * @param userId 用户Id
+     */
+    ResponseJson<Void> deleteSearchHistory(Integer userId);
+    /**
+     * 产品仪器热搜词
+     */
+    ResponseJson<Map<String, Object>> getHotSearchTerms();
 }

+ 12 - 0
src/main/java/com/caimei365/commodity/service/SecondHandService.java

@@ -82,4 +82,16 @@ public interface SecondHandService {
      * 商品品牌列表
      */
     ResponseJson<List<BrandVo>> getBrandList();
+
+    /**
+     * 计算二手商品浏览量
+     * @param productId 商品Id
+     */
+    ResponseJson<Integer> updateSecondHandViews(Integer productId);
+
+    /**
+     * 二手商品-相关推荐
+     * @param productId 商品Id
+     */
+    ResponseJson<List<SecondListVo>> getSecondRecommends(Integer productId);
 }

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

@@ -208,6 +208,18 @@ public class PageServiceImpl implements PageService {
             }
         });
         map.put("topMenuList", menuList);
+        // banner图
+        List<ImageLinkVo> bannerImageList = pageMapper.getBannerImages();
+        bannerImageList.forEach(image -> {
+            if (StringUtils.isNotEmpty(image.getLink())) {
+                image.setLinkType(AppletsLinkUtil.getLinkType(image.getLink()));
+                image.setLinkParam(AppletsLinkUtil.getLinkParam(image.getLinkType(), image.getLink()));
+            }
+        });
+        map.put("bannerList", bannerImageList);
+        // 售后无忧,购物须知
+        AfterSaleVo afterSale = pageMapper.getAfterSale();
+        map.put("afterSale", afterSale);
         // 底部帮助页
         List<BaseLinkVo> helpPages = pageMapper.getHelpPageTypes();
         helpPages.forEach(item -> {
@@ -230,6 +242,61 @@ public class PageServiceImpl implements PageService {
         return ResponseJson.success(map);
     }
 
+    /**
+     * 首页侧边栏数据
+     *
+     * @param source 来源 : 1 网站 ; 2 小程序
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> getHomesideBar(Integer source) {
+        Map<String, Object> map = new HashMap<>(4);
+        //直播导航
+        List<LiveVo> liveList = pageMapper.getSidebarLive(source);
+        //设置直播状态
+        liveList.forEach(live -> {
+            if (null != live.getStartTime() && null != live.getEndTime()) {
+                Date date = new Date();
+                int startResult = date.compareTo(live.getStartTime());
+                int endResult = date.compareTo(live.getEndTime());
+                live.setLiveStatus(startResult < 0 ? 1 : endResult < 0 ? 2 : 3);
+            } else {
+                live.setLiveStatus(1);
+            }
+        });
+        map.put("liveList", liveList);
+        //文章导航
+        List<InfoVo> infoList = pageMapper.getSidebarInfo();
+        infoList.forEach(info -> {
+            info.setLink(domain + "/info/detail-" + info.getId() + "-1.html");
+            info.setLinkType(AppletsLinkUtil.getLinkType(info.getLink()));
+            info.setLinkParam(AppletsLinkUtil.getLinkParam(info.getLinkType(), info.getLink()));
+            info.setCreateDate(info.getCreateDate() == null ? null : info.getCreateDate().split(" ")[0]);
+        });
+        map.put("infoList", infoList);
+        //活动导航
+        List<PageImageVo> cmImageList = pageMapper.getSidebarPageImage(source);
+        cmImageList.forEach(cmImage -> {
+            cmImage.setLinkType(AppletsLinkUtil.getLinkType(cmImage.getLink()));
+            cmImage.setLinkParam(AppletsLinkUtil.getLinkParam(cmImage.getLinkType(), cmImage.getLink()));
+            cmImage.setCreateDate(cmImage.getCreateDate() == null ? null : cmImage.getCreateDate().split(" ")[0]);
+        });
+        map.put("cmImageList", cmImageList);
+        // 直播宣传图
+        String liveAdvertisingImage = pageMapper.getLiveAdvertisingImage();
+        map.put("liveImage", liveAdvertisingImage);
+        return ResponseJson.success(map);
+    }
+
+    /**
+     * 售后无忧,购物须知
+     */
+    @Override
+    public ResponseJson<AfterSaleVo> getAfterSale() {
+        // 售后无忧,购物须知
+        AfterSaleVo afterSale = pageMapper.getAfterSale();
+        return ResponseJson.success(afterSale);
+    }
+
     /**
      * 二级专题页楼层数据
      *

+ 90 - 6
src/main/java/com/caimei365/commodity/service/impl/SearchProductServiceImpl.java

@@ -7,11 +7,15 @@ 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.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.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;
@@ -21,7 +25,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.List;
+import java.util.*;
 
 /**
  * Description
@@ -39,6 +43,8 @@ public class SearchProductServiceImpl implements SearchProductService {
     @Resource
     private SearchMapper searchMapper;
     @Resource
+    private PageMapper pageMapper;
+    @Resource
     private SearchOpenService searchOpenService;
     @Resource
     private PriceUtilService priceUtilService;
@@ -220,11 +226,6 @@ public class SearchProductServiceImpl implements SearchProductService {
         }
     }
 
-
-
-
-
-
     /**
      * 查询商品(阿里云搜索)
      *
@@ -316,4 +317,87 @@ public class SearchProductServiceImpl implements SearchProductService {
         }
         return result;
     }
+
+    /**
+     * 根据用户ID查找历史记录
+     *
+     * @param userId 用户Id
+     */
+    @Override
+    public ResponseJson<List<SearchHistoryPo>> getSearchHistory(Integer userId) {
+        List<SearchHistoryPo> historyList = searchMapper.getHistoryList(userId);
+        return ResponseJson.success(historyList);
+    }
+
+    /**
+     * 保存搜索历史记录
+     *
+     * @param userId  用户Id
+     * @param keyword 搜索关键字
+     */
+    @Override
+    public ResponseJson<Void> addSearchHistory(Integer userId, String keyword) {
+        //保存并删除大于10条的历史记录
+        SearchHistoryPo historyRecord = new SearchHistoryPo();
+        historyRecord.setUserId(userId);
+        historyRecord.setSearchDate(new Date());
+        historyRecord.setSearchWord(keyword);
+        historyRecord.setDelFlag(0);
+        Integer recordId = searchMapper.getHistoryIdByWord(keyword);
+        if (null != recordId && recordId > 0) {
+            //更新
+            historyRecord.setId(recordId);
+            searchMapper.updateSearchHistoryById(historyRecord);
+        } else {
+            // 新增
+            searchMapper.insertSearchHistory(historyRecord);
+        }
+        int count = searchMapper.getHistoryCount(userId);
+        if (count>10){
+            // 删除大于10条的历史记录
+            searchMapper.deleteSearchHistory(userId);
+        }
+        return ResponseJson.success(null);
+    }
+
+    /**
+     * 根据用户ID删除历史记录
+     *
+     * @param userId 用户Id
+     */
+    @Override
+    public ResponseJson<Void> deleteSearchHistory(Integer userId) {
+        // 删除用户所有历史记录
+        searchMapper.deleteAllSearchHistory(userId);
+        return ResponseJson.success(null);
+    }
+
+    /**
+     * 产品仪器热搜词
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> getHotSearchTerms() {
+        //产品
+        List<HotSearchVo> productHotSearch = getHotSearch(1, 2);
+        //仪器
+        List<HotSearchVo> instrumentHotSearch = getHotSearch(2, 2);
+        Map<String, Object> map = new HashMap<>(2);
+        map.put("productHotSearch", productHotSearch);
+        map.put("instrumentHotSearch", instrumentHotSearch);
+        return ResponseJson.success(map);
+    }
+
+    private List<HotSearchVo> getHotSearch(Integer typeSort, Integer source) {
+        List<Integer> pageIds = pageMapper.getPageIdByTypeSort(typeSort);
+        List<HotSearchVo> productHotSearch = new ArrayList<>();
+        if (pageIds != null) {
+            productHotSearch = pageMapper.getHotSearchByPageIds(pageIds, source);
+        }
+        productHotSearch.forEach(h -> {
+            String link = h.getLink();
+            h.setLinkType(AppletsLinkUtil.getLinkType(link));
+            h.setLinkParam(AppletsLinkUtil.getLinkParam(h.getLinkType(), link));
+        });
+        return productHotSearch;
+    }
 }

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

@@ -13,7 +13,6 @@ import com.caimei365.commodity.model.vo.*;
 import com.caimei365.commodity.service.SecondHandService;
 import com.caimei365.commodity.utils.ImageUtils;
 import com.github.pagehelper.PageHelper;
-import io.swagger.v3.oas.annotations.parameters.RequestBody;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
@@ -24,6 +23,7 @@ import org.springframework.util.CollectionUtils;
 import javax.annotation.Resource;
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
@@ -472,6 +472,82 @@ public class SecondHandServiceImpl implements SecondHandService {
             return "时间未知";
         }
     }
+    /**
+     * 获取是否在固定天数以内
+     *
+     * @param addtime 需要判断的时间
+     * @param now     当前时间
+     * @param day     多少天内
+     * @return
+     */
+    public boolean isLatestWeek(Date addtime, Date now, int day) {
+        Calendar calendar = Calendar.getInstance();  //得到日历
+        calendar.setTime(now);//把当前时间赋给日历
+        calendar.add(Calendar.DAY_OF_MONTH, -day);  //设置为day天前
+        Date before7days = calendar.getTime();   //得到day天前的时间
+        if (before7days.getTime() < addtime.getTime()) {
+            return true;
+        } else {
+            return false;
+        }
+    }
 
+    /**
+     * 计算二手商品浏览量
+     *
+     * @param productId 商品Id
+     */
+    @Override
+    public ResponseJson<Integer> updateSecondHandViews(Integer productId) {
+        SecondDetailVo second = secondHandMapper.getSecondHandDetail(productId);
+        Integer viewingNum = 0;
+        if (null != second) {
+            viewingNum = second.getViewingNum();
+            /* 更新新浏览量规则
+             * 7天内,每被浏览一次,浏览数添加一个20以内的随机数
+             * 14天内,每被浏览一次,浏览数添加一个10以内的随机数
+             * 30天内,每被浏览一次,浏览数添加一个5以内的随机数
+             * 30天以外,每被浏览一次,浏览数添加1
+             */
+            Date onLine = second.getOnLineDate();
+            int random = 1;
+            if (null != onLine) {
+                boolean latestWeek = isLatestWeek(onLine, new Date(), 7);
+                boolean latestHalfMonth = isLatestWeek(onLine, new Date(), 14);
+                boolean latestMonth = isLatestWeek(onLine, new Date(), 30);
+                if (latestWeek) {
+                    random = (int) (Math.random() * 20 + 1);
+                } else if (latestHalfMonth) {
+                    random = (int) (Math.random() * 10 + 1);
+                } else if (latestMonth) {
+                    random = (int) (Math.random() * 5 + 1);
+                }
+            }
+            if (null != viewingNum) {
+                viewingNum = viewingNum + random;
+                second.setViewingNum(viewingNum);
+            } else {
+                viewingNum = random;
+                second.setViewingNum(random);
+            }
+            secondHandMapper.updateSecondHandViews(second);
+            return ResponseJson.success(viewingNum);
+        } else {
+            return ResponseJson.error("二手商品异常!", null);
+        }
+    }
 
+    /**
+     * 二手商品-相关推荐
+     *
+     * @param productId 商品Id
+     */
+    @Override
+    public ResponseJson<List<SecondListVo>> getSecondRecommends(Integer productId) {
+        List<SecondListVo> recommendList = secondHandMapper.getSecondRecommends(productId);
+        for (SecondListVo product : recommendList) {
+            product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
+        }
+        return ResponseJson.success(recommendList);
+    }
 }

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

@@ -20,6 +20,18 @@
         </if>
         order by -sort desc, creationTime desc
     </select>
+    <select id="getHotSearchByPageIds" resultType="com.caimei365.commodity.model.vo.HotSearchVo">
+        select id, pageId, name, isHot, link, pcStatus, sort, appletsStatus, creationTime
+        from cm_page_hot_search
+        where appletsStatus = 1
+        <if test="pageIds.size() > 0">
+            and pageId in
+            <foreach collection="pageIds" open="(" separator="," close=")" item="pageId">
+                #{pageId}
+            </foreach>
+        </if>
+        order by -sort desc, creationTime desc
+    </select>
     <select id="getHomePageFloor" resultType="com.caimei365.commodity.model.vo.PageFloorVo">
         select id, type, floorTitle as title, floorDetail as detail
 		from new_page_floor
@@ -481,7 +493,7 @@
     <select id="getSvipProductAdsImage" resultType="java.lang.String">
         select if(#{source} = 1, pcImage, appletsImage)
         from cm_svip_product_adsimage
-        limit 1;
+        limit 1
     </select>
     <select id="getSvipProductList" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
         select
@@ -522,5 +534,118 @@
     <select id="getSvipUserIdByUserId" resultType="java.lang.Integer">
         select userId from cm_svip_user where userId = #{userId} and delFlag = '0' and now() <![CDATA[ < ]]> endTime
     </select>
+    <select id="getBannerImages" resultType="com.caimei365.commodity.model.vo.ImageLinkVo">
+        select id, title, link, crmImage as image, crmImage, crmLink, crmTitle
+        from new_page_homeimage
+        where crmEnabledStatus = 1
+        order by sort desc, createDate desc
+    </select>
+    <select id="getAfterSale" resultType="com.caimei365.commodity.model.vo.AfterSaleVo">
+        SELECT id, organizeName, organizeLinkName, mobile, contactNumber, systemName, systemImage,
+               introduction, afterSale, shoppingNotes, updateTime, addTime, delFlag
+        FROM cm_mall_organize
+        WHERE id = 0 AND delFlag = '0'
+    </select>
+    <select id="getPageIdByTypeSort" resultType="java.lang.Integer">
+        SELECT id FROM cm_page WHERE enabledStatus = 1 AND typeSort = #{typeSort}
+    </select>
+    <select id="getSidebarLive" resultType="com.caimei365.commodity.model.vo.LiveVo">
+        SELECT
+            id,
+            liveTitle,
+            homePageImage,
+            advertisingImage,
+            link,
+            wwwValidFlag,
+            crmValidFlag,
+            topPosition,
+            createTime,
+            startTime,
+            endTime,
+            liveStatus,
+            delFlag
+        FROM
+        new_page_live
+        WHERE
+        topPosition IN (1, 2, 3)
+        AND delFlag = '0'
+        <if test="source == 1">
+            AND wwwValidFlag = '1'
+        </if>
+        <if test="source == 2">
+            AND crmValidFlag = '1'
+        </if>
+        ORDER BY topPosition
+    </select>
+    <select id="getSidebarInfo" resultType="com.caimei365.commodity.model.vo.InfoVo">
+        SELECT
+            id,
+            typeId,
+            title,
+            label,
+            publisher,
+            source,
+            keyword,
+            recommendContent,
+            infoContent,
+            guidanceImage,
+            homePageImage,
+            pubdate,
+            recommendStatus,
+            enabledStatus,
+            basePraise,
+            basePv,
+            priorityIndex,
+            createBy,
+            createDate,
+            updateBy,
+            updateDate,
+            topPosition
+        FROM
+            info
+        WHERE
+            topPosition IN (1, 2, 3)
+          AND enabledStatus = '1'
+        ORDER BY
+            topPosition
+    </select>
+    <select id="getSidebarPageImage" resultType="com.caimei365.commodity.model.vo.PageImageVo">
+        SELECT
+            id,
+            title,
+            link,
+            appLink,
+            image,
+            homePageImage,
+            appletsImage,
+            appletsLink,
+            appletsEnabledStatus,
+            sort,
+            type,
+            enabledStatus,
+            crmEnabledStatus,
+            beginTime,
+            endTime,
+            actType,
+            createBy,
+            createDate,
+            updateBy,
+            updateDate,
+            topPosition
+        FROM
+        cm_page_image
+        WHERE
+        topPosition IN (1, 2, 3)
+        <if test="source == 1">
+            AND enabledstatus = '1'
+        </if>
+        <if test="source == 2">
+            AND appletsEnabledStatus = '1'
+        </if>
+        ORDER BY topPosition
+    </select>
+    <select id="getLiveAdvertisingImage" resultType="java.lang.String">
+        SELECT advertisingImage FROM new_page_live_advertising_image LIMIT 1;
+    </select>
 
 </mapper>

+ 71 - 0
src/main/resources/mapper/SearchMapper.xml

@@ -415,4 +415,75 @@
             </otherwise>
         </choose>
     </select>
+    <select id="getHistoryList" resultType="com.caimei365.commodity.model.po.SearchHistoryPo">
+        select id, userId, searchWord, searchDate, delFlag
+        from user_search_history
+        where userId = #{userId}
+        order by id desc
+    </select>
+    <select id="getHistoryIdByWord" resultType="java.lang.Integer">
+        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>
+    <update id="updateSearchHistoryById">
+        update user_search_history
+        <set>
+            <if test="userId != null">
+                userId = #{userId},
+            </if>
+            <if test="searchWord != null">
+                searchWord = #{searchWord},
+            </if>
+            <if test="searchDate != null">
+                searchDate = #{searchDate},
+            </if>
+            <if test="delFlag != null">
+                delFlag = #{delFlag},
+            </if>
+        </set>
+        where id = #{id}
+    </update>
+    <insert id="insertSearchHistory">
+        INSERT INTO user_search_history
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userId != null">
+                userId,
+            </if>
+            <if test="searchWord != null">
+                searchWord,
+            </if>
+            <if test="searchDate != null">
+                searchDate,
+            </if>
+            <if test="delFlag != null">
+                delFlag,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="userId != null">
+                #{userId},
+            </if>
+            <if test="searchWord != null">
+                #{searchWord},
+            </if>
+            <if test="searchDate != null">
+                #{searchDate},
+            </if>
+            <if test="delFlag != null">
+                #{delFlag},
+            </if>
+        </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>
+    <delete id="deleteAllSearchHistory">
+        DELETE FROM user_search_history WHERE userId=#{userId}
+    </delete>
 </mapper>

+ 20 - 0
src/main/resources/mapper/SecondHandMapper.xml

@@ -34,6 +34,10 @@
             #{visibility}, #{addTime}, #{updateTime}, #{onlineTime}, #{offlineTime}
         )
     </insert>
+    <update id="updateSecondHandViews">
+        UPDATE cm_second_hand_detail SET viewingNum = #{viewingNum}
+        WHERE productID = #{productId}
+    </update>
     <select id="getSeconHandList" resultType="com.caimei365.commodity.model.vo.SecondListVo">
         select
             p.productID as productId,
@@ -182,4 +186,20 @@
 		where status = '1' and delFlag = '0' and description is not null and description != '' and id not in (161)
 		order by sort
     </select>
+    <select id="getSecondRecommends" resultType="com.caimei365.commodity.model.vo.SecondListVo">
+        select
+        p.productID as productId,
+        p.actStatus,
+        p.`name` as name,
+        p.mainImage as image,
+        p.price1 as price,
+        p.brandID as brandId,
+        cb.name as "brandName"
+        from product p
+        left join cm_second_hand_recommend cshr on p.productID = cshr.recommendProductID
+        left join cm_brand cb on cb.id = p.brandID
+        where p.productCategory = 2 and p.validFlag = 2 and cshr.delFlag = 0
+        and cshr.secondHandProductID = #{productId}
+        order by cshr.sort desc
+    </select>
 </mapper>