shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package com.walker.pay.allinpaycloud;
 
import com.walker.infrastructure.utils.StringUtils;
import com.walker.pay.RequestNotifyBean;
 
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
 
/**
 * 通知的最外层对象定义。
 * @author 时克英
 * @date 2023-02-26
 */
public class RequestNotify extends RequestNotifyBean {
 
    @Override
    public String toString(){
        return new StringBuilder("[notifyId=").append(this.getNotifyId())
                .append(", notifyType=").append(this.getNotifyType())
                .append(", notifyTime=").append(this.getNotifyTime())
                .append(", sign=").append(this.getSign())
                .append(", appId=").append(this.getAppId())
                .append(", signType=").append(this.getSignType())
                .append(", bizContent=").append(this.getBizContent())
                .append("]").toString();
    }
 
    /**
     * 把对象转成等待验证签名的数据字符串。
     * @return
     * @date 2023-03-05
     */
    public String toSignSource(){
        StringBuilder sb = new StringBuilder("appId=").append(this.appId)
                .append("&bizContent=").append(this.bizContent)
                .append("&charset=").append(this.charset)
                .append("&notifyId=").append(this.notifyId)
                .append("&notifyTime=").append(this.notifyTime)
                .append("&notifyType=").append(this.notifyType)
                .append("&version=").append(this.version);
        try {
            return URLDecoder.decode(sb.toString(), StringUtils.DEFAULT_CHARSET_UTF8);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
 
//    /**
//     * 转换成签名序列化字符串,按照key/value拼接方式,以字母表顺序。
//     * @return
//     * @date 2023-03-06
//     */
//    public String toSignSerialize(){
//        Field[] fields = this.getClass().getDeclaredFields();
//        List<String> fieldNameList = new ArrayList<>(8);
//        for(int i=0;i<fields.length;i++){
//            fieldNameList.add(fields[i].getName());
//        }
//        Collections.sort(fieldNameList);
//        System.out.println(fieldNameList);
//
//        StringBuilder sb = new StringBuilder();
//        for(int i=0; i<fieldNameList.size(); i++){
//            if(i > 0){
//                sb.append("&");
//            }
//            sb.append(fieldNameList.get(i))
//                    .append("=")
//                    .append(ClassUtils.getFieldValueByName(fieldNameList.get(i), this));
//        }
//        return sb.toString();
//    }
 
    public String getAppId() {
        return appId;
    }
 
    public void setAppId(String appId) {
        this.appId = appId;
    }
 
    public String getNotifyType() {
        return notifyType;
    }
 
    public void setNotifyType(String notifyType) {
        this.notifyType = notifyType;
    }
 
    public String getNotifyTime() {
        return notifyTime;
    }
 
    public void setNotifyTime(String notifyTime) {
        this.notifyTime = notifyTime;
    }
 
    public String getNotifyId() {
        return notifyId;
    }
 
    public void setNotifyId(String notifyId) {
        this.notifyId = notifyId;
    }
 
    public String getCharset() {
        return charset;
    }
 
    public void setCharset(String charset) {
        this.charset = charset;
    }
 
    public String getVersion() {
        return version;
    }
 
    public void setVersion(String version) {
        this.version = version;
    }
 
    public String getSignType() {
        return signType;
    }
 
    public void setSignType(String signType) {
        this.signType = signType;
    }
 
    public String getSign() {
        return sign;
    }
 
    public void setSign(String sign) {
        this.sign = sign;
    }
 
//    public OrderNotifyInfo getBizContent() {
//        return bizContent;
//    }
//
//    public void setBizContent(OrderNotifyInfo bizContent) {
//        this.bizContent = bizContent;
//    }
 
    public String getBizContent() {
        return bizContent;
    }
 
    public void setBizContent(String bizContent) {
        this.bizContent = bizContent;
    }
 
    private String bizContent;
    private String appId;
    private String notifyType;
    private String notifyTime;
    private String notifyId;
    private String charset;
    private String version;
    private String signType;
    private String sign;
 
//    private OrderNotifyInfo bizContent;
}