Browse Source

颜选内部优惠逻辑更改

Aslee 2 years ago
parent
commit
3bf7cd688a

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

@@ -37,7 +37,7 @@ public class HeheApi {
      */
     @ApiOperation("轮播图")
     @GetMapping("/home/carousel")
-    public ResponseJson<List<ImageLinkVo>> getHomeCarousel() {
+    public ResponseJson<List<HeHeImageVo>> getHomeCarousel() {
         return heheService.getHomeCarousel();
     }
 

+ 3 - 2
src/main/java/com/caimei365/commodity/mapper/HeheMapper.java

@@ -28,7 +28,7 @@ public interface HeheMapper {
 
     List<LadderPriceVo> getActivityLadderList(Integer activityId, Integer productId);
 
-    Integer getProductDiscount(Integer productId, Integer userId);
+    HeHeDiscountVo getProductDiscount(Integer productId, Integer userId);
 
     Integer getAllProductCouponCount();
 
@@ -68,6 +68,7 @@ public interface HeheMapper {
 
     /**
      * 查询首页轮播图
+     * @return
      */
-    List<ImageLinkVo> getHomeCarousel();
+    List<HeHeImageVo> getHomeCarousel();
 }

+ 75 - 0
src/main/java/com/caimei365/commodity/model/vo/FloorContentVo.java

@@ -173,4 +173,79 @@ public class FloorContentVo implements Serializable {
      * 链接包含的参数
      */
     private Map<String, Object> linkParam5;
+
+    /**
+     * 跳转商品id1(颜选)
+     */
+    private Integer productId1;
+
+    /**
+     * 跳转商品id2(颜选)
+     */
+    private Integer productId2;
+
+    /**
+     * 跳转商品id3(颜选)
+     */
+    private Integer productId3;
+
+    /**
+     * 跳转商品id4(颜选)
+     */
+    private Integer productId4;
+
+    /**
+     * 跳转商品id5(颜选)
+     */
+    private Integer productId5;
+
+    /**
+     * 跳转图片1(颜选)
+     */
+    private String jumpImage1;
+
+    /**
+     * 跳转图片2(颜选)
+     */
+    private String jumpImage2;
+
+    /**
+     * 跳转图片3(颜选)
+     */
+    private String jumpImage3;
+
+    /**
+     * 跳转图片4(颜选)
+     */
+    private String jumpImage4;
+
+    /**
+     * 跳转图片5(颜选)
+     */
+    private String jumpImage5;
+
+    /**
+     * 跳转类型1(颜选):1链接,2商品,3图片
+     */
+    private Integer jumpType1;
+
+    /**
+     * 跳转类型2(颜选):1链接,2商品,3图片
+     */
+    private Integer jumpType2;
+
+    /**
+     * 跳转类型3(颜选):1链接,2商品,3图片
+     */
+    private Integer jumpType3;
+
+    /**
+     * 跳转类型4(颜选):1链接,2商品,3图片
+     */
+    private Integer jumpType4;
+
+    /**
+     * 跳转类型5(颜选):1链接,2商品,3图片
+     */
+    private Integer jumpType5;
 }

+ 32 - 0
src/main/java/com/caimei365/commodity/model/vo/HeHeDiscountVo.java

@@ -0,0 +1,32 @@
+package com.caimei365.commodity.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/4/27
+ */
+@Data
+public class HeHeDiscountVo implements Serializable {
+    /**
+     * 内部优惠活动id
+     */
+    private Integer discountId;
+
+    /**
+     * 折扣率
+     */
+    private Integer discount;
+
+    /**
+     * 折扣价
+     */
+    private BigDecimal discountPrice;
+}

+ 54 - 0
src/main/java/com/caimei365/commodity/model/vo/HeHeImageVo.java

@@ -0,0 +1,54 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * cm_hehe_image:呵呵商城轮播图
+ *
+ * @author
+ */
+@Data
+public class HeHeImageVo implements Serializable {
+
+    /**
+     * 主题
+     */
+    private String topic;
+
+    /**
+     * 轮播图
+     */
+    private String image;
+
+    /**
+     * 跳转类型:1链接,2商品,3图片
+     */
+    private Integer jumpType;
+
+    /**
+     * 跳转链接
+     */
+    private String jumpLink;
+
+    /**
+     * 跳转商品id
+     */
+    private String jumpProductId;
+
+    /**
+     * 跳转图片
+     */
+    private String jumpImage;
+
+    /** 链接类型 -1未知类型 */
+    private Integer linkType;
+    /**
+     * 链接包含的参数
+     */
+    private Map<String,Object> linkParam;
+
+    private static final long serialVersionUID = 1L;
+}

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

@@ -47,8 +47,9 @@ public interface HeheService {
 
     /**
      * 查询轮播图
+     * @return
      */
-    ResponseJson<List<ImageLinkVo>> getHomeCarousel();
+    ResponseJson<List<HeHeImageVo>> getHomeCarousel();
 
     /**
      * 设置商品详情

+ 51 - 25
src/main/java/com/caimei365/commodity/service/impl/HeheServiceImpl.java

@@ -10,7 +10,6 @@ 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;
@@ -104,12 +103,6 @@ public class HeheServiceImpl implements HeheService {
         }
         // 来源:小程序
         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()) {
@@ -118,7 +111,7 @@ public class HeheServiceImpl implements HeheService {
             if (null == floorContent) {
                 iterator.remove();
             } else {
-                pageService.setFloorLinkType(floorContent);
+                setFloorLinkType(floorContent);
                 Integer limitNum = 6;
                 String templateType = floorContent.getTemplateType();
                 if ("5".equals(templateType) || "9".equals(templateType)) {
@@ -178,16 +171,11 @@ public class HeheServiceImpl implements HeheService {
         product.setParametersList(parametersList);
         // 商城活动id
         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);
@@ -203,8 +191,8 @@ public class HeheServiceImpl implements HeheService {
     }
 
     @Override
-    public ResponseJson<List<ImageLinkVo>> getHomeCarousel() {
-        List<ImageLinkVo> imageList = heheMapper.getHomeCarousel();
+    public ResponseJson<List<HeHeImageVo>> getHomeCarousel() {
+        List<HeHeImageVo> imageList = heheMapper.getHomeCarousel();
         return ResponseJson.success(imageList);
     }
 
@@ -216,6 +204,8 @@ public class HeheServiceImpl implements HeheService {
         HeheCollageProductPo collageProduct = heheMapper.getCollageProduct(product.getProductId());
         // 限时特价
         HeheDiscountPricePo discountPrice = heheMapper.getDiscountPrice(product.getProductId());
+        // 内部优惠折扣
+        HeHeDiscountVo discount = heheMapper.getProductDiscount(product.getProductId(), userId);
         if (activityId != null && activityId > 0) {
             product.setActiveStatus(1);
             //活动阶梯
@@ -235,12 +225,18 @@ public class HeheServiceImpl implements HeheService {
             product.setPrice(discountPrice.getDiscountPrice());
             product.setDiscountStatus(1);
             product.setDiscountEndTime(discountPrice.getOfflineTime());
-        }
-        // 内部优惠折扣
-        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));
+        } else if (discount != null) {
+            BigDecimal price = product.getPrice();
+            // 折扣价
+            BigDecimal disPrice = discount.getDiscountPrice();
+            // 折扣率
+            Integer dis = discount.getDiscount();
+            if (null != disPrice && disPrice.compareTo(BigDecimal.ZERO)>0) {
+                price = disPrice;
+            } else if (null != dis && dis > 0) {
+                price = MathUtil.div(MathUtil.mul(product.getPrice(), dis), 100);
+            }
+            product.setPrice(price);
         }
         //税费
         boolean addTaxFlag = ("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType())));
@@ -320,10 +316,6 @@ public class HeheServiceImpl implements HeheService {
         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());
@@ -339,4 +331,38 @@ public class HeheServiceImpl implements HeheService {
         }
     }
 
+    /**
+     * 设置跳转参数
+     * @param floorContent
+     */
+    private void setFloorLinkType(FloorContentVo floorContent) {
+        if (floorContent != null) {
+            if (null != floorContent.getJumpType1() && 1 == floorContent.getJumpType1() && StringUtils.isNotBlank(floorContent.getAdsLink1())) {
+                Integer linkType1 = AppletsLinkUtil.getLinkType(floorContent.getAdsLink1());
+                floorContent.setLinkType1(linkType1);
+                floorContent.setLinkParam1(AppletsLinkUtil.getLinkParam(linkType1, floorContent.getAdsLink1()));
+            }
+            if (null != floorContent.getJumpType2() && 1 == floorContent.getJumpType2() && StringUtils.isNotBlank(floorContent.getAdsLink2())) {
+                Integer linkType2 = AppletsLinkUtil.getLinkType(floorContent.getAdsLink2());
+                floorContent.setLinkType2(linkType2);
+                floorContent.setLinkParam2(AppletsLinkUtil.getLinkParam(linkType2, floorContent.getAdsLink2()));
+            }
+            if (null != floorContent.getJumpType3() && 1 == floorContent.getJumpType3() && StringUtils.isNotBlank(floorContent.getAdsLink3())) {
+                Integer linkType3 = AppletsLinkUtil.getLinkType(floorContent.getAdsLink3());
+                floorContent.setLinkType3(linkType3);
+                floorContent.setLinkParam3(AppletsLinkUtil.getLinkParam(linkType3, floorContent.getAdsLink3()));
+            }
+            if (null != floorContent.getJumpType4() && 1 == floorContent.getJumpType4() && StringUtils.isNotBlank(floorContent.getAdsLink4())) {
+                Integer linkType4 = AppletsLinkUtil.getLinkType(floorContent.getAdsLink4());
+                floorContent.setLinkType4(linkType4);
+                floorContent.setLinkParam4(AppletsLinkUtil.getLinkParam(linkType4, floorContent.getAdsLink4()));
+            }
+            if (null != floorContent.getJumpType5() && 1 == floorContent.getJumpType5() && StringUtils.isNotBlank(floorContent.getAdsLink5())) {
+                Integer linkType3 = AppletsLinkUtil.getLinkType(floorContent.getAdsLink3());
+                floorContent.setLinkType3(linkType3);
+                floorContent.setLinkParam3(AppletsLinkUtil.getLinkParam(linkType3, floorContent.getAdsLink3()));
+            }
+        }
+    }
+
 }

+ 12 - 11
src/main/resources/mapper/HeheMapper.xml

@@ -125,8 +125,8 @@
         ORDER BY
             ladderNum
     </select>
-    <select id="getProductDiscount" resultType="java.lang.Integer">
-        select chd.discount
+    <select id="getProductDiscount" resultType="com.caimei365.commodity.model.vo.HeHeDiscountVo">
+        select chd.id as discountId, chd.discount,if(chd.productType = 2,chdp.discountPrice,null) as discountPrice
         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
@@ -305,15 +305,16 @@
     <select id="getActivityImageById" resultType="java.lang.String">
         SELECT detailsImage FROM cm_hehe_activity WHERE id = #{activityId}
     </select>
-    <select id="getHomeCarousel" resultType="com.caimei365.commodity.model.vo.ImageLinkVo">
-        SELECT
-            image,link
-        FROM
-            cm_hehe_image
-        WHERE
-            status = 1
-        ORDER BY
-            - sort DESC
+    <select id="getHomeCarousel" resultType="com.caimei365.commodity.model.vo.HeHeImageVo">
+        SELECT topic,
+               image,
+               jumpType,
+               jumpLink,
+               jumpProductId,
+               jumpImage
+        FROM cm_hehe_image
+        WHERE status = 1
+        ORDER BY - sort DESC
     </select>
 
 </mapper>

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

@@ -110,7 +110,22 @@
                adsLink5,
                displayDate1,
                displayDate2,
-               displayDate3
+               displayDate3,
+               productId1,
+               productId2,
+               productId3,
+               productId4,
+               productId5,
+               jumpImage1,
+               jumpImage2,
+               jumpImage3,
+               jumpImage4,
+               jumpImage5,
+               jumpType1,
+               jumpType2,
+               jumpType3,
+               jumpType4,
+               jumpType5
         from new_page_floor_content
         where centreId = #{id}
     </select>
@@ -736,7 +751,8 @@
         order by -sort desc,addTime desc
     </select>
     <select id="getBaikeProducts" resultType="com.caimei365.commodity.model.vo.BaikeProductVo">
-        select id as productId, commodityType, image, name, discription, publishTime, (basePv + actualPv) as pv
+        select id as productId, commodityType, image, name, discription, publishTime,
+               (ifnull(basePv,0) + ifnull(actualPv,0)) as pv
         from cm_baike_product
         <where>
             status = 1 and NOW() > publishTime and delFlag = 0 and auditStatus = 2 and onlineStatus = 2

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

@@ -412,6 +412,7 @@
             a.enabledStatus = 1
             and a.auditStatus = 2
             and a.onlineStatus = 2
+            and a.delFlag = 0
             <if test="articleId != null">
                 and a.id = #{articleId}
             </if>