条件筛选
This commit is contained in:
parent
4a4629c8bb
commit
a92506f967
@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
- `startDate`、`endDate` 必填,包含首尾日期,最多 31 天。
|
- `startDate`、`endDate` 必填,包含首尾日期,最多 31 天。
|
||||||
- `storeName` 选填;不传或传空字符串时查询全部网点。多个网点可用逗号分隔。
|
- `storeName` 选填;不传或传空字符串时查询全部网点。多个网点可用逗号分隔。
|
||||||
- 系统状态和退款状态沿用 NGP 接口默认值。
|
- 后端调用 NGP 时固定传入 `postState=800`(财务核算成功)和
|
||||||
|
`refundStatus=0`(无需退款),调用方不需要传这两个参数,也不能覆盖。
|
||||||
- NGP 每页最多查询 200 条;服务会读取全部页面后返回合计。
|
- NGP 每页最多查询 200 条;服务会读取全部页面后返回合计。
|
||||||
|
|
||||||
## 响应
|
## 响应
|
||||||
|
|||||||
@ -27,6 +27,8 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||||||
@Component
|
@Component
|
||||||
public class NgpApiClient {
|
public class NgpApiClient {
|
||||||
static final String SALES_POST_BILL_LIST = "ngp.bill.salepostbill.list";
|
static final String SALES_POST_BILL_LIST = "ngp.bill.salepostbill.list";
|
||||||
|
static final int FINANCIAL_ACCOUNTING_SUCCESS = 800;
|
||||||
|
static final int NO_REFUND = 0;
|
||||||
|
|
||||||
private final FoundationProperties.Ngp config;
|
private final FoundationProperties.Ngp config;
|
||||||
private final NgpTokenProvider tokenProvider;
|
private final NgpTokenProvider tokenProvider;
|
||||||
@ -57,13 +59,19 @@ public class NgpApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public JsonNode salesPostBillPage(String beginTime, String endTime, int pageIndex) {
|
public JsonNode salesPostBillPage(String beginTime, String endTime, int pageIndex) {
|
||||||
|
return call(SALES_POST_BILL_LIST, salesPostBillRequestBody(beginTime, endTime, pageIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> salesPostBillRequestBody(String beginTime, String endTime, int pageIndex) {
|
||||||
Map<String, Object> body = new LinkedHashMap<>();
|
Map<String, Object> body = new LinkedHashMap<>();
|
||||||
body.put("pageSize", Math.min(Math.max(config.getPageSize(), 1), 200));
|
body.put("pageSize", Math.min(Math.max(config.getPageSize(), 1), 200));
|
||||||
body.put("pageIndex", pageIndex);
|
body.put("pageIndex", pageIndex);
|
||||||
body.put("vchtypes", List.of(2000));
|
body.put("vchtypes", List.of(2000));
|
||||||
body.put("beginTime", beginTime);
|
body.put("beginTime", beginTime);
|
||||||
body.put("endTime", endTime);
|
body.put("endTime", endTime);
|
||||||
return call(SALES_POST_BILL_LIST, body);
|
body.put("postState", FINANCIAL_ACCOUNTING_SUCCESS);
|
||||||
|
body.put("refundStatus", NO_REFUND);
|
||||||
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JsonNode call(String method, Object requestBody) {
|
private JsonNode call(String method, Object requestBody) {
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
package com.company.agentfoundation.integration.ngp;
|
package com.company.agentfoundation.integration.ngp;
|
||||||
|
|
||||||
|
import com.company.agentfoundation.config.FoundationProperties;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -24,4 +27,23 @@ class NgpApiClientTest {
|
|||||||
|
|
||||||
assertThat(signature).isEqualTo("9d2447bdd434d0cdf68e3918bf69226c");
|
assertThat(signature).isEqualTo("9d2447bdd434d0cdf68e3918bf69226c");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void salesPerformanceRequestAlwaysFiltersSuccessfulAccountingAndNoRefund() {
|
||||||
|
FoundationProperties properties = new FoundationProperties();
|
||||||
|
NgpApiClient client = new NgpApiClient(
|
||||||
|
properties,
|
||||||
|
org.mockito.Mockito.mock(NgpTokenProvider.class),
|
||||||
|
new ObjectMapper(),
|
||||||
|
WebClient.builder()
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, Object> body = client.salesPostBillRequestBody(
|
||||||
|
"2026-09-01 00:00:00", "2026-09-01 23:59:59", 3);
|
||||||
|
|
||||||
|
assertThat(body)
|
||||||
|
.containsEntry("postState", 800)
|
||||||
|
.containsEntry("refundStatus", 0)
|
||||||
|
.containsEntry("pageIndex", 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user