:new:【微信支付】增加查询结算账户、查询分账结果、查询分账回退结果和申请分账账单等V3接口

This commit is contained in:
NotePlus
2022-12-25 14:38:26 +00:00
committed by binarywang
parent 87c33ac776
commit 0d1320a48f
7 changed files with 220 additions and 6 deletions

View File

@@ -49,8 +49,8 @@ public interface Applyment4SubService {
ApplymentStateQueryResult queryApplyStatusByApplymentId(String applymentId) throws WxPayException;
/**
* 通过申请单号查询申请状态
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/tool/applyment4sub/chapter3_4.shtml
* 根据特约子商户ID查询结算账户
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter11_1_4.shtml
* 接口链接https://api.mch.weixin.qq.com/v3/apply4sub/sub_merchants/{sub_mchid}/settlement
*
* @param subMchid 本服务商进件、已签约的特约商户号。
@@ -61,7 +61,7 @@ public interface Applyment4SubService {
/**
* 修改结算帐号
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/tool/applyment4sub/chapter3_3.shtml
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter11_1_3.shtml
* 接口链接https://api.mch.weixin.qq.com/v3/apply4sub/sub_merchants/{sub_mchid}/modify-settlement
*
* @param subMchid 特约商户号

View File

@@ -51,7 +51,7 @@ public interface ProfitSharingV3Service {
/**
* <pre>
* 查询分账结果API
* 查询分账结果API(商户平台)
*
* 发起分账请求后,可调用此接口查询分账结果
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_2.shtml
@@ -69,6 +69,27 @@ public interface ProfitSharingV3Service {
*/
ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId) throws WxPayException;
/**
* <pre>
* 查询分账结果API服务商平台
*
* 发起分账请求后,可调用此接口查询分账结果
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_2.shtml
* 接口链接https://api.mch.weixin.qq.com/v3/profitsharing/orders/{out_order_no}
*
* 注意:
* • 发起解冻剩余资金请求后,可调用此接口查询解冻剩余资金的结果
* </pre>
*
* @param outOrderNo 商户系统内部的分账单号在商户系统内部唯一同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@ 。
* @param transactionId 微信支付订单号
* @param subMchId 微信支付分配的子商户号,即分账的出资商户号。
* @return {@link ProfitSharingResult} 微信返回的分账结果
* @throws WxPayException the wx pay exception
* @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_2.shtml">微信文档</a>
*/
ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId, String subMchId) throws WxPayException;
/**
* <pre>
* 请求分账回退API
@@ -94,7 +115,7 @@ public interface ProfitSharingV3Service {
/**
* <pre>
* 查询分账回退结果API
* 查询分账回退结果API(商户平台)
*
* 商户需要核实回退结果,可调用此接口查询回退结果
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_4.shtml
@@ -112,6 +133,27 @@ public interface ProfitSharingV3Service {
*/
ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo) throws WxPayException;
/**
* <pre>
* 查询分账回退结果API服务商平台
*
* 商户需要核实回退结果,可调用此接口查询回退结果
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_3.shtml
* 接口链接https://api.mch.weixin.qq.com/v3/profitsharing/return-orders/{out_return_no}
*
* 注意:
* • 如果分账回退接口返回状态为处理中,可调用此接口查询回退结果
* </pre>
*
* @param outOrderNo 原发起分账请求时使用的商户系统内部的分账单号
* @param outReturnNo 调用回退接口提供的商户系统内部的回退单号
* @param subMchId 微信支付分配的子商户号,即分账的回退方商户号。
* @return {@link ProfitSharingReturnResult} 微信返回的分账回退结果
* @throws WxPayException the wx pay exception
* @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_3.shtml">微信文档</a>
*/
ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo, String subMchId) throws WxPayException;
/**
* <pre>
* 解冻剩余资金API
@@ -198,4 +240,21 @@ public interface ProfitSharingV3Service {
*/
ProfitSharingNotifyData getProfitSharingNotifyData(String notifyData, SignatureHeader header) throws WxPayException;
/**
* <pre>
* 申请分账账单
*
* 微信支付按天提供分账账单文件,商户可以通过该接口获取账单文件的下载地址
* 文档详见: https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_11.shtml
* 接口链接: https://api.mch.weixin.qq.com/v3/profitsharing/bills
* </pre>
*
* @param request 申请分账账单请求实体({@link ProfitSharingBillRequest}
* @return {@link ProfitSharingBillResult} 申请分账账单结果类
* @throws WxPayException the wx pay exception
* @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_11.shtml">服务商平台>>API字典>>资金应用>>分账>>申请分账账单API</a>
* @since 4.4.0
* @date 2022-12-09
*/
ProfitSharingBillResult getProfitSharingBill(ProfitSharingBillRequest request) throws WxPayException;
}

View File

@@ -12,6 +12,7 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -52,6 +53,13 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service {
return GSON.fromJson(result, ProfitSharingResult.class);
}
@Override
public ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId, String subMchId) throws WxPayException {
String url = String.format("%s/v3/profitsharing/orders/%s?sub_mchid=%s&transaction_id=%s", this.payService.getPayBaseUrl(), outOrderNo, subMchId, transactionId);
String result = this.payService.getV3(url);
return GSON.fromJson(result, ProfitSharingResult.class);
}
@Override
public ProfitSharingReturnResult profitSharingReturn(ProfitSharingReturnRequest request) throws WxPayException {
String url = String.format("%s/v3/profitsharing/return-orders", this.payService.getPayBaseUrl());
@@ -67,6 +75,13 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service {
return GSON.fromJson(result, ProfitSharingReturnResult.class);
}
@Override
public ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo, String subMchId) throws WxPayException {
String url = String.format("%s/v3/profitsharing/return-orders/%s?sub_mchid=%s&out_order_no=%s", this.payService.getPayBaseUrl(), outReturnNo, subMchId, outOrderNo);
String result = this.payService.getV3(url);
return GSON.fromJson(result, ProfitSharingReturnResult.class);
}
@Override
public ProfitSharingUnfreezeResult profitSharingUnfreeze(ProfitSharingUnfreezeRequest request) throws WxPayException {
String url = String.format("%s/v3/profitsharing/orders/unfreeze", this.payService.getPayBaseUrl());
@@ -115,6 +130,19 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service {
}
}
@Override
public ProfitSharingBillResult getProfitSharingBill(ProfitSharingBillRequest request) throws WxPayException {
String url = String.format("%s/v3/profitsharing/bills?bill_date=%s", this.payService.getPayBaseUrl(), request.getBillDate());
if (StringUtils.isNotBlank(request.getSubMchId())) {
url = String.format("%s&sub_mchid=%s", url, request.getSubMchId());
}
if (StringUtils.isNotBlank(request.getTarType())) {
url = String.format("%s&tar_type=%s", url, request.getTarType());
}
String result = this.payService.getV3(url);
return GSON.fromJson(result, ProfitSharingBillResult.class);
}
private ProfitSharingNotifyData parseNotifyData(String data, SignatureHeader header) throws WxPayException {
if (Objects.nonNull(header) && !this.verifyNotifySign(header, data)) {
throw new WxPayException("非法请求,头部信息验证失败");