GroupProductMapper.xml
5.6 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
<?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.IMWebGroupProductDao">
<resultMap type="com.sibu.orderHelper.integral.reponse.GroupProductListResponse" id="groupProduct">
<id column="im_group_id" property="imGroupId"/>
<result column="group_product_id" property="groupProductId"/>
<result column="product_id" property="productId" />
<result column="name" property="name" />
<result column="thumb_img" property="thumbImg" />
<result column="price" property="price" />
<result column="integral" property="integral" />
<result column="erp_code" property="erpCode" />
<result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
<result column="product_num" property="productNum"/>
<result column="sku_id" property="skuId"/>
<result column="product_type" property="productType"/>
</resultMap>
<resultMap type="com.sibu.orderHelper.integral.model.IMGroupProductBean" id="erpGroupProduct">
<id column="im_group_id" property="imGroupId"/>
<result column="group_product_id" property="groupProductId"/>
<result column="product_id" property="productId" />
<result column="price" property="price" />
<result column="integral" property="integral" />
<result column="erp_code" property="erpCode" />
<result column="product_num" property="productNum"/>
<result column="sku_id" property="skuId"/>
</resultMap>
<!-- 添加组合产品 -->
<insert id="addGroupProduct" parameterType="com.sibu.orderHelper.integral.request.GroupProductAddRequest">
insert into im_product_group(group_product_id,product_id,price,integral,erp_code,product_num,sku_id)
value(#{groupProductId},#{productId},#{price},#{integral},#{erpCode},#{productNum},#{skuId})
</insert>
<!-- 删除组合产品 -->
<delete id="deleteGroupProduct" parameterType="com.sibu.orderHelper.integral.request.GroupProductDeleteRequest">
delete from im_product_group where group_product_id=#{groupProductId} and product_id=#{productId} limit 1
</delete>
<!-- 检查组合产品中是否已经添加了该产品 -->
<select id="checkGroupProduct" parameterType="com.sibu.orderHelper.integral.request.GroupProductDeleteRequest" resultMap="erpGroupProduct">
select * from im_product_group where group_product_id=#{groupProductId} and product_id=#{productId} limit 1
</select>
<select id="checkGroupProductBySkuId" parameterType="com.sibu.orderHelper.integral.request.GroupProductDeleteRequest" resultMap="erpGroupProduct">
select * from im_product_group where group_product_id=#{groupProductId} and product_id=#{productId} AND sku_id=#{skuId} limit 1
</select>
<!-- 获取组合产品 -->
<select id="listGroupProduct" resultMap="groupProduct" parameterType="java.lang.String">
SELECT ipg.im_group_id,ipg.group_product_id,ipg.product_id,ipg.price,ipg.integral,ipg.erp_code,
ipg.create_date,ipg.product_num,ip.name,ip.thumb_img ,ipg.sku_id,ip.product_type
FROM im_product_group ipg LEFT JOIN im_product ip ON ipg.product_id=ip.im_product_id
where ipg.group_product_id = #{groupProductId}
</select>
<!-- 用于ERP拉去组合产品 -->
<select id="listErpGroupProduct" resultMap="erpGroupProduct" parameterType="java.lang.String">
select * from im_product_group where group_product_id=#{productId}
</select>
<!-- 获取组合产品 -->
<select id="getGroupProductByProductId" resultMap="erpGroupProduct" parameterType="java.lang.String">
select ipg.im_group_id,ipg.group_product_id,ipg.product_id,ipg.price,ipg.integral,ipg.erp_code,
ipg.create_date,ipg.product_num from im_product_group ipg
where ipg.product_id = #{productId} AND ipg.group_product_id=#{groupProductId}
</select>
<!-- 获取组合产品中的产品信息 -->
<select id="listGroupProductById" parameterType="java.lang.String" resultType="com.sibu.orderHelper.integral.reponse.GroupProductResponse">
SELECT ip.thumb_img AS thumbImg, ip.name, GROUP_CONCAT(v.attr_value ORDER BY v.attr_value DESC) AS attrValue,
s.erp_code AS SkuErpCode,ipg.erp_code AS erpCode, ipg.price,ipg.integral,
ipg.product_num AS productNum,s.sku_id AS skuId,ipg.group_product_id AS groupProductId
FROM im_product_group ipg
LEFT JOIN im_product ip ON ipg.product_id=ip.im_product_id
LEFT JOIN sku s ON s.im_product_id=ip.im_product_id
LEFT JOIN attr_ref r ON r.sku_id= s.sku_id
LEFT JOIN attr_value v ON v.value_id=r.attr_value_id
WHERE ipg.group_product_id =#{groupProductId}
GROUP BY s.sku_id
ORDER BY s.sku_id ASC,v.attr_value ASC,s.erp_code ASC,ip.thumb_img ASC,ip.name ASC,ipg.erp_code ASC,
ipg.price ASC,ipg.integral ASC,ipg.product_num ASC,ipg.group_product_id ASC
</select>
<select id="getAttrValueBySkuId" parameterType="java.lang.String" resultType="com.sibu.orderHelper.integral.vo.ImportSkuExist">
SELECT t0.sku_id AS skuId,t0.erp_code AS erpCode,GROUP_CONCAT(t2.attr_value ORDER BY t2.attr_value DESC) AS attrValue
FROM sku t0
LEFT JOIN attr_ref t1 ON t1.sku_id=t0.sku_id
LEFT JOIN attr_value t2 ON t2.value_id=t1.attr_value_id
LEFT JOIN attr_name t3 ON t3.attr_id=t2.attr_id
WHERE t0.sku_id=#{skuId}
GROUP BY t0.sku_id
ORDER BY t0.sku_id ASC,t2.attr_value ASC,t0.erp_code ASC,t3.attr_name ASC
</select>
</mapper>