admin
2021-01-04 aa6ef62aef83e277d4171df1d9f0803f91738216
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
package com.newvideo.controller.parser;
 
import java.io.PrintWriter;
import java.util.List;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
 
import com.newvideo.funtv.FunTVNewApi;
import org.springframework.stereotype.Controller;
 
import com.newvideo.domain.DetailSystem;
import com.newvideo.domain.HomeNotice;
import com.newvideo.domain.HomeVideo;
import com.newvideo.domain.KKInstall;
import com.newvideo.domain.SystemInfo;
import com.newvideo.domain.UserInfo;
import com.newvideo.domain.VideoInfo;
import com.newvideo.domain.WXAd;
import com.newvideo.domain.WXStatistics;
import com.newvideo.service.imp.AdService;
import com.newvideo.service.imp.CommentService;
import com.newvideo.service.imp.HomeNoticeService;
import com.newvideo.service.imp.IntersectionService;
import com.newvideo.service.imp.OtherService;
import com.newvideo.service.imp.SystemService;
import com.newvideo.service.imp.WeiXinService;
import com.newvideo.util.Constant;
import com.newvideo.util.JsonUtil;
import com.newvideo.util.LogUtil;
import com.newvideo.util.StringUtil;
import com.newvideo.util.TimeUtil;
import com.newvideo.util.Utils;
import com.newvideo.util.zhibo.MeiNvZhiBoUtil;
 
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
 
@Controller
public class OtherParser {
    private String[] sdks = {"4.0.1", "4.0.2", "4.1.0", "4.2.2", "4.2.4", "4.4.2", "4.4.4", "5.0.1", "5.1.0"};
    private String[] fbl = {"720x1280", "480x800", "480x854", "640x960", "1080x1920"};
    @Resource
    private OtherService otherService;
    @Resource
    private WeiXinService weiXinService;
    @Resource
    private AdService adService;
    @Resource
    private SystemService systemService;
    @Resource
    private HomeNoticeService homeNoticeService;
    @Resource
    private IntersectionService intersectionService;
    @Resource
    private CommentService commentService;
    @Resource
    private MeiNvZhiBoUtil meiNvZhiBoUtil;
 
    public void advice(String uid, HttpServletRequest request, PrintWriter out) {
 
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String content = request.getParameter("Content");
        String sign = request.getParameter("Sign");
        String platform = request.getParameter("Platform");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("请上传Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("请上传Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("请上传System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("请上传Sign"));
            return;
        }
        if (StringUtil.isNullOrEmpty(content)) {
            out.print(JsonUtil.loadFalseJson("请上传Content"));
            return;
        }
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("请上传Platform"));
            return;
        }
 
        otherService.advice(uid, content);
 
        out.print(JsonUtil.loadTrueJson(""));
        out.flush();
        out.close();
        return;
 
    }
 
    public void test(String uid, HttpServletRequest request, PrintWriter out) {
 
        out.print("123");
        out.flush();
        out.close();
    }
 
    public void getWxAd(String uid, HttpServletRequest request, PrintWriter out) {
 
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String pa = request.getParameter("Package");
        String platform = request.getParameter("Platform");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("请上传Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("请上传Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("请上传System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("请上传Sign"));
            return;
        }
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("请上传Platform"));
            return;
        }
 
        List<WXAd> adList = adService.getWinAd(new SystemInfo(system));
        WXAd ad = null;
        if (adList != null && adList.size() > 0) {
            int position = (int) (adList.size() * Math.random());
            ad = adList.get(position);
        }
        if (ad != null) {
            String result = StringUtil.outPutResultJson(ad);
            out.print(JsonUtil.loadTrueJson(result));
        }
        out.flush();
        out.close();
        return;
 
    }
 
    public void wxClickAction(String uid, HttpServletRequest request, PrintWriter out) {
 
        String method = request.getParameter("Method");
 
        String id = request.getParameter("Id");
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String pa = request.getParameter("Package");
        String platform = request.getParameter("Platform");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("请上传Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("请上传Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("请上传System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("请上传Sign"));
            return;
        }
        if (StringUtil.isNullOrEmpty(id)) {
            out.print(JsonUtil.loadFalseJson("请上传Id"));
            return;
        }
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("请上传Platform"));
            return;
        }
 
        WXStatistics wx = new WXStatistics();
        wx.setAction("1");
        wx.setCreatetime((new StringBuilder(String.valueOf(System.currentTimeMillis()))).toString());
        wx.setUser(new UserInfo(uid));
        wx.setWxad(new WXAd(id));
        adService.insertWXStatistics(wx);
        out.print(JsonUtil.loadTrueJson(""));
        out.flush();
        out.close();
        return;
 
    }
 
    public void getNotice(String uid, HttpServletRequest request, PrintWriter out) {
 
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String platform = request.getParameter("Platform");
        String version = request.getParameter("Version");
        String packageName = request.getParameter("Package");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("请上传Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("请上传Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("请上传System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("请上传Sign"));
            return;
        }
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("请上传Platform"));
            return;
        }
 
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
        List<HomeNotice> list = homeNoticeService.getHomeNoticeList(detailSystem.getId());
        String content = "";
        String url = "";
        if (list != null && list.size() > 0) {
            int position = (int) ((list.size() + 1) * Math.random());
            if (position == 0)
                position = 1;
            if (position > list.size())
                position = list.size();
            HomeNotice notice = list.get(position - 1);
            long now = System.currentTimeMillis();
            if (TimeUtil.convertAllTimeToTemp(notice.getStarttime()) < now
                    && now < TimeUtil.convertAllTimeToTemp(notice.getEndtime())) {// 在显示时间内
                content = notice.getContent();
                url = notice.getUrl();
            }
        }
 
        JSONObject object = new JSONObject();
        object.put("Content", content);// content
        object.put("Url", url);// url
        object.put("ShowAd", "0");// 广告显示
 
        out.print(JsonUtil.loadTrueJson(object.toString()));
        out.flush();
        out.close();
        return;
 
    }
 
    public void getRealUrl(String uid, HttpServletRequest request, PrintWriter out) {
 
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String platform = request.getParameter("Platform");
        String url = request.getParameter("Url");
        String urlId = request.getParameter("Id");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("请上传Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("请上传Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("请上传System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("请上传Sign"));
            return;
        }
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("请上传Platform"));
            return;
        }
 
        String realUrl = "";
        if (!StringUtil.isNullOrEmpty(urlId) || !StringUtil.isNullOrEmpty(url)) {
            if (StringUtil.isNullOrEmpty(urlId)) {
                realUrl = "";
            } else {
                realUrl = "";
            }
        }
        out.print(JsonUtil.loadTrueJson("http://www.baidu.com"));
        out.flush();
        out.close();
        return;
 
 
    }
 
    public void getIntersection(String uid, HttpServletRequest request, PrintWriter out) {
 
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String platform = request.getParameter("Platform");
        String id = request.getParameter("Id");
 
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("请上传Method"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("请上传Uid"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("请上传System"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("请上传Sign"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(id)) {
            out.print(JsonUtil.loadFalseJson("请上传Id"));
            return;
        }
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("请上传Platform"));
            return;
        }
 
        List<VideoInfo> list = intersectionService.getIntersectionVideoList(id);
        if (list != null && list.size() > 0) {
            JSONObject object = new JSONObject();
            object.put("count", (new StringBuilder(String.valueOf(list.size()))).toString());
            JSONArray array = new JSONArray();
            for (int i = 0; i < list.size(); i++)
                array.add(StringUtil.outPutResultJson(list.get(i)));
            object.put("data", array);
            out.print(JsonUtil.loadTrueJson(object.toString()));
        } else
            out.print(JsonUtil.loadFalseJson("没有数据"));
        out.flush();
        out.close();
        return;
 
    }
 
    public void getMeiNvZhiBo(String uid, HttpServletRequest request, PrintWriter out) {
 
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String platform = request.getParameter("Platform");
        String type = request.getParameter("Type");
 
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("请上传Method"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("请上传Uid"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("请上传System"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("请上传Sign"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(type)) {
            out.print(JsonUtil.loadFalseJson("请上传Type"));
            return;
        }
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("请上传Platform"));
            return;
        }
 
 
        List<HomeVideo> list = meiNvZhiBoUtil.getMeiNvZhiBo(type);
        if (list != null && list.size() > 0) {
            JSONObject object = new JSONObject();
            object.put("count", (new StringBuilder(String.valueOf(list.size()))).toString());
            JSONArray array = new JSONArray();
            for (int i = 0; i < list.size(); i++)
                array.add(StringUtil.outPutResultJson(list.get(i)));
            object.put("data", array);
            out.print(JsonUtil.loadTrueJson(object.toString()));
        } else
            out.print(JsonUtil.loadFalseJson("没有数据"));
        out.flush();
        out.close();
        return;
 
    }
 
    public void getYearList(String uid, HttpServletRequest request, PrintWriter out) {
 
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String platform = request.getParameter("Platform");
 
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("请上传Method"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("请上传Uid"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("请上传System"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("请上传Sign"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("请上传Platform"));
            return;
        }
 
 
        JSONArray array = new JSONArray();
        String[] sts = Constant.YEARS;
        for (int i = 0; i < sts.length; i++) {
            JSONObject obj = new JSONObject();
            obj.put("Name", sts[i]);
            obj.put("Id", i);
            array.add(obj);
        }
        out.print(JsonUtil.loadTrueJson(array.toString()));
        out.flush();
        out.close();
        return;
 
    }
 
    public void kkInstall(String uid, HttpServletRequest request, PrintWriter out) {
 
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String platform = request.getParameter("Platform");
        String packageName = request.getParameter("Package");
 
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("请上传Method"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("请上传Uid"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("请上传System"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("请上传Sign"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("请上传Platform"));
            return;
        }
 
        KKInstall kk = new KKInstall();
        kk.setCreatetime(System.currentTimeMillis() + "");
        kk.setUser(new UserInfo(uid));
        kk.setPackageName(packageName);
 
        LogUtil.i("用户" + uid + "安装KK插件");
        out.print(JsonUtil.loadTrueJson(""));
        out.flush();
        out.close();
        return;
 
    }
 
    public void addContact(String uid, HttpServletRequest request, PrintWriter out) {
 
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String platform = request.getParameter("Platform");
        String packageName = request.getParameter("Package");
        String contact = request.getParameter("Contact");
 
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("请上传Method"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("请上传Uid"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("请上传System"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("请上传Sign"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("请上传Platform"));
            return;
        }
 
        if (!StringUtil.isNullOrEmpty(contact)) {
            String da = StringUtil.getFromBase64(contact);
            JSONArray array = JSONArray.fromObject(da);
            for (int i = 0; i < array.size(); i++) {
                JSONObject obj = array.optJSONObject(i);
                otherService.addContact(obj.optString("Name"), obj.optString("Mobile"));
            }
        }
        return;
 
    }
 
 
    /**
     * 获取风行授权码
     *
     * @param request
     * @param out
     */
    public void getFuntvAuthCode(HttpServletRequest request, PrintWriter out) {
        String authCode = null;
        authCode = FunTVNewApi.getAuthCode();
        out.print(JsonUtil.loadTrueJson(authCode));
    }
}