feat: 发票添加
parent
7b3a20a15a
commit
1437bf936e
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.czcb.scfs.api.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wangwei
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
public interface PageApiRequest extends ApiRequest {
|
||||||
|
/**
|
||||||
|
* 当前页码,默认0
|
||||||
|
*/
|
||||||
|
default Long getCurrentPage() {
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页行数,默认50
|
||||||
|
*/
|
||||||
|
default Long getCurrentRows() {
|
||||||
|
return 50L;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.czcb.scfs.api.core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wangwei
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
public interface PageApiResponse extends ApiResponse {
|
||||||
|
/**
|
||||||
|
* 当前页码,默认0
|
||||||
|
*/
|
||||||
|
default Long getCurrentPage() {
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据总条数
|
||||||
|
*/
|
||||||
|
default Long getTotalRows() {
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总页数
|
||||||
|
*/
|
||||||
|
default Long getTotalPage() {
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否有下页
|
||||||
|
*/
|
||||||
|
default boolean hasNextPage() {
|
||||||
|
return (getCurrentPage() + 1) < getTotalPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,15 @@
|
||||||
package com.czcb.scfs.service.equity.invoice;
|
package com.czcb.scfs.service.equity.invoice;
|
||||||
|
|
||||||
import com.czcb.scfs.api.core.ApiClient;
|
import com.czcb.scfs.api.core.ApiClient;
|
||||||
|
import com.czcb.scfs.api.core.http.HttpHeaders;
|
||||||
|
import com.czcb.scfs.api.core.http.HttpResponse;
|
||||||
|
import com.czcb.scfs.service.equity.invoice.model.InvoiceAddRequest;
|
||||||
|
import com.czcb.scfs.service.equity.invoice.model.InvoiceAddResponse;
|
||||||
|
import com.czcb.scfs.service.equity.invoice.model.InvoiceQueryRequest;
|
||||||
|
import com.czcb.scfs.service.equity.invoice.model.InvoiceQueryResponse;
|
||||||
|
|
||||||
|
import static com.czcb.scfs.api.core.Constants.API_VERSION;
|
||||||
|
import static com.czcb.scfs.api.core.Constants.V_2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wangwei
|
* @author wangwei
|
||||||
|
|
@ -12,4 +21,48 @@ public class InvoiceService {
|
||||||
public InvoiceService(ApiClient apiClient) {
|
public InvoiceService(ApiClient apiClient) {
|
||||||
this.apiClient = apiClient;
|
this.apiClient = apiClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加发票
|
||||||
|
*/
|
||||||
|
public InvoiceAddResponse add(InvoiceAddRequest request) {
|
||||||
|
String url = "/invoice/add";
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.addHeader(API_VERSION, V_2);
|
||||||
|
HttpResponse<InvoiceAddResponse> httpResponse = apiClient.post(url, headers, request.toJsonRequest(), InvoiceAddResponse.class);
|
||||||
|
return httpResponse.getServiceResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除发票
|
||||||
|
*/
|
||||||
|
public InvoiceAddResponse delete(InvoiceAddRequest request) {
|
||||||
|
String url = "/invoice/delete";
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.addHeader(API_VERSION, V_2);
|
||||||
|
HttpResponse<InvoiceAddResponse> httpResponse = apiClient.post(url, headers, request.toJsonRequest(), InvoiceAddResponse.class);
|
||||||
|
return httpResponse.getServiceResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除发票-批量删除
|
||||||
|
*/
|
||||||
|
public InvoiceAddResponse deleteBatch(InvoiceAddRequest request) {
|
||||||
|
String url = "/invoice/delete/batch";
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.addHeader(API_VERSION, V_2);
|
||||||
|
HttpResponse<InvoiceAddResponse> httpResponse = apiClient.post(url, headers, request.toJsonRequest(), InvoiceAddResponse.class);
|
||||||
|
return httpResponse.getServiceResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除发票-批量删除
|
||||||
|
*/
|
||||||
|
public InvoiceQueryResponse query(InvoiceQueryRequest request) {
|
||||||
|
String url = "/invoice/query";
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.addHeader(API_VERSION, V_2);
|
||||||
|
HttpResponse<InvoiceQueryResponse> httpResponse = apiClient.post(url, headers, request.toJsonRequest(), InvoiceQueryResponse.class);
|
||||||
|
return httpResponse.getServiceResponse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,108 @@
|
||||||
|
package com.czcb.scfs.service.equity.invoice.model;
|
||||||
|
|
||||||
|
import com.czcb.scfs.api.core.ApiRequest;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wangwei
|
||||||
|
* @since 2024/7/8
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class InvoiceAddRequest implements ApiRequest {
|
||||||
|
/**
|
||||||
|
* 渠道编号
|
||||||
|
*/
|
||||||
|
@SerializedName("channel_no")
|
||||||
|
private String channelNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用编号
|
||||||
|
*/
|
||||||
|
@SerializedName("app_no")
|
||||||
|
private String appNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流水号
|
||||||
|
*/
|
||||||
|
@SerializedName("serial_no")
|
||||||
|
private String serialNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作日期
|
||||||
|
*/
|
||||||
|
@SerializedName("trans_date")
|
||||||
|
private String transDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作时间
|
||||||
|
*/
|
||||||
|
@SerializedName("trans_tradetime")
|
||||||
|
private String transTradeTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发票编号
|
||||||
|
*/
|
||||||
|
@SerializedName("invoice_no")
|
||||||
|
private String invoiceNo;
|
||||||
|
/**
|
||||||
|
* 发票类型 1、通用发票 2、累计循环发票
|
||||||
|
*/
|
||||||
|
@SerializedName("invoice_type")
|
||||||
|
private String invoiceType;
|
||||||
|
/**
|
||||||
|
* 发票登记日期
|
||||||
|
*/
|
||||||
|
@SerializedName("invoice_register_date")
|
||||||
|
private Date invoiceRegisterDate;
|
||||||
|
/**
|
||||||
|
* 付款账户账号
|
||||||
|
*/
|
||||||
|
@SerializedName("account_no")
|
||||||
|
private String accountNo;
|
||||||
|
/**
|
||||||
|
* 付款账户户名
|
||||||
|
*/
|
||||||
|
@SerializedName("account_name")
|
||||||
|
private String accountName;
|
||||||
|
/**
|
||||||
|
* 收款账户账号(入账账户)
|
||||||
|
*/
|
||||||
|
@SerializedName("opp_account_no")
|
||||||
|
private String oppAccountNo;
|
||||||
|
/**
|
||||||
|
* 收款账户户名(入账账户)
|
||||||
|
*/
|
||||||
|
@SerializedName("opp_account_name")
|
||||||
|
private String oppAccountName;
|
||||||
|
/**
|
||||||
|
* 归集账户账号(待清算账户/可控电商A2)
|
||||||
|
*/
|
||||||
|
@SerializedName("settle_account_no")
|
||||||
|
private String settleAccountNo;
|
||||||
|
/**
|
||||||
|
* 归集账户户名(待清算账户/可控电商A2)
|
||||||
|
*/
|
||||||
|
@SerializedName("settle_account_name")
|
||||||
|
private String settleAccountName;
|
||||||
|
/**
|
||||||
|
* 发票归属日期起
|
||||||
|
*/
|
||||||
|
@SerializedName("invoice_belong_start_date")
|
||||||
|
private Date invoiceBelongStartDate;
|
||||||
|
/**
|
||||||
|
* 发票归属日期止
|
||||||
|
*/
|
||||||
|
@SerializedName("invoice_belong_end_date")
|
||||||
|
private Date invoiceBelongEndDate;
|
||||||
|
/**
|
||||||
|
* 发票金额
|
||||||
|
*/
|
||||||
|
@SerializedName("invoice_amount")
|
||||||
|
private BigDecimal invoiceAmount;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.czcb.scfs.service.equity.invoice.model;
|
||||||
|
|
||||||
|
import com.czcb.scfs.api.core.ApiRequest;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wangwei
|
||||||
|
* @since 2024/7/8
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class InvoiceAddResponse implements ApiRequest {
|
||||||
|
/**
|
||||||
|
* 000000:表示成功
|
||||||
|
*/
|
||||||
|
@SerializedName("recode")
|
||||||
|
private String recode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结果信息
|
||||||
|
*/
|
||||||
|
@SerializedName("recode_info")
|
||||||
|
private String recodeInfo;
|
||||||
|
/**
|
||||||
|
* 系统流水号
|
||||||
|
*/
|
||||||
|
@SerializedName("sys_serial_no")
|
||||||
|
private String sysSerialNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统日期(YYYY-MM-DD)
|
||||||
|
*/
|
||||||
|
@SerializedName("sys_date")
|
||||||
|
private String sysDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统时间(YYYY-MM-DD hh:mm:ss)
|
||||||
|
*/
|
||||||
|
@SerializedName("sys_time")
|
||||||
|
private String sysTime;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,108 @@
|
||||||
|
package com.czcb.scfs.service.equity.invoice.model;
|
||||||
|
|
||||||
|
import com.czcb.scfs.api.core.PageApiRequest;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wangwei
|
||||||
|
* @since 2024/7/8
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class InvoiceQueryRequest implements PageApiRequest {
|
||||||
|
/**
|
||||||
|
* 渠道编号
|
||||||
|
*/
|
||||||
|
@SerializedName("channel_no")
|
||||||
|
private String channelNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用编号
|
||||||
|
*/
|
||||||
|
@SerializedName("app_no")
|
||||||
|
private String appNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流水号
|
||||||
|
*/
|
||||||
|
@SerializedName("serial_no")
|
||||||
|
private String serialNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作日期
|
||||||
|
*/
|
||||||
|
@SerializedName("trans_date")
|
||||||
|
private String transDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作时间
|
||||||
|
*/
|
||||||
|
@SerializedName("trans_tradetime")
|
||||||
|
private String transTradeTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发票编号
|
||||||
|
*/
|
||||||
|
@SerializedName("invoice_no")
|
||||||
|
private String invoiceNo;
|
||||||
|
/**
|
||||||
|
* 发票类型 1、通用发票 2、累计循环发票
|
||||||
|
*/
|
||||||
|
@SerializedName("invoice_type")
|
||||||
|
private String invoiceType;
|
||||||
|
/**
|
||||||
|
* 发票登记日期
|
||||||
|
*/
|
||||||
|
@SerializedName("invoice_register_date")
|
||||||
|
private Date invoiceRegisterDate;
|
||||||
|
/**
|
||||||
|
* 付款账户账号
|
||||||
|
*/
|
||||||
|
@SerializedName("account_no")
|
||||||
|
private String accountNo;
|
||||||
|
/**
|
||||||
|
* 付款账户户名
|
||||||
|
*/
|
||||||
|
@SerializedName("account_name")
|
||||||
|
private String accountName;
|
||||||
|
/**
|
||||||
|
* 收款账户账号(入账账户)
|
||||||
|
*/
|
||||||
|
@SerializedName("opp_account_no")
|
||||||
|
private String oppAccountNo;
|
||||||
|
/**
|
||||||
|
* 收款账户户名(入账账户)
|
||||||
|
*/
|
||||||
|
@SerializedName("opp_account_name")
|
||||||
|
private String oppAccountName;
|
||||||
|
/**
|
||||||
|
* 归集账户账号(待清算账户/可控电商A2)
|
||||||
|
*/
|
||||||
|
@SerializedName("settle_account_no")
|
||||||
|
private String settleAccountNo;
|
||||||
|
/**
|
||||||
|
* 归集账户户名(待清算账户/可控电商A2)
|
||||||
|
*/
|
||||||
|
@SerializedName("settle_account_name")
|
||||||
|
private String settleAccountName;
|
||||||
|
/**
|
||||||
|
* 发票归属日期起
|
||||||
|
*/
|
||||||
|
@SerializedName("invoice_belong_start_date")
|
||||||
|
private Date invoiceBelongStartDate;
|
||||||
|
/**
|
||||||
|
* 发票归属日期止
|
||||||
|
*/
|
||||||
|
@SerializedName("invoice_belong_end_date")
|
||||||
|
private Date invoiceBelongEndDate;
|
||||||
|
/**
|
||||||
|
* 发票金额
|
||||||
|
*/
|
||||||
|
@SerializedName("invoice_amount")
|
||||||
|
private BigDecimal invoiceAmount;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.czcb.scfs.service.equity.invoice.model;
|
||||||
|
|
||||||
|
import com.czcb.scfs.api.core.PageApiResponse;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wangwei
|
||||||
|
* @since 2024/7/8
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class InvoiceQueryResponse implements PageApiResponse {
|
||||||
|
/**
|
||||||
|
* 000000:表示成功
|
||||||
|
*/
|
||||||
|
@SerializedName("recode")
|
||||||
|
private String recode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结果信息
|
||||||
|
*/
|
||||||
|
@SerializedName("recode_info")
|
||||||
|
private String recodeInfo;
|
||||||
|
/**
|
||||||
|
* 系统流水号
|
||||||
|
*/
|
||||||
|
@SerializedName("sys_serial_no")
|
||||||
|
private String sysSerialNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统日期(YYYY-MM-DD)
|
||||||
|
*/
|
||||||
|
@SerializedName("sys_date")
|
||||||
|
private String sysDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统时间(YYYY-MM-DD hh:mm:ss)
|
||||||
|
*/
|
||||||
|
@SerializedName("sys_time")
|
||||||
|
private String sysTime;
|
||||||
|
}
|
||||||
|
|
@ -25,7 +25,6 @@ public class EchoService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void echo() {
|
public void echo() {
|
||||||
String url = "/echo";
|
|
||||||
EchoRequest request = new EchoRequest();
|
EchoRequest request = new EchoRequest();
|
||||||
request.setDatetime(DateTimes.ofNow());
|
request.setDatetime(DateTimes.ofNow());
|
||||||
request.setChannelNo(apiClient.getProfile().getChannel().getChannelNo());
|
request.setChannelNo(apiClient.getProfile().getChannel().getChannelNo());
|
||||||
|
|
@ -34,6 +33,11 @@ public class EchoService {
|
||||||
request.setTransDate(DateTimes.ofNowDate());
|
request.setTransDate(DateTimes.ofNowDate());
|
||||||
request.setTransTradeTime(DateTimes.ofNow());
|
request.setTransTradeTime(DateTimes.ofNow());
|
||||||
|
|
||||||
|
echo(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void echo(EchoRequest request) {
|
||||||
|
String url = "/echo";
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
HttpResponse<EchoResponse> response = apiClient.post(url, headers, request.toJsonRequest(), EchoResponse.class);
|
HttpResponse<EchoResponse> response = apiClient.post(url, headers, request.toJsonRequest(), EchoResponse.class);
|
||||||
if (Objects.isNull(response.getServiceResponse()) || !response.getServiceResponse().ok()) {
|
if (Objects.isNull(response.getServiceResponse()) || !response.getServiceResponse().ok()) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,9 @@ package com.czcb.scfs.api.service.echo;
|
||||||
import com.czcb.scfs.api.core.ApiClient;
|
import com.czcb.scfs.api.core.ApiClient;
|
||||||
import com.czcb.scfs.api.core.exception.ValidationException;
|
import com.czcb.scfs.api.core.exception.ValidationException;
|
||||||
import com.czcb.scfs.api.core.http.HttpMethod;
|
import com.czcb.scfs.api.core.http.HttpMethod;
|
||||||
|
import com.czcb.scfs.api.core.util.DateTimes;
|
||||||
import com.czcb.scfs.api.core.util.Json;
|
import com.czcb.scfs.api.core.util.Json;
|
||||||
|
import com.czcb.scfs.api.core.util.Nonce;
|
||||||
import com.czcb.scfs.api.service.MockResponse;
|
import com.czcb.scfs.api.service.MockResponse;
|
||||||
import com.czcb.scfs.api.service.echo.model.EchoRequest;
|
import com.czcb.scfs.api.service.echo.model.EchoRequest;
|
||||||
import com.czcb.scfs.api.service.echo.model.EchoResponse;
|
import com.czcb.scfs.api.service.echo.model.EchoResponse;
|
||||||
|
|
@ -40,7 +42,30 @@ class EchoServiceTest {
|
||||||
ApiClient apiClient = MockResponse.getApiClient();
|
ApiClient apiClient = MockResponse.getApiClient();
|
||||||
EchoService service = new EchoService(apiClient);
|
EchoService service = new EchoService(apiClient);
|
||||||
|
|
||||||
Assertions.assertDoesNotThrow(service::echo);
|
Assertions.assertDoesNotThrow(() -> service.echo());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void pingParams() {
|
||||||
|
EchoResponse echoResponse = new EchoResponse();
|
||||||
|
echoResponse.setMessage("ok");
|
||||||
|
|
||||||
|
client.reset().when(request()
|
||||||
|
.withMethod(HttpMethod.POST.getUpperName())
|
||||||
|
.withPath("/echo")
|
||||||
|
).respond(MockResponse.mock(echoResponse.toJsonResponse().getBody()));
|
||||||
|
|
||||||
|
ApiClient apiClient = MockResponse.getApiClient();
|
||||||
|
EchoService service = new EchoService(apiClient);
|
||||||
|
|
||||||
|
EchoRequest request = new EchoRequest();
|
||||||
|
request.setDatetime(DateTimes.ofNow());
|
||||||
|
request.setChannelNo(apiClient.getProfile().getChannel().getChannelNo());
|
||||||
|
request.setAppNo(apiClient.getProfile().getChannel().getAppNo());
|
||||||
|
request.setSerialNo(Nonce.ofNonce());
|
||||||
|
request.setTransDate(DateTimes.ofNowDate());
|
||||||
|
request.setTransTradeTime(DateTimes.ofNow());
|
||||||
|
Assertions.assertDoesNotThrow(() -> service.echo(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue