Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.github.binarywang.wxpay.bean.payscore;

import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
* 设备信息
**/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Device implements Serializable {

private static final long serialVersionUID = -4510224826631515321L;


/**
* 服务开始的设备ID
*/
@SerializedName("start_device_id")
private String startDeviceId;

/**
* 服务结束的设备ID
*/
@SerializedName("end_device_id")
private String endDeviceId;

/**
* 物料编码
*/
@SerializedName("materiel_no")
private String materielNo;
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public String toJson() {
* openid : oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
* need_user_confirm : true
* profitSharing : false:不分账,默认:false,true:分账
* device : {"start_device_id":"202501","end_device_id":"202502","materiel_no":"212323232"}
*/
@SerializedName("out_order_no")
private String outOrderNo;
Expand Down Expand Up @@ -95,4 +96,6 @@ public String toJson() {
*/
@SerializedName("complete_time")
private String completeTime;
@SerializedName("device")
private Device device;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.github.binarywang.wxpay.bean.payscore;

import org.testng.annotations.Test;

import static org.assertj.core.api.Assertions.assertThat;

/**
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* created on 2020-07-11
*/
public class WxPartnerPayScoreRequestTest {

@Test
public void testToJson() {
WxPartnerPayScoreRequest request = WxPartnerPayScoreRequest.builder()
.outOrderNo("QLS202005201058000201")
.appid("123")
.serviceId("345")
.serviceIntroduction("租借服务")
.timeRange(new TimeRange("20230901011023", "20230930235959","开始时间","结束时间"))
.device(new Device("deviceId","deviceId","212323232"))
.build();
System.out.println(request.toJson());
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\"}}";
assertThat(request.toJson()).isEqualTo(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"
// }
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import org.testng.annotations.Test;

import static org.assertj.core.api.Assertions.assertThat;

/**
* @author <a href="https://github.com/binarywang">Binary Wang</a>
* created on 2020-07-11
Expand All @@ -15,40 +17,29 @@ public void testToJson() {
.serviceId("345")
.serviceIntroduction("租借服务")
.timeRange(new TimeRange("20230901011023", "20230930235959","开始时间","结束时间"))
.device(new Device("deviceId","deviceId","212323232"))
.build();
System.out.println(request.toJson());
/* {
"out_order_no":"QLS202005201058000201",
"appid":"123",
"service_id":"345",
"service_introduction":"租借服务",
"time_range":{
"start_time":"OnAccept",
"end_time":"20200520225840"
},
"location":{
"start_location":"山",
"end_location":"山"
},
"risk_fund":{
"name":"DEPOSIT",
"amount":200,
"description":"丢失偿还费用2元/台"
},
"attach":"",
"notify_url":"/pay/notify/payScore",
"openid":"",
"need_user_confirm":true,
"profit_sharing":false,
"post_payments":[
{
"name":"租借服务",
"amount":100,
"description":"服务费:1元/台",
"count":1
}
],
"total_amount":0
}*/
String json = request.toJson();
System.out.println(json);

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\"}}";
assertThat(request.toJson()).isEqualTo(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"
// }
// }
}
}