CosPlyaPlayerServiceImpl.java
12.4 KB
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
package com.pipi.qa.service.impl;
import java.util.HashMap;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.pipi.qa.basic.BasicData;
import com.pipi.qa.framework.tools.HttpToolKit;
import com.pipi.qa.service.CosPlayPlayerService;
/**
* Created by dennis.dong on 2021/05/18.
*/
@Service
public class CosPlyaPlayerServiceImpl implements CosPlayPlayerService {
public static Map<String, Object> headers = new HashMap<String, Object>();
public static String cardUrl = "https://test-game-play.oss-cn-hangzhou.aliyuncs.com/temp/2021/4/17/991a50cab9594ce9b7827744f8286b09.jpg";
public static String cardHandUrl = "https://test-game-play.oss-cn-hangzhou.aliyuncs.com/temp/2021/4/17/66ed341c47764ff1b12c834eda023956.jpg";
public static String emblemUrl = "https://test-game-play.oss-cn-hangzhou.aliyuncs.com/temp/2021/4/17/66ed341c47764ff1b12c834eda023956.jpg";
public static String pngURL = "http://test-game-play.oss-cn-hangzhou.aliyuncs.com/temp/2020/11/11/c343b09eccfe4f14b56f33b2f42041d2.jpg";
/**
* 登录
* @param env
* @param mobile
* @return
*/
@Override
public JSONObject login(String mobile,String env) {
String loginUrl = "https://"+env+"-api-app.apeiwan.com/"+"login";
String smsUrl = "https://"+env+"-api-app.apeiwan.com/"+"sms/verify";
Map<String, Object> params = new HashMap();
Map<String, Object> SmsParams = new HashMap();
SmsParams.put("mobile", mobile);
//获取验证码
HttpToolKit.invokePost(smsUrl, null, SmsParams);
params.put("mobile", mobile);
params.put("code", 2222);
//登录
JSONObject jsonObj = HttpToolKit.invokePost(loginUrl, null, params).getJSONObject();
return jsonObj;
}
/**
* 获取token
* @param env
* @param mobile
* @return
*/
@Override
public String getAppToken(String mobile,String env) {
JSONObject loginRes = this.login(mobile, env);
String token = loginRes.getJSONObject("data").getString("token");
return token;
}
/**
* 获取admin token
* @param env
* @param mobile
* @return
*/
@Override
public String getAdminToken(String username,String password,String env) {
String adminLoginUrl = "https://"+env+"-api-admin.apeiwan.com/login";
Map<String, Object> params = new HashMap();
params.put("username", username);
params.put("password", password);
JSONObject jsonObj = HttpToolKit.invokePost(adminLoginUrl, null, params ).getJSONObject();
String token = jsonObj.getJSONObject("data").getString("token");
return token;
}
/**
* 实名认证
* @param env
* @param mobile
* @return
*/
@Override
public JSONObject SubmitAuthentication(String token,String userId,String env) {
logger.info("token:"+token);
logger.info("userId:"+userId);
headers.put("token", token);
Map<String, Object> params = new HashMap();
params.put("authType", 0);
params.put("userId", userId);
params.put("userName", "testc");
params.put("cardNo", "12124333541551");
params.put("cardHandUrl", cardHandUrl);
params.put("cardUrl", cardUrl);
params.put("emblemUrl", emblemUrl);
params.put("gender", 1);
//实名认证申请
String authUrl = "https://"+env+"-api-h5.apeiwan.com/api/v2/user/body-auth/save";
HttpToolKit.invokePost(authUrl, headers, params);
//获取控制台用户token
String adminToken = getAdminToken(BasicData.userName, BasicData.passWord, env);
String passUrl = "https://"+env+"-api-admin.apeiwan.com/api/v1/user/body-auth/pass";
Map<String, Object> headers1 = new HashMap();
headers1.put("token", adminToken);
//实名认证同意
JSONObject jsonObj = HttpToolKit.invokePost(passUrl, headers1, params).getJSONObject();
return jsonObj;
}
/**
* 提交个人资料及审核
* @param env
* @param mobile
* @return
*/
@Override
public JSONObject saveUserInfo(String token,String userId,String env) {
//提交个人资料
headers.put("token", token);
String saveUserInfoUrl = "https://"+env+"-api-h5.apeiwan.com/api/v2/user/save-user-info";
Map<String, Object> params = new HashMap();
params.put("nickName", "test");
params.put("headPortraitsUrl", pngURL);
params.put("picUrls", pngURL);
params.put("videoUrl", pngURL);
HttpToolKit.invokePost(saveUserInfoUrl, headers, params).getJSONObject();
//获取控制台用户token
String adminToken = getAdminToken(BasicData.userName, BasicData.passWord, env);
String authUpdateUrl = "https://"+env+"-api-admin.apeiwan.com/api/v2/user/info-auth-update";
Map<String, Object> headers1 = new HashMap();
headers1.put("token", adminToken);
//个人资料审核通过
Map<String, Object> updateParams = new HashMap();
updateParams.put("userId", userId);
updateParams.put("status", 2);
updateParams.put("reasonJSon", "");
JSONObject jsonObj = HttpToolKit.invokePost(authUpdateUrl, headers1, updateParams).getJSONObject();
return jsonObj;
}
/**
* 充钻石
* @param env
* @param mobile
* @return
*/
@Override
public JSONObject virtualMoneyModify(String mobile,long money,String env) {
//获取控制台用户token
String adminToken = getAdminToken(BasicData.userName, BasicData.passWord, env);
//根据用户手机号获取userId
String userListUrl = "https://"+env+"-api-admin.apeiwan.com/api/v1/user/list";
Map<String, Object> adminHeaders = new HashMap();
adminHeaders.put("token", adminToken);
Map<String, Object> updateParams = new HashMap();
updateParams.put("pageNum", 1);
updateParams.put("pageSize", 10);
updateParams.put("mobile", mobile);
JSONObject jsonObj = HttpToolKit.invokePost(userListUrl, adminHeaders, updateParams).getJSONObject();
JSONArray jsonArr = jsonObj.getJSONObject("data").getJSONArray("list");
JSONObject jsonObj1 = (JSONObject) jsonArr.get(0);
String userId = jsonObj1.getString("id");
logger.info("userId:"+userId);
//充值钻石
String virtualMoneyModifyUrl = "https://"+env+"-api-admin.apeiwan.com/api/v1/moneyDetails/virtual-money/modify";
Map<String, Object> modifyParams = new HashMap();
modifyParams.put("userId", userId);
modifyParams.put("type", 1);
modifyParams.put("remark", "1");
modifyParams.put("ext", "1");
modifyParams.put("money", money);
JSONObject modifyJsonObj = HttpToolKit.invokePost(virtualMoneyModifyUrl, adminHeaders, modifyParams).getJSONObject();
return jsonObj1;
}
/**
* 充皮皮币
* @param env
* @param mobile
* @return
*/
@Override
public JSONObject moneyDetailsSave(String mobile,long money,String env) {
//获取控制台用户token
String adminToken = getAdminToken(BasicData.userName, BasicData.passWord, env);
//根据用户手机号获取userId
String userListUrl = "https://"+env+"-api-admin.apeiwan.com/api/v1/user/list";
Map<String, Object> adminHeaders = new HashMap();
adminHeaders.put("token", adminToken);
Map<String, Object> updateParams = new HashMap();
updateParams.put("pageNum", 1);
updateParams.put("pageSize", 10);
updateParams.put("mobile", mobile);
JSONObject jsonObj = HttpToolKit.invokePost(userListUrl, adminHeaders, updateParams).getJSONObject();
JSONArray jsonArr = jsonObj.getJSONObject("data").getJSONArray("list");
JSONObject jsonObj1 = (JSONObject) jsonArr.get(0);
String userId = jsonObj1.getString("id");
String nickname = jsonObj1.getString("nickname");
String balance = jsonObj1.getString("balance");
String chargeBalance = jsonObj1.getString("chargeBalance");
logger.info("userId:"+userId);
//充皮皮币
String saveUrl = "https://"+env+"-api-admin.apeiwan.com/api/v1/moneyDetails/save";
Map<String, Object> saveParams = new HashMap();
saveParams.put("mobile", mobile);
saveParams.put("userId", userId);
saveParams.put("moneyType", 1);
saveParams.put("remark", "1");
saveParams.put("ext", "1");
saveParams.put("money", money);
saveParams.put("nickname", nickname);
saveParams.put("balance", balance);
saveParams.put("chargeBalance", chargeBalance);
saveParams.put("isSearch", true);
saveParams.put("searchValue", userId);
JSONObject saveJsonObj = HttpToolKit.invokePost(saveUrl, adminHeaders, saveParams).getJSONObject();
return jsonObj1;
}
/**
* 送礼物
* @param env
* @param mobile
* @return
*/
@Override
public JSONObject send(String mobile, String roomNo,String productId,String amount, String userIds,String env) {
String sendUrl = "https://"+env+"-api-app.apeiwan.com/api/v4/room/gift/send";
String appToken = this.getAppToken(mobile, env);
Map<String, Object> sendParams = new HashMap();
headers.put("token", appToken);
sendParams.put("actionType", "1");
sendParams.put("amount", amount);
sendParams.put("roomNo", roomNo);
sendParams.put("productId", productId);
sendParams.put("userIds", userIds);
sendParams.put("timestamp", "1621828487580");
JSONObject jsonObj = HttpToolKit.invokePost(sendUrl, headers, sendParams).getJSONObject();
return jsonObj;
}
/**
* 礼物列表
* @param env
* @param mobile
* @return
*/
@Override
public JSONObject giftList(String env) {
//获取控制台用户token
String adminToken = getAdminToken(BasicData.userName, BasicData.passWord, env);
Map<String, Object> adminHeaders = new HashMap();
adminHeaders.put("token", adminToken);
//查询礼物列表
String giftListUrl = "https://"+env+"-api-admin.apeiwan.com/api/v1/virtual-product/gift-list";
Map<String, Object> giftListParams = new HashMap();
giftListParams.put("pageNum", "1");
giftListParams.put("pageSize", "10");
giftListParams.put("useStatus", "1");
giftListParams.put("type", "1");
JSONObject giftListJsonObj = HttpToolKit.invokePost(giftListUrl, adminHeaders, giftListParams).getJSONObject();
return giftListJsonObj;
}
/**
* 幸运夺宝箱列表
* @param env
* @param mobile
* @return
*/
@Override
public JSONObject activityList(String env) {
//获取控制台用户token
String adminToken = getAdminToken(BasicData.userName, BasicData.passWord, env);
Map<String, Object> adminHeaders = new HashMap();
adminHeaders.put("token", adminToken);
//幸运夺宝箱列表
String giftListUrl = "https://"+env+"-api-admin.apeiwan.com/api/v1/lottery/activity/list";
Map<String, Object> activityListParams = new HashMap();
activityListParams.put("pageNum", "1");
activityListParams.put("pageSize", "10");
activityListParams.put("activityType", "1");
JSONObject giftListJsonObj = HttpToolKit.invokePost(giftListUrl, adminHeaders, activityListParams).getJSONObject();
return giftListJsonObj;
}
/**
* 开宝箱
* @param env
* @param mobile
* @return
*/
@Override
public JSONObject lotteryActivity(String mobile,String roomNo, String activityId,String times,String env) {
String sendUrl = "https://"+env+"-api-app.apeiwan.com/api/v3/virtual-product/lottery-activity";
String appToken = this.getAppToken(mobile, env);
Map<String, Object> sendParams = new HashMap();
headers.put("token", appToken);
sendParams.put("activityId", activityId);
sendParams.put("roomNo", roomNo);
sendParams.put("times", times);
sendParams.put("timestamp", "1621828487580");
JSONObject jsonObj = HttpToolKit.invokePost(sendUrl, headers, sendParams).getJSONObject();
return jsonObj;
}
public static void main(String args[]){
CosPlyaPlayerServiceImpl CosPlyaPlayerServiceImpl = new CosPlyaPlayerServiceImpl();
String env = "t5";
String mobile = "13823774138";
String roomNo = "TEST902661";
String productId = "444";
String userIds = "2952662,2952651";
String amount="1";
long money=10;
String times="1";
String activityId="110";
//JSONObject loginRes = CosPlyaPlayerServiceImpl.login(mobile,env);
//String token = loginRes.getJSONObject("data").getString("token");
//String userId = loginRes.getJSONObject("data").getString("id");
//CosPlyaPlayerServiceImpl.SubmitAuthentication(token,userId,env);
//CosPlyaPlayerServiceImpl.saveUserInfo(token, userId, env);
//CosPlyaPlayerServiceImpl.virtualMoneyModify(mobile,money,env);
//CosPlyaPlayerServiceImpl.send(mobile, roomNo, productId,amount,userIds,env);
//CosPlyaPlayerServiceImpl.giftList(env);
//CosPlyaPlayerServiceImpl.moneyDetailsSave(mobile, money, env);
//CosPlyaPlayerServiceImpl.activityList(env);
CosPlyaPlayerServiceImpl.lotteryActivity(mobile, roomNo, activityId, times, env);
}
}