1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.talentcard.server.business.merchant;
 
import static org.assertj.core.api.Assertions.assertThat;
 
import org.junit.jupiter.api.Test;
 
/**
 * 个人(小微)主体上报给汇付的 MCC 怎么取。
 *
 * <p>业务口径(2026-09-16):**行业由系统动态匹配,商户改不了**。所以系统里的商家档案优先——
 * 经营类型是我们自己维护的,也是匹配微信行业类目与费率的依据,不该被进件表单上的一次选择盖掉;
 * 已进件商户也不提供补改行业的入口。商户在进件表单第一步选的「行业类型」只在档案给不出具体
 * 行业时兜底(未配、或配成「其它」未识别),避免档案缺数据时一律落「其它」。
 *
 * <p>「其它」与识别不出来的取值返回空串(见 {@link #anUnrecognisedIndustryFallsBackToTheMerchantProfile}),
 * 正是这个兜底生效的触发条件。
 */
class MerchantOnboardingIndustryMccTests {
 
    /** 系统档案能给出具体行业时,以档案为准——哪怕进件表单上选的是别的行业。 */
    @Test
    void theMerchantProfileWinsOverWhatWasPickedOnTheForm() {
        assertThat(MerchantSettlementService.preferConfiguredMcc("7011", "餐饮服务")).isEqualTo("7011");
        assertThat(MerchantSettlementService.preferConfiguredMcc("5812", "其它")).isEqualTo("5812");
    }
 
    /** 档案给不出具体行业(落兜底的「其它」)时,才用进件表单上申报的行业。 */
    @Test
    void theDeclaredIndustryIsOnlyAFallbackForAMissingProfileIndustry() {
        assertThat(MerchantSettlementService.preferConfiguredMcc("7399", "餐饮服务")).isEqualTo("5812");
        assertThat(MerchantSettlementService.preferConfiguredMcc("7399", "停车服务")).isEqualTo("7523");
        // 两边都给不出具体行业时保持兜底值,不会变成空串。
        assertThat(MerchantSettlementService.preferConfiguredMcc("7399", "其它")).isEqualTo("7399");
        assertThat(MerchantSettlementService.preferConfiguredMcc("7399", "")).isEqualTo("7399");
    }
 
    @Test
    void theIndustryPickedOnTheFormBecomesTheMcc() {
        assertThat(MerchantSettlementService.mccForIndustry("餐饮服务")).isEqualTo("5812");
        assertThat(MerchantSettlementService.mccForIndustry("酒店服务")).isEqualTo("7011");
        assertThat(MerchantSettlementService.mccForIndustry("景区服务")).isEqualTo("7991");
        assertThat(MerchantSettlementService.mccForIndustry("加油服务")).isEqualTo("5541");
        assertThat(MerchantSettlementService.mccForIndustry("停车服务")).isEqualTo("7523");
    }
 
    /** 别名与规范化代码同样认,商户端换过文案不影响映射。 */
    @Test
    void theIndustryIsResolvedThroughTheSharedCatalog() {
        assertThat(MerchantSettlementService.mccForIndustry("餐饮")).isEqualTo("5812");
        assertThat(MerchantSettlementService.mccForIndustry("food")).isEqualTo("5812");
        assertThat(MerchantSettlementService.mccForIndustry("餐饮商家")).isEqualTo("5812");
        assertThat(MerchantSettlementService.mccForIndustry(" theatre ")).isEqualTo("7832");
    }
 
    @Test
    void anUnrecognisedIndustryFallsBackToTheMerchantProfile() {
        assertThat(MerchantSettlementService.mccForIndustry("其它")).isEmpty();
        assertThat(MerchantSettlementService.mccForIndustry("街边小店")).isEmpty();
        assertThat(MerchantSettlementService.mccForIndustry("")).isEmpty();
        assertThat(MerchantSettlementService.mccForIndustry(null)).isEmpty();
    }
}