正在显示
10 个修改的文件
包含
534 行增加
和
2 行删除
checl_test.go
0 → 100644
1 | +package socialwork_sdk | ||
2 | + | ||
3 | +import ( | ||
4 | + "encoding/json" | ||
5 | + "gitlab.workai.com.cn/chenang/socialwork-sdk/model" | ||
6 | + "testing" | ||
7 | +) | ||
8 | + | ||
9 | +const ( | ||
10 | + KEY = "fbb416bfd0a242419e6528f2" | ||
11 | + IV = "0f6ce46636264d66" | ||
12 | + //客户私钥 | ||
13 | + PRIVATEKEY = `-----BEGIN PRIVATE KEY----- | ||
14 | +MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAL+HIjm9wYlMx5dR | ||
15 | +hCGw9Uw5X1ZKPUfOvKXq/8mIuNVtH2ls6jz1fBlhoSHrYMjxY5t7EPSRZzOLeqGI | ||
16 | +7FKbwlHPLAC4cN3njho8TE4Ao7EqipG7L81qHL6Wll/NrziP67+dDROG0ozscmNh | ||
17 | +kq0JFxIkxQn3aKGbeEdJbLcLRRM7AgMBAAECgYEAn72Rah89v8nt3eL7FS6GKGDh | ||
18 | +hxK8MZvX83oghHIn1roArOlOJDGKo5Ct16B9RJsvvInUBmcPcAow6XFNyUhntGnk | ||
19 | +evnBZSPz8SJlwGMTTz/P4ebQURrcup5UejQzmBOSXrIXsrW4Ty0AdvnwM1OB/lmz | ||
20 | +tQZyU3xMzK6QbXJkCgECQQDqWeR9/gBwWZLkZBPQASxWbb7NKwyCNN7clzMZv6MN | ||
21 | +ea8sR7Zp6cNfPtfcVVTeHRX/sXRhB7inRyLi/ec3dSJBAkEA0TiGYiTv1l5prTCC | ||
22 | +PK6lyShDK9SR8ZBcSxO5KsttFeOs3f9l2uU0ddd8fAuLJPm2xjd3RAbnH9dAfEC1 | ||
23 | +GXoeewJBAJ/aB0iFnIkGIHNXbEhCtJqTq0VJavPZ2nZ/UCTtGexUJ0+97shZ4qEy | ||
24 | +PY2WSxhioKHTyn1xBdxcYoiRBklGxcECQAqDOZVi3744vjyajGC6MdBauo1QQAkQ | ||
25 | +ROLs2cgBsrh/2SbKd3a5P5qQOkwNVG+GMJ3jGZYMdr6N1UqpAbCHB1MCQH1aSvf2 | ||
26 | ++CXW9fbkUz+qyjIWLN0pDyI+uh+zAHRRs9sL5UVOLfyU03W3120bUL7aekrbynP8 | ||
27 | +1+ihe8QolWZgvUk= | ||
28 | +-----END PRIVATE KEY-----` | ||
29 | + //平台公钥 | ||
30 | + PUBLICKEY = `-----BEGIN PUBLIC KEY----- | ||
31 | +MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHk0VRd3+CqwUHA2jC4dzrqe7/ | ||
32 | +pjX8BTbC7T7DnzAGO7iN09kf2abbzudLTM+xbOKr2wSTLkhffBhycZ4zlf3PuVu/ | ||
33 | +KmUhzAS0v+cvRYEBdiD+ckC1i80KaGPsiSvKSgJIxEEo1urgsrGJBGP0uBMM50Bm | ||
34 | +3YZBKCNST3LB1JNSeQIDAQAB | ||
35 | +-----END PUBLIC KEY-----` | ||
36 | + IP = "http://47.110.250.177:20000/" | ||
37 | + //IP = "http://127.0.0.1:51393/" | ||
38 | + STR = `{"response_type":"code","client_id":"432437055486697481","redirect_uri":"https://dev3.workai.com.cn/wso-workai?state=socialwork_strait_certification_list","state":"client_credential","scope":"global_access:end_user","user_mobile":"13301169757","user_name":"sasl_dispose","callback":"","certification":"0","ptcode":"730088256896503808","path_type":"","path":""}` | ||
39 | + | ||
40 | + V1DATA = "Wxy8h961GO12QmdOdwOYaUZdy6P+o67Olid6YbbjP+SiZNKYofmbQ33eyixsWXIP33sLIrrUrYZ/BNd1+iC8Bng9itBpIcJEfO7fJX9+8Sgp+5hORLESdPRoiyIjeQMX1JKpBk0Uiu7eSsxRRepi33oMi1+580LtFa91lc44PAwnrAEPoTZbEpPQQQmNPrGM0DzmZRUxEIT/SajlwoNg34DvKrGpsb2g8GZ7wUR8GuTOYUg2odF8WjTWNj2GWuzCUw8WPN8FGXdgTzRMn0glivn5SizGmJn0oOJZxo4JRG0Q6h0hV3xi8nPtvwjyOdy0Wspjcd4jQny1jaOKCaPg/5CRLWdmQKLE9d7UhSyQoQ6jzNxEkd/r7vAbtuvRfwvB6zN7NKODjVc/kJf7qovou8u6k2xBGQ7C1CT8wULjqRy3bAYfJ4A5YYWIwtMPJ/l1swlEYsalq5M4Y1g5RjnX1auMczdhnTCOzNeXm2tTJSQ=" | ||
41 | + V1SIGN = "qTxPJ0t4vW6cMIMYw5vQukG+BnsUY0ku5S1h9TM/IHqJVa0VU5Q7FXxgy0I6T6R12jDZ37+R9RxeEBzO5Fc3rfMWQQfcfGfLgRsbhHSjF0In9T72QHKmzn2upArfCArNlDJh+tC3FvTG9BTMfztlLRlXmVJJ7oTqgJDcZ4m5IqU=" | ||
42 | +) | ||
43 | + | ||
44 | +var client *OrderClient | ||
45 | + | ||
46 | +func init() { | ||
47 | + client = NewOrderClient(KEY, IV, PRIVATEKEY, PUBLICKEY, IP) | ||
48 | +} | ||
49 | + | ||
50 | +func TestCheckParams(t *testing.T) { | ||
51 | + b := `{"response_type":"code","client_id":"432437055486697481","redirect_uri":"https://dev3.workai.com.cn/wso-workai?state=socialwork_strait_certification_list","state":"client_credential","scope":"global_access:end_user","user_mobile":"13301169757","user_name":"sasl_dispose","callback":"http://tjianke.tcl.com/wxapp.php/sdata/identNotice","certification":"0","ptcode":"638103470397722624","path_type":"PathType","path":"Path"}` | ||
52 | + if err := checkParams("AUTHORIZE", b); err != nil { | ||
53 | + t.Logf("AUTHORIZE err : %+v", err) | ||
54 | + } | ||
55 | + | ||
56 | + b = `{"items":{"name":"新的测试订单","customer_name":"","service_contract_no":"新服务合同543534543","bill_month":1638288000,"payer_object_type":"customer","payer_object_name":"","electron_contract_template_name":"","settlement_org_id":"635981601368444928","has_auto_create":"oneself","payer_name":"","payer_mobile":"","provide_mode":"","callback":"http://47.110.250.177:20000/socialwork/v1/external/callbacktext"}}` | ||
57 | + if err := checkParams("CREATEORDER", b); err != nil { | ||
58 | + t.Logf("CREATEORDER err : %+v", err) | ||
59 | + } | ||
60 | + | ||
61 | + b = `{"id":"728622438832672768","items":[{"user_name":"人员姓名","user_mobile":"13301189876","id_card_no":"110101199003077192","bank_name":"招商银行","bank_card":"621083011111111119","total_salary":"1000","comment":"任务成果备注","job_name":"任务名称","begin_time":1642576824,"end_time":1643527224,"job_type":"会务服务","work_place":"工作地址","salary_unit":"order","salary":"100.00","confirm_type":"oneself","open_account_bank":"开户行","open_account_place":"开户地","open_bank_no":"开户行号","industry_code":"","extra":"","bank_payment_id":"","work_load":"","interval_price":"","real_total_salary":""},{"user_name":"人员姓名1","user_mobile":"13301189877","id_card_no":"110101199003074151","bank_name":"招商银行","bank_card":"621083011111111119","total_salary":"2000","comment":"任务成果备注1","job_name":"任务名称1","begin_time":1642576824,"end_time":1643527224,"job_type":"会务服务","work_place":"工作地址1","salary_unit":"order","salary":"200.00","confirm_type":"oneself","open_account_bank":"开户行1","open_account_place":"开户地1","open_bank_no":"开户行号1","industry_code":"","extra":"","bank_payment_id":"","work_load":"","interval_price":"","real_total_salary":""}]}` | ||
62 | + if err := checkParams("ADDFREEDOMEEMP", b); err != nil { | ||
63 | + t.Logf("ADDFREEDOMEEMP err : %+v", err) | ||
64 | + } | ||
65 | + | ||
66 | + b = `{"id":"690313836787404802","file_type":"id_card_front_image","content":"6ZmE5Lu25YaF5a65","trace_no":"dsdsds"}` | ||
67 | + if err := checkParams("UPLOADATTACHMENT", b); err != nil { | ||
68 | + t.Logf("UPLOADATTACHMENT err : %+v", err) | ||
69 | + } | ||
70 | + | ||
71 | + b = `{"id":"695762134566440960","file_type":"id_card_front_image","url":"http://hbimg.b0.upaiyun.com/32f065b3afb3fb36b75a5cbc9034s051b1050e1e6b6e199-Ml6q9F_fw320","trace_no":"dsdsds"}` | ||
72 | + if err := checkParams("UPLOADATTACHMENTBYURL", b); err != nil { | ||
73 | + t.Logf("UPLOADATTACHMENTBYURL err : %+v", err) | ||
74 | + } | ||
75 | + | ||
76 | + b = `{"id":"705537141886685184"}` | ||
77 | + if err := checkParams("ORDERINFO", b); err != nil { | ||
78 | + t.Logf("ORDERINFO err : %+v", err) | ||
79 | + } | ||
80 | + | ||
81 | + b = `{"id":"719706386803462144"}` | ||
82 | + if err := checkParams("FREEDOMEMOSTATUS", b); err != nil { | ||
83 | + t.Logf("FREEDOMEMOSTATUS err : %+v", err) | ||
84 | + } | ||
85 | + | ||
86 | + b = `{"id":"30207117494289"}` | ||
87 | + if err := checkParams("SUBACCOUNTBALANCE", b); err != nil { | ||
88 | + t.Logf("SUBACCOUNTBALANCE err : %+v", err) | ||
89 | + } | ||
90 | + | ||
91 | + b = `{"order_id":"723262661785030656","detail_id":"723262661785030657","user_name":"杨舟","user_mobile":"12203987657","user_id_card":"42108719910802122743","bank_name":"中国建设银行","bank_card":"621733002230003638850","update_fields":["bank_name","bank_card"]}` | ||
92 | + if err := checkParams("UPDATEORDERDETAIL", b); err != nil { | ||
93 | + t.Logf("UPDATEORDERDETAIL err : %+v", err) | ||
94 | + } | ||
95 | + | ||
96 | + b = `{"id":"700814624890556416"}` | ||
97 | + if err := checkParams("EXISTRECEIPT", b); err != nil { | ||
98 | + t.Logf("EXISTRECEIPT err : %+v", err) | ||
99 | + } | ||
100 | + | ||
101 | + b = `{"file_id":[],"type":"pa","order_id":"700814624890556416"}` | ||
102 | + if err := checkParams("DOWNLOADRECEIPT", b); err != nil { | ||
103 | + t.Logf("DOWNLOADRECEIPT err : %+v", err) | ||
104 | + } | ||
105 | + | ||
106 | + b = `{"id":"728622438832672768","bank":"银行民称","recharge_date":1639639779,"serial_no":"76547654765","setting_status":false,"pt_code":""}` | ||
107 | + if err := checkParams("PAYORDER", b); err != nil { | ||
108 | + t.Logf("PAYORDER err : %+v", err) | ||
109 | + } | ||
110 | + | ||
111 | + b = `{"name":"测试的订单20220210","service_contract_no":"676573793673547776","bill_month":1644485537,"payer_object_type":"customer","settlement_org_id":"676432056892264448","payer_name":"","payer_mobile":"","provide_mode":"","details":[{"user_name":"覃超","user_mobile":"18320960031","id_card_no":"430723199002143210","bank_name":"招商银行","bank_card":"6226096804210467","total_salary":"4.94","comment":"","job_name":"佣金提现申请金额","begin_time":0,"end_time":0,"job_type":"","work_place":"","salary_unit":"单","salary":"","confirm_type":"","open_account_bank":"","open_account_place":"","open_bank_no":"","industry_code":"","extra":"","bank_payment_id":"","work_load":"","interval_price":"","real_total_salary":""}],"Callback":"","setting_status":false,"pt_code":""}` | ||
112 | + if err := checkParams("PAYORDERV1", b); err != nil { | ||
113 | + t.Logf("PAYORDERV1 err : %+v", err) | ||
114 | + } | ||
115 | + | ||
116 | + b = `{"filter":{"mobile":"13301169755"}}` | ||
117 | + if err := checkParams("USERINFO", b); err != nil { | ||
118 | + t.Logf("USERINFO err : %+v", err) | ||
119 | + } | ||
120 | + | ||
121 | + b = `{"user_id":"705485356060905472","mobile":"18881652932"}` | ||
122 | + if err := checkParams("UPDATEMOBILE", b); err != nil { | ||
123 | + t.Logf("UPDATEMOBILE err : %+v", err) | ||
124 | + } | ||
125 | + | ||
126 | + b = `{"name":"聂顺成","mobile":"15017402918","id_num":"341322190709230027","id_card_back":"http://hrshare.oss-cn-shenzhen.aliyuncs.com/hrshare/2022/04/06/frontCard151211551394418626561.png","id_card_front":"http://hrshare.oss-cn-shenzhen.aliyuncs.com/hrshare/2022/04/06/backCard121511551394418626561.png","callback":"https://hrshare.tacll.com/prod-api/app/wxApp/spiritedCallback"}` | ||
127 | + if err := checkParams("CREATEEMPLOYMENTPOOL", b); err != nil { | ||
128 | + t.Logf("CREATEEMPLOYMENTPOOL err : %+v", err) | ||
129 | + } | ||
130 | +} | ||
131 | + | ||
132 | +func checkParams(businessCode, reqBody string) error { | ||
133 | + switch businessCode { | ||
134 | + case "AUTHORIZE": | ||
135 | + var authorize model.Authorize | ||
136 | + if err := json.Unmarshal([]byte(reqBody), &authorize); err != nil { | ||
137 | + return err | ||
138 | + } | ||
139 | + return nil | ||
140 | + case "CREATEORDER": | ||
141 | + var createOrder model.CreateOrder | ||
142 | + if err := json.Unmarshal([]byte(reqBody), &createOrder); err != nil { | ||
143 | + return err | ||
144 | + } | ||
145 | + return nil | ||
146 | + case "ADDFREEDOMEEMP": | ||
147 | + var freedomEmps model.FreedomEmps | ||
148 | + if err := json.Unmarshal([]byte(reqBody), &freedomEmps); err != nil { | ||
149 | + return err | ||
150 | + } | ||
151 | + return nil | ||
152 | + case "UPLOADATTACHMENT": | ||
153 | + var uploadFreedomEmps model.UploadFreedomEmps | ||
154 | + if err := json.Unmarshal([]byte(reqBody), &uploadFreedomEmps); err != nil { | ||
155 | + return err | ||
156 | + } | ||
157 | + return nil | ||
158 | + case "UPLOADATTACHMENTBYURL": | ||
159 | + var uploadFreedomEmpsByUrl model.UploadFreedomEmpsByUrl | ||
160 | + if err := json.Unmarshal([]byte(reqBody), &uploadFreedomEmpsByUrl); err != nil { | ||
161 | + return err | ||
162 | + } | ||
163 | + return nil | ||
164 | + case "ORDERINFO": | ||
165 | + var simpleOrderInfo model.SimpleOrderInfo | ||
166 | + if err := json.Unmarshal([]byte(reqBody), &simpleOrderInfo); err != nil { | ||
167 | + return err | ||
168 | + } | ||
169 | + return nil | ||
170 | + case "FREEDOMEMOSTATUS": | ||
171 | + var freedomEmpStatus model.FreedomEmpStatus | ||
172 | + if err := json.Unmarshal([]byte(reqBody), &freedomEmpStatus); err != nil { | ||
173 | + return err | ||
174 | + } | ||
175 | + return nil | ||
176 | + case "SUBACCOUNTBALANCE": | ||
177 | + var subAccountBalance model.SubAccountBalance | ||
178 | + if err := json.Unmarshal([]byte(reqBody), &subAccountBalance); err != nil { | ||
179 | + return err | ||
180 | + } | ||
181 | + return nil | ||
182 | + case "UPDATEORDERDETAIL": | ||
183 | + var updateOrderDetail model.UpdateOrderDetail | ||
184 | + if err := json.Unmarshal([]byte(reqBody), &updateOrderDetail); err != nil { | ||
185 | + return err | ||
186 | + } | ||
187 | + return nil | ||
188 | + case "EXISTRECEIPT": | ||
189 | + var receipt model.Receipt | ||
190 | + if err := json.Unmarshal([]byte(reqBody), &receipt); err != nil { | ||
191 | + return err | ||
192 | + } | ||
193 | + return nil | ||
194 | + case "DOWNLOADRECEIPT": | ||
195 | + var downloadReceipt model.DownloadReceipt | ||
196 | + if err := json.Unmarshal([]byte(reqBody), &downloadReceipt); err != nil { | ||
197 | + return err | ||
198 | + } | ||
199 | + return nil | ||
200 | + case "PAYORDER": | ||
201 | + var payOrder model.PayOrder | ||
202 | + if err := json.Unmarshal([]byte(reqBody), &payOrder); err != nil { | ||
203 | + return err | ||
204 | + } | ||
205 | + return nil | ||
206 | + case "USERINFO": | ||
207 | + var getUserInfo model.GetUserInfo | ||
208 | + if err := json.Unmarshal([]byte(reqBody), &getUserInfo); err != nil { | ||
209 | + return err | ||
210 | + } | ||
211 | + return nil | ||
212 | + case "PAYORDERV1": | ||
213 | + var mergeCreateOrder model.MergeCreateOrder | ||
214 | + if err := json.Unmarshal([]byte(reqBody), &mergeCreateOrder); err != nil { | ||
215 | + return err | ||
216 | + } | ||
217 | + return nil | ||
218 | + case "UPDATEMOBILE": | ||
219 | + var updateMobile model.UpdateMobile | ||
220 | + if err := json.Unmarshal([]byte(reqBody), &updateMobile); err != nil { | ||
221 | + return err | ||
222 | + } | ||
223 | + return nil | ||
224 | + | ||
225 | + case "CREATEEMPLOYMENTPOOL": | ||
226 | + var createEmploymentPool model.CreateEmploymentPool | ||
227 | + if err := json.Unmarshal([]byte(reqBody), &createEmploymentPool); err != nil { | ||
228 | + return err | ||
229 | + } | ||
230 | + return nil | ||
231 | + } | ||
232 | + return nil | ||
233 | +} | ||
234 | + | ||
235 | +func TestEncryption(t *testing.T) { | ||
236 | + data, sign, err := client.EncryptAndSign([]byte(STR)) | ||
237 | + if err != nil { | ||
238 | + t.Logf("加密和签名错误 err : %+v", err) | ||
239 | + } | ||
240 | + if data != V1DATA { | ||
241 | + t.Logf("加密数据与期望值不匹配 err : %+v", err) | ||
242 | + } | ||
243 | + | ||
244 | + if sign != V1SIGN { | ||
245 | + t.Logf("签名数据与期望值不匹配 err : %+v", err) | ||
246 | + } | ||
247 | + | ||
248 | +} | ||
249 | + | ||
250 | +/*func TestDecryptAndVerySign(t *testing.T) { | ||
251 | + by, err := client.DecryptAndVerySign(V1DATA, V1SIGN) | ||
252 | + if err != nil { | ||
253 | + t.Logf("解密错误 err : %+v", err) | ||
254 | + } | ||
255 | + if string(by) != STR { | ||
256 | + t.Logf("加密数据与期望值不匹配 err : %+v", err) | ||
257 | + } | ||
258 | + | ||
259 | +}*/ | ||
260 | + | ||
261 | +func TestSendRequest(t *testing.T) { | ||
262 | + by, err := client.SendRequest("AUTHORIZE", STR) | ||
263 | + if err != nil { | ||
264 | + t.Logf("解密错误 err : %+v", err) | ||
265 | + } | ||
266 | + t.Log(by) | ||
267 | + | ||
268 | +} |
model/account.go
0 → 100644
model/authorize.go
0 → 100644
1 | +package model | ||
2 | + | ||
3 | +type Authorize struct { | ||
4 | + ResponseType string `json:"response_type"` | ||
5 | + ClientId string `json:"client_id"` | ||
6 | + RedirectUri string `json:"redirect_uri"` | ||
7 | + State string `json:"state"` | ||
8 | + Scope string `json:"scope"` | ||
9 | + UserMobile string `json:"user_mobile"` | ||
10 | + UserName string `json:"user_name"` | ||
11 | + Callback string `json:"callback"` | ||
12 | + Certification string `json:"certification"` | ||
13 | + Ptcode string `json:"ptcode"` | ||
14 | + PathType string `json:"path_type"` | ||
15 | + Path string `json:"path"` | ||
16 | +} | ||
17 | + | ||
18 | +type Receipt struct { | ||
19 | + Id string `json:"id"` | ||
20 | +} |
model/employment_pool.go
0 → 100644
model/freedom_emp.go
0 → 100644
1 | +package model | ||
2 | + | ||
3 | +type FreedomEmps struct { | ||
4 | + Id string `json:"id"` | ||
5 | + Items []*FreedomEmp `json:"items"` | ||
6 | +} | ||
7 | + | ||
8 | +type FreedomEmp struct { | ||
9 | + UserName string `json:"user_name"` | ||
10 | + UserMobile string `json:"user_mobile"` | ||
11 | + IdCardNo string `json:"id_card_no"` | ||
12 | + BankName string `json:"bank_name"` | ||
13 | + BankCard string `json:"bank_card"` | ||
14 | + TotalSalary string `json:"total_salary"` | ||
15 | + Comment string `json:"comment"` | ||
16 | + JobName string `json:"job_name"` | ||
17 | + BeginTime int64 `json:"begin_time"` | ||
18 | + EndTime int64 `json:"end_time"` | ||
19 | + JobType string `json:"job_type"` | ||
20 | + WorkPlace string `json:"work_place"` | ||
21 | + SalaryUnit string `json:"salary_unit"` | ||
22 | + Salary string `json:"salary"` | ||
23 | + ConfirmType string `json:"confirm_type"` | ||
24 | + OpenAccountBank string `json:"open_account_bank"` | ||
25 | + OpenAccountPlace string `json:"open_account_place"` | ||
26 | + OpenBankNo string `json:"open_bank_no"` | ||
27 | + IndustryCode string `json:"industry_code"` | ||
28 | + Extra string `json:"extra"` | ||
29 | + BankPaymentId string `json:"bank_payment_id"` | ||
30 | + WorkLoad string `json:"work_load"` | ||
31 | + IntervalPrice string `json:"interval_price"` | ||
32 | + RealTotalSalary string `json:"real_total_salary"` | ||
33 | +} | ||
34 | + | ||
35 | + | ||
36 | +type UploadFreedomEmps struct { | ||
37 | + Id string `json:"id"` | ||
38 | + FileType string `json:"file_type"` | ||
39 | + Content string `json:"content"` | ||
40 | + TraceNo string `json:"trace_no"` | ||
41 | +} | ||
42 | + | ||
43 | +type UploadFreedomEmpsByUrl struct { | ||
44 | + Id string `json:"id"` | ||
45 | + FileType string `json:"file_type"` | ||
46 | + Url string `json:"url"` | ||
47 | + TraceNo string `json:"trace_no"` | ||
48 | +} | ||
49 | + | ||
50 | +type FreedomEmpStatus struct { | ||
51 | + Id string `json:"id"` | ||
52 | +} | ||
53 | + | ||
54 | +type UpdateOrderDetail struct { | ||
55 | + OrderId string `json:"order_id"` | ||
56 | + DetailId string `json:"detail_id"` | ||
57 | + UserName string `json:"user_name"` | ||
58 | + UserMobile string `json:"user_mobile"` | ||
59 | + UserIdCard string `json:"user_id_card"` | ||
60 | + BankName string `json:"bank_name"` | ||
61 | + BankCard string `json:"bank_card"` | ||
62 | + UpdateFields []string `json:"update_fields"` | ||
63 | +} |
model/order.go
0 → 100644
1 | +package model | ||
2 | + | ||
3 | +type CreateOrder struct { | ||
4 | + Items *ExternalCreateOrder `json:"items,omitempty"` | ||
5 | +} | ||
6 | + | ||
7 | +type ExternalCreateOrder struct { | ||
8 | + Name string `json:"name"` | ||
9 | + CustomerName string `json:"customer_name"` | ||
10 | + ServiceContractNo string `json:"service_contract_no"` | ||
11 | + BillMonth int64 `json:"bill_month"` | ||
12 | + PayerObjectType string `json:"payer_object_type"` | ||
13 | + PayerObjectName string `json:"payer_object_name"` | ||
14 | + ElectronContractTemplateName string `json:"electron_contract_template_name"` | ||
15 | + SettlementOrgId string `json:"settlement_org_id"` | ||
16 | + HasAutoCreate string `json:"has_auto_create"` | ||
17 | + PayerName string `json:"payer_name"` | ||
18 | + PayerMobile string `json:"payer_mobile"` | ||
19 | + ProvideMode string `json:"provide_mode"` | ||
20 | + Callback string `json:"callback"` | ||
21 | +} | ||
22 | + | ||
23 | +type SimpleOrderInfo struct { | ||
24 | + Id string `json:"id"` | ||
25 | +} | ||
26 | + | ||
27 | +type PayOrder struct { | ||
28 | + Id string `json:"id"` | ||
29 | + Bank string `json:"bank"` | ||
30 | + RechargeDate int64 `json:"recharge_date"` | ||
31 | + SerialNo string `json:"serial_no"` | ||
32 | + SettingStatus bool `json:"setting_status"` | ||
33 | + PtCode string `json:"pt_code"` | ||
34 | +} | ||
35 | + | ||
36 | +type MergeCreateOrder struct { | ||
37 | + Name string `json:"name"` | ||
38 | + ServiceContractNo string `json:"service_contract_no"` | ||
39 | + BillMonth int64 `json:"bill_month"` | ||
40 | + PayerObjectType string `json:"payer_object_type"` | ||
41 | + SettlementOrgId string `json:"settlement_org_id"` | ||
42 | + PayerName string `json:"payer_name"` | ||
43 | + PayerMobile string `json:"payer_mobile"` | ||
44 | + ProvideMode string `json:"provide_mode"` | ||
45 | + Details []*FreedomEmp `json:"details"` | ||
46 | + Callback string `son:"callback"` | ||
47 | + SettingStatus bool `json:"setting_status"` | ||
48 | + PtCode string `json:"pt_code"` | ||
49 | +} |
@@ -3,6 +3,7 @@ package model | @@ -3,6 +3,7 @@ package model | ||
3 | type OrderModel struct { | 3 | type OrderModel struct { |
4 | Data string `json:"data"` | 4 | Data string `json:"data"` |
5 | Sign string `json:"sign"` | 5 | Sign string `json:"sign"` |
6 | - PtCode string `json:"pt_code"` | ||
7 | - BusinessCode string `json:"business_code"` | 6 | + PtCode string `json:"ptcode"` |
7 | + BusinessCode string `json:"bussiness_code"` | ||
8 | } | 8 | } |
9 | + |
model/user.go
0 → 100644
@@ -88,5 +88,104 @@ func (o *OrderClient) SendRequest(businessCode, reqBody string) (string, error) | @@ -88,5 +88,104 @@ func (o *OrderClient) SendRequest(businessCode, reqBody string) (string, error) | ||
88 | } | 88 | } |
89 | 89 | ||
90 | func (o *OrderClient) checkParams(businessCode, reqBody string) error { | 90 | func (o *OrderClient) checkParams(businessCode, reqBody string) error { |
91 | + switch businessCode { | ||
92 | + case "AUTHORIZE": | ||
93 | + var authorize model.Authorize | ||
94 | + if err := json.Unmarshal([]byte(reqBody),&authorize); err != nil { | ||
95 | + return err | ||
96 | + } | ||
97 | + return nil | ||
98 | + case "CREATEORDER": | ||
99 | + var createOrder model.CreateOrder | ||
100 | + if err := json.Unmarshal([]byte(reqBody),&createOrder); err != nil { | ||
101 | + return err | ||
102 | + } | ||
103 | + return nil | ||
104 | + case "ADDFREEDOMEEMP": | ||
105 | + var freedomEmps model.FreedomEmps | ||
106 | + if err := json.Unmarshal([]byte(reqBody),&freedomEmps); err != nil { | ||
107 | + return err | ||
108 | + } | ||
109 | + return nil | ||
110 | + case "UPLOADATTACHMENT": | ||
111 | + var uploadFreedomEmps model.UploadFreedomEmps | ||
112 | + if err := json.Unmarshal([]byte(reqBody),&uploadFreedomEmps); err != nil { | ||
113 | + return err | ||
114 | + } | ||
115 | + return nil | ||
116 | + case "UPLOADATTACHMENTBYURL": | ||
117 | + var uploadFreedomEmpsByUrl model.UploadFreedomEmpsByUrl | ||
118 | + if err := json.Unmarshal([]byte(reqBody),&uploadFreedomEmpsByUrl); err != nil { | ||
119 | + return err | ||
120 | + } | ||
121 | + return nil | ||
122 | + case "ORDERINFO": | ||
123 | + var simpleOrderInfo model.SimpleOrderInfo | ||
124 | + if err := json.Unmarshal([]byte(reqBody),&simpleOrderInfo); err != nil { | ||
125 | + return err | ||
126 | + } | ||
127 | + return nil | ||
128 | + case "FREEDOMEMOSTATUS": | ||
129 | + var freedomEmpStatus model.FreedomEmpStatus | ||
130 | + if err := json.Unmarshal([]byte(reqBody),&freedomEmpStatus); err != nil { | ||
131 | + return err | ||
132 | + } | ||
133 | + return nil | ||
134 | + case "SUBACCOUNTBALANCE": | ||
135 | + var subAccountBalance model.SubAccountBalance | ||
136 | + if err := json.Unmarshal([]byte(reqBody),&subAccountBalance); err != nil { | ||
137 | + return err | ||
138 | + } | ||
139 | + return nil | ||
140 | + case "UPDATEORDERDETAIL": | ||
141 | + var updateOrderDetail model.UpdateOrderDetail | ||
142 | + if err := json.Unmarshal([]byte(reqBody),&updateOrderDetail); err != nil { | ||
143 | + return err | ||
144 | + } | ||
145 | + return nil | ||
146 | + case "EXISTRECEIPT": | ||
147 | + var receipt model.Receipt | ||
148 | + if err := json.Unmarshal([]byte(reqBody),&receipt); err != nil { | ||
149 | + return err | ||
150 | + } | ||
151 | + return nil | ||
152 | + case "DOWNLOADRECEIPT": | ||
153 | + var downloadReceipt model.DownloadReceipt | ||
154 | + if err := json.Unmarshal([]byte(reqBody),&downloadReceipt); err != nil { | ||
155 | + return err | ||
156 | + } | ||
157 | + return nil | ||
158 | + case "PAYORDER": | ||
159 | + var payOrder model.PayOrder | ||
160 | + if err := json.Unmarshal([]byte(reqBody),&payOrder); err != nil { | ||
161 | + return err | ||
162 | + } | ||
163 | + return nil | ||
164 | + case "USERINFO": | ||
165 | + var getUserInfo model.GetUserInfo | ||
166 | + if err := json.Unmarshal([]byte(reqBody),&getUserInfo); err != nil { | ||
167 | + return err | ||
168 | + } | ||
169 | + return nil | ||
170 | + case "PAYORDERV1": | ||
171 | + var mergeCreateOrder model.MergeCreateOrder | ||
172 | + if err := json.Unmarshal([]byte(reqBody),&mergeCreateOrder); err != nil { | ||
173 | + return err | ||
174 | + } | ||
175 | + return nil | ||
176 | + case "UPDATEMOBILE": | ||
177 | + var updateMobile model.UpdateMobile | ||
178 | + if err := json.Unmarshal([]byte(reqBody),&updateMobile); err != nil { | ||
179 | + return err | ||
180 | + } | ||
181 | + return nil | ||
182 | + | ||
183 | + case "CREATEEMPLOYMENTPOOL": | ||
184 | + var createEmploymentPool model.CreateEmploymentPool | ||
185 | + if err := json.Unmarshal([]byte(reqBody),&createEmploymentPool); err != nil { | ||
186 | + return err | ||
187 | + } | ||
188 | + return nil | ||
189 | + } | ||
91 | return nil | 190 | return nil |
92 | } | 191 | } |
请
注册
或
登录
后发表评论