PromotionProductGiftMapper.xml
7.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?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.sibu.orderHelper.integral.web.dao.IMPromotionProductGiftDao">
<resultMap id="rs_PromotionRuleGiftBean" type="com.sibu.orderHelper.integral.model.PromotionProductGift">
<result property="id" column="id" javaType="java.lang.Long" jdbcType="VARCHAR"/>
<result property="buyLimitNum" column="buy_limit_num" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
<result property="giftProductId" column="gift_product_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="giftNum" column="gift_num" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
<result property="giftTotal" column="gift_total" javaType="java.lang.Long" jdbcType="VARCHAR"/>
<result property="surplusNum" column="surplus_num" javaType="java.lang.Long" jdbcType="VARCHAR"/>
<result property="isDelete" column="is_delete" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
<result property="status" column="status" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
<result property="buyProductId" column="buy_product_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
<result property="promotionId" column="promotion_id" javaType="java.lang.Long" jdbcType="VARCHAR"/>
</resultMap>
<!-- 返回购买商品返回商品明 -->
<resultMap id="promotionRuleGiftResp" type="com.sibu.orderHelper.integral.reponse.PromotionProductGiftResponse">
<result property="id" column="id" javaType="java.lang.Long" jdbcType="VARCHAR"/>
<result property="buyLimitNum" column="buy_limit_num" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
<result property="giftProductId" column="gift_product_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="giftNum" column="gift_num" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
<result property="buyProductId" column="buy_product_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
<result property="giftProductName" column="gift_product_name" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="buyProductName" column="buy_product_name" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="supplierId" column="supplier_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="supplierName" column="supplier_name" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="platformType" column="platform_type" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
</resultMap>
<!-- 返回满金额送商品 -->
<resultMap id="promotionMoneyGiftResp" type="com.sibu.orderHelper.integral.reponse.PromotionMoneyGiftResponse">
<result property="id" column="id" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
<result property="buyMoney" column="bug_money" javaType="java.math.BigDecimal" jdbcType="VARCHAR"/>
<result property="giftNum" column="gift_num" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
<result property="giftTotal" column="gift_total" javaType="java.lang.Long" jdbcType="VARCHAR"/>
<result property="status" column="status" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
<result property="giftProductId" column="gift_product_id" javaType="java.lang.String" jdbcType="TIMESTAMP"/>
<result property="giftProductName" column="gift_product_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="createDate" column="create_date" javaType="java.util.Date" jdbcType="VARCHAR"/>
<result property="supplierId" column="supplier_id" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="supplierName" column="supplier_name" javaType="java.lang.String" jdbcType="VARCHAR"/>
<result property="platformType" column="platform_type" javaType="java.lang.Integer" jdbcType="VARCHAR"/>
</resultMap>
<select id="count" resultType="java.lang.Integer" >
SELECT COUNT(id) FROM promotion_product_gift
<trim prefix="where" prefixOverrides="and | or">
<if test="null != id">
AND id = #{id}
</if>
</trim>
</select>
<select id="list" resultMap="rs_PromotionRuleGiftBean" >
SELECT * FROM promotion_product_gift where
id = #{id}
ORDER BY create_date desc
</select>
<select id="get" resultMap="rs_PromotionRuleGiftBean" parameterType="java.lang.String">
SELECT * FROM promotion_product_gift
where id = #{id}
</select>
<insert id="save" parameterType="com.sibu.orderHelper.integral.request.PromostionProductGiftRequest">
INSERT INTO promotion_product_gift (
buy_limit_num,gift_product_id,gift_num,gift_total,buy_product_id,promotion_id,supplier_id,supplier_name,platform_type
) VALUES (
#{buyLimitNum},#{giftProductId},#{giftNum},#{giftTotal},#{buyProductId},#{promotionId},#{supplierId},#{supplierName},#{platformType}
)
<!-- <selectKey resultType="java.lang.String" keyProperty="id">
<![CDATA[SELECT last_insert_id() AS id ]]>
</selectKey> -->
</insert>
<update id="update" parameterType="java.util.Map">
UPDATE promotion_product_gift
<trim prefix="SET" suffixOverrides=",">
<if test="null != buyLimitNum">
buy_limit_num=#{buyLimitNum},
</if>
<if test="null != giftProductId">
gift_product_id=#{giftProductId},
</if>
<if test="null != giftNum">
gift_num=#{giftNum},
</if>
<if test="null != giftTotal">
gift_total=#{giftTotal},
</if>
<if test="null != surplusNum">
surplus_num=#{surplusNum},
</if>
<if test="null != isDelete">
is_delete=#{isDelete},
</if>
<if test="null != status">
status=#{status},
</if>
<if test="null != buyProductId">
buy_product_id=#{buyProductId},
</if>
<if test="null != createDate">
create_date=#{createDate},
</if>
<if test="null != promotionId">
promotion_id=#{promotionId},
</if>
</trim>
WHERE id = #{id}
</update>
<delete id="delete" parameterType="java.lang.Long">
DELETE FROM promotion_product_gift WHERE id = #{id}
</delete>
<delete id="batchDelete" parameterType="java.util.List">
DELETE FROM promotion_product_gift WHERE id in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
<!-- 查询促销规则下的商品促销 -->
<select id="listProductGift" resultMap="promotionRuleGiftResp" parameterType="java.lang.Long">
SELECT gift.id, gift.buy_limit_num,gift.gift_product_id,
gift.gift_num,gift.buy_product_id,gift.create_date,p1.name as gift_product_name,p2.name as buy_product_name
FROM promotion_product_gift gift
left join im_product p1 on gift.gift_product_id =p1.im_product_id
left join im_product p2 on gift.buy_product_id =p2.im_product_id
where promotion_id = #{promotionId}
ORDER BY create_date desc
</select>
<select id="getPromotionProductGiftResponseById" parameterType="java.lang.Long" resultMap="promotionRuleGiftResp">
SELECT * FROM promotion_product_gift WHERE id = #{id}
</select>
<select id="getPromotionMoneyGiftResponseById" parameterType="java.lang.Long" resultMap="promotionMoneyGiftResp">
SELECT * FROM promotion_money_gift WHERE id = #{id}
</select>
<!-- 查询促销规则下的商品促销(商家)-->
<select id="listSupplierProductGift" resultMap="promotionRuleGiftResp" parameterType="java.util.Map">
SELECT gift.id, gift.buy_limit_num,gift.gift_product_id,
gift.gift_num,gift.buy_product_id,gift.create_date,p1.name as gift_product_name,p2.name as buy_product_name
FROM promotion_product_gift gift
left join im_product p1 on gift.gift_product_id =p1.im_product_id
left join im_product p2 on gift.buy_product_id =p2.im_product_id
where promotion_id = #{promotionId} and supplier_id = #{supplierId}
ORDER BY create_date desc
</select>
</mapper>