统一修改ruoyi->bms

This commit is contained in:
caojia
2026-09-28 10:02:38 +08:00
parent 341afc4111
commit 0408b6c35e
639 changed files with 2776 additions and 2807 deletions
@@ -0,0 +1,672 @@
<?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.bms.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="productCodes" column="product_codes" />
<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>
<!-- 账户余额/外币余额统一取 ctr_customer_account 余额表(CNY 为本币,其余为外币),不取 ctr_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 ctr_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 ctr_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 ctr_customer_account ca
where ca.customer_id = c.customer_id and ca.del_flag = '0') as credit_ed,
c.product_codes, c.remark,
c.create_by, c.create_time, c.update_by, c.update_time, c.del_flag
from ctr_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="productCodes != null and productCodes != ''"> and c.product_codes = #{productCodes}</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>
<!-- TMS 实时状态接口只读取客户ID和启用状态,避免加载客户完整资料和额度汇总。 -->
<select id="selectCustomerStatusByCustomerId" parameterType="Long" resultMap="BmsCustomerResult">
select customer_id, is_enable
from ctr_customer
where customer_id = #{customerId}
and del_flag = '0'
</select>
<resultMap type="com.bms.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 ctr_customer_attachment
</sql>
<select id="selectBmsCustomerAttachmentList" parameterType="com.bms.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.bms.customer.customerinfo.domain.BmsCustomerAttachment" useGeneratedKeys="true" keyProperty="attachmentId">
insert into ctr_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.bms.customer.customerinfo.domain.BmsCustomerAttachment">
update ctr_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 ctr_customer_attachment set del_flag = '2' where customer_id = #{customerId}
</delete>
<!-- 仅逻辑删除客户档案模块的附件,保留收款水单等其他业务模块的附件 -->
<update id="deleteBmsCustomerProfileAttachmentByCustomerId" parameterType="Long">
update ctr_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 ctr_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 ctr_customer
where customer_id = #{customerId}
</select>
<delete id="deleteBmsCustomerAttachmentByAttachmentIds" parameterType="String">
update ctr_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 ctr_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="productCodes != null">product_codes,</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="productCodes != null">#{productCodes},</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 ctr_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="productCodes != null">product_codes = #{productCodes},</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 ctr_customer set del_flag = '2' where customer_id = #{customerId}
</delete>
<delete id="deleteBmsCustomerByCustomerIds" parameterType="Long">
update ctr_customer set del_flag = '2' where customer_id in
<foreach item="customerId" collection="customerIds" open="(" separator="," close=")">
#{customerId}
</foreach>
</delete>
<!-- ========== ctr_customer_company 子表 ========== -->
<resultMap type="com.bms.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 ctr_customer_company
</sql>
<select id="selectBmsCustomerCompanyList" parameterType="com.bms.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.bms.customer.customerinfo.domain.BmsCustomerCompany" useGeneratedKeys="true" keyProperty="companyId">
insert into ctr_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.bms.customer.customerinfo.domain.BmsCustomerCompany">
update ctr_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 ctr_customer_company set del_flag = '2' where customer_id = #{customerId}
</delete>
<delete id="deleteBmsCustomerCompanyByCompanyId" parameterType="Long">
update ctr_customer_company set del_flag = '2' where company_id = #{companyId}
</delete>
<!-- ========== ctr_customer_contact 子表 ========== -->
<resultMap type="com.bms.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 ctr_customer_contact
</sql>
<select id="selectBmsCustomerContactList" parameterType="com.bms.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.bms.customer.customerinfo.domain.BmsCustomerContact" useGeneratedKeys="true" keyProperty="contactId">
insert into ctr_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.bms.customer.customerinfo.domain.BmsCustomerContact">
update ctr_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 ctr_customer_contact set del_flag = '2' where customer_id = #{customerId}
</delete>
<delete id="deleteBmsCustomerContactByContactId" parameterType="Long">
update ctr_customer_contact set del_flag = '2' where contact_id = #{contactId}
</delete>
</mapper>
@@ -0,0 +1,123 @@
<?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.bms.customer.customerinfo.mapper.BmsCustomerPriceSetMapper">
<resultMap type="com.bms.customer.customerinfo.domain.BmsCustomerPriceSet" id="BmsCustomerPriceSetResult">
<id property="customerPricesetId" column="customer_priceset_id" />
<result property="priceSetId" column="price_set_id" />
<result property="customerId" column="customer_id" />
<result property="customerCode" column="customer_code" />
<result property="customerName" column="customer_name" />
<result property="bindPriority" column="bind_priority" />
<result property="prBegindate" column="pr_begindate" />
<result property="prEnddate" column="pr_enddate" />
<result property="priceSetNote" column="price_set_note" />
<result property="createBy" column="created_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="updated_by" />
<result property="updateTime" column="update_time" />
<result property="priceSetCode" column="price_set_code" />
<result property="priceSetName" column="price_set_name" />
<result property="setType" column="set_type" />
<result property="priceSetStatus" column="price_set_status" />
</resultMap>
<resultMap type="com.bms.customer.customerinfo.domain.BmsPriceSetOption" id="BmsPriceSetOptionResult">
<id property="priceSetId" column="price_set_id" />
<result property="priceSetCode" column="price_set_code" />
<result property="priceSetName" column="price_set_name" />
<result property="setType" column="set_type" />
<result property="status" column="status" />
</resultMap>
<sql id="bindVo">
select c.customer_priceset_id, c.price_set_id, c.customer_id, c.customer_code, c.customer_name,
c.bind_priority, c.pr_begindate, c.pr_enddate, c.price_set_note,
c.created_by, c.create_time, c.updated_by, c.update_time,
s.price_set_code, s.price_set_name, s.set_type,
s.status as price_set_status
from prc_customer_price_set c
left join prc_price_set s on s.price_set_id = c.price_set_id
</sql>
<select id="selectBindListByCustomerId" resultMap="BmsCustomerPriceSetResult">
<include refid="bindVo"/>
where c.customer_id = #{customerId}
order by c.bind_priority asc, c.customer_priceset_id asc
</select>
<select id="selectBindById" parameterType="Long" resultMap="BmsCustomerPriceSetResult">
<include refid="bindVo"/>
where c.customer_priceset_id = #{customerPricesetId}
</select>
<select id="selectBindByCustomerId" resultMap="BmsCustomerPriceSetResult">
select customer_priceset_id, price_set_id, customer_id, customer_code, customer_name,
bind_priority, pr_begindate, pr_enddate, price_set_note,
created_by, create_time, updated_by, update_time
from prc_customer_price_set
where customer_id = #{customerId}
limit 1
</select>
<insert id="insertBind" parameterType="com.bms.customer.customerinfo.domain.BmsCustomerPriceSet"
useGeneratedKeys="true" keyProperty="customerPricesetId">
insert into prc_customer_price_set (
price_set_id, customer_id, customer_code, customer_name,
bind_priority, pr_begindate, pr_enddate, price_set_note,
created_by, create_time
) values (
#{priceSetId}, #{customerId}, #{customerCode}, #{customerName},
#{bindPriority}, #{prBegindate}, #{prEnddate}, #{priceSetNote},
#{createBy}, sysdate()
)
</insert>
<update id="updateBind" parameterType="com.bms.customer.customerinfo.domain.BmsCustomerPriceSet">
update prc_customer_price_set
set price_set_id = #{priceSetId},
customer_code = #{customerCode},
customer_name = #{customerName},
bind_priority = #{bindPriority},
pr_begindate = #{prBegindate},
pr_enddate = #{prEnddate},
price_set_note = #{priceSetNote},
updated_by = #{updateBy},
update_time = sysdate()
where customer_priceset_id = #{customerPricesetId}
</update>
<delete id="deleteBindByIds" parameterType="Long">
delete from prc_customer_price_set where customer_priceset_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectPriceSetOptionList"
parameterType="com.bms.customer.customerinfo.domain.BmsPriceSetOption"
resultMap="BmsPriceSetOptionResult">
select price_set_id, price_set_code, price_set_name, set_type, status
from prc_price_set
<where>
status = 'E'
<if test="setType != null and setType != ''">
and set_type = #{setType}
</if>
<if test="keyword != null and keyword != ''">
and (price_set_code like concat('%', #{keyword}, '%')
or price_set_name like concat('%', #{keyword}, '%'))
</if>
</where>
order by price_set_id desc
</select>
<select id="selectPriceSetOptionById" resultMap="BmsPriceSetOptionResult">
select price_set_id, price_set_code, price_set_name, set_type, status
from prc_price_set
where price_set_id = #{priceSetId}
</select>
</mapper>
@@ -0,0 +1,614 @@
<?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.bms.customer.supplierinfo.mapper.BmsSupplierMapper">
<resultMap type="BmsSupplier" id="BmsSupplierResult">
<result property="supplierId" column="supplier_id" />
<result property="supplierCode" column="supplier_code" />
<result property="supplierName" column="supplier_name" />
<result property="supplierCodeDw" column="supplier_code_dw" />
<result property="creditCode" column="credit_code" />
<result property="supplierType" column="supplier_type" />
<result property="isEnable" column="is_enable" />
<result property="purchaserUserId" column="purchaser_user_id" />
<result property="purchaserUser" column="purchaser_user" />
<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="ed" column="ed" />
<result property="zq" column="zq" />
<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="creditEd" column="credit_ed" />
<result property="weightThreshold" column="weight_threshold" />
<result property="throwRatio" column="throw_ratio" />
<result property="cooperationStartDate" column="cooperation_start_date" />
<result property="cooperationStatus" column="cooperation_status" />
<result property="channelIds" column="channel_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="selectBmsSupplierVo">
select s.supplier_id, s.supplier_code, s.supplier_name, s.supplier_code_dw, s.credit_code, s.supplier_type,
s.is_enable, s.purchaser_user_id, s.purchaser_user, s.settlement_user_id, s.settlement_user,
s.service_user_id, s.service_user, s.ed, s.zq, s.settlement_type, s.temp_ed, s.account_balance,
s.foreign_currency_balance, s.credit_ed, s.weight_threshold, s.throw_ratio, s.cooperation_start_date,
s.cooperation_status, s.channel_ids, s.remark, s.create_by, s.create_time, s.update_by, s.update_time, s.del_flag
from sup_supplier s
<!-- 数据权限:采购/销售(仅本人 s.purchaser_user_id)/部门经理(本部门 su.dept_id);
非数字历史工号 +0 后不匹配任何 sys_user,仅管理员可见 -->
left join sys_user su on su.user_id = s.purchaser_user_id + 0
</sql>
<select id="selectBmsSupplierList" parameterType="BmsSupplier" resultMap="BmsSupplierResult">
<include refid="selectBmsSupplierVo"/>
<where>
s.del_flag = '0'
<if test="supplierCode != null and supplierCode != ''"> and s.supplier_code = #{supplierCode}</if>
<if test="supplierName != null and supplierName != ''"> and s.supplier_name like concat('%', #{supplierName}, '%')</if>
<if test="supplierCodeDw != null and supplierCodeDw != ''"> and s.supplier_code_dw = #{supplierCodeDw}</if>
<if test="creditCode != null and creditCode != ''"> and s.credit_code = #{creditCode}</if>
<if test="supplierType != null and supplierType != ''"> and s.supplier_type = #{supplierType}</if>
<if test="isEnable != null and isEnable != ''"> and s.is_enable = #{isEnable}</if>
<if test="purchaserUserId != null and purchaserUserId != ''"> and s.purchaser_user_id = #{purchaserUserId}</if>
<if test="purchaserUser != null and purchaserUser != ''"> and s.purchaser_user = #{purchaserUser}</if>
<if test="settlementUserId != null and settlementUserId != ''"> and s.settlement_user_id = #{settlementUserId}</if>
<if test="settlementUser != null and settlementUser != ''"> and s.settlement_user = #{settlementUser}</if>
<if test="serviceUserId != null and serviceUserId != ''"> and s.service_user_id = #{serviceUserId}</if>
<if test="serviceUser != null and serviceUser != ''"> and s.service_user = #{serviceUser}</if>
<if test="cooperationStatus != null and cooperationStatus != ''"> and s.cooperation_status = #{cooperationStatus}</if>
<!-- 数据权限过滤(@DataScope 生成:仅本人= s.purchaser_user_id=当前用户;本部门= su.dept_id=当前用户部门) -->
${params.dataScope}
</where>
order by s.supplier_id desc
</select>
<select id="selectBmsSupplierBySupplierId" parameterType="Long" resultMap="BmsSupplierResult">
<include refid="selectBmsSupplierVo"/>
where s.supplier_id = #{supplierId} and s.del_flag = '0'
</select>
<insert id="insertBmsSupplier" parameterType="BmsSupplier" useGeneratedKeys="true" keyProperty="supplierId">
insert into sup_supplier
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="supplierCode != null and supplierCode != ''">supplier_code,</if>
<if test="supplierName != null and supplierName != ''">supplier_name,</if>
<if test="supplierCodeDw != null">supplier_code_dw,</if>
<if test="creditCode != null">credit_code,</if>
<if test="supplierType != null">supplier_type,</if>
<if test="isEnable != null">is_enable,</if>
<if test="purchaserUserId != null">purchaser_user_id,</if>
<if test="purchaserUser != null">purchaser_user,</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="ed != null">ed,</if>
<if test="zq != null">zq,</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="creditEd != null">credit_ed,</if>
<if test="weightThreshold != null">weight_threshold,</if>
<if test="throwRatio != null">throw_ratio,</if>
<if test="cooperationStartDate != null">cooperation_start_date,</if>
<if test="cooperationStatus != null">cooperation_status,</if>
<if test="channelIds != null">channel_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="supplierCode != null and supplierCode != ''">#{supplierCode},</if>
<if test="supplierName != null and supplierName != ''">#{supplierName},</if>
<if test="supplierCodeDw != null">#{supplierCodeDw},</if>
<if test="creditCode != null">#{creditCode},</if>
<if test="supplierType != null">#{supplierType},</if>
<if test="isEnable != null">#{isEnable},</if>
<if test="purchaserUserId != null">#{purchaserUserId},</if>
<if test="purchaserUser != null">#{purchaserUser},</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="ed != null">#{ed},</if>
<if test="zq != null">#{zq},</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="creditEd != null">#{creditEd},</if>
<if test="weightThreshold != null">#{weightThreshold},</if>
<if test="throwRatio != null">#{throwRatio},</if>
<if test="cooperationStartDate != null">#{cooperationStartDate},</if>
<if test="cooperationStatus != null">#{cooperationStatus},</if>
<if test="channelIds != null">#{channelIds},</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="updateBmsSupplier" parameterType="BmsSupplier">
update sup_supplier
<trim prefix="SET" suffixOverrides=",">
<if test="supplierCode != null and supplierCode != ''">supplier_code = #{supplierCode},</if>
<if test="supplierName != null and supplierName != ''">supplier_name = #{supplierName},</if>
<if test="supplierCodeDw != null">supplier_code_dw = #{supplierCodeDw},</if>
<if test="creditCode != null">credit_code = #{creditCode},</if>
<if test="supplierType != null">supplier_type = #{supplierType},</if>
<if test="isEnable != null">is_enable = #{isEnable},</if>
purchaser_user_id = #{purchaserUserId},
purchaser_user = #{purchaserUser},
settlement_user_id = #{settlementUserId},
settlement_user = #{settlementUser},
service_user_id = #{serviceUserId},
service_user = #{serviceUser},
<if test="ed != null">ed = #{ed},</if>
<if test="zq != null">zq = #{zq},</if>
<if test="settlementType != null">settlement_type = #{settlementType},</if>
<if test="tempEd != null">temp_ed = #{tempEd},</if>
<if test="accountBalance != null">account_balance = #{accountBalance},</if>
<if test="foreignCurrencyBalance != null">foreign_currency_balance = #{foreignCurrencyBalance},</if>
<if test="creditEd != null">credit_ed = #{creditEd},</if>
<if test="weightThreshold != null">weight_threshold = #{weightThreshold},</if>
<if test="throwRatio != null">throw_ratio = #{throwRatio},</if>
<if test="cooperationStartDate != null">cooperation_start_date = #{cooperationStartDate},</if>
<if test="cooperationStatus != null">cooperation_status = #{cooperationStatus},</if>
<if test="channelIds != null">channel_ids = #{channelIds},</if>
<if test="remark != null">remark = #{remark},</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 supplier_id = #{supplierId}
</update>
<delete id="deleteBmsSupplierBySupplierId" parameterType="Long">
delete from sup_supplier where supplier_id = #{supplierId}
</delete>
<delete id="deleteBmsSupplierBySupplierIds" parameterType="Long">
delete from sup_supplier where supplier_id in
<foreach item="supplierId" collection="array" open="(" separator="," close=")">
#{supplierId}
</foreach>
</delete>
<!-- ========== sup_supplier_attachment 子表 ========== -->
<resultMap type="com.bms.customer.supplierinfo.domain.BmsSupplierAttachment" id="BmsSupplierAttachmentResult">
<result property="attachmentId" column="attachment_id" />
<result property="supplierId" column="supplier_id" />
<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="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="selectBmsSupplierAttachmentVo">
select attachment_id, supplier_id, file_name, file_path, file_size, file_type, file_extension, attachment_type, is_logo, sort_order, remark, create_by, create_time, update_by, update_time, del_flag from sup_supplier_attachment
</sql>
<select id="selectBmsSupplierAttachmentList" parameterType="com.bms.customer.supplierinfo.domain.BmsSupplierAttachment" resultMap="BmsSupplierAttachmentResult">
<include refid="selectBmsSupplierAttachmentVo"/>
<where>
<if test="supplierId != null"> and supplier_id = #{supplierId}</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="isLogo != null and isLogo != ''"> and is_logo = #{isLogo}</if>
and del_flag = '0'
</where>
order by sort_order asc
</select>
<insert id="insertBmsSupplierAttachment" parameterType="com.bms.customer.supplierinfo.domain.BmsSupplierAttachment" useGeneratedKeys="true" keyProperty="attachmentId">
insert into sup_supplier_attachment
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="supplierId != null">supplier_id,</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="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="supplierId != null">#{supplierId},</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="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="updateBmsSupplierAttachment" parameterType="com.bms.customer.supplierinfo.domain.BmsSupplierAttachment">
update sup_supplier_attachment
<trim prefix="SET" suffixOverrides=",">
<if test="supplierId != null">supplier_id = #{supplierId},</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="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="deleteBmsSupplierAttachmentBySupplierId" parameterType="Long">
update sup_supplier_attachment set del_flag = '2' where supplier_id = #{supplierId}
</delete>
<delete id="deleteBmsSupplierAttachmentByAttachmentId" parameterType="Long">
update sup_supplier_attachment set del_flag = '2' where attachment_id = #{attachmentId}
</delete>
<!-- ========== sup_supplier_company 子表 ========== -->
<resultMap type="com.bms.customer.supplierinfo.domain.BmsSupplierCompany" id="BmsSupplierCompanyResult">
<result property="companyId" column="company_id" />
<result property="supplierId" column="supplier_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="selectBmsSupplierCompanyVo">
select company_id, supplier_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 sup_supplier_company
</sql>
<select id="selectBmsSupplierCompanyList" parameterType="com.bms.customer.supplierinfo.domain.BmsSupplierCompany" resultMap="BmsSupplierCompanyResult">
<include refid="selectBmsSupplierCompanyVo"/>
<where>
<if test="supplierId != null"> and supplier_id = #{supplierId}</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="selectBmsSupplierCompanyByCompanyId" parameterType="Long" resultMap="BmsSupplierCompanyResult">
<include refid="selectBmsSupplierCompanyVo"/>
where company_id = #{companyId} and del_flag = '0'
</select>
<insert id="insertBmsSupplierCompany" parameterType="com.bms.customer.supplierinfo.domain.BmsSupplierCompany" useGeneratedKeys="true" keyProperty="companyId">
insert into sup_supplier_company
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="supplierId != null">supplier_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="supplierId != null">#{supplierId},</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="updateBmsSupplierCompany" parameterType="com.bms.customer.supplierinfo.domain.BmsSupplierCompany">
update sup_supplier_company
<trim prefix="SET" suffixOverrides=",">
<if test="supplierId != null">supplier_id = #{supplierId},</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="deleteBmsSupplierCompanyBySupplierId" parameterType="Long">
update sup_supplier_company set del_flag = '2' where supplier_id = #{supplierId}
</delete>
<delete id="deleteBmsSupplierCompanyByCompanyId" parameterType="Long">
update sup_supplier_company set del_flag = '2' where company_id = #{companyId}
</delete>
<!-- ========== sup_supplier_contact 子表 ========== -->
<resultMap type="com.bms.customer.supplierinfo.domain.BmsSupplierContact" id="BmsSupplierContactResult">
<result property="contactId" column="contact_id" />
<result property="supplierId" column="supplier_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="selectBmsSupplierContactVo">
select contact_id, supplier_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 sup_supplier_contact
</sql>
<select id="selectBmsSupplierContactList" parameterType="com.bms.customer.supplierinfo.domain.BmsSupplierContact" resultMap="BmsSupplierContactResult">
<include refid="selectBmsSupplierContactVo"/>
<where>
<if test="supplierId != null"> and supplier_id = #{supplierId}</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>
<if test="isDefault != null and isDefault != ''"> and is_default = #{isDefault}</if>
and del_flag = '0'
</where>
order by sort_order asc
</select>
<select id="selectBmsSupplierContactByContactId" parameterType="Long" resultMap="BmsSupplierContactResult">
<include refid="selectBmsSupplierContactVo"/>
where contact_id = #{contactId} and del_flag = '0'
</select>
<insert id="insertBmsSupplierContact" parameterType="com.bms.customer.supplierinfo.domain.BmsSupplierContact" useGeneratedKeys="true" keyProperty="contactId">
insert into sup_supplier_contact
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="supplierId != null">supplier_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="supplierId != null">#{supplierId},</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="updateBmsSupplierContact" parameterType="com.bms.customer.supplierinfo.domain.BmsSupplierContact">
update sup_supplier_contact
<trim prefix="SET" suffixOverrides=",">
<if test="supplierId != null">supplier_id = #{supplierId},</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="deleteBmsSupplierContactBySupplierId" parameterType="Long">
update sup_supplier_contact set del_flag = '2' where supplier_id = #{supplierId}
</delete>
<delete id="deleteBmsSupplierContactByContactId" parameterType="Long">
update sup_supplier_contact set del_flag = '2' where contact_id = #{contactId}
</delete>
</mapper>
@@ -0,0 +1,169 @@
<?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.bms.customer.customermoney.mapper.CreditQuotaMapper">
<!-- ================= 角色额度池 ================= -->
<select id="selectRoleQuotaList" resultType="com.bms.customer.customermoney.vo.RoleCreditQuotaVo">
select r.role_id as roleId,
r.role_name as roleName,
r.role_key as roleKey,
r.status as status,
coalesce(q.total_quota, 0) as totalQuota,
(select coalesce(sum(g.remaining), 0)
from ctr_customer_credit_grant g
where g.role_id = r.role_id and g.status = '0' and g.del_flag = '0') as usedQuota,
q.remark as remark
from sys_role r
left join sys_role_credit_quota q on q.role_id = r.role_id
where r.del_flag = '0'
order by r.role_sort, r.role_id
</select>
<select id="selectRoleQuotaListByUserId"
resultType="com.bms.customer.customermoney.vo.RoleCreditQuotaVo">
select r.role_id as roleId,
r.role_name as roleName,
r.role_key as roleKey,
r.status as status,
q.total_quota as totalQuota,
(select coalesce(sum(g.remaining), 0)
from ctr_customer_credit_grant g
where g.role_id = r.role_id and g.status = '0' and g.del_flag = '0') as usedQuota,
q.remark as remark
from sys_user_role ur
inner join sys_role r on r.role_id = ur.role_id and r.del_flag = '0' and r.status = '0'
inner join sys_role_credit_quota q on q.role_id = r.role_id
where ur.user_id = #{userId}
order by r.role_sort, r.role_id
</select>
<select id="selectQuotaForUpdate"
resultType="com.bms.customer.customermoney.domain.SysRoleCreditQuota">
select role_id as roleId, total_quota as totalQuota, version, remark
from sys_role_credit_quota
where role_id = #{roleId}
for update
</select>
<select id="sumActiveRemaining" resultType="java.math.BigDecimal">
select coalesce(sum(remaining), 0)
from ctr_customer_credit_grant
where role_id = #{roleId} and status = '0' and del_flag = '0'
</select>
<insert id="insertQuota" parameterType="com.bms.customer.customermoney.domain.SysRoleCreditQuota">
insert into sys_role_credit_quota (role_id, total_quota, version, create_by, create_time, remark)
values (#{roleId}, #{totalQuota}, 0, #{createBy}, sysdate(), #{remark})
on duplicate key update total_quota = values(total_quota),
remark = values(remark),
update_by = values(create_by),
update_time = now()
</insert>
<update id="updateQuota" parameterType="com.bms.customer.customermoney.domain.SysRoleCreditQuota">
update sys_role_credit_quota
set total_quota = #{totalQuota},
version = version + 1,
update_by = #{updateBy},
update_time = now(),
remark = #{remark}
where role_id = #{roleId} and version = #{version}
</update>
<!-- ================= 授信分配台账 ================= -->
<resultMap type="com.bms.customer.customermoney.domain.CustomerCreditGrant" id="CustomerCreditGrantResult">
<id property="grantId" column="grant_id" />
<result property="customerId" column="customer_id" />
<result property="accountId" column="account_id" />
<result property="roleId" column="role_id" />
<result property="approveUserId" column="approve_user_id" />
<result property="applyId" column="apply_id" />
<result property="flowId" column="flow_id" />
<result property="creditType" column="credit_type" />
<result property="amount" column="amount" />
<result property="remaining" column="remaining" />
<result property="effectiveDate" column="effective_date" />
<result property="expireDate" column="expire_date" />
<result property="status" column="status" />
<result property="releaseTime" column="release_time" />
<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="remark" column="remark" />
<result property="delFlag" column="del_flag" />
<result property="customerCode" column="customer_code" />
<result property="customerName" column="customer_name" />
<result property="roleName" column="role_name" />
<result property="approveBy" column="approve_by" />
</resultMap>
<sql id="grantVo">
select g.grant_id, g.customer_id, g.account_id, g.role_id, g.approve_user_id, g.apply_id, g.flow_id,
g.credit_type, g.amount, g.remaining, g.effective_date, g.expire_date, g.status, g.release_time,
g.create_by, g.create_time, g.update_by, g.update_time, g.remark, g.del_flag,
c.customer_code, c.customer_name,
r.role_name,
u.user_name as approve_by
from ctr_customer_credit_grant g
left join ctr_customer c on c.customer_id = g.customer_id
left join sys_role r on r.role_id = g.role_id
left join sys_user u on u.user_id = g.approve_user_id
</sql>
<select id="selectGrantList"
parameterType="com.bms.customer.customermoney.domain.CustomerCreditGrant"
resultMap="CustomerCreditGrantResult">
<include refid="grantVo"/>
<where>
g.del_flag = '0'
<if test="customerId != null"> and g.customer_id = #{customerId}</if>
<if test="roleId != null"> and g.role_id = #{roleId}</if>
<if test="creditType != null and creditType != ''"> and g.credit_type = #{creditType}</if>
<if test="status != null and status != ''"> and g.status = #{status}</if>
</where>
order by g.grant_id desc
</select>
<select id="selectActiveGrantsForUpdate"
resultMap="CustomerCreditGrantResult">
select grant_id, customer_id, account_id, role_id, approve_user_id, apply_id, flow_id,
credit_type, amount, remaining, effective_date, expire_date, status,
create_by, create_time, update_by, update_time, del_flag
from ctr_customer_credit_grant
where customer_id = #{customerId}
and credit_type = #{creditType}
and status = '0'
and del_flag = '0'
order by grant_id
for update
</select>
<insert id="insertGrant" parameterType="com.bms.customer.customermoney.domain.CustomerCreditGrant"
useGeneratedKeys="true" keyProperty="grantId">
insert into ctr_customer_credit_grant (
customer_id, account_id, role_id, approve_user_id, apply_id, flow_id,
credit_type, amount, remaining, effective_date, expire_date, status,
create_by, create_time, remark, del_flag
) values (
#{customerId}, #{accountId}, #{roleId}, #{approveUserId}, #{applyId}, #{flowId},
#{creditType}, #{amount}, #{remaining}, #{effectiveDate}, #{expireDate}, #{status},
#{createBy}, sysdate(), #{remark}, '0'
)
</insert>
<update id="updateGrantRemaining"
parameterType="com.bms.customer.customermoney.domain.CustomerCreditGrant">
update ctr_customer_credit_grant
set remaining = #{remaining},
status = #{status},
release_time = #{releaseTime},
update_by = #{updateBy},
update_time = now()
where grant_id = #{grantId}
</update>
</mapper>
@@ -0,0 +1,134 @@
<?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.bms.customer.customermoney.mapper.CustomerCreditApplyMapper">
<resultMap type="com.bms.customer.customermoney.domain.CustomerCreditApply" id="CustomerCreditApplyResult">
<id property="applyId" column="apply_id" />
<result property="applyNo" column="apply_no" />
<result property="customerId" column="customer_id" />
<result property="accountId" column="account_id" />
<result property="creditType" column="credit_type" />
<result property="adjustMode" column="adjust_mode" />
<result property="changeAmount" column="change_amount" />
<result property="effectiveDate" column="effective_date" />
<result property="expireDate" column="expire_date" />
<result property="reason" column="reason" />
<result property="status" column="status" />
<result property="applyBy" column="apply_by" />
<result property="applyUserId" column="apply_user_id" />
<result property="applyTime" column="apply_time" />
<result property="approveBy" column="approve_by" />
<result property="approveUserId" column="approve_user_id"/>
<result property="approveRoleId" column="approve_role_id"/>
<result property="approveRoleName" column="approve_role_name"/>
<result property="approveTime" column="approve_time" />
<result property="approveRemark" column="approve_remark" />
<result property="flowId" column="flow_id" />
<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="remark" column="remark" />
<result property="delFlag" column="del_flag" />
<result property="customerCode" column="customer_code" />
<result property="customerName" column="customer_name" />
</resultMap>
<sql id="applyVo">
select a.apply_id, a.apply_no, a.customer_id, a.account_id, a.credit_type, a.adjust_mode,
a.change_amount, a.effective_date, a.expire_date, a.reason, a.status,
a.apply_by, a.apply_user_id, a.apply_time,
a.approve_by, a.approve_user_id, a.approve_role_id, a.approve_time, a.approve_remark, a.flow_id,
a.create_by, a.create_time, a.update_by, a.update_time, a.remark, a.del_flag,
c.customer_code, c.customer_name,
r.role_name as approve_role_name
from ctr_customer_credit_apply a
left join ctr_customer c on a.customer_id = c.customer_id
left join sys_role r on r.role_id = a.approve_role_id
</sql>
<select id="selectApplyList"
parameterType="com.bms.customer.customermoney.domain.CustomerCreditApply"
resultMap="CustomerCreditApplyResult">
<include refid="applyVo"/>
<where>
a.del_flag = '0'
<if test="customerId != null"> and a.customer_id = #{customerId}</if>
<if test="status != null and status != ''"> and a.status = #{status}</if>
<if test="creditType != null and creditType != ''"> and a.credit_type = #{creditType}</if>
<if test="applyNo != null and applyNo != ''"> and a.apply_no like concat('%', #{applyNo}, '%')</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 申请时间范围 -->
and date_format(a.apply_time, '%y%m%d') &gt;= date_format(#{params.beginTime}, '%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''">
and date_format(a.apply_time, '%y%m%d') &lt;= date_format(#{params.endTime}, '%y%m%d')
</if>
</where>
order by a.apply_id desc
</select>
<select id="selectApplyById" resultMap="CustomerCreditApplyResult">
<include refid="applyVo"/>
where a.apply_id = #{applyId} and a.del_flag = '0'
</select>
<select id="selectApplyByIdForUpdate" resultMap="CustomerCreditApplyResult">
select * from ctr_customer_credit_apply where apply_id = #{applyId} and del_flag = '0' for update
</select>
<insert id="insertApply"
parameterType="com.bms.customer.customermoney.domain.CustomerCreditApply"
useGeneratedKeys="true" keyProperty="applyId">
insert into ctr_customer_credit_apply (
apply_no, customer_id, credit_type, adjust_mode, change_amount,
effective_date, expire_date, reason, status,
apply_by, apply_user_id, apply_time,
create_by, create_time, remark
) values (
#{applyNo}, #{customerId}, #{creditType}, #{adjustMode}, #{changeAmount},
#{effectiveDate}, #{expireDate}, #{reason}, #{status},
#{applyBy}, #{applyUserId}, #{applyTime},
#{createBy}, sysdate(), #{remark}
)
</insert>
<update id="updateApproved"
parameterType="com.bms.customer.customermoney.domain.CustomerCreditApply">
update ctr_customer_credit_apply
set status = 'APPROVED',
account_id = #{accountId},
flow_id = #{flowId},
approve_by = #{approveBy},
approve_user_id = #{approveUserId},
approve_role_id = #{approveRoleId},
approve_time = sysdate(),
approve_remark = #{approveRemark},
update_by = #{approveBy},
update_time = sysdate()
where apply_id = #{applyId} and status = 'PENDING' and del_flag = '0'
</update>
<update id="updateRejected"
parameterType="com.bms.customer.customermoney.domain.CustomerCreditApply">
update ctr_customer_credit_apply
set status = 'REJECTED',
approve_by = #{approveBy},
approve_user_id = #{approveUserId},
approve_time = sysdate(),
approve_remark = #{approveRemark},
update_by = #{approveBy},
update_time = sysdate()
where apply_id = #{applyId} and status = 'PENDING' and del_flag = '0'
</update>
<update id="updateCancelled">
update ctr_customer_credit_apply
set status = 'CANCELLED',
update_by = #{updateBy},
update_time = sysdate()
where apply_id = #{applyId} and status = 'PENDING' and del_flag = '0'
</update>
</mapper>
@@ -0,0 +1,497 @@
<?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.bms.customer.customermoney.mapper.CustomerMoneyMapper">
<!-- ================= 客户余额账户 ================= -->
<resultMap type="com.bms.customer.customermoney.domain.CustomerAccount" id="CustomerAccountResult">
<id property="id" column="id" />
<result property="customerId" column="customer_id" />
<result property="currency" column="currency" />
<result property="balance" column="balance" />
<result property="frozenBalance" column="frozen_balance" />
<result property="totalCredit" column="total_credit" />
<result property="creditEffectiveDate" column="credit_effective_date" />
<result property="creditExpireDate" column="credit_expire_date" />
<result property="extraCredit" column="extra_credit" />
<result property="extraEffectiveDate" column="extra_effective_date" />
<result property="extraExpireDate" column="extra_expire_date" />
<result property="usedCredit" column="used_credit" />
<result property="tax" column="tax" />
<result property="version" column="version" />
<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="remark" column="remark" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectCustomerAccountVo">
select id, customer_id, currency, balance, frozen_balance, total_credit,
credit_effective_date, credit_expire_date, extra_credit,
extra_effective_date, extra_expire_date, used_credit,
tax, version, create_by, create_time, update_by, update_time, remark, del_flag
from ctr_customer_account
</sql>
<select id="selectAccountByCustomerCurrency" resultMap="CustomerAccountResult">
<include refid="selectCustomerAccountVo"/>
where customer_id = #{customerId} and currency = #{currency} and del_flag = '0'
</select>
<select id="selectAccountForUpdate" resultMap="CustomerAccountResult">
<include refid="selectCustomerAccountVo"/>
where customer_id = #{customerId} and currency = #{currency} and del_flag = '0'
for update
</select>
<select id="selectAccountListByCustomerId" resultMap="CustomerAccountResult">
<include refid="selectCustomerAccountVo"/>
where customer_id = #{customerId} and del_flag = '0'
</select>
<!-- 扫描已到期授信的CNY账户(信用或临时额度失效日早于今天;失效日当天仍有效,故严格小于今天) -->
<select id="selectExpiredCreditCustomerIds" resultType="java.lang.Long">
select distinct customer_id
from ctr_customer_account
where del_flag = '0'
and currency = 'CNY'
and (
(total_credit &gt; 0 and credit_expire_date is not null and credit_expire_date &lt; CURDATE())
or
(extra_credit &gt; 0 and extra_expire_date is not null and extra_expire_date &lt; CURDATE())
)
</select>
<insert id="insertAccount" parameterType="com.bms.customer.customermoney.domain.CustomerAccount"
useGeneratedKeys="true" keyProperty="id">
insert into ctr_customer_account
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="customerId != null">customer_id,</if>
<if test="currency != null">currency,</if>
<if test="balance != null">balance,</if>
<if test="frozenBalance != null">frozen_balance,</if>
<if test="totalCredit != null">total_credit,</if>
<if test="extraCredit != null">extra_credit,</if>
<if test="usedCredit != null">used_credit,</if>
<if test="tax != null">tax,</if>
<if test="version != null">version,</if>
<if test="createBy != null">create_by,</if>
<if test="remark != null">remark,</if>
del_flag,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="customerId != null">#{customerId},</if>
<if test="currency != null">#{currency},</if>
<if test="balance != null">#{balance},</if>
<if test="frozenBalance != null">#{frozenBalance},</if>
<if test="totalCredit != null">#{totalCredit},</if>
<if test="extraCredit != null">#{extraCredit},</if>
<if test="usedCredit != null">#{usedCredit},</if>
<if test="tax != null">#{tax},</if>
<if test="version != null">#{version},</if>
<if test="createBy != null">#{createBy},</if>
<if test="remark != null">#{remark},</if>
'0',
</trim>
</insert>
<update id="updateAccountBalance">
update ctr_customer_account
set balance = #{balance},
frozen_balance = #{frozenBalance},
used_credit = #{usedCredit},
version = version + 1,
update_by = #{updateBy},
update_time = now()
where id = #{id} and version = #{version} and del_flag = '0'
</update>
<!-- 乐观锁更新额度(信用/临时额度及各自有效期) -->
<update id="updateAccountCredit">
update ctr_customer_account
set total_credit = #{totalCredit},
credit_effective_date = #{creditEffectiveDate},
credit_expire_date = #{creditExpireDate},
extra_credit = #{extraCredit},
extra_effective_date = #{extraEffectiveDate},
extra_expire_date = #{extraExpireDate},
version = version + 1,
update_by = #{updateBy},
update_time = now()
where id = #{id} and version = #{version} and del_flag = '0'
</update>
<!-- ================= 客户额度流水 ================= -->
<resultMap type="com.bms.customer.customermoney.domain.CustomerCreditFlow" id="CustomerCreditFlowResult">
<id property="id" column="id" />
<result property="flowNo" column="flow_no" />
<result property="customerId" column="customer_id" />
<result property="accountId" column="account_id" />
<result property="creditType" column="credit_type" />
<result property="changeType" column="change_type" />
<result property="bizType" column="biz_type" />
<result property="bizId" column="biz_id" />
<result property="bizNo" column="biz_no" />
<result property="direction" column="direction" />
<result property="beforeAmount" column="before_amount" />
<result property="changeAmount" column="change_amount" />
<result property="afterAmount" column="after_amount" />
<result property="usedCredit" column="used_credit" />
<result property="effectiveDate" column="effective_date" />
<result property="expireDate" column="expire_date" />
<result property="reason" column="reason" />
<result property="adjustMode" column="adjust_mode" />
<result property="operatorId" column="operator_id" />
<result property="roleId" column="role_id" />
<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="remark" column="remark" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectCustomerCreditFlowVo">
select id, flow_no, customer_id, account_id, credit_type, change_type, biz_type, biz_id, biz_no, direction,
before_amount, change_amount, after_amount, used_credit,
effective_date, expire_date, reason, adjust_mode, operator_id, role_id,
create_by, create_time, update_by, update_time, remark, del_flag
from ctr_customer_credit_flow
</sql>
<select id="selectCreditFlowList" parameterType="com.bms.customer.customermoney.domain.CustomerCreditFlow"
resultMap="CustomerCreditFlowResult">
<include refid="selectCustomerCreditFlowVo"/>
<where>
<if test="customerId != null"> and customer_id = #{customerId}</if>
<if test="creditType != null and creditType != ''"> and credit_type = #{creditType}</if>
<if test="changeType != null and changeType != ''"> and change_type = #{changeType}</if>
<if test="bizType != null and bizType != ''"> and biz_type = #{bizType}</if>
<if test="bizId != null"> and biz_id = #{bizId}</if>
<if test="params.beginTime != null and params.beginTime != ''"> and date(create_time) &gt;= #{params.beginTime}</if>
<if test="params.endTime != null and params.endTime != ''"> and date(create_time) &lt;= #{params.endTime}</if>
and del_flag = '0'
</where>
order by create_time desc, id desc
</select>
<insert id="insertCreditFlow" parameterType="com.bms.customer.customermoney.domain.CustomerCreditFlow"
useGeneratedKeys="true" keyProperty="id">
insert into ctr_customer_credit_flow
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="flowNo != null">flow_no,</if>
<if test="customerId != null">customer_id,</if>
<if test="accountId != null">account_id,</if>
<if test="creditType != null">credit_type,</if>
<if test="changeType != null">change_type,</if>
<if test="bizType != null">biz_type,</if>
<if test="bizId != null">biz_id,</if>
<if test="bizNo != null">biz_no,</if>
<if test="direction != null">direction,</if>
<if test="beforeAmount != null">before_amount,</if>
<if test="changeAmount != null">change_amount,</if>
<if test="afterAmount != null">after_amount,</if>
<if test="usedCredit != null">used_credit,</if>
<if test="effectiveDate != null">effective_date,</if>
<if test="expireDate != null">expire_date,</if>
<if test="reason != null">reason,</if>
<if test="adjustMode != null">adjust_mode,</if>
<if test="operatorId != null">operator_id,</if>
<if test="roleId != null">role_id,</if>
<if test="createBy != null">create_by,</if>
<if test="remark != null">remark,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="flowNo != null">#{flowNo},</if>
<if test="customerId != null">#{customerId},</if>
<if test="accountId != null">#{accountId},</if>
<if test="creditType != null">#{creditType},</if>
<if test="changeType != null">#{changeType},</if>
<if test="bizType != null">#{bizType},</if>
<if test="bizId != null">#{bizId},</if>
<if test="bizNo != null">#{bizNo},</if>
<if test="direction != null">#{direction},</if>
<if test="beforeAmount != null">#{beforeAmount},</if>
<if test="changeAmount != null">#{changeAmount},</if>
<if test="afterAmount != null">#{afterAmount},</if>
<if test="usedCredit != null">#{usedCredit},</if>
<if test="effectiveDate != null">#{effectiveDate},</if>
<if test="expireDate != null">#{expireDate},</if>
<if test="reason != null">#{reason},</if>
<if test="adjustMode != null">#{adjustMode},</if>
<if test="operatorId != null">#{operatorId},</if>
<if test="roleId != null">#{roleId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="remark != null">#{remark},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<!-- ================= 客户收款 ================= -->
<resultMap type="com.bms.customer.customermoney.domain.CustomerReceipt" id="CustomerReceiptResult">
<id property="id" column="id" />
<result property="receiptNo" column="receipt_no" />
<result property="customerId" column="customer_id" />
<result property="accountId" column="account_id" />
<result property="receiptType" column="receipt_type" />
<result property="amount" column="amount" />
<result property="allocatedAmount" column="allocated_amount" />
<result property="unallocatedAmount" column="unallocated_amount" />
<result property="currency" column="currency" />
<result property="exchangeRate" column="exchange_rate" />
<result property="rateSource" column="rate_source" />
<result property="rateSourceDesc" column="rate_source_desc" />
<result property="baseAmount" column="base_amount" />
<result property="payMethod" column="pay_method" />
<result property="bankAccountId" column="bank_account_id" />
<result property="bankAccountName" column="bank_account_name" />
<result property="bankAccountNo" column="bank_account_no" />
<result property="bankName" column="bank_name" />
<result property="bankTransactionNo" column="bank_transaction_no" />
<result property="receivedAt" column="received_at" />
<result property="status" column="status" />
<result property="confirmedAt" column="confirmed_at" />
<result property="confirmedBy" column="confirmed_by" />
<result property="invoiceStatus" column="invoice_status" />
<result property="version" column="version" />
<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="remark" column="remark" />
<result property="delFlag" column="del_flag" />
<result property="attachmentCount" column="attachment_count" />
</resultMap>
<sql id="selectCustomerReceiptVo">
select r.id, r.receipt_no, r.customer_id, r.account_id, r.receipt_type, r.amount, r.allocated_amount,
r.unallocated_amount, r.currency, r.exchange_rate, r.rate_source, r.rate_source_desc,
r.base_amount, r.pay_method, r.bank_account_id, r.bank_account_name,
r.bank_account_no, r.bank_name, r.bank_transaction_no,
r.received_at, r.status,
r.confirmed_at, r.confirmed_by, r.invoice_status, r.version, r.create_by, r.create_time,
r.update_by, r.update_time, r.remark, r.del_flag,
(select count(1) from ctr_customer_attachment a
where a.biz_id = r.id and a.attachment_type = '3' and a.del_flag = '0') as attachment_count
from ctr_customer_receipt r
</sql>
<select id="selectReceiptList" parameterType="com.bms.customer.customermoney.domain.CustomerReceipt"
resultMap="CustomerReceiptResult">
<include refid="selectCustomerReceiptVo"/>
<where>
r.del_flag = '0'
<if test="customerId != null"> and r.customer_id = #{customerId}</if>
<if test="receiptNo != null and receiptNo != ''"> and r.receipt_no like concat('%', #{receiptNo}, '%')</if>
<if test="receiptType != null and receiptType != ''"> and r.receipt_type = #{receiptType}</if>
<if test="status != null and status != ''"> and r.status = #{status}</if>
<if test="currency != null and currency != ''"> and r.currency = #{currency}</if>
<if test="payMethod != null and payMethod != ''"> and r.pay_method = #{payMethod}</if>
<if test="bankTransactionNo != null and bankTransactionNo != ''">
and r.bank_transaction_no like concat('%', #{bankTransactionNo}, '%')
</if>
<if test="params != null and params.beginTime != null and params.beginTime != ''">
and date_format(r.received_at,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params != null and params.endTime != null and params.endTime != ''">
and date_format(r.received_at,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
order by r.received_at desc, r.id desc
</select>
<select id="selectReceiptById" resultMap="CustomerReceiptResult">
<include refid="selectCustomerReceiptVo"/>
where r.id = #{id} and r.del_flag = '0'
</select>
<insert id="insertReceipt" parameterType="com.bms.customer.customermoney.domain.CustomerReceipt"
useGeneratedKeys="true" keyProperty="id">
insert into ctr_customer_receipt
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="receiptNo != null">receipt_no,</if>
<if test="customerId != null">customer_id,</if>
<if test="accountId != null">account_id,</if>
<if test="receiptType != null">receipt_type,</if>
<if test="amount != null">amount,</if>
<if test="allocatedAmount != null">allocated_amount,</if>
<if test="unallocatedAmount != null">unallocated_amount,</if>
<if test="currency != null">currency,</if>
<if test="exchangeRate != null">exchange_rate,</if>
<if test="rateSource != null">rate_source,</if>
<if test="rateSourceDesc != null">rate_source_desc,</if>
<if test="baseAmount != null">base_amount,</if>
<if test="payMethod != null">pay_method,</if>
<if test="bankAccountId != null">bank_account_id,</if>
<if test="bankAccountName != null">bank_account_name,</if>
<if test="bankAccountNo != null">bank_account_no,</if>
<if test="bankName != null">bank_name,</if>
<if test="bankTransactionNo != null">bank_transaction_no,</if>
<if test="receivedAt != null">received_at,</if>
<if test="status != null">status,</if>
<if test="confirmedAt != null">confirmed_at,</if>
<if test="confirmedBy != null">confirmed_by,</if>
<if test="invoiceStatus != null">invoice_status,</if>
<if test="version != null">version,</if>
<if test="createBy != null">create_by,</if>
<if test="remark != null">remark,</if>
del_flag,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="receiptNo != null">#{receiptNo},</if>
<if test="customerId != null">#{customerId},</if>
<if test="accountId != null">#{accountId},</if>
<if test="receiptType != null">#{receiptType},</if>
<if test="amount != null">#{amount},</if>
<if test="allocatedAmount != null">#{allocatedAmount},</if>
<if test="unallocatedAmount != null">#{unallocatedAmount},</if>
<if test="currency != null">#{currency},</if>
<if test="exchangeRate != null">#{exchangeRate},</if>
<if test="rateSource != null">#{rateSource},</if>
<if test="rateSourceDesc != null">#{rateSourceDesc},</if>
<if test="baseAmount != null">#{baseAmount},</if>
<if test="payMethod != null">#{payMethod},</if>
<if test="bankAccountId != null">#{bankAccountId},</if>
<if test="bankAccountName != null">#{bankAccountName},</if>
<if test="bankAccountNo != null">#{bankAccountNo},</if>
<if test="bankName != null">#{bankName},</if>
<if test="bankTransactionNo != null">#{bankTransactionNo},</if>
<if test="receivedAt != null">#{receivedAt},</if>
<if test="status != null">#{status},</if>
<if test="confirmedAt != null">#{confirmedAt},</if>
<if test="confirmedBy != null">#{confirmedBy},</if>
<if test="invoiceStatus != null">#{invoiceStatus},</if>
<if test="version != null">#{version},</if>
<if test="createBy != null">#{createBy},</if>
<if test="remark != null">#{remark},</if>
'0',
</trim>
</insert>
<update id="confirmReceipt" parameterType="com.bms.customer.customermoney.domain.CustomerReceipt">
update ctr_customer_receipt
set status = 'CONFIRMED',
confirmed_at = #{confirmedAt},
confirmed_by = #{confirmedBy},
version = version + 1,
update_by = #{updateBy},
update_time = now()
where id = #{id} and status = 'PENDING' and version = #{version} and del_flag = '0'
</update>
<update id="cancelReceipt">
update ctr_customer_receipt
set status = 'CANCELLED',
update_by = #{updateBy},
update_time = now()
where id = #{id} and status = 'PENDING' and del_flag = '0'
</update>
<!-- ================= 余额流水 ================= -->
<resultMap type="com.bms.customer.customermoney.domain.CustomerBalanceFlow" id="CustomerBalanceFlowResult">
<id property="id" column="id" />
<result property="flowNo" column="flow_no" />
<result property="customerId" column="customer_id" />
<result property="accountId" column="account_id" />
<result property="currency" column="currency" />
<result property="exchangeRate" column="exchange_rate" />
<result property="baseAmount" column="base_amount" />
<result property="bizType" column="biz_type" />
<result property="bizId" column="biz_id" />
<result property="bizNo" column="biz_no" />
<result property="direction" column="direction" />
<result property="amount" column="amount" />
<result property="beforeBalance" column="before_balance" />
<result property="afterBalance" column="after_balance" />
<result property="beforeFrozenBalance" column="before_frozen_balance" />
<result property="afterFrozenBalance" column="after_frozen_balance" />
<result property="operatorId" column="operator_id" />
<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="remark" column="remark" />
<result property="delFlag" column="del_flag" />
</resultMap>
<sql id="selectCustomerBalanceFlowVo">
select id, flow_no, customer_id, account_id, currency, exchange_rate, base_amount, biz_type, biz_id, biz_no,
direction, amount,
before_balance, after_balance, before_frozen_balance, after_frozen_balance, operator_id,
create_by, create_time, update_by, update_time, remark, del_flag
from ctr_customer_balance_flow
</sql>
<select id="selectFlowList" parameterType="com.bms.customer.customermoney.domain.CustomerBalanceFlow"
resultMap="CustomerBalanceFlowResult">
<include refid="selectCustomerBalanceFlowVo"/>
<where>
del_flag = '0'
<if test="customerId != null"> and customer_id = #{customerId}</if>
<if test="accountId != null"> and account_id = #{accountId}</if>
<if test="bizType != null and bizType != ''"> and biz_type = #{bizType}</if>
<if test="direction != null"> and direction = #{direction}</if>
<if test="currency != null and currency != ''"> and currency = #{currency}</if>
<if test="bizNo != null and bizNo != ''"> and biz_no like concat('%', #{bizNo}, '%')</if>
<if test="params != null and params.beginTime != null and params.beginTime != ''">
and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params != null and params.endTime != null and params.endTime != ''">
and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
order by create_time desc, id desc
</select>
<insert id="insertFlow" parameterType="com.bms.customer.customermoney.domain.CustomerBalanceFlow"
useGeneratedKeys="true" keyProperty="id">
insert into ctr_customer_balance_flow
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="flowNo != null">flow_no,</if>
<if test="customerId != null">customer_id,</if>
<if test="accountId != null">account_id,</if>
<if test="currency != null">currency,</if>
<if test="exchangeRate != null">exchange_rate,</if>
<if test="baseAmount != null">base_amount,</if>
<if test="bizType != null">biz_type,</if>
<if test="bizId != null">biz_id,</if>
<if test="bizNo != null">biz_no,</if>
<if test="direction != null">direction,</if>
<if test="amount != null">amount,</if>
<if test="beforeBalance != null">before_balance,</if>
<if test="afterBalance != null">after_balance,</if>
<if test="beforeFrozenBalance != null">before_frozen_balance,</if>
<if test="afterFrozenBalance != null">after_frozen_balance,</if>
<if test="operatorId != null">operator_id,</if>
<if test="createBy != null">create_by,</if>
<if test="remark != null">remark,</if>
del_flag,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="flowNo != null">#{flowNo},</if>
<if test="customerId != null">#{customerId},</if>
<if test="accountId != null">#{accountId},</if>
<if test="currency != null">#{currency},</if>
<if test="exchangeRate != null">#{exchangeRate},</if>
<if test="baseAmount != null">#{baseAmount},</if>
<if test="bizType != null">#{bizType},</if>
<if test="bizId != null">#{bizId},</if>
<if test="bizNo != null">#{bizNo},</if>
<if test="direction != null">#{direction},</if>
<if test="amount != null">#{amount},</if>
<if test="beforeBalance != null">#{beforeBalance},</if>
<if test="afterBalance != null">#{afterBalance},</if>
<if test="beforeFrozenBalance != null">#{beforeFrozenBalance},</if>
<if test="afterFrozenBalance != null">#{afterFrozenBalance},</if>
<if test="operatorId != null">#{operatorId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="remark != null">#{remark},</if>
'0',
</trim>
</insert>
</mapper>
@@ -0,0 +1,72 @@
<?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.bms.customer.customerinfo.mapper.CustomerSyncMapper">
<select id="selectExistingCodes" resultType="java.lang.String">
SELECT customer_code FROM ctr_customer WHERE del_flag = '0'
</select>
<!-- 字段集与 scripts/import_customers.py 的 MAP_COLUMNS 保持一致;
源行为空的字段不写,走数据库默认值 -->
<insert id="insertSyncCustomer" parameterType="com.bms.customer.customerinfo.domain.BmsCustomer">
INSERT INTO ctr_customer (
customer_code, customer_name, is_enable,
del_flag, create_by
<if test="customerCodeDw != null">, customer_code_dw</if>
<if test="customerType != null">, customer_type</if>
<if test="salesUserId != null">, sales_user_id</if>
<if test="salesUser != null">, sales_user</if>
<if test="settlementUser != null">, settlement_user</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="creditEd != null">, credit_ed</if>
<if test="remark != null">, remark</if>
<if test="createTime != null">, create_time</if>
) VALUES (
#{customerCode}, #{customerName}, #{isEnable},
'0', #{createBy}
<if test="customerCodeDw != null">, #{customerCodeDw}</if>
<if test="customerType != null">, #{customerType}</if>
<if test="salesUserId != null">, #{salesUserId}</if>
<if test="salesUser != null">, #{salesUser}</if>
<if test="settlementUser != null">, #{settlementUser}</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="creditEd != null">, #{creditEd}</if>
<if test="remark != null">, #{remark}</if>
<if test="createTime != null">, #{createTime}</if>
)
</insert>
<update id="updateSyncCustomerByCode" parameterType="com.bms.customer.customerinfo.domain.BmsCustomer">
UPDATE ctr_customer
SET is_enable = #{isEnable}
<if test="customerName != null">, customer_name = #{customerName}</if>
<if test="customerCodeDw != null">, customer_code_dw = #{customerCodeDw}</if>
<if test="customerType != null">, customer_type = #{customerType}</if>
<if test="salesUserId != null">, sales_user_id = #{salesUserId}</if>
<if test="salesUser != null">, sales_user = #{salesUser}</if>
<if test="settlementUser != null">, settlement_user = #{settlementUser}</if>
<if test="serviceUser != null">, service_user = #{serviceUser}</if>
<if test="settlementType != null">, settlement_type = #{settlementType}</if>
<if test="tempEd != null">, temp_ed = #{tempEd}</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="creditEd != null">, credit_ed = #{creditEd}</if>
<if test="remark != null">, remark = #{remark}</if>
, update_by = #{updateBy}
, update_time = #{updateTime}
WHERE customer_code = #{customerCode} AND del_flag = '0'
</update>
</mapper>
@@ -0,0 +1,17 @@
<?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.bms.customer.customerinfo.mapper.OracleCustomerSyncMapper">
<!-- 老系统客户主表全量读取;列集与 import_customers.py 的映射保持一致 -->
<select id="selectAllTabCustomer" resultType="java.util.HashMap" fetchSize="500">
SELECT CUSTOMER_CODE, CUSTOMER_NAME, CUSTOMER_OUTER_CODE,
BELONG_SALER, BELONG_SALER_NAME, SETTLEMENT_MAN, SERVICE_MAN,
REMARK, WEIGHT_LIMIT, CREDIT_LIMIT, TEMP_AMOUNT,
ACCOUNT_AMOUNT, EUR_AMOUNT,
CUSTOMER_TYPE, CUSTOMER_BALANCE_MODE, BL_OPEN,
CREATE_DATE, GMT_CREATE
FROM WEISHI_USER.TAB_CUSTOMER
</select>
</mapper>