WeFlowerCustomerRelMapper.xml
6.97 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
<?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.linkwechat.wecom.mapper.WeFlowerCustomerRelMapper">
<resultMap type="WeFlowerCustomerRel" id="WeFlowerCustomerRelResult">
<result property="id" column="id" />
<result property="userId" column="user_id" />
<result property="remark" column="remark" />
<result property="description" column="description" />
<result property="createTime" column="create_time" />
<result property="remarkCorpName" column="remark_corp_name" />
<!-- <result property="remarkMobiles" column="remark_mobiles" />-->
<result property="operUserid" column="oper_userid" />
<result property="addWay" column="add_way" />
<result property="state" column="state" />
<result property="customerId" column="customer_id" />
</resultMap>
<sql id="selectWeFlowerCustomerRelVo">
select id, user_id, remark, description, create_time, remark_corp_name, remark_mobiles, oper_userid, add_way, state, customer_id from we_flower_customer_rel
</sql>
<select id="selectWeFlowerCustomerRelList" parameterType="WeFlowerCustomerRel" resultMap="WeFlowerCustomerRelResult">
<include refid="selectWeFlowerCustomerRelVo"/>
<where>
<if test="userId != null and userId != ''"> and user_id = #{userId}</if>
<if test="description != null and description != ''"> and description = #{description}</if>
<if test="remarkCorpName != null and remarkCorpName != ''"> and remark_corp_name like concat('%', #{remarkCorpName}, '%')</if>
<if test="remarkMobiles != null and remarkMobiles != ''"> and remark_mobiles = #{remarkMobiles}</if>
<if test="operUserid != null and operUserid != ''"> and oper_userid = #{operUserid}</if>
<if test="addWay != null and addWay != ''"> and add_way = #{addWay}</if>
<if test="state != null and state != ''"> and state = #{state}</if>
<if test="customerId != null "> and customer_id = #{customerId}</if>
</where>
</select>
<select id="selectWeFlowerCustomerRelById" parameterType="Long" resultMap="WeFlowerCustomerRelResult">
<include refid="selectWeFlowerCustomerRelVo"/>
where id = #{id}
</select>
<insert id="insertWeFlowerCustomerRel" parameterType="WeFlowerCustomerRel">
insert into we_flower_customer_rel
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="userId != null">user_id,</if>
<if test="remark != null">remark,</if>
<if test="description != null">description,</if>
<if test="createTime != null">create_time,</if>
<if test="remarkCorpName != null">remark_corp_name,</if>
<!-- <if test="remarkMobiles != null">remark_mobiles,</if>-->
<if test="operUserid != null">oper_userid,</if>
<if test="addWay != null">add_way,</if>
<if test="state != null">state,</if>
<if test="customerId != null">customer_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="userId != null">#{userId},</if>
<if test="remark != null">#{remark},</if>
<if test="description != null">#{description},</if>
<if test="createTime != null">#{createTime},</if>
<if test="remarkCorpName != null">#{remarkCorpName},</if>
<!-- <if test="remarkMobiles != null">#{remarkMobiles},</if>-->
<if test="operUserid != null">#{operUserid},</if>
<if test="addWay != null">#{addWay},</if>
<if test="state != null">#{state},</if>
<if test="customerId != null">#{customerId},</if>
</trim>
</insert>
<update id="updateWeFlowerCustomerRel" parameterType="WeFlowerCustomerRel">
update we_flower_customer_rel
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="description != null">description = #{description},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="remarkCorpName != null">remark_corp_name = #{remarkCorpName},</if>
<!-- <if test="remarkMobiles != null">remark_mobiles = #{remarkMobiles},</if>-->
<if test="operUserid != null">oper_userid = #{operUserid},</if>
<if test="addWay != null">add_way = #{addWay},</if>
<if test="state != null">state = #{state},</if>
<if test="customerId != null">customer_id = #{customerId},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteWeFlowerCustomerRelById" parameterType="Long">
delete from we_flower_customer_rel where id = #{id}
</delete>
<delete id="deleteWeFlowerCustomerRelByIds" parameterType="String">
delete from we_flower_customer_rel where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<insert id="batchInsetWeFlowerCustomerRel" >
insert into we_flower_customer_rel (id, user_id, remark, description, create_time, remark_corp_name, remark_mobiles, oper_userid, add_way, state, customer_id)
values
<foreach collection="weFlowerCustomerRels" item="tag" index="index" separator=",">
(#{tag.id},#{tag.userId},#{tag.remark},#{tag.description},#{tag.createTime},#{tag.remarkCorpName},#{tag.remarkMobiles},#{tag.operUserid},#{tag.addWay},#{tag.state},#{tag.customerId})
</foreach>
</insert>
<update id="batchLogicDeleteByIds" parameterType="String">
update we_flower_customer_rel set del_flag=2
where id in
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<select id="getUserAddCustomerStat" parameterType="WeFlowerCustomerRel" resultType="java.util.HashMap">
select
left(wfcr.create_time,10) as createTime , count(1) as total
from
we_flower_customer_rel wfcr
<where>
<if test="userId != null and userId != ''">and wfcr.user_id = #{userId}</if>
<if test="addWay != null and addWay != ''">and wfcr.add_way = #{addWay}</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(wfcr.create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(wfcr.create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
</where>
group by
left(wfcr.create_time,10)
</select>
</mapper>