|
@@ -6,22 +6,22 @@
|
|
select id as bigTypeId, name, icon as crmIcon
|
|
select id as bigTypeId, name, icon as crmIcon
|
|
from hehe_home_type
|
|
from hehe_home_type
|
|
where status = 1
|
|
where status = 1
|
|
- order by -sort desc,addTime desc
|
|
|
|
|
|
+ order by -sort desc, addTime desc
|
|
limit 8
|
|
limit 8
|
|
</select>
|
|
</select>
|
|
<select id="getProductList" resultType="com.caimei365.commodity.model.vo.HeheProductVo">
|
|
<select id="getProductList" resultType="com.caimei365.commodity.model.vo.HeheProductVo">
|
|
SELECT
|
|
SELECT
|
|
chp.productId,
|
|
chp.productId,
|
|
- chp.price,
|
|
|
|
- chp.price as normalPrice,
|
|
|
|
|
|
+ (select price from cm_hehe_sku where productId=chp.productId order by price asc limit 1) as price,
|
|
|
|
+ (select price from cm_hehe_sku where productId=chp.productId order by price asc limit 1) as normalPrice,
|
|
chp.includedTax,
|
|
chp.includedTax,
|
|
chp.invoiceType,
|
|
chp.invoiceType,
|
|
chp.clubTaxPoint,
|
|
chp.clubTaxPoint,
|
|
p.name,
|
|
p.name,
|
|
- P.unit,
|
|
|
|
|
|
+ (select unit from cm_sku cs left join cm_hehe_sku chs on cs.skuId=chs.skuId where chs.productId=chp.productId
|
|
|
|
+ order by chs.price asc limit 1) as unit,
|
|
p.mainImage
|
|
p.mainImage
|
|
- FROM
|
|
|
|
- cm_hehe_product chp
|
|
|
|
|
|
+ FROM cm_hehe_product chp
|
|
LEFT JOIN product p ON chp.productId = p.productID
|
|
LEFT JOIN product p ON chp.productId = p.productID
|
|
<if test="listType == 2">
|
|
<if test="listType == 2">
|
|
LEFT JOIN hehe_home_type_product hhtp on chp.productId = hhtp.productId
|
|
LEFT JOIN hehe_home_type_product hhtp on chp.productId = hhtp.productId
|
|
@@ -73,60 +73,54 @@
|
|
order by chp.id desc
|
|
order by chp.id desc
|
|
</if>
|
|
</if>
|
|
</select>
|
|
</select>
|
|
|
|
+
|
|
<select id="getProduct" resultType="com.caimei365.commodity.model.vo.HeheProductVo">
|
|
<select id="getProduct" resultType="com.caimei365.commodity.model.vo.HeheProductVo">
|
|
- SELECT
|
|
|
|
- chp.productId,
|
|
|
|
- chp.price,
|
|
|
|
- chp.price as normalPrice,
|
|
|
|
- chp.includedTax,
|
|
|
|
- chp.invoiceType,
|
|
|
|
- chp.clubTaxPoint,
|
|
|
|
- p.name,
|
|
|
|
- P.unit,
|
|
|
|
- p.mainImage,
|
|
|
|
- cb.name as "brandName",
|
|
|
|
- P.unit,
|
|
|
|
- P.stock,
|
|
|
|
- p.tags
|
|
|
|
- FROM
|
|
|
|
- cm_hehe_product chp
|
|
|
|
- LEFT JOIN product p ON chp.productId = p.productID
|
|
|
|
- LEFT JOIN cm_brand cb on p.brandID = cb.id
|
|
|
|
- WHERE
|
|
|
|
- chp.validFlag = 1
|
|
|
|
- and chp.productId = #{productId}
|
|
|
|
|
|
+ SELECT chp.productId,
|
|
|
|
+ (select price from cm_hehe_sku where productId = chp.productId order by price asc limit 1) as price,
|
|
|
|
+ (select price from cm_hehe_sku where productId = chp.productId order by price asc limit 1) as normalPrice,
|
|
|
|
+ (select unit from cm_sku cs left join cm_hehe_sku chs on cs.skuId=chs.skuId where cs.productId = chp.productId order by chs.price asc limit 1) as unit,
|
|
|
|
+ (select stock from cm_sku cs left join cm_hehe_sku chs on cs.skuId=chs.skuId where cs.productId = chp.productId order by chs.price asc limit 1) as stock,
|
|
|
|
+ chp.includedTax,
|
|
|
|
+ chp.invoiceType,
|
|
|
|
+ chp.clubTaxPoint,
|
|
|
|
+ p.name,
|
|
|
|
+ p.mainImage,
|
|
|
|
+ cb.name as "brandName",
|
|
|
|
+ p.tags
|
|
|
|
+ FROM cm_hehe_product chp
|
|
|
|
+ LEFT JOIN product p ON chp.productId = p.productID
|
|
|
|
+ LEFT JOIN cm_brand cb on p.brandID = cb.id
|
|
|
|
+ WHERE chp.validFlag = 1
|
|
|
|
+ and chp.productId = #{productId}
|
|
</select>
|
|
</select>
|
|
<select id="getActivityIdByProductId" resultType="java.lang.Integer">
|
|
<select id="getActivityIdByProductId" resultType="java.lang.Integer">
|
|
- SELECT
|
|
|
|
- activityId
|
|
|
|
- FROM
|
|
|
|
- cm_hehe_activity_product a
|
|
|
|
- LEFT JOIN cm_hehe_activity cha ON a.activityId = cha.id
|
|
|
|
- WHERE
|
|
|
|
- cha.delFlag = 0
|
|
|
|
|
|
+ SELECT activityId
|
|
|
|
+ FROM cm_hehe_activity_product a
|
|
|
|
+ LEFT JOIN cm_hehe_activity cha ON a.activityId = cha.id
|
|
|
|
+ WHERE cha.delFlag = 0
|
|
AND a.delFlag = 0
|
|
AND a.delFlag = 0
|
|
AND NOW() BETWEEN cha.beginTime AND cha.endTime
|
|
AND NOW() BETWEEN cha.beginTime AND cha.endTime
|
|
AND a.productId = #{productId}
|
|
AND a.productId = #{productId}
|
|
</select>
|
|
</select>
|
|
<select id="getCollageProduct" resultType="com.caimei365.commodity.model.po.HeheCollageProductPo">
|
|
<select id="getCollageProduct" resultType="com.caimei365.commodity.model.po.HeheCollageProductPo">
|
|
- select chcp.productId, chcp.price, chcp.limitedNum, chcp.unlimitedFlag, chcp.memberNum
|
|
|
|
|
|
+ select chcp.skuId,chcp.productId, chcp.price, chcp.limitedNum, chcp.unlimitedFlag, chcp.memberNum
|
|
from cm_hehe_collage_product chcp
|
|
from cm_hehe_collage_product chcp
|
|
- where chcp.productId = #{productID} and chcp.status = 1
|
|
|
|
|
|
+ where chcp.skuId = #{skuId}
|
|
|
|
+ and chcp.status = 1
|
|
|
|
+ ORDER BY price ASC
|
|
|
|
+ LIMIT 1
|
|
</select>
|
|
</select>
|
|
<select id="getActivityLadderList" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
|
|
<select id="getActivityLadderList" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
|
|
- SELECT
|
|
|
|
- buyNum,
|
|
|
|
- buyPrice
|
|
|
|
- FROM
|
|
|
|
- cm_hehe_activity_ladder
|
|
|
|
- WHERE
|
|
|
|
- activityId = #{activityId}
|
|
|
|
- AND productId = #{productId}
|
|
|
|
- ORDER BY
|
|
|
|
- ladderNum
|
|
|
|
|
|
+ SELECT skuId,
|
|
|
|
+ buyNum,
|
|
|
|
+ buyPrice
|
|
|
|
+ FROM cm_hehe_activity_ladder
|
|
|
|
+ WHERE activityId = #{activityId}
|
|
|
|
+ AND skuId = #{skuId}
|
|
|
|
+ ORDER BY buyPrice ASC
|
|
</select>
|
|
</select>
|
|
<select id="getProductDiscount" resultType="com.caimei365.commodity.model.vo.HeHeDiscountVo">
|
|
<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
|
|
|
|
|
|
+ select chd.id as discountId, chd.discount, if(chd.productType = 2, chdp.discountPrice, null) as discountPrice
|
|
from cm_hehe_discount chd
|
|
from cm_hehe_discount chd
|
|
left join cm_hehe_discount_product chdp on chd.id = chdp.discountId
|
|
left join cm_hehe_discount_product chdp on chd.id = chdp.discountId
|
|
left join cm_hehe_discount_user chdu on chd.id = chdu.discountId
|
|
left join cm_hehe_discount_user chdu on chd.id = chdu.discountId
|
|
@@ -138,7 +132,8 @@
|
|
<select id="getAllProductCouponCount" resultType="java.lang.Integer">
|
|
<select id="getAllProductCouponCount" resultType="java.lang.Integer">
|
|
select count(*)
|
|
select count(*)
|
|
from cm_hehe_coupon chc
|
|
from cm_hehe_coupon chc
|
|
- where chc.delFlag = 0 and chc.productType = 1
|
|
|
|
|
|
+ where chc.delFlag = 0
|
|
|
|
+ and chc.productType = 1
|
|
and if(startNowFlag = 1, true, NOW() <![CDATA[ >= ]]> startTime)
|
|
and if(startNowFlag = 1, true, NOW() <![CDATA[ >= ]]> startTime)
|
|
and if(permanentFlag = 1, true, NOW() <![CDATA[ <= ]]> endTime)
|
|
and if(permanentFlag = 1, true, NOW() <![CDATA[ <= ]]> endTime)
|
|
</select>
|
|
</select>
|
|
@@ -147,7 +142,9 @@
|
|
from cm_hehe_coupon chc
|
|
from cm_hehe_coupon chc
|
|
left join cm_hehe_coupon_product chcp on chc.id = chcp.couponId
|
|
left join cm_hehe_coupon_product chcp on chc.id = chcp.couponId
|
|
left join cm_hehe_product chp on chcp.productId = chp.id
|
|
left join cm_hehe_product chp on chcp.productId = chp.id
|
|
- where chc.delFlag = 0 and chc.productType = 2 and chp.productId = #{productId}
|
|
|
|
|
|
+ where chc.delFlag = 0
|
|
|
|
+ and chc.productType = 2
|
|
|
|
+ and chp.productId = #{productId}
|
|
and if(startNowFlag = 1, true, NOW() <![CDATA[ >= ]]> startTime)
|
|
and if(startNowFlag = 1, true, NOW() <![CDATA[ >= ]]> startTime)
|
|
and if(permanentFlag = 1, true, NOW() <![CDATA[ <= ]]> endTime)
|
|
and if(permanentFlag = 1, true, NOW() <![CDATA[ <= ]]> endTime)
|
|
</select>
|
|
</select>
|
|
@@ -155,9 +152,11 @@
|
|
select a.discountPrice, a.productId, chda.offlineTime
|
|
select a.discountPrice, a.productId, chda.offlineTime
|
|
from hehe_discount_activity_product a
|
|
from hehe_discount_activity_product a
|
|
left join cm_hehe_discount_activity chda on a.activityId = chda.id
|
|
left join cm_hehe_discount_activity chda on a.activityId = chda.id
|
|
- where a.productId = #{productId}
|
|
|
|
|
|
+ where a.skuId = #{skuId}
|
|
and a.status = 1
|
|
and a.status = 1
|
|
and NOW() between chda.onlineTime and chda.offlineTime
|
|
and NOW() between chda.onlineTime and chda.offlineTime
|
|
|
|
+ order by discountPrice asc
|
|
|
|
+ limit 1
|
|
</select>
|
|
</select>
|
|
<select id="getCouponList" resultType="com.caimei365.commodity.model.vo.HeheCouponVo">
|
|
<select id="getCouponList" resultType="com.caimei365.commodity.model.vo.HeheCouponVo">
|
|
select chc.id as couponId,
|
|
select chc.id as couponId,
|
|
@@ -177,7 +176,8 @@
|
|
<if test="userId > 0">
|
|
<if test="userId > 0">
|
|
date_add(
|
|
date_add(
|
|
if(couponType <![CDATA[ <= ]]> 3,
|
|
if(couponType <![CDATA[ <= ]]> 3,
|
|
- if(#{registerTime} <![CDATA[ >= ]]> startTime and if(permanentFlag = 1,true,#{registerTime} <![CDATA[ < ]]> endTime),
|
|
|
|
|
|
+ if(#{registerTime} <![CDATA[ >= ]]> startTime and if(permanentFlag = 1,true,#{registerTime} <![CDATA[ < ]]>
|
|
|
|
+ endTime),
|
|
#{registerTime},startTime),
|
|
#{registerTime},startTime),
|
|
chcs.createTime
|
|
chcs.createTime
|
|
)
|
|
)
|
|
@@ -191,7 +191,7 @@
|
|
left join (select couponId as couponId, group_concat(productId) as productIds
|
|
left join (select couponId as couponId, group_concat(productId) as productIds
|
|
from cm_hehe_coupon_product
|
|
from cm_hehe_coupon_product
|
|
group by couponId
|
|
group by couponId
|
|
- ) as chcp on chc.id = chcp.couponId
|
|
|
|
|
|
+ ) as chcp on chc.id = chcp.couponId
|
|
where chc.delFlag = 0
|
|
where chc.delFlag = 0
|
|
and if(startNowFlag = 1, true, NOW() <![CDATA[ >= ]]> startTime)
|
|
and if(startNowFlag = 1, true, NOW() <![CDATA[ >= ]]> startTime)
|
|
<if test="productIdArr != null and productIdArr.length > 0">
|
|
<if test="productIdArr != null and productIdArr.length > 0">
|
|
@@ -208,13 +208,17 @@
|
|
</if>
|
|
</if>
|
|
<if test="userId > 0">
|
|
<if test="userId > 0">
|
|
and if(couponType <![CDATA[ <= ]]> 3,
|
|
and if(couponType <![CDATA[ <= ]]> 3,
|
|
- chc.id not in (select couponId from cm_hehe_receive_coupon where userId = #{userId} and couponId is not null),
|
|
|
|
- chcs.id not in (select couponShareId from cm_hehe_receive_coupon where userId = #{userId} and couponShareId is not null)
|
|
|
|
|
|
+ chc.id not in (select couponId from cm_hehe_receive_coupon where userId = #{userId} and couponId is not
|
|
|
|
+ null),
|
|
|
|
+ chcs.id not in (select couponShareId from cm_hehe_receive_coupon where userId = #{userId} and couponShareId
|
|
|
|
+ is not null)
|
|
)
|
|
)
|
|
and (
|
|
and (
|
|
(couponType = 1
|
|
(couponType = 1
|
|
- or (couponType = 2 and chc.id in (select distinct couponId from cm_hehe_coupon_user where userId = #{userId} and couponId is not null))
|
|
|
|
- or (couponType = 3 and #{registerTime} <![CDATA[ >= ]]> startTime and if(permanentFlag = 1,true,#{registerTime} <![CDATA[ < ]]> endTime))
|
|
|
|
|
|
+ or (couponType = 2 and chc.id in (select distinct couponId from cm_hehe_coupon_user where userId = #{userId}
|
|
|
|
+ and couponId is not null))
|
|
|
|
+ or (couponType = 3 and #{registerTime} <![CDATA[ >= ]]> startTime and if(permanentFlag =
|
|
|
|
+ 1,true,#{registerTime} <![CDATA[ < ]]> endTime))
|
|
or (couponType = 4 and chcs.shareUserId = #{userId})
|
|
or (couponType = 4 and chcs.shareUserId = #{userId})
|
|
or (couponType = 5 and chcs.shareUserId = #{userId})
|
|
or (couponType = 5 and chcs.shareUserId = #{userId})
|
|
or (couponType = 6 and chcs.shareUserId = #{userId})
|
|
or (couponType = 6 and chcs.shareUserId = #{userId})
|
|
@@ -223,7 +227,8 @@
|
|
if(permanentFlag = 1,true,NOW() <![CDATA[ < ]]> endTime),
|
|
if(permanentFlag = 1,true,NOW() <![CDATA[ < ]]> endTime),
|
|
NOW() <![CDATA[ < ]]> date_add(
|
|
NOW() <![CDATA[ < ]]> date_add(
|
|
if(couponType <![CDATA[ <= ]]> 3,
|
|
if(couponType <![CDATA[ <= ]]> 3,
|
|
- if(#{registerTime} <![CDATA[ >= ]]> startTime and if(permanentFlag = 1,true,#{registerTime} <![CDATA[ < ]]> endTime),
|
|
|
|
|
|
+ if(#{registerTime} <![CDATA[ >= ]]> startTime and if(permanentFlag = 1,true,#{registerTime} <![CDATA[ < ]]>
|
|
|
|
+ endTime),
|
|
#{registerTime},startTime),
|
|
#{registerTime},startTime),
|
|
chcs.createTime
|
|
chcs.createTime
|
|
)
|
|
)
|
|
@@ -236,7 +241,9 @@
|
|
order by chc.createDate desc
|
|
order by chc.createDate desc
|
|
</select>
|
|
</select>
|
|
<select id="getUserRegisterTime" resultType="java.util.Date">
|
|
<select id="getUserRegisterTime" resultType="java.util.Date">
|
|
- select registerTime from user where userID = #{userId}
|
|
|
|
|
|
+ select registerTime
|
|
|
|
+ from user
|
|
|
|
+ where userID = #{userId}
|
|
</select>
|
|
</select>
|
|
<select id="getReceiveCouponList" resultType="com.caimei365.commodity.model.vo.HeheCouponVo">
|
|
<select id="getReceiveCouponList" resultType="com.caimei365.commodity.model.vo.HeheCouponVo">
|
|
select distinct
|
|
select distinct
|
|
@@ -281,29 +288,26 @@
|
|
</if>
|
|
</if>
|
|
</select>
|
|
</select>
|
|
<select id="getActivityList" resultType="com.caimei365.commodity.model.vo.HeHeActivityVo">
|
|
<select id="getActivityList" resultType="com.caimei365.commodity.model.vo.HeHeActivityVo">
|
|
- SELECT
|
|
|
|
- cha.id AS activityId,
|
|
|
|
- cha.name,
|
|
|
|
- cha.listImage,
|
|
|
|
- cha.beginTime,
|
|
|
|
- cha.endTime,
|
|
|
|
- COUNT(chua.id) AS productCount
|
|
|
|
- FROM
|
|
|
|
- cm_hehe_user_activity chua
|
|
|
|
- LEFT JOIN cm_hehe_activity cha ON chua.activityId = cha.id
|
|
|
|
- WHERE
|
|
|
|
- chua.userId = #{userId}
|
|
|
|
|
|
+ SELECT cha.id AS activityId,
|
|
|
|
+ cha.name,
|
|
|
|
+ cha.listImage,
|
|
|
|
+ cha.beginTime,
|
|
|
|
+ cha.endTime,
|
|
|
|
+ COUNT(chua.id) AS productCount
|
|
|
|
+ FROM cm_hehe_user_activity chua
|
|
|
|
+ LEFT JOIN cm_hehe_activity cha ON chua.activityId = cha.id
|
|
|
|
+ WHERE chua.userId = #{userId}
|
|
AND cha.delFlag = 0
|
|
AND cha.delFlag = 0
|
|
AND cha.status = 1
|
|
AND cha.status = 1
|
|
AND cha.beginTime <![CDATA[ <= ]]> NOW()
|
|
AND cha.beginTime <![CDATA[ <= ]]> NOW()
|
|
AND cha.endTime <![CDATA[ >= ]]> NOW()
|
|
AND cha.endTime <![CDATA[ >= ]]> NOW()
|
|
- GROUP BY
|
|
|
|
- cha.id
|
|
|
|
- ORDER BY
|
|
|
|
- cha.addTime DESC
|
|
|
|
|
|
+ GROUP BY cha.id
|
|
|
|
+ ORDER BY cha.addTime DESC
|
|
</select>
|
|
</select>
|
|
<select id="getActivityImageById" resultType="java.lang.String">
|
|
<select id="getActivityImageById" resultType="java.lang.String">
|
|
- SELECT detailsImage FROM cm_hehe_activity WHERE id = #{activityId}
|
|
|
|
|
|
+ SELECT detailsImage
|
|
|
|
+ FROM cm_hehe_activity
|
|
|
|
+ WHERE id = #{activityId}
|
|
</select>
|
|
</select>
|
|
<select id="getHomeCarousel" resultType="com.caimei365.commodity.model.vo.HeHeImageVo">
|
|
<select id="getHomeCarousel" resultType="com.caimei365.commodity.model.vo.HeHeImageVo">
|
|
SELECT topic,
|
|
SELECT topic,
|
|
@@ -316,5 +320,29 @@
|
|
WHERE status = 1
|
|
WHERE status = 1
|
|
ORDER BY - sort DESC
|
|
ORDER BY - sort DESC
|
|
</select>
|
|
</select>
|
|
|
|
+ <select id="findHeheSkus" resultType="com.caimei365.commodity.model.dto.HeHeSku">
|
|
|
|
+ select cs.skuId,
|
|
|
|
+ cs.unit,
|
|
|
|
+ cs.productId,
|
|
|
|
+ cs.costCheckFlag,
|
|
|
|
+ cs.costPrice,
|
|
|
|
+ cs.costProportional,
|
|
|
|
+ cs.stock,
|
|
|
|
+ chs.price,
|
|
|
|
+ chs.price as normalPrice
|
|
|
|
+ from cm_sku cs
|
|
|
|
+ left join cm_hehe_sku chs on cs.skuId = chs.skuId
|
|
|
|
+ where cs.productId=#{productId}
|
|
|
|
+ order by chs.price asc
|
|
|
|
+ </select>
|
|
|
|
+ <select id="getActivityLadderListBySkuId" resultType="com.caimei365.commodity.model.vo.LadderPriceVo">
|
|
|
|
+ SELECT skuId,
|
|
|
|
+ buyNum,
|
|
|
|
+ buyPrice
|
|
|
|
+ FROM cm_hehe_activity_ladder
|
|
|
|
+ WHERE activityId = #{activityId}
|
|
|
|
+ AND skuId = #{skuId}
|
|
|
|
+ ORDER BY buyPrice ASC
|
|
|
|
+ </select>
|
|
|
|
|
|
</mapper>
|
|
</mapper>
|