支持分账

This commit is contained in:
2025-07-07 17:39:15 +08:00
parent f84adc8ebe
commit ecc011269c
2 changed files with 9 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ import com.wechat.pay.java.service.payments.jsapi.model.Payer;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayResponse;
import com.wechat.pay.java.service.payments.jsapi.model.QueryOrderByOutTradeNoRequest;
import com.wechat.pay.java.service.payments.jsapi.model.SettleInfo;
import com.wechat.pay.java.service.payments.model.Transaction;
import com.wechat.pay.java.service.refund.RefundService;
import com.wechat.pay.java.service.refund.model.AmountReq;
@@ -77,12 +78,15 @@ public class WxMpPayAdapter implements IPayAdapter {
this.config.setWxPublicKey(_config.get("wxPublicKey"));
this.config.setWxPublicKeyId(_config.get("wxPublicKeyId"));
this.config.setApiV3Key(_config.get("apiV3Key"));
if (_config.containsKey("enableProfitSharing")) {
this.config.setEnableProfitSharing(_config.get("enableProfitSharing").equals("true"));
}
}
}
private Config clientConfig;
private Config getConfig() {
public Config getConfig() {
if (clientConfig == null) {
if (StringUtils.isNotBlank(config.getWxPublicKeyId())) {
clientConfig = new RSAPublicKeyConfig.Builder()
@@ -126,6 +130,9 @@ public class WxMpPayAdapter implements IPayAdapter {
Payer payer = new Payer();
payer.setOpenid(request.getUserIdentify());
prepayRequest.setPayer(payer);
SettleInfo settleInfo = new SettleInfo();
settleInfo.setProfitSharing(config.isEnableProfitSharing());
prepayRequest.setSettleInfo(settleInfo);
PrepayResponse response = service.prepay(prepayRequest);
resp.setSuccess(true);
resp.setSkipPay(false);

View File

@@ -11,4 +11,5 @@ public class WxMpPayConfig {
private String wxPublicKeyId;
private String serialNumber;
private String apiV3Key;
private boolean enableProfitSharing;
}