mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🆕 #2135 【小程序】实现获取 URL Link接口 以及微信电子发票报销方相关接口
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -402,4 +402,16 @@ public interface WxMaService extends WxService {
|
||||
* @return
|
||||
*/
|
||||
WxMaShopSpuService getShopSpuService();
|
||||
|
||||
/**
|
||||
* 获取小程序 URL Link服务接口
|
||||
* @return
|
||||
*/
|
||||
WxMaLinkService getLinkService();
|
||||
|
||||
/**
|
||||
* 获取电子发票报销方服务接口
|
||||
* @return
|
||||
*/
|
||||
WxMaReimburseInvoiceService getReimburseInvoiceService();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user