ProductTemplateMapper.xml
3.12 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
<?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.bs.order.mapper.ProductTemplateMapper">
<resultMap id="BaseResultMap" type="com.bs.order.entity.ProductTemplate">
<id property="id" column="id" />
<result property="product_name" column="product_name" />
<result property="product_code" column="product_code" />
<result property="price_unit_type" column="price_unit_type" />
<result property="price_unit_name" column="price_unit_name" />
<result property="created_by" column="created_by" />
<result property="created_date" column="created_date" />
<result property="updated_by" column="updated_by" />
<result property="updated_date" column="updated_date" />
<result property="deleted_flag" column="deleted_flag" />
</resultMap>
<resultMap id="DTOResultMap" type="com.bs.order.dto.ProductTemplateDTO" extends="BaseResultMap">
</resultMap>
<sql id="Base_Column_List">
id,product_name,product_code,price_unit_type,price_unit_name,created_by,
created_date,updated_by,updated_date,deleted_flag
</sql>
<select id="countOnShelfTotal" resultType="java.lang.Long">
select count(0) from bo_merchant_goods_info mgi
left join bo_upgrade_goods ug on ug.id=mgi.upgrade_goods_id and ug.deleted_flag='N'
where mgi.deleted_flag='N' and mgi.status=1 and ug.product_template_id=#{id}
</select>
<select id="list" resultMap="DTOResultMap">
select
id, product_name, product_code, price_unit_type, price_unit_name
from bo_product_template
<where>
deleted_flag = 'N'
<if test="query.productName != null and query.productName !=''">
and product_name like concat('%', #{query.productName}, '%')
</if>
<if test="query.productCode != null and query.productCode !=''">
and product_code like concat('%', #{query.productCode}, '%')
</if>
</where>
order by updated_date desc
</select>
<select id="listByProductTemplateIdList" resultMap="DTOResultMap">
select
ug.product_template_id as id,
GROUP_CONCAT(distinct gi.goods_name SEPARATOR "/") as spuGoodsNames,
GROUP_CONCAT(distinct gp.provider_name SEPARATOR "/") as providerNames
from bo_upgrade_goods ug
left join bo_goods_info gi on gi.goods_code=ug.goods_code
left join bo_upgrade_goods_provider_ref ugpr on ugpr.upgrade_goods_id=ug.id and ugpr.deleted_flag='N'
left join bo_goods_provider gp on gp.id=ugpr.provider_id and gp.deleted_flag='N'
<where>
ug.deleted_flag='N' and gi.deleted_flag='N'
and ug.product_template_id in
<foreach collection="productTemplateIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</where>
GROUP BY ug.product_template_id
</select>
</mapper>