892 lines
52 KiB
XML
892 lines
52 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.ibs.customerselect.mapper.CustInfoBusinessMapper">
|
|
|
|
<resultMap type="CustInfoBusiness" id="CustInfoBusinessResult">
|
|
<result property="id" column="id" />
|
|
<result property="custType" column="cust_type" />
|
|
<result property="custTag" column="cust_tag" />
|
|
<result property="custScale" column="cust_scale" />
|
|
<result property="custName" column="cust_name" />
|
|
<result property="lpName" column="lp_name" />
|
|
<result property="custPhone" column="cust_phone" />
|
|
<result property="custId" column="cust_id" />
|
|
<result property="custIsn" column="cust_isn" />
|
|
<result property="custCapital" column="cust_capital" />
|
|
<result property="custLocation" column="cust_location" />
|
|
<result property="loanTag" column="loan_tag" />
|
|
<result property="status" column="status" />
|
|
<result property="belongBranchId" column="belong_branch_id" />
|
|
<result property="belongBranchName" column="belong_branch_name" />
|
|
<result property="belongOutletId" column="belong_outlet_id" />
|
|
<result property="belongOutletName" column="belong_outlet_name" />
|
|
<result property="belongUserId" column="belong_user_id" />
|
|
<result property="belongUserName" column="belong_user_name" />
|
|
<result property="belongUserNameList" column="belong_user_name_list" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="regionCode" column="region_code" />
|
|
<result property="socialCreditCode" column="social_credit_code" />
|
|
<result property="tel" column="tel" />
|
|
<result property="registerLocation" column="register_location" />
|
|
<result property="businessScope" column="business_scope" />
|
|
<result property="taxpayerIdentificationNumber" column="taxpayer_identification_number" />
|
|
<result property="taxpayerQualification" column="taxpayer_qualification" />
|
|
<result property="label" column="label" />
|
|
<result property="industry" column="industry" />
|
|
<result property="custIdc" column="cust_idc" />
|
|
<result property="custAge" column="cust_age" />
|
|
<result property="custGender" column="cust_gender" />
|
|
<result property="birthday" column="birthday" />
|
|
<result property="recordStatus" column="record_status" />
|
|
<result property="asset" column="asset" />
|
|
<result property="credit" column="credit" />
|
|
</resultMap>
|
|
<resultMap type="CustInfoBusiness" id="CustInfoBusinessResult2">
|
|
<result property="id" column="id" />
|
|
<result property="custType" column="cust_type" />
|
|
<result property="custTag" column="cust_tag" />
|
|
<result property="custScale" column="cust_scale" />
|
|
<result property="custName" column="cust_name" />
|
|
<result property="lpName" column="lp_name" />
|
|
<result property="custPhone" column="cust_phone" />
|
|
<result property="custId" column="cust_id" />
|
|
<result property="custIsn" column="cust_isn" />
|
|
<result property="custCapital" column="cust_capital" />
|
|
<result property="custLocation" column="cust_location" />
|
|
<result property="loanTag" column="loan_tag" />
|
|
<result property="status" column="status" />
|
|
<result property="belongBranchId" column="belong_branch_id" />
|
|
<result property="belongBranchName" column="dept_name" />
|
|
<result property="belongOutletId" column="belong_outlet_id" />
|
|
<result property="belongOutletName" column="outlets" />
|
|
<result property="belongUserId" column="belong_user_id" />
|
|
<result property="belongUserName" column="belong_user_name" />
|
|
<result property="belongUserNameList" column="belong_user_name_list" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="regionCode" column="region_code" />
|
|
<result property="socialCreditCode" column="social_credit_code" />
|
|
<result property="tel" column="tel" />
|
|
<result property="registerLocation" column="register_location" />
|
|
<result property="businessScope" column="business_scope" />
|
|
<result property="taxpayerIdentificationNumber" column="taxpayer_identification_number" />
|
|
<result property="taxpayerQualification" column="taxpayer_qualification" />
|
|
<result property="label" column="label" />
|
|
<result property="industry" column="industry" />
|
|
<result property="custIdc" column="cust_idc" />
|
|
<result property="custAge" column="cust_age" />
|
|
<result property="custGender" column="cust_gender" />
|
|
<result property="birthday" column="birthday" />
|
|
</resultMap>
|
|
|
|
<resultMap type="CustManageInfo" id="CustManageInfoResult">
|
|
<result property="custId" column="cust_id" />
|
|
<result property="custName" column="cust_name" />
|
|
<result property="custNo" column="social_credit_code" />
|
|
<result property="belongUserId" column="user_name" />
|
|
<result property="belongUserName" column="nick_name" />
|
|
<result property="custPattern" column="cust_type" />
|
|
<result property="regionCode" column="region_code" />
|
|
</resultMap>
|
|
|
|
<sql id="selectCustInfoBusinessVo">
|
|
select id, cust_type, cust_tag, cust_scale, cust_name, lp_name, cust_phone, cust_id, cust_isn, cust_capital, cust_location, loan_tag, status, belong_branch_id, belong_branch_name, belong_outlet_id, belong_outlet_name, belong_user_id, belong_user_name, create_by, create_time, update_by, update_time, region_code, social_credit_code, tel,
|
|
register_location, business_scope, taxpayer_identification_number, taxpayer_qualification, label, industry, cust_idc,cust_age,cust_gender,birthday,record_status from cust_info_business
|
|
</sql>
|
|
|
|
<select id="selectCustInfoBusinessList" parameterType="CustInfoBusiness" resultMap="CustInfoBusinessResult2">
|
|
|
|
SELECT a.id, a.cust_type, a.cust_tag, a.cust_scale, a.cust_name, a.lp_name,
|
|
a.cust_phone, a.cust_id, a.cust_isn,a.loan_tag,a.cust_capital,
|
|
GROUP_CONCAT(b.dept_name SEPARATOR ',') as dept_name,
|
|
GROUP_CONCAT(b.outlets SEPARATOR ',') as outlets,
|
|
a.cust_idc,GROUP_CONCAT(b.user_name SEPARATOR ',') as belong_user_name_list
|
|
from cust_info_business a
|
|
<if test="opsDept != null and opsDept != ''">
|
|
inner </if>
|
|
<if test="opsDept == null or opsDept == ''">
|
|
left </if>
|
|
join (select user_name,user_id,dept_id,cust_id,dept_name,outlets from
|
|
(select concat_ws('-',user_name,teller_id) as user_name,user_id,dept_id,cust_id,dept_name,outlets from cust_dept_user_grid
|
|
<where>
|
|
<if test="opsDept != null and opsDept != ''">
|
|
ops_dept = #{opsDept}</if>
|
|
</where>
|
|
union
|
|
(select '', t2.user_id,t2.dept_id,t2.cust_id,'','' from cust_dept_user_cmpm t2
|
|
left join (select cust_id from cust_dept_user_grid
|
|
<where>
|
|
<if test="opsDept != null and opsDept != ''">
|
|
ops_dept = #{opsDept}</if>
|
|
</where>
|
|
group by cust_id)t1 on t2.cust_id = t1.cust_id
|
|
where (t1.cust_id is null or t1.cust_id = '') and t2.cust_type = '2' and t2.dept_id is not null)) f
|
|
where 1=1
|
|
<if test = "isHead == false">
|
|
${params.dataScope}
|
|
</if>
|
|
) b on a.cust_id = b.cust_id
|
|
<where>
|
|
<if test = "isHead == false">
|
|
b.user_id>0
|
|
</if>
|
|
<if test="custTag != null and custTag != ''"> and
|
|
((CASE WHEN substr(#{custTag}, 1, 1) = '1' THEN substr(a.cust_tag, 1, 1) = '1' end)
|
|
OR (CASE WHEN substr(#{custTag}, 2, 1) = '1' THEN substr(a.cust_tag, 2, 1) = '1' end)
|
|
OR (CASE WHEN substr(#{custTag}, 3, 1) = '1' THEN substr(a.cust_tag, 3, 1) = '1' end))
|
|
</if>
|
|
<if test="custName != null and custName != ''"> and a.cust_name like concat('%', #{custName}, '%') </if>
|
|
<if test="custType != null and custType != ''"> and a.cust_type = #{custType}</if>
|
|
<if test="custScale != null and custScale != ''">
|
|
and ( a.cust_scale = '5'
|
|
<if test="
|
|
custScale0 != null and custScale0 != ''">or a.cust_scale = #{custScale0}</if>
|
|
<if test="
|
|
custScale1 != null and custScale1 != ''">or a.cust_scale = #{custScale1}</if>
|
|
<if test="
|
|
custScale2 != null and custScale2 != ''">or a.cust_scale = #{custScale2}</if>
|
|
<if test="
|
|
custScale3 != null and custScale3 != ''">or a.cust_scale = #{custScale3}</if>
|
|
)
|
|
</if>
|
|
</where>
|
|
group by a.cust_id,a.id
|
|
limit #{start},#{size}
|
|
</select>
|
|
|
|
<select id="selectCustInfoBusinessListHead" parameterType="CustInfoBusiness" resultType="com.ruoyi.ibs.customerselect.domain.CustBaseInfo">
|
|
SELECT a.id, a.cust_type, a.cust_tag, a.cust_scale, a.cust_name, a.lp_name,
|
|
a.cust_phone, a.cust_id, a.cust_isn,a.loan_tag,a.cust_capital,a.asset,a.credit,
|
|
null as dept_name,
|
|
null as outlets,
|
|
a.cust_idc,null as belong_user_name_list,
|
|
a.hq_cur_balance, a.bz_cur_balance, a.is_credit,
|
|
a.loan_balance_cny, a.loan_year_dailyaverage, a.is_htqy, a.finance_prod_716_open_flag, a.finance_prod_716_balance,
|
|
a.finance_prod_711_open_flag, a.finance_prod_711_balance, a.intl_bussiness_jcbh_open_flag, a.is_ustr,
|
|
a.ustr_count_per_m, a.ustr_bal_m, a.eleccharge_sign_flag, a.watercharge_sign_flag, a.taxdeduction_sign_flag,
|
|
a.pjb, a.czb, a.sfb, a.mrb, a.szst, a.is_open_sts, a.intl_bussiness_open_flag, a.intl_bussiness_325_open_flag,
|
|
a.is_365zf,a.is_180zf,a.is_90zf,a.is_30zf, a.cust_level
|
|
from cust_info_business a
|
|
<where>
|
|
<if test="regionTopGridIds != null and regionTopGridIds.size() > 0 ">
|
|
AND a.cust_id IN (
|
|
SELECT cust_id
|
|
FROM grid_region_cust_user grcu
|
|
<where>
|
|
<if test="regionTopGridIds != null and regionTopGridIds.size()>0">
|
|
<foreach collection="regionTopGridIds" item="param" separator="or">
|
|
grcu.top_grid_id = #{param.value}
|
|
</foreach>
|
|
</if>
|
|
)
|
|
</where>
|
|
</if>
|
|
<if test="regionSecGridIds != null and regionSecGridIds.size()>0">
|
|
AND a.cust_id IN (
|
|
SELECT cust_id
|
|
FROM grid_region_cust_user grcu
|
|
<where>
|
|
<foreach collection="regionSecGridIds" item="param" separator="or">
|
|
grcu.sec_grid_id = #{param.value}
|
|
</foreach>
|
|
</where>
|
|
)
|
|
</if>
|
|
<if test="virtualGridIds != null and virtualGridIds.size() > 0 ">
|
|
AND a.cust_id IN (
|
|
SELECT cust_id
|
|
FROM grid_virtual_cust_user gvcu
|
|
<where>
|
|
<foreach collection="virtualGridIds" item="param" separator="or">
|
|
gvcu.grid_id = #{param.value}
|
|
</foreach>
|
|
</where>
|
|
)
|
|
</if>
|
|
<if test="drawGridIds != null and drawGridIds.size() > 0 ">
|
|
AND a.cust_id IN (
|
|
SELECT dsc.cust_id
|
|
FROM grid_draw_user_relate gdur
|
|
INNER JOIN grid_draw_shape_relate gdsr ON gdur.grid_id = gdsr.grid_id
|
|
INNER JOIN draw_shape_cust dsc ON gdsr.shape_id = dsc.shape_id
|
|
<where>
|
|
<foreach collection="drawGridIds" item="param" separator="or">
|
|
gdur.grid_id = #{param.value}
|
|
</foreach>
|
|
</where>
|
|
)
|
|
</if>
|
|
<if test="continuousParams != null and continuousParams.size() > 0 or discreteParams != null and discreteParams.size() > 0">
|
|
<if test="continuousParams != null and continuousParams.size() > 0">
|
|
and
|
|
<foreach collection="continuousParams" item="param" separator="and">
|
|
<choose>
|
|
<when test="param.value[0] != null and param.value[0] != '' and param.value[1] != null and param.value[1] != ''">
|
|
CAST(${param.key} AS DECIMAL(10,2)) BETWEEN CAST(#{param.value[0]} AS DECIMAL(10,2)) AND CAST(#{param.value[1]} AS DECIMAL(10,2))
|
|
</when>
|
|
<when test="param.value[0] != null and param.value[0] != ''">
|
|
CAST(${param.key} AS DECIMAL(10,2)) >= CAST(#{param.value[0]} AS DECIMAL(10,2))
|
|
</when>
|
|
<when test="param.value[1] != null and param.value[1] != ''">
|
|
CAST(${param.key} AS DECIMAL(10,2)) <= CAST(#{param.value[1]} AS DECIMAL(10,2))
|
|
</when>
|
|
</choose>
|
|
</foreach>
|
|
</if>
|
|
<if test="discreteParams != null and discreteParams.size() > 0">
|
|
and
|
|
<foreach collection="discreteParams" item="param" separator="and">
|
|
${param.key} = #{param.value}
|
|
</foreach>
|
|
</if>
|
|
</if>
|
|
<if test="custTag != null and custTag != ''"> and
|
|
((CASE WHEN substr(#{custTag}, 1, 1) = '1' THEN substr(a.cust_tag, 1, 1) = '1' end)
|
|
OR (CASE WHEN substr(#{custTag}, 2, 1) = '1' THEN substr(a.cust_tag, 2, 1) = '1' end)
|
|
OR (CASE WHEN substr(#{custTag}, 3, 1) = '1' THEN substr(a.cust_tag, 3, 1) = '1' end))
|
|
</if>
|
|
<if test="custName != null and custName != ''"> and a.cust_name like concat('%', #{custName}, '%') </if>
|
|
<if test="custId != null and custId != ''"> and a.cust_id like concat('%', #{custId}, '%') </if>
|
|
<if test="custType != null and custType != ''"> and a.cust_type = #{custType}</if>
|
|
<if test="custScale != null and custScale != ''">
|
|
and ( a.cust_scale = '5'
|
|
<if test="
|
|
custScale0 != null and custScale0 != ''">or a.cust_scale = #{custScale0}</if>
|
|
<if test="
|
|
custScale1 != null and custScale1 != ''">or a.cust_scale = #{custScale1}</if>
|
|
<if test="
|
|
custScale2 != null and custScale2 != ''">or a.cust_scale = #{custScale2}</if>
|
|
<if test="
|
|
custScale3 != null and custScale3 != ''">or a.cust_scale = #{custScale3}</if>
|
|
)
|
|
</if>
|
|
</where>
|
|
group by a.cust_id,a.id
|
|
limit #{start},#{size}
|
|
</select>
|
|
|
|
<select id="selectCustInfoBusinessListOps" parameterType="CustInfoBusiness" resultType="com.ruoyi.ibs.customerselect.domain.CustBaseInfo">
|
|
|
|
SELECT distinct a.id, a.cust_type, a.cust_tag, a.cust_scale, a.cust_name, a.lp_name,
|
|
a.cust_phone, a.cust_id, a.cust_isn,a.loan_tag,a.cust_capital,a.asset,a.credit,
|
|
null as dept_name,
|
|
null as outlets,
|
|
a.cust_idc,null as belong_user_name_list,
|
|
a.hq_cur_balance, a.bz_cur_balance, a.is_credit,
|
|
a.loan_balance_cny, a.loan_year_dailyaverage, a.is_htqy, a.finance_prod_716_open_flag, a.finance_prod_716_balance,
|
|
a.finance_prod_711_open_flag, a.finance_prod_711_balance, a.intl_bussiness_jcbh_open_flag, a.is_ustr,
|
|
a.ustr_count_per_m, a.ustr_bal_m, a.eleccharge_sign_flag, a.watercharge_sign_flag, a.taxdeduction_sign_flag,
|
|
a.pjb, a.czb, a.sfb, a.mrb, a.szst, a.is_open_sts, a.intl_bussiness_open_flag, a.intl_bussiness_325_open_flag,
|
|
a.is_365zf,a.is_180zf,a.is_90zf,a.is_30zf, a.cust_level
|
|
from cust_info_business a
|
|
<if test="isSelectGrid == false">
|
|
inner join (select user_id,dept_id,cust_id from
|
|
(select user_id,dept_id,cust_id,outlets_id from cust_dept_user_grid
|
|
<where>
|
|
<if test="opsDept != null and opsDept != ''">
|
|
ops_dept = #{opsDept}</if>
|
|
</where>
|
|
union all
|
|
(select t2.user_id,t2.dept_id,t2.cust_id,t2.outlets_id from cust_dept_user_cmpm t2
|
|
where t2.cust_type = '2' and t2.dept_id is not null)
|
|
) f
|
|
where 1=1
|
|
<if test="deptId != null ">
|
|
and f.dept_id in (select dept_id from sys_dept where dept_id = #{deptId} or find_in_set(#{deptId},ancestors))
|
|
</if>
|
|
<if test="outletsId != null ">
|
|
and f.outlets_id in (select dept_id from sys_dept where dept_id = #{outletsId} or find_in_set(#{outletsId},ancestors))
|
|
</if>
|
|
<if test="userId != null ">
|
|
and f.user_id = #{userId}</if>
|
|
) b on a.cust_id = b.cust_id
|
|
</if>
|
|
<where>
|
|
<if test="regionTopGridIds != null and regionTopGridIds.size() > 0 ">
|
|
AND a.cust_id IN (
|
|
SELECT cust_id
|
|
FROM grid_region_cust_user grcu
|
|
<where>
|
|
<if test="regionTopGridIds != null and regionTopGridIds.size()>0">
|
|
<foreach collection="regionTopGridIds" item="param" separator="or">
|
|
grcu.top_grid_id = #{param.value}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
)
|
|
</if>
|
|
<if test="regionSecGridIds != null and regionSecGridIds.size()>0">
|
|
AND a.cust_id IN (
|
|
SELECT cust_id
|
|
FROM grid_region_cust_user grcu
|
|
<where>
|
|
<foreach collection="regionSecGridIds" item="param" separator="or">
|
|
grcu.sec_grid_id = #{param.value}
|
|
</foreach>
|
|
</where>
|
|
)
|
|
</if>
|
|
<if test="virtualGridIds != null and virtualGridIds.size() > 0 ">
|
|
AND a.cust_id IN (
|
|
SELECT cust_id
|
|
FROM grid_virtual_cust_user gvcu
|
|
<where>
|
|
<foreach collection="virtualGridIds" item="param" separator="or">
|
|
gvcu.grid_id = #{param.value}
|
|
</foreach>
|
|
<if test="userName != null ">
|
|
and gvcu.user_name = #{userName}
|
|
</if>
|
|
</where>
|
|
)
|
|
</if>
|
|
<if test="drawGridIds != null and drawGridIds.size() > 0 ">
|
|
AND a.cust_id IN (
|
|
SELECT dsc.cust_id
|
|
FROM grid_draw_user_relate gdur
|
|
INNER JOIN grid_draw_shape_relate gdsr ON gdur.grid_id = gdsr.grid_id
|
|
INNER JOIN draw_shape_cust dsc ON gdsr.shape_id = dsc.shape_id
|
|
<where>
|
|
<foreach collection="drawGridIds" item="param" separator="or">
|
|
gdur.grid_id = #{param.value}
|
|
</foreach>
|
|
</where>
|
|
)
|
|
</if>
|
|
<if test="continuousParams != null and continuousParams.size() > 0 or discreteParams != null and discreteParams.size() > 0">
|
|
<if test="continuousParams != null and continuousParams.size() > 0">
|
|
and
|
|
<foreach collection="continuousParams" item="param" separator="and">
|
|
<choose>
|
|
<when test="param.value[0] != null and param.value[0] != '' and param.value[1] != null and param.value[1] != ''">
|
|
CAST(${param.key} AS DECIMAL(10,2)) BETWEEN CAST(#{param.value[0]} AS DECIMAL(10,2)) AND CAST(#{param.value[1]} AS DECIMAL(10,2))
|
|
</when>
|
|
<when test="param.value[0] != null and param.value[0] != ''">
|
|
CAST(${param.key} AS DECIMAL(10,2)) >= CAST(#{param.value[0]} AS DECIMAL(10,2))
|
|
</when>
|
|
<when test="param.value[1] != null and param.value[1] != ''">
|
|
CAST(${param.key} AS DECIMAL(10,2)) <= CAST(#{param.value[1]} AS DECIMAL(10,2))
|
|
</when>
|
|
</choose>
|
|
</foreach>
|
|
</if>
|
|
<if test="discreteParams != null and discreteParams.size() > 0">
|
|
and
|
|
<foreach collection="discreteParams" item="param" separator="and">
|
|
${param.key} = #{param.value}
|
|
</foreach>
|
|
</if>
|
|
</if>
|
|
<if test="custTag != null and custTag != ''"> and
|
|
((CASE WHEN substr(#{custTag}, 1, 1) = '1' THEN substr(a.cust_tag, 1, 1) = '1' end)
|
|
OR (CASE WHEN substr(#{custTag}, 2, 1) = '1' THEN substr(a.cust_tag, 2, 1) = '1' end)
|
|
OR (CASE WHEN substr(#{custTag}, 3, 1) = '1' THEN substr(a.cust_tag, 3, 1) = '1' end))
|
|
</if>
|
|
<if test="custName != null and custName != ''"> and a.cust_name like concat('%', #{custName}, '%') </if>
|
|
<if test="custId != null and custId != ''"> and a.cust_id like concat('%', #{custId}, '%') </if>
|
|
<if test="custType != null and custType != ''"> and a.cust_type = #{custType}</if>
|
|
<if test="custScale != null and custScale != ''">
|
|
and ( a.cust_scale = '5'
|
|
<if test="
|
|
custScale0 != null and custScale0 != ''">or a.cust_scale = #{custScale0}</if>
|
|
<if test="
|
|
custScale1 != null and custScale1 != ''">or a.cust_scale = #{custScale1}</if>
|
|
<if test="
|
|
custScale2 != null and custScale2 != ''">or a.cust_scale = #{custScale2}</if>
|
|
<if test="
|
|
custScale3 != null and custScale3 != ''">or a.cust_scale = #{custScale3}</if>
|
|
)
|
|
</if>
|
|
</where>
|
|
group by a.cust_id,a.id
|
|
limit #{start},#{size}
|
|
</select>
|
|
<select id="selectCustInfoBusinessList_COUNT" resultType="Long">
|
|
select -1
|
|
</select>
|
|
|
|
<select id="getBusinessNumByDeptId" parameterType="Long" resultType="java.lang.Long">
|
|
select count(distinct a.cust_id) from cust_info_business a
|
|
inner join (select distinct code, grid_id
|
|
from grid_region_admin_division_relate
|
|
where delete_flag = '0') b
|
|
on b.code = a.region_code
|
|
inner join (select distinct grid_id from grid_region_user_relate where delete_flag ='0' and parent_grid_id is null
|
|
and relate_dept_id in (select dept_id from sys_dept where dept_id = #{headDeptId} or find_in_set(#{headDeptId},ancestors))) c
|
|
on b.grid_id =c.grid_id
|
|
</select>
|
|
|
|
<select id="getBusinessNumByUserId" parameterType="String" resultType="java.lang.Long">
|
|
select count(distinct a.cust_id) from cust_info_business a
|
|
inner join (select distinct code, grid_id
|
|
from grid_region_admin_division_relate
|
|
where delete_flag = '0'
|
|
and ops_dept != '0') b
|
|
on b.code = a.region_code
|
|
inner join (select distinct grid_id, user_name, delete_flag
|
|
from grid_region_user_relate
|
|
where delete_flag = '0'
|
|
and parent_grid_id is not null) c
|
|
on b.grid_id = c.grid_id
|
|
where c.user_name = #{UserId} and c.delete_flag ='0'
|
|
</select>
|
|
|
|
<select id="selectCustInfoBusinessByAdminList" parameterType="Long">
|
|
select a.* from cust_info_business a inner join grid_region_admin_division_relate b on b.code like concat('',a.region_code , '%')
|
|
where b.grid_id = #{gridId}
|
|
<if test="custName != null and custName != ''"> and cust_name like concat('%', #{custName}, '%') </if>
|
|
<if test="custId != null and custId != ''"> and cust_id like concat('%', #{custId}, '%') </if>
|
|
group by a.cust_id
|
|
</select>
|
|
|
|
<select id="selectunDisCustByAdminList" parameterType="Long">
|
|
select a.* from cust_info_business a inner join grid_region_admin_division_relate b on b.code like concat('',a.region_code , '%')
|
|
where b.grid_id = #{gridId} and a.belong_user_name = ''
|
|
<if test="custName != null and custName != ''"> and cust_name like concat('%', #{custName}, '%') </if>
|
|
<if test="custId != null and custId != ''"> and cust_id like concat('%', #{custId}, '%') </if>
|
|
group by a.cust_id
|
|
</select>
|
|
|
|
<select id="selectunDisCustByVirtualList" >
|
|
select a.* from cust_info_business a inner join grid_virtual_customer_relate b on b.cust_id =a.cust_id
|
|
where b.grid_id = #{gridId} and a.belong_user_name = ''
|
|
<if test="custName != null and custName != ''"> and a.cust_name like concat('%', #{custName}, '%') </if>
|
|
<if test="custId != null and custId != ''"> and a.cust_id like concat('%', #{custId}, '%') </if>
|
|
group by a.cust_id
|
|
</select>
|
|
|
|
<select id="selectCustInfoBusinessByVirtualList" >
|
|
select a.* from cust_info_business a inner join grid_virtual_customer_relate b on b.cust_id =a.cust_id
|
|
where b.grid_id = #{gridId}
|
|
<if test="custName != null and custName != ''"> and a.cust_name like concat('%', #{custName}, '%') </if>
|
|
<if test="custId != null and custId != ''"> and a.cust_id like concat('%', #{custId}, '%') </if>
|
|
group by a.cust_id
|
|
</select>
|
|
|
|
<select id="selectBusinessNumByAdmin" parameterType="Long" resultType="java.lang.Long">
|
|
select count(distinct a.cust_id) from (select cust_id,region_code from cust_info_business) a
|
|
inner join (select distinct code,grid_id from grid_region_admin_division_relate) b on b.code = a.region_code
|
|
inner join (select distinct grid_id from grid_region_user_relate where delete_flag ='0'
|
|
and (relate_dept_id in (select dept_id from sys_dept where dept_id = #{userDept} or find_in_set(#{userDept},ancestors)) or user_name = #{userDept})) c on b.grid_id = c.grid_id
|
|
where b.grid_id = #{gridId}
|
|
</select>
|
|
|
|
<select id="selectCustInfoBusinessListBykeyword" parameterType="CustInfoBusiness" resultMap="CustInfoBusinessResult">
|
|
<include refid="selectCustInfoBusinessVo"/>
|
|
<where>
|
|
<if test="keyword != null and keyword != ''"> and ( cust_idc like concat('%', #{keyword}, '%') or cust_name like concat('%', #{keyword}, '%')
|
|
or cust_phone like concat('%', #{keyword}, '%') or lp_name like concat('%', #{keyword}, '%'))
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectCustInfoBusinessListBykeywordBranchAndManager" parameterType="CustInfoBusiness" resultMap="CustInfoBusinessResult">
|
|
select distinct a.id, a.cust_name, a.lp_name, a.cust_id, a.social_credit_code,a.cust_phone,a.tel ,a.cust_idc
|
|
from cust_info_business a inner join
|
|
(select user_id,dept_id,outlets_id,cust_id from cust_dept_user_grid
|
|
<where>
|
|
<if test="deptId != null and deptId != ''">
|
|
and dept_id in (select dept_id from sys_dept where dept_id = #{deptId} or find_in_set(#{deptId},ancestors))
|
|
</if>
|
|
<if test="outletsId != null and outletsId != ''">
|
|
and outlets_id in (select dept_id from sys_dept where dept_id = #{outletsId} or find_in_set(#{outletsId},ancestors))
|
|
</if>
|
|
<if test="userId != null and userId != ''">
|
|
and user_id = #{userId}
|
|
</if>
|
|
<if test="opsDept != null and opsDept != ''">
|
|
and ops_dept = #{opsDept}
|
|
</if>
|
|
</where>
|
|
union all
|
|
(select t2.user_id,t2.dept_id,t2.outlets_id,t2.cust_id from cust_dept_user_cmpm t2
|
|
<where>
|
|
and t2.cust_type = '2'
|
|
<if test="deptId != null and deptId != ''">
|
|
and t2.dept_id in (select dept_id from sys_dept where dept_id = #{deptId} or find_in_set(#{deptId},ancestors))
|
|
</if>
|
|
<if test="outletsId != null and outletsId != ''">
|
|
and t2.outlets_id in (select dept_id from sys_dept where dept_id = #{outletsId} or find_in_set(#{outletsId},ancestors))
|
|
</if>
|
|
<if test="userId != null and userId != ''">
|
|
and t2.user_id = #{userId}
|
|
</if>
|
|
</where>
|
|
)) b
|
|
on a.cust_id = b.cust_id
|
|
<where>
|
|
<if test="keyword != null and keyword != ''"> and ( a.cust_idc like concat('%', #{keyword}, '%') or a.cust_name like concat('%', #{keyword}, '%')
|
|
or a.cust_phone like concat('%', #{keyword}, '%') or a.lp_name like concat('%', #{keyword}, '%'))
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectCustInfoBusinessById" parameterType="Long" resultMap="CustInfoBusinessResult">
|
|
<include refid="selectCustInfoBusinessVo"/>
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertCustInfoBusiness" parameterType="CustInfoBusiness" useGeneratedKeys="true" keyProperty="id">
|
|
insert into cust_info_business
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="custType != null and custType != ''">cust_type,</if>
|
|
<if test="custTag != null and custTag != ''">cust_tag,</if>
|
|
<if test="custScale != null and custScale != ''">cust_scale,</if>
|
|
<if test="custName != null and custName != ''">cust_name,</if>
|
|
<if test="lpName != null">lp_name,</if>
|
|
<if test="custPhone != null">cust_phone,</if>
|
|
<if test="custId != null">cust_id,</if>
|
|
<if test="custIsn != null">cust_isn,</if>
|
|
<if test="custCapital != null">cust_capital,</if>
|
|
<if test="custLocation != null">cust_location,</if>
|
|
<if test="loanTag != null">loan_tag,</if>
|
|
<if test="status != null">status,</if>
|
|
<if test="belongBranchId != null">belong_branch_id,</if>
|
|
<if test="belongBranchName != null">belong_branch_name,</if>
|
|
<if test="belongOutletId != null">belong_outlet_id,</if>
|
|
<if test="belongOutletName != null">belong_outlet_name,</if>
|
|
<if test="belongUserId != null">belong_user_id,</if>
|
|
<if test="belongUserName != null">belong_user_name,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="regionCode != null">region_code,</if>
|
|
<if test="socialCreditCode != null">social_credit_code,</if>
|
|
<if test="tel != null">tel,</if>
|
|
<if test="registerLocation != null">register_location,</if>
|
|
<if test="businessScope != null">business_scope,</if>
|
|
<if test="taxpayerIdentificationNumber != null">taxpayer_identification_number,</if>
|
|
<if test="taxpayerQualification != null">taxpayer_qualification,</if>
|
|
<if test="label != null">label,</if>
|
|
<if test="industry != null">industry,</if>
|
|
<if test="custIdc != null">cust_idc,</if>
|
|
<if test="custAge != null">cust_age,</if>
|
|
<if test="custGender != null">cust_gender,</if>
|
|
<if test="birthday != null">birthday,</if>
|
|
<if test="recordStatus != null "> record_status ,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="custType != null and custType != ''">#{custType},</if>
|
|
<if test="custTag != null and custTag != ''">#{custTag},</if>
|
|
<if test="custScale != null and custScale != ''">#{custScale},</if>
|
|
<if test="custName != null and custName != ''">#{custName},</if>
|
|
<if test="lpName != null">#{lpName},</if>
|
|
<if test="custPhone != null">#{custPhone},</if>
|
|
<if test="custId != null">#{custId},</if>
|
|
<if test="custIsn != null">#{custIsn},</if>
|
|
<if test="custCapital != null">#{custCapital},</if>
|
|
<if test="custLocation != null">#{custLocation},</if>
|
|
<if test="loanTag != null">#{loanTag},</if>
|
|
<if test="status != null">#{status},</if>
|
|
<if test="belongBranchId != null">#{belongBranchId},</if>
|
|
<if test="belongBranchName != null">#{belongBranchName},</if>
|
|
<if test="belongOutletId != null">#{belongOutletId},</if>
|
|
<if test="belongOutletName != null">#{belongOutletName},</if>
|
|
<if test="belongUserId != null">#{belongUserId},</if>
|
|
<if test="belongUserName != null">#{belongUserName},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="regionCode != null">#{regionCode},</if>
|
|
<if test="socialCreditCode != null">#{socialCreditCode},</if>
|
|
<if test="tel != null">#{tel},</if>
|
|
<if test="registerLocation != null">#{registerLocation},</if>
|
|
<if test="businessScope != null">#{businessScope},</if>
|
|
<if test="taxpayerIdentificationNumber != null">#{taxpayerIdentificationNumber},</if>
|
|
<if test="taxpayerQualification != null">#{taxpayerQualification},</if>
|
|
<if test="label != null">#{label},</if>
|
|
<if test="industry != null">#{industry},</if>
|
|
<if test="custIdc != null">#{custIdc},</if>
|
|
<if test="custAge != null">#{custAge},</if>
|
|
<if test="custGender != null">#{custGender},</if>
|
|
<if test="birthday != null">#{birthday},</if>
|
|
<if test="recordStatus != null"> #{recordStatus}</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateCustInfoBusiness" parameterType="CustInfoBusiness">
|
|
update cust_info_business
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="custType != null and custType != ''">cust_type = #{custType},</if>
|
|
<if test="custTag != null and custTag != ''">cust_tag = #{custTag},</if>
|
|
<if test="custScale != null and custScale != ''">cust_scale = #{custScale},</if>
|
|
<if test="custName != null and custName != ''">cust_name = #{custName},</if>
|
|
<if test="lpName != null">lp_name = #{lpName},</if>
|
|
<if test="custPhone != null">cust_phone = #{custPhone},</if>
|
|
<if test="custId != null">cust_id = #{custId},</if>
|
|
<if test="custIsn != null">cust_isn = #{custIsn},</if>
|
|
<if test="custCapital != null">cust_capital = #{custCapital},</if>
|
|
<if test="custLocation != null">cust_location = #{custLocation},</if>
|
|
<if test="loanTag != null">loan_tag = #{loanTag},</if>
|
|
<if test="status != null">status = #{status},</if>
|
|
<if test="belongBranchId != null">belong_branch_id = #{belongBranchId},</if>
|
|
<if test="belongBranchName != null">belong_branch_name = #{belongBranchName},</if>
|
|
<if test="belongOutletId != null">belong_outlet_id = #{belongOutletId},</if>
|
|
<if test="belongOutletName != null">belong_outlet_name = #{belongOutletName},</if>
|
|
<if test="belongUserId != null">belong_user_id = #{belongUserId},</if>
|
|
<if test="belongUserName != null">belong_user_name = #{belongUserName},</if>
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="regionCode != null">region_code = #{regionCode},</if>
|
|
<if test="socialCreditCode != null">social_credit_code = #{socialCreditCode},</if>
|
|
<if test="tel != null">tel = #{tel},</if>
|
|
<if test="registerLocation != null">register_location = #{registerLocation},</if>
|
|
<if test="businessScope != null">business_scope = #{businessScope},</if>
|
|
<if test="taxpayerIdentificationNumber != null">taxpayer_identification_number = #{taxpayerIdentificationNumber},</if>
|
|
<if test="taxpayerQualification != null">taxpayer_qualification = #{taxpayerQualification},</if>
|
|
<if test="label != null">label = #{label},</if>
|
|
<if test="industry != null">industry = #{industry},</if>
|
|
<if test="custIdc != null">cust_idc = #{custIdc},</if>
|
|
<if test="custAge != null">cust_age = #{custAge},</if>
|
|
<if test="custGender != null">cust_gender = #{custGender},</if>
|
|
<if test="birthday != null">birthday = #{birthday},</if>
|
|
<if test="recordStatus != null and recordStatus != ''"> record_status = #{recordStatus},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
|
|
<update id="updateCustInfoBusinessLabel" parameterType="CustInfoBusiness">
|
|
update cust_info_business
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="custType != null and custType != ''">cust_type = #{custType},</if>
|
|
<if test="custTag != null and custTag != ''">cust_tag = #{custTag},</if>
|
|
<if test="custScale != null and custScale != ''">cust_scale = #{custScale},</if>
|
|
<if test="custName != null and custName != ''">cust_name = #{custName},</if>
|
|
<if test="lpName != null and custName != ''">lp_name = #{lpName},</if>
|
|
<if test="custPhone != null and custPhone != ''">cust_phone = #{custPhone},</if>
|
|
<if test="custId != null and custId != ''">cust_id = #{custId},</if>
|
|
<if test="custIsn != null and custIsn != ''">cust_isn = #{custIsn},</if>
|
|
<if test="custCapital != null and custCapital != ''">cust_capital = #{custCapital},</if>
|
|
<if test="custLocation != null and custLocation != ''">cust_location = #{custLocation},</if>
|
|
<if test="loanTag != null and loanTag != ''">loan_tag = #{loanTag},</if>
|
|
<if test="status != null and status != ''">status = #{status},</if>
|
|
<if test="belongBranchId != null and belongBranchId != ''">belong_branch_id = #{belongBranchId},</if>
|
|
<if test="belongBranchName != null and belongBranchName != ''">belong_branch_name = #{belongBranchName},</if>
|
|
<if test="belongOutletId != null and belongOutletId != ''">belong_outlet_id = #{belongOutletId},</if>
|
|
<if test="belongOutletName != null and belongOutletName != ''">belong_outlet_name = #{belongOutletName},</if>
|
|
<if test="belongUserId != null and belongUserId != ''">belong_user_id = #{belongUserId},</if>
|
|
<if test="belongUserName != null and belongUserName != ''">belong_user_name = #{belongUserName},</if>
|
|
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
|
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="regionCode != null and regionCode != ''">region_code = #{regionCode},</if>
|
|
<if test="socialCreditCode != null and socialCreditCode != ''">social_credit_code = #{socialCreditCode},</if>
|
|
<if test="tel != null and tel != ''">tel = #{tel},</if>
|
|
<if test="registerLocation != null and registerLocation != ''">register_location = #{registerLocation},</if>
|
|
<if test="businessScope != null and businessScope != ''">business_scope = #{businessScope},</if>
|
|
<if test="taxpayerIdentificationNumber != null and taxpayerIdentificationNumber != ''">taxpayer_identification_number = #{taxpayerIdentificationNumber},</if>
|
|
<if test="taxpayerQualification != null and taxpayerQualification != ''">taxpayer_qualification = #{taxpayerQualification},</if>
|
|
<if test="label != null and label != ''">label = #{label},</if>
|
|
<if test="industry != null and industry != ''">industry = #{industry},</if>
|
|
<if test="custIdc != null and custIdc != ''">cust_idc = #{custIdc},</if>
|
|
<if test="custAge != null and custAge != ''">cust_age = #{custAge},</if>
|
|
<if test="custGender != null and custGender != ''">cust_gender = #{custGender},</if>
|
|
<if test="birthday != null ">birthday = #{birthday},</if>
|
|
<if test="recordStatus != null and recordStatus != ''"> record_status = #{recordStatus},</if>
|
|
</trim>
|
|
where cust_id = #{custId}
|
|
</update>
|
|
|
|
<delete id="deleteCustInfoBusinessById" parameterType="Long">
|
|
delete from cust_info_business where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteCustInfoBusinessByIds" parameterType="String">
|
|
delete from cust_info_business where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<select id="selectCustInfoBusinessByCustId" parameterType="String" resultMap="CustInfoBusinessResult">
|
|
select * from cust_info_business
|
|
where cust_id = #{custId}
|
|
</select>
|
|
|
|
<select id="selectCustInfoBusinessBySocialCreditCode" parameterType="String" resultMap="CustInfoBusinessResult">
|
|
select * from cust_info_business
|
|
where social_credit_code = #{socialCreditCode}
|
|
</select>
|
|
|
|
|
|
<select id="selectCustInfoBusinessLists" parameterType="CustInfoBusiness" resultMap="CustInfoBusinessResult">
|
|
<include refid="selectCustInfoBusinessVo"/>
|
|
<where>
|
|
<if test="custType != null and custType != ''"> and cust_type = #{custType}</if>
|
|
<if test="custTag != null and custTag != ''"> and cust_tag = #{custTag}</if>
|
|
<if test="custScale != null and custScale != ''"> and cust_scale = #{custScale}</if>
|
|
<if test="custName != null and custName != ''"> and cust_name like concat('%', #{custName}, '%')</if>
|
|
<if test="lpName != null and lpName != ''"> and lp_name like concat('%', #{lpName}, '%')</if>
|
|
<if test="custPhone != null and custPhone != ''"> and cust_phone = #{custPhone}</if>
|
|
<if test="custId != null and custId != ''"> and cust_id = #{custId}</if>
|
|
<if test="custIsn != null and custIsn != ''"> and cust_isn = #{custIsn}</if>
|
|
<if test="custCapital != null and custCapital != ''"> and cust_capital = #{custCapital}</if>
|
|
<if test="custLocation != null and custLocation != ''"> and cust_location = #{custLocation}</if>
|
|
<if test="loanTag != null and loanTag != ''"> and loan_tag = #{loanTag}</if>
|
|
<if test="status != null and status != ''"> and status = #{status}</if>
|
|
<if test="belongBranchId != null and belongBranchId != ''"> and belong_branch_id = #{belongBranchId}</if>
|
|
<if test="belongBranchName != null and belongBranchName != ''"> and belong_branch_name like concat('%', #{belongBranchName}, '%')</if>
|
|
<if test="belongOutletId != null and belongOutletId != ''"> and belong_outlet_id = #{belongOutletId}</if>
|
|
<if test="belongOutletName != null and belongOutletName != ''"> and belong_outlet_name like concat('%', #{belongOutletName}, '%')</if>
|
|
<if test="belongUserId != null and belongUserId != ''"> and belong_user_id = #{belongUserId}</if>
|
|
<if test="belongUserName != null and belongUserName != ''"> and belong_user_name like concat('%', #{belongUserName}, '%')</if>
|
|
<if test="regionCode != null and regionCode != ''"> and region_code = #{regionCode}</if>
|
|
<if test="socialCreditCode != null and socialCreditCode != ''"> and social_credit_code = #{socialCreditCode}</if>
|
|
<if test="tel != null and tel != ''"> and tel = #{tel}</if>
|
|
<if test="registerLocation != null and registerLocation != ''"> and register_location = #{registerLocation}</if>
|
|
<if test="businessScope != null and businessScope != ''"> and business_scope = #{businessScope}</if>
|
|
<if test="taxpayerIdentificationNumber != null and taxpayerIdentificationNumber != ''"> and taxpayer_identification_number = #{taxpayerIdentificationNumber}</if>
|
|
<if test="taxpayerQualification != null and taxpayerQualification != ''"> and taxpayer_qualification = #{taxpayerQualification}</if>
|
|
<if test="label != null and label != ''"> and label = #{label}</if>
|
|
<if test="industry != null and industry != ''"> and industry = #{industry}</if>
|
|
<if test="custIdc != null and custIdc != ''"> and cust_idc = #{custIdc}</if>
|
|
<if test="birthday != null "> and birthday = #{birthday}</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="getBusinessNumByLegalId" parameterType="String" resultType="java.lang.Long">
|
|
select count(*) from cust_info_business
|
|
where social_credit_code = #{LegalId}
|
|
</select>
|
|
|
|
<update id="updateBusinessByAnchor" parameterType="CustInfoUpdateFromAnchor">
|
|
update cust_info_business
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="anchorName != null">cust_name = #{anchorName},</if>
|
|
<if test="belongBusiness != null">industry = #{belongBusiness},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="updateOrg != null">update_dept = #{updateOrg},</if>
|
|
<if test="address != null">${addressName} = #{address},</if>
|
|
<if test="regionCode != null">region_code = #{regionCode},</if>
|
|
</trim>
|
|
where social_credit_code = #{legalId}
|
|
</update>
|
|
|
|
<insert id="insertBusinessByAnchor" parameterType="CustInfoUpdateFromAnchor" >
|
|
insert into cust_info_business
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="custId != null">cust_id,</if>
|
|
<if test="custIsn != null">cust_isn,</if>
|
|
<if test="legalId != null">social_credit_code,</if>
|
|
<if test="anchorName != null">cust_name,</if>
|
|
<if test="belongBusiness != null">industry,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="address != null">${addressName},</if>
|
|
<if test="regionCode != null">region_code,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="custId != null">#{custId},</if>
|
|
<if test="custIsn != null">#{custIsn},</if>
|
|
<if test="legalId != null">#{legalId},</if>
|
|
<if test="anchorName != null">#{anchorName},</if>
|
|
<if test="belongBusiness != null">#{belongBusiness},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="address != null">#{address},</if>
|
|
<if test="regionCode != null">#{regionCode},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<delete id="deleteBusinessByAnchor" parameterType="CustInfoDeleteFromAnchor">
|
|
update cust_info_business set region_code ='' where social_credit_code = #{legalId}
|
|
</delete>
|
|
|
|
<select id="getLpNameByCustId" >
|
|
select distinct lp_name from cust_info_business
|
|
where cust_id = #{custId}
|
|
</select>
|
|
|
|
<select id="getBusiIdcByCustId" parameterType="String">
|
|
select distinct social_credit_code from cust_info_business
|
|
where cust_id = #{custId}
|
|
</select>
|
|
|
|
<select id="selectBusinessInfoByManage" parameterType="CustManageInfo" resultMap="CustManageInfoResult">
|
|
select distinct a.cust_id,a.cust_name,a.social_credit_code,a.region_code,c.user_name,c.nick_name,'2' as cust_type from cust_info_business a
|
|
inner join (select distinct code,grid_id from grid_region_admin_division_relate where delete_flag ='0') b on
|
|
b.code =a.region_code
|
|
inner join (select distinct grid_id,relate_dept_id,user_name,nick_name from grid_region_user_relate where delete_flag ='0'
|
|
and (relate_dept_id in (select dept_id from sys_dept where dept_id = #{userDept} or find_in_set(#{userDept},ancestors)) or user_name =#{userDept})) c
|
|
on b.grid_id = c.grid_id
|
|
where c.grid_id = #{gridId}
|
|
<if test="custName != null and custName != ''"> and a.cust_name like concat('%', #{custName}, '%') </if>
|
|
<if test="custId != null and custId != ''"> and a.cust_id like concat('%', #{custId}, '%') </if>
|
|
<if test="custNo != null and custNo != ''"> and a.social_credit_code like concat('%', #{custNo}, '%') </if>
|
|
<if test="distributeTag != null and distributeTag != ''">
|
|
and case when #{distributeTag} = '0' then exists (select * from sys_grid_user_cust d where d.grid_id = #{gridId} and a.cust_id =d.cust_id and c.user_name = d.user_name)
|
|
when #{distributeTag} = '1' then not exists (select * from sys_grid_user_cust d where d.grid_id = #{gridId} and a.cust_id =d.cust_id and c.user_name = d.user_name)
|
|
else 1=1 end
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectCustInfoBusinessByCustNameAndCustIdc" parameterType="String" resultMap="CustInfoBusinessResult">
|
|
<include refid="selectCustInfoBusinessVo"/>
|
|
<where>
|
|
<if test="custName != null and custName != ''"> and cust_name = #{custName}</if>
|
|
<if test="custIdc != null and custIdc != ''"> and cust_idc = #{custIdc}</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectCustInfoBusinessCustId" parameterType="String" resultMap="CustInfoBusinessResult">
|
|
<include refid="selectCustInfoBusinessVo"/>
|
|
<where>
|
|
<if test="custId != null and custId != ''"> and cust_id = #{custId}</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="countByCode" resultType="Long">
|
|
select count(distinct cust_id)
|
|
from cust_info_business_${deptCode}
|
|
where region_code like concat(#{code}, '%')
|
|
</select>
|
|
<select id="selectRecord" resultType="com.ruoyi.common.core.domain.entity.CustInfoBusiness">
|
|
select id,cust_name from cust_info_business where social_credit_code = #{socialCreditCode}
|
|
</select>
|
|
|
|
<select id="selectExistingSocialCreditCodes" resultType="java.lang.String">
|
|
select social_credit_code
|
|
from cust_info_business_${deptCode}
|
|
where social_credit_code in
|
|
<foreach item="socialCreditCode" collection="socialCreditCodes" open="(" separator="," close=")">
|
|
#{socialCreditCode}
|
|
</foreach>
|
|
</select>
|
|
|
|
<update id="batchUpdateCustLevelBySocialCreditCode">
|
|
update cust_info_business_${deptCode}
|
|
set cust_level = case social_credit_code
|
|
<foreach item="item" collection="list">
|
|
when #{item.socialCreditCode} then #{item.custLevel}
|
|
</foreach>
|
|
end
|
|
where social_credit_code in
|
|
<foreach item="item" collection="list" open="(" separator="," close=")">
|
|
#{item.socialCreditCode}
|
|
</foreach>
|
|
</update>
|
|
|
|
<insert id="insertCustomersToBusinessByScCode" parameterType="java.util.List">
|
|
INSERT INTO cust_info_business
|
|
(cust_id,cust_name, social_credit_code, update_by, update_time, cust_phone, industry, asset, credit)
|
|
VALUES
|
|
<foreach collection="list" item="item" separator=",">
|
|
(#{item.custId},#{item.custName}, #{item.socialCreditCode}, #{item.createBy}, #{item.createTime}, #{item.custPhone},#{item.industry},#{item.asset},#{item.credit})
|
|
</foreach>
|
|
</insert>
|
|
|
|
</mapper>
|