123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <?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,
- pr.description,
- pr.type,
- pr.mode,
- pr.touchPrice,
- pr.reducedPrice,
- pr.beginTime,
- pr.endTime,
- pr.status,
- prp.productId,
- prp.supplierId as shopId
- from cm_promotions pr
- left join cm_promotions_product prp on pr.id = prp.promotionsId
- where (prp.productId = #{productId} or
- prp.supplierId = (select p.shopID from product p where p.productID = #{productId})
- )
- and (pr.status = 1 or (pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
- and pr.delFlag not in (1,2)
- order by pr.type desc
- limit 1
- </select>
- <select id="getPromotionGifts" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
- select
- cpg.id as id,
- p.productID as productId,
- p.actStatus,
- p.shopID as shopId,
- p.`name` as `name`,
- p.mainImage as image,
- cpg.number as number,
- 0 as price,
- 2 as productType,
- p.price1 as originalPrice,
- p.unit as unit,
- p.validFlag as validFlag,
- p.stock as stock
- from product p
- left join cm_promotions_gift cpg on cpg.productId = p.productID
- 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 productId,
- 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>
- <select id="getPromotionGiftsByProductId" resultType="com.caimei365.commodity.model.vo.PromotionsVo">
- select pr.id,
- pr.name,
- pr.description,
- pr.type,
- pr.mode,
- pr.touchPrice,
- pr.reducedPrice,
- pr.beginTime,
- pr.endTime,
- pr.status,
- cpg.productId
- from cm_promotions pr
- left join cm_promotions_gift cpg on pr.id = cpg.promotionsId
- where cpg.productId = #{productId}
- and (pr.status = 1 or ( pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
- and pr.mode = 3
- and pr.delFlag not in (1,2)
- order by pr.type desc
- limit 1
- </select>
- </mapper>
|