本地设置
This commit is contained in:
parent
41305adb9d
commit
0ace2cc68f
@ -35,6 +35,18 @@ public class LocalDefaultRequestHeaderFilter extends OncePerRequestFilter {
|
||||
Map.entry(RequestHeaderConstant.REQ_LANG, "zh-CN"),
|
||||
Map.entry(RequestHeaderConstant.REQ_ZONE, "Asia/Shanghai")
|
||||
);
|
||||
private static final Set<String> SUPPRESSED_HEADERS = Set.of(
|
||||
"connection",
|
||||
"content-length",
|
||||
"host",
|
||||
"keep-alive",
|
||||
"proxy-authenticate",
|
||||
"proxy-authorization",
|
||||
"te",
|
||||
"trailer",
|
||||
"transfer-encoding",
|
||||
"upgrade"
|
||||
);
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
|
||||
@ -45,13 +57,24 @@ public class LocalDefaultRequestHeaderFilter extends OncePerRequestFilter {
|
||||
missingHeaders.put(header.getKey(), header.getValue());
|
||||
}
|
||||
}
|
||||
if (missingHeaders.isEmpty()) {
|
||||
boolean hasSuppressedHeader = hasSuppressedHeader(request);
|
||||
if (missingHeaders.isEmpty() && !hasSuppressedHeader) {
|
||||
filterChain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
filterChain.doFilter(new LocalHeaderRequestWrapper(request, missingHeaders), response);
|
||||
}
|
||||
|
||||
private boolean hasSuppressedHeader(HttpServletRequest request) {
|
||||
Enumeration<String> headerNames = request.getHeaderNames();
|
||||
while (headerNames.hasMoreElements()) {
|
||||
if (SUPPRESSED_HEADERS.contains(headerNames.nextElement().toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final class LocalHeaderRequestWrapper extends HttpServletRequestWrapper {
|
||||
|
||||
private final Map<String, String> headers;
|
||||
@ -63,12 +86,18 @@ public class LocalDefaultRequestHeaderFilter extends OncePerRequestFilter {
|
||||
|
||||
@Override
|
||||
public String getHeader(String name) {
|
||||
if (isSuppressedHeader(name)) {
|
||||
return null;
|
||||
}
|
||||
String header = headers.get(name);
|
||||
return header != null ? header : super.getHeader(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getHeaders(String name) {
|
||||
if (isSuppressedHeader(name)) {
|
||||
return Collections.emptyEnumeration();
|
||||
}
|
||||
String header = headers.get(name);
|
||||
if (header != null) {
|
||||
return Collections.enumeration(List.of(header));
|
||||
@ -81,10 +110,17 @@ public class LocalDefaultRequestHeaderFilter extends OncePerRequestFilter {
|
||||
Set<String> headerNames = new LinkedHashSet<>();
|
||||
Enumeration<String> originalHeaderNames = super.getHeaderNames();
|
||||
while (originalHeaderNames.hasMoreElements()) {
|
||||
headerNames.add(originalHeaderNames.nextElement());
|
||||
String headerName = originalHeaderNames.nextElement();
|
||||
if (!isSuppressedHeader(headerName)) {
|
||||
headerNames.add(headerName);
|
||||
}
|
||||
}
|
||||
headerNames.addAll(headers.keySet());
|
||||
return Collections.enumeration(headerNames);
|
||||
}
|
||||
|
||||
private static boolean isSuppressedHeader(String name) {
|
||||
return name != null && SUPPRESSED_HEADERS.contains(name.toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,11 @@ VALUES
|
||||
('PK', 'PKR', 'Ewallet_Easypaisa', 'Easypaisa', 5.5000, 0.0000, '', 170),
|
||||
('PK', 'PKR', 'Ewallet_JazzCash', 'JazzCash', 5.5000, 0.0000, '', 180),
|
||||
('VN', 'VND', 'QR_VietQR', 'VietQR', 4.5000, 0.0000, '', 190),
|
||||
('VN', 'VND', 'BankTransfer_VN_BankTransfer', 'VN_BankTransfer', 4.5000, 0.0000, '', 200);
|
||||
('VN', 'VND', 'BankTransfer_VN_BankTransfer', 'VN_BankTransfer', 4.5000, 0.0000, '', 200),
|
||||
('PH', 'PHP', 'Ewallet_Gcash', 'Gcash', 0.0000, 0.0000, '', 50),
|
||||
('PH', 'PHP', 'Ewallet_PayMaya', 'PayMaya', 0.0000, 0.0000, '', 100),
|
||||
('PH', 'PHP', 'QR_QRPH', 'QRPH', 0.0000, 0.0000, '', 1),
|
||||
('BD', 'BDT', 'Ewallet_bKash', 'bKash', 0.0000, 0.0000, '', 50);
|
||||
|
||||
-- Hide unsupported MiFaPay country/channel combinations.
|
||||
UPDATE `sys_pay_country_channel_details` d
|
||||
|
||||
140
sql/20260512_mifapay_ph_bd_supported_channels.sql
Normal file
140
sql/20260512_mifapay_ph_bd_supported_channels.sql
Normal file
@ -0,0 +1,140 @@
|
||||
-- Enable newly configured MiFaPay methods for LIKEI.
|
||||
-- Requires the base channel rows from 20260430_mifapay_full_payment_country_channels.sql.
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
SET @factory_code := 'MIFA_PAY';
|
||||
SET @sys_origin := 'LIKEI';
|
||||
SET @region_relation_group := 'OPEN_PAY_COUNTRY';
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS `tmp_mifapay_new_supported_channel`;
|
||||
CREATE TEMPORARY TABLE `tmp_mifapay_new_supported_channel` (
|
||||
`country_code` VARCHAR(2) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
|
||||
`currency` VARCHAR(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
||||
`channel_code` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
||||
`factory_channel` VARCHAR(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
||||
`suggest_score` INT NOT NULL,
|
||||
PRIMARY KEY (`country_code`, `currency`, `channel_code`, `factory_channel`)
|
||||
) ENGINE=Memory;
|
||||
|
||||
INSERT INTO `tmp_mifapay_new_supported_channel`
|
||||
(`country_code`, `currency`, `channel_code`, `factory_channel`, `suggest_score`)
|
||||
VALUES
|
||||
('PH', 'PHP', 'Ewallet_Gcash', 'Gcash', 95),
|
||||
('PH', 'PHP', 'Ewallet_PayMaya', 'PayMaya', 90),
|
||||
('PH', 'PHP', 'QR_QRPH', 'QRPH', 100),
|
||||
('BD', 'BDT', 'Ewallet_bKash', 'bKash', 95);
|
||||
|
||||
-- Enable the specific MiFaPay country/channel details.
|
||||
UPDATE `sys_pay_country_channel_details` d
|
||||
JOIN `sys_pay_country` pc ON pc.`id` = d.`pay_country_id`
|
||||
JOIN `sys_country_code` cc ON cc.`id` = pc.`country_id`
|
||||
JOIN `tmp_mifapay_new_supported_channel` s
|
||||
ON s.`country_code` = cc.`alpha_two`
|
||||
AND s.`currency` = pc.`currency`
|
||||
AND s.`channel_code` = d.`channel_code`
|
||||
AND s.`factory_channel` = d.`factory_channel`
|
||||
SET d.`is_shelf` = 1,
|
||||
d.`factory_min_limit` = 0.01,
|
||||
d.`factory_max_limit` = 99999999.00,
|
||||
d.`factory_daily_limit` = 99999999.00,
|
||||
d.`suggest_score` = s.`suggest_score`,
|
||||
d.`update_time` = CURRENT_TIMESTAMP
|
||||
WHERE d.`factory_code` = @factory_code;
|
||||
|
||||
-- Enable country/channel rows that now have at least one supported MiFaPay detail.
|
||||
UPDATE `sys_pay_country_channel` cch
|
||||
JOIN `sys_pay_country` pc ON pc.`id` = cch.`pay_country_id`
|
||||
JOIN `sys_country_code` cc ON cc.`id` = pc.`country_id`
|
||||
JOIN `tmp_mifapay_new_supported_channel` s
|
||||
ON s.`country_code` = cc.`alpha_two`
|
||||
AND s.`currency` = pc.`currency`
|
||||
AND s.`channel_code` = cch.`channel_code`
|
||||
SET cch.`is_shelf` = 1,
|
||||
cch.`update_time` = CURRENT_TIMESTAMP
|
||||
WHERE EXISTS (
|
||||
SELECT 1
|
||||
FROM `sys_pay_country_channel_details` d
|
||||
WHERE d.`pay_country_id` = cch.`pay_country_id`
|
||||
AND d.`channel_code` = cch.`channel_code`
|
||||
AND d.`factory_code` = @factory_code
|
||||
AND d.`factory_channel` = s.`factory_channel`
|
||||
AND d.`is_shelf` = 1
|
||||
);
|
||||
|
||||
-- Expose the related pay countries and LIKEI V2 region relations.
|
||||
UPDATE `sys_pay_country` pc
|
||||
JOIN `sys_country_code` cc ON cc.`id` = pc.`country_id`
|
||||
JOIN (SELECT DISTINCT `country_code`, `currency` FROM `tmp_mifapay_new_supported_channel`) s
|
||||
ON s.`country_code` = cc.`alpha_two`
|
||||
AND s.`currency` = pc.`currency`
|
||||
SET pc.`is_shelf` = 1,
|
||||
pc.`update_time` = CURRENT_TIMESTAMP
|
||||
WHERE EXISTS (
|
||||
SELECT 1
|
||||
FROM `sys_pay_country_channel_details` d
|
||||
WHERE d.`pay_country_id` = pc.`id`
|
||||
AND d.`factory_code` = @factory_code
|
||||
AND d.`is_shelf` = 1
|
||||
);
|
||||
|
||||
UPDATE `sys_region_relation` rr
|
||||
JOIN `sys_pay_country` pc ON pc.`id` = rr.`relation_id`
|
||||
JOIN `sys_country_code` cc ON cc.`id` = pc.`country_id`
|
||||
JOIN (SELECT DISTINCT `country_code`, `currency` FROM `tmp_mifapay_new_supported_channel`) s
|
||||
ON s.`country_code` = cc.`alpha_two`
|
||||
AND s.`currency` = pc.`currency`
|
||||
SET rr.`is_showcase` = 1,
|
||||
rr.`update_time` = CURRENT_TIMESTAMP
|
||||
WHERE rr.`sys_origin` = @sys_origin
|
||||
AND rr.`group_type` = @region_relation_group
|
||||
AND pc.`is_shelf` = 1;
|
||||
|
||||
COMMIT;
|
||||
|
||||
-- Verification queries. Expected: 4, 0, 2, 2.
|
||||
SELECT 'enabled_new_mifapay_details' AS `metric`, COUNT(*) AS `value`
|
||||
FROM `sys_pay_country_channel_details` d
|
||||
JOIN `sys_pay_country` pc ON pc.`id` = d.`pay_country_id`
|
||||
JOIN `sys_country_code` cc ON cc.`id` = pc.`country_id`
|
||||
JOIN `tmp_mifapay_new_supported_channel` s
|
||||
ON s.`country_code` = cc.`alpha_two`
|
||||
AND s.`currency` = pc.`currency`
|
||||
AND s.`channel_code` = d.`channel_code`
|
||||
AND s.`factory_channel` = d.`factory_channel`
|
||||
WHERE d.`factory_code` = @factory_code
|
||||
AND d.`is_shelf` = 1;
|
||||
|
||||
SELECT 'missing_new_mifapay_details' AS `metric`, COUNT(*) AS `value`
|
||||
FROM `tmp_mifapay_new_supported_channel` s
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM `sys_pay_country_channel_details` d
|
||||
JOIN `sys_pay_country` pc ON pc.`id` = d.`pay_country_id`
|
||||
JOIN `sys_country_code` cc ON cc.`id` = pc.`country_id`
|
||||
WHERE cc.`alpha_two` = s.`country_code`
|
||||
AND pc.`currency` = s.`currency`
|
||||
AND d.`channel_code` = s.`channel_code`
|
||||
AND d.`factory_code` = @factory_code
|
||||
AND d.`factory_channel` = s.`factory_channel`
|
||||
AND d.`is_shelf` = 1
|
||||
);
|
||||
|
||||
SELECT 'enabled_new_mifapay_countries' AS `metric`, COUNT(DISTINCT pc.`id`) AS `value`
|
||||
FROM `sys_pay_country` pc
|
||||
JOIN `sys_country_code` cc ON cc.`id` = pc.`country_id`
|
||||
JOIN (SELECT DISTINCT `country_code`, `currency` FROM `tmp_mifapay_new_supported_channel`) s
|
||||
ON s.`country_code` = cc.`alpha_two`
|
||||
AND s.`currency` = pc.`currency`
|
||||
WHERE pc.`is_shelf` = 1;
|
||||
|
||||
SELECT 'enabled_new_mifapay_region_relations' AS `metric`, COUNT(DISTINCT rr.`id`) AS `value`
|
||||
FROM `sys_region_relation` rr
|
||||
JOIN `sys_pay_country` pc ON pc.`id` = rr.`relation_id`
|
||||
JOIN `sys_country_code` cc ON cc.`id` = pc.`country_id`
|
||||
JOIN (SELECT DISTINCT `country_code`, `currency` FROM `tmp_mifapay_new_supported_channel`) s
|
||||
ON s.`country_code` = cc.`alpha_two`
|
||||
AND s.`currency` = pc.`currency`
|
||||
WHERE rr.`sys_origin` = @sys_origin
|
||||
AND rr.`group_type` = @region_relation_group
|
||||
AND rr.`is_showcase` = 1;
|
||||
Loading…
x
Reference in New Issue
Block a user