forked from Wechat-Group/WxJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🆕 Wechat-Group#2135 【小程序】实现获取 URL Link接口 以及微信电子发票报销方相关接口
- Loading branch information
Showing
18 changed files
with
924 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLinkService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package cn.binarywang.wx.miniapp.api; | ||
|
||
|
||
import cn.binarywang.wx.miniapp.bean.urllink.GenerateUrlLinkRequest; | ||
import me.chanjar.weixin.common.error.WxErrorException; | ||
|
||
/** | ||
* 获取小程序 URL Link接口 | ||
* 接口文档: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/url-link/urllink.generate.html | ||
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a> | ||
* @since 2021-06-10 | ||
*/ | ||
public interface WxMaLinkService { | ||
|
||
String generate(GenerateUrlLinkRequest request) throws WxErrorException; | ||
} |
48 changes: 48 additions & 0 deletions
48
...-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaReimburseInvoiceService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package cn.binarywang.wx.miniapp.api; | ||
|
||
import cn.binarywang.wx.miniapp.bean.invoice.reimburse.*; | ||
import me.chanjar.weixin.common.error.WxErrorException; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* 电子发票报销方相关接口 | ||
* 接口文档: https://developers.weixin.qq.com/doc/offiaccount/WeChat_Invoice/E_Invoice/Reimburser_API_List.html | ||
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a> | ||
* @since 2021-06-10 | ||
*/ | ||
public interface WxMaReimburseInvoiceService { | ||
|
||
/** | ||
* 查询报销发票信息 | ||
* @param request {@link InvoiceInfoRequest} 查询报销发票信息参数 | ||
* @return {@link InvoiceInfoResponse} 查询结果 | ||
* @throws WxErrorException 查询失败时 | ||
*/ | ||
InvoiceInfoResponse getInvoiceInfo(InvoiceInfoRequest request) throws WxErrorException; | ||
|
||
|
||
/** | ||
* 批量查询报销发票信息 | ||
* @param request {@link InvoiceBatchRequest} 批量查询报销发票信息参数对象 | ||
* @return {@link InvoiceInfoResponse} 查询结果列表 | ||
* @throws WxErrorException 查询失败时 | ||
*/ | ||
List<InvoiceInfoResponse> getInvoiceBatch(InvoiceBatchRequest request) throws WxErrorException; | ||
|
||
|
||
/** | ||
* 更新发票状态 | ||
* @param request {@link UpdateInvoiceStatusRequest} 更新发票状态参数 | ||
* @throws WxErrorException 更新失败时 | ||
*/ | ||
void updateInvoiceStatus(UpdateInvoiceStatusRequest request) throws WxErrorException; | ||
|
||
|
||
/** | ||
* 批量更新发票状态 | ||
* @param request {@link UpdateStatusBatchRequest} 批量更新发票状态参数 | ||
* @throws WxErrorException 更新失败时 | ||
*/ | ||
void updateStatusBatch(UpdateStatusBatchRequest request) throws WxErrorException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLinkServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package cn.binarywang.wx.miniapp.api.impl; | ||
|
||
import cn.binarywang.wx.miniapp.api.WxMaLinkService; | ||
import cn.binarywang.wx.miniapp.api.WxMaService; | ||
import cn.binarywang.wx.miniapp.bean.urllink.GenerateUrlLinkRequest; | ||
import com.google.gson.JsonObject; | ||
import lombok.AllArgsConstructor; | ||
import me.chanjar.weixin.common.error.WxErrorException; | ||
import me.chanjar.weixin.common.util.json.GsonParser; | ||
import me.chanjar.weixin.common.util.json.WxGsonBuilder; | ||
|
||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Link.GENERATE_URLLINK_URL; | ||
|
||
/** | ||
* 获取小程序 URL Link接口实现 | ||
* 接口文档: https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/url-link/urllink.generate.html | ||
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a> | ||
* @since 2021-06-10 | ||
*/ | ||
@AllArgsConstructor | ||
public class WxMaLinkServiceImpl implements WxMaLinkService { | ||
|
||
private final WxMaService wxMaService; | ||
|
||
@Override | ||
public String generate(GenerateUrlLinkRequest request) throws WxErrorException { | ||
String result = this.wxMaService.post(GENERATE_URLLINK_URL,request); | ||
String linkField = "url_link"; | ||
JsonObject jsonObject = GsonParser.parse(result); | ||
if(jsonObject.has(linkField)){ | ||
return jsonObject.get(linkField).toString(); | ||
} | ||
throw new WxErrorException("无url_link"); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...iapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaReimburseInvoiceServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package cn.binarywang.wx.miniapp.api.impl; | ||
|
||
import cn.binarywang.wx.miniapp.api.WxMaReimburseInvoiceService; | ||
import cn.binarywang.wx.miniapp.api.WxMaService; | ||
import cn.binarywang.wx.miniapp.bean.invoice.reimburse.*; | ||
import lombok.AllArgsConstructor; | ||
import me.chanjar.weixin.common.error.WxErrorException; | ||
|
||
import java.util.List; | ||
|
||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Invoice.*; | ||
|
||
/** | ||
* 电子发票报销方相关接口实现 | ||
* 接口文档: https://developers.weixin.qq.com/doc/offiaccount/WeChat_Invoice/E_Invoice/Reimburser_API_List.html | ||
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a> | ||
* @since 2021-06-10 | ||
*/ | ||
@AllArgsConstructor | ||
public class WxMaReimburseInvoiceServiceImpl implements WxMaReimburseInvoiceService { | ||
|
||
private final WxMaService wxMaService; | ||
|
||
@Override | ||
public InvoiceInfoResponse getInvoiceInfo(InvoiceInfoRequest request) throws WxErrorException { | ||
return InvoiceInfoResponse.fromJson(this.wxMaService.post(GET_INVOICE_INFO,request.toJson())); | ||
} | ||
|
||
@Override | ||
public List<InvoiceInfoResponse> getInvoiceBatch(InvoiceBatchRequest request) throws WxErrorException { | ||
return InvoiceInfoResponse.toList(this.wxMaService.post(GET_INVOICE_BATCH,request.toJson())); | ||
} | ||
|
||
@Override | ||
public void updateInvoiceStatus(UpdateInvoiceStatusRequest request) throws WxErrorException { | ||
this.wxMaService.post(UPDATE_INVOICE_STATUS,request.toJson()); | ||
} | ||
|
||
@Override | ||
public void updateStatusBatch(UpdateStatusBatchRequest request) throws WxErrorException { | ||
this.wxMaService.post(UPDATE_STATUS_BATCH,request.toJson()); | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
...pp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/InvoiceBatchRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package cn.binarywang.wx.miniapp.bean.invoice.reimburse; | ||
|
||
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; | ||
import com.google.gson.annotations.SerializedName; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
/** | ||
* <pre> | ||
* 批量查询报销发票信息参数对象 | ||
* </pre> | ||
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a> | ||
* @since 2021-03-23 | ||
*/ | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class InvoiceBatchRequest implements Serializable { | ||
|
||
private static final long serialVersionUID = -9121443117105107231L; | ||
|
||
/** | ||
* 发票卡券的card_id | ||
* <pre> | ||
* 是否必填: 是 | ||
* </pre> | ||
*/ | ||
@SerializedName("item_list") | ||
private List<InvoiceInfoRequest> itemList; | ||
|
||
|
||
public String toJson() { | ||
return WxMaGsonBuilder.create().toJson(this); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...p/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/InvoiceCommodityInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cn.binarywang.wx.miniapp.bean.invoice.reimburse; | ||
|
||
import lombok.Data; | ||
|
||
/** | ||
* <pre> | ||
* 发票商品信息 | ||
* </pre> | ||
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a> | ||
* @since 2021-03-23 | ||
*/ | ||
@Data | ||
public class InvoiceCommodityInfo { | ||
|
||
/** | ||
* 项目(商品)名称 | ||
*/ | ||
private String name; | ||
|
||
/** | ||
* 项目数量 | ||
*/ | ||
private Integer num; | ||
|
||
/** | ||
* 项目单位 | ||
*/ | ||
private String unit; | ||
|
||
/** | ||
* 单价,以分为单位 | ||
*/ | ||
private Integer price; | ||
} |
53 changes: 53 additions & 0 deletions
53
...app/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/InvoiceInfoRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package cn.binarywang.wx.miniapp.bean.invoice.reimburse; | ||
|
||
|
||
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; | ||
import com.google.gson.annotations.SerializedName; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* <pre> | ||
* 查询报销发票信息参数对象 | ||
* </pre> | ||
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a> | ||
* @since 2021-03-23 | ||
*/ | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class InvoiceInfoRequest implements Serializable { | ||
|
||
private static final long serialVersionUID = 7854633127026139444L; | ||
|
||
|
||
/** | ||
* 发票卡券的card_id | ||
* <pre> | ||
* 是否必填: 是 | ||
* </pre> | ||
*/ | ||
@SerializedName("card_id") | ||
private String cardId; | ||
|
||
|
||
/** | ||
* 发票卡券的加密code,和card_id共同构成一张发票卡券的唯一标识 | ||
* <pre> | ||
* 是否必填: 是 | ||
* </pre> | ||
*/ | ||
@SerializedName("encrypt_code") | ||
private String encryptCode; | ||
|
||
|
||
|
||
public String toJson() { | ||
return WxMaGsonBuilder.create().toJson(this); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
...pp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/InvoiceInfoResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package cn.binarywang.wx.miniapp.bean.invoice.reimburse; | ||
|
||
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; | ||
import com.google.gson.JsonObject; | ||
import com.google.gson.annotations.SerializedName; | ||
import com.google.gson.reflect.TypeToken; | ||
import lombok.Data; | ||
import me.chanjar.weixin.common.util.json.GsonParser; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* <pre> | ||
* 查询报销发票信息响应对象 | ||
* </pre> | ||
* @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a> | ||
* @since 2021-03-23 | ||
*/ | ||
@Data | ||
public class InvoiceInfoResponse { | ||
|
||
/** | ||
* 发票ID | ||
*/ | ||
@SerializedName("card_id") | ||
private String cardId; | ||
|
||
|
||
/** | ||
* 发票的有效期起始时间 | ||
*/ | ||
@SerializedName("begin_time") | ||
private Integer beginTime; | ||
|
||
/** | ||
* 发票的有效期截止时间 | ||
*/ | ||
@SerializedName("end_time") | ||
private Integer endTime; | ||
|
||
/** | ||
* 用户标识 | ||
*/ | ||
private String openid; | ||
|
||
/** | ||
* 发票的类型 | ||
*/ | ||
private String type; | ||
|
||
/** | ||
* 发票的收款方 | ||
*/ | ||
private String payee; | ||
|
||
/** | ||
* 发票详情 | ||
*/ | ||
private String detail; | ||
|
||
/** | ||
* 用户可在发票票面看到的主要信息 | ||
*/ | ||
@SerializedName("user_info") | ||
private InvoiceUserInfo userInfo; | ||
|
||
|
||
public static InvoiceInfoResponse fromJson(String json) { | ||
return WxMaGsonBuilder.create().fromJson(json, InvoiceInfoResponse.class); | ||
} | ||
|
||
|
||
public static List<InvoiceInfoResponse> toList(String json) { | ||
JsonObject jsonObject = GsonParser.parse(json); | ||
return WxMaGsonBuilder.create().fromJson(jsonObject.get("item_list").toString(), | ||
new TypeToken<List<InvoiceInfoResponse>>() { | ||
}.getType()); | ||
} | ||
} |
Oops, something went wrong.