From acc08336226c48b06ad158f5dbaf9dcea2f54f2a Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 2 Nov 2019 21:47:21 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E8=A7=84=E8=8C=83=E5=8C=96=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=92=8C=E5=91=BD?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profitsharing/ProfitSharingRequest.java | 4 +- .../wxpay/service/ProfitSharingService.java | 62 +++++++++---------- .../impl/ProfitSharingServiceImpl.java | 24 +++---- .../impl/ProfitSharingServiceImplTest.java | 12 ++-- 4 files changed, 49 insertions(+), 53 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingRequest.java index aeb2e8175..6e6c2a314 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingRequest.java @@ -78,9 +78,7 @@ public class ProfitSharingRequest extends BaseWxPayRequest { @Override protected void checkConstraints() throws WxPayException { - /** - * 目前仅支持HMAC-SHA256 - */ + // 目前仅支持HMAC-SHA256. this.setSignType(WxPayConstants.SignType.HMAC_SHA256); } } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingService.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingService.java index 8371fcb0b..7f8d6ad33 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingService.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingService.java @@ -3,9 +3,6 @@ package com.github.binarywang.wxpay.service; import com.github.binarywang.wxpay.bean.profitsharing.*; import com.github.binarywang.wxpay.exception.WxPayException; -import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingResult; -import com.github.binarywang.wxpay.bean.profitsharing.ProfitSharingRequest; - /** * 注意:微信最高分账比例为30% * 可多次分账到同一个人,但是依然不能超过30% @@ -22,11 +19,11 @@ public interface ProfitSharingService { * 接口链接:https://api.mch.weixin.qq.com/secapi/pay/profitsharing * * - * @param profitsharingRequest - * @return + * @param request . + * @return . * @throws WxPayException the wx pay exception */ - ProfitSharingResult profitsharing(ProfitSharingRequest profitsharingRequest) throws WxPayException; + ProfitSharingResult profitSharing(ProfitSharingRequest request) throws WxPayException; /** *
@@ -38,11 +35,11 @@ public interface ProfitSharingService {
    * 文档详见: https://pay.weixin.qq.com/wiki/doc/api/allocation_sl.php?chapter=25_6&index=2
    * 接口链接:https://api.mch.weixin.qq.com/secapi/pay/multiprofitsharing
    *
-   * @param profitsharingRequest
-   * @return
+   * @param request .
+   * @return .
    * @throws WxPayException the wx pay exception
    */
-  ProfitSharingResult multiprofitsharing(ProfitSharingRequest profitsharingRequest) throws WxPayException;
+  ProfitSharingResult multiProfitSharing(ProfitSharingRequest request) throws WxPayException;
 
   /**
    * 
@@ -54,11 +51,11 @@ public interface ProfitSharingService {
    * 接口链接:https://api.mch.weixin.qq.com/secapi/pay/profitsharingfinish
    * 
* - * @param profitSharingFinishRequest - * @return + * @param request . + * @return . * @throws WxPayException the wx pay exception */ - ProfitSharingResult profitsharingfinish(ProfitSharingFinishRequest profitSharingFinishRequest) throws WxPayException; + ProfitSharingResult profitSharingFinish(ProfitSharingFinishRequest request) throws WxPayException; /** *
@@ -67,11 +64,11 @@ public interface ProfitSharingService {
    * 接口链接:https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver
    * 
* - * @param profitSharingReceiverRequest - * @return - * @throws WxPayException + * @param request . + * @return . + * @throws WxPayException . */ - ProfitSharingReceiverResult addReceiver(ProfitSharingReceiverRequest profitSharingReceiverRequest) throws WxPayException; + ProfitSharingReceiverResult addReceiver(ProfitSharingReceiverRequest request) throws WxPayException; /** *
@@ -80,11 +77,11 @@ public interface ProfitSharingService {
    * 接口链接:https://api.mch.weixin.qq.com/pay/profitsharingremovereceiver
    * 
* - * @param profitSharingReceiverRequest - * @return - * @throws WxPayException + * @param request . + * @return . + * @throws WxPayException . */ - ProfitSharingReceiverResult removeReceiver(ProfitSharingReceiverRequest profitSharingReceiverRequest) throws WxPayException; + ProfitSharingReceiverResult removeReceiver(ProfitSharingReceiverRequest request) throws WxPayException; /** * TODO:微信返回签名失败 @@ -93,11 +90,11 @@ public interface ProfitSharingService { * 接口频率:80QPS *
* - * @param profitSharingReceiverRequest - * @return - * @throws WxPayException + * @param request . + * @return . + * @throws WxPayException . */ - ProfitSharingQueryResult profitsharingQuery(ProfitSharingQueryRequest profitSharingReceiverRequest) throws WxPayException; + ProfitSharingQueryResult profitSharingQuery(ProfitSharingQueryRequest request) throws WxPayException; /** * TODO:这个接口用真实的数据返回【参数不正确】,我对比官方文档除了缺少sub_mch_id,和sub_appid之外其他相同,当我随便填了一个商户id的时候,提示【回退方没有开通分账回退功能】 @@ -111,11 +108,11 @@ public interface ProfitSharingService { * 接口链接:https://api.mch.weixin.qq.com/secapi/pay/profitsharingreturn * * - * @param profitSharingReturnRequest - * @return - * @throws WxPayException + * @param returnRequest . + * @return . + * @throws WxPayException . */ - ProfitSharingReturnResult profitsharingReturn(ProfitSharingReturnRequest profitSharingReturnRequest) throws WxPayException; + ProfitSharingReturnResult profitSharingReturn(ProfitSharingReturnRequest returnRequest) throws WxPayException; /** * TODO:因profitsharingReturn接口无法使用,没有办法对这里进行真实的测试,模拟数据这里返回【记录不存在】 @@ -127,10 +124,11 @@ public interface ProfitSharingService { * 接口链接:https://api.mch.weixin.qq.com/pay/profitsharingreturnquery * * - * @param profitSharingReturnQueryRequest - * @return - * @throws WxPayException + * @param queryRequest . + * @return . + * @throws WxPayException . */ - ProfitSharingReturnResult profitsharingReturnQuery(ProfitSharingReturnQueryRequest profitSharingReturnQueryRequest) throws WxPayException; + ProfitSharingReturnResult profitSharingReturnQuery(ProfitSharingReturnQueryRequest queryRequest) + throws WxPayException; } diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImpl.java index d660f67c5..114ae023c 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImpl.java @@ -20,7 +20,7 @@ public class ProfitSharingServiceImpl implements ProfitSharingService { } @Override - public ProfitSharingResult profitsharing(ProfitSharingRequest request) throws WxPayException { + public ProfitSharingResult profitSharing(ProfitSharingRequest request) throws WxPayException { request.checkAndSign(this.payService.getConfig()); String url = this.payService.getPayBaseUrl() + "/secapi/pay/profitsharing"; @@ -31,7 +31,7 @@ public class ProfitSharingServiceImpl implements ProfitSharingService { } @Override - public ProfitSharingResult multiprofitsharing(ProfitSharingRequest request) throws WxPayException { + public ProfitSharingResult multiProfitSharing(ProfitSharingRequest request) throws WxPayException { request.checkAndSign(this.payService.getConfig()); String url = this.payService.getPayBaseUrl() + "/secapi/pay/multiprofitsharing"; @@ -42,7 +42,7 @@ public class ProfitSharingServiceImpl implements ProfitSharingService { } @Override - public ProfitSharingResult profitsharingfinish(ProfitSharingFinishRequest request) throws WxPayException { + public ProfitSharingResult profitSharingFinish(ProfitSharingFinishRequest request) throws WxPayException { request.checkAndSign(this.payService.getConfig()); String url = this.payService.getPayBaseUrl() + "/secapi/pay/profitsharingfinish"; @@ -75,7 +75,7 @@ public class ProfitSharingServiceImpl implements ProfitSharingService { } @Override - public ProfitSharingQueryResult profitsharingQuery(ProfitSharingQueryRequest request) throws WxPayException { + public ProfitSharingQueryResult profitSharingQuery(ProfitSharingQueryRequest request) throws WxPayException { if (true) throw new WxPayException("暂不支持,微信一直返回签名失败"); request.checkAndSign(this.payService.getConfig()); String url = this.payService.getPayBaseUrl() + "/pay/profitsharingquery"; @@ -87,24 +87,24 @@ public class ProfitSharingServiceImpl implements ProfitSharingService { } @Override - public ProfitSharingReturnResult profitsharingReturn(ProfitSharingReturnRequest request) throws WxPayException { - request.checkAndSign(this.payService.getConfig()); + public ProfitSharingReturnResult profitSharingReturn(ProfitSharingReturnRequest returnRequest) throws WxPayException { + returnRequest.checkAndSign(this.payService.getConfig()); String url = this.payService.getPayBaseUrl() + "/secapi/pay/profitsharingreturn"; - String responseContent = this.payService.post(url, request.toXML(), true); + String responseContent = this.payService.post(url, returnRequest.toXML(), true); ProfitSharingReturnResult result = BaseWxPayResult.fromXML(responseContent, ProfitSharingReturnResult.class); - result.checkResult(this.payService, request.getSignType(), true); + result.checkResult(this.payService, returnRequest.getSignType(), true); return result; } @Override - public ProfitSharingReturnResult profitsharingReturnQuery(ProfitSharingReturnQueryRequest request) throws WxPayException { - request.checkAndSign(this.payService.getConfig()); + public ProfitSharingReturnResult profitSharingReturnQuery(ProfitSharingReturnQueryRequest queryRequest) throws WxPayException { + queryRequest.checkAndSign(this.payService.getConfig()); String url = this.payService.getPayBaseUrl() + "/pay/profitsharingreturnquery"; - String responseContent = this.payService.post(url, request.toXML(), true); + String responseContent = this.payService.post(url, queryRequest.toXML(), true); ProfitSharingReturnResult result = BaseWxPayResult.fromXML(responseContent, ProfitSharingReturnResult.class); - result.checkResult(this.payService, request.getSignType(), true); + result.checkResult(this.payService, queryRequest.getSignType(), true); return result; } } diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImplTest.java index 44949896e..d21cca55a 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImplTest.java @@ -36,7 +36,7 @@ public class ProfitSharingServiceImplTest { .transactionId("4200000431201910234736634272") .receivers(instance.toJSONString()) .build(); - this.logger.info(this.payService.getProfitSharingService().profitsharing(request).toString()); + this.logger.info(this.payService.getProfitSharingService().profitSharing(request).toString()); } @Test @@ -52,7 +52,7 @@ public class ProfitSharingServiceImplTest { .transactionId("4200000448201910238249687345")//order_id=30000102922019102310821824010 .receivers(instance.toJSONString()) .build(); - this.logger.info(this.payService.getProfitSharingService().multiprofitsharing(request).toString()); + this.logger.info(this.payService.getProfitSharingService().multiProfitSharing(request).toString()); } @Test @@ -63,7 +63,7 @@ public class ProfitSharingServiceImplTest { .transactionId("4200000441201910238267278073") .description("分账完成") .build(); - this.logger.info(this.payService.getProfitSharingService().profitsharingfinish(request).toString()); + this.logger.info(this.payService.getProfitSharingService().profitSharingFinish(request).toString()); } @Test @@ -98,7 +98,7 @@ public class ProfitSharingServiceImplTest { .outOrderNo("20191023112023031060677") .transactionId("4200000431201910234736634272") .build(); - ProfitSharingQueryResult result = this.payService.getProfitSharingService().profitsharingQuery(request); + ProfitSharingQueryResult result = this.payService.getProfitSharingService().profitSharingQuery(request); this.logger.info(result.formatReceivers().toString()); this.logger.info(result.toString()); } @@ -114,7 +114,7 @@ public class ProfitSharingServiceImplTest { .returnAmount(2) .description("用户退款") .build(); - this.logger.info(this.payService.getProfitSharingService().profitsharingReturn(request).toString()); + this.logger.info(this.payService.getProfitSharingService().profitSharingReturn(request).toString()); } @Test @@ -124,7 +124,7 @@ public class ProfitSharingServiceImplTest { .outOrderNo("20191023154723316420060") .outReturnNo("R2019102315") .build(); - this.logger.info(this.payService.getProfitSharingService().profitsharingReturnQuery(request).toString()); + this.logger.info(this.payService.getProfitSharingService().profitSharingReturnQuery(request).toString()); }