|
@@ -2,23 +2,20 @@
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<!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">
|
|
<mapper namespace="com.caimei365.commodity.mapper.PromotionsMapper">
|
|
<select id="getPromotionsById" resultType="com.caimei365.commodity.model.vo.PromotionsVo">
|
|
<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}
|
|
|
|
|
|
+ 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 (status = 1 or (status = 2 and (NOW() between beginTime and endTime)))
|
|
- and delFlag not in (1,2)
|
|
|
|
|
|
+ and delFlag not in (1, 2)
|
|
</select>
|
|
</select>
|
|
<select id="getPromotionsByProductId" resultType="com.caimei365.commodity.model.vo.PromotionsVo">
|
|
<select id="getPromotionsByProductId" resultType="com.caimei365.commodity.model.vo.PromotionsVo">
|
|
select pr.id,
|
|
select pr.id,
|
|
@@ -33,54 +30,55 @@
|
|
pr.status,
|
|
pr.status,
|
|
prp.productId,
|
|
prp.productId,
|
|
prp.supplierId as shopId,
|
|
prp.supplierId as shopId,
|
|
- pr.seen as promotionsSeen
|
|
|
|
|
|
+ pr.seen as seen
|
|
from cm_promotions pr
|
|
from cm_promotions pr
|
|
left join cm_promotions_product prp on pr.id = prp.promotionsId
|
|
left join cm_promotions_product prp on pr.id = prp.promotionsId
|
|
where (prp.productId = #{productId} or
|
|
where (prp.productId = #{productId} or
|
|
prp.supplierId = (select p.shopID from product p where p.productID = #{productId})
|
|
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.status = 1 or (pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
|
|
- and pr.delFlag not in (1,2)
|
|
|
|
|
|
+ and pr.delFlag not in (1, 2)
|
|
order by pr.type desc
|
|
order by pr.type desc
|
|
limit 1
|
|
limit 1
|
|
</select>
|
|
</select>
|
|
<select id="getPromotionGifts" resultType="com.caimei365.commodity.model.vo.ProductItemVo">
|
|
<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 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>
|
|
<select id="getPromotionsList" resultType="com.caimei365.commodity.model.vo.ImageLinkVo">
|
|
<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
|
|
|
|
|
|
+ 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
|
|
from cm_page_image a
|
|
where a.type=4
|
|
where a.type=4
|
|
<choose>
|
|
<choose>
|
|
@@ -94,16 +92,16 @@
|
|
order by case when <![CDATA[status<3]]> then 0 when status>=3 then 1 end asc,a.sort desc,a.createDate desc
|
|
order by case when <![CDATA[status<3]]> then 0 when status>=3 then 1 end asc,a.sort desc,a.createDate desc
|
|
</select>
|
|
</select>
|
|
<select id="getProductListByPromotions" resultType="com.caimei365.commodity.model.search.ProductListVo">
|
|
<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
|
|
|
|
|
|
+ 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}
|
|
where cpp.promotionsId = #{promotionsId}
|
|
and p.visibility in
|
|
and p.visibility in
|
|
<foreach collection="visibilityList" item="visibility" index="index" open="(" separator="," close=")">
|
|
<foreach collection="visibilityList" item="visibility" index="index" open="(" separator="," close=")">
|
|
@@ -125,12 +123,18 @@
|
|
pr.status,
|
|
pr.status,
|
|
cpg.productId
|
|
cpg.productId
|
|
from cm_promotions pr
|
|
from cm_promotions pr
|
|
- left join cm_promotions_gift cpg on pr.id = cpg.promotionsId
|
|
|
|
|
|
+ left join cm_promotions_gift cpg on pr.id = cpg.promotionsId
|
|
where cpg.productId = #{productId}
|
|
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)
|
|
|
|
|
|
+ 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
|
|
order by pr.type desc
|
|
limit 1
|
|
limit 1
|
|
</select>
|
|
</select>
|
|
|
|
+
|
|
|
|
+ <select id="findUserIdentity" resultType="java.lang.Integer">
|
|
|
|
+ select userIdentity
|
|
|
|
+ from user
|
|
|
|
+ where userID = #{userId}
|
|
|
|
+ </select>
|
|
</mapper>
|
|
</mapper>
|