Skip to content

Commit e621bb1

Browse files
committed
🎨 优化部分代码
1 parent 736fbd3 commit e621bb1

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/ma/WxMaOpenSubpackage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
/**
77
* @author momorans
8-
* @create 2019-03-12
8+
* @since 2019-03-12
99
**/
1010
@Data
1111
@Builder

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingNotifyData.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212
* 通用通知实体
1313
*
1414
* @author yuanbo
15-
* @create 2022-04-26-21:33 PM
15+
* @since 2022-04-26-21:33 PM
1616
*/
1717
@Data
1818
@NoArgsConstructor
1919
public class ProfitSharingNotifyData implements Serializable{
20-
21-
2220
private static final long serialVersionUID = 4242383310854692441L;
2321

2422
/**

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/profitsharingV3/ProfitSharingNotifyResult.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212
* 分账动账通知解密后数据实体
1313
*
1414
* @author yuanbo
15-
* @create 2022-04-26-21:08 PM
15+
* @since 2022-04-26-21:08 PM
1616
*/
1717
@Data
1818
@NoArgsConstructor
1919
public class ProfitSharingNotifyResult implements Serializable {
20-
21-
2220
private static final long serialVersionUID = -2875006651351414624L;
2321

2422
/**

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/ProfitSharingV3Service.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public interface ProfitSharingV3Service {
238238
* @throws WxPayException the wx pay exception
239239
* @see <a href="https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter8_1_10.shtml">微信文档</a>
240240
*/
241-
ProfitSharingNotifyData getProfitSharingNotifyData(String notifyData, SignatureHeader header) throws WxPayException;
241+
ProfitSharingNotifyResult getProfitSharingNotifyData(String notifyData, SignatureHeader header) throws WxPayException;
242242

243243
/**
244244
* <pre>

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/ProfitSharingV3ServiceImpl.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,17 @@ public ProfitSharingResult profitSharing(ProfitSharingRequest request) throws Wx
4848

4949
@Override
5050
public ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId) throws WxPayException {
51-
String url = String.format("%s/v3/profitsharing/orders/%s?transaction_id=%s", this.payService.getPayBaseUrl(), outOrderNo, transactionId);
51+
String url = String.format("%s/v3/profitsharing/orders/%s?transaction_id=%s", this.payService.getPayBaseUrl(),
52+
outOrderNo, transactionId);
5253
String result = this.payService.getV3(url);
5354
return GSON.fromJson(result, ProfitSharingResult.class);
5455
}
5556

5657
@Override
57-
public ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId, String subMchId) throws WxPayException {
58-
String url = String.format("%s/v3/profitsharing/orders/%s?sub_mchid=%s&transaction_id=%s", this.payService.getPayBaseUrl(), outOrderNo, subMchId, transactionId);
58+
public ProfitSharingResult getProfitSharingResult(String outOrderNo, String transactionId, String subMchId)
59+
throws WxPayException {
60+
String url = String.format("%s/v3/profitsharing/orders/%s?sub_mchid=%s&transaction_id=%s",
61+
this.payService.getPayBaseUrl(), outOrderNo, subMchId, transactionId);
5962
String result = this.payService.getV3(url);
6063
return GSON.fromJson(result, ProfitSharingResult.class);
6164
}
@@ -70,14 +73,17 @@ public ProfitSharingReturnResult profitSharingReturn(ProfitSharingReturnRequest
7073

7174
@Override
7275
public ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo) throws WxPayException {
73-
String url = String.format("%s/v3/profitsharing/return-orders/%s?out_order_no=%s", this.payService.getPayBaseUrl(), outReturnNo, outOrderNo);
76+
String url = String.format("%s/v3/profitsharing/return-orders/%s?out_order_no=%s", this.payService.getPayBaseUrl(),
77+
outReturnNo, outOrderNo);
7478
String result = this.payService.getV3(url);
7579
return GSON.fromJson(result, ProfitSharingReturnResult.class);
7680
}
7781

7882
@Override
79-
public ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo, String subMchId) throws WxPayException {
80-
String url = String.format("%s/v3/profitsharing/return-orders/%s?sub_mchid=%s&out_order_no=%s", this.payService.getPayBaseUrl(), outReturnNo, subMchId, outOrderNo);
83+
public ProfitSharingReturnResult getProfitSharingReturnResult(String outOrderNo, String outReturnNo, String subMchId)
84+
throws WxPayException {
85+
String url = String.format("%s/v3/profitsharing/return-orders/%s?sub_mchid=%s&out_order_no=%s",
86+
this.payService.getPayBaseUrl(), outReturnNo, subMchId, outOrderNo);
8187
String result = this.payService.getV3(url);
8288
return GSON.fromJson(result, ProfitSharingReturnResult.class);
8389
}
@@ -114,7 +120,7 @@ public ProfitSharingReceiver deleteProfitSharingReceiver(ProfitSharingReceiver r
114120
}
115121

116122
@Override
117-
public ProfitSharingNotifyData getProfitSharingNotifyData(String notifyData, SignatureHeader header) throws WxPayException {
123+
public ProfitSharingNotifyResult getProfitSharingNotifyData(String notifyData, SignatureHeader header) throws WxPayException {
118124
ProfitSharingNotifyData response = parseNotifyData(notifyData, header);
119125
ProfitSharingNotifyData.Resource resource = response.getResource();
120126
String cipherText = resource.getCipherText();
@@ -123,16 +129,17 @@ public ProfitSharingNotifyData getProfitSharingNotifyData(String notifyData, Sig
123129
String apiV3Key = this.payService.getConfig().getApiV3Key();
124130
try {
125131
String result = AesUtils.decryptToString(associatedData, nonce, cipherText, apiV3Key);
126-
ProfitSharingNotifyData notifyResult = GSON.fromJson(result, ProfitSharingNotifyData.class);
127-
return notifyResult;
132+
return GSON.fromJson(result, ProfitSharingNotifyResult.class);
128133
} catch (GeneralSecurityException | IOException e) {
129134
throw new WxPayException("解析报文异常!", e);
130135
}
131136
}
132137

133138
@Override
134139
public ProfitSharingBillResult getProfitSharingBill(ProfitSharingBillRequest request) throws WxPayException {
135-
String url = String.format("%s/v3/profitsharing/bills?bill_date=%s", this.payService.getPayBaseUrl(), request.getBillDate());
140+
String url = String.format("%s/v3/profitsharing/bills?bill_date=%s", this.payService.getPayBaseUrl(),
141+
request.getBillDate());
142+
136143
if (StringUtils.isNotBlank(request.getSubMchId())) {
137144
url = String.format("%s&sub_mchid=%s", url, request.getSubMchId());
138145
}
@@ -158,10 +165,7 @@ private ProfitSharingNotifyData parseNotifyData(String data, SignatureHeader hea
158165
* @return true:校验通过 false:校验不通过
159166
*/
160167
private boolean verifyNotifySign(SignatureHeader header, String data) throws WxPayException {
161-
String beforeSign = String.format("%s\n%s\n%s\n",
162-
header.getTimeStamp(),
163-
header.getNonce(),
164-
data);
168+
String beforeSign = String.format("%s%n%s%n%s%n", header.getTimeStamp(), header.getNonce(), data);
165169
Verifier verifier = this.payService.getConfig().getVerifier();
166170
if (verifier == null) {
167171
throw new WxPayException("证书检验对象为空");

weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/ProfitSharingV3ServiceImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* 测试类
1616
*
1717
* @author yuanbo
18-
* @create 2022-04-26-22:33 PM
18+
* @since 2022-04-26-22:33 PM
1919
*/
2020
@Test
2121
@Slf4j

0 commit comments

Comments
 (0)