mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
✨ #1010 微信支付模块增加单次分账接口
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.github.binarywang.wxpay.service;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingResult;
|
||||
import com.github.binarywang.wxpay.bean.profitsharing.ProfitsharingRequest;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
|
||||
/**
|
||||
* @author Wang GuangXin 2019/10/22 10:05
|
||||
* @version 1.0
|
||||
*/
|
||||
public interface ProfitSharingService {
|
||||
/**
|
||||
* 单次分账请求按照传入的分账接收方账号和资金进行分账,同时会将订单剩余的待分账金额解冻给特约商户。故操作成功后,订单不能再进行分账,也不能进行分账完结。
|
||||
* <p>
|
||||
* 接口频率:30QPS
|
||||
* 文档详见: https://pay.weixin.qq.com/wiki/doc/api/allocation_sl.php?chapter=25_1&index=1
|
||||
* 接口链接:https://api.mch.weixin.qq.com/secapi/pay/profitsharing
|
||||
*
|
||||
* @param profitsharingRequest
|
||||
* @return
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
ProfitSharingResult profitsharing(ProfitsharingRequest profitsharingRequest) throws WxPayException;
|
||||
|
||||
;
|
||||
}
|
||||
@@ -65,6 +65,13 @@ public interface WxPayService {
|
||||
*/
|
||||
EntPayService getEntPayService();
|
||||
|
||||
/**
|
||||
* 获取分账服务类.
|
||||
*
|
||||
* @return the ent pay service
|
||||
*/
|
||||
ProfitSharingService getProfitSharingService();
|
||||
|
||||
/**
|
||||
* 设置企业付款服务类,允许开发者自定义实现类.
|
||||
*
|
||||
@@ -304,6 +311,7 @@ public interface WxPayService {
|
||||
* @throws WxPayException the wx pay exception
|
||||
*/
|
||||
WxPayRedpackQueryResult queryRedpack(String mchBillNo) throws WxPayException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 查询红包记录.
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.github.binarywang.wxpay.constant.WxPayConstants.SignType;
|
||||
import com.github.binarywang.wxpay.constant.WxPayConstants.TradeType;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.service.EntPayService;
|
||||
import com.github.binarywang.wxpay.service.ProfitSharingService;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import com.github.binarywang.wxpay.util.SignUtils;
|
||||
import com.google.common.base.Joiner;
|
||||
@@ -59,7 +60,7 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
|
||||
static ThreadLocal<WxPayApiData> wxApiData = new ThreadLocal<>();
|
||||
|
||||
private EntPayService entPayService = new EntPayServiceImpl(this);
|
||||
|
||||
private ProfitSharingService profitSharingService = new ProfitSharingServiceImpl(this);
|
||||
/**
|
||||
* The Config.
|
||||
*/
|
||||
@@ -70,6 +71,11 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
|
||||
return entPayService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfitSharingService getProfitSharingService() {
|
||||
return profitSharingService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntPayService(EntPayService entPayService) {
|
||||
this.entPayService = entPayService;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.github.binarywang.wxpay.service.impl;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.entpay.EntPayResult;
|
||||
import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingResult;
|
||||
import com.github.binarywang.wxpay.bean.profitsharing.ProfitsharingRequest;
|
||||
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.service.ProfitSharingService;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
|
||||
/**
|
||||
* @author Wang GuangXin 2019/10/22 10:13
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ProfitSharingServiceImpl implements ProfitSharingService {
|
||||
private WxPayService payService;
|
||||
public ProfitSharingServiceImpl(WxPayService payService) {
|
||||
this.payService = payService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfitSharingResult profitsharing(ProfitsharingRequest request) throws WxPayException {
|
||||
request.checkAndSign(this.payService.getConfig());
|
||||
String url = this.payService.getPayBaseUrl() + "/secapi/pay/profitsharing";
|
||||
|
||||
String responseContent = this.payService.post(url, request.toXML(), true);
|
||||
ProfitSharingResult result = BaseWxPayResult.fromXML(responseContent, ProfitSharingResult.class);
|
||||
result.checkResult(this.payService, request.getSignType(), true);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user