Skip to content

Commit 5155c8c

Browse files
authored
🆕 #2052 【公众号】增加微信电子发票报销方相关接口
1、查询报销发票信息 2、批量查询报销发票信息 3、报销方更新发票状态 4、报销方批量更新发票状态
1 parent 8623306 commit 5155c8c

13 files changed

+654
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package me.chanjar.weixin.mp.api;
2+
3+
import me.chanjar.weixin.common.error.WxErrorException;
4+
import me.chanjar.weixin.mp.bean.invoice.reimburse.*;
5+
6+
import java.util.List;
7+
8+
/**
9+
* 电子发票报销方相关接口
10+
* 接口文档: https://developers.weixin.qq.com/doc/offiaccount/WeChat_Invoice/E_Invoice/Reimburser_API_List.html
11+
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a>
12+
* @since 2021-03-23
13+
*/
14+
public interface WxMpReimburseInvoiceService {
15+
16+
/**
17+
* 查询报销发票信息
18+
* @param request {@link InvoiceInfoRequest} 查询报销发票信息参数
19+
* @return {@link InvoiceInfoResponse} 查询结果
20+
* @throws WxErrorException 查询失败时
21+
*/
22+
InvoiceInfoResponse getInvoiceInfo(InvoiceInfoRequest request) throws WxErrorException;
23+
24+
25+
/**
26+
* 批量查询报销发票信息
27+
* @param request {@link InvoiceBatchRequest} 批量查询报销发票信息参数对象
28+
* @return {@link InvoiceInfoResponse} 查询结果列表
29+
* @throws WxErrorException 查询失败时
30+
*/
31+
List<InvoiceInfoResponse> getInvoiceBatch(InvoiceBatchRequest request) throws WxErrorException;
32+
33+
34+
/**
35+
* 更新发票状态
36+
* @param request {@link UpdateInvoiceStatusRequest} 更新发票状态参数
37+
* @throws WxErrorException 更新失败时
38+
*/
39+
void updateInvoiceStatus(UpdateInvoiceStatusRequest request) throws WxErrorException;
40+
41+
42+
/**
43+
* 批量更新发票状态
44+
* @param request {@link UpdateStatusBatchRequest} 批量更新发票状态参数
45+
* @throws WxErrorException 更新失败时
46+
*/
47+
void updateStatusBatch(UpdateStatusBatchRequest request) throws WxErrorException;
48+
}

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,18 @@ public interface WxMpService extends WxService {
533533
*/
534534
WxImgProcService getImgProcService();
535535

536+
/**
537+
* 返回电子发票报销方相关接口
538+
* @return WxMpReimburseInvoiceService
539+
*/
540+
WxMpReimburseInvoiceService getReimburseInvoiceService();
541+
542+
/**
543+
* .
544+
* @param reimburseInvoiceService .
545+
*/
546+
void setReimburseInvoiceService(WxMpReimburseInvoiceService reimburseInvoiceService);
547+
536548
/**
537549
* .
538550
*

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/BaseWxMpServiceImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ public abstract class BaseWxMpServiceImpl<H, P> implements WxMpService, RequestH
129129
@Setter
130130
private WxOAuth2Service oAuth2Service = new WxMpOAuth2ServiceImpl(this);
131131

132+
@Getter
133+
@Setter
134+
private WxMpReimburseInvoiceService reimburseInvoiceService = new WxMpReimburseInvoiceServiceImpl(this);
135+
132136
private Map<String, WxMpConfigStorage> configStorageMap;
133137

134138
private int retrySleepMillis = 1000;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package me.chanjar.weixin.mp.api.impl;
2+
3+
import lombok.AllArgsConstructor;
4+
import me.chanjar.weixin.common.error.WxErrorException;
5+
import me.chanjar.weixin.mp.api.WxMpReimburseInvoiceService;
6+
import me.chanjar.weixin.mp.api.WxMpService;
7+
import me.chanjar.weixin.mp.bean.invoice.reimburse.*;
8+
9+
import java.util.List;
10+
11+
import static me.chanjar.weixin.mp.enums.WxMpApiUrl.Invoice.*;
12+
13+
/**
14+
* 电子发票报销方相关接口实现
15+
* 接口文档: https://developers.weixin.qq.com/doc/offiaccount/WeChat_Invoice/E_Invoice/Reimburser_API_List.html
16+
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a>
17+
* @since 2021-03-23
18+
*/
19+
@AllArgsConstructor
20+
public class WxMpReimburseInvoiceServiceImpl implements WxMpReimburseInvoiceService {
21+
22+
private final WxMpService wxMpService;
23+
24+
@Override
25+
public InvoiceInfoResponse getInvoiceInfo(InvoiceInfoRequest request) throws WxErrorException {
26+
return InvoiceInfoResponse.fromJson(this.wxMpService.post(GET_INVOICE_INFO,request.toJson()));
27+
}
28+
29+
@Override
30+
public List<InvoiceInfoResponse> getInvoiceBatch(InvoiceBatchRequest request) throws WxErrorException {
31+
return InvoiceInfoResponse.toList(this.wxMpService.post(GET_INVOICE_BATCH,request.toJson()));
32+
}
33+
34+
@Override
35+
public void updateInvoiceStatus(UpdateInvoiceStatusRequest request) throws WxErrorException {
36+
this.wxMpService.post(UPDATE_INVOICE_STATUS,request.toJson());
37+
}
38+
39+
@Override
40+
public void updateStatusBatch(UpdateStatusBatchRequest request) throws WxErrorException {
41+
this.wxMpService.post(UPDATE_STATUS_BATCH,request.toJson());
42+
}
43+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package me.chanjar.weixin.mp.bean.invoice.reimburse;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
7+
8+
import java.io.Serializable;
9+
import java.util.List;
10+
11+
/**
12+
* <pre>
13+
* 批量查询报销发票信息参数对象
14+
* </pre>
15+
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a>
16+
* @since 2021-03-23
17+
*/
18+
@Data
19+
@Builder
20+
public class InvoiceBatchRequest implements Serializable {
21+
22+
private static final long serialVersionUID = -9121443117105107231L;
23+
24+
/**
25+
* 发票卡券的card_id
26+
* <pre>
27+
* 是否必填: 是
28+
* </pre>
29+
*/
30+
@SerializedName("item_list")
31+
private List<InvoiceInfoRequest> itemList;
32+
33+
public String toJson() {
34+
return WxMpGsonBuilder.create().toJson(this);
35+
}
36+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package me.chanjar.weixin.mp.bean.invoice.reimburse;
2+
3+
import lombok.Data;
4+
5+
/**
6+
* <pre>
7+
* 发票商品信息
8+
* </pre>
9+
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a>
10+
* @since 2021-03-23
11+
*/
12+
@Data
13+
public class InvoiceCommodityInfo {
14+
15+
/**
16+
* 项目(商品)名称
17+
*/
18+
private String name;
19+
20+
/**
21+
* 项目数量
22+
*/
23+
private Integer num;
24+
25+
/**
26+
* 项目单位
27+
*/
28+
private String unit;
29+
30+
/**
31+
* 单价,以分为单位
32+
*/
33+
private Integer price;
34+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package me.chanjar.weixin.mp.bean.invoice.reimburse;
2+
3+
4+
import com.google.gson.annotations.SerializedName;
5+
import lombok.Builder;
6+
import lombok.Data;
7+
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
8+
9+
import java.io.Serializable;
10+
11+
/**
12+
* <pre>
13+
* 查询报销发票信息参数对象
14+
* </pre>
15+
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a>
16+
* @since 2021-03-23
17+
*/
18+
@Data
19+
@Builder
20+
public class InvoiceInfoRequest implements Serializable {
21+
22+
private static final long serialVersionUID = 7854633127026139444L;
23+
24+
25+
/**
26+
* 发票卡券的card_id
27+
* <pre>
28+
* 是否必填: 是
29+
* </pre>
30+
*/
31+
@SerializedName("card_id")
32+
private String cardId;
33+
34+
35+
/**
36+
* 发票卡券的加密code,和card_id共同构成一张发票卡券的唯一标识
37+
* <pre>
38+
* 是否必填: 是
39+
* </pre>
40+
*/
41+
@SerializedName("encrypt_code")
42+
private String encryptCode;
43+
44+
45+
public String toJson() {
46+
return WxMpGsonBuilder.create().toJson(this);
47+
}
48+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package me.chanjar.weixin.mp.bean.invoice.reimburse;
2+
3+
import com.google.gson.JsonObject;
4+
import com.google.gson.annotations.SerializedName;
5+
import com.google.gson.reflect.TypeToken;
6+
import lombok.Data;
7+
import me.chanjar.weixin.common.util.json.GsonParser;
8+
import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder;
9+
10+
import java.util.List;
11+
12+
/**
13+
* <pre>
14+
* 查询报销发票信息响应对象
15+
* </pre>
16+
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a>
17+
* @since 2021-03-23
18+
*/
19+
@Data
20+
public class InvoiceInfoResponse {
21+
22+
/**
23+
* 发票ID
24+
*/
25+
@SerializedName("card_id")
26+
private String cardId;
27+
28+
29+
/**
30+
* 发票的有效期起始时间
31+
*/
32+
@SerializedName("begin_time")
33+
private Integer beginTime;
34+
35+
/**
36+
* 发票的有效期截止时间
37+
*/
38+
@SerializedName("end_time")
39+
private Integer endTime;
40+
41+
/**
42+
* 用户标识
43+
*/
44+
private String openid;
45+
46+
/**
47+
* 发票的类型
48+
*/
49+
private String type;
50+
51+
/**
52+
* 发票的收款方
53+
*/
54+
private String payee;
55+
56+
/**
57+
* 发票详情
58+
*/
59+
private String detail;
60+
61+
/**
62+
* 用户可在发票票面看到的主要信息
63+
*/
64+
@SerializedName("user_info")
65+
private InvoiceUserInfo userInfo;
66+
67+
68+
public static InvoiceInfoResponse fromJson(String json) {
69+
return WxMpGsonBuilder.create().fromJson(json, InvoiceInfoResponse.class);
70+
}
71+
72+
73+
public static List<InvoiceInfoResponse> toList(String json) {
74+
JsonObject jsonObject = GsonParser.parse(json);
75+
return WxMpGsonBuilder.create().fromJson(jsonObject.get("item_list").toString(),
76+
new TypeToken<List<InvoiceInfoResponse>>() {
77+
}.getType());
78+
}
79+
}

0 commit comments

Comments
 (0)