Browse Source

呵呵商城改版part1

Aslee 3 years ago
parent
commit
cbedeb804e
22 changed files with 1341 additions and 17 deletions
  1. 120 0
      src/main/java/com/caimei365/commodity/controller/HeheApi.java
  2. 4 3
      src/main/java/com/caimei365/commodity/controller/ProductPageApi.java
  3. 66 0
      src/main/java/com/caimei365/commodity/mapper/HeheMapper.java
  4. 5 0
      src/main/java/com/caimei365/commodity/mapper/PageMapper.java
  5. 2 1
      src/main/java/com/caimei365/commodity/mapper/ProductTypeMapper.java
  6. 1 1
      src/main/java/com/caimei365/commodity/mapper/SearchMapper.java
  7. 40 0
      src/main/java/com/caimei365/commodity/model/po/HeheCollageProductPo.java
  8. 5 0
      src/main/java/com/caimei365/commodity/model/vo/FloorImageVo.java
  9. 49 0
      src/main/java/com/caimei365/commodity/model/vo/HeHeActivityVo.java
  10. 91 0
      src/main/java/com/caimei365/commodity/model/vo/HeheCouponVo.java
  11. 86 0
      src/main/java/com/caimei365/commodity/model/vo/HeheProductDetailsVo.java
  12. 160 0
      src/main/java/com/caimei365/commodity/model/vo/HeheProductVo.java
  13. 51 0
      src/main/java/com/caimei365/commodity/service/HeheService.java
  14. 9 3
      src/main/java/com/caimei365/commodity/service/PageService.java
  15. 324 0
      src/main/java/com/caimei365/commodity/service/impl/HeheServiceImpl.java
  16. 7 5
      src/main/java/com/caimei365/commodity/service/impl/PageServiceImpl.java
  17. 1 2
      src/main/java/com/caimei365/commodity/service/impl/ProductTypeServiceImpl.java
  18. 1 1
      src/main/java/com/caimei365/commodity/service/impl/SearchProductServiceImpl.java
  19. 297 0
      src/main/resources/mapper/HeheMapper.xml
  20. 18 0
      src/main/resources/mapper/PageMapper.xml
  21. 3 0
      src/main/resources/mapper/ProductTypeMapper.xml
  22. 1 1
      src/main/resources/mapper/SearchMapper.xml

+ 120 - 0
src/main/java/com/caimei365/commodity/controller/HeheApi.java

@@ -0,0 +1,120 @@
+package com.caimei365.commodity.controller;
+
+import com.caimei365.commodity.annotation.Statistics;
+import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.po.ProductParameterPo;
+import com.caimei365.commodity.model.search.ProductListVo;
+import com.caimei365.commodity.model.vo.*;
+import com.caimei365.commodity.service.HeheService;
+import com.caimei365.commodity.service.PageService;
+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.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2022/3/29
+ */
+@Api(tags = "呵呵商品API")
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/commodity/hehe")
+public class HeheApi {
+
+    private final HeheService heheService;
+
+    /**
+     * 获取首页分类列表
+     */
+    @ApiOperation("首页分类菜单")
+    @GetMapping("/home/type")
+    public ResponseJson<List<BigTypeVo>> getHomeTypeList() {
+        return heheService.getHomeTypeList();
+    }
+
+    /**
+     * 获取商品列表
+     */
+    @ApiOperation("商品列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = false, name = "listType", value = "列表类型:1首页搜索商品列表,2首页分类商品列表,3首页楼层商品列表.4二级分类商品列表,5活动商品列表"),
+            @ApiImplicitParam(required = false, name = "homeTypeId", value = "首页分类id"),
+            @ApiImplicitParam(required = false, name = "homeFloorId", value = "首页楼层id"),
+            @ApiImplicitParam(required = false, name = "smallTypeId", value = "二级分类id"),
+            @ApiImplicitParam(required = false, name = "userId", value = "用户id"),
+            @ApiImplicitParam(required = false, name = "productName", value = "搜索商品名称"),
+            @ApiImplicitParam(required = false, name = "sortType", value = "排序类型:1综合,2价格升序,3价格降序,4最新"),
+            @ApiImplicitParam(required = false, name = "productIds", value = "综合排序已查出的商品id,以,隔开"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
+    })
+    @GetMapping("/product/list")
+    public ResponseJson<PaginationVo<HeheProductVo>> getProductList(Integer listType, Integer homeTypeId, Integer homeFloorId, Integer smallTypeId,
+                                                                    Integer userId, String productName, String productIds,
+                                                                    Integer sortType,
+                                                                    @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                    @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+        return heheService.getProductList(listType, homeTypeId, homeFloorId, smallTypeId, userId, productName, productIds, sortType, pageNum, pageSize);
+    }
+
+    @ApiOperation("首页楼层数据")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = false, name = "userId", value = "用户id")
+    })
+    @GetMapping("/home/init")
+    public ResponseJson<Map<String, Object>> getHomeData(Integer userId) {
+        return heheService.getHomeData(userId);
+    }
+
+
+    @ApiOperation("活动专区")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "userId", value = "分销者用户id", required = true),
+            @ApiImplicitParam(name = "pageNum", value = "第几页", required = false),
+            @ApiImplicitParam(name = "pageSize", value = "一页多少条", required = false)
+    })
+    @GetMapping("/activity/list")
+    public ResponseJson<PaginationVo<HeHeActivityVo>> getActivityList(Integer userId,
+                                                                      @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+                                                                      @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        if (null == userId) {
+            return ResponseJson.error("参数异常,分销者用户id不能为空", null);
+        }
+        return heheService.getActivityList(userId, pageNum, pageSize);
+    }
+
+    @ApiOperation("活动详情")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "userId", value = "分销者用户id", required = true),
+            @ApiImplicitParam(name = "activityId", value = "活动id", required = true),
+            @ApiImplicitParam(name = "pageNum", value = "第几页", required = false),
+            @ApiImplicitParam(name = "pageSize", value = "一页多少条", required = false)
+    })
+    @GetMapping("/activity/details")
+    public ResponseJson<Map<String, Object>> getActivityDetails(Integer userId, Integer activityId,
+                                                             @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
+                                                             @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
+        if (userId == null || activityId == null) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return heheService.getActivityDetails(userId, activityId, pageNum, pageSize);
+    }
+
+    @ApiOperation("商品详情")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "productId", required = true, value = "商品Id"),
+            @ApiImplicitParam(name = "userId", required = true, value = "机构用户Id")
+    })
+    @GetMapping("/details")
+    public ResponseJson<HeheProductVo> getProductDetails(Integer productId, Integer userId) {
+        return heheService.getProductDetails(productId, userId);
+    }
+}

+ 4 - 3
src/main/java/com/caimei365/commodity/controller/ProductPageApi.java

@@ -39,11 +39,12 @@ public class ProductPageApi {
     @ApiOperation("获取分类菜单(旧:/product/classify)")
     @ApiImplicitParams({
             @ApiImplicitParam(required = true, name = "typeSort", value = "分类类型:1产品,2仪器,0全部"),
-            @ApiImplicitParam(required = false, name = "source", value = "请求来源:www,crm")
+            @ApiImplicitParam(required = false, name = "source", value = "请求来源:www,crm"),
+            @ApiImplicitParam(required = false, name = "mallType", value = "商城类型:1采美,2呵呵")
     })
     @GetMapping("/classify")
-    public ResponseJson<List<BigTypeVo>> getClassify(Integer typeSort, String source) {
-        return pageService.getClassify(typeSort, source);
+    public ResponseJson<List<BigTypeVo>> getClassify(Integer typeSort, String source, Integer mallType) {
+        return pageService.getClassify(typeSort, source, mallType);
     }
 
     /**

+ 66 - 0
src/main/java/com/caimei365/commodity/mapper/HeheMapper.java

@@ -0,0 +1,66 @@
+package com.caimei365.commodity.mapper;
+
+import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.po.HeheCollageProductPo;
+import com.caimei365.commodity.model.vo.*;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2022/3/29
+ */
+@Mapper
+public interface HeheMapper {
+
+    ResponseJson<List<BigTypeVo>> getHomeTypeList();
+
+    List<HeheProductVo> getProductList(@Param("listType") Integer listType, @Param("homeTypeId") Integer homeTypeId, @Param("homeFloorId") Integer homeFloorId, @Param("smallTypeId") Integer smallTypeId, @Param("activityId") Integer activityId, @Param("productName") String productName, @Param("sortType") Integer sortType, @Param("productIds") String productIds);
+
+    Integer getActivityIdByProductId(Integer productId);
+
+    HeheCollageProductPo getCollageProduct(Integer productId);
+
+    List<LadderPriceVo> getActivityLadderList(Integer activityId, Integer productId);
+
+    Integer getProductDiscount(Integer productId, Integer userId);
+
+    Integer getAllProductCouponCount();
+
+    Integer getPartProductCounponCount(Integer productId);
+
+    BigDecimal getDiscountPrice(Integer productId);
+
+    /**
+     * 查询可领取的优惠券列表
+     * @return
+     */
+    List<HeheCouponVo> getCouponList(@Param("userId") Integer userId, @Param("productIdArr") String[] productIdArr, @Param("registerTime") Date registerTime, @Param("couponType") Integer couponType);
+
+    Date getUserRegisterTime(Integer userId);
+
+    /**
+     * 查询已领取的优惠券列表
+     */
+    List<HeheCouponVo> getReceiveCouponList(@Param("userId") Integer userId, @Param("productIdArr") String[] productIdArr, @Param("receiveCouponId") Integer receiveCouponId, @Param("status") Integer status);
+
+    /**
+     * 根据商品id查询商品
+     */
+    HeheProductVo getProduct(Integer productId);
+
+    /**
+     * 根据分销者用户id查询活动列表
+     * @param userId
+     * @return
+     */
+    List<HeHeActivityVo> getActivityList(Integer userId);
+
+    String getActivityImageById(Integer activityId);
+}

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

@@ -353,4 +353,9 @@ public interface PageMapper {
      * 根据商品id查询问题列表
      */
     List<String> getBaikeQuestionList(Integer productId);
+
+    /**
+     * 查找呵呵首页页面
+     */
+    CmPageVo findHeheHomePage();
 }

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

@@ -19,8 +19,9 @@ public interface ProductTypeMapper {
      * 获取大分类
      * @param typeSort 分类类型:1产品,2仪器,0全部
      * @param source   请求来源:www,crm
+     * @param mallType
      */
-    List<BigTypeVo> getBigTypeList(Integer typeSort, String source);
+    List<BigTypeVo> getBigTypeList(Integer typeSort, String source, Integer mallType);
     /**
      * 根据大分类Id获取二级分类
      * @param bigTypeId 大分类Id

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

@@ -217,7 +217,7 @@ public interface SearchMapper {
      *
      * @param keyword 关键词
      */
-    Integer getHistoryIdByWord(String keyword);
+    Integer getHistoryIdByWord(String keyword,Integer userId);
 
     /**
      * 更新历史记录

+ 40 - 0
src/main/java/com/caimei365/commodity/model/po/HeheCollageProductPo.java

@@ -0,0 +1,40 @@
+package com.caimei365.commodity.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2021/12/16
+ */
+@Data
+public class HeheCollageProductPo implements Serializable {
+    /**
+     * 呵呵商城商品id
+     */
+    private Integer productId;
+
+    /**
+     * 拼团价格
+     */
+    private BigDecimal price;
+
+    /**
+     * 单人限购量
+     */
+    private Integer limitedNum;
+
+    /**
+     * 不限购买量标识:1不限制,0限制
+     */
+    private Integer unlimitedFlag;
+
+    /**
+     * 拼团人数
+     */
+    private Integer memberNum;
+}

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

@@ -98,6 +98,11 @@ public class FloorImageVo implements Serializable {
      */
     private ProductItemVo product;
 
+    /**
+     * 呵呵商品信息
+     */
+    private HeheProductVo heheProduct;
+
     /**
      * 区分商品和二级列表,1 商品 2 二级列表
      */

+ 49 - 0
src/main/java/com/caimei365/commodity/model/vo/HeHeActivityVo.java

@@ -0,0 +1,49 @@
+package com.caimei365.commodity.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/4/27
+ */
+@Data
+public class HeHeActivityVo implements Serializable {
+    /**
+     * 活动id
+     */
+    private Integer activityId;
+
+    /**
+     * 活动名称
+     */
+    private String name;
+
+    /**
+     * 小程序列表缩略图
+     */
+    private String listImage;
+
+    /**
+     * 开始时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date beginTime;
+
+    /**
+     * 结束时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private Date endTime;
+
+    /**
+     * 商品数量
+     */
+    private Integer productCount;
+
+}

+ 91 - 0
src/main/java/com/caimei365/commodity/model/vo/HeheCouponVo.java

@@ -0,0 +1,91 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/8/12
+ */
+@Data
+public class HeheCouponVo implements Serializable {
+    /**
+     * 优惠券id
+     */
+    private Integer couponId;
+
+    /**
+     * 优惠券分享id
+     */
+    private Integer couponShareId;
+
+    /**
+     * 优惠券名称
+     */
+    private String couponName;
+
+    /**
+     * 优惠券金额(面值)
+     */
+    private BigDecimal couponAmount;
+
+    /**
+     * 优惠满减条件金额
+     */
+    private BigDecimal touchPrice;
+
+    /**
+     * 无门槛标记 0否 1是
+     */
+    private Integer noThresholdFlag;
+
+    /**
+     * 永久可领取标识:true是,false否
+     */
+    private Boolean permanentFlag;
+
+    /**
+     * 劵类型 1活动券 2专享券 3新人券 4好友分享券 5好友消费券
+     */
+    private Integer couponType;
+
+    /**
+     * 优惠商品:1全商城商品 2指定商品
+     */
+    private Integer productType;
+
+    /**
+     * 领取截止时间
+     */
+    private Date receivePeriod;
+
+    /**
+     * 使用截止时间
+     */
+    private Date usePeriod;
+
+    /**
+     * 使用状态: 0未领取 1未使用 2已使用 3已失效
+     */
+    private Integer useStatus;
+
+    /**
+     * 是否达到优惠条件:1达到,2未达到
+     */
+    private Integer touchFlag;
+
+    /**
+     * 创建时间
+     */
+    private Date createDate;
+
+    /**
+     * 部分商品优惠券关联的商品id
+     */
+    private String productIds;
+}

+ 86 - 0
src/main/java/com/caimei365/commodity/model/vo/HeheProductDetailsVo.java

@@ -0,0 +1,86 @@
+package com.caimei365.commodity.model.vo;
+
+import com.caimei365.commodity.model.po.ProductDetailInfoPo;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/4/23
+ */
+@Data
+public class HeheProductDetailsVo extends HeheProductVo {
+    /**
+     * 上架状态:1上架,2下架
+     */
+    private Integer validFlag;
+
+    /**
+     * 品牌id
+     */
+    private Integer brandId;
+
+    /**
+     * 一级分类ID
+     */
+    private Integer bigTypeId;
+
+    /**
+     * 二级分类ID
+     */
+    private Integer smallTypeId;
+
+    /**
+     * 三级分类Id
+     */
+    private Integer tinyTypeId;
+
+    /**
+     * 库存
+     */
+    private Integer stock;
+
+    /**
+     * 商品标签用英文逗号隔开,中文逗号或其它一律不作切割
+     */
+    private String tags;
+
+    /**
+     * 所在分类名称
+     */
+    private String typeName;
+
+    /**
+     * 品牌名称
+     */
+    private String brandName;
+
+    /**
+     * 标签数组
+     */
+    private String[] tagsList;
+
+    /**
+     * 所有商品图片
+     */
+    private List<String> imageList;
+
+    /**
+     * 商品详情
+     */
+    private ProductDetailInfoPo productDetail;
+
+    /**
+     * 相关参数
+     */
+/*    private List<RelatedParametersVo> parametersList;
+
+    *//**
+     * 活动阶梯
+     *//*
+    List<ActivityLadderVo> ladderList;*/
+
+}

+ 160 - 0
src/main/java/com/caimei365/commodity/model/vo/HeheProductVo.java

@@ -0,0 +1,160 @@
+package com.caimei365.commodity.model.vo;
+
+import com.caimei365.commodity.model.po.HeheCollageProductPo;
+import com.caimei365.commodity.model.po.ProductDetailInfoPo;
+import com.caimei365.commodity.model.po.ProductParameterPo;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/4/22
+ */
+@Data
+public class HeheProductVo implements Serializable {
+    /**
+     * 对应采美商品id
+     */
+    private Integer productId;
+
+    /**
+     * 是否为推荐商品(0 没推荐,1 推荐商品)
+     */
+    private String recommend;
+
+    /**
+     * 市场价
+     */
+    private BigDecimal normalPrice;
+
+    /**
+     * 售价
+     */
+    private BigDecimal price;
+
+    /**
+     * 券后价
+     */
+    private BigDecimal couponPrice = BigDecimal.ZERO;
+
+    /**
+     * 券后价
+     */
+    private BigDecimal normalCouponPrice = BigDecimal.ZERO;
+
+    /**
+     * 商品名称
+     */
+    private String name;
+
+    /**
+     * 商品图片
+     */
+    private String mainImage;
+
+    /**
+     * 券后价对应优惠券id
+     */
+    private Integer couponId;
+
+    /**
+     * 包装规格
+     */
+    private String unit;
+
+    /**
+     * 库存
+     */
+    private Integer stock;
+
+    /**
+     * 商品标签用英文逗号隔开,中文逗号或其它一律不作切割
+     */
+    private String tags;
+
+    /**
+     * 活动状态:0没有活动,1活动价
+     */
+    private Integer activeStatus = 0;
+
+    /**
+     * 拼团状态:0没有拼团价,1拼团价
+     */
+    private Integer collageStatus = 0;
+
+    /**
+     * 限时特价状态:0没有限时特价,1限时特价
+     */
+    private Integer discountStatus = 0;
+
+    /**
+     * 优惠券标签状态:0无可用优惠券,1券后价,2优惠券信息
+     */
+    private Integer couponStatus = 0;
+
+    /**
+     * 单价未满足优惠条件,显示最小优惠条件的优惠券信息
+     */
+    private String couponInfo;
+
+    /**
+     * 拼团商品
+     */
+    private HeheCollageProductPo collageProduct;
+
+    /**
+     * 是否含税 0不含税,1含税
+     */
+    private String includedTax;
+
+    /**
+     * 发票类型(基于是否含税基础) 1增值税专用发票,2增值税普通发票, 3不能开票
+     */
+    private String invoiceType;
+
+    /**
+     * 机构税率 :增值税默认13%,普通票6%取值范围[0-100]
+     */
+    private BigDecimal clubTaxPoint;
+
+    /**
+     * 优惠券标识是否显示
+     */
+    private Boolean couponsLogo = false;
+
+    /**
+     * 品牌名称
+     */
+    private String brandName;
+
+    /**
+     * 标签数组
+     */
+    private String[] tagsList;
+
+    /**
+     * 所有商品图片
+     */
+    private List<String> imageList;
+
+    /**
+     * 商品详情
+     */
+    private ProductDetailInfoPo productDetail;
+
+    /**
+     * 相关参数
+     */
+    private List<ProductParameterPo> parametersList;
+
+    /**
+     * 活动阶梯
+     */
+    List<LadderPriceVo> ladderList;
+
+}

+ 51 - 0
src/main/java/com/caimei365/commodity/service/HeheService.java

@@ -0,0 +1,51 @@
+package com.caimei365.commodity.service;
+
+import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.vo.*;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2022/3/29
+ */
+public interface HeheService {
+    /**
+     * 获取首页分类列表
+     */
+    ResponseJson<List<BigTypeVo>> getHomeTypeList();
+
+    /**
+     * 获取商品列表
+     */
+    ResponseJson<PaginationVo<HeheProductVo>> getProductList(Integer listType, Integer homeTypeId, Integer homeFloorId, Integer smallTypeId, Integer userId, String productName, String productIds, Integer sortType, int pageNum, int pageSize);
+
+    /**
+     * 首页楼层数据
+     */
+    ResponseJson<Map<String, Object>> getHomeData(Integer userId);
+
+    /**
+     * 活动专区
+     * @return
+     */
+    ResponseJson<PaginationVo<HeHeActivityVo>> getActivityList(Integer userId, Integer pageNum, Integer pageSize);
+
+    /**
+     * 活动详情
+     */
+    ResponseJson<Map<String, Object>> getActivityDetails(Integer userId, Integer activityId, Integer pageNum, Integer pageSize);
+
+    /**
+     * 查询商品详情
+     */
+    ResponseJson<HeheProductVo> getProductDetails(Integer productId, Integer userId);
+
+    /**
+     * 设置商品详情
+     */
+//    void setProductDetails(HeheProductVo product, Integer userId);
+}

+ 9 - 3
src/main/java/com/caimei365/commodity/service/PageService.java

@@ -17,11 +17,11 @@ import java.util.Map;
 public interface PageService {
     /**
      * 获取分类列表
-     *
-     * @param typeSort 分类类型:1产品,2仪器,0全部
+     *  @param typeSort 分类类型:1产品,2仪器,0全部
      * @param source   请求来源:www,crm
+     * @param mallType
      */
-    ResponseJson<List<BigTypeVo>> getClassify(Integer typeSort, String source);
+    ResponseJson<List<BigTypeVo>> getClassify(Integer typeSort, String source, Integer mallType);
 
     /**
      * 产品/仪器页面数据
@@ -213,4 +213,10 @@ public interface PageService {
      * @return
      */
     ResponseJson<PaginationVo<BaikeProductVo>> getBaikeTypeData(Integer typeId, int pageNum, int pageSize);
+
+    /**
+     * 设置跳转参数
+     * @param floorContent
+     */
+    void setFloorLinkType(FloorContentVo floorContent);
 }

+ 324 - 0
src/main/java/com/caimei365/commodity/service/impl/HeheServiceImpl.java

@@ -0,0 +1,324 @@
+package com.caimei365.commodity.service.impl;
+
+import com.caimei365.commodity.mapper.*;
+import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.po.HeheCollageProductPo;
+import com.caimei365.commodity.model.po.ProductDetailInfoPo;
+import com.caimei365.commodity.model.po.ProductParameterPo;
+import com.caimei365.commodity.model.po.SearchHistoryPo;
+import com.caimei365.commodity.model.vo.*;
+import com.caimei365.commodity.service.HeheService;
+import com.caimei365.commodity.service.PageService;
+import com.caimei365.commodity.utils.AppletsLinkUtil;
+import com.caimei365.commodity.utils.ImageUtils;
+import com.caimei365.commodity.utils.MathUtil;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.*;
+
+import static com.alibaba.fastjson.JSON.parseArray;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/4/9
+ */
+@Slf4j
+@Service
+public class HeheServiceImpl implements HeheService {
+    @Value("${caimei.wwwDomain}")
+    private String domain;
+    @Resource
+    private HeheMapper heheMapper;
+    @Resource
+    private SearchMapper searchMapper;
+    @Resource
+    private PageMapper pageMapper;
+    @Resource
+    private ShopMapper shopMapper;
+    @Resource
+    private SecondHandMapper secondHandMapper;
+    @Autowired
+    private PageService pageService;
+
+
+    @Override
+    public ResponseJson<List<BigTypeVo>> getHomeTypeList() {
+        return heheMapper.getHomeTypeList();
+    }
+
+    @Override
+    public ResponseJson<PaginationVo<HeheProductVo>> getProductList(Integer listType, Integer homeTypeId, Integer homeFloorId, Integer smallTypeId, Integer userId, String productName, String productIds, Integer sortType, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<HeheProductVo> productList = heheMapper.getProductList(listType, homeTypeId, homeFloorId, smallTypeId, null, productName, sortType, productIds);
+        productList.forEach(product -> setProductInfo(product, userId));
+        PaginationVo<HeheProductVo> page = new PaginationVo<>(productList);
+        if (1 == listType) {
+            // 保存搜索记录
+            if (StringUtils.isNotEmpty(productName) && userId != null && userId > 0) {
+                //保存并删除大于10条的历史记录
+                SearchHistoryPo historyRecord = new SearchHistoryPo();
+                historyRecord.setUserId(userId);
+                historyRecord.setSearchDate(new Date());
+                historyRecord.setSearchWord(productName);
+                historyRecord.setDelFlag(0);
+                Integer recordId = searchMapper.getHistoryIdByWord(productName, userId);
+                if (recordId != null && 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(page);
+    }
+
+    @Override
+    public ResponseJson<Map<String, Object>> getHomeData(Integer userId) {
+        // 页面数据
+        CmPageVo page = pageMapper.findHeheHomePage();
+        if (page == null) {
+            return ResponseJson.error("首页页面不存在", null);
+        }
+        // 来源:小程序
+        Integer source = 2;
+        //轮播图设置链接类型
+        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(page.getId(), source);
+        ListIterator<PageFloorVo> iterator = floorList.listIterator();
+        while (iterator.hasNext()) {
+            PageFloorVo floor = iterator.next();
+            FloorContentVo floorContent = pageMapper.getFloorContentByCentreId(floor.getId());
+            if (null == floorContent) {
+                iterator.remove();
+            } else {
+                pageService.setFloorLinkType(floorContent);
+                List<FloorImageVo> floorImageList = pageMapper.getFloorImageByCentreId(floor.getId(), source);
+                setFloorImageProduct(userId, floorImageList);
+                floor.setFloorImageList(floorImageList);
+                floor.setFloorContent(floorContent);
+            }
+        }
+        Map<String, Object> map = new HashMap<>(2);
+        map.put("page", page);
+        map.put("floorList", floorList);
+        return ResponseJson.success(map);
+    }
+
+    @Override
+    public ResponseJson<PaginationVo<HeHeActivityVo>> getActivityList(Integer userId, Integer pageNum, Integer pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<HeHeActivityVo> activityList = heheMapper.getActivityList(userId);
+        PaginationVo<HeHeActivityVo> pageInfo = new PaginationVo<>(activityList);
+        return ResponseJson.success(pageInfo);
+    }
+
+    @Override
+    public ResponseJson<Map<String, Object>> getActivityDetails(Integer userId, Integer activityId, Integer pageNum, Integer pageSize) {
+        Map<String, Object> map = new HashMap<>(2);
+        String image = heheMapper.getActivityImageById(activityId);
+        PageHelper.startPage(pageNum, pageSize);
+        List<HeheProductVo> productList = heheMapper.getProductList(5, null, null, null, activityId, null, 4, null);
+        productList.forEach(product -> setProductInfo(product, userId));
+        PageInfo<HeheProductVo> pageInfo = new PageInfo<>(productList);
+        map.put("image", image);
+        map.put("pageInfo", pageInfo);
+        return ResponseJson.success(map);
+    }
+
+    @Override
+    public ResponseJson<HeheProductVo> getProductDetails(Integer productId, Integer userId) {
+        HeheProductVo product = heheMapper.getProduct(productId);
+        if (product == null) {
+            //商品不存在
+            return ResponseJson.error("商品不存在", null);
+        }
+        String[] split = null;
+        //商品标签
+        if (product.getTags() != null) {
+            String tags = product.getTags();
+            tags = tags.replace(" ", ",").replace("、", ",").replace(",", ",");
+            split = tags.split(",");
+            List<String> list = new ArrayList<>();
+            for (String s : split) {
+                if (org.apache.commons.lang3.StringUtils.isNotBlank(s)) {
+                    list.add(s);
+                }
+            }
+            split = list.toArray(new String[list.size()]);
+        }
+        product.setTagsList(split);
+        //商品图片
+        List<String> imageList = secondHandMapper.getImageByProductId(product.getProductId());
+        imageList.forEach(img -> img = ImageUtils.getImageURL("product", img, 0, domain));
+        product.setImageList(imageList);
+        //商品详情
+        ProductDetailInfoPo productDetail = shopMapper.getProductDetailInfo(productId);
+        product.setProductDetail(productDetail);
+        //相关参数
+        List<ProductParameterPo> parametersList = shopMapper.getProductParameters(productId);
+        product.setParametersList(parametersList);
+        // 商城活动
+        Integer activityId = heheMapper.getActivityIdByProductId(product.getProductId());
+        //内部优惠折扣
+        Integer discount = heheMapper.getProductDiscount(product.getProductId(), userId);
+        //税费
+        boolean addTaxFlag = ("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType())));
+        if (activityId != null && activityId > 0) {
+            //活动阶梯
+            List<LadderPriceVo> ladderList = heheMapper.getActivityLadderList(activityId, product.getProductId());
+            if (null != discount && discount > 0 && null != ladderList && ladderList.size() > 0) {
+                ladderList.forEach(ladder -> ladder.setBuyPrice(MathUtil.div(MathUtil.mul(ladder.getBuyPrice(), discount), 100).doubleValue()));
+            }
+            if (addTaxFlag && null != ladderList && ladderList.size() > 0) {
+                ladderList.forEach(ladder->{
+                    BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(ladder.getBuyPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
+                    BigDecimal price = MathUtil.add(ladder.getBuyPrice(), addedValueTax);
+                    ladder.setBuyPrice(price.doubleValue());
+                });
+            }
+            product.setLadderList(ladderList);
+        }
+        setProductInfo(product, userId);
+        return ResponseJson.success(product);
+    }
+
+    public void setProductInfo(HeheProductVo product, Integer userId) {
+        product.setMainImage(ImageUtils.getImageURL("product", product.getMainImage(), 0, domain));
+        // 活动id
+        Integer activityId = heheMapper.getActivityIdByProductId(product.getProductId());
+        // 拼团商品
+        HeheCollageProductPo collageProduct = heheMapper.getCollageProduct(product.getProductId());
+        // 限时特价
+        BigDecimal discountPrice = heheMapper.getDiscountPrice(product.getProductId());
+        if (activityId != null && activityId > 0) {
+            product.setActiveStatus(1);
+            //活动阶梯
+            List<LadderPriceVo> ladderList = heheMapper.getActivityLadderList(activityId, product.getProductId());
+            if (ladderList != null && ladderList.size() > 0) {
+                LadderPriceVo ladder = ladderList.get(0);
+                // 没有起订量概念,默认显示购买1个商品的价格,若第一阶梯为一个商品,则取第一阶梯时间
+                product.setPrice(1 == ladder.getBuyNum() ? new BigDecimal(ladder.getBuyPrice()) : product.getPrice());
+            }
+        } else if (collageProduct != null) {
+            // 拼团价
+            product.setPrice(collageProduct.getPrice());
+            product.setCollageStatus(1);
+            product.setCollageProduct(collageProduct);
+        } else if (discountPrice != null) {
+            // 限时特价
+            product.setPrice(discountPrice);
+            product.setDiscountStatus(1);
+        }
+        Integer discount = heheMapper.getProductDiscount(product.getProductId(), userId);
+        if (null != discount && discount > 0) {
+            product.setPrice(MathUtil.div(MathUtil.mul(product.getPrice(), discount), 100));
+            product.setNormalPrice(MathUtil.div(MathUtil.mul(product.getNormalPrice(), discount), 100));
+        }
+        //税费
+        boolean addTaxFlag = ("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType())));
+        if (addTaxFlag) {
+            BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(product.getPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
+            BigDecimal price = MathUtil.add(product.getPrice(), addedValueTax);
+            product.setPrice(price);
+            if (null != product.getNormalPrice()) {
+                addedValueTax = MathUtil.div(MathUtil.mul(product.getNormalPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100), 2);
+                price = MathUtil.add(product.getNormalPrice(), addedValueTax);
+                product.setNormalPrice(price);
+            }
+        }
+        // 查询用户的注册时间
+        Date registerTime = heheMapper.getUserRegisterTime(userId);
+        String[] productIdArr = {product.getProductId().toString()};
+        // 用户在该商品上可领取的优惠券列表
+        List<HeheCouponVo> couponList = heheMapper.getCouponList(userId, productIdArr, registerTime, null);
+        if (null != userId) {
+            // 用户在该商品上已领取未使用的优惠券列表
+            List<HeheCouponVo> receiveCouponList = heheMapper.getReceiveCouponList(userId, productIdArr, null, 1);
+            couponList.addAll(receiveCouponList);
+        }
+        // 单价满足优惠条件的优惠券列表
+        List<HeheCouponVo> ableCouponList = new ArrayList<>();
+        // 单价不满足优惠条件的优惠券列表
+        List<HeheCouponVo> unableCouponList = new ArrayList<>();
+        if (couponList.size() > 0) {
+            // 有可用优惠券且商品未参与其他活动
+            couponList.forEach(coupon->{
+                if (1 == coupon.getNoThresholdFlag() || MathUtil.compare(product.getPrice(),coupon.getTouchPrice())>0) {
+                    ableCouponList.add(coupon);
+                } else {
+                    unableCouponList.add(coupon);
+                }
+            });
+            if (ableCouponList.size() > 0) {
+                // 根据优惠金额排序,优惠大的排前面
+                ableCouponList.sort(Comparator.comparing(HeheCouponVo::getCouponAmount));
+                HeheCouponVo biggestCoupon = ableCouponList.get(0);
+                // 现价-最大优惠金额=券后价
+                product.setCouponPrice(MathUtil.sub(product.getPrice(), biggestCoupon.getCouponAmount()));
+                // 原价-最大优惠金额=原价券后价
+                product.setNormalCouponPrice(MathUtil.sub(product.getNormalPrice(), biggestCoupon.getCouponAmount()));
+                // 优惠券id
+                product.setCouponId(biggestCoupon.getCouponId());
+                // 券后价标签
+                product.setCouponStatus(1);
+            } else {
+                // 根据优惠条件排序,条件小的排前面
+                unableCouponList.sort((o1, o2) -> o2.getTouchPrice().compareTo(o1.getTouchPrice()));
+                // 优惠券信息
+                product.setCouponStatus(2);
+                HeheCouponVo smallestCoupon = unableCouponList.get(0);
+                product.setCouponInfo("券|满" + smallestCoupon.getTouchPrice() + "元减" + smallestCoupon.getCouponAmount());
+            }
+        }
+    }
+
+
+    /**
+     * 设置楼层相关图片的商品信息
+     */
+    private void setFloorImageProduct(Integer userId, List<FloorImageVo> floorImageList) {
+        Iterator<FloorImageVo> iterator = floorImageList.iterator();
+        while (iterator.hasNext()) {
+            FloorImageVo image = iterator.next();
+            Integer linkType = AppletsLinkUtil.getLinkType(image.getLink());
+            Map<String, Object> linkParam = AppletsLinkUtil.getLinkParam(linkType, image.getLink());
+            image.setLinkType(linkType);
+            image.setLinkParam(linkParam);
+            if (image.getProductId() != null) {
+                // 获取商品及价格
+                HeheProductVo product = heheMapper.getProduct(image.getProductId());
+                if (product != null) {
+                    setProductInfo(product, userId);
+                    // 设置商品主图
+                    image.setImage(ImageUtils.getImageURL("product", product.getMainImage(), 0, domain));
+                    image.setHeheProduct(product);
+                } else {
+                    iterator.remove();
+                }
+            }
+        }
+    }
+
+}

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

@@ -65,14 +65,15 @@ public class PageServiceImpl implements PageService {
 
     /**
      * 获取分类列表
-     *
-     * @param typeSort 分类类型:1产品,2仪器,0全部
+     *  @param typeSort 分类类型:1产品,2仪器,0全部
      * @param source   请求来源:www,crm
+     * @param mallType
      */
     @Override
     @Cacheable(value = "getCommodityClassify", key = "#typeSort +'-'+ #source", unless = "#result == null")
-    public ResponseJson<List<BigTypeVo>> getClassify(Integer typeSort, String source) {
-        List<BigTypeVo> bigTypeList = productTypeMapper.getBigTypeList(typeSort, source);
+    public ResponseJson<List<BigTypeVo>> getClassify(Integer typeSort, String source, Integer mallType) {
+        mallType = null == mallType ? 1 : mallType;
+        List<BigTypeVo> bigTypeList = productTypeMapper.getBigTypeList(typeSort, source, mallType);
         bigTypeList.forEach(bigType -> {
             String caiMeiImage = ImageUtils.getImageURL("caiMeiImage", null, 0, domain);
             bigType.setWwwIcon(StringUtils.isEmpty(bigType.getWwwIcon()) ? caiMeiImage : bigType.getWwwIcon());
@@ -901,7 +902,8 @@ public class PageServiceImpl implements PageService {
      *
      * @param floorContent FloorContentVo
      */
-    private void setFloorLinkType(FloorContentVo floorContent) {
+    @Override
+    public void setFloorLinkType(FloorContentVo floorContent) {
         if (floorContent != null) {
             if (StringUtils.isNotBlank(floorContent.getAdsLink1())) {
                 Integer linkType1 = AppletsLinkUtil.getLinkType(floorContent.getAdsLink1());

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

@@ -11,7 +11,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
-import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
 import java.util.List;
@@ -37,7 +36,7 @@ public class ProductTypeServiceImpl implements ProductTypeService {
      */
     @Override
     public ResponseJson<List<BigTypeVo>> getBigTypeSelect(Integer typeSort) {
-        List<BigTypeVo> bigTypeList = productTypeMapper.getBigTypeList(typeSort,"www");
+        List<BigTypeVo> bigTypeList = productTypeMapper.getBigTypeList(typeSort,"www", mallType);
         return ResponseJson.success(bigTypeList);
     }
 

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

@@ -525,7 +525,7 @@ public class SearchProductServiceImpl implements SearchProductService {
         historyRecord.setSearchDate(new Date());
         historyRecord.setSearchWord(keyword);
         historyRecord.setDelFlag(0);
-        Integer recordId = searchMapper.getHistoryIdByWord(keyword);
+        Integer recordId = searchMapper.getHistoryIdByWord(keyword, userId);
         if (null != recordId && recordId > 0) {
             //更新
             historyRecord.setId(recordId);

+ 297 - 0
src/main/resources/mapper/HeheMapper.xml

@@ -0,0 +1,297 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.caimei365.commodity.mapper.HeheMapper">
+
+    <select id="getHomeTypeList" resultType="java.util.List">
+        select id as bigTypeId, name, icon as crmIcon
+        from hehe_home_type
+        where status = 1
+        order by -sort desc
+        limit 8
+    </select>
+    <select id="getProductList" resultType="com.caimei365.commodity.model.vo.HeheProductVo">
+        SELECT
+        chp.productId,
+        chp.price,
+        chp.price as normalPrice,
+        chp.includedTax,
+        chp.invoiceType,
+        chp.clubTaxPoint,
+        p.name,
+        P.unit,
+        p.mainImage
+        FROM
+        cm_hehe_product chp
+        LEFT JOIN product p ON chp.productId = p.productID
+        <if test="listType == 2">
+            LEFT JOIN hehe_home_type_product hhtp on hhtp.productId = chp.productId
+        </if>
+        <if test="listType == 3">
+            LEFT JOIN new_page_floor_image fi on chp.productId = fi.productId
+        </if>
+        WHERE
+        chp.validFlag = 1
+        <if test="listType != null">
+            <if test="listType == 2 and homeTypeId != null">
+                and hhtp.status = 1 and hhtp.homeTypeId = #{homeTypeId}
+            </if>
+            <if test="listType == 3 and homeFloorId != null">
+                and fi.appletsStatus = 1 and fi.centreId = #{homeFloorId}
+            </if>
+            <if test="listType == 4 and smallTypeId != null">
+                and chp.smallTypeId = #{smallTypeId}
+            </if>
+        </if>
+        <if test="productName != null and productName != ''">
+            AND p.name LIKE CONCAT('%',#{productName},'%')
+        </if>
+        <if test="sortType == 1">
+            and chp.productId not in (#{productIds})
+        </if>
+        <if test="sortType == 1">
+            order by rand()
+        </if>
+        <if test="sortType == 2">
+            order by chp.price
+        </if>
+        <if test="sortType == 3">
+            order by chp.price desc
+        </if>
+        <if test="sortType == 4">
+            order by chp.id desc
+        </if>
+    </select>
+    <select id="getProduct" resultType="com.caimei365.commodity.model.vo.HeheProductVo">
+        SELECT
+            chp.productId,
+            chp.price,
+            chp.price as normalPrice,
+            chp.includedTax,
+            chp.invoiceType,
+            chp.clubTaxPoint,
+            p.name,
+            P.unit,
+            p.mainImage,
+            cb.name as "brandName",
+            P.unit,
+            P.stock,
+            p.tags
+        FROM
+            cm_hehe_product chp
+                LEFT JOIN product p ON chp.productId = p.productID
+                LEFT JOIN cm_brand cb on p.brandID = cb.id
+        WHERE
+            chp.validFlag = 1
+            and chp.productId = #{productId}
+    </select>
+    <select id="getActivityIdByProductId" resultType="java.lang.Integer">
+        SELECT
+            activityId
+        FROM
+            cm_hehe_activity_product a
+                LEFT JOIN cm_hehe_activity cha ON a.activityId = cha.id
+        WHERE
+            cha.delFlag = 0
+          AND a.delFlag = 0
+          AND NOW() BETWEEN cha.beginTime AND cha.endTime
+          AND a.productId = #{productId}
+    </select>
+    <select id="getCollageProduct" resultType="com.caimei365.commodity.model.po.HeheCollageProductPo">
+        select chcp.productId, chcp.price, chcp.limitedNum, chcp.unlimitedFlag, chcp.memberNum
+        from cm_hehe_collage_product chcp
+        where chcp.productId = #{productID} and chcp.status = 1
+    </select>
+    <select id="getActivityLadderList" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
+        SELECT
+            buyNum,
+            buyPrice
+        FROM
+            cm_hehe_activity_ladder
+        WHERE
+            activityId = #{activityId}
+          AND productId = #{productId}
+        ORDER BY
+            ladderNum
+    </select>
+    <select id="getProductDiscount" resultType="java.lang.Integer">
+        select chd.discount
+        from cm_hehe_discount chd
+                 left join cm_hehe_discount_product chdp on chd.id = chdp.discountId
+                 left join cm_hehe_discount_user chdu on chd.id = chdu.discountId
+        where (chd.productType = 1 or chdp.productId = #{productId})
+          and chdu.userId = #{userId}
+        order by chd.discount desc
+        limit 1
+    </select>
+    <select id="getAllProductCouponCount" resultType="java.lang.Integer">
+        select count(*)
+        from cm_hehe_coupon chc
+        where chc.delFlag = 0 and chc.productType = 1
+          and if(startNowFlag = 1, true, NOW() <![CDATA[  >=  ]]> startTime)
+          and if(permanentFlag = 1, true, NOW() <![CDATA[  <=  ]]> endTime)
+    </select>
+    <select id="getPartProductCounponCount" resultType="java.lang.Integer">
+        select count(*)
+        from cm_hehe_coupon chc
+                 left join cm_hehe_coupon_product chcp on chc.id = chcp.couponId
+                 left join cm_hehe_product chp on chcp.productId = chp.id
+        where chc.delFlag = 0 and chc.productType = 2 and chp.productId = #{productId}
+          and if(startNowFlag = 1, true, NOW() <![CDATA[  >=  ]]> startTime)
+          and if(permanentFlag = 1, true, NOW() <![CDATA[  <=  ]]> endTime)
+    </select>
+    <select id="getDiscountPrice" resultType="java.math.BigDecimal">
+        select a.discountPrice
+        from hehe_discount_activity_product a
+                 left join cm_hehe_discount_activity chda on a.activityId = chda.id
+        where a.productId = #{productId}
+          and a.status = 1
+          and NOW() between chda.onlineTime and chda.offlineTime
+    </select>
+    <select id="getCouponList" resultType="com.caimei365.commodity.model.vo.HeheCouponVo">
+        select chc.id as couponId,
+        chcs.id as couponShareId,
+        name as couponName,
+        couponType,
+        productType,
+        couponAmount,
+        touchPrice,
+        noThresholdFlag,
+        0 as useStatus,
+        if(receiveFlag = 1,if(permanentFlag = 1,true,false),false) as permanentFlag,
+        if(receiveFlag = 1 ,if(permanentFlag = 1,null,endTime),
+        <if test="userId  == null or userId == 0">
+            date_add(startTime,interval receivePeriod DAY)
+        </if>
+        <if test="userId > 0">
+            date_add(
+            if(couponType <![CDATA[ <= ]]> 3,
+            if(#{registerTime} <![CDATA[ >= ]]> startTime and if(permanentFlag = 1,true,#{registerTime} <![CDATA[ < ]]> endTime),
+            #{registerTime},startTime),
+            chcs.createTime
+            )
+            ,interval receivePeriod DAY)
+        </if>
+        ) as receivePeriod,
+        if(productType = 2,chcp.productIds,null) as productIds,
+        chc.createDate
+        from cm_hehe_coupon chc
+        left join cm_hehe_coupon_share chcs on chc.id = chcs.shareCouponId
+        left join (select couponId as couponId, group_concat(productId) as productIds
+        from cm_hehe_coupon_product
+        group by couponId
+        ) as  chcp on chc.id = chcp.couponId
+        where chc.delFlag = 0
+        and if(startNowFlag = 1, true, NOW() <![CDATA[  >=  ]]> startTime)
+        <if test="productIdArr != null and productIdArr.length > 0">
+            and (chc.productType = 1
+            <foreach item="productId" index="index" collection="productIdArr" open="" separator=" " close="">
+                or find_in_set(#{productId},productIds)
+            </foreach>)
+        </if>
+        <if test="userId == null or userId == 0">
+            AND couponType not in (2,4,5,6)
+            and if(receiveFlag = 1,
+            if(permanentFlag = 1,true,NOW() <![CDATA[ < ]]> endTime),
+            NOW() <![CDATA[ < ]]> date_add(startTime,interval receivePeriod DAY))
+        </if>
+        <if test="userId > 0">
+            and if(couponType <![CDATA[ <= ]]> 3,
+            chc.id not in (select couponId from cm_hehe_receive_coupon where userId = #{userId} and couponId is not null),
+            chcs.id not in (select couponShareId from cm_hehe_receive_coupon where userId = #{userId} and couponShareId is not null)
+            )
+            and (
+            (couponType = 1
+            or (couponType = 2 and chc.id in (select distinct couponId from cm_hehe_coupon_user where userId = #{userId} and couponId is not null))
+            or (couponType = 3 and #{registerTime} <![CDATA[ >= ]]> startTime and if(permanentFlag = 1,true,#{registerTime} <![CDATA[ < ]]> endTime))
+            or (couponType = 4 and chcs.shareUserId = #{userId})
+            or (couponType = 5 and chcs.shareUserId = #{userId})
+            or (couponType = 6 and chcs.shareUserId = #{userId})
+            )
+            and if(receiveFlag = 1,
+            if(permanentFlag = 1,true,NOW() <![CDATA[ < ]]> endTime),
+            NOW() <![CDATA[ < ]]> date_add(
+            if(couponType <![CDATA[ <= ]]> 3,
+            if(#{registerTime} <![CDATA[ >= ]]> startTime and if(permanentFlag = 1,true,#{registerTime} <![CDATA[ < ]]> endTime),
+            #{registerTime},startTime),
+            chcs.createTime
+            )
+            ,interval receivePeriod DAY))
+            )
+        </if>
+        <if test="couponType != null">
+            and couponType = #{couponType}
+        </if>
+        order by chc.createDate desc
+    </select>
+    <select id="getUserRegisterTime" resultType="java.util.Date">
+        select registerTime from user where userID = #{userId}
+    </select>
+    <select id="getReceiveCouponList" resultType="com.caimei365.commodity.model.vo.HeheCouponVo">
+        select distinct
+        chrc.couponId as couponId,
+        chrc.couponShareId,
+        name as couponName,
+        couponType,
+        productType,
+        couponAmount,
+        touchPrice,
+        noThresholdFlag,
+        date_add(chrc.receiveTime, interval chc.usePeriod DAY) as usePeriod,
+        createDate,
+        if(productType = 2,chcp.productIds,null) as productIds
+        from cm_hehe_receive_coupon chrc left join cm_hehe_coupon chc on chrc.couponId = chc.id
+        left join (select couponId as couponId, group_concat(productId) as productIds
+        from cm_hehe_coupon_product
+        group by couponId) chcp on chrc.couponId = chcp.couponId
+        where chrc.delFlag = 0 and chc.delFlag = 0 and chrc.userId = #{userId}
+        <if test="receiveCouponId != null and receiveCouponId > 0">
+            and chrc.id = #{receiveCouponId}
+        </if>
+        <if test="productIdArr != null and productIdArr.length > 0">
+            and (chc.productType = 1
+            <foreach item="productId" index="index" collection="productIdArr" open="" separator=" " close="">
+                or find_in_set(#{productId},productIds)
+            </foreach>)
+        </if>
+        <if test="status == 1">
+            and chrc.status = 1
+            and NOW() <![CDATA[ <= ]]> date_add(chrc.receiveTime, interval chc.usePeriod DAY)
+            order by chrc.receiveTime desc
+        </if>
+        <if test="status == 2">
+            and chrc.status = 2
+            order by chrc.useTime desc
+        </if>
+        <if test="status == 3">
+            and chrc.status = 1
+            and NOW() <![CDATA[ > ]]> date_add(chrc.receiveTime, interval chc.usePeriod DAY)
+            order by date_add(chrc.receiveTime, interval chc.usePeriod DAY) desc
+        </if>
+    </select>
+    <select id="getActivityList" resultType="com.caimei365.commodity.model.vo.HeHeActivityVo">
+        SELECT
+            cha.id AS activityId,
+            cha.name,
+            cha.listImage,
+            cha.beginTime,
+            cha.endTime,
+            COUNT(chua.id) AS productCount
+        FROM
+            cm_hehe_user_activity chua
+                LEFT JOIN cm_hehe_activity cha ON chua.activityId = cha.id
+        WHERE
+            chua.userId = #{userId}
+          AND cha.delFlag = 0
+          AND cha.status = 1
+          AND cha.beginTime <![CDATA[ <= ]]> NOW()
+          AND cha.endTime <![CDATA[ >= ]]> NOW()
+        GROUP BY
+            cha.id
+        ORDER BY
+            cha.addTime DESC
+    </select>
+    <select id="getActivityImageById" resultType="java.lang.String">
+        SELECT detailsImage FROM cm_hehe_activity WHERE id = #{activityId}
+    </select>
+
+</mapper>

+ 18 - 0
src/main/resources/mapper/PageMapper.xml

@@ -729,5 +729,23 @@
     <select id="getBaikeQuestionList" resultType="java.lang.String">
         select question from cm_baike_product_question where productId = #{productId} limit 3
     </select>
+    <select id="findHeheHomePage" resultType="com.caimei365.commodity.model.vo.CmPageVo">
+        select id,
+               type,
+               title,
+               keywords,
+               description,
+               headImage,
+               crmHeadImage,
+               headLink,
+               headText,
+               redPacketBeginTime,
+               redPacketEndTime,
+               infoBarStatus
+        from cm_page
+        where type = 8
+          and enabledStatus = '1'
+        limit 1
+    </select>
 
 </mapper>

+ 3 - 0
src/main/resources/mapper/ProductTypeMapper.xml

@@ -21,6 +21,9 @@
             <if test="source == 'crm'.toString()">
                 and crmValidFlag = '1'
             </if>
+            <if test="null != mallType">
+                and mallType = #{mallType}
+            </if>
         order by ifnull(sortIndex,10000) , addTime DESC
     </select>
     <select id="getSmallTypeList" resultType="com.caimei365.commodity.model.vo.SmallTypeVo">

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

@@ -440,7 +440,7 @@
     <select id="getHistoryIdByWord" resultType="java.lang.Integer">
         select id
         from user_search_history
-        where searchWord = #{keyword}
+        where searchWord = #{keyword} and userId = #{userId}
         limit 1
     </select>
     <select id="getHistoryCount" resultType="java.lang.Integer">