|
|
@@ -219,13 +219,38 @@ class PaymentMethodGateServiceTest {
|
|
|
assertTrue(options.stream().noneMatch(o -> "4".equals(o.getPayType())), "商家未勾选现金时不返回现金项");
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ void platformDisabledCashBlocksUserDiningCash() {
|
|
|
+ // 平台关现金:用户自取/堂食现金单被拒,即使商家勾选(或未设置)CASH
|
|
|
+ when(configMapper.selectList(any()))
|
|
|
+ .thenReturn(List.of(disabled("CASH", "MERCHANT")));
|
|
|
+ when(userMapper.selectById(7L)).thenReturn(merchant("COD,CASH"));
|
|
|
+ assertThrows(ServiceException.class, () ->
|
|
|
+ service.assertUsableForOrder("4", PaymentMethodGateService.GateScope.MERCHANT, 1L, 7L, 1L));
|
|
|
+ when(userMapper.selectById(7L)).thenReturn(merchant(null));
|
|
|
+ assertThrows(ServiceException.class, () ->
|
|
|
+ service.assertUsableForOrder("4", PaymentMethodGateService.GateScope.MERCHANT, 1L, 7L, 2L));
|
|
|
+ // 商家端设置页可用列表同样不再返回现金
|
|
|
+ List<PaymentMethodGateService.PayMethodOption> options =
|
|
|
+ service.listAvailable(PaymentMethodGateService.GateScope.MERCHANT, 1L, 7L, 1L);
|
|
|
+ assertTrue(options.stream().noneMatch(o -> "4".equals(o.getPayType())), "平台关现金后列表不返回现金项");
|
|
|
+ assertEquals(5, options.size());
|
|
|
+ // orderType 缺失(商家建单/闪送缺省现金)不受平台开关管控,保持现状放行
|
|
|
+ assertDoesNotThrow(() ->
|
|
|
+ service.assertUsableForOrder("4", PaymentMethodGateService.GateScope.MERCHANT, 1L, 7L, null));
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
void cashGroupOnlyInMerchantScopeDomains() {
|
|
|
- // 值域:商家勾选可选 CASH;平台开关矩阵与骑手闪送维度不含 CASH
|
|
|
+ // 值域:商家勾选与平台开关矩阵均可选 CASH;骑手闪送维度不含 CASH
|
|
|
assertTrue(PaymentMethodGateService.groupsOf(PaymentMethodGateService.GateScope.MERCHANT)
|
|
|
.contains(PaymentMethodGateService.GROUP_CASH));
|
|
|
assertTrue(!PaymentMethodGateService.groupsOf(PaymentMethodGateService.GateScope.RIDER_FLASH)
|
|
|
.contains(PaymentMethodGateService.GROUP_CASH));
|
|
|
+ assertTrue(PaymentMethodGateService.platformGroupsOf(PaymentMethodGateService.GateScope.MERCHANT)
|
|
|
+ .contains(PaymentMethodGateService.GROUP_CASH));
|
|
|
+ assertTrue(!PaymentMethodGateService.platformGroupsOf(PaymentMethodGateService.GateScope.RIDER_FLASH)
|
|
|
+ .contains(PaymentMethodGateService.GROUP_CASH));
|
|
|
assertTrue(!PaymentMethodGateService.allGroups().contains(PaymentMethodGateService.GROUP_CASH));
|
|
|
}
|
|
|
|