🎨 规范化部分代码格式和命名

This commit is contained in:
Binary Wang 2019-11-02 21:47:21 +08:00
parent 913aec6e93
commit acc0833622
4 changed files with 49 additions and 53 deletions

View File

@ -78,9 +78,7 @@ public class ProfitSharingRequest extends BaseWxPayRequest {
@Override @Override
protected void checkConstraints() throws WxPayException { protected void checkConstraints() throws WxPayException {
/** // 目前仅支持HMAC-SHA256.
* 目前仅支持HMAC-SHA256
*/
this.setSignType(WxPayConstants.SignType.HMAC_SHA256); this.setSignType(WxPayConstants.SignType.HMAC_SHA256);
} }
} }

View File

@ -3,9 +3,6 @@ package com.github.binarywang.wxpay.service;
import com.github.binarywang.wxpay.bean.profitsharing.*; import com.github.binarywang.wxpay.bean.profitsharing.*;
import com.github.binarywang.wxpay.exception.WxPayException; 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%
* 可多次分账到同一个人但是依然不能超过30% * 可多次分账到同一个人但是依然不能超过30%
@ -22,11 +19,11 @@ public interface ProfitSharingService {
* 接口链接https://api.mch.weixin.qq.com/secapi/pay/profitsharing * 接口链接https://api.mch.weixin.qq.com/secapi/pay/profitsharing
* </pre> * </pre>
* *
* @param profitsharingRequest * @param request .
* @return * @return .
* @throws WxPayException the wx pay exception * @throws WxPayException the wx pay exception
*/ */
ProfitSharingResult profitsharing(ProfitSharingRequest profitsharingRequest) throws WxPayException; ProfitSharingResult profitSharing(ProfitSharingRequest request) throws WxPayException;
/** /**
* <pre> * <pre>
@ -38,11 +35,11 @@ public interface ProfitSharingService {
* 文档详见: https://pay.weixin.qq.com/wiki/doc/api/allocation_sl.php?chapter=25_6&index=2 * 文档详见: 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 * 接口链接https://api.mch.weixin.qq.com/secapi/pay/multiprofitsharing
* *
* @param profitsharingRequest * @param request .
* @return * @return .
* @throws WxPayException the wx pay exception * @throws WxPayException the wx pay exception
*/ */
ProfitSharingResult multiprofitsharing(ProfitSharingRequest profitsharingRequest) throws WxPayException; ProfitSharingResult multiProfitSharing(ProfitSharingRequest request) throws WxPayException;
/** /**
* <pre> * <pre>
@ -54,11 +51,11 @@ public interface ProfitSharingService {
* 接口链接https://api.mch.weixin.qq.com/secapi/pay/profitsharingfinish * 接口链接https://api.mch.weixin.qq.com/secapi/pay/profitsharingfinish
* </pre> * </pre>
* *
* @param profitSharingFinishRequest * @param request .
* @return * @return .
* @throws WxPayException the wx pay exception * @throws WxPayException the wx pay exception
*/ */
ProfitSharingResult profitsharingfinish(ProfitSharingFinishRequest profitSharingFinishRequest) throws WxPayException; ProfitSharingResult profitSharingFinish(ProfitSharingFinishRequest request) throws WxPayException;
/** /**
* <pre> * <pre>
@ -67,11 +64,11 @@ public interface ProfitSharingService {
* 接口链接https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver * 接口链接https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver
* </pre> * </pre>
* *
* @param profitSharingReceiverRequest * @param request .
* @return * @return .
* @throws WxPayException * @throws WxPayException .
*/ */
ProfitSharingReceiverResult addReceiver(ProfitSharingReceiverRequest profitSharingReceiverRequest) throws WxPayException; ProfitSharingReceiverResult addReceiver(ProfitSharingReceiverRequest request) throws WxPayException;
/** /**
* <pre> * <pre>
@ -80,11 +77,11 @@ public interface ProfitSharingService {
* 接口链接https://api.mch.weixin.qq.com/pay/profitsharingremovereceiver * 接口链接https://api.mch.weixin.qq.com/pay/profitsharingremovereceiver
* </pre> * </pre>
* *
* @param profitSharingReceiverRequest * @param request .
* @return * @return .
* @throws WxPayException * @throws WxPayException .
*/ */
ProfitSharingReceiverResult removeReceiver(ProfitSharingReceiverRequest profitSharingReceiverRequest) throws WxPayException; ProfitSharingReceiverResult removeReceiver(ProfitSharingReceiverRequest request) throws WxPayException;
/** /**
* TODO:微信返回签名失败 * TODO:微信返回签名失败
@ -93,11 +90,11 @@ public interface ProfitSharingService {
* 接口频率80QPS * 接口频率80QPS
* </pre> * </pre>
* *
* @param profitSharingReceiverRequest * @param request .
* @return * @return .
* @throws WxPayException * @throws WxPayException .
*/ */
ProfitSharingQueryResult profitsharingQuery(ProfitSharingQueryRequest profitSharingReceiverRequest) throws WxPayException; ProfitSharingQueryResult profitSharingQuery(ProfitSharingQueryRequest request) throws WxPayException;
/** /**
* TODO:这个接口用真实的数据返回参数不正确我对比官方文档除了缺少sub_mch_id和sub_appid之外其他相同当我随便填了一个商户id的时候提示回退方没有开通分账回退功能 * TODO:这个接口用真实的数据返回参数不正确我对比官方文档除了缺少sub_mch_id和sub_appid之外其他相同当我随便填了一个商户id的时候提示回退方没有开通分账回退功能
@ -111,11 +108,11 @@ public interface ProfitSharingService {
* 接口链接https://api.mch.weixin.qq.com/secapi/pay/profitsharingreturn * 接口链接https://api.mch.weixin.qq.com/secapi/pay/profitsharingreturn
* </pre> * </pre>
* *
* @param profitSharingReturnRequest * @param returnRequest .
* @return * @return .
* @throws WxPayException * @throws WxPayException .
*/ */
ProfitSharingReturnResult profitsharingReturn(ProfitSharingReturnRequest profitSharingReturnRequest) throws WxPayException; ProfitSharingReturnResult profitSharingReturn(ProfitSharingReturnRequest returnRequest) throws WxPayException;
/** /**
* TODO:因profitsharingReturn接口无法使用没有办法对这里进行真实的测试模拟数据这里返回记录不存在 * TODO:因profitsharingReturn接口无法使用没有办法对这里进行真实的测试模拟数据这里返回记录不存在
@ -127,10 +124,11 @@ public interface ProfitSharingService {
* 接口链接https://api.mch.weixin.qq.com/pay/profitsharingreturnquery * 接口链接https://api.mch.weixin.qq.com/pay/profitsharingreturnquery
* </pre> * </pre>
* *
* @param profitSharingReturnQueryRequest * @param queryRequest .
* @return * @return .
* @throws WxPayException * @throws WxPayException .
*/ */
ProfitSharingReturnResult profitsharingReturnQuery(ProfitSharingReturnQueryRequest profitSharingReturnQueryRequest) throws WxPayException; ProfitSharingReturnResult profitSharingReturnQuery(ProfitSharingReturnQueryRequest queryRequest)
throws WxPayException;
} }

View File

@ -20,7 +20,7 @@ public class ProfitSharingServiceImpl implements ProfitSharingService {
} }
@Override @Override
public ProfitSharingResult profitsharing(ProfitSharingRequest request) throws WxPayException { public ProfitSharingResult profitSharing(ProfitSharingRequest request) throws WxPayException {
request.checkAndSign(this.payService.getConfig()); request.checkAndSign(this.payService.getConfig());
String url = this.payService.getPayBaseUrl() + "/secapi/pay/profitsharing"; String url = this.payService.getPayBaseUrl() + "/secapi/pay/profitsharing";
@ -31,7 +31,7 @@ public class ProfitSharingServiceImpl implements ProfitSharingService {
} }
@Override @Override
public ProfitSharingResult multiprofitsharing(ProfitSharingRequest request) throws WxPayException { public ProfitSharingResult multiProfitSharing(ProfitSharingRequest request) throws WxPayException {
request.checkAndSign(this.payService.getConfig()); request.checkAndSign(this.payService.getConfig());
String url = this.payService.getPayBaseUrl() + "/secapi/pay/multiprofitsharing"; String url = this.payService.getPayBaseUrl() + "/secapi/pay/multiprofitsharing";
@ -42,7 +42,7 @@ public class ProfitSharingServiceImpl implements ProfitSharingService {
} }
@Override @Override
public ProfitSharingResult profitsharingfinish(ProfitSharingFinishRequest request) throws WxPayException { public ProfitSharingResult profitSharingFinish(ProfitSharingFinishRequest request) throws WxPayException {
request.checkAndSign(this.payService.getConfig()); request.checkAndSign(this.payService.getConfig());
String url = this.payService.getPayBaseUrl() + "/secapi/pay/profitsharingfinish"; String url = this.payService.getPayBaseUrl() + "/secapi/pay/profitsharingfinish";
@ -75,7 +75,7 @@ public class ProfitSharingServiceImpl implements ProfitSharingService {
} }
@Override @Override
public ProfitSharingQueryResult profitsharingQuery(ProfitSharingQueryRequest request) throws WxPayException { public ProfitSharingQueryResult profitSharingQuery(ProfitSharingQueryRequest request) throws WxPayException {
if (true) throw new WxPayException("暂不支持,微信一直返回签名失败"); if (true) throw new WxPayException("暂不支持,微信一直返回签名失败");
request.checkAndSign(this.payService.getConfig()); request.checkAndSign(this.payService.getConfig());
String url = this.payService.getPayBaseUrl() + "/pay/profitsharingquery"; String url = this.payService.getPayBaseUrl() + "/pay/profitsharingquery";
@ -87,24 +87,24 @@ public class ProfitSharingServiceImpl implements ProfitSharingService {
} }
@Override @Override
public ProfitSharingReturnResult profitsharingReturn(ProfitSharingReturnRequest request) throws WxPayException { public ProfitSharingReturnResult profitSharingReturn(ProfitSharingReturnRequest returnRequest) throws WxPayException {
request.checkAndSign(this.payService.getConfig()); returnRequest.checkAndSign(this.payService.getConfig());
String url = this.payService.getPayBaseUrl() + "/secapi/pay/profitsharingreturn"; 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); ProfitSharingReturnResult result = BaseWxPayResult.fromXML(responseContent, ProfitSharingReturnResult.class);
result.checkResult(this.payService, request.getSignType(), true); result.checkResult(this.payService, returnRequest.getSignType(), true);
return result; return result;
} }
@Override @Override
public ProfitSharingReturnResult profitsharingReturnQuery(ProfitSharingReturnQueryRequest request) throws WxPayException { public ProfitSharingReturnResult profitSharingReturnQuery(ProfitSharingReturnQueryRequest queryRequest) throws WxPayException {
request.checkAndSign(this.payService.getConfig()); queryRequest.checkAndSign(this.payService.getConfig());
String url = this.payService.getPayBaseUrl() + "/pay/profitsharingreturnquery"; 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); ProfitSharingReturnResult result = BaseWxPayResult.fromXML(responseContent, ProfitSharingReturnResult.class);
result.checkResult(this.payService, request.getSignType(), true); result.checkResult(this.payService, queryRequest.getSignType(), true);
return result; return result;
} }
} }

View File

@ -36,7 +36,7 @@ public class ProfitSharingServiceImplTest {
.transactionId("4200000431201910234736634272") .transactionId("4200000431201910234736634272")
.receivers(instance.toJSONString()) .receivers(instance.toJSONString())
.build(); .build();
this.logger.info(this.payService.getProfitSharingService().profitsharing(request).toString()); this.logger.info(this.payService.getProfitSharingService().profitSharing(request).toString());
} }
@Test @Test
@ -52,7 +52,7 @@ public class ProfitSharingServiceImplTest {
.transactionId("4200000448201910238249687345")//order_id=30000102922019102310821824010 .transactionId("4200000448201910238249687345")//order_id=30000102922019102310821824010
.receivers(instance.toJSONString()) .receivers(instance.toJSONString())
.build(); .build();
this.logger.info(this.payService.getProfitSharingService().multiprofitsharing(request).toString()); this.logger.info(this.payService.getProfitSharingService().multiProfitSharing(request).toString());
} }
@Test @Test
@ -63,7 +63,7 @@ public class ProfitSharingServiceImplTest {
.transactionId("4200000441201910238267278073") .transactionId("4200000441201910238267278073")
.description("分账完成") .description("分账完成")
.build(); .build();
this.logger.info(this.payService.getProfitSharingService().profitsharingfinish(request).toString()); this.logger.info(this.payService.getProfitSharingService().profitSharingFinish(request).toString());
} }
@Test @Test
@ -98,7 +98,7 @@ public class ProfitSharingServiceImplTest {
.outOrderNo("20191023112023031060677") .outOrderNo("20191023112023031060677")
.transactionId("4200000431201910234736634272") .transactionId("4200000431201910234736634272")
.build(); .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.formatReceivers().toString());
this.logger.info(result.toString()); this.logger.info(result.toString());
} }
@ -114,7 +114,7 @@ public class ProfitSharingServiceImplTest {
.returnAmount(2) .returnAmount(2)
.description("用户退款") .description("用户退款")
.build(); .build();
this.logger.info(this.payService.getProfitSharingService().profitsharingReturn(request).toString()); this.logger.info(this.payService.getProfitSharingService().profitSharingReturn(request).toString());
} }
@Test @Test
@ -124,7 +124,7 @@ public class ProfitSharingServiceImplTest {
.outOrderNo("20191023154723316420060") .outOrderNo("20191023154723316420060")
.outReturnNo("R2019102315") .outReturnNo("R2019102315")
.build(); .build();
this.logger.info(this.payService.getProfitSharingService().profitsharingReturnQuery(request).toString()); this.logger.info(this.payService.getProfitSharingService().profitSharingReturnQuery(request).toString());
} }