664 lines
41 KiB
XML
664 lines
41 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.customer.customerinfo.mapper.BmsCustomerMapper">
|
||
|
||
<resultMap type="BmsCustomer" id="BmsCustomerResult">
|
||
<result property="customerId" column="customer_id" />
|
||
<result property="customerCode" column="customer_code" />
|
||
<result property="customerName" column="customer_name" />
|
||
<result property="customerCodeDw" column="customer_code_dw" />
|
||
<result property="creditCode" column="credit_code" />
|
||
<result property="customerType" column="customer_type" />
|
||
<result property="isEnable" column="is_enable" />
|
||
<result property="salesUserId" column="sales_user_id" />
|
||
<result property="salesUser" column="sales_user" />
|
||
<result property="ed" column="ed" />
|
||
<result property="zq" column="zq" />
|
||
<result property="settlementUserId" column="settlement_user_id" />
|
||
<result property="settlementUser" column="settlement_user" />
|
||
<result property="serviceUserId" column="service_user_id" />
|
||
<result property="serviceUser" column="service_user" />
|
||
<result property="settlementType" column="settlement_type" />
|
||
<result property="tempEd" column="temp_ed" />
|
||
<result property="accountBalance" column="account_balance" />
|
||
<result property="foreignCurrencyBalance" column="foreign_currency_balance" />
|
||
<result property="weightThreshold" column="weight_threshold" />
|
||
<result property="throwRatio" column="throw_ratio" />
|
||
<result property="creditEd" column="credit_ed" />
|
||
<result property="productIds" column="product_ids" />
|
||
<result property="remark" column="remark" />
|
||
<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="delFlag" column="del_flag" />
|
||
</resultMap>
|
||
|
||
<!-- 账户余额/外币余额统一取 customer_account 余额表(CNY 为本币,其余为外币),不取 bms_customer 冗余列 -->
|
||
<!-- 信用额度=总额度+额外额度-已用额度-->
|
||
<sql id="selectBmsCustomerVo">
|
||
select c.customer_id, c.customer_code, c.customer_name, c.customer_code_dw, c.credit_code, c.customer_type,
|
||
c.is_enable, c.sales_user_id, c.sales_user, c.ed, c.zq, c.settlement_user_id, c.settlement_user,
|
||
c.service_user_id, c.service_user, c.settlement_type, c.temp_ed,
|
||
(select coalesce(sum(ca.balance), 0) from customer_account ca
|
||
where ca.customer_id = c.customer_id and ca.currency = 'CNY' and ca.del_flag = '0') as account_balance,
|
||
(select coalesce(sum(ca.balance), 0) from customer_account ca
|
||
where ca.customer_id = c.customer_id and ca.currency != 'CNY' and ca.del_flag = '0') as foreign_currency_balance,
|
||
c.weight_threshold, c.throw_ratio,
|
||
|
||
(select coalesce(sum(ca.total_credit+ca.extra_credit-ca.used_credit), 0) from customer_account ca
|
||
where ca.customer_id = c.customer_id and ca.del_flag = '0') as credit_ed,
|
||
|
||
c.product_ids, c.remark,
|
||
c.create_by, c.create_time, c.update_by, c.update_time, c.del_flag
|
||
from bms_customer c
|
||
<!-- 数据权限:销售(仅本人 c.sales_user_id)/销售经理(本部门 su.dept_id);
|
||
历史迁移数据 sales_user_id 为非数字工号,+0 后不匹配任何 sys_user,仅管理员可见 -->
|
||
left join sys_user su on su.user_id = c.sales_user_id + 0
|
||
</sql>
|
||
|
||
<select id="selectBmsCustomerList" parameterType="BmsCustomer" resultMap="BmsCustomerResult">
|
||
<include refid="selectBmsCustomerVo"/>
|
||
<where>
|
||
c.del_flag = '0'
|
||
<if test="customerCode != null and customerCode != ''"> and c.customer_code = #{customerCode}</if>
|
||
<if test="customerName != null and customerName != ''"> and c.customer_name like concat('%', #{customerName}, '%')</if>
|
||
<if test="customerCodeDw != null and customerCodeDw != ''"> and c.customer_code_dw = #{customerCodeDw}</if>
|
||
<if test="creditCode != null and creditCode != ''"> and c.credit_code = #{creditCode}</if>
|
||
<if test="customerType != null and customerType != ''"> and c.customer_type = #{customerType}</if>
|
||
<if test="isEnable != null and isEnable != ''"> and c.is_enable = #{isEnable}</if>
|
||
<if test="salesUserId != null and salesUserId != ''"> and c.sales_user_id = #{salesUserId}</if>
|
||
<if test="salesUser != null and salesUser != ''"> and c.sales_user = #{salesUser}</if>
|
||
<if test="ed != null "> and c.ed = #{ed}</if>
|
||
<if test="zq != null "> and c.zq = #{zq}</if>
|
||
<if test="settlementUserId != null and settlementUserId != ''"> and c.settlement_user_id = #{settlementUserId}</if>
|
||
<if test="settlementUser != null and settlementUser != ''"> and c.settlement_user = #{settlementUser}</if>
|
||
<if test="serviceUserId != null and serviceUserId != ''"> and c.service_user_id = #{serviceUserId}</if>
|
||
<if test="serviceUser != null and serviceUser != ''"> and c.service_user = #{serviceUser}</if>
|
||
<if test="settlementType != null and settlementType != ''"> and c.settlement_type = #{settlementType}</if>
|
||
<if test="tempEd != null "> and c.temp_ed = #{tempEd}</if>
|
||
<if test="weightThreshold != null "> and c.weight_threshold = #{weightThreshold}</if>
|
||
<if test="throwRatio != null "> and c.throw_ratio = #{throwRatio}</if>
|
||
<if test="creditEd != null "> and c.credit_ed = #{creditEd}</if>
|
||
<if test="productIds != null and productIds != ''"> and c.product_ids = #{productIds}</if>
|
||
<!-- 数据权限过滤(@DataScope 生成:仅本人= c.sales_user_id=当前用户;本部门= su.dept_id=当前用户部门) -->
|
||
${params.dataScope}
|
||
</where>
|
||
order by c.customer_id desc
|
||
</select>
|
||
|
||
<select id="selectBmsCustomerByCustomerId" parameterType="Long" resultMap="BmsCustomerResult">
|
||
<include refid="selectBmsCustomerVo"/>
|
||
where c.customer_id = #{customerId} and c.del_flag = '0'
|
||
</select>
|
||
|
||
<resultMap type="com.ruoyi.customer.customerinfo.domain.BmsCustomerAttachment" id="BmsCustomerAttachmentResult">
|
||
<result property="attachmentId" column="attachment_id" />
|
||
<result property="customerId" column="customer_id" />
|
||
<result property="bizType" column="biz_type" />
|
||
<result property="fileName" column="file_name" />
|
||
<result property="filePath" column="file_path" />
|
||
<result property="fileSize" column="file_size" />
|
||
<result property="fileType" column="file_type" />
|
||
<result property="fileExtension" column="file_extension" />
|
||
<result property="attachmentType" column="attachment_type" />
|
||
<result property="bizId" column="biz_id" />
|
||
<result property="isLogo" column="is_logo" />
|
||
<result property="sortOrder" column="sort_order" />
|
||
<result property="remark" column="remark" />
|
||
<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="delFlag" column="del_flag" />
|
||
</resultMap>
|
||
|
||
<sql id="selectBmsCustomerAttachmentVo">
|
||
select attachment_id, customer_id, biz_type, file_name, file_path, file_size, file_type, file_extension, attachment_type, biz_id, is_logo, sort_order, remark, create_by, create_time, update_by, update_time, del_flag from bms_customer_attachment
|
||
</sql>
|
||
|
||
<select id="selectBmsCustomerAttachmentList" parameterType="com.ruoyi.customer.customerinfo.domain.BmsCustomerAttachment" resultMap="BmsCustomerAttachmentResult">
|
||
<include refid="selectBmsCustomerAttachmentVo"/>
|
||
<where>
|
||
<if test="customerId != null "> and customer_id = #{customerId}</if>
|
||
<if test="bizType != null and bizType != ''"> and ifnull(nullif(biz_type, ''), 'customer') = #{bizType}</if>
|
||
<if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
|
||
<if test="attachmentType != null and attachmentType != ''"> and attachment_type = #{attachmentType}</if>
|
||
<if test="bizId != null"> and biz_id = #{bizId}</if>
|
||
<if test="isLogo != null and isLogo != ''"> and is_logo = #{isLogo}</if>
|
||
and del_flag = '0'
|
||
</where>
|
||
order by sort_order asc
|
||
</select>
|
||
|
||
<insert id="insertBmsCustomerAttachment" parameterType="com.ruoyi.customer.customerinfo.domain.BmsCustomerAttachment" useGeneratedKeys="true" keyProperty="attachmentId">
|
||
insert into bms_customer_attachment
|
||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
<if test="customerId != null">customer_id,</if>
|
||
<if test="bizType != null">biz_type,</if>
|
||
<if test="fileName != null">file_name,</if>
|
||
<if test="filePath != null">file_path,</if>
|
||
<if test="fileSize != null">file_size,</if>
|
||
<if test="fileType != null">file_type,</if>
|
||
<if test="fileExtension != null">file_extension,</if>
|
||
<if test="attachmentType != null">attachment_type,</if>
|
||
<if test="bizId != null">biz_id,</if>
|
||
<if test="isLogo != null">is_logo,</if>
|
||
<if test="sortOrder != null">sort_order,</if>
|
||
<if test="remark != null">remark,</if>
|
||
<if test="createBy != null">create_by,</if>
|
||
<if test="createTime != null">create_time,</if>
|
||
<if test="delFlag != null">del_flag,</if>
|
||
</trim>
|
||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||
<if test="customerId != null">#{customerId},</if>
|
||
<if test="bizType != null">#{bizType},</if>
|
||
<if test="fileName != null">#{fileName},</if>
|
||
<if test="filePath != null">#{filePath},</if>
|
||
<if test="fileSize != null">#{fileSize},</if>
|
||
<if test="fileType != null">#{fileType},</if>
|
||
<if test="fileExtension != null">#{fileExtension},</if>
|
||
<if test="attachmentType != null">#{attachmentType},</if>
|
||
<if test="bizId != null">#{bizId},</if>
|
||
<if test="isLogo != null">#{isLogo},</if>
|
||
<if test="sortOrder != null">#{sortOrder},</if>
|
||
<if test="remark != null">#{remark},</if>
|
||
<if test="createBy != null">#{createBy},</if>
|
||
<if test="createTime != null">#{createTime},</if>
|
||
<if test="delFlag != null">#{delFlag},</if>
|
||
</trim>
|
||
</insert>
|
||
|
||
<update id="updateBmsCustomerAttachment" parameterType="com.ruoyi.customer.customerinfo.domain.BmsCustomerAttachment">
|
||
update bms_customer_attachment
|
||
<trim prefix="SET" suffixOverrides=",">
|
||
<if test="customerId != null">customer_id = #{customerId},</if>
|
||
<if test="bizType != null">biz_type = #{bizType},</if>
|
||
<if test="fileName != null">file_name = #{fileName},</if>
|
||
<if test="filePath != null">file_path = #{filePath},</if>
|
||
<if test="fileSize != null">file_size = #{fileSize},</if>
|
||
<if test="fileType != null">file_type = #{fileType},</if>
|
||
<if test="fileExtension != null">file_extension = #{fileExtension},</if>
|
||
<if test="attachmentType != null">attachment_type = #{attachmentType},</if>
|
||
<if test="bizId != null">biz_id = #{bizId},</if>
|
||
<if test="isLogo != null">is_logo = #{isLogo},</if>
|
||
<if test="sortOrder != null">sort_order = #{sortOrder},</if>
|
||
<if test="remark != null">remark = #{remark},</if>
|
||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||
</trim>
|
||
where attachment_id = #{attachmentId}
|
||
</update>
|
||
|
||
<delete id="deleteBmsCustomerAttachmentByCustomerId" parameterType="Long">
|
||
update bms_customer_attachment set del_flag = '2' where customer_id = #{customerId}
|
||
</delete>
|
||
|
||
<!-- 仅逻辑删除客户档案模块的附件,保留收款水单等其他业务模块的附件 -->
|
||
<update id="deleteBmsCustomerProfileAttachmentByCustomerId" parameterType="Long">
|
||
update bms_customer_attachment set del_flag = '2'
|
||
where customer_id = #{customerId}
|
||
and (biz_type = 'customer' or biz_type is null or biz_type = '')
|
||
</update>
|
||
|
||
<!-- 额度调整后回写客户档案额度字段(数据源为客户余额账户) -->
|
||
<update id="updateCustomerCredit">
|
||
update bms_customer
|
||
set credit_ed = #{creditEd},
|
||
temp_ed = #{tempEd},
|
||
update_by = #{updateBy},
|
||
update_time = now()
|
||
where customer_id = #{customerId}
|
||
</update>
|
||
|
||
<!-- 只取档案物理额度列(列表查询里的 credit_ed 是账户可用额度子查询) -->
|
||
<select id="selectRawCreditByCustomerId" resultType="BmsCustomer">
|
||
select customer_id as customerId,
|
||
credit_ed as creditEd,
|
||
temp_ed as tempEd
|
||
from bms_customer
|
||
where customer_id = #{customerId}
|
||
</select>
|
||
|
||
<delete id="deleteBmsCustomerAttachmentByAttachmentIds" parameterType="String">
|
||
update bms_customer_attachment set del_flag = '2' where attachment_id in
|
||
<foreach item="attachmentId" collection="attachmentIds" open="(" separator="," close=")">
|
||
#{attachmentId}
|
||
</foreach>
|
||
</delete>
|
||
|
||
<insert id="insertBmsCustomer" parameterType="BmsCustomer" useGeneratedKeys="true" keyProperty="customerId">
|
||
insert into bms_customer
|
||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
<if test="customerCode != null and customerCode != ''">customer_code,</if>
|
||
<if test="customerName != null and customerName != ''">customer_name,</if>
|
||
<if test="customerCodeDw != null">customer_code_dw,</if>
|
||
<if test="creditCode != null">credit_code,</if>
|
||
<if test="customerType != null">customer_type,</if>
|
||
<if test="isEnable != null">is_enable,</if>
|
||
<if test="salesUserId != null">sales_user_id,</if>
|
||
<if test="salesUser != null">sales_user,</if>
|
||
<if test="ed != null">ed,</if>
|
||
<if test="zq != null">zq,</if>
|
||
<if test="settlementUserId != null">settlement_user_id,</if>
|
||
<if test="settlementUser != null">settlement_user,</if>
|
||
<if test="serviceUserId != null">service_user_id,</if>
|
||
<if test="serviceUser != null">service_user,</if>
|
||
<if test="settlementType != null">settlement_type,</if>
|
||
<if test="tempEd != null">temp_ed,</if>
|
||
<if test="accountBalance != null">account_balance,</if>
|
||
<if test="foreignCurrencyBalance != null">foreign_currency_balance,</if>
|
||
<if test="weightThreshold != null">weight_threshold,</if>
|
||
<if test="throwRatio != null">throw_ratio,</if>
|
||
<if test="creditEd != null">credit_ed,</if>
|
||
<if test="productIds != null">product_ids,</if>
|
||
<if test="remark != null">remark,</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="delFlag != null">del_flag,</if>
|
||
</trim>
|
||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||
<if test="customerCode != null and customerCode != ''">#{customerCode},</if>
|
||
<if test="customerName != null and customerName != ''">#{customerName},</if>
|
||
<if test="customerCodeDw != null">#{customerCodeDw},</if>
|
||
<if test="creditCode != null">#{creditCode},</if>
|
||
<if test="customerType != null">#{customerType},</if>
|
||
<if test="isEnable != null">#{isEnable},</if>
|
||
<if test="salesUserId != null">#{salesUserId},</if>
|
||
<if test="salesUser != null">#{salesUser},</if>
|
||
<if test="ed != null">#{ed},</if>
|
||
<if test="zq != null">#{zq},</if>
|
||
<if test="settlementUserId != null">#{settlementUserId},</if>
|
||
<if test="settlementUser != null">#{settlementUser},</if>
|
||
<if test="serviceUserId != null">#{serviceUserId},</if>
|
||
<if test="serviceUser != null">#{serviceUser},</if>
|
||
<if test="settlementType != null">#{settlementType},</if>
|
||
<if test="tempEd != null">#{tempEd},</if>
|
||
<if test="accountBalance != null">#{accountBalance},</if>
|
||
<if test="foreignCurrencyBalance != null">#{foreignCurrencyBalance},</if>
|
||
<if test="weightThreshold != null">#{weightThreshold},</if>
|
||
<if test="throwRatio != null">#{throwRatio},</if>
|
||
<if test="creditEd != null">#{creditEd},</if>
|
||
<if test="productIds != null">#{productIds},</if>
|
||
<if test="remark != null">#{remark},</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="delFlag != null">#{delFlag},</if>
|
||
</trim>
|
||
</insert>
|
||
|
||
<update id="updateBmsCustomer" parameterType="BmsCustomer">
|
||
update bms_customer
|
||
<trim prefix="SET" suffixOverrides=",">
|
||
<if test="customerCode != null and customerCode != ''">customer_code = #{customerCode},</if>
|
||
<if test="customerName != null and customerName != ''">customer_name = #{customerName},</if>
|
||
<if test="customerCodeDw != null">customer_code_dw = #{customerCodeDw},</if>
|
||
<if test="creditCode != null">credit_code = #{creditCode},</if>
|
||
<if test="customerType != null">customer_type = #{customerType},</if>
|
||
<if test="isEnable != null">is_enable = #{isEnable},</if>
|
||
sales_user_id = #{salesUserId},
|
||
sales_user = #{salesUser},
|
||
<if test="ed != null">ed = #{ed},</if>
|
||
<if test="zq != null">zq = #{zq},</if>
|
||
settlement_user_id = #{settlementUserId},
|
||
settlement_user = #{settlementUser},
|
||
service_user_id = #{serviceUserId},
|
||
service_user = #{serviceUser},
|
||
<if test="settlementType != null">settlement_type = #{settlementType},</if>
|
||
<if test="accountBalance != null">account_balance = #{accountBalance},</if>
|
||
<if test="foreignCurrencyBalance != null">foreign_currency_balance = #{foreignCurrencyBalance},</if>
|
||
<if test="weightThreshold != null">weight_threshold = #{weightThreshold},</if>
|
||
<if test="throwRatio != null">throw_ratio = #{throwRatio},</if>
|
||
<if test="productIds != null">product_ids = #{productIds},</if>
|
||
<if test="remark != null">remark = #{remark},</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="delFlag != null">del_flag = #{delFlag},</if>
|
||
</trim>
|
||
where customer_id = #{customerId}
|
||
</update>
|
||
|
||
<delete id="deleteBmsCustomerByCustomerId" parameterType="Long">
|
||
update bms_customer set del_flag = '2' where customer_id = #{customerId}
|
||
</delete>
|
||
|
||
<delete id="deleteBmsCustomerByCustomerIds" parameterType="Long">
|
||
update bms_customer set del_flag = '2' where customer_id in
|
||
<foreach item="customerId" collection="customerIds" open="(" separator="," close=")">
|
||
#{customerId}
|
||
</foreach>
|
||
</delete>
|
||
|
||
<!-- ========== bms_customer_company 子表 ========== -->
|
||
<resultMap type="com.ruoyi.customer.customerinfo.domain.BmsCustomerCompany" id="BmsCustomerCompanyResult">
|
||
<result property="companyId" column="company_id" />
|
||
<result property="customerId" column="customer_id" />
|
||
<result property="companyNameFull" column="company_name_full" />
|
||
<result property="englishName" column="english_name" />
|
||
<result property="creditCode" column="credit_code" />
|
||
<result property="legalPerson" column="legal_person" />
|
||
<result property="legalPersonPhone" column="legal_person_phone" />
|
||
<result property="legalPersonIdCard" column="legal_person_id_card" />
|
||
<result property="registeredCapital" column="registered_capital" />
|
||
<result property="capitalCurrency" column="capital_currency" />
|
||
<result property="paidInCapital" column="paid_in_capital" />
|
||
<result property="establishDate" column="establish_date" />
|
||
<result property="businessTermStart" column="business_term_start" />
|
||
<result property="businessTermEnd" column="business_term_end" />
|
||
<result property="businessTermPermanent" column="business_term_permanent" />
|
||
<result property="registrationAuthority" column="registration_authority" />
|
||
<result property="registrationNumber" column="registration_number" />
|
||
<result property="operatingStatus" column="operating_status" />
|
||
<result property="businessScope" column="business_scope" />
|
||
<result property="shareholders" column="shareholders" />
|
||
<result property="employeeCount" column="employee_count" />
|
||
<result property="companyPhone" column="company_phone" />
|
||
<result property="companyFax" column="company_fax" />
|
||
<result property="companyWebsite" column="company_website" />
|
||
<result property="companyEmail" column="company_email" />
|
||
<result property="registeredProvince" column="registered_province" />
|
||
<result property="registeredCity" column="registered_city" />
|
||
<result property="registeredDistrict" column="registered_district" />
|
||
<result property="registeredAddressDetail" column="registered_address_detail" />
|
||
<result property="businessLicenseUrl" column="business_license_url" />
|
||
<result property="attachmentIds" column="attachment_ids" />
|
||
<result property="remark" column="remark" />
|
||
<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="delFlag" column="del_flag" />
|
||
</resultMap>
|
||
|
||
<sql id="selectBmsCustomerCompanyVo">
|
||
select company_id, customer_id, company_name_full, english_name, credit_code, legal_person, legal_person_phone, legal_person_id_card, registered_capital, capital_currency, paid_in_capital, establish_date, business_term_start, business_term_end, business_term_permanent, registration_authority, registration_number, operating_status, business_scope, shareholders, employee_count, company_phone, company_fax, company_website, company_email, registered_province, registered_city, registered_district, registered_address_detail, business_license_url, attachment_ids, remark, create_by, create_time, update_by, update_time, del_flag from bms_customer_company
|
||
</sql>
|
||
|
||
<select id="selectBmsCustomerCompanyList" parameterType="com.ruoyi.customer.customerinfo.domain.BmsCustomerCompany" resultMap="BmsCustomerCompanyResult">
|
||
<include refid="selectBmsCustomerCompanyVo"/>
|
||
<where>
|
||
<if test="customerId != null"> and customer_id = #{customerId}</if>
|
||
<if test="companyNameFull != null and companyNameFull != ''"> and company_name_full like concat('%', #{companyNameFull}, '%')</if>
|
||
<if test="creditCode != null and creditCode != ''"> and credit_code = #{creditCode}</if>
|
||
<if test="legalPerson != null and legalPerson != ''"> and legal_person like concat('%', #{legalPerson}, '%')</if>
|
||
<if test="operatingStatus != null and operatingStatus != ''"> and operating_status = #{operatingStatus}</if>
|
||
and del_flag = '0'
|
||
</where>
|
||
order by company_id asc
|
||
</select>
|
||
|
||
<select id="selectBmsCustomerCompanyByCompanyId" parameterType="Long" resultMap="BmsCustomerCompanyResult">
|
||
<include refid="selectBmsCustomerCompanyVo"/>
|
||
where company_id = #{companyId} and del_flag = '0'
|
||
</select>
|
||
|
||
<insert id="insertBmsCustomerCompany" parameterType="com.ruoyi.customer.customerinfo.domain.BmsCustomerCompany" useGeneratedKeys="true" keyProperty="companyId">
|
||
insert into bms_customer_company
|
||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
<if test="customerId != null">customer_id,</if>
|
||
<if test="companyNameFull != null">company_name_full,</if>
|
||
<if test="englishName != null">english_name,</if>
|
||
<if test="creditCode != null">credit_code,</if>
|
||
<if test="legalPerson != null">legal_person,</if>
|
||
<if test="legalPersonPhone != null">legal_person_phone,</if>
|
||
<if test="legalPersonIdCard != null">legal_person_id_card,</if>
|
||
<if test="registeredCapital != null">registered_capital,</if>
|
||
<if test="capitalCurrency != null">capital_currency,</if>
|
||
<if test="paidInCapital != null">paid_in_capital,</if>
|
||
<if test="establishDate != null">establish_date,</if>
|
||
<if test="businessTermStart != null">business_term_start,</if>
|
||
<if test="businessTermEnd != null">business_term_end,</if>
|
||
<if test="businessTermPermanent != null">business_term_permanent,</if>
|
||
<if test="registrationAuthority != null">registration_authority,</if>
|
||
<if test="registrationNumber != null">registration_number,</if>
|
||
<if test="operatingStatus != null">operating_status,</if>
|
||
<if test="businessScope != null">business_scope,</if>
|
||
<if test="shareholders != null">shareholders,</if>
|
||
<if test="employeeCount != null">employee_count,</if>
|
||
<if test="companyPhone != null">company_phone,</if>
|
||
<if test="companyFax != null">company_fax,</if>
|
||
<if test="companyWebsite != null">company_website,</if>
|
||
<if test="companyEmail != null">company_email,</if>
|
||
<if test="registeredProvince != null">registered_province,</if>
|
||
<if test="registeredCity != null">registered_city,</if>
|
||
<if test="registeredDistrict != null">registered_district,</if>
|
||
<if test="registeredAddressDetail != null">registered_address_detail,</if>
|
||
<if test="businessLicenseUrl != null">business_license_url,</if>
|
||
<if test="attachmentIds != null">attachment_ids,</if>
|
||
<if test="remark != null">remark,</if>
|
||
<if test="createBy != null">create_by,</if>
|
||
<if test="createTime != null">create_time,</if>
|
||
<if test="delFlag != null">del_flag,</if>
|
||
</trim>
|
||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||
<if test="customerId != null">#{customerId},</if>
|
||
<if test="companyNameFull != null">#{companyNameFull},</if>
|
||
<if test="englishName != null">#{englishName},</if>
|
||
<if test="creditCode != null">#{creditCode},</if>
|
||
<if test="legalPerson != null">#{legalPerson},</if>
|
||
<if test="legalPersonPhone != null">#{legalPersonPhone},</if>
|
||
<if test="legalPersonIdCard != null">#{legalPersonIdCard},</if>
|
||
<if test="registeredCapital != null">#{registeredCapital},</if>
|
||
<if test="capitalCurrency != null">#{capitalCurrency},</if>
|
||
<if test="paidInCapital != null">#{paidInCapital},</if>
|
||
<if test="establishDate != null">#{establishDate},</if>
|
||
<if test="businessTermStart != null">#{businessTermStart},</if>
|
||
<if test="businessTermEnd != null">#{businessTermEnd},</if>
|
||
<if test="businessTermPermanent != null">#{businessTermPermanent},</if>
|
||
<if test="registrationAuthority != null">#{registrationAuthority},</if>
|
||
<if test="registrationNumber != null">#{registrationNumber},</if>
|
||
<if test="operatingStatus != null">#{operatingStatus},</if>
|
||
<if test="businessScope != null">#{businessScope},</if>
|
||
<if test="shareholders != null">#{shareholders},</if>
|
||
<if test="employeeCount != null">#{employeeCount},</if>
|
||
<if test="companyPhone != null">#{companyPhone},</if>
|
||
<if test="companyFax != null">#{companyFax},</if>
|
||
<if test="companyWebsite != null">#{companyWebsite},</if>
|
||
<if test="companyEmail != null">#{companyEmail},</if>
|
||
<if test="registeredProvince != null">#{registeredProvince},</if>
|
||
<if test="registeredCity != null">#{registeredCity},</if>
|
||
<if test="registeredDistrict != null">#{registeredDistrict},</if>
|
||
<if test="registeredAddressDetail != null">#{registeredAddressDetail},</if>
|
||
<if test="businessLicenseUrl != null">#{businessLicenseUrl},</if>
|
||
<if test="attachmentIds != null">#{attachmentIds},</if>
|
||
<if test="remark != null">#{remark},</if>
|
||
<if test="createBy != null">#{createBy},</if>
|
||
<if test="createTime != null">#{createTime},</if>
|
||
<if test="delFlag != null">#{delFlag},</if>
|
||
</trim>
|
||
</insert>
|
||
|
||
<update id="updateBmsCustomerCompany" parameterType="com.ruoyi.customer.customerinfo.domain.BmsCustomerCompany">
|
||
update bms_customer_company
|
||
<trim prefix="SET" suffixOverrides=",">
|
||
<if test="customerId != null">customer_id = #{customerId},</if>
|
||
<if test="companyNameFull != null">company_name_full = #{companyNameFull},</if>
|
||
<if test="englishName != null">english_name = #{englishName},</if>
|
||
<if test="creditCode != null">credit_code = #{creditCode},</if>
|
||
<if test="legalPerson != null">legal_person = #{legalPerson},</if>
|
||
<if test="legalPersonPhone != null">legal_person_phone = #{legalPersonPhone},</if>
|
||
<if test="legalPersonIdCard != null">legal_person_id_card = #{legalPersonIdCard},</if>
|
||
<if test="registeredCapital != null">registered_capital = #{registeredCapital},</if>
|
||
<if test="capitalCurrency != null">capital_currency = #{capitalCurrency},</if>
|
||
<if test="paidInCapital != null">paid_in_capital = #{paidInCapital},</if>
|
||
<if test="establishDate != null">establish_date = #{establishDate},</if>
|
||
<if test="businessTermStart != null">business_term_start = #{businessTermStart},</if>
|
||
<if test="businessTermEnd != null">business_term_end = #{businessTermEnd},</if>
|
||
<if test="businessTermPermanent != null">business_term_permanent = #{businessTermPermanent},</if>
|
||
<if test="registrationAuthority != null">registration_authority = #{registrationAuthority},</if>
|
||
<if test="registrationNumber != null">registration_number = #{registrationNumber},</if>
|
||
<if test="operatingStatus != null">operating_status = #{operatingStatus},</if>
|
||
<if test="businessScope != null">business_scope = #{businessScope},</if>
|
||
<if test="shareholders != null">shareholders = #{shareholders},</if>
|
||
<if test="employeeCount != null">employee_count = #{employeeCount},</if>
|
||
<if test="companyPhone != null">company_phone = #{companyPhone},</if>
|
||
<if test="companyFax != null">company_fax = #{companyFax},</if>
|
||
<if test="companyWebsite != null">company_website = #{companyWebsite},</if>
|
||
<if test="companyEmail != null">company_email = #{companyEmail},</if>
|
||
<if test="registeredProvince != null">registered_province = #{registeredProvince},</if>
|
||
<if test="registeredCity != null">registered_city = #{registeredCity},</if>
|
||
<if test="registeredDistrict != null">registered_district = #{registeredDistrict},</if>
|
||
<if test="registeredAddressDetail != null">registered_address_detail = #{registeredAddressDetail},</if>
|
||
<if test="businessLicenseUrl != null">business_license_url = #{businessLicenseUrl},</if>
|
||
<if test="attachmentIds != null">attachment_ids = #{attachmentIds},</if>
|
||
<if test="remark != null">remark = #{remark},</if>
|
||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||
</trim>
|
||
where company_id = #{companyId}
|
||
</update>
|
||
|
||
<delete id="deleteBmsCustomerCompanyByCustomerId" parameterType="Long">
|
||
update bms_customer_company set del_flag = '2' where customer_id = #{customerId}
|
||
</delete>
|
||
|
||
<delete id="deleteBmsCustomerCompanyByCompanyId" parameterType="Long">
|
||
update bms_customer_company set del_flag = '2' where company_id = #{companyId}
|
||
</delete>
|
||
|
||
<!-- ========== bms_customer_contact 子表 ========== -->
|
||
<resultMap type="com.ruoyi.customer.customerinfo.domain.BmsCustomerContact" id="BmsCustomerContactResult">
|
||
<result property="contactId" column="contact_id" />
|
||
<result property="customerId" column="customer_id" />
|
||
<result property="contactName" column="contact_name" />
|
||
<result property="position" column="position" />
|
||
<result property="department" column="department" />
|
||
<result property="phone" column="phone" />
|
||
<result property="landline" column="landline" />
|
||
<result property="email" column="email" />
|
||
<result property="wechat" column="wechat" />
|
||
<result property="qq" column="qq" />
|
||
<result property="country" column="country" />
|
||
<result property="province" column="province" />
|
||
<result property="city" column="city" />
|
||
<result property="district" column="district" />
|
||
<result property="contactAddress" column="contact_address" />
|
||
<result property="postalCode" column="postal_code" />
|
||
<result property="isDefault" column="is_default" />
|
||
<result property="contactType" column="contact_type" />
|
||
<result property="sortOrder" column="sort_order" />
|
||
<result property="remark" column="remark" />
|
||
<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="delFlag" column="del_flag" />
|
||
</resultMap>
|
||
|
||
<sql id="selectBmsCustomerContactVo">
|
||
select contact_id, customer_id, contact_name, position, department, phone, landline, email, wechat, qq, country, province, city, district, contact_address, postal_code, is_default, contact_type, sort_order, remark, create_by, create_time, update_by, update_time, del_flag from bms_customer_contact
|
||
</sql>
|
||
|
||
<select id="selectBmsCustomerContactList" parameterType="com.ruoyi.customer.customerinfo.domain.BmsCustomerContact" resultMap="BmsCustomerContactResult">
|
||
<include refid="selectBmsCustomerContactVo"/>
|
||
<where>
|
||
<if test="customerId != null"> and customer_id = #{customerId}</if>
|
||
<if test="contactName != null and contactName != ''"> and contact_name like concat('%', #{contactName}, '%')</if>
|
||
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
|
||
<if test="contactType != null and contactType != ''"> and contact_type = #{contactType}</if>
|
||
and del_flag = '0'
|
||
</where>
|
||
order by sort_order asc, contact_id asc
|
||
</select>
|
||
|
||
<select id="selectBmsCustomerContactByContactId" parameterType="Long" resultMap="BmsCustomerContactResult">
|
||
<include refid="selectBmsCustomerContactVo"/>
|
||
where contact_id = #{contactId} and del_flag = '0'
|
||
</select>
|
||
|
||
<insert id="insertBmsCustomerContact" parameterType="com.ruoyi.customer.customerinfo.domain.BmsCustomerContact" useGeneratedKeys="true" keyProperty="contactId">
|
||
insert into bms_customer_contact
|
||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||
<if test="customerId != null">customer_id,</if>
|
||
<if test="contactName != null">contact_name,</if>
|
||
<if test="position != null">position,</if>
|
||
<if test="department != null">department,</if>
|
||
<if test="phone != null">phone,</if>
|
||
<if test="landline != null">landline,</if>
|
||
<if test="email != null">email,</if>
|
||
<if test="wechat != null">wechat,</if>
|
||
<if test="qq != null">qq,</if>
|
||
<if test="country != null">country,</if>
|
||
<if test="province != null">province,</if>
|
||
<if test="city != null">city,</if>
|
||
<if test="district != null">district,</if>
|
||
<if test="contactAddress != null">contact_address,</if>
|
||
<if test="postalCode != null">postal_code,</if>
|
||
<if test="isDefault != null">is_default,</if>
|
||
<if test="contactType != null">contact_type,</if>
|
||
<if test="sortOrder != null">sort_order,</if>
|
||
<if test="remark != null">remark,</if>
|
||
<if test="createBy != null">create_by,</if>
|
||
<if test="createTime != null">create_time,</if>
|
||
<if test="delFlag != null">del_flag,</if>
|
||
</trim>
|
||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||
<if test="customerId != null">#{customerId},</if>
|
||
<if test="contactName != null">#{contactName},</if>
|
||
<if test="position != null">#{position},</if>
|
||
<if test="department != null">#{department},</if>
|
||
<if test="phone != null">#{phone},</if>
|
||
<if test="landline != null">#{landline},</if>
|
||
<if test="email != null">#{email},</if>
|
||
<if test="wechat != null">#{wechat},</if>
|
||
<if test="qq != null">#{qq},</if>
|
||
<if test="country != null">#{country},</if>
|
||
<if test="province != null">#{province},</if>
|
||
<if test="city != null">#{city},</if>
|
||
<if test="district != null">#{district},</if>
|
||
<if test="contactAddress != null">#{contactAddress},</if>
|
||
<if test="postalCode != null">#{postalCode},</if>
|
||
<if test="isDefault != null">#{isDefault},</if>
|
||
<if test="contactType != null">#{contactType},</if>
|
||
<if test="sortOrder != null">#{sortOrder},</if>
|
||
<if test="remark != null">#{remark},</if>
|
||
<if test="createBy != null">#{createBy},</if>
|
||
<if test="createTime != null">#{createTime},</if>
|
||
<if test="delFlag != null">#{delFlag},</if>
|
||
</trim>
|
||
</insert>
|
||
|
||
<update id="updateBmsCustomerContact" parameterType="com.ruoyi.customer.customerinfo.domain.BmsCustomerContact">
|
||
update bms_customer_contact
|
||
<trim prefix="SET" suffixOverrides=",">
|
||
<if test="customerId != null">customer_id = #{customerId},</if>
|
||
<if test="contactName != null">contact_name = #{contactName},</if>
|
||
<if test="position != null">position = #{position},</if>
|
||
<if test="department != null">department = #{department},</if>
|
||
<if test="phone != null">phone = #{phone},</if>
|
||
<if test="landline != null">landline = #{landline},</if>
|
||
<if test="email != null">email = #{email},</if>
|
||
<if test="wechat != null">wechat = #{wechat},</if>
|
||
<if test="qq != null">qq = #{qq},</if>
|
||
<if test="country != null">country = #{country},</if>
|
||
<if test="province != null">province = #{province},</if>
|
||
<if test="city != null">city = #{city},</if>
|
||
<if test="district != null">district = #{district},</if>
|
||
<if test="contactAddress != null">contact_address = #{contactAddress},</if>
|
||
<if test="postalCode != null">postal_code = #{postalCode},</if>
|
||
<if test="isDefault != null">is_default = #{isDefault},</if>
|
||
<if test="contactType != null">contact_type = #{contactType},</if>
|
||
<if test="sortOrder != null">sort_order = #{sortOrder},</if>
|
||
<if test="remark != null">remark = #{remark},</if>
|
||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||
</trim>
|
||
where contact_id = #{contactId}
|
||
</update>
|
||
|
||
<delete id="deleteBmsCustomerContactByCustomerId" parameterType="Long">
|
||
update bms_customer_contact set del_flag = '2' where customer_id = #{customerId}
|
||
</delete>
|
||
|
||
<delete id="deleteBmsCustomerContactByContactId" parameterType="Long">
|
||
update bms_customer_contact set del_flag = '2' where contact_id = #{contactId}
|
||
</delete>
|
||
</mapper> |