86 lines
4.7 KiB
XML
86 lines
4.7 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<!DOCTYPE mapper
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.bms.customer.customerinfo.mapper.CustomerSyncMapper">
|
|
|
|
<select id="selectExistingCodes" resultType="java.lang.String">
|
|
SELECT customer_code FROM ctr_customer WHERE del_flag = '0'
|
|
</select>
|
|
|
|
<!-- 工号->用户ID 候选;Java 层检测重复工号,不任意取一条。 -->
|
|
<select id="selectUserLoginMap" resultType="com.bms.common.core.domain.entity.SysUser">
|
|
SELECT user_id AS userId, user_name AS userName
|
|
FROM sys_user
|
|
WHERE del_flag = '0'
|
|
</select>
|
|
|
|
<select id="selectExistingSalesAssignments" resultType="com.bms.customer.customerinfo.domain.BmsCustomer">
|
|
SELECT customer_code AS customerCode,
|
|
sales_user_id AS salesUserId,
|
|
source_sales_code AS sourceSalesCode
|
|
FROM ctr_customer
|
|
WHERE del_flag = '0'
|
|
</select>
|
|
|
|
<!-- 普通客户资料沿用源空值不覆盖;业务员ID和源工号始终按本次匹配结果写入,允许明确清空。 -->
|
|
<insert id="insertSyncCustomer" parameterType="com.bms.customer.customerinfo.domain.BmsCustomer">
|
|
INSERT INTO ctr_customer (
|
|
customer_code, customer_name, is_enable,
|
|
del_flag, create_by, sales_user_id, source_sales_code
|
|
<if test="customerCodeDw != null">, customer_code_dw</if>
|
|
<if test="customerType != null">, customer_type</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}, #{salesUserId}, #{sourceSalesCode}
|
|
<if test="customerCodeDw != null">, #{customerCodeDw}</if>
|
|
<if test="customerType != null">, #{customerType}</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>
|
|
, sales_user_id = #{salesUserId}
|
|
, source_sales_code = #{sourceSalesCode}
|
|
<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>
|