Jelajahi Sumber

bugfix-呵呵商品

Aslee 3 tahun lalu
induk
melakukan
aed9dac53b

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

@@ -12,6 +12,7 @@ import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
@@ -45,24 +46,48 @@ public class HeheApi {
      */
     @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 = "listType", value = "列表类型:1首页搜索商品列表,2首页分类商品列表," +
+                    "3首页楼层商品列表.4二级分类商品列表,5优惠券商品列表,6活动商品列表"),
+            @ApiImplicitParam(required = false, name = "name", value = "搜索商品名称(1)"),
+            @ApiImplicitParam(required = false, name = "homeTypeId", value = "首页分类id(2)"),
+            @ApiImplicitParam(required = false, name = "homeFloorId", value = "首页楼层id(3)"),
+            @ApiImplicitParam(required = false, name = "smallTypeId", value = "二级分类id(4)"),
+            @ApiImplicitParam(required = false, name = "couponId", value = "优惠券id(5)"),
+            @ApiImplicitParam(required = false, name = "activityId", value = "活动id(6)"),
             @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,
+    public ResponseJson<Map<String,Object>> getProductList(Integer listType, Integer homeTypeId, Integer homeFloorId, Integer smallTypeId,
+                                                                    Integer userId, String name, Integer couponId, Integer activityId, 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);
+        if (null == listType) {
+            return ResponseJson.error("列表类型不能为空", null);
+        }
+        if (1 == listType && StringUtils.isEmpty(name)) {
+            return ResponseJson.error("搜索关键词不能为空", null);
+        }
+        if (2 == listType && (null == homeTypeId || 0 == homeTypeId)) {
+            return ResponseJson.error("首页分类id不能为空", null);
+        }
+        if (3 == listType && (null == homeFloorId || 0 == homeFloorId)) {
+            return ResponseJson.error("首页楼层id不能为空", null);
+        }
+        if (4 == listType && (null == smallTypeId || 0 == smallTypeId)) {
+            return ResponseJson.error("二级分类id不能为空", null);
+        }
+        if (5 == listType && (null == couponId || 0 == couponId)) {
+            return ResponseJson.error("优惠券id不能为空", null);
+        }
+        if (6 == listType && (null == activityId || 0 == activityId)) {
+            return ResponseJson.error("活动id不能为空", null);
+        }
+        return heheService.getProductList(listType, homeTypeId, homeFloorId, smallTypeId, couponId, activityId, userId, name, productIds, sortType, pageNum, pageSize);
     }
 
     @ApiOperation("首页楼层数据")
@@ -91,7 +116,7 @@ public class HeheApi {
         return heheService.getActivityList(userId, pageNum, pageSize);
     }
 
-    @ApiOperation("活动详情")
+    /*@ApiOperation("活动详情")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "userId", value = "分销者用户id", required = true),
             @ApiImplicitParam(name = "activityId", value = "活动id", required = true),
@@ -106,7 +131,7 @@ public class HeheApi {
             return ResponseJson.error("参数异常", null);
         }
         return heheService.getActivityDetails(userId, activityId, pageNum, pageSize);
-    }
+    }*/
 
     @ApiOperation("商品详情")
     @ApiImplicitParams({

+ 4 - 5
src/main/java/com/caimei365/commodity/mapper/HeheMapper.java

@@ -1,12 +1,11 @@
 package com.caimei365.commodity.mapper;
 
-import com.caimei365.commodity.model.ResponseJson;
 import com.caimei365.commodity.model.po.HeheCollageProductPo;
+import com.caimei365.commodity.model.po.HeheDiscountPricePo;
 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;
 
@@ -19,9 +18,9 @@ import java.util.List;
 @Mapper
 public interface HeheMapper {
 
-    ResponseJson<List<BigTypeVo>> getHomeTypeList();
+    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);
+    List<HeheProductVo> getProductList(@Param("listType") Integer listType, @Param("homeTypeId") Integer homeTypeId, @Param("homeFloorId") Integer homeFloorId, @Param("smallTypeId") Integer smallTypeId, @Param("couponId") Integer couponId, @Param("activityId") Integer activityId, @Param("productName") String productName, @Param("sortType") Integer sortType, @Param("productIds") String productIds);
 
     Integer getActivityIdByProductId(Integer productId);
 
@@ -35,7 +34,7 @@ public interface HeheMapper {
 
     Integer getPartProductCounponCount(Integer productId);
 
-    BigDecimal getDiscountPrice(Integer productId);
+    HeheDiscountPricePo getDiscountPrice(Integer productId);
 
     /**
      * 查询可领取的优惠券列表

+ 31 - 0
src/main/java/com/caimei365/commodity/model/po/HeheDiscountPricePo.java

@@ -0,0 +1,31 @@
+package com.caimei365.commodity.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2021/12/16
+ */
+@Data
+public class HeheDiscountPricePo implements Serializable {
+    /**
+     * 呵呵商城商品id
+     */
+    private Integer productId;
+
+    /**
+     * 限时特价
+     */
+    private BigDecimal discountPrice;
+
+    /**
+     * 结束时间
+     */
+    private Date offlineTime;
+}

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

@@ -7,6 +7,7 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -107,6 +108,11 @@ public class HeheProductVo implements Serializable {
      */
     private HeheCollageProductPo collageProduct;
 
+    /**
+     * 限时特价结束时间
+     */
+    private Date discountEndTime;
+
     /**
      * 是否含税 0不含税,1含税
      */

+ 3 - 2
src/main/java/com/caimei365/commodity/service/HeheService.java

@@ -20,8 +20,9 @@ public interface HeheService {
 
     /**
      * 获取商品列表
+     * @return
      */
-    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>> getProductList(Integer listType, Integer homeTypeId, Integer homeFloorId, Integer smallTypeId, Integer couponId, Integer activityId, Integer userId, String name, String productIds, Integer sortType, int pageNum, int pageSize);
 
     /**
      * 首页楼层数据
@@ -37,7 +38,7 @@ public interface HeheService {
     /**
      * 活动详情
      */
-    ResponseJson<Map<String, Object>> getActivityDetails(Integer userId, Integer activityId, Integer pageNum, Integer pageSize);
+//    ResponseJson<Map<String, Object>> getActivityDetails(Integer userId, Integer activityId, Integer pageNum, Integer pageSize);
 
     /**
      * 查询商品详情

+ 20 - 27
src/main/java/com/caimei365/commodity/service/impl/HeheServiceImpl.java

@@ -2,10 +2,7 @@ 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.po.*;
 import com.caimei365.commodity.model.vo.*;
 import com.caimei365.commodity.service.HeheService;
 import com.caimei365.commodity.service.PageService;
@@ -53,25 +50,27 @@ public class HeheServiceImpl implements HeheService {
 
     @Override
     public ResponseJson<List<BigTypeVo>> getHomeTypeList() {
-        return heheMapper.getHomeTypeList();
+        List<BigTypeVo> homeTypeList = heheMapper.getHomeTypeList();
+        return ResponseJson.success(homeTypeList);
     }
 
     @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);
+    public ResponseJson<Map<String, Object>> getProductList(Integer listType, Integer homeTypeId, Integer homeFloorId, Integer smallTypeId, Integer couponId, Integer activityId, Integer userId, String name, String productIds, Integer sortType, int pageNum, int pageSize) {
+        // 综合排序时排除掉已查询的商品id,始终取第一页的数据
+        PageHelper.startPage(1 == sortType ? 1 : pageNum, pageSize);
+        List<HeheProductVo> productList = heheMapper.getProductList(listType, homeTypeId, homeFloorId, smallTypeId, couponId, activityId, name, 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) {
+            if (StringUtils.isNotEmpty(name) && userId != null && userId > 0) {
                 //保存并删除大于10条的历史记录
                 SearchHistoryPo historyRecord = new SearchHistoryPo();
                 historyRecord.setUserId(userId);
                 historyRecord.setSearchDate(new Date());
-                historyRecord.setSearchWord(productName);
+                historyRecord.setSearchWord(name);
                 historyRecord.setDelFlag(0);
-                Integer recordId = searchMapper.getHistoryIdByWord(productName, userId);
+                Integer recordId = searchMapper.getHistoryIdByWord(name, userId);
                 if (recordId != null && recordId > 0) {
                     //更新
                     historyRecord.setId(recordId);
@@ -87,7 +86,13 @@ public class HeheServiceImpl implements HeheService {
                 }
             }
         }
-        return ResponseJson.success(page);
+        HashMap<String, Object> map = new HashMap<>();
+        map.put("pageInfo", page);
+        if (6 == listType) {
+            String activityBanner = heheMapper.getActivityImageById(activityId);
+            map.put("activityBanner", activityBanner);
+        }
+        return ResponseJson.success(map);
     }
 
     @Override
@@ -134,19 +139,6 @@ public class HeheServiceImpl implements HeheService {
         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);
@@ -212,7 +204,7 @@ public class HeheServiceImpl implements HeheService {
         // 拼团商品
         HeheCollageProductPo collageProduct = heheMapper.getCollageProduct(product.getProductId());
         // 限时特价
-        BigDecimal discountPrice = heheMapper.getDiscountPrice(product.getProductId());
+        HeheDiscountPricePo discountPrice = heheMapper.getDiscountPrice(product.getProductId());
         if (activityId != null && activityId > 0) {
             product.setActiveStatus(1);
             //活动阶梯
@@ -229,8 +221,9 @@ public class HeheServiceImpl implements HeheService {
             product.setCollageProduct(collageProduct);
         } else if (discountPrice != null) {
             // 限时特价
-            product.setPrice(discountPrice);
+            product.setPrice(discountPrice.getDiscountPrice());
             product.setDiscountStatus(1);
+            product.setDiscountEndTime(discountPrice.getOfflineTime());
         }
         // 内部优惠折扣
         Integer discount = heheMapper.getProductDiscount(product.getProductId(), userId);

+ 1 - 1
src/main/resources/bootstrap.yml

@@ -9,7 +9,7 @@ spring:
     config:                             # Config客户端配置
       profile: @activatedProperties@    # 启用配置后缀名称
       label: master                     # 分支名称
-      # uri: http://localhost:18001
+#      uri: http://192.168.2.92:18001
       # uri: http://47.119.112.46:18001          # 配置中心地址
       uri: http://120.79.162.1:18001          # 配置中心地址(正式环境)
       name: commodity                   # 配置文件名称

+ 17 - 5
src/main/resources/mapper/HeheMapper.xml

@@ -2,7 +2,7 @@
 <!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="getHomeTypeList" resultType="com.caimei365.commodity.model.vo.BigTypeVo">
         select id as bigTypeId, name, icon as crmIcon
         from hehe_home_type
         where status = 1
@@ -24,11 +24,17 @@
         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
+            LEFT JOIN hehe_home_type_product hhtp on chp.productId = hhtp.productId
         </if>
         <if test="listType == 3">
             LEFT JOIN new_page_floor_image fi on chp.productId = fi.productId
         </if>
+        <if test="listType == 5">
+            LEFT JOIN cm_hehe_coupon_product chcp on chp.productId = chcp.productId
+        </if>
+        <if test="listType == 6">
+            LEFT JOIN cm_hehe_activity_product chap on chp.productId = chap.productId
+        </if>
         WHERE
         chp.validFlag = 1
         <if test="listType != null">
@@ -41,11 +47,17 @@
             <if test="listType == 4 and smallTypeId != null">
                 and chp.smallTypeId = #{smallTypeId}
             </if>
+            <if test="listType == 5 and couponId != null">
+                and chcp.couponId = #{couponId}
+            </if>
+            <if test="listType == 6 and activityId != null">
+                and chap.activityId = #{activityId}
+            </if>
         </if>
         <if test="productName != null and productName != ''">
             AND p.name LIKE CONCAT('%',#{productName},'%')
         </if>
-        <if test="sortType == 1">
+        <if test="sortType == 1 and productIds != null and productIds != ''">
             and chp.productId not in (#{productIds})
         </if>
         <if test="sortType == 1">
@@ -139,8 +151,8 @@
           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
+    <select id="getDiscountPrice" resultType="com.caimei365.commodity.model.po.HeheDiscountPricePo">
+        select a.discountPrice, a.productId, chda.offlineTime
         from hehe_discount_activity_product a
                  left join cm_hehe_discount_activity chda on a.activityId = chda.id
         where a.productId = #{productId}

+ 2 - 1
src/main/resources/mapper/ProductTypeMapper.xml

@@ -5,7 +5,7 @@
         select
             bigTypeID as bigTypeId, typeSort, `name`, bigTypeCode, wwwValidFlag, crmValidFlag, wwwIcon, crmIcon, addTime, sortIndex
         from bigtype
-        where
+        <where>
             <if test="typeSort == 1">
                 typeSort = '1'
             </if>
@@ -24,6 +24,7 @@
             <if test="null != mallType">
                 and mallType = #{mallType}
             </if>
+        </where>
         order by ifnull(sortIndex,10000) , addTime DESC
     </select>
     <select id="getSmallTypeList" resultType="com.caimei365.commodity.model.vo.SmallTypeVo">