|
|
@@ -364,4 +364,47 @@ class AlipayBatchPayServiceTest {
|
|
|
() -> service.batchExport("E100", null, "bad-time", null));
|
|
|
assertEquals(400, ex.getCode());
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void queryAuthorize_notExist_returnsAUTHINGInsteadOfError() throws AlipayApiException {
|
|
|
+ // Task 8 全链路验证: 支付宝 40004 AUTHORIZATION_NOT_EXIST(未授权)是正常业务状态而非查询失败
|
|
|
+ AlipayFundAuthorizeUniQueryResponse resp = new AlipayFundAuthorizeUniQueryResponse();
|
|
|
+ resp.setCode("40004");
|
|
|
+ resp.setSubCode("AUTHORIZATION_NOT_EXIST");
|
|
|
+ resp.setMsg("Business Failed");
|
|
|
+ when(alipayClient.certificateExecute(any(AlipayFundAuthorizeUniQueryRequest.class))).thenReturn(resp);
|
|
|
+
|
|
|
+ Map<String, String> result = service.queryAuthorize("E100", "A1");
|
|
|
+
|
|
|
+ assertEquals("", result.get("agreement_no"));
|
|
|
+ assertEquals("AUTHING", result.get("status"));
|
|
|
+ verify(batchAuthorizeMapper, never()).updateById(any());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void batchCreate_authInfoNotExists_friendlyMessage() throws AlipayApiException {
|
|
|
+ // Task 8 全链路验证: AUTH_INFO_NOT_EXISTS(付款方未授权)应提示明确动作而非透传支付宝原文案
|
|
|
+ AlipayFundBatchCreateResponse resp = new AlipayFundBatchCreateResponse();
|
|
|
+ resp.setCode("40004");
|
|
|
+ resp.setSubCode("AUTH_INFO_NOT_EXISTS");
|
|
|
+ resp.setMsg("Business Failed");
|
|
|
+ when(alipayClient.certificateExecute(any(AlipayFundBatchCreateRequest.class))).thenReturn(resp);
|
|
|
+
|
|
|
+ BatchCreateDTO dto = new BatchCreateDTO();
|
|
|
+ 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"));
|
|
|
+ detail.setPayeeIdentity("test@taobao.com");
|
|
|
+ detail.setPayeeIdentityType("ALIPAY_LOGON_ID");
|
|
|
+ detail.setPayeeName("张三");
|
|
|
+ dto.setDetails(List.of(detail));
|
|
|
+
|
|
|
+ BusinessException ex = assertThrows(BusinessException.class, () -> service.batchCreate(dto));
|
|
|
+ assertEquals(400, ex.getCode());
|
|
|
+ assertTrue(ex.getMessage().contains("制单授权"), "应提示先完成制单授权: " + ex.getMessage());
|
|
|
+ }
|
|
|
}
|