|
@@ -8,6 +8,15 @@
|
|
|
cus_id, cus_code, cus_name, cus_phone, address_area, address_name, address_no, address_gcj02, address_full, contact_name, contact_phone, cus_from, channel_id, org_id, staff_id, report_staff, report_time, sale_status, remarks, follow_staffs, last_follow_staff, last_follow_id, last_follow_status, last_follow_time, follow_count, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
|
|
cus_id, cus_code, cus_name, cus_phone, address_area, address_name, address_no, address_gcj02, address_full, contact_name, contact_phone, cus_from, channel_id, org_id, staff_id, report_staff, report_time, sale_status, remarks, follow_staffs, last_follow_staff, last_follow_id, last_follow_status, last_follow_time, follow_count, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
|
|
|
</sql>
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <sql id="Base_Column_List_Response">
|
|
|
|
|
+ tmc.cus_id, tmc.cus_code,tmc.cus_name, tmc.cus_phone, tmc.address_area, tmc.address_name, tmc.address_no,
|
|
|
|
|
+ tmc.address_gcj02, tmc.address_full, tmc.contact_name, tmc.contact_phone, tmc.cus_from, tmc.channel_id,
|
|
|
|
|
+ tmc.org_id, tmc.staff_id, tmc.report_staff, tmc.report_time, tmc.sale_status, tmc.remarks, tmc.follow_staffs,
|
|
|
|
|
+ tmc.last_follow_staff, tmc.last_follow_id, tmc.last_follow_status, tmc.last_follow_time, tmc.follow_count, tmc.flg_valid, tmc.cp_id
|
|
|
|
|
+ </sql>
|
|
|
|
|
+
|
|
|
<!-- 通用查询映射结果 -->
|
|
<!-- 通用查询映射结果 -->
|
|
|
<resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.Customer">
|
|
<resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.Customer">
|
|
|
<id column="cus_id" property="cusId"/>
|
|
<id column="cus_id" property="cusId"/>
|
|
@@ -46,108 +55,126 @@
|
|
|
<result column="op_db_user" property="opDbUser"/>
|
|
<result column="op_db_user" property="opDbUser"/>
|
|
|
</resultMap>
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
+ <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mst.CustomerResponse">
|
|
|
|
|
+ <id column="cus_id" property="cusId"/>
|
|
|
|
|
+ <result column="cus_code" property="cusCode"/>
|
|
|
|
|
+ <result column="cus_name" property="cusName"/>
|
|
|
|
|
+ <result column="cus_phone" property="cusPhone"/>
|
|
|
|
|
+ <result column="address_area" property="addressArea" typeHandler="JsonTypeHandler"/>
|
|
|
|
|
+ <result column="address_name" property="addressName"/>
|
|
|
|
|
+ <result column="address_no" property="addressNo"/>
|
|
|
|
|
+ <result column="address_gcj02" property="addressGcj02" typeHandler="JsonTypeHandler"/>
|
|
|
|
|
+ <result column="address_full" property="addressFull"/>
|
|
|
|
|
+ <result column="contact_name" property="contactName"/>
|
|
|
|
|
+ <result column="contact_phone" property="contactPhone"/>
|
|
|
|
|
+ <result column="cus_from" property="cusFrom" typeHandler="UuidTypeHandler"/>
|
|
|
|
|
+ <result column="channel_id" property="channelId" typeHandler="UuidTypeHandler"/>
|
|
|
|
|
+ <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
|
|
|
|
|
+ <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
|
|
|
|
|
+ <result column="report_staff" property="reportStaff" typeHandler="UuidTypeHandler"/>
|
|
|
|
|
+ <result column="report_time" property="reportTime" typeHandler="TimestampTypeHandler"/>
|
|
|
|
|
+ <result column="sale_status" property="saleStatus"/>
|
|
|
|
|
+ <result column="remarks" property="remarks"/>
|
|
|
|
|
+ <result column="follow_staffs" property="followStaffs" typeHandler="UuidListTypeHandler"/>
|
|
|
|
|
+ <result column="last_follow_staff" property="lastFollowStaff" typeHandler="UuidTypeHandler"/>
|
|
|
|
|
+ <result column="last_follow_id" property="lastFollowId" typeHandler="UuidTypeHandler"/>
|
|
|
|
|
+ <result column="last_follow_status" property="lastFollowStatus"/>
|
|
|
|
|
+ <result column="last_follow_time" property="lastFollowTime" typeHandler="TimestampTypeHandler"/>
|
|
|
|
|
+ <result column="follow_count" property="followCount"/>
|
|
|
|
|
+ <result column="flg_valid" property="flgValid"/>
|
|
|
|
|
+ <result column="cp_id" property="cpId"/>
|
|
|
|
|
+ <result column="cusFromName" property="cusFromName"/>
|
|
|
|
|
+ <result column="channelName" property="channelName"/>
|
|
|
|
|
+ <result column="orgName" property="orgName"/>
|
|
|
|
|
+ <result column="staffName" property="staffName"/>
|
|
|
|
|
+ <result column="reportStaffName" property="reportStaffName"/>
|
|
|
|
|
+ <result column="followStaffName" property="followStaffName"/>
|
|
|
|
|
+ <result column="lastFollowStaffName" property="lastFollowStaffName"/>
|
|
|
|
|
+
|
|
|
|
|
+ </resultMap>
|
|
|
|
|
+
|
|
|
<!-- 通用条件列 -->
|
|
<!-- 通用条件列 -->
|
|
|
<sql id="Condition">
|
|
<sql id="Condition">
|
|
|
<where>
|
|
<where>
|
|
|
<if test="cusCode != null and cusCode != ''">
|
|
<if test="cusCode != null and cusCode != ''">
|
|
|
- AND cus_code = #{cusCode}
|
|
|
|
|
|
|
+ AND tmc.cus_code = #{cusCode}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="cusName != null and cusName != ''">
|
|
<if test="cusName != null and cusName != ''">
|
|
|
- AND cus_name = #{cusName}
|
|
|
|
|
|
|
+ AND tmc.cus_name = #{cusName}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="cusPhone != null and cusPhone != ''">
|
|
<if test="cusPhone != null and cusPhone != ''">
|
|
|
- AND cus_phone = #{cusPhone}
|
|
|
|
|
|
|
+ AND tmc.cus_phone = #{cusPhone}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="addressArea != null and addressArea != ''">
|
|
<if test="addressArea != null and addressArea != ''">
|
|
|
- AND address_area = #{addressArea}
|
|
|
|
|
|
|
+ AND tmc.address_area = #{addressArea}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="addressName != null and addressName != ''">
|
|
<if test="addressName != null and addressName != ''">
|
|
|
- AND address_name = #{addressName}
|
|
|
|
|
|
|
+ AND tmc.address_name = #{addressName}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="addressNo != null and addressNo != ''">
|
|
<if test="addressNo != null and addressNo != ''">
|
|
|
- AND address_no = #{addressNo}
|
|
|
|
|
|
|
+ AND tmc.address_no = #{addressNo}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="addressGcj02 != null and addressGcj02 != ''">
|
|
<if test="addressGcj02 != null and addressGcj02 != ''">
|
|
|
- AND address_gcj02 = #{addressGcj02}
|
|
|
|
|
|
|
+ AND tmc.address_gcj02 = #{addressGcj02}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="addressFull != null and addressFull != ''">
|
|
<if test="addressFull != null and addressFull != ''">
|
|
|
- AND address_full = #{addressFull}
|
|
|
|
|
|
|
+ AND tmc.address_full = #{addressFull}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="contactName != null and contactName != ''">
|
|
<if test="contactName != null and contactName != ''">
|
|
|
- AND contact_name = #{contactName}
|
|
|
|
|
|
|
+ AND tmc.contact_name = #{contactName}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="contactPhone != null and contactPhone != ''">
|
|
<if test="contactPhone != null and contactPhone != ''">
|
|
|
- AND contact_phone = #{contactPhone}
|
|
|
|
|
|
|
+ AND tmc.contact_phone = #{contactPhone}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="cusFrom != null and cusFrom != ''">
|
|
<if test="cusFrom != null and cusFrom != ''">
|
|
|
- AND cus_from = #{cusFrom}
|
|
|
|
|
|
|
+ AND tmc.cus_from = #{cusFrom}::uuid
|
|
|
</if>
|
|
</if>
|
|
|
<if test="channelId != null and channelId != ''">
|
|
<if test="channelId != null and channelId != ''">
|
|
|
- AND channel_id = #{channelId}
|
|
|
|
|
|
|
+ AND tmc.channel_id = #{channelId}::uuid
|
|
|
</if>
|
|
</if>
|
|
|
<if test="orgId != null and orgId != ''">
|
|
<if test="orgId != null and orgId != ''">
|
|
|
- AND org_id = #{orgId}
|
|
|
|
|
|
|
+ AND tmc.org_id = #{orgId}::uuid
|
|
|
</if>
|
|
</if>
|
|
|
<if test="staffId != null and staffId != ''">
|
|
<if test="staffId != null and staffId != ''">
|
|
|
- AND staff_id = #{staffId}
|
|
|
|
|
|
|
+ AND tmc.staff_id = #{staffId}::uuid
|
|
|
</if>
|
|
</if>
|
|
|
<if test="reportStaff != null and reportStaff != ''">
|
|
<if test="reportStaff != null and reportStaff != ''">
|
|
|
- AND report_staff = #{reportStaff}
|
|
|
|
|
|
|
+ AND tmc.report_staff = #{reportStaff}::uuid
|
|
|
</if>
|
|
</if>
|
|
|
<if test="reportTime != null">
|
|
<if test="reportTime != null">
|
|
|
- AND report_time = #{reportTime}
|
|
|
|
|
|
|
+ AND tmc.report_time = #{reportTime}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="saleStatus != null and saleStatus != ''">
|
|
<if test="saleStatus != null and saleStatus != ''">
|
|
|
- AND sale_status = #{saleStatus}
|
|
|
|
|
|
|
+ AND tmc.sale_status = #{saleStatus}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="remarks != null and remarks != ''">
|
|
<if test="remarks != null and remarks != ''">
|
|
|
- AND remarks = #{remarks}
|
|
|
|
|
|
|
+ AND tmc.remarks = #{remarks}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="followStaffs != null and followStaffs != ''">
|
|
<if test="followStaffs != null and followStaffs != ''">
|
|
|
- AND follow_staffs = #{followStaffs}
|
|
|
|
|
|
|
+ AND tmc.follow_staffs = #{followStaffs}::uuid
|
|
|
</if>
|
|
</if>
|
|
|
<if test="lastFollowStaff != null and lastFollowStaff != ''">
|
|
<if test="lastFollowStaff != null and lastFollowStaff != ''">
|
|
|
- AND last_follow_staff = #{lastFollowStaff}
|
|
|
|
|
|
|
+ AND tmc.last_follow_staff = #{lastFollowStaff}::uuid
|
|
|
</if>
|
|
</if>
|
|
|
<if test="lastFollowId != null and lastFollowId != ''">
|
|
<if test="lastFollowId != null and lastFollowId != ''">
|
|
|
- AND last_follow_id = #{lastFollowId}
|
|
|
|
|
|
|
+ AND tmc.last_follow_id = #{lastFollowId}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="lastFollowStatus != null and lastFollowStatus != ''">
|
|
<if test="lastFollowStatus != null and lastFollowStatus != ''">
|
|
|
- AND last_follow_status = #{lastFollowStatus}
|
|
|
|
|
|
|
+ AND tmc.last_follow_status = #{lastFollowStatus}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="lastFollowTime != null">
|
|
<if test="lastFollowTime != null">
|
|
|
- AND last_follow_time = #{lastFollowTime}
|
|
|
|
|
|
|
+ AND tmc.last_follow_time = #{lastFollowTime}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="followCount != null">
|
|
<if test="followCount != null">
|
|
|
- AND follow_count = #{followCount}
|
|
|
|
|
|
|
+ AND tmc.follow_count = #{followCount}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="flgValid != null">
|
|
<if test="flgValid != null">
|
|
|
- AND flg_valid = #{flgValid}
|
|
|
|
|
|
|
+ AND tmc.flg_valid = #{flgValid}
|
|
|
</if>
|
|
</if>
|
|
|
<if test="cpId != null">
|
|
<if test="cpId != null">
|
|
|
- AND cp_id = #{cpId}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="opCreateTime != null">
|
|
|
|
|
- AND op_create_time = #{opCreateTime}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="opCreateUserId != null and opCreateUserId != ''">
|
|
|
|
|
- AND op_create_user_id = #{opCreateUserId}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="opUpdateTime != null">
|
|
|
|
|
- AND op_update_time = #{opUpdateTime}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="opUpdateUserId != null and opUpdateUserId != ''">
|
|
|
|
|
- AND op_update_user_id = #{opUpdateUserId}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="opAppCode != null and opAppCode != ''">
|
|
|
|
|
- AND op_app_code = #{opAppCode}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="opTimestamp != null">
|
|
|
|
|
- AND op_timestamp = #{opTimestamp}
|
|
|
|
|
- </if>
|
|
|
|
|
- <if test="opDbUser != null and opDbUser != ''">
|
|
|
|
|
- AND op_db_user = #{opDbUser}
|
|
|
|
|
|
|
+ AND tmc.cp_id = #{cpId}
|
|
|
</if>
|
|
</if>
|
|
|
|
|
+
|
|
|
</where>
|
|
</where>
|
|
|
</sql>
|
|
</sql>
|
|
|
|
|
|
|
@@ -160,10 +187,24 @@
|
|
|
</sql>
|
|
</sql>
|
|
|
|
|
|
|
|
<!-- 查询表t_mst_customer,(条件查询+分页)列表 -->
|
|
<!-- 查询表t_mst_customer,(条件查询+分页)列表 -->
|
|
|
- <select id="selectByCond" resultMap="BaseResultMap">
|
|
|
|
|
|
|
+ <select id="selectByCond" resultMap="BaseResultMapResponse">
|
|
|
SELECT
|
|
SELECT
|
|
|
- <include refid="Base_Column_List"/>
|
|
|
|
|
- FROM t_mst_customer
|
|
|
|
|
|
|
+ <include refid="Base_Column_List_Response"/>,
|
|
|
|
|
+ tmd.data_value AS "cusFromName",
|
|
|
|
|
+ tmsc.channel_name AS "channelName",
|
|
|
|
|
+ tmo.org_name AS "orgName",
|
|
|
|
|
+ tms.staff_name AS "staffName",
|
|
|
|
|
+ tms2.staff_name AS "reportStaffName"
|
|
|
|
|
+-- tms3.staff_name AS "followStaffName",
|
|
|
|
|
+-- tms4.staff_name AS "lastFollowStaffName"
|
|
|
|
|
+ FROM dkic_b.t_mst_customer tmc
|
|
|
|
|
+ LEFT JOIN dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tmc.cus_from
|
|
|
|
|
+ LEFT JOIN dkic_b.t_mst_sale_channel tmsc on tmsc.channel_id = tmc.channel_id
|
|
|
|
|
+ LEFT JOIN dkic_b.t_mst_org tmo on tmo.org_id = tmc.org_id
|
|
|
|
|
+ LEFT JOIN dkic_b.t_mst_staff tms on tms.staff_id = tmc.staff_id
|
|
|
|
|
+ LEFT JOIN dkic_b.t_mst_staff tms2 on tms2.staff_id = tmc.report_staff
|
|
|
|
|
+-- LEFT JOIN dkic_b.t_mst_staff tms3 on tms3.staff_id = tmc.follow_staffs
|
|
|
|
|
+-- LEFT JOIN dkic_b.t_mst_staff tms4 on tms4.staff_id = tmc.last_follow_staff
|
|
|
<include refid="Condition"/>
|
|
<include refid="Condition"/>
|
|
|
<if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
<if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
limit #{end} offset #{start}
|
|
limit #{end} offset #{start}
|
|
@@ -174,7 +215,7 @@
|
|
|
<select id="countByCond" resultType="Long">
|
|
<select id="countByCond" resultType="Long">
|
|
|
SELECT
|
|
SELECT
|
|
|
count(1)
|
|
count(1)
|
|
|
- FROM t_mst_customer
|
|
|
|
|
|
|
+ FROM dkic_b.t_mst_customer
|
|
|
<include refid="Condition"/>
|
|
<include refid="Condition"/>
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
@@ -182,7 +223,7 @@
|
|
|
<select id="selectById" resultMap="BaseResultMap">
|
|
<select id="selectById" resultMap="BaseResultMap">
|
|
|
SELECT
|
|
SELECT
|
|
|
<include refid="Base_Column_List"/>
|
|
<include refid="Base_Column_List"/>
|
|
|
- FROM t_mst_customer
|
|
|
|
|
|
|
+ FROM dkic_b.t_mst_customer
|
|
|
WHERE cus_id = #{cusId}::uuid
|
|
WHERE cus_id = #{cusId}::uuid
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
@@ -190,7 +231,7 @@
|
|
|
<select id="selectByIdForUpdate" resultMap="BaseResultMap">
|
|
<select id="selectByIdForUpdate" resultMap="BaseResultMap">
|
|
|
SELECT
|
|
SELECT
|
|
|
<include refid="Base_Column_List"/>
|
|
<include refid="Base_Column_List"/>
|
|
|
- FROM t_mst_customer
|
|
|
|
|
|
|
+ FROM dkic_b.t_mst_customer
|
|
|
WHERE cus_id = #{cusId}
|
|
WHERE cus_id = #{cusId}
|
|
|
for update
|
|
for update
|
|
|
</select>
|
|
</select>
|
|
@@ -199,13 +240,13 @@
|
|
|
<select id="selectByIdsForUpdate" resultMap="BaseResultMap">
|
|
<select id="selectByIdsForUpdate" resultMap="BaseResultMap">
|
|
|
SELECT
|
|
SELECT
|
|
|
<include refid="Base_Column_List"/>
|
|
<include refid="Base_Column_List"/>
|
|
|
- FROM t_mst_customer
|
|
|
|
|
|
|
+ FROM dkic_b.t_mst_customer
|
|
|
<include refid="idsForeach"/>
|
|
<include refid="idsForeach"/>
|
|
|
for update
|
|
for update
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<insert id="insertBatch">
|
|
<insert id="insertBatch">
|
|
|
- insert into t_mst_customer
|
|
|
|
|
|
|
+ insert into dkic_b.t_mst_customer
|
|
|
(
|
|
(
|
|
|
<trim suffixOverrides=",">
|
|
<trim suffixOverrides=",">
|
|
|
cus_code,
|
|
cus_code,
|