97 lines
3.8 KiB
XML
97 lines
3.8 KiB
XML
<?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.ruoyi.group.mapper.CustGroupMemberMapper">
|
||
|
||
<select id="selectCustGroupMemberList" resultType="CustGroupMemberVO">
|
||
SELECT
|
||
cgm.id,
|
||
cgm.group_id,
|
||
cgm.cust_type,
|
||
cgm.cust_id,
|
||
cgm.cust_name,
|
||
cgm.cust_idc,
|
||
cgm.social_credit_code,
|
||
cgm.user_name,
|
||
cgm.nick_name,
|
||
cgm.outlet_id,
|
||
cgm.outlet_name,
|
||
cgm.branch_id,
|
||
cgm.branch_name,
|
||
cgm.create_time
|
||
FROM ibs_cust_group_member cgm
|
||
<where>
|
||
cgm.group_id = #{groupId}
|
||
AND cgm.del_flag = '0'
|
||
<if test="dto != null and dto.custType != null and dto.custType != ''">
|
||
AND cgm.cust_type = #{dto.custType}
|
||
</if>
|
||
<if test="dto != null and dto.custName != null and dto.custName != ''">
|
||
AND cgm.cust_name LIKE CONCAT('%', #{dto.custName}, '%')
|
||
</if>
|
||
<if test="dto != null and dto.userName != null and dto.userName != ''">
|
||
AND cgm.user_name = #{dto.userName}
|
||
</if>
|
||
<if test="dto != null and dto.nickName != null and dto.nickName != ''">
|
||
AND cgm.nick_name LIKE CONCAT('%', #{dto.nickName}, '%')
|
||
</if>
|
||
</where>
|
||
ORDER BY cgm.create_time ASC
|
||
</select>
|
||
|
||
<!-- 批量查询个人客户是否存在 -->
|
||
<select id="selectExistingRetailCustIds" resultType="String">
|
||
SELECT DISTINCT t.cust_id
|
||
FROM ibs_cust_group_member t
|
||
INNER JOIN cust_info_retail c ON t.cust_id = c.cust_id AND t.cust_idc = c.cust_idc
|
||
WHERE t.del_flag = '0'
|
||
AND t.cust_type = '0'
|
||
AND t.cust_id IN
|
||
<foreach collection="list" item="item" open="(" separator="," close=")">
|
||
#{item}
|
||
</foreach>
|
||
</select>
|
||
|
||
<!-- 批量查询商户客户是否存在 -->
|
||
<select id="selectExistingMerchantCustIds" resultType="String">
|
||
SELECT DISTINCT t.cust_id
|
||
FROM ibs_cust_group_member t
|
||
INNER JOIN cust_info_merchant c ON t.cust_id = c.cust_id AND t.social_credit_code = c.social_credit_code
|
||
WHERE t.del_flag = '0'
|
||
AND t.cust_type = '1'
|
||
AND t.cust_id IN
|
||
<foreach collection="list" item="item" open="(" separator="," close=")">
|
||
#{item}
|
||
</foreach>
|
||
</select>
|
||
|
||
<!-- 批量查询企业客户是否存在 -->
|
||
<select id="selectExistingBusinessCustIds" resultType="String">
|
||
SELECT DISTINCT t.cust_id
|
||
FROM ibs_cust_group_member t
|
||
INNER JOIN cust_info_business c ON t.cust_id = c.cust_id AND t.social_credit_code = c.social_credit_code
|
||
WHERE t.del_flag = '0'
|
||
AND t.cust_type = '2'
|
||
AND t.cust_id IN
|
||
<foreach collection="list" item="item" open="(" separator="," close=")">
|
||
#{item}
|
||
</foreach>
|
||
</select>
|
||
|
||
<!-- 批量插入客群客户(INSERT IGNORE,遇到重复键自动跳过) -->
|
||
<insert id="batchInsertMembers">
|
||
INSERT IGNORE INTO ibs_cust_group_member
|
||
(group_id, cust_type, cust_id, cust_name, cust_idc, social_credit_code,
|
||
user_name, nick_name, outlet_id, outlet_name, branch_id, branch_name,
|
||
create_by, create_time, del_flag, manual_remove)
|
||
VALUES
|
||
<foreach collection="list" item="item" index="index" separator=",">
|
||
(#{item.groupId}, #{item.custType}, #{item.custId}, #{item.custName}, #{item.custIdc}, #{item.socialCreditCode},
|
||
#{item.userName}, #{item.nickName}, #{item.outletId}, #{item.outletName}, #{item.branchId}, #{item.branchName},
|
||
#{item.createBy}, NOW(), '0', '0')
|
||
</foreach>
|
||
</insert>
|
||
|
||
</mapper>
|