CustomerDeviceMapper.xml
7.44 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?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="cn.com.glsx.dj.customer.mapper.CustomerDeviceMapper" >
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.customer.model.CustomerDevice" >
<!--
WARNING - @mbg.generated
-->
<id column="id" property="id" jdbcType="INTEGER" />
<result column="user_id" property="userId" jdbcType="INTEGER" />
<result column="employee_name" property="employeeName"/>
<result column="merchant_id" property="merchantId" jdbcType="INTEGER" />
<result column="merchant_name" property="merchantName" jdbcType="VARCHAR" />
<result column="imei" property="imei" jdbcType="VARCHAR" />
<result column="device_type_id" property="deviceTypeId" jdbcType="INTEGER" />
<result column="source" property="source" jdbcType="TINYINT" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR" />
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="phone" property="phone" jdbcType="INTEGER" />
<result column="stand_no" property="standNo" jdbcType="VARCHAR" />
<result column="d_d_code" property="DDCode" jdbcType="INTEGER"/>
<result column="plate_num" property="plateNum" jdbcType="VARCHAR"/>
<result column="vehicle_brand_id" property="vehicleBrandId" jdbcType="INTEGER" />
<result column="vehicle_brand" property="vehicleBrand" jdbcType="VARCHAR" />
<result column="vehicle_childs_brand_id" property="vehicleChildsBrandId" jdbcType="INTEGER" />
<result column="vehicle_childs_brand_name" property="vehicleChildsBrandName" jdbcType="VARCHAR" />
<result column="vehicle_series_id" property="vehicleSeriesId" jdbcType="INTEGER" />
<result column="vehicle_series_name" property="vehicleSeriesName" jdbcType="VARCHAR" />
<result column="vehicle_type_id" property="vehicleTypeId" jdbcType="INTEGER" />
<result column="vehicle_type_name" property="vehicleTypeName" jdbcType="VARCHAR" />
<result column="has_order" property="hasOrder" jdbcType="TINYINT" />
<result column="install_mileage" property="installMileage"/>
<result column="next_maintain_mileage" property="nextMaintainMileage"/>
<result column="next_maintain_time" property="nextMaintainTime"/>
<result column="last_maintain_mileage" property="lastMaintainMileage"/>
<result column="last_maintain_time" property="lastMaintainTime"/>
<result column="is_auth" property="isAuth"/>
<result column="is_shop_change" property="isShopChange"/>
<result column="is_auth_phone" property="isAuthPhone"/>
<result column="iccid" property="iccid"/>
<result column="dispatch_order_code" property="dispatchOrderCode"/>
<result column="gender" property="gender"/>
<result column="is_change" property="isChange"/>
</resultMap>
<resultMap id="DTOResultMap" type="cn.com.glsx.dj.customer.dto.CustomerDeviceDTO" extends="BaseResultMap"></resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
-->
id, user_id,employee_name, merchant_id, merchant_name, imei, device_type_id, source, created_by,
created_date, updated_by, updated_date, deleted_flag,is_auth,is_shop_change,
name,phone,stand_no,d_d_code,plate_num,has_order,is_auth_phone,
vehicle_brand_id,vehicle_brand,vehicle_childs_brand_id,vehicle_childs_brand_name,vehicle_series_id,
vehicle_series_name,vehicle_type_id,vehicle_type_name,gender,is_change,
install_mileage,next_maintain_mileage,next_maintain_time,last_maintain_mileage,last_maintain_time,iccid, dispatch_order_code
</sql>
<select id="list" parameterType="cn.com.glsx.dj.customer.dto.CustomerDeviceDTO" resultMap="DTOResultMap">
select <include refid="Base_Column_List" />
from dj_customer_device
<where>
deleted_flag = 'N'
<if test="userId != null">
and user_id = #{userId}
</if>
<if test="isAuth != null">
and is_auth = #{isAuth}
</if>
<if test="employeeName != null and employeeName !=''">
and employee_name like CONCAT('%',#{employeeName},'%')
</if>
<if test="merchantId != null">
and merchant_id = #{merchantId}
</if>
<if test="merchantName != null and merchantName !=''">
and merchant_name like CONCAT('%',#{merchantName},'%')
</if>
<if test="standNo != null and standNo !=''">
and stand_no = #{standNo}
</if>
<if test="name != null and name !=''">
and name = #{name}
</if>
<if test="imei != null and imei !=''">
and imei = #{imei}
</if>
<if test="deviceTypeId != null">
and device_type_id = #{deviceTypeId}
</if>
<if test="createdBy != null and createdBy !=''">
and created_by like CONCAT('%',#{createdBy},'%')
</if>
<if test="startDate != null">
<![CDATA[ and created_date >= #{startDate} ]]>
</if>
<if test="endDate != null">
<![CDATA[ and created_date <= #{endDate} ]]>
</if>
<if test="merchantIds != null and merchantIds.size > 0 ">
and merchant_id in
<foreach item="item" index="index" collection="merchantIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="dispatchOrderCode != null and dispatchOrderCode != ''">
and dispatch_order_code = #{dispatchOrderCode}
</if>
<if test="source != null">
and source = #{source}
</if>
<if test="isBind != null and isBind == 0">
and stand_no is null
</if>
<if test="isBind != null and isBind == 1">
and stand_no is not null
</if>
</where>
order by updated_date desc
</select>
<select id="getNotdidi" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from dj_customer_device
<where>
deleted_flag = 'N'
and (
d_d_code is NULL
and IFNULL(is_auth_phone,0) != '1'
and IFNULL(is_shop_change,0) != '1'
)
or IFNULL(is_auth_phone,0) != '1'
</where>
order by id desc
</select>
<select id="listAll" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from dj_customer_device
<where>
deleted_flag = 'N'
</where>
order by id desc
</select>
<select id="getCountCustomerAndOrder" parameterType="java.util.List" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT a.sub_device_sn)
FROM (
SELECT DISTINCT sub_device_sn
FROM dj_insure_order
<where>
insurance_status = 1 AND deleted_flag = 'N'
and merchant_id in
<foreach item="merchantId" index="index" collection="merchantIds" open="(" separator="," close=")">
#{merchantId}
</foreach>
</where>
UNION ALL
SELECT DISTINCT imei AS sub_device_sn
FROM dj_customer_device
<where>
deleted_flag = 'N'
and merchant_id in
<foreach item="merchantId" index="index" collection="merchantIds" open="(" separator="," close=")">
#{merchantId}
</foreach>
</where>
) a
</select>
<delete id="deleteById" parameterType="java.lang.Integer">
DELETE FROM dj_customer_device WHERE id = #{id}
</delete>
<update id="updateGenderAndIsChangeById" parameterType="cn.com.glsx.dj.customer.model.CustomerDevice" >
update dj_customer_device
<set>
gender =#{gender},is_change =#{isChange},
</set>
<where>
deleted_flag = 'N'
and id = #{id}
</where>
</update>
</mapper>