|
@@ -182,6 +182,14 @@ public class EcommerceServiceImpl implements EcommerceService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public ProfitSharingResult queryProfitSharing(ProfitSharingQueryRequest request) throws WxPayException {
|
|
|
+ String url = String.format("%s/v3/ecommerce/profitsharing/orders?sub_mchid=%s&transaction_id=%s&out_order_no=%s",
|
|
|
+ this.payService.getPayBaseUrl(), request.getSubMchid(), request.getTransactionId(), request.getOutOrderNo());
|
|
|
+ String response = this.payService.getV3(URI.create(url));
|
|
|
+ return GSON.fromJson(response, ProfitSharingResult.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public ReturnOrdersResult returnOrders(ReturnOrdersRequest request) throws WxPayException {
|
|
|
String url = String.format("%s/v3/ecommerce/profitsharing/returnorders", this.payService.getPayBaseUrl());
|
|
|
String response = this.payService.postV3(url, GSON.toJson(request));
|
|
@@ -203,6 +211,41 @@ public class EcommerceServiceImpl implements EcommerceService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public RefundQueryResult queryRefundByRefundId(String subMchid, String refundId) throws WxPayException {
|
|
|
+ String url = String.format("%s/v3/ecommerce/refunds/id/%s?sub_mchid=%s", this.payService.getPayBaseUrl(), refundId, subMchid);
|
|
|
+ String response = this.payService.getV3(URI.create(url));
|
|
|
+ return GSON.fromJson(response, RefundQueryResult.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RefundQueryResult queryRefundByOutRefundNo(String subMchid, String outRefundNo) throws WxPayException {
|
|
|
+ String url = String.format("%s/v3/ecommerce/applyments/out-request-no/%s?sub_mchid=%s", this.payService.getPayBaseUrl(), outRefundNo, subMchid);
|
|
|
+ String response = this.payService.getV3(URI.create(url));
|
|
|
+ return GSON.fromJson(response, RefundQueryResult.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public RefundNotifyResult parseRefundNotifyResult(String notifyData, SignatureHeader header) throws WxPayException {
|
|
|
+ if(Objects.nonNull(header) && !this.verifyNotifySign(header, notifyData)){
|
|
|
+ throw new WxPayException("非法请求,头部信息验证失败");
|
|
|
+ }
|
|
|
+ NotifyResponse response = GSON.fromJson(notifyData, NotifyResponse.class);
|
|
|
+ NotifyResponse.Resource resource = response.getResource();
|
|
|
+ String cipherText = resource.getCiphertext();
|
|
|
+ String associatedData = resource.getAssociatedData();
|
|
|
+ String nonce = resource.getNonce();
|
|
|
+ String apiV3Key = this.payService.getConfig().getApiV3Key();
|
|
|
+ try {
|
|
|
+ String result = AesUtils.decryptToString(associatedData, nonce,cipherText, apiV3Key);
|
|
|
+ RefundNotifyResult notifyResult = GSON.fromJson(result, RefundNotifyResult.class);
|
|
|
+ notifyResult.setRawData(response);
|
|
|
+ return notifyResult;
|
|
|
+ } catch (GeneralSecurityException | IOException e) {
|
|
|
+ throw new WxPayException("解析报文异常!", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public SubWithdrawResult subWithdraw(SubWithdrawRequest request) throws WxPayException {
|
|
|
String url = String.format("%s/v3/ecommerce/fund/withdraw", this.payService.getPayBaseUrl());
|
|
|
String response = this.payService.postV3(url, GSON.toJson(request));
|
|
@@ -216,6 +259,20 @@ public class EcommerceServiceImpl implements EcommerceService {
|
|
|
return GSON.fromJson(response, SpWithdrawResult.class);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void modifySettlement(String subMchid, SettlementRequest request) throws WxPayException {
|
|
|
+ String url = String.format("%s/v3/apply4sub/sub_merchants/%s/modify-settlement", this.payService.getPayBaseUrl(), subMchid);
|
|
|
+ RsaCryptoUtil.encryptFields(request, this.payService.getConfig().getVerifier().getValidCertificate());
|
|
|
+ this.payService.postV3WithWechatpaySerial(url, GSON.toJson(request));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public SettlementResult querySettlement(String subMchid) throws WxPayException {
|
|
|
+ String url = String.format("%s/v3/apply4sub/sub_merchants/%s/settlement", this.payService.getPayBaseUrl(), subMchid);
|
|
|
+ String response = this.payService.getV3(URI.create(url));
|
|
|
+ return GSON.fromJson(response, SettlementResult.class);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 校验通知签名
|
|
|
* @param header 通知头信息
|