Files
BMS/bms-back/bms-system/src/main/resources/mapper/price/CustomerCodeResolveMapper.xml
T
2026-10-20 16:20:57 +08:00

35 lines
1.4 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.price.mapper.CustomerCodeResolveMapper">
<!--
Resolve customer keywords to codes for Oracle TAB_ORDER.CUSTOMER_CODE IN (...).
Match: customer_code / customer_name / customer_code_dw (对外代码).
Return both internal code and outer code so either form on TAB_ORDER hits.
-->
<select id="selectCustomerCodesByKeywords" resultType="java.lang.String">
SELECT DISTINCT code FROM (
SELECT customer_code AS code
FROM ctr_customer
WHERE customer_code IS NOT NULL AND customer_code &lt;&gt; ''
AND (
<foreach collection="keywords" item="kw" separator=" OR ">
customer_code = #{kw} OR customer_name = #{kw} OR customer_code_dw = #{kw}
</foreach>
)
UNION ALL
SELECT customer_code_dw AS code
FROM ctr_customer
WHERE customer_code_dw IS NOT NULL AND customer_code_dw &lt;&gt; ''
AND (
<foreach collection="keywords" item="kw" separator=" OR ">
customer_code = #{kw} OR customer_name = #{kw} OR customer_code_dw = #{kw}
</foreach>
)
) t
</select>
</mapper>