Skip to content

Commit d52e225

Browse files
authored
🎨 #3633【微信支付】创建支付分订单接口请求参数里增加设备信息字段
1 parent 686dff6 commit d52e225

File tree

4 files changed

+111
-34
lines changed

4 files changed

+111
-34
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.github.binarywang.wxpay.bean.payscore;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
8+
import java.io.Serializable;
9+
10+
/**
11+
* 设备信息
12+
**/
13+
@Data
14+
@NoArgsConstructor
15+
@AllArgsConstructor
16+
public class Device implements Serializable {
17+
18+
private static final long serialVersionUID = -4510224826631515321L;
19+
20+
21+
/**
22+
* 服务开始的设备ID
23+
*/
24+
@SerializedName("start_device_id")
25+
private String startDeviceId;
26+
27+
/**
28+
* 服务结束的设备ID
29+
*/
30+
@SerializedName("end_device_id")
31+
private String endDeviceId;
32+
33+
/**
34+
* 物料编码
35+
*/
36+
@SerializedName("materiel_no")
37+
private String materielNo;
38+
}

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/payscore/WxPayScoreRequest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public String toJson() {
4242
* openid : oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
4343
* need_user_confirm : true
4444
* profitSharing : false:不分账,默认:false,true:分账
45+
* device : {"start_device_id":"202501","end_device_id":"202502","materiel_no":"212323232"}
4546
*/
4647
@SerializedName("out_order_no")
4748
private String outOrderNo;
@@ -95,4 +96,6 @@ public String toJson() {
9596
*/
9697
@SerializedName("complete_time")
9798
private String completeTime;
99+
@SerializedName("device")
100+
private Device device;
98101
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.github.binarywang.wxpay.bean.payscore;
2+
3+
import org.testng.annotations.Test;
4+
5+
import static org.assertj.core.api.Assertions.assertThat;
6+
7+
/**
8+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
9+
* created on 2020-07-11
10+
*/
11+
public class WxPartnerPayScoreRequestTest {
12+
13+
@Test
14+
public void testToJson() {
15+
WxPartnerPayScoreRequest request = WxPartnerPayScoreRequest.builder()
16+
.outOrderNo("QLS202005201058000201")
17+
.appid("123")
18+
.serviceId("345")
19+
.serviceIntroduction("租借服务")
20+
.timeRange(new TimeRange("20230901011023", "20230930235959","开始时间","结束时间"))
21+
.device(new Device("deviceId","deviceId","212323232"))
22+
.build();
23+
System.out.println(request.toJson());
24+
String expectedJson =
25+
"{\"out_order_no\":\"QLS202005201058000201\",\"appid\":\"123\",\"service_id\":\"345\",\"service_introduction\":\"租借服务\",\"time_range\":{\"start_time\":\"20230901011023\",\"end_time\":\"20230930235959\",\"start_time_remark\":\"开始时间\",\"end_time_remark\":\"结束时间\"},\"device\":{\"start_device_id\":\"deviceId\",\"end_device_id\":\"deviceId\",\"materiel_no\":\"212323232\"}}";
26+
assertThat(request.toJson()).isEqualTo(expectedJson);
27+
// {
28+
// "out_order_no": "QLS202005201058000201",
29+
// "appid": "123",
30+
// "service_id": "345",
31+
// "service_introduction": "租借服务",
32+
// "time_range": {
33+
// "start_time": "20230901011023",
34+
// "end_time": "20230930235959",
35+
// "start_time_remark": "开始时间",
36+
// "end_time_remark": "结束时间"
37+
// },
38+
// "device": {
39+
// "start_device_id": "deviceId",
40+
// "end_device_id": "deviceId",
41+
// "materiel_no": "212323232"
42+
// }
43+
// }
44+
}
45+
}

weixin-java-pay/src/test/java/com/github/binarywang/wxpay/bean/payscore/WxPayScoreRequestTest.java

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import org.testng.annotations.Test;
44

5+
import static org.assertj.core.api.Assertions.assertThat;
6+
57
/**
68
* @author <a href="https://github.com/binarywang">Binary Wang</a>
79
* created on 2020-07-11
@@ -15,40 +17,29 @@ public void testToJson() {
1517
.serviceId("345")
1618
.serviceIntroduction("租借服务")
1719
.timeRange(new TimeRange("20230901011023", "20230930235959","开始时间","结束时间"))
20+
.device(new Device("deviceId","deviceId","212323232"))
1821
.build();
19-
System.out.println(request.toJson());
20-
/* {
21-
"out_order_no":"QLS202005201058000201",
22-
"appid":"123",
23-
"service_id":"345",
24-
"service_introduction":"租借服务",
25-
"time_range":{
26-
"start_time":"OnAccept",
27-
"end_time":"20200520225840"
28-
},
29-
"location":{
30-
"start_location":"山",
31-
"end_location":"山"
32-
},
33-
"risk_fund":{
34-
"name":"DEPOSIT",
35-
"amount":200,
36-
"description":"丢失偿还费用2元/台"
37-
},
38-
"attach":"",
39-
"notify_url":"/pay/notify/payScore",
40-
"openid":"",
41-
"need_user_confirm":true,
42-
"profit_sharing":false,
43-
"post_payments":[
44-
{
45-
"name":"租借服务",
46-
"amount":100,
47-
"description":"服务费:1元/台",
48-
"count":1
49-
}
50-
],
51-
"total_amount":0
52-
}*/
22+
String json = request.toJson();
23+
System.out.println(json);
24+
25+
String expectedJson = "{\"out_order_no\":\"QLS202005201058000201\",\"appid\":\"123\",\"service_id\":\"345\",\"service_introduction\":\"租借服务\",\"time_range\":{\"start_time\":\"20230901011023\",\"end_time\":\"20230930235959\",\"start_time_remark\":\"开始时间\",\"end_time_remark\":\"结束时间\"},\"device\":{\"start_device_id\":\"deviceId\",\"end_device_id\":\"deviceId\",\"materiel_no\":\"212323232\"}}";
26+
assertThat(request.toJson()).isEqualTo(expectedJson);
27+
// {
28+
// "out_order_no": "QLS202005201058000201",
29+
// "appid": "123",
30+
// "service_id": "345",
31+
// "service_introduction": "租借服务",
32+
// "time_range": {
33+
// "start_time": "20230901011023",
34+
// "end_time": "20230930235959",
35+
// "start_time_remark": "开始时间",
36+
// "end_time_remark": "结束时间"
37+
// },
38+
// "device": {
39+
// "start_device_id": "deviceId",
40+
// "end_device_id": "deviceId",
41+
// "materiel_no": "212323232"
42+
// }
43+
// }
5344
}
5445
}

0 commit comments

Comments
 (0)