Преглед на файлове

:new: #2135 【小程序】实现获取 URL Link接口 以及微信电子发票报销方相关接口

mrxiao преди 3 години
родител
ревизия
8e0a6a3d40
променени са 18 файла, в които са добавени 924 реда и са изтрити 0 реда
  1. 16 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLinkService.java
  2. 48 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaReimburseInvoiceService.java
  3. 12 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java
  4. 12 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java
  5. 35 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLinkServiceImpl.java
  6. 44 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaReimburseInvoiceServiceImpl.java
  7. 41 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/InvoiceBatchRequest.java
  8. 34 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/InvoiceCommodityInfo.java
  9. 53 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/InvoiceInfoRequest.java
  10. 79 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/InvoiceInfoResponse.java
  11. 137 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/InvoiceUserInfo.java
  12. 60 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/UpdateInvoiceStatusRequest.java
  13. 58 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/UpdateStatusBatchRequest.java
  14. 60 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/urllink/CloudBase.java
  15. 85 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/urllink/GenerateUrlLinkRequest.java
  16. 30 0
      weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java
  17. 31 0
      weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLinkServiceImplTest.java
  18. 89 0
      weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaReimburseInvoiceServiceImplTest.java

+ 16 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaLinkService.java

@@ -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 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaReimburseInvoiceService.java

@@ -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;
+}

+ 12 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaService.java

@@ -402,4 +402,16 @@ public interface WxMaService extends WxService {
    * @return
    */
   WxMaShopSpuService getShopSpuService();
+
+  /**
+   * 获取小程序 URL Link服务接口
+   * @return
+   */
+  WxMaLinkService getLinkService();
+
+  /**
+   * 获取电子发票报销方服务接口
+   * @return
+   */
+  WxMaReimburseInvoiceService getReimburseInvoiceService();
 }

+ 12 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java

@@ -65,6 +65,8 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
   private final WxImgProcService imgProcService = new WxMaImgProcServiceImpl(this);
   private final WxMaShopSpuService shopSpuService = new WxMaShopSpuServiceImpl(this);
   private final WxMaShopOrderService shopOrderService = new WxMaShopOrderServiceImpl(this);
+  private final WxMaLinkService linkService = new WxMaLinkServiceImpl(this);
+  private final WxMaReimburseInvoiceService reimburseInvoiceService = new WxMaReimburseInvoiceServiceImpl(this);
   private Map<String, WxMaConfig> configMap;
   private int retrySleepMillis = 1000;
   private int maxRetryTimes = 5;
@@ -512,4 +514,14 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
   public WxMaShopOrderService getShopOrderService() {
     return this.shopOrderService;
   }
+
+  @Override
+  public WxMaLinkService getLinkService() {
+    return this.linkService;
+  }
+
+  @Override
+  public WxMaReimburseInvoiceService getReimburseInvoiceService() {
+    return this.reimburseInvoiceService;
+  }
 }

+ 35 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaLinkServiceImpl.java

@@ -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 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaReimburseInvoiceServiceImpl.java

@@ -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 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/InvoiceBatchRequest.java

@@ -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 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/InvoiceCommodityInfo.java

@@ -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 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/InvoiceInfoRequest.java

@@ -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 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/InvoiceInfoResponse.java

@@ -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());
+  }
+}

+ 137 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/InvoiceUserInfo.java

@@ -0,0 +1,137 @@
+package cn.binarywang.wx.miniapp.bean.invoice.reimburse;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * <pre>
+ * 用户可在发票票面看到的主要信息
+ * </pre>
+ * @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a>
+ * @since 2021-03-23
+ */
+@Data
+public class InvoiceUserInfo {
+
+  /**
+   * 发票加税合计金额,以分为单位
+   */
+  private Integer fee;
+
+  /**
+   * 发票的抬头
+   */
+  private String title;
+
+  /**
+   * 开票时间
+   */
+  @SerializedName("billing_time")
+  private Integer billingTime;
+
+  /**
+   * 发票代码
+   */
+  @SerializedName("billing_no")
+  private String billingNo;
+
+  /**
+   * 发票号码
+   */
+  @SerializedName("billing_code")
+  private String billingCode;
+
+  /**
+   * 不含税金额,以分为单位
+   */
+  @SerializedName("fee_without_tax")
+  private Integer feeWithoutTax;
+
+  /**
+   * 税额,以分为单位
+   */
+  private Integer tax;
+
+  /**
+   * 发票对应的PDF_URL
+   */
+  @SerializedName("pdf_url")
+  private String pdfUrl;
+
+  /**
+   * 其它消费凭证附件对应的URL
+   */
+  @SerializedName("trip_pdf_url")
+  private String tripPdfUrl;
+
+  /**
+   * 发票报销状态
+   */
+  @SerializedName("reimburse_status")
+  private String reimburseStatus;
+
+  /**
+   * 校验码
+   */
+  @SerializedName("check_code")
+  private String checkCode;
+
+  /**
+   * 购买方纳税人识别号
+   */
+  @SerializedName("buyer_number")
+  private String buyerNumber;
+
+  /**
+   * 购买方地址、电话
+   */
+  @SerializedName("buyer_address_and_phone")
+  private String buyerAddressAndPhone;
+
+  /**
+   * 购买方开户行及账号
+   */
+  @SerializedName("buyer_bank_account")
+  private String buyerBankAccount;
+
+  /**
+   * 销售方纳税人识别号
+   */
+  @SerializedName("seller_number")
+  private String sellerNumber;
+
+  /**
+   * 销售方地址、电话
+   */
+  @SerializedName("seller_address_and_phone")
+  private String sellerAddressAndPhone;
+
+  /**
+   * 销售方开户行及账号
+   */
+  @SerializedName("seller_bank_account")
+  private String sellerBankAccount;
+
+  /**
+   * 备注
+   */
+  private String remarks;
+
+  /**
+   * 收款人
+   */
+  private String cashier;
+
+  /**
+   * 开票人
+   */
+  private String maker;
+
+  /**
+   * 商品信息结构
+   */
+  private List<InvoiceCommodityInfo> info;
+}
+

+ 60 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/UpdateInvoiceStatusRequest.java

@@ -0,0 +1,60 @@
+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 UpdateInvoiceStatusRequest implements Serializable {
+
+  private static final long serialVersionUID = -4122242332481909977L;
+
+
+  /**
+   * 发票卡券的card_id
+   * <pre>
+   * 是否必填: 是
+   * </pre>
+   */
+  @SerializedName("card_id")
+  private String cardId;
+
+
+  /**
+   * 发票卡券的加密code,和card_id共同构成一张发票卡券的唯一标识
+   * <pre>
+   * 是否必填: 是
+   * </pre>
+   */
+  @SerializedName("encrypt_code")
+  private String encryptCode;
+
+
+  /**
+   * 发票报销状态
+   * <pre>
+   * 是否必填: 是
+   * </pre>
+   */
+  @SerializedName("reimburse_status")
+  private String reimburseStatus;
+
+
+  public String toJson() {
+    return WxMaGsonBuilder.create().toJson(this);
+  }
+}

+ 58 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/invoice/reimburse/UpdateStatusBatchRequest.java

@@ -0,0 +1,58 @@
+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 UpdateStatusBatchRequest implements Serializable {
+
+  private static final long serialVersionUID = 7016357689566912199L;
+  /**
+   * 用户openid
+   * <pre>
+   * 是否必填: 是
+   * </pre>
+   */
+  private String openid;
+
+  /**
+   * 发票报销状态
+   * <pre>
+   * 是否必填: 是
+   * </pre>
+   */
+  @SerializedName("reimburse_status")
+  private String reimburseStatus;
+
+  /**
+   * 发票列表
+   * <pre>
+   * 是否必填: 是
+   * </pre>
+   */
+  @SerializedName("invoice_list")
+  private List<InvoiceInfoRequest> invoiceList;
+
+
+  public String toJson() {
+    return WxMaGsonBuilder.create().toJson(this);
+  }
+
+}

+ 60 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/urllink/CloudBase.java

@@ -0,0 +1,60 @@
+package cn.binarywang.wx.miniapp.bean.urllink;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Builder;
+import lombok.Data;
+
+/**
+ * <pre>
+ * 云开发静态网站自定义 H5 配置参数
+ * </pre>
+ * @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a>
+ * @since 2021-06-11
+ */
+@Data
+@Builder
+public class CloudBase {
+
+  /**
+   * 云开发环境
+   * <pre>
+   * 是否必填: 是
+   * </pre>
+   */
+  private String env;
+
+  /**
+   * 静态网站自定义域名,不填则使用默认域名
+   * <pre>
+   * 是否必填: 否
+   * </pre>
+   */
+  private String domain;
+
+  /**
+   * 云开发静态网站 H5 页面路径,不可携带 query
+   * <pre>
+   * 默认值:/
+   * 是否必填: 否
+   * </pre>
+   */
+  private String path;
+
+  /**
+   * 云开发静态网站 H5 页面 query 参数,最大 1024 个字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~
+   * <pre>
+   * 是否必填: 否
+   * </pre>
+   */
+  private String query;
+
+  /**
+   * 第三方批量代云开发时必填,表示创建该 env 的 appid (小程序/第三方平台)
+   * <pre>
+   * 是否必填: 否
+   * </pre>
+   */
+  @SerializedName("resource_appid")
+  private String resourceAppid;
+
+}

+ 85 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bean/urllink/GenerateUrlLinkRequest.java

@@ -0,0 +1,85 @@
+package cn.binarywang.wx.miniapp.bean.urllink;
+
+import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
+import com.google.gson.annotations.SerializedName;
+import lombok.Builder;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * <pre>
+ * 获取小程序 URL Link参数对象
+ * </pre>
+ * @author <a href="https://github.com/mr-xiaoyu">xiaoyu</a>
+ * @since 2021-06-11
+ */
+@Data
+@Builder
+public class GenerateUrlLinkRequest implements Serializable {
+
+  private static final long serialVersionUID = -2183685760797791910L;
+
+  /**
+   * 通过 URL Link 进入的小程序页面路径,必须是已经发布的小程序存在的页面,不可携带 query 。path 为空时会跳转小程序主页
+   * <pre>
+   * 是否必填: 是
+   * </pre>
+   */
+  private String path;
+
+  /**
+   * 通过 URL Link 进入小程序时的query,最大1024个字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~
+   * <pre>
+   * 是否必填: 是
+   * </pre>
+   */
+  private String query;
+
+  /**
+   * 生成的 URL Link 类型,到期失效:true,永久有效:false
+   * <pre>
+   * 默认值:false
+   * 是否必填: 否
+   * </pre>
+   */
+  @SerializedName("is_expire")
+  private Boolean isExpire;
+
+  /**
+   * 小程序 URL Link 失效类型,失效时间:0,失效间隔天数:1
+   * <pre>
+   * 是否必填: 是
+   * </pre>
+   */
+  @SerializedName("expire_type")
+  private Integer expireType;
+
+  /**
+   * 到期失效的 URL Link 的失效时间,为 Unix 时间戳。生成的到期失效 URL Link 在该时间前有效。最长有效期为1年。expire_type 为 0 必填
+   * <pre>
+   * 是否必填: 是
+   * </pre>
+   */
+  @SerializedName("expire_time")
+  private Integer expireTime;
+
+  /**
+   * 到期失效的URL Link的失效间隔天数。生成的到期失效URL Link在该间隔时间到达前有效。最长间隔天数为365天。expire_type 为 1 必填
+   * <pre>
+   * 是否必填: 是
+   * </pre>
+   */
+  @SerializedName("expire_interval")
+  private Integer expireInterval;
+
+  /**
+   * 云开发静态网站自定义 H5 配置参数,可配置中转的云开发 H5 页面。不填默认用官方 H5 页面
+   * <pre>
+   * 是否必填: 否
+   * </pre>
+   */
+  @SerializedName("cloud_base")
+  private CloudBase cloudBase;
+
+}

+ 30 - 0
weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/constant/WxMaApiUrlConstants.java

@@ -222,6 +222,10 @@ public class WxMaApiUrlConstants {
     String GENERATE_SCHEME_URL = "https://api.weixin.qq.com/wxa/generatescheme";
   }
 
+  public interface Link {
+    String GENERATE_URLLINK_URL = "https://api.weixin.qq.com/wxa/generate_urllink";
+  }
+
   public interface SecCheck {
     String IMG_SEC_CHECK_URL = "https://api.weixin.qq.com/wxa/img_sec_check";
     String MSG_SEC_CHECK_URL = "https://api.weixin.qq.com/wxa/msg_sec_check";
@@ -316,4 +320,30 @@ public class WxMaApiUrlConstants {
       String ORDER_GET = "https://api.weixin.qq.com/shop/order/get";
     }
   }
+
+  /**
+   * 电子发票报销方
+   */
+  public interface Invoice{
+
+    /**
+     * 报销方查询报销发票信息
+     */
+    String GET_INVOICE_INFO = "https://api.weixin.qq.com/card/invoice/reimburse/getinvoiceinfo";
+
+    /**
+     * 报销方批量查询报销发票信息
+     */
+    String GET_INVOICE_BATCH = "https://api.weixin.qq.com/card/invoice/reimburse/getinvoicebatch";
+
+    /**
+     * 报销方更新发票状态
+     */
+    String UPDATE_INVOICE_STATUS = "https://api.weixin.qq.com/card/invoice/reimburse/updateinvoicestatus";
+
+    /**
+     * 报销方批量更新发票状态
+     */
+    String UPDATE_STATUS_BATCH = "https://api.weixin.qq.com/card/invoice/reimburse/updatestatusbatch";
+  }
 }

+ 31 - 0
weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaLinkServiceImplTest.java

@@ -0,0 +1,31 @@
+package cn.binarywang.wx.miniapp.api.impl;
+
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.urllink.GenerateUrlLinkRequest;
+import cn.binarywang.wx.miniapp.test.ApiTestModule;
+import com.google.inject.Inject;
+import me.chanjar.weixin.common.error.WxErrorException;
+import org.testng.annotations.Guice;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.*;
+
+@Test
+@Guice(modules = ApiTestModule.class)
+public class WxMaLinkServiceImplTest {
+
+  @Inject
+  private WxMaService wxMaService;
+
+  @Test
+  public void testGenerate() throws WxErrorException {
+
+    GenerateUrlLinkRequest request = GenerateUrlLinkRequest.builder()
+      .path("pages/tabBar/home/home")
+      .build();
+
+    String url = this.wxMaService.getLinkService().generate(request);
+
+    System.out.println(url);
+  }
+}

+ 89 - 0
weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaReimburseInvoiceServiceImplTest.java

@@ -0,0 +1,89 @@
+package cn.binarywang.wx.miniapp.api.impl;
+
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.invoice.reimburse.*;
+import cn.binarywang.wx.miniapp.test.ApiTestModule;
+import com.google.gson.GsonBuilder;
+import com.google.inject.Inject;
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxErrorException;
+import org.testng.annotations.Guice;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.testng.Assert.*;
+
+@Slf4j
+@Test
+@Guice(modules = ApiTestModule.class)
+public class WxMaReimburseInvoiceServiceImplTest {
+
+  @Inject
+  private WxMaService wxMaService;
+
+  @Test
+  public void testGetInvoiceInfo() throws WxErrorException {
+
+    InvoiceInfoRequest request = InvoiceInfoRequest.builder()
+      .cardId("**********************")
+      .encryptCode("**********************")
+      .build();
+
+    InvoiceInfoResponse response = this.wxMaService.getReimburseInvoiceService().getInvoiceInfo(request);
+
+    log.info("response: {}", new GsonBuilder().create().toJson(response));
+  }
+
+  @Test
+  public void testGetInvoiceBatch() throws WxErrorException {
+
+    List<InvoiceInfoRequest> invoices = new ArrayList<>();
+    InvoiceInfoRequest r = InvoiceInfoRequest.builder()
+      .cardId("**********************")
+      .encryptCode("********************************************")
+      .build();
+    invoices.add(r);
+    r = InvoiceInfoRequest.builder()
+      .cardId("**********************")
+      .encryptCode("********************************************")
+      .build();
+    invoices.add(r);
+
+    InvoiceBatchRequest request = InvoiceBatchRequest.builder().itemList(invoices).build();
+
+    List<InvoiceInfoResponse> responses = this.wxMaService.getReimburseInvoiceService().getInvoiceBatch(request);
+    log.info("responses: {}",new GsonBuilder().create().toJson(responses));
+  }
+
+  @Test
+  public void testUpdateInvoiceStatus() throws WxErrorException {
+    UpdateInvoiceStatusRequest request = UpdateInvoiceStatusRequest.builder()
+      .cardId("**********************")
+      .encryptCode("********************************************")
+      .reimburseStatus("INVOICE_REIMBURSE_INIT")
+      .build();
+
+    this.wxMaService.getReimburseInvoiceService().updateInvoiceStatus(request);
+  }
+
+  @Test
+  public void testUpdateStatusBatch() throws WxErrorException {
+
+    List<InvoiceInfoRequest> invoices = new ArrayList<>();
+    InvoiceInfoRequest r = InvoiceInfoRequest.builder()
+      .cardId("**************")
+      .encryptCode("**************")
+      .build();
+    invoices.add(r);
+
+    UpdateStatusBatchRequest request = UpdateStatusBatchRequest.builder()
+      .invoiceList(invoices)
+      .openid("**************")
+      .reimburseStatus("INVOICE_REIMBURSE_LOCK")
+      .build();
+
+    this.wxMaService.getReimburseInvoiceService().updateStatusBatch(request);
+  }
+}