|
|
@@ -83,7 +83,7 @@ class AlipayBatchPayServiceTest {
|
|
|
resp.setOutBizNo("A1");
|
|
|
when(alipayClient.certificateExecute(any(AlipayFundAuthorizeUniApplyRequest.class))).thenReturn(resp);
|
|
|
|
|
|
- Map<String, String> result = service.authorizeApply("E100", "2088123412341234");
|
|
|
+ Map<String, String> result = service.authorizeApply("E100");
|
|
|
|
|
|
assertEquals("https://ur.alipay.com/abc", result.get("authorize_link"));
|
|
|
assertEquals("AUTHING", result.get("status"));
|
|
|
@@ -95,7 +95,8 @@ class AlipayBatchPayServiceTest {
|
|
|
assertEquals("STANDARD_CREATE_FUND_ORDER", m.getBizScene());
|
|
|
assertEquals("SHORT_URL", m.getAuthorizeLinkType());
|
|
|
assertEquals("pc", m.getChannel());
|
|
|
- assertEquals("2088123412341234", m.getPrincipalInfo().getParticipantId());
|
|
|
+ // Ruling 19/22: 付款方恒为企业自身 UID(enterprise_id),不接受客户端指定
|
|
|
+ assertEquals("E100", m.getPrincipalInfo().getParticipantId());
|
|
|
|
|
|
ArgumentCaptor<BatchAuthorizeEntity> ent = ArgumentCaptor.forClass(BatchAuthorizeEntity.class);
|
|
|
verify(batchAuthorizeMapper).insert(ent.capture());
|
|
|
@@ -108,7 +109,7 @@ class AlipayBatchPayServiceTest {
|
|
|
when(alipayClient.certificateExecute(any(AlipayFundAuthorizeUniApplyRequest.class)))
|
|
|
.thenThrow(new AlipayApiException("network error"));
|
|
|
|
|
|
- assertThrows(BusinessException.class, () -> service.authorizeApply("E100", "2088123412341234"));
|
|
|
+ assertThrows(BusinessException.class, () -> service.authorizeApply("E100"));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@@ -132,7 +133,7 @@ class AlipayBatchPayServiceTest {
|
|
|
existing.setStatus("AUTHED");
|
|
|
when(batchAuthorizeMapper.selectOne(any())).thenReturn(existing);
|
|
|
|
|
|
- assertThrows(BusinessException.class, () -> service.authorizeApply("E100", "2088123412341234"));
|
|
|
+ assertThrows(BusinessException.class, () -> service.authorizeApply("E100"));
|
|
|
|
|
|
verify(alipayClient, never()).certificateExecute(any(AlipayFundAuthorizeUniApplyRequest.class));
|
|
|
verify(batchAuthorizeMapper, never()).insert(any());
|
|
|
@@ -143,7 +144,7 @@ class AlipayBatchPayServiceTest {
|
|
|
AlipayFundAuthorizeUniApplyResponse resp = new AlipayFundAuthorizeUniApplyResponse();
|
|
|
when(alipayClient.certificateExecute(any(AlipayFundAuthorizeUniApplyRequest.class))).thenReturn(resp);
|
|
|
|
|
|
- Map<String, String> result = service.authorizeApply("E100", "2088123412341234");
|
|
|
+ Map<String, String> result = service.authorizeApply("E100");
|
|
|
|
|
|
assertEquals("", result.get("authorize_link"));
|
|
|
assertEquals("AUTHING", result.get("status"));
|
|
|
@@ -177,7 +178,6 @@ class AlipayBatchPayServiceTest {
|
|
|
dto.setEnterpriseId("E100");
|
|
|
dto.setOutBatchNo("B1");
|
|
|
dto.setOrderTitle("202608报销");
|
|
|
- dto.setPayerUid("2088PAYER");
|
|
|
dto.setAgreementNo("AGMT001");
|
|
|
dto.setTransferSceneName("佣金报酬");
|
|
|
dto.setTransferSceneReportInfos(List.of(Map.of("info_type", "佣金报酬说明", "info_content", "8月家政服务报酬")));
|
|
|
@@ -209,7 +209,6 @@ class AlipayBatchPayServiceTest {
|
|
|
void batchCreate_detailAmountBelow1_throws() {
|
|
|
BatchCreateDTO dto = new BatchCreateDTO();
|
|
|
dto.setOrderTitle("t");
|
|
|
- dto.setPayerUid("2088PAYER");
|
|
|
BatchCreateDTO.BatchDetailDTO detail = new BatchCreateDTO.BatchDetailDTO();
|
|
|
detail.setOutBizNo("D1");
|
|
|
detail.setAmount(new BigDecimal("0.5"));
|
|
|
@@ -230,7 +229,6 @@ class AlipayBatchPayServiceTest {
|
|
|
when(batchOrderMapper.selectOne(any())).thenReturn(existing);
|
|
|
BatchCreateDTO dto = new BatchCreateDTO();
|
|
|
dto.setOrderTitle("t");
|
|
|
- dto.setPayerUid("2088PAYER");
|
|
|
dto.setOutBatchNo("B1");
|
|
|
BatchCreateDTO.BatchDetailDTO detail = new BatchCreateDTO.BatchDetailDTO();
|
|
|
detail.setOutBizNo("D1");
|
|
|
@@ -262,7 +260,6 @@ class AlipayBatchPayServiceTest {
|
|
|
dto.setEnterpriseId("E100");
|
|
|
dto.setOutBatchNo("B1");
|
|
|
dto.setOrderTitle("t");
|
|
|
- dto.setPayerUid("2088PAYER");
|
|
|
BatchCreateDTO.BatchDetailDTO detail = new BatchCreateDTO.BatchDetailDTO();
|
|
|
detail.setOutBizNo("D1");
|
|
|
detail.setAmount(new BigDecimal("10"));
|
|
|
@@ -286,7 +283,6 @@ class AlipayBatchPayServiceTest {
|
|
|
dto.setEnterpriseId("E100");
|
|
|
dto.setOutBatchNo("B1");
|
|
|
dto.setOrderTitle("t");
|
|
|
- dto.setPayerUid("2088PAYER");
|
|
|
BatchCreateDTO.BatchDetailDTO d1 = new BatchCreateDTO.BatchDetailDTO();
|
|
|
d1.setOutBizNo("D1");
|
|
|
d1.setAmount(new BigDecimal("10"));
|
|
|
@@ -412,7 +408,6 @@ class AlipayBatchPayServiceTest {
|
|
|
dto.setEnterpriseId("E100");
|
|
|
dto.setOutBatchNo("B1");
|
|
|
dto.setOrderTitle("202608报销");
|
|
|
- dto.setPayerUid("2088PAYER");
|
|
|
BatchCreateDTO.BatchDetailDTO detail = new BatchCreateDTO.BatchDetailDTO();
|
|
|
detail.setOutBizNo("D1");
|
|
|
detail.setAmount(new BigDecimal("20.11"));
|
|
|
@@ -549,7 +544,6 @@ class AlipayBatchPayServiceTest {
|
|
|
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
|
|
|
BatchCreateDTO dto = new BatchCreateDTO();
|
|
|
dto.setOrderTitle("t");
|
|
|
- dto.setPayerUid("2088PAYER");
|
|
|
dto.setTransferSceneName("");
|
|
|
dto.setTransferSceneReportInfos(List.of(Map.of("info_type", "佣金报酬说明", "info_content", "8月报酬")));
|
|
|
dto.setDetails(List.of(detail("D1", "10")));
|
|
|
@@ -565,7 +559,6 @@ class AlipayBatchPayServiceTest {
|
|
|
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
|
|
|
BatchCreateDTO dto = new BatchCreateDTO();
|
|
|
dto.setOrderTitle("t");
|
|
|
- dto.setPayerUid("2088PAYER");
|
|
|
dto.setTransferSceneName("佣金报酬");
|
|
|
dto.setTransferSceneReportInfos(List.of());
|
|
|
dto.setDetails(List.of(detail("D1", "10")));
|
|
|
@@ -642,7 +635,7 @@ class AlipayBatchPayServiceTest {
|
|
|
doThrow(new DuplicateKeyException("duplicate key")).when(batchAuthorizeMapper).insert(any());
|
|
|
|
|
|
BusinessException ex = assertThrows(BusinessException.class,
|
|
|
- () -> service.authorizeApply("E100", "2088123412341234"));
|
|
|
+ () -> service.authorizeApply("E100"));
|
|
|
|
|
|
assertEquals(400, ex.getCode());
|
|
|
assertTrue(ex.getMessage().contains("请勿重复操作"), ex.getMessage());
|
|
|
@@ -660,7 +653,7 @@ class AlipayBatchPayServiceTest {
|
|
|
when(batchAuthorizeMapper.selectOne(any())).thenReturn(existing);
|
|
|
|
|
|
BusinessException ex = assertThrows(BusinessException.class,
|
|
|
- () -> service.authorizeApply("E100", "2088123412341234"));
|
|
|
+ () -> service.authorizeApply("E100"));
|
|
|
|
|
|
assertEquals(400, ex.getCode());
|
|
|
assertTrue(ex.getMessage().contains("未完成"), ex.getMessage());
|
|
|
@@ -678,7 +671,7 @@ class AlipayBatchPayServiceTest {
|
|
|
existing.setCreatedTime(OffsetDateTime.now());
|
|
|
when(batchAuthorizeMapper.selectOne(any())).thenReturn(existing);
|
|
|
|
|
|
- assertThrows(BusinessException.class, () -> service.authorizeApply("E100", "2088123412341234"));
|
|
|
+ assertThrows(BusinessException.class, () -> service.authorizeApply("E100"));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@@ -696,7 +689,7 @@ class AlipayBatchPayServiceTest {
|
|
|
resp.setAuthorizeLink("https://ur.alipay.com/abc");
|
|
|
when(alipayClient.certificateExecute(any(AlipayFundAuthorizeUniApplyRequest.class))).thenReturn(resp);
|
|
|
|
|
|
- Map<String, String> result = service.authorizeApply("E100", "2088123412341234");
|
|
|
+ Map<String, String> result = service.authorizeApply("E100");
|
|
|
|
|
|
assertEquals("AUTHING", result.get("status"));
|
|
|
// 旧记录作废置 UNBIND(与 uk_batch_authorize_active 的 WHERE status <> 'UNBIND' 协同)
|
|
|
@@ -730,7 +723,7 @@ class AlipayBatchPayServiceTest {
|
|
|
resp.setAuthorizeLink("https://ur.alipay.com/abc");
|
|
|
when(alipayClient.certificateExecute(any(AlipayFundAuthorizeUniApplyRequest.class))).thenReturn(resp);
|
|
|
|
|
|
- Map<String, String> result = service.authorizeApply("E100", "2088123412341234");
|
|
|
+ Map<String, String> result = service.authorizeApply("E100");
|
|
|
|
|
|
assertNotNull(result.get("authorize_link"));
|
|
|
verify(batchAuthorizeMapper).updateById(argThat(e -> "UNBIND".equals(e.getStatus())));
|
|
|
@@ -740,13 +733,13 @@ class AlipayBatchPayServiceTest {
|
|
|
// ==================== 用户反馈轮 2: 付款方 UID 自动带出 + 授权可重新生成 ====================
|
|
|
|
|
|
@Test
|
|
|
- void authorizeApply_blankParticipantId_defaultsToEnterpriseId() throws AlipayApiException {
|
|
|
- // Ruling 19/21: 付款方即企业自己,participant_id 为空时默认企业 enterprise_id(防绕过前端直调)
|
|
|
+ void authorizeApply_alwaysUsesEnterpriseAsPayer() throws AlipayApiException {
|
|
|
+ // Ruling 19/22: 付款方恒为企业自身 UID(enterprise_id),方法不接受客户端传入的 participant_id(防篡改指向他人账号)
|
|
|
AlipayFundAuthorizeUniApplyResponse resp = new AlipayFundAuthorizeUniApplyResponse();
|
|
|
resp.setAuthorizeLink("https://ur.alipay.com/abc");
|
|
|
when(alipayClient.certificateExecute(any(AlipayFundAuthorizeUniApplyRequest.class))).thenReturn(resp);
|
|
|
|
|
|
- Map<String, String> result = service.authorizeApply("E100", " ");
|
|
|
+ Map<String, String> result = service.authorizeApply("E100");
|
|
|
|
|
|
assertEquals("AUTHING", result.get("status"));
|
|
|
ArgumentCaptor<AlipayFundAuthorizeUniApplyRequest> cap = ArgumentCaptor.forClass(AlipayFundAuthorizeUniApplyRequest.class);
|
|
|
@@ -761,7 +754,7 @@ class AlipayBatchPayServiceTest {
|
|
|
@Test
|
|
|
void authorizeApply_nullEnterpriseId_throws() {
|
|
|
// requireEnterpriseId 防御: 企业都不存在时直接拒绝而非默认空串申请
|
|
|
- assertThrows(BusinessException.class, () -> service.authorizeApply(null, null));
|
|
|
+ assertThrows(BusinessException.class, () -> service.authorizeApply(null));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@@ -833,8 +826,8 @@ class AlipayBatchPayServiceTest {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void batchCreate_blankPayerUid_defaultsToEnterpriseId() throws AlipayApiException {
|
|
|
- // Ruling 21: payer_uid 为空时默认企业 enterprise_id(付款方即企业自己)
|
|
|
+ void batchCreate_alwaysUsesEnterpriseAsPayer() throws AlipayApiException {
|
|
|
+ // Ruling 19/22: 付款方恒为企业自身 UID(enterprise_id),DTO 已移除 payer_uid 不接受客户端指定
|
|
|
AlipayFundBatchCreateResponse resp = new AlipayFundBatchCreateResponse();
|
|
|
resp.setOutBatchNo("B1");
|
|
|
when(alipayClient.certificateExecute(any(AlipayFundBatchCreateRequest.class))).thenReturn(resp);
|
|
|
@@ -843,7 +836,6 @@ class AlipayBatchPayServiceTest {
|
|
|
dto.setEnterpriseId("E100");
|
|
|
dto.setOutBatchNo("B1");
|
|
|
dto.setOrderTitle("t");
|
|
|
- dto.setPayerUid(" ");
|
|
|
BatchCreateDTO.BatchDetailDTO detail = new BatchCreateDTO.BatchDetailDTO();
|
|
|
detail.setOutBizNo("D1");
|
|
|
detail.setAmount(new BigDecimal("10"));
|
|
|
@@ -859,7 +851,7 @@ class AlipayBatchPayServiceTest {
|
|
|
verify(alipayClient).certificateExecute(cap.capture());
|
|
|
AlipayFundBatchCreateModel m = (AlipayFundBatchCreateModel) cap.getValue().getBizModel();
|
|
|
assertEquals("E100", m.getPayerInfo().getIdentity());
|
|
|
- // DB 回写 payer_uid 同样默认企业 ID
|
|
|
+ // DB 回写 payer_uid 恒为企业自身 UID
|
|
|
ArgumentCaptor<BatchOrderEntity> order = ArgumentCaptor.forClass(BatchOrderEntity.class);
|
|
|
verify(batchOrderMapper).insert(order.capture());
|
|
|
assertEquals("E100", order.getValue().getPayerUid());
|