|
@@ -3,7 +3,7 @@
|
|
<mapper namespace="com.caimei.modules.product.dao.CmPromotionDao">
|
|
<mapper namespace="com.caimei.modules.product.dao.CmPromotionDao">
|
|
|
|
|
|
<sql id="cmPromotionColumns">
|
|
<sql id="cmPromotionColumns">
|
|
- cp.id AS "id",
|
|
|
|
|
|
+ cp.id AS "id",
|
|
cp.name AS "name",
|
|
cp.name AS "name",
|
|
cp.description AS "description",
|
|
cp.description AS "description",
|
|
cp.type AS "type",
|
|
cp.type AS "type",
|
|
@@ -16,7 +16,7 @@
|
|
cp.updateTime AS "updateTime",
|
|
cp.updateTime AS "updateTime",
|
|
cp.status AS "status",
|
|
cp.status AS "status",
|
|
cp.delFlag AS "delFlag1"
|
|
cp.delFlag AS "delFlag1"
|
|
- </sql>
|
|
|
|
|
|
+ </sql>
|
|
|
|
|
|
<select id="get" resultType="CmPromotion">
|
|
<select id="get" resultType="CmPromotion">
|
|
SELECT
|
|
SELECT
|
|
@@ -94,58 +94,58 @@
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="findPromotionProduct" resultType="com.caimei.modules.product.entity.Product">
|
|
<select id="findPromotionProduct" resultType="com.caimei.modules.product.entity.Product">
|
|
- SELECT
|
|
|
|
- p.*,
|
|
|
|
- cp.reducedPrice AS "reducedPrice",
|
|
|
|
- s.name AS "shopName"
|
|
|
|
- FROM
|
|
|
|
- cm_promotions cp
|
|
|
|
- LEFT JOIN cm_promotions_product cpp ON cp.id = cpp.promotionsId
|
|
|
|
- LEFT JOIN product p ON cpp.productId = p.productID
|
|
|
|
- LEFT JOIN shop s ON s.shopID = p.shopID
|
|
|
|
- WHERE
|
|
|
|
- cp.id = #{id}
|
|
|
|
- and p.productCategory = 1
|
|
|
|
|
|
+ SELECT p.*,
|
|
|
|
+ cp.reducedPrice AS "reducedPrice",
|
|
|
|
+ s.name AS "shopName"
|
|
|
|
+ FROM cm_promotions cp
|
|
|
|
+ LEFT JOIN cm_promotions_product cpp ON cp.id = cpp.promotionsId
|
|
|
|
+ LEFT JOIN product p ON cpp.productId = p.productID
|
|
|
|
+ LEFT JOIN shop s ON s.shopID = p.shopID
|
|
|
|
+ WHERE cp.id = #{id}
|
|
|
|
+ and p.productCategory = 1
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="findGiftProduct" resultType="com.caimei.modules.product.entity.Product">
|
|
<select id="findGiftProduct" resultType="com.caimei.modules.product.entity.Product">
|
|
- SELECT
|
|
|
|
- p.*,
|
|
|
|
- s.name AS "shopName",
|
|
|
|
- cpg.number AS "giftNumber"
|
|
|
|
- FROM
|
|
|
|
- cm_promotions cp
|
|
|
|
- LEFT JOIN cm_promotions_gift cpg ON cp.id = cpg.promotionsId
|
|
|
|
- LEFT JOIN product p ON cpg.productId = p.productID
|
|
|
|
- LEFT JOIN shop s ON s.shopID = p.shopID
|
|
|
|
- WHERE
|
|
|
|
- cp.id = #{id}
|
|
|
|
- and p.productCategory = 1
|
|
|
|
|
|
+ SELECT p.*,
|
|
|
|
+ s.name AS "shopName",
|
|
|
|
+ cpg.number AS "giftNumber"
|
|
|
|
+ FROM cm_promotions cp
|
|
|
|
+ LEFT JOIN cm_promotions_gift cpg ON cp.id = cpg.promotionsId
|
|
|
|
+ LEFT JOIN product p ON cpg.productId = p.productID
|
|
|
|
+ LEFT JOIN shop s ON s.shopID = p.shopID
|
|
|
|
+ WHERE cp.id = #{id}
|
|
|
|
+ and p.productCategory = 1
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="findGiftPurchaseProduct" resultType="com.caimei.modules.bulkpurchase.entity.PurchaseProduct">
|
|
<select id="findGiftPurchaseProduct" resultType="com.caimei.modules.bulkpurchase.entity.PurchaseProduct">
|
|
- SELECT p.name name,s.name shopName ,s.`shopID` shopId,p.name purchaseProductName,
|
|
|
|
- p.`price1` price,p.`productID` productId,p.productCode productNo,p.mainImage image
|
|
|
|
- ,p.costCheckFlag costCheckFlag,p.costPrice costPrice,p.costProportional costProportional, p.price0 AS normalPrice,
|
|
|
|
- cpg.number AS num
|
|
|
|
- FROM
|
|
|
|
- cm_promotions cp
|
|
|
|
- LEFT JOIN cm_promotions_gift cpg ON cp.id = cpg.promotionsId
|
|
|
|
- LEFT JOIN product p ON cpg.productId = p.productID
|
|
|
|
- LEFT JOIN shop s ON s.shopID = p.shopID
|
|
|
|
- WHERE
|
|
|
|
- cp.id = #{id}
|
|
|
|
- and p.productCategory = 1
|
|
|
|
|
|
+ SELECT p.name name,
|
|
|
|
+ s.name shopName,
|
|
|
|
+ s.`shopID` shopId,
|
|
|
|
+ p.name purchaseProductName,
|
|
|
|
+ p.`price1` price,
|
|
|
|
+ p.`productID` productId,
|
|
|
|
+ p.productCode productNo,
|
|
|
|
+ p.mainImage image
|
|
|
|
+ ,
|
|
|
|
+ p.costCheckFlag costCheckFlag,
|
|
|
|
+ p.costPrice costPrice,
|
|
|
|
+ p.costProportional costProportional,
|
|
|
|
+ p.price0 AS normalPrice,
|
|
|
|
+ cpg.number AS num,
|
|
|
|
+ cp.discount as discounts
|
|
|
|
+ FROM cm_promotions cp
|
|
|
|
+ LEFT JOIN cm_promotions_gift cpg ON cp.id = cpg.promotionsId
|
|
|
|
+ LEFT JOIN product p ON cpg.productId = p.productID
|
|
|
|
+ LEFT JOIN shop s ON s.shopID = p.shopID
|
|
|
|
+ WHERE cp.id = #{id}
|
|
|
|
+ and p.productCategory = 1
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="findPromotionShops" resultType="com.caimei.modules.cibe.entity.Shop">
|
|
<select id="findPromotionShops" resultType="com.caimei.modules.cibe.entity.Shop">
|
|
- SELECT
|
|
|
|
- s.*
|
|
|
|
- FROM
|
|
|
|
- cm_promotions_product cpp
|
|
|
|
- LEFT JOIN shop s ON cpp.supplierId = s.shopID
|
|
|
|
- WHERE
|
|
|
|
- cpp.promotionsId = #{id}
|
|
|
|
|
|
+ SELECT s.*
|
|
|
|
+ FROM cm_promotions_product cpp
|
|
|
|
+ LEFT JOIN shop s ON cpp.supplierId = s.shopID
|
|
|
|
+ WHERE cpp.promotionsId = #{id}
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
|
|
<select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
|
|
@@ -239,154 +239,151 @@
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<delete id="deleteAllPromotionProductsAndShops">
|
|
<delete id="deleteAllPromotionProductsAndShops">
|
|
- DELETE FROM cm_promotions_product
|
|
|
|
- WHERE promotionsId = #{id}
|
|
|
|
- </delete>
|
|
|
|
|
|
+ DELETE
|
|
|
|
+ FROM cm_promotions_product
|
|
|
|
+ WHERE promotionsId = #{id}
|
|
|
|
+ </delete>
|
|
|
|
|
|
<delete id="deleteAllPromotionGifts">
|
|
<delete id="deleteAllPromotionGifts">
|
|
- DELETE FROM cm_promotions_gift
|
|
|
|
- WHERE promotionsId = #{id}
|
|
|
|
- </delete>
|
|
|
|
|
|
+ DELETE
|
|
|
|
+ FROM cm_promotions_gift
|
|
|
|
+ WHERE promotionsId = #{id}
|
|
|
|
+ </delete>
|
|
|
|
|
|
<insert id="insertPromotionProduct">
|
|
<insert id="insertPromotionProduct">
|
|
- INSERT INTO cm_promotions_product(
|
|
|
|
- promotionsId,
|
|
|
|
- productId,
|
|
|
|
- addTime
|
|
|
|
- ) VALUES (
|
|
|
|
- #{promotionId},
|
|
|
|
- #{productId},
|
|
|
|
- now()
|
|
|
|
- )
|
|
|
|
- </insert>
|
|
|
|
|
|
+ INSERT INTO cm_promotions_product(promotionsId,
|
|
|
|
+ productId,
|
|
|
|
+ addTime)
|
|
|
|
+ VALUES (#{promotionId},
|
|
|
|
+ #{productId},
|
|
|
|
+ now())
|
|
|
|
+ </insert>
|
|
|
|
|
|
<insert id="insertGiftProduct">
|
|
<insert id="insertGiftProduct">
|
|
- INSERT INTO cm_promotions_gift(
|
|
|
|
- promotionsId,
|
|
|
|
- productId,
|
|
|
|
- number,
|
|
|
|
- addTime
|
|
|
|
- ) VALUES (
|
|
|
|
- #{promotionId},
|
|
|
|
- #{giftId},
|
|
|
|
- #{number},
|
|
|
|
- now()
|
|
|
|
- )
|
|
|
|
- </insert>
|
|
|
|
|
|
+ INSERT INTO cm_promotions_gift(promotionsId,
|
|
|
|
+ productId,
|
|
|
|
+ number,
|
|
|
|
+ addTime)
|
|
|
|
+ VALUES (#{promotionId},
|
|
|
|
+ #{giftId},
|
|
|
|
+ #{number},
|
|
|
|
+ now())
|
|
|
|
+ </insert>
|
|
|
|
|
|
<insert id="insertPromotionShop">
|
|
<insert id="insertPromotionShop">
|
|
- INSERT INTO cm_promotions_product(
|
|
|
|
- promotionsId,
|
|
|
|
- supplierId,
|
|
|
|
- productId,
|
|
|
|
- addTime
|
|
|
|
- ) VALUES (
|
|
|
|
- #{promotionId},
|
|
|
|
- #{shopId},
|
|
|
|
- 0,
|
|
|
|
- now()
|
|
|
|
- )
|
|
|
|
- </insert>
|
|
|
|
|
|
+ INSERT INTO cm_promotions_product(promotionsId,
|
|
|
|
+ supplierId,
|
|
|
|
+ productId,
|
|
|
|
+ addTime)
|
|
|
|
+ VALUES (#{promotionId},
|
|
|
|
+ #{shopId},
|
|
|
|
+ 0,
|
|
|
|
+ now())
|
|
|
|
+ </insert>
|
|
|
|
|
|
<insert id="insert" parameterType="CmPromotion" keyProperty="id" useGeneratedKeys="true">
|
|
<insert id="insert" parameterType="CmPromotion" keyProperty="id" useGeneratedKeys="true">
|
|
- INSERT INTO cm_promotions(
|
|
|
|
- name,
|
|
|
|
- description,
|
|
|
|
- type,
|
|
|
|
- mode,
|
|
|
|
- touchPrice,
|
|
|
|
- reducedPrice,
|
|
|
|
- beginTime,
|
|
|
|
- endTime,
|
|
|
|
- addTime,
|
|
|
|
- updateTime,
|
|
|
|
- status,
|
|
|
|
- delFlag,
|
|
|
|
- discount,
|
|
|
|
- seen
|
|
|
|
- ) VALUES (
|
|
|
|
- #{name},
|
|
|
|
- #{description},
|
|
|
|
- #{type},
|
|
|
|
- #{mode},
|
|
|
|
- #{touchPrice},
|
|
|
|
- #{reducedPrice},
|
|
|
|
- #{beginTime},
|
|
|
|
- #{endTime},
|
|
|
|
- #{addTime},
|
|
|
|
- #{updateTime},
|
|
|
|
- #{status},
|
|
|
|
- #{delFlag1},
|
|
|
|
- #{discount},
|
|
|
|
- #{seen}
|
|
|
|
- )
|
|
|
|
|
|
+ INSERT INTO cm_promotions(name,
|
|
|
|
+ description,
|
|
|
|
+ type,
|
|
|
|
+ mode,
|
|
|
|
+ touchPrice,
|
|
|
|
+ reducedPrice,
|
|
|
|
+ beginTime,
|
|
|
|
+ endTime,
|
|
|
|
+ addTime,
|
|
|
|
+ updateTime,
|
|
|
|
+ status,
|
|
|
|
+ delFlag,
|
|
|
|
+ discount,
|
|
|
|
+ seen)
|
|
|
|
+ VALUES (#{name},
|
|
|
|
+ #{description},
|
|
|
|
+ #{type},
|
|
|
|
+ #{mode},
|
|
|
|
+ #{touchPrice},
|
|
|
|
+ #{reducedPrice},
|
|
|
|
+ #{beginTime},
|
|
|
|
+ #{endTime},
|
|
|
|
+ #{addTime},
|
|
|
|
+ #{updateTime},
|
|
|
|
+ #{status},
|
|
|
|
+ #{delFlag1},
|
|
|
|
+ #{discount},
|
|
|
|
+ #{seen})
|
|
</insert>
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="update">
|
|
<update id="update">
|
|
UPDATE cm_promotions
|
|
UPDATE cm_promotions
|
|
- SET name = #{name},
|
|
|
|
- description = #{description},
|
|
|
|
- type = #{type},
|
|
|
|
- mode = #{mode},
|
|
|
|
- touchPrice = #{touchPrice},
|
|
|
|
- reducedPrice = #{reducedPrice},
|
|
|
|
- beginTime = #{beginTime},
|
|
|
|
- endTime = #{endTime},
|
|
|
|
- updateTime = #{updateTime},
|
|
|
|
- status = #{status},
|
|
|
|
- delFlag = #{delFlag1}
|
|
|
|
|
|
+ SET name = #{name},
|
|
|
|
+ description = #{description},
|
|
|
|
+ type = #{type},
|
|
|
|
+ mode = #{mode},
|
|
|
|
+ touchPrice = #{touchPrice},
|
|
|
|
+ reducedPrice = #{reducedPrice},
|
|
|
|
+ beginTime = #{beginTime},
|
|
|
|
+ endTime = #{endTime},
|
|
|
|
+ updateTime = #{updateTime},
|
|
|
|
+ status = #{status},
|
|
|
|
+ delFlag = #{delFlag1},
|
|
|
|
+ discount = #{discount},
|
|
|
|
+ seen = #{seen}
|
|
WHERE id = #{id}
|
|
WHERE id = #{id}
|
|
</update>
|
|
</update>
|
|
|
|
|
|
<select id="findShop" resultType="com.caimei.modules.cibe.entity.Shop">
|
|
<select id="findShop" resultType="com.caimei.modules.cibe.entity.Shop">
|
|
- SELECT * from shop where shopID = #{id}
|
|
|
|
|
|
+ SELECT *
|
|
|
|
+ from shop
|
|
|
|
+ where shopID = #{id}
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="findProductPromotion" resultType="com.caimei.modules.product.entity.CmPromotion">
|
|
<select id="findProductPromotion" resultType="com.caimei.modules.product.entity.CmPromotion">
|
|
- select pr.id,
|
|
|
|
- pr.name,
|
|
|
|
- pr.type,
|
|
|
|
- pr.mode,
|
|
|
|
- pr.touchPrice,
|
|
|
|
- pr.reducedPrice,
|
|
|
|
- pr.beginTime,
|
|
|
|
- pr.endTime,
|
|
|
|
- pr.status,
|
|
|
|
- prp.productId,
|
|
|
|
- prp.supplierId
|
|
|
|
|
|
+ select pr.id,
|
|
|
|
+ pr.name,
|
|
|
|
+ pr.type,
|
|
|
|
+ pr.mode,
|
|
|
|
+ pr.touchPrice,
|
|
|
|
+ pr.reducedPrice,
|
|
|
|
+ pr.beginTime,
|
|
|
|
+ pr.endTime,
|
|
|
|
+ pr.status,
|
|
|
|
+ prp.productId,
|
|
|
|
+ prp.supplierId,
|
|
|
|
+ pr.discount
|
|
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}
|
|
where (prp.productId = #{productId}
|
|
- or prp.supplierId = #{shopId})
|
|
|
|
- and (pr.status = 1 or ( pr.status = 2 and (NOW() between pr.beginTime and pr.endTime)))
|
|
|
|
- and pr.delFlag not in ('1','2')
|
|
|
|
|
|
+ or prp.supplierId = #{shopId})
|
|
|
|
+ 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
|
|
order by pr.type desc
|
|
limit 1
|
|
limit 1
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="findProductPromotionsGift" resultType="com.caimei.modules.product.entity.CmPromotion">
|
|
<select id="findProductPromotionsGift" resultType="com.caimei.modules.product.entity.CmPromotion">
|
|
- SELECT DISTINCT pr.id,
|
|
|
|
- pr.name,
|
|
|
|
- pr.type,
|
|
|
|
- pr.mode,
|
|
|
|
- pr.touchPrice,
|
|
|
|
- pr.reducedPrice,
|
|
|
|
- pr.beginTime,
|
|
|
|
- pr.endTime,
|
|
|
|
- pr.status
|
|
|
|
|
|
+ SELECT DISTINCT pr.id,
|
|
|
|
+ pr.name,
|
|
|
|
+ pr.type,
|
|
|
|
+ pr.mode,
|
|
|
|
+ pr.touchPrice,
|
|
|
|
+ pr.reducedPrice,
|
|
|
|
+ pr.beginTime,
|
|
|
|
+ pr.endTime,
|
|
|
|
+ pr.status
|
|
FROM cm_promotions_gift cpg
|
|
FROM cm_promotions_gift cpg
|
|
- LEFT JOIN cm_promotions pr ON pr.id = cpg.promotionsId
|
|
|
|
|
|
+ LEFT JOIN cm_promotions pr 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="findOrderPromotions" resultType="com.caimei.modules.product.entity.CmPromotion">
|
|
<select id="findOrderPromotions" resultType="com.caimei.modules.product.entity.CmPromotion">
|
|
- SELECT * FROM cm_promotions_order WHERE id = #{orderPromotionsId}
|
|
|
|
|
|
+ SELECT *
|
|
|
|
+ FROM cm_promotions_order
|
|
|
|
+ WHERE id = #{orderPromotionsId}
|
|
</select>
|
|
</select>
|
|
|
|
|
|
<select id="findPromotionsByProductId" resultType="com.caimei.modules.product.entity.CmPromotion">
|
|
<select id="findPromotionsByProductId" resultType="com.caimei.modules.product.entity.CmPromotion">
|
|
@@ -408,11 +405,13 @@
|
|
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="getPresentPriceById" resultType="java.lang.Double">
|
|
<select id="getPresentPriceById" resultType="java.lang.Double">
|
|
- select price1 from product where productID=#{productId}
|
|
|
|
|
|
+ select price1
|
|
|
|
+ from product
|
|
|
|
+ where productID = #{productId}
|
|
</select>
|
|
</select>
|
|
</mapper>
|
|
</mapper>
|