From 0732b6b4846ac8054a63e5573346766afca30ed3 Mon Sep 17 00:00:00 2001 From: hy001 Date: Fri, 10 Jul 2026 20:03:32 +0800 Subject: [PATCH] data(pay): configure Yumi TR V5Pay products --- sql/20260710_yumi_tr_v5pay_products.sql | 179 ++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 sql/20260710_yumi_tr_v5pay_products.sql diff --git a/sql/20260710_yumi_tr_v5pay_products.sql b/sql/20260710_yumi_tr_v5pay_products.sql new file mode 100644 index 00000000..4e638adb --- /dev/null +++ b/sql/20260710_yumi_tr_v5pay_products.sql @@ -0,0 +1,179 @@ +-- Make the new TR/TUR country record self-contained for Yumi V5Pay. +-- Historical Turkey data is split across T2/TU2 pay-country rows: one row owns the +-- active GOLD product while other rows own disabled MiFaPay channels. Copying only +-- a country alias therefore leaves the H5 resolver without a usable product snapshot. + +START TRANSACTION; + +SET @application_id := 2048200000000000701; +SET @legacy_product_pay_country_id := 2049740323986403343; +SET @target_country_id := ( + SELECT `id` + FROM `sys_country_code` + WHERE UPPER(`alpha_two`) = 'TR' AND UPPER(`alpha_three`) = 'TUR' + LIMIT 1 +); + +-- Reuse an existing direct TR/TRY payment-country row when operations created one +-- concurrently; otherwise use the reserved Snowflake id below. This keeps the script idempotent. +SET @target_pay_country_id := ( + SELECT `id` + FROM `sys_pay_country` + WHERE `country_id` = @target_country_id AND UPPER(`currency`) = 'TRY' + ORDER BY `is_shelf` DESC, `sort` DESC, `id` ASC + LIMIT 1 +); +SET @target_pay_country_id := IFNULL(@target_pay_country_id, 2075550766742757376); + +INSERT INTO `sys_pay_country` + (`id`, `country_id`, `currency`, `usd_exchange_rate`, `sort`, `is_shelf`, + `create_time`, `update_time`, `create_user`, `update_user`) +SELECT + @target_pay_country_id, @target_country_id, 'TRY', `usd_exchange_rate`, 165, 1, + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, NULL +FROM `sys_pay_country` +WHERE `id` = @legacy_product_pay_country_id +ON DUPLICATE KEY UPDATE + `country_id` = VALUES(`country_id`), + `currency` = VALUES(`currency`), + `usd_exchange_rate` = VALUES(`usd_exchange_rate`), + `sort` = VALUES(`sort`), + `is_shelf` = VALUES(`is_shelf`), + `update_time` = CURRENT_TIMESTAMP; + +-- The resolver considers a payment country usable only when at least one active channel +-- detail exists. Register the four V5Pay productTypes exposed by the TR merchant profile; +-- order creation can then use these persisted snapshots instead of falling back to an alias. +SET @gpay_channel_id := IFNULL(( + SELECT `id` FROM `sys_pay_country_channel` + WHERE `pay_country_id` = @target_pay_country_id AND `channel_code` = 'GPAY' LIMIT 1 +), 2075550766742757377); +SET @bkm_channel_id := IFNULL(( + SELECT `id` FROM `sys_pay_country_channel` + WHERE `pay_country_id` = @target_pay_country_id AND `channel_code` = 'BKM_EXPRESS' LIMIT 1 +), 2075550766742757378); +SET @bank_channel_id := IFNULL(( + SELECT `id` FROM `sys_pay_country_channel` + WHERE `pay_country_id` = @target_pay_country_id AND `channel_code` = 'BANK_TRANSFER' LIMIT 1 +), 2075550766742757379); +SET @card_channel_id := IFNULL(( + SELECT `id` FROM `sys_pay_country_channel` + WHERE `pay_country_id` = @target_pay_country_id AND `channel_code` = 'CREDIT_CARD' LIMIT 1 +), 2075550766742757380); + +INSERT INTO `sys_pay_country_channel` + (`id`, `pay_country_id`, `channel_code`, `is_shelf`, + `create_time`, `update_time`, `create_user`, `update_user`) +VALUES + (@gpay_channel_id, @target_pay_country_id, 'GPAY', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, NULL), + (@bkm_channel_id, @target_pay_country_id, 'BKM_EXPRESS', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, NULL), + (@bank_channel_id, @target_pay_country_id, 'BANK_TRANSFER', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, NULL), + (@card_channel_id, @target_pay_country_id, 'CREDIT_CARD', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, NULL) +ON DUPLICATE KEY UPDATE + `pay_country_id` = VALUES(`pay_country_id`), + `channel_code` = VALUES(`channel_code`), + `is_shelf` = VALUES(`is_shelf`), + `update_time` = CURRENT_TIMESTAMP; + +SET @gpay_detail_id := IFNULL(( + SELECT `id` FROM `sys_pay_country_channel_details` + WHERE `pay_country_id` = @target_pay_country_id AND `factory_code` = 'V5_PAY' + AND `factory_channel` = 'GPAY' LIMIT 1 +), 2075550766742757381); +SET @bkm_detail_id := IFNULL(( + SELECT `id` FROM `sys_pay_country_channel_details` + WHERE `pay_country_id` = @target_pay_country_id AND `factory_code` = 'V5_PAY' + AND `factory_channel` = 'BKM_EXPRESS' LIMIT 1 +), 2075550766742757382); +SET @bank_detail_id := IFNULL(( + SELECT `id` FROM `sys_pay_country_channel_details` + WHERE `pay_country_id` = @target_pay_country_id AND `factory_code` = 'V5_PAY' + AND `factory_channel` = 'BANK_TRANSFER' LIMIT 1 +), 2075550766742757383); +SET @card_detail_id := IFNULL(( + SELECT `id` FROM `sys_pay_country_channel_details` + WHERE `pay_country_id` = @target_pay_country_id AND `factory_code` = 'V5_PAY' + AND `factory_channel` = 'CREDIT_CARD' LIMIT 1 +), 2075550766742757384); + +INSERT INTO `sys_pay_country_channel_details` + (`id`, `pay_country_id`, `country_channel_id`, `channel_code`, `factory_code`, + `factory_min_limit`, `factory_max_limit`, `factory_daily_limit`, `suggest_score`, + `factory_channel`, `factory_currency_point`, `is_shelf`, + `create_time`, `update_time`, `create_user`, `update_user`) +VALUES + (@gpay_detail_id, @target_pay_country_id, @gpay_channel_id, 'GPAY', 'V5_PAY', + 0.01, 99999999.00, 99999999.00, 100, 'GPAY', 2, 1, + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, NULL), + (@bkm_detail_id, @target_pay_country_id, @bkm_channel_id, 'BKM_EXPRESS', 'V5_PAY', + 0.01, 99999999.00, 99999999.00, 90, 'BKM_EXPRESS', 2, 1, + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, NULL), + (@bank_detail_id, @target_pay_country_id, @bank_channel_id, 'BANK_TRANSFER', 'V5_PAY', + 0.01, 99999999.00, 99999999.00, 80, 'BANK_TRANSFER', 2, 1, + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, NULL), + (@card_detail_id, @target_pay_country_id, @card_channel_id, 'CREDIT_CARD', 'V5_PAY', + 0.01, 99999999.00, 99999999.00, 70, 'CREDIT_CARD', 2, 1, + CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, NULL) +ON DUPLICATE KEY UPDATE + `pay_country_id` = VALUES(`pay_country_id`), + `country_channel_id` = VALUES(`country_channel_id`), + `channel_code` = VALUES(`channel_code`), + `factory_code` = VALUES(`factory_code`), + `factory_min_limit` = VALUES(`factory_min_limit`), + `factory_max_limit` = VALUES(`factory_max_limit`), + `factory_daily_limit` = VALUES(`factory_daily_limit`), + `suggest_score` = VALUES(`suggest_score`), + `factory_channel` = VALUES(`factory_channel`), + `factory_currency_point` = VALUES(`factory_currency_point`), + `is_shelf` = VALUES(`is_shelf`), + `update_time` = CURRENT_TIMESTAMP; + +-- Clone the exact active Yumi GOLD tier from the historical Turkey product record. +SET @target_product_id := IFNULL(( + SELECT target.`id` + FROM `sys_pay_application_commodity` target + JOIN `sys_pay_application_commodity` source + ON source.`id` = 2075541026046537730 + AND target.`application_id` = source.`application_id` + AND target.`pay_country_id` = @target_pay_country_id + AND target.`type` = source.`type` + AND target.`amount_usd` = source.`amount_usd` + AND target.`content` = source.`content` + AND IFNULL(target.`award_content`, '') = IFNULL(source.`award_content`, '') + LIMIT 1 +), 2075550766742757385); + +INSERT INTO `sys_pay_application_commodity` + (`id`, `region_id`, `application_id`, `pay_country_id`, `type`, `content`, + `award_content`, `amount_usd`, `is_shelf`, + `create_time`, `update_time`, `create_user`, `update_user`) +SELECT + @target_product_id, `region_id`, `application_id`, @target_pay_country_id, `type`, `content`, + `award_content`, `amount_usd`, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, NULL, NULL +FROM `sys_pay_application_commodity` +WHERE `id` = 2075541026046537730 AND `application_id` = @application_id +ON DUPLICATE KEY UPDATE + `region_id` = VALUES(`region_id`), + `application_id` = VALUES(`application_id`), + `pay_country_id` = VALUES(`pay_country_id`), + `type` = VALUES(`type`), + `content` = VALUES(`content`), + `award_content` = VALUES(`award_content`), + `amount_usd` = VALUES(`amount_usd`), + `is_shelf` = VALUES(`is_shelf`), + `update_time` = CURRENT_TIMESTAMP; + +COMMIT; + +SELECT + country.`alpha_two`, country.`alpha_three`, pay_country.`id` AS `pay_country_id`, + pay_country.`currency`, pay_country.`usd_exchange_rate`, pay_country.`is_shelf`, + (SELECT COUNT(*) FROM `sys_pay_country_channel_details` details + WHERE details.`pay_country_id` = pay_country.`id` + AND details.`factory_code` = 'V5_PAY' AND details.`is_shelf` = 1) AS `v5pay_methods`, + (SELECT COUNT(*) FROM `sys_pay_application_commodity` commodity + WHERE commodity.`pay_country_id` = pay_country.`id` + AND commodity.`application_id` = @application_id AND commodity.`is_shelf` = 1) AS `products` +FROM `sys_pay_country` pay_country +JOIN `sys_country_code` country ON country.`id` = pay_country.`country_id` +WHERE pay_country.`id` = @target_pay_country_id;