Browse Source

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

master
Binary Wang 5 years ago
parent
commit
acc0833622
4 changed files with 49 additions and 53 deletions
  1. +1
    -3
      weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingRequest.java
  2. +30
    -32
      weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingService.java
  3. +12
    -12
      weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImpl.java
  4. +6
    -6
      weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImplTest.java

+ 1
- 3
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharing/ProfitSharingRequest.java View File

@@ -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);
}
}

+ 30
- 32
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingService.java View File

@@ -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
* </pre>
*
* @param profitsharingRequest
* @return
* @param request .
* @return .
* @throws WxPayException the wx pay exception
*/
ProfitSharingResult profitsharing(ProfitSharingRequest profitsharingRequest) throws WxPayException;
ProfitSharingResult profitSharing(ProfitSharingRequest request) throws WxPayException;

/**
* <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://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;

/**
* <pre>
@@ -54,11 +51,11 @@ public interface ProfitSharingService {
* 接口链接:https://api.mch.weixin.qq.com/secapi/pay/profitsharingfinish
* </pre>
*
* @param profitSharingFinishRequest
* @return
* @param request .
* @return .
* @throws WxPayException the wx pay exception
*/
ProfitSharingResult profitsharingfinish(ProfitSharingFinishRequest profitSharingFinishRequest) throws WxPayException;
ProfitSharingResult profitSharingFinish(ProfitSharingFinishRequest request) throws WxPayException;

/**
* <pre>
@@ -67,11 +64,11 @@ public interface ProfitSharingService {
* 接口链接:https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver
* </pre>
*
* @param profitSharingReceiverRequest
* @return
* @throws WxPayException
* @param request .
* @return .
* @throws WxPayException .
*/
ProfitSharingReceiverResult addReceiver(ProfitSharingReceiverRequest profitSharingReceiverRequest) throws WxPayException;
ProfitSharingReceiverResult addReceiver(ProfitSharingReceiverRequest request) throws WxPayException;

/**
* <pre>
@@ -80,11 +77,11 @@ public interface ProfitSharingService {
* 接口链接:https://api.mch.weixin.qq.com/pay/profitsharingremovereceiver
* </pre>
*
* @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
* </pre>
*
* @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
* </pre>
*
* @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
* </pre>
*
* @param profitSharingReturnQueryRequest
* @return
* @throws WxPayException
* @param queryRequest .
* @return .
* @throws WxPayException .
*/
ProfitSharingReturnResult profitsharingReturnQuery(ProfitSharingReturnQueryRequest profitSharingReturnQueryRequest) throws WxPayException;
ProfitSharingReturnResult profitSharingReturnQuery(ProfitSharingReturnQueryRequest queryRequest)
throws WxPayException;

}

+ 12
- 12
weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImpl.java View File

@@ -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;
}
}

+ 6
- 6
weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ProfitSharingServiceImplTest.java View File

@@ -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());
}




Loading…
Cancel
Save