chao 4 年 前
コミット
925c2bd269

+ 91 - 0
src/main/java/com/caimei365/commodity/controller/PromotionsApi.java

@@ -0,0 +1,91 @@
+package com.caimei365.commodity.controller;
+
+import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.search.ProductListVo;
+import com.caimei365.commodity.model.vo.CartItemVo;
+import com.caimei365.commodity.model.vo.ImageLinkVo;
+import com.caimei365.commodity.model.vo.PromotionsVo;
+import com.caimei365.commodity.service.PromotionsService;
+import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.Api;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 促销活动API
+ *
+ * @author : Charles
+ * @date : 2021/4/9
+ */
+@Api(tags="促销活动API")
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/promotions")
+public class PromotionsApi {
+    private final PromotionsService promotionsService;
+    /**
+     * 专题活动列表数据
+     *
+     * spi旧接口:/promotions/list
+     *
+     * @param source 来源
+     */
+    @GetMapping("/list")
+    @ResponseBody
+    public ResponseJson<PageInfo<ImageLinkVo>> getPromotionsList(Integer source,
+                                                                 @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                                 @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+        return promotionsService.getPromotionsList(source, pageNum, pageSize);
+    }
+
+    /**
+     * 获取促销活动详情
+     *
+     * spi旧接口:/product/promotion/info
+     *
+     * @param promotionsId 促销活动Id
+     */
+    @GetMapping("/info")
+    public ResponseJson<PromotionsVo> promotionDetails(Integer promotionsId) {
+        if (null == promotionsId) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return promotionsService.getPromotionDetails(promotionsId);
+    }
+
+    /**
+     * 获取促销活动凑单商品
+     *
+     * spi旧接口:/product/promotion/products
+     *
+     * @param promotionsId 促销活动Id
+     * @param identity     用户身份
+     */
+    @GetMapping("/product")
+    public ResponseJson<PageInfo<ProductListVo>> promotionProduct(Integer promotionsId,
+                                                               @RequestParam(value = "identity", defaultValue = "0") Integer identity,
+                                                               @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                               @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+        if (null == promotionsId) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return promotionsService.getPromotionProduct(promotionsId, identity, pageNum, pageSize);
+    }
+
+    /**
+     * 获取赠品
+     *
+     * spi旧接口:/product/promotion/gifts
+     *
+     * @param promotionsId 促销活动Id
+     */
+    @GetMapping("/gifts")
+    public ResponseJson<List<CartItemVo>> getPromotionGifts(Integer promotionsId) {
+        if (null == promotionsId) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return promotionsService.getPromotionGifts(promotionsId);
+    }
+}

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

@@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
  * @author : Charles
  * @date : 2021/4/6
  */
-@Api(tags="更新搜索索引API")
+@Api(tags="搜索索引更新API")
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/commodity/search/index")

+ 17 - 3
src/main/java/com/caimei365/commodity/mapper/PromotionsMapper.java

@@ -1,8 +1,11 @@
 package com.caimei365.commodity.mapper;
 
+import com.caimei365.commodity.model.search.ProductListVo;
 import com.caimei365.commodity.model.vo.CartItemVo;
+import com.caimei365.commodity.model.vo.ImageLinkVo;
 import com.caimei365.commodity.model.vo.PromotionsVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -15,12 +18,23 @@ import java.util.List;
 @Mapper
 public interface PromotionsMapper {
     /**
-     * 获取促销商品信息
+     * 通过Id获取促销活动详情
+     */
+    PromotionsVo getPromotionsById(Integer promotionsId);
+    /**
+     * 通过商品Id获取促销信息
      */
     PromotionsVo getPromotionsByProductId(Integer productId);
     /**
      * 获取促销赠品
      */
-    List<CartItemVo> getProductGifts(Integer promotionsId);
-
+    List<CartItemVo> getPromotionGifts(Integer promotionsId);
+    /**
+     * 专题活动列表数据
+     */
+    List<ImageLinkVo> getPromotionsList(Integer source);
+    /**
+     * 获取促销活动所有凑单商品
+     */
+    List<ProductListVo> getProductListByPromotions(Integer promotionsId, @Param("visibilityList") List<Integer> visibilityList);
 }

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

@@ -0,0 +1,45 @@
+package com.caimei365.commodity.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Map;
+
+/**
+ * 图片链接
+ *
+ * @author : Charles
+ * @date : 2021/4/9
+ */
+@Data
+public class ImageLinkVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	private Integer id;
+	private Integer status;
+	private String title;
+	private String detail;
+	private String link;
+	/** 小程序链接 */
+	private String crmLink;
+	/** 小程序标题 */
+	private String crmTitle;
+	/** 小程序图片 */
+	private String crmImage;
+	private String image;
+	/** 活动开始时间 */
+	private Date beginTime;
+	/** 活动开始时间 */
+	private Date endTime;
+	/** 链接类型 -1未知类型 1二级页面 2项目仪器 3直播页面 4自由页面 5商品详情 6项目仪器详情
+	 * 7供应商主页 8专题活动页 9二手市场介绍 10二手商品列表 11二手商品发布 12商品搜索 13信息详情
+	 * 14品牌招商介绍页 15维修保养介绍页 16首页 17注册页 18信息中心 19供应商列表*/
+	private Integer linkType;
+    /**
+     * 链接包含的参数
+     */
+    private Map<String,Object> linkParam;
+
+}
+

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

@@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
 
 import java.io.Serializable;
-import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 

+ 44 - 0
src/main/java/com/caimei365/commodity/service/PromotionsService.java

@@ -0,0 +1,44 @@
+package com.caimei365.commodity.service;
+
+import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.search.ProductListVo;
+import com.caimei365.commodity.model.vo.CartItemVo;
+import com.caimei365.commodity.model.vo.ImageLinkVo;
+import com.caimei365.commodity.model.vo.PromotionsVo;
+import com.github.pagehelper.PageInfo;
+
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/4/9
+ */
+public interface PromotionsService {
+    /**
+     * 专题活动列表数据
+     *
+     * @param  source 来源
+     * @return List<PromotionsVo>
+     */
+    ResponseJson<PageInfo<ImageLinkVo>> getPromotionsList(Integer source, int pageNum, int pageSize);
+    /**
+     * 获取促销活动详情
+     *
+     * @param promotionsId 促销活动Id
+     */
+    ResponseJson<PromotionsVo> getPromotionDetails(Integer promotionsId);
+    /**
+     * 获取促销活动凑单商品
+     *
+     * @param promotionsId 促销活动id
+     */
+    ResponseJson<PageInfo<ProductListVo>> getPromotionProduct(Integer promotionsId, Integer identity, int pageNum, int pageSize);
+    /**
+     * 详情-获取赠品
+     *
+     * @param promotionsId 促销活动Id
+     */
+    ResponseJson<List<CartItemVo>> getPromotionGifts(Integer promotionsId);
+}

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

@@ -145,7 +145,7 @@ public class PriceServiceImpl implements PriceService {
                 price.setLadderPriceFlag(0);
                 if (promotions.getMode() == 3) {
                     // 获取赠品
-                    List<CartItemVo> giftList = promotionsMapper.getProductGifts(promotions.getId());
+                    List<CartItemVo> giftList = promotionsMapper.getPromotionGifts(promotions.getId());
                     promotions.setGiftList(giftList);
                 }
                 if (promotions.getType() == 1 && promotions.getMode() == 1 && null != promotions.getTouchPrice()) {

+ 125 - 0
src/main/java/com/caimei365/commodity/service/impl/PromotionsServiceImpl.java

@@ -0,0 +1,125 @@
+package com.caimei365.commodity.service.impl;
+
+import com.caimei365.commodity.mapper.PromotionsMapper;
+import com.caimei365.commodity.model.ResponseJson;
+import com.caimei365.commodity.model.search.ProductListVo;
+import com.caimei365.commodity.model.vo.CartItemVo;
+import com.caimei365.commodity.model.vo.ImageLinkVo;
+import com.caimei365.commodity.model.vo.PromotionsVo;
+import com.caimei365.commodity.service.PromotionsService;
+import com.caimei365.commodity.utils.AppletsLinkUtil;
+import com.caimei365.commodity.utils.ImageUtils;
+import com.caimei365.commodity.utils.PriceUtil;
+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.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/4/9
+ */
+@Slf4j
+@Service
+public class PromotionsServiceImpl implements PromotionsService {
+    @Value("${caimei.wwwDomain}")
+    private String domain;
+    @Resource
+    private PromotionsMapper promotionsMapper;
+    /**
+     * 专题活动列表数据
+     *
+     * @param source   来源
+     * @return List<PromotionsVo>
+     */
+    @Override
+    public ResponseJson<PageInfo<ImageLinkVo>> getPromotionsList(Integer source, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        List<ImageLinkVo> promotionsList = promotionsMapper.getPromotionsList(source);
+        if (!CollectionUtils.isEmpty(promotionsList)) {
+            promotionsList.forEach(item -> {
+                //链接类型获取
+                if (StringUtils.isNotEmpty(item.getLink())) {
+                    item.setLinkType(AppletsLinkUtil.getLinkType(item.getLink()));
+                    item.setLinkParam(AppletsLinkUtil.getLinkParam(item.getLinkType(), item.getLink()));
+                }
+            });
+        }
+        PageInfo<ImageLinkVo> pageInfo = new PageInfo(promotionsList);
+        return ResponseJson.success(pageInfo);
+    }
+
+    /**
+     * 获取促销活动详情
+     *
+     * @param promotionsId 促销活动Id
+     * @return PromotionsVo
+     */
+    @Override
+    public ResponseJson<PromotionsVo> getPromotionDetails(Integer promotionsId) {
+        PromotionsVo promotions = promotionsMapper.getPromotionsById(promotionsId);
+        if (null != promotions) {
+            List<CartItemVo> productGifts = promotionsMapper.getPromotionGifts(promotionsId);
+            productGifts.forEach(p -> {
+                p.setImage(ImageUtils.getImageURL("product", p.getImage(), 0, domain));
+            });
+            promotions.setGiftList(productGifts);
+        }
+        return ResponseJson.success(promotions);
+    }
+
+    /**
+     * 获取促销活动凑单商品
+     *
+     * @param promotionsId 促销活动id
+     * @param identity
+     * @param pageNum
+     * @param pageSize
+     */
+    @Override
+    public ResponseJson<PageInfo<ProductListVo>> getPromotionProduct(Integer promotionsId, Integer identity, int pageNum, int pageSize) {
+        // identity: 0个人,1协销,2会员机构,3供应商,4普通机构 ||| visibility:3:所有人可见,2:普通机构可见,1:会员机构可见
+        List<Integer> visibilityList = new ArrayList<>();
+        if (identity == 1 || identity == 2) {
+            // 协销 | 会员机构 | 综合供应商
+            visibilityList.addAll(Arrays.asList(1,2,3));
+        } else if (identity == 4) {
+            // 普通机构
+            visibilityList.addAll(Arrays.asList(2,3));
+        } else {
+            // 游客|所有人
+            visibilityList.add(3);
+        }
+        PageHelper.startPage(pageNum, pageSize);
+        List<ProductListVo> list = promotionsMapper.getProductListByPromotions(promotionsId, visibilityList);
+        // 设置价格等级 及 老图片路径
+        list.forEach(product -> {
+            product.setPriceGrade(PriceUtil.getpriceGrade(product.getPrice()));
+            product.setPrice(0d);
+            product.setImage(ImageUtils.getImageURL("product", product.getImage(), 0, domain));
+        });
+        PageInfo<ProductListVo> pageInfo = new PageInfo(list);
+        return ResponseJson.success(pageInfo);
+    }
+
+    /**
+     * 详情-获取赠品
+     *
+     * @param promotionsId 促销活动Id
+     */
+    @Override
+    public ResponseJson<List<CartItemVo>> getPromotionGifts(Integer promotionsId) {
+        List<CartItemVo> list = promotionsMapper.getPromotionGifts(promotionsId);
+        return ResponseJson.success(list);
+    }
+}

+ 238 - 0
src/main/java/com/caimei365/commodity/utils/AppletsLinkUtil.java

@@ -0,0 +1,238 @@
+package com.caimei365.commodity.utils;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+/**
+ * 小程序链接工具类
+ *
+ * @author : Charles
+ * @date : 2021/4/9
+ */
+@Slf4j
+public class AppletsLinkUtil {
+    /**
+     * 1二级页面
+     */
+    public static final Pattern pattern1 = Pattern.compile("/cmpage/info-1");
+    public static final Pattern pattern34 = Pattern.compile("/topic.html");
+    /**
+     * 2项目仪器详情
+     */
+    public static final Pattern pattern2 = Pattern.compile("/cmpage/info-2");
+    public static final Pattern pattern6 = Pattern.compile("equipment/detail");
+    /**
+     * 3直播页面
+     */
+    public static final Pattern pattern3 = Pattern.compile("/cmpage/info-3");
+    public static final Pattern pattern36 = Pattern.compile("wx.vzan.com");
+    /**
+     * 4自由页面
+     */
+    public static final Pattern pattern4 = Pattern.compile("/cmpage/info-4");
+    public static final Pattern pattern33 = Pattern.compile("page.html");
+    /**
+     * 5商品详情
+     */
+    public static final Pattern pattern5 = Pattern.compile("/product-");
+
+    /**
+     * 7供应商主页
+     */
+    public static final Pattern pattern7 = Pattern.compile("supplier/prolist");
+    public static final Pattern pattern8 = Pattern.compile("supplier/index.html");
+    public static final Pattern pattern9 = Pattern.compile("view/supplierHomePage.jsp");
+    public static final Pattern pattern10 = Pattern.compile("supplier/productlist-");
+    /**
+     * 8专题活动页
+     */
+    public static final Pattern pattern11 = Pattern.compile("promotions.html");
+    public static final Pattern pattern12 = Pattern.compile("cmpage/area.html");
+    /**
+     * 9二手市场介绍
+     */
+    public static final Pattern pattern13 = Pattern.compile("html/secondHand/introduction.jsp");
+    public static final Pattern pattern14 = Pattern.compile("flea-market/intro.html");
+    /**
+     * 10二手商品列表
+     */
+    public static final Pattern pattern15 = Pattern.compile("html/secondHand/secondList.jsp");
+    public static final Pattern pattern16 = Pattern.compile("flea-market/list.html");
+    /**
+     * 11二手商品发布
+     */
+    public static final Pattern pattern17 = Pattern.compile("html/maintenance/view/secondtransactions.jsp");
+    public static final Pattern pattern18 = Pattern.compile("flea-market/form.html");
+    /**
+     * 12商品搜索
+     */
+    public static final Pattern pattern19 = Pattern.compile("product/search.shtml");
+    public static final Pattern pattern20 = Pattern.compile("product/search/list");
+    public static final Pattern pattern21 = Pattern.compile("product/list.html");
+    /**
+     * 13信息详情
+     */
+    public static final Pattern pattern22 = Pattern.compile("info/detail");
+    /**
+     * 14品牌招商介绍页
+     */
+    public static final Pattern pattern23 = Pattern.compile("html/InvestmentCaiMei/investmentpage.jsp");
+    public static final Pattern pattern24 = Pattern.compile("investment.html");
+    /**
+     * 15维修保养介绍页
+     */
+    public static final Pattern pattern25 = Pattern.compile("html/maintenance/view/mt-entry-index.jsp");
+    public static final Pattern pattern26 = Pattern.compile("repair.html");
+    /**
+     * 16首页
+     */
+    public static final Pattern pattern27 = Pattern.compile("index.action");
+    public static final Pattern pattern28 = Pattern.compile("index.html");
+    /**
+     * 17注册页
+     */
+    public static final Pattern pattern29 = Pattern.compile("web/login/view/register_new_vip.jsp");
+    public static final Pattern pattern30 = Pattern.compile("register.html");
+    /**
+     * 18信息中心
+     */
+    public static final Pattern pattern31 = Pattern.compile("info/center");
+    /**
+     * 19供应商列表
+     */
+    public static final Pattern pattern32 = Pattern.compile("supplier/list.html");
+    /**
+     * 20分类详情
+     */
+    public static final Pattern pattern35 = Pattern.compile("/cmpage/info-5");
+    /**
+     * 21美博会专题页
+     */
+    public static final Pattern pattern37 = Pattern.compile("/beautytopic");
+    /**
+     * 22美体会专题页
+     */
+    public static final Pattern pattern38 = Pattern.compile("/cmpage/info-5-301");
+
+    /**
+     * 根据链接判断链接类型
+     *
+     * @param link
+     * @return
+     */
+    public static Integer getLinkType(String link) {
+        if (StringUtils.isNotEmpty(link)) {
+            if (pattern1.matcher(link).find() || pattern34.matcher(link).find()) {
+                return 1;
+            } else if (pattern2.matcher(link).find() || pattern6.matcher(link).find()) {
+                return 2;
+            } else if (pattern3.matcher(link).find() || pattern36.matcher(link).find()) {
+                return 3;
+            } else if (pattern4.matcher(link).find() || pattern33.matcher(link).find()) {
+                return 4;
+            } else if (pattern5.matcher(link).find()) {
+                return 5;
+            } else if (pattern7.matcher(link).find() || pattern8.matcher(link).find() || pattern9.matcher(link).find() || pattern10.matcher(link).find()) {
+                return 7;
+            } else if (pattern11.matcher(link).find() || pattern12.matcher(link).find()) {
+                return 8;
+            } else if (pattern13.matcher(link).find() || pattern14.matcher(link).find()) {
+                return 9;
+            } else if (pattern15.matcher(link).find() || pattern16.matcher(link).find()) {
+                return 10;
+            } else if (pattern17.matcher(link).find() || pattern18.matcher(link).find()) {
+                return 11;
+            } else if (pattern19.matcher(link).find() || pattern20.matcher(link).find() || pattern21.matcher(link).find()) {
+                return 12;
+            } else if (pattern22.matcher(link).find()) {
+                return 13;
+            } else if (pattern23.matcher(link).find() || pattern24.matcher(link).find()) {
+                return 14;
+            } else if (pattern25.matcher(link).find() || pattern26.matcher(link).find()) {
+                return 15;
+            } else if (pattern27.matcher(link).find() || pattern28.matcher(link).find()) {
+                return 16;
+            } else if (pattern29.matcher(link).find() || pattern30.matcher(link).find()) {
+                return 17;
+            } else if (pattern31.matcher(link).find()) {
+                return 18;
+            } else if (pattern32.matcher(link).find()) {
+                return 19;
+            } else if (pattern35.matcher(link).find()) {
+                if (pattern38.matcher(link).find()) {
+                    return 22;
+                }
+                return 20;
+            } else if (pattern37.matcher(link).find()) {
+                return 21;
+            } else {
+                return -1;
+            }
+        } else {
+            return -1;
+        }
+    }
+
+    /**
+     * 根据链接获取链接中携带的参数
+     *
+     * @param linkType
+     * @param link
+     * @return
+     */
+    public static Map<String, Object> getLinkParam(Integer linkType, String link) {
+        HashMap<String, Object> map = new HashMap<>();
+        String[] idArr = link.split("/");
+        String[] split1 = null;
+        String[] split2 = null;
+        String[] split3 = null;
+        if (idArr.length > 0) {
+            split1 = idArr[idArr.length - 1].split("-");
+            split2 = idArr[idArr.length - 1].split("=");
+            if (split1.length > 0) {
+                split3 = split1[split1.length - 1].split("\\.");
+            }
+        }
+        if (linkType == 3 || linkType == 5 || linkType == 20 || linkType == 22) {
+            //-{id}.html
+            if (split3 != null && split3.length == 2) {
+                map.put("id", split3[0]);
+            }
+        } else if (linkType == 1 || linkType == 2 || linkType == 4 || linkType == 7) {
+            if (pattern1.matcher(link).find() || pattern2.matcher(link).find() || pattern4.matcher(link).find() || pattern7.matcher(link).find() || pattern10.matcher(link).find()) {
+                //-{id}.html
+                if (split3 != null && split3.length == 2) {
+                    map.put("id", split3[0]);
+                }
+            } else if (pattern6.matcher(link).find() || pattern33.matcher(link).find() || pattern8.matcher(link).find() || pattern9.matcher(link).find() || pattern34.matcher(link).find()) {
+                //id={id}
+                if (split2 != null && split2.length == 2) {
+                    map.put("id", split2[1]);
+                }
+            }
+        } else if (linkType == 13 || linkType == 18) {
+            //a-{id}-b
+            if (split1 != null && split1.length == 3) {
+                map.put("id", split1[1]);
+            }
+        } else if (linkType == 12 || linkType == 19) {
+            //keyword=
+            if (split2 != null && split2.length == 2) {
+                String keyword = split2[1];
+                try {
+                    keyword = URLDecoder.decode(keyword, "UTF-8");
+                } catch (UnsupportedEncodingException e) {
+                    log.error("try-catch:",e);
+                }
+                map.put("keyword", keyword);
+            }
+        }
+        return map;
+    }
+}

+ 68 - 1
src/main/resources/mapper/PromotionsMapper.xml

@@ -1,6 +1,25 @@
 <?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.PromotionsMapper">
+    <select id="getPromotionsById" resultType="com.caimei365.commodity.model.vo.PromotionsVo">
+        select
+          id,
+          name,
+          description,
+          type,
+          mode,
+          touchPrice,
+          reducedPrice,
+          beginTime,
+          endTime,
+          status
+        from
+          cm_promotions
+        where
+          id = #{promotionsId}
+          and (status = 1 or (status = 2 and (NOW() between beginTime and endTime)))
+          and delFlag not in (1,2)
+    </select>
     <select id="getPromotionsByProductId" resultType="com.caimei365.commodity.model.vo.PromotionsVo">
         select pr.id,
                pr.name,
@@ -24,7 +43,7 @@
         order by pr.type desc
         limit 1
     </select>
-    <select id="getProductGifts" resultType="com.caimei365.commodity.model.vo.CartItemVo">
+    <select id="getPromotionGifts" resultType="com.caimei365.commodity.model.vo.CartItemVo">
 		select
 			cpg.id as id,
 			p.productID as productId,
@@ -43,4 +62,52 @@
 		where cpg.promotionsId = #{promotionsId}
 		order by cpg.addTime desc
     </select>
+    <select id="getPromotionsList" resultType="com.caimei365.commodity.model.vo.ImageLinkVo">
+        select  a.id as id,
+                a.title as title,
+                a.link as link,
+                a.image as image,
+                a.beginTime as beginTime,
+                a.endTime as endTime,
+                a.appletsImage as crmImage,
+                a.appletsLink as crmLink,
+                (case
+                when a.beginTime>NOW() and <![CDATA[a.beginTime < a.endTime ]]> then 1
+                when <![CDATA[a.beginTime<NOW()]]> and a.endTime >NOW() and <![CDATA[a.beginTime < a.endTime ]]> then 2
+                else 3 end) as status,
+                (case
+                when a.beginTime>NOW() and <![CDATA[a.beginTime < a.endTime ]]>  then concat(DATE_FORMAT(a.beginTime,'%Y-%m-%d'),'~',DATE_FORMAT(a.endTime,'%Y-%m-%d'))
+                when <![CDATA[a.beginTime<NOW()]]> and a.endTime >NOW() and <![CDATA[a.beginTime < a.endTime ]]> then concat(DATE_FORMAT(a.beginTime,'%Y-%m-%d'),'~',DATE_FORMAT(a.endTime,'%Y-%m-%d'))
+                else null end) as detail
+        from cm_page_image a
+        where a.type=4
+        <choose>
+            <when test="source == 2">
+                and a.appletsEnabledStatus = 1
+            </when>
+            <otherwise>
+                and a.enabledStatus = 1
+            </otherwise>
+        </choose>
+        order by case when <![CDATA[status<3]]> then 0 when status>=3 then 1 end asc,a.sort desc,a.createDate desc
+    </select>
+    <select id="getProductListByPromotions" resultType="com.caimei365.commodity.model.search.ProductListVo">
+		select
+			p.productID as id,
+			p.`name` as `name`,
+			p.mainImage as image,
+			p.price1 as price,
+			p.unit as unit,
+			p.price1TextFlag as priceFlag,
+            IFNULL(p.visibility,3) as visibility
+		from product p
+		left join cm_promotions_product cpp on cpp.productId = p.productID
+        where cpp.promotionsId = #{promotionsId}
+        and p.visibility in
+        <foreach collection="visibilityList" item="visibility" index="index" open="(" separator="," close=")">
+            #{visibility}
+        </foreach>
+        and p.validFlag = 2
+        order by p.productID desc
+    </select>
 </mapper>