|
|
@@ -75,14 +75,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
LEFT JOIN ymdf_basic_region parent_region
|
|
|
ON region.parent_id = parent_region.region_id
|
|
|
WHERE
|
|
|
- -- 複数選択条件(ブランド、業種、地域は複数の値ををサポート)
|
|
|
- s.brand_code IN ('010', '020') -- 複数選択ブランドコード
|
|
|
- AND s.business_type_code IN ('010', '020') -- 複数選択業種コード
|
|
|
- AND s.region_code IN ('KYUSHU_KAGOSHIMA', 'KINKI_KEIHAN', 'SHIKOKU') -- 複数選択地域コード
|
|
|
- -- 店舗名のあいまい検索(例:「東京」を含む店舗)
|
|
|
- AND s.store_name LIKE '%L%' -- 店舗名に「東京」を含む
|
|
|
- -- 基本フィルタ
|
|
|
- AND c.del_flag = 0 -- 削除済み顧客を除外
|
|
|
+ c.del_flag = 0 -- 削除済み顧客を除外
|
|
|
+
|
|
|
+ <if test="brandCodes != null and brandCodes != ''">
|
|
|
+ AND s.brand_code IN
|
|
|
+ <foreach collection="brandCodes" item="brandCode" open="(" separator="," close=")">
|
|
|
+ #{brandCode}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="businessTypeCodes != null and businessTypeCodes != ''">
|
|
|
+ AND s.business_type_code IN
|
|
|
+ <foreach collection="businessTypeCodes" item="businessTypeCode" open="(" separator="," close=")">
|
|
|
+ #{businessTypeCode}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="regionCodes != null and regionCodes != ''">
|
|
|
+ AND s.region_code IN
|
|
|
+ <foreach collection="regionCodes" item="regionCode" open="(" separator="," close=")">
|
|
|
+ #{regionCode}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="storeName != null and storeName != ''">
|
|
|
+ AND s.store_name LIKE CONCAT('%', #{storeName}, '%')
|
|
|
+ </if>
|
|
|
</select>
|
|
|
|
|
|
<select id="selectYmdfCustomerDmList" parameterType="YmdfSurvey" resultMap="YmdfCustomerResult">
|
|
|
@@ -141,15 +159,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
AND c.last_purchase_month >=
|
|
|
CAST(DATE_FORMAT(DATE_SUB(CURRENT_DATE(), INTERVAL 6 MONTH), '%Y%m') AS UNSIGNED)
|
|
|
-- -- 累計金額基準(例:10,000円以上)
|
|
|
- AND c.total_valid_spending >= 500
|
|
|
+ AND c.total_valid_spending >= #{minSpendingAmount}
|
|
|
-- ブランド複数選択
|
|
|
- AND s.brand_code IN ('010', '020')
|
|
|
- -- 業種複数選択
|
|
|
- AND s.business_type_code IN ('010', '020')
|
|
|
- -- 地域複数選択
|
|
|
- AND s.region_code IN ('KYUSHU_KAGOSHIMA', 'KINKI_KEIHAN', 'SHIKOKU')
|
|
|
- -- 店舗名あいまい検索
|
|
|
- AND s.store_name LIKE '%L%' -- 店舗名に「東京」を含む
|
|
|
+ <if test="brandCodes != null and brandCodes != ''">
|
|
|
+ AND s.brand_code IN
|
|
|
+ <foreach collection="brandCodes" item="brandCode" open="(" separator="," close=")">
|
|
|
+ #{brandCode}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="businessTypeCodes != null and businessTypeCodes != ''">
|
|
|
+ AND s.business_type_code IN
|
|
|
+ <foreach collection="businessTypeCodes" item="businessTypeCode" open="(" separator="," close=")">
|
|
|
+ #{businessTypeCode}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="regionCodes != null and regionCodes != ''">
|
|
|
+ AND s.region_code IN
|
|
|
+ <foreach collection="regionCodes" item="regionCode" open="(" separator="," close=")">
|
|
|
+ #{regionCode}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+
|
|
|
+ <if test="storeName != null and storeName != ''">
|
|
|
+ AND s.store_name LIKE CONCAT('%', #{storeName}, '%')
|
|
|
+ </if>
|
|
|
ORDER BY
|
|
|
c.total_valid_spending DESC,
|
|
|
c.last_purchase_month DESC
|