mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-23 22:11:40 +08:00
🎨 优化部分代码
This commit is contained in:
parent
736fbd3ed8
commit
e621bb1828
@ -5,7 +5,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author momorans
|
* @author momorans
|
||||||
* @create 2019-03-12
|
* @since 2019-03-12
|
||||||
**/
|
**/
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
|
@ -12,13 +12,11 @@ import java.io.Serializable;
|
|||||||
* 通用通知实体
|
* 通用通知实体
|
||||||
*
|
*
|
||||||
* @author yuanbo
|
* @author yuanbo
|
||||||
* @create 2022-04-26-21:33 PM
|
* @since 2022-04-26-21:33 PM
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class ProfitSharingNotifyData implements Serializable{
|
public class ProfitSharingNotifyData implements Serializable{
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 4242383310854692441L;
|
private static final long serialVersionUID = 4242383310854692441L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,13 +12,11 @@ import java.io.Serializable;
|
|||||||
* 分账动账通知解密后数据实体
|
* 分账动账通知解密后数据实体
|
||||||
*
|
*
|
||||||
* @author yuanbo
|
* @author yuanbo
|
||||||
* @create 2022-04-26-21:08 PM
|
* @since 2022-04-26-21:08 PM
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class ProfitSharingNotifyResult implements Serializable {
|
public class ProfitSharingNotifyResult implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -2875006651351414624L;
|
private static final long serialVersionUID = -2875006651351414624L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -238,7 +238,7 @@ public interface ProfitSharingV3Service {
|
|||||||
* @throws WxPayException the wx pay exception
|
* @throws WxPayException the wx pay exception
|
||||||
* @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_10.shtml">微信文档</a>
|
* @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_10.shtml">微信文档</a>
|
||||||
*/
|
*/
|
||||||
ProfitSharingNotifyData getProfitSharingNotifyData(String notifyData, SignatureHeader header) throws WxPayException;
|
ProfitSharingNotifyResult getProfitSharingNotifyData(String notifyData, SignatureHeader header) throws WxPayException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
|
@ -48,14 +48,17 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId) throws WxPayException {
|
public ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId) throws WxPayException {
|
||||||
String url = String.format("%s/v3/profitsharing/orders/%s?transaction_id=%s", this.payService.getPayBaseUrl(), outOrderNo, transactionId);
|
String url = String.format("%s/v3/profitsharing/orders/%s?transaction_id=%s", this.payService.getPayBaseUrl(),
|
||||||
|
outOrderNo, transactionId);
|
||||||
String result = this.payService.getV3(url);
|
String result = this.payService.getV3(url);
|
||||||
return GSON.fromJson(result, ProfitSharingResult.class);
|
return GSON.fromJson(result, ProfitSharingResult.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId, String subMchId) throws WxPayException {
|
public ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId, String subMchId)
|
||||||
String url = String.format("%s/v3/profitsharing/orders/%s?sub_mchid=%s&transaction_id=%s", this.payService.getPayBaseUrl(), outOrderNo, subMchId, transactionId);
|
throws WxPayException {
|
||||||
|
String url = String.format("%s/v3/profitsharing/orders/%s?sub_mchid=%s&transaction_id=%s",
|
||||||
|
this.payService.getPayBaseUrl(), outOrderNo, subMchId, transactionId);
|
||||||
String result = this.payService.getV3(url);
|
String result = this.payService.getV3(url);
|
||||||
return GSON.fromJson(result, ProfitSharingResult.class);
|
return GSON.fromJson(result, ProfitSharingResult.class);
|
||||||
}
|
}
|
||||||
@ -70,14 +73,17 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo) throws WxPayException {
|
public ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo) throws WxPayException {
|
||||||
String url = String.format("%s/v3/profitsharing/return-orders/%s?out_order_no=%s", this.payService.getPayBaseUrl(), outReturnNo, outOrderNo);
|
String url = String.format("%s/v3/profitsharing/return-orders/%s?out_order_no=%s", this.payService.getPayBaseUrl(),
|
||||||
|
outReturnNo, outOrderNo);
|
||||||
String result = this.payService.getV3(url);
|
String result = this.payService.getV3(url);
|
||||||
return GSON.fromJson(result, ProfitSharingReturnResult.class);
|
return GSON.fromJson(result, ProfitSharingReturnResult.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo, String subMchId) throws WxPayException {
|
public ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo, String subMchId)
|
||||||
String url = String.format("%s/v3/profitsharing/return-orders/%s?sub_mchid=%s&out_order_no=%s", this.payService.getPayBaseUrl(), outReturnNo, subMchId, outOrderNo);
|
throws WxPayException {
|
||||||
|
String url = String.format("%s/v3/profitsharing/return-orders/%s?sub_mchid=%s&out_order_no=%s",
|
||||||
|
this.payService.getPayBaseUrl(), outReturnNo, subMchId, outOrderNo);
|
||||||
String result = this.payService.getV3(url);
|
String result = this.payService.getV3(url);
|
||||||
return GSON.fromJson(result, ProfitSharingReturnResult.class);
|
return GSON.fromJson(result, ProfitSharingReturnResult.class);
|
||||||
}
|
}
|
||||||
@ -114,7 +120,7 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProfitSharingNotifyData getProfitSharingNotifyData(String notifyData, SignatureHeader header) throws WxPayException {
|
public ProfitSharingNotifyResult getProfitSharingNotifyData(String notifyData, SignatureHeader header) throws WxPayException {
|
||||||
ProfitSharingNotifyData response = parseNotifyData(notifyData, header);
|
ProfitSharingNotifyData response = parseNotifyData(notifyData, header);
|
||||||
ProfitSharingNotifyData.Resource resource = response.getResource();
|
ProfitSharingNotifyData.Resource resource = response.getResource();
|
||||||
String cipherText = resource.getCipherText();
|
String cipherText = resource.getCipherText();
|
||||||
@ -123,8 +129,7 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service {
|
|||||||
String apiV3Key = this.payService.getConfig().getApiV3Key();
|
String apiV3Key = this.payService.getConfig().getApiV3Key();
|
||||||
try {
|
try {
|
||||||
String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key);
|
String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key);
|
||||||
ProfitSharingNotifyData notifyResult = GSON.fromJson(result, ProfitSharingNotifyData.class);
|
return GSON.fromJson(result, ProfitSharingNotifyResult.class);
|
||||||
return notifyResult;
|
|
||||||
} catch (GeneralSecurityException | IOException e) {
|
} catch (GeneralSecurityException | IOException e) {
|
||||||
throw new WxPayException("解析报文异常!", e);
|
throw new WxPayException("解析报文异常!", e);
|
||||||
}
|
}
|
||||||
@ -132,7 +137,9 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProfitSharingBillResult getProfitSharingBill(ProfitSharingBillRequest request) throws WxPayException {
|
public ProfitSharingBillResult getProfitSharingBill(ProfitSharingBillRequest request) throws WxPayException {
|
||||||
String url = String.format("%s/v3/profitsharing/bills?bill_date=%s", this.payService.getPayBaseUrl(), request.getBillDate());
|
String url = String.format("%s/v3/profitsharing/bills?bill_date=%s", this.payService.getPayBaseUrl(),
|
||||||
|
request.getBillDate());
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(request.getSubMchId())) {
|
if (StringUtils.isNotBlank(request.getSubMchId())) {
|
||||||
url = String.format("%s&sub_mchid=%s", url, request.getSubMchId());
|
url = String.format("%s&sub_mchid=%s", url, request.getSubMchId());
|
||||||
}
|
}
|
||||||
@ -158,10 +165,7 @@ public class ProfitSharingV3ServiceImpl implements ProfitSharingV3Service {
|
|||||||
* @return true:校验通过 false:校验不通过
|
* @return true:校验通过 false:校验不通过
|
||||||
*/
|
*/
|
||||||
private boolean verifyNotifySign(SignatureHeader header, String data) throws WxPayException {
|
private boolean verifyNotifySign(SignatureHeader header, String data) throws WxPayException {
|
||||||
String beforeSign = String.format("%s\n%s\n%s\n",
|
String beforeSign = String.format("%s%n%s%n%s%n", header.getTimeStamp(), header.getNonce(), data);
|
||||||
header.getTimeStamp(),
|
|
||||||
header.getNonce(),
|
|
||||||
data);
|
|
||||||
Verifier verifier = this.payService.getConfig().getVerifier();
|
Verifier verifier = this.payService.getConfig().getVerifier();
|
||||||
if (verifier == null) {
|
if (verifier == null) {
|
||||||
throw new WxPayException("证书检验对象为空");
|
throw new WxPayException("证书检验对象为空");
|
||||||
|
@ -15,7 +15,7 @@ import org.testng.annotations.Test;
|
|||||||
* 测试类
|
* 测试类
|
||||||
*
|
*
|
||||||
* @author yuanbo
|
* @author yuanbo
|
||||||
* @create 2022-04-26-22:33 PM
|
* @since 2022-04-26-22:33 PM
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
Loading…
Reference in New Issue
Block a user