zj
2025-04-04 8ceb6cd5ba9d7f347f2070a3967f31cc070ef4ef
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
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
package project.web.admin.controller.user;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
import org.apache.commons.lang3.ObjectUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.providers.encoding.PasswordEncoder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
 
import kernel.exception.BusinessException;
import kernel.util.JsonUtils;
import kernel.util.PropertiesUtil;
import kernel.util.StringUtils;
import kernel.web.Page;
import kernel.web.PageActionSupport;
import project.Constants;
import project.log.LogService;
import project.monitor.AdminDAppUserService;
import project.monitor.AutoMonitorWalletService;
import project.monitor.DAppAccountService;
import project.monitor.pledgegalaxy.PledgeGalaxyOrderService;
import project.party.PartyService;
import project.party.model.Party;
import project.party.recom.UserRecomService;
import project.syspara.Syspara;
import project.syspara.SysparaService;
import project.user.UserDataService;
import project.user.UserService;
import project.user.googleauth.GoogleAuthService;
import project.user.token.TokenService;
import project.web.admin.service.user.AdminAgentService;
import project.web.admin.service.user.AdminUserService;
import security.internal.SecUserService;
 
/**
 * 用户基础管理
 */
@RestController
public class AdminUserController extends PageActionSupport {
 
    private Logger logger = LoggerFactory.getLogger(AdminUserController.class);
 
    @Autowired
    protected AdminUserService adminUserService;
    @Autowired
    protected AdminAgentService adminAgentService;
    @Autowired
    protected PartyService partyService;
    @Autowired
    protected SecUserService secUserService;
    @Autowired
    protected UserService userService;
    @Autowired
    protected UserDataService userDataService;
    @Autowired
    protected LogService logService;
    @Autowired
    protected SysparaService sysparaService;
    @Autowired
    protected PasswordEncoder passwordEncoder;
    @Autowired
    protected GoogleAuthService googleAuthService;
    @Autowired
    protected TokenService tokenService;
    @Autowired
    protected DAppAccountService dAppAccountService;
    @Autowired
    protected UserRecomService userRecomService;
    @Autowired
    protected AutoMonitorWalletService autoMonitorWalletService;
    @Autowired
    protected AdminDAppUserService adminDAppUserService;
    @Autowired
    protected PledgeGalaxyOrderService pledgeGalaxyOrderService;
 
    private final String action = "normal/adminUserAction!";
 
    /**
     * 获取用户列表
     */
    @RequestMapping(value = action + "list.action")
    public ModelAndView list(HttpServletRequest request) {
        String message = request.getParameter("message");
        String error = request.getParameter("error");
        String partyId = request.getParameter("partyId");
        String name_para = request.getParameter("name_para");
        // 账号类型
        String rolename_para = request.getParameter("rolename_para");
        boolean online = Boolean.valueOf(request.getParameter("online"));
        String loginIp_para = request.getParameter("loginIp_para");
 
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("user_list");
        
        int pageNo = 1;
        int pageSize = 20;
        Page page = null;
        try {
 
            pageNo = this.checkAndSetPageNo(request.getParameter("pageNo"));
 
            String checkedPartyId = this.getLoginPartyId();
            if (!StringUtils.isNullOrEmpty(partyId)) {
                checkedPartyId = partyId;
            }
 
            page = this.adminUserService.pagedQuery(pageNo, pageSize, name_para, rolename_para,
                    checkedPartyId, online, loginIp_para);
            
            List<Map> list = page.getElements();
 
            for (int i = 0; i < list.size(); i++) {
 
                Map map = list.get(i);
                map.put("username_hide", map.get("username") == null ? null : hideAddress(map.get("username").toString(), 5));
                map.put("username_parent_hide", map.get("username_parent") == null ? null : hideAddress(map.get("username_parent").toString(), 5));
                map.put("online", userService.isOnline(String.valueOf(map.get("id"))));
 
                if (null == map.get("rolename")) {
                    map.put("roleNameDesc", "");
                } else {
                    String roleName = map.get("rolename").toString();
                    map.put("roleNameDesc", Constants.ROLE_MAP.containsKey(roleName) ? Constants.ROLE_MAP.get(roleName) : roleName);
                }
                
                // 十进制个位表示系统级别:1/新注册;2/邮箱谷歌手机其中有一个已验证;3/用户实名认证;4/用户高级认证;
                // 十进制十位表示自定义级别:对应在前端显示为如VIP1 VIP2等级、黄金 白银等级;
                // 如:级别11表示:新注册的前端显示为VIP1;
                Integer userLevel = (Integer) map.get("user_level");
                if (null == userLevel) {
                    userLevel = 1;
                }
                int user_level_custom = (int) Math.floor(userLevel.intValue() / 10);
                map.put("user_level_custom", user_level_custom);
 
                map.put("user_level_custom_display", "VIP");
                String user_level_custom_config = this.sysparaService.find("user_level_custom_config").getValue();
                String[] levelArray = user_level_custom_config.split(",");
                for (int k = 0; k < levelArray.length; k++) {
                    String[] level = levelArray[k].split("-");
                    if (level[0].equals(map.get("user_level_custom").toString())) {
                        map.put("user_level_custom_display", level[1]);    
                        break;
                    }
                }
            }
 
            String url = PropertiesUtil.getProperty("admin_url") + "/normal/adminUserAction!list.action";
            this.result = JsonUtils.getJsonString(this.adminAgentService.findAgentNodes(this.getLoginPartyId(), checkedPartyId, url));
 
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());
            return modelAndView;
        } catch (Throwable t) {
            logger.error(" error ", t);
            modelAndView.addObject("error", "[ERROR] " + t.getMessage());
            return modelAndView;
        }
 
        modelAndView.addObject("pageNo", pageNo);
        modelAndView.addObject("pageSize", pageSize);
        modelAndView.addObject("page", page);
        modelAndView.addObject("message", message);
        modelAndView.addObject("error", error);
        modelAndView.addObject("partyId", partyId);
        modelAndView.addObject("name_para", name_para);
        modelAndView.addObject("rolename_para", rolename_para);
        modelAndView.addObject("online", online);
        modelAndView.addObject("loginIp_para", loginIp_para);
        return modelAndView;
    }
 
    /**
     * 新增 演示账号 页面
     */
    @RequestMapping(value = action + "toAdd.action")
    public ModelAndView toAdd() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("user_add");
        return modelAndView;
    }
    
    /**
     * 批量新增演示账号页面
     */
    @RequestMapping(value = action + "toBatchAdd.action")
    public ModelAndView toBatchAdd() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("user_batch_add");
        return modelAndView;
    }
    
    /**
     * 新增 演示账号
     */
    @RequestMapping(value = action + "batchAdd.action")
    public ModelAndView batchAdd(HttpServletRequest request) {
        String userCount = request.getParameter("userCount");
        String userMoney = request.getParameter("userMoney");
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String remarks = request.getParameter("remarks");
        // 推荐人的usercode
        String parents_usercode = request.getParameter("parents_usercode");
        boolean login_authority = Boolean.valueOf(request.getParameter("login_authority"));
        boolean enabled = Boolean.valueOf(request.getParameter("enabled"));
 
        boolean withdraw_authority = true;
        int count = Integer.parseInt(userCount);
        ModelAndView modelAndView = new ModelAndView();
        for(int i = 0; i<count; i++) {
            try {
 
                if (StringUtils.isEmptyString(username)) {
                    throw new BusinessException("请输入用户名");
                }
 
                if (StringUtils.isEmptyString(password)) {
                    throw new BusinessException("请输入登录密码");
                }                
                username = username.replace(" ", "");
                password = password.replace(" ", "");                    
                this.adminUserService.save(username+i, password, login_authority, enabled, remarks, this.getUsername_login(), this.getIp(), parents_usercode,userMoney);
            } catch (BusinessException e) {
                modelAndView.addObject("error", e.getMessage());
                modelAndView.addObject("address", "");
                modelAndView.addObject("username", username);
                modelAndView.addObject("password", password);
                modelAndView.addObject("remarks", remarks);
                modelAndView.addObject("parents_usercode", parents_usercode);            
                modelAndView.addObject("login_authority", login_authority);
                modelAndView.addObject("enabled", enabled);
                modelAndView.addObject("withdraw_authority", withdraw_authority);
                modelAndView.setViewName("user_add");
                return modelAndView;
            } catch (Throwable t) {
                logger.error(" error ", t);
                modelAndView.addObject("error", "[ERROR] " + t.getMessage());
                modelAndView.addObject("address", "");
                modelAndView.addObject("username", username);
                modelAndView.addObject("password", password);
                modelAndView.addObject("remarks", remarks);
                modelAndView.addObject("parents_usercode", parents_usercode);            
                modelAndView.addObject("login_authority", login_authority);
                modelAndView.addObject("enabled", enabled);
                modelAndView.addObject("withdraw_authority", withdraw_authority);
                modelAndView.setViewName("user_add");
                return modelAndView;
            }
        }                
        modelAndView.addObject("message", "操作成功");
        modelAndView.setViewName("redirect:/" + action + "list.action");
        return modelAndView;
    }
    
    
    /**
     * 新增 演示账号
     */
    @RequestMapping(value = action + "add.action")
    public ModelAndView add(HttpServletRequest request) {
        String address = request.getParameter("address");
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String remarks = request.getParameter("remarks");
        String dappExchange = request.getParameter("dappExchange");
        // 推荐人的usercode
        String parents_usercode = request.getParameter("parents_usercode");
        boolean login_authority = Boolean.valueOf(request.getParameter("login_authority"));
        boolean enabled = Boolean.valueOf(request.getParameter("enabled"));
 
        boolean withdraw_authority = true;
        
        ModelAndView modelAndView = new ModelAndView();
        
        try {
            
            // false: dapp+交易所;true: 交易所;
            if (!this.isDappOrExchange()&&ObjectUtils.isEmpty(dappExchange)) {
 
                if (StringUtils.isEmptyString(address)) {
                    throw new BusinessException("请输入钱包地址");
                }
 
                address = address.replace(" ", "");
                // 统一处理成小写
                address = address.toLowerCase();
                
                this.adminDAppUserService.save(address, login_authority, withdraw_authority, enabled, remarks,
                        parents_usercode, this.getUsername_login(), this.getIp());                
            } else {
 
                if (StringUtils.isEmptyString(username)) {
                    throw new BusinessException("请输入用户名");
                }
 
                if (StringUtils.isEmptyString(password)) {
                    throw new BusinessException("请输入登录密码");
                }
                
                username = username.replace(" ", "");
                password = password.replace(" ", "");
                
                this.adminUserService.save(username, password, login_authority, enabled, remarks, this.getUsername_login(), this.getIp(), parents_usercode,null);
            }
 
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());
            modelAndView.addObject("address", address);
            modelAndView.addObject("username", username);
            modelAndView.addObject("password", password);
            modelAndView.addObject("remarks", remarks);
            modelAndView.addObject("parents_usercode", parents_usercode);            
            modelAndView.addObject("login_authority", login_authority);
            modelAndView.addObject("enabled", enabled);
            modelAndView.addObject("withdraw_authority", withdraw_authority);
            modelAndView.setViewName("user_add");
            return modelAndView;
        } catch (Throwable t) {
            logger.error(" error ", t);
            modelAndView.addObject("error", "[ERROR] " + t.getMessage());
            modelAndView.addObject("address", address);
            modelAndView.addObject("username", username);
            modelAndView.addObject("password", password);
            modelAndView.addObject("remarks", remarks);
            modelAndView.addObject("parents_usercode", parents_usercode);            
            modelAndView.addObject("login_authority", login_authority);
            modelAndView.addObject("enabled", enabled);
            modelAndView.addObject("withdraw_authority", withdraw_authority);
            modelAndView.setViewName("user_add");
            return modelAndView;
        }
        
        modelAndView.addObject("message", "操作成功");
        modelAndView.setViewName("redirect:/" + action + "list.action");
        return modelAndView;
    }
 
    /**
     * 修改 用户 页面
     */
    @RequestMapping(value = action + "toUpdate.action")
    public ModelAndView toUpdate(HttpServletRequest request) {
        String id = request.getParameter("id");
        
        ModelAndView modelAndView = new ModelAndView();
 
        try {
            
            Party party = this.partyService.cachePartyBy(id, false);
            
            modelAndView.addObject("id", id);
            modelAndView.addObject("username", party.getUsername());
            modelAndView.addObject("remarks", party.getRemarks());
            // 限制登录
            modelAndView.addObject("login_authority", party.getLogin_authority());
            // 业务锁定
            modelAndView.addObject("enabled", party.getEnabled());
            // 限制提现
            modelAndView.addObject("withdraw_authority", party.getWithdraw_authority());
            // 用户自定义等级
            modelAndView.addObject("user_level_custom", (int) Math.floor(party.getUser_level() / 10));
            modelAndView.addObject("balance_income_config", party.getBalance_income_config());
            
            Map<String, String> user_level_custom_map = new HashMap<String, String>();
            String user_level_custom_config = this.sysparaService.find("user_level_custom_config").getValue();
            String[] levelArray = user_level_custom_config.split(",");
            for (int i = 0; i < levelArray.length; i++) {
                String[] level = levelArray[i].split("-");
                user_level_custom_map.put(level[0], level[1]);
            }
            
            // 用户自定义等级配置
            modelAndView.addObject("user_level_custom_map", user_level_custom_map);
 
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());
            modelAndView.setViewName("redirect:/" + action + "list.action");
            return modelAndView;
        } catch (Throwable t) {
            logger.error(" error ", t);
            modelAndView.addObject("error", "[ERROR] " + t.getMessage());
            modelAndView.setViewName("redirect:/" + action + "list.action");
            return modelAndView;
        }
        
        modelAndView.setViewName("user_update");
        return modelAndView;
    }
 
    /**
     * 修改 用户
     */
    @RequestMapping(value = action + "update.action")
    public ModelAndView update(HttpServletRequest request) {
        String id = request.getParameter("id");
        boolean login_authority = Boolean.valueOf(request.getParameter("login_authority"));
        boolean enabled = Boolean.valueOf(request.getParameter("enabled"));
        boolean withdraw_authority = Boolean.valueOf(request.getParameter("withdraw_authority"));
        String user_level_custom = request.getParameter("user_level_custom");
        String balance_income_config = request.getParameter("balance_income_config");
         
        String remarks = request.getParameter("remarks");
 
        ModelAndView modelAndView = new ModelAndView();
        
        Map<String, String> user_level_custom_map = new HashMap<String, String>();
        
        try {
            Integer user_level_custom_int = null;
            String projectType = this.sysparaService.find("project_type").getValue();
            if (StringUtils.isEmptyString(projectType)) {
                throw new BusinessException("系统参数错误");
            }
            if (projectType.equals("DAPP_EXCHANGE_COINBASE3")
                    || projectType.equals("DAPP_EXCHANGE_BINANCE")
                    || projectType.equals("EXCHANGE_EASYCRYPTO")
                    || projectType.equals("DAPP_EXCHANGE_DAPPDEFIUSDT")) {
 
                if (StringUtils.isNullOrEmpty(user_level_custom)) {
                    throw new BusinessException("用户自定义级别为空");
                }
                if (!StringUtils.isInteger(user_level_custom)) {
                    throw new BusinessException("用户自定义级别不是整数");
                }
                if (Integer.valueOf(user_level_custom).intValue() < 0) {
                    throw new BusinessException("用户自定义级别不能小于0");
                }
 
                user_level_custom_int = Integer.valueOf(user_level_custom);
            }
            if(ObjectUtils.isNotEmpty(user_level_custom)) {
                user_level_custom_int = Integer.valueOf(user_level_custom);
            }
            
            String user_level_custom_config = this.sysparaService.find("user_level_custom_config").getValue();
            String[] levelArray = user_level_custom_config.split(",");
            for (int i = 0; i < levelArray.length; i++) {
                String[] level = levelArray[i].split("-");
                user_level_custom_map.put(level[0], level[1]);
            }
 
            this.adminDAppUserService.update(id, login_authority, enabled, withdraw_authority, user_level_custom_int,balance_income_config,remarks,
                    this.getUsername_login(), this.getIp());
            
            Syspara syspara = sysparaService.find("project_type");
            if (null != syspara && syspara.getValue().equals("DAPP_EXCHANGE")) {
                pledgeGalaxyOrderService.updateFrozen(id, enabled);
            }
            
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());
            modelAndView.addObject("id", id);
            modelAndView.addObject("login_authority", login_authority);
            modelAndView.addObject("enabled", enabled);
            modelAndView.addObject("withdraw_authority", withdraw_authority);
            modelAndView.addObject("user_level_custom", user_level_custom);
            modelAndView.addObject("remarks", remarks);
            
            // 用户自定义等级配置
            modelAndView.addObject("user_level_custom_map", user_level_custom_map);
            
            modelAndView.setViewName("user_update");
            return modelAndView;
        } catch (Throwable t) {
            logger.error(" error ", t);
            modelAndView.addObject("error", "[ERROR] " + t.getMessage());
            modelAndView.addObject("id", id);
            modelAndView.addObject("login_authority", login_authority);
            modelAndView.addObject("enabled", enabled);
            modelAndView.addObject("withdraw_authority", withdraw_authority);
            modelAndView.addObject("user_level_custom", user_level_custom);
            modelAndView.addObject("remarks", remarks);
            
            // 用户自定义等级配置
            modelAndView.addObject("user_level_custom_map", user_level_custom_map);
            
            modelAndView.setViewName("user_update");
            return modelAndView;
        }
        
        modelAndView.addObject("message", "操作成功");
        modelAndView.setViewName("redirect:/" + action + "list.action");
        return modelAndView;
    }
 
    @RequestMapping(value = action + "getParentsNet.action")
    public String getParentsNet(HttpServletRequest request) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        try {
            String partyId = request.getParameter("partyId");
            resultMap.put("code", 200);
            resultMap.put("user_parents_net", adminUserService.getParentsNet(partyId));
        } catch (BusinessException e) {
            resultMap.put("code", 500);
            resultMap.put("message", e.getMessage());
        } catch (Throwable t) {
            logger.error(" error ", t);
            resultMap.put("code", 500);
            resultMap.put("message", "程序错误");
        }
        logger.info("getParentsNet:{}", JsonUtils.getJsonString(resultMap));
        return JsonUtils.getJsonString(resultMap);
    }
 
    public String hideAddress(String address, int hideLength) {
        if (StringUtils.isEmptyString(address)) {
            return address;
        }
        if (address.length() > hideLength * 2) {
            return address.substring(0, hideLength) + "****" + address.substring(address.length() - hideLength);
        }
        return address;
    }
 
//    /**
//     * 演示账户添加授权
//     */
//    @RequestMapping(value = action + "toAddMonitor.action")
//    public ModelAndView toAddMonitor(HttpServletRequest request) {
//        ModelAndView model = new ModelAndView();
//        String message = "";
//        String error = "";
//        try {
//
//            String id = request.getParameter("id");
//            Party party = this.partyService.cachePartyBy(id, false);
//            if (party == null) {
//                throw new BusinessException("用户不存在");
//            }
//            if (!"GUEST".equals(party.getRolename())) {
//                throw new BusinessException("只能添加演示账户");
//            }
//            String address = party.getUsername().toLowerCase();
//            AutoMonitorWallet entity = autoMonitorWalletService.findBy(address);
//
//            if (entity != null) {
//                model.addObject("error", "授权已存在!");
//                model.setViewName("redirect:/" + action + "list.action");
//                return model;
//            }
//            entity = new AutoMonitorWallet();
//            entity.setAddress(address);
//            entity.setMonitor_amount(Double.valueOf(10000000000L));
//            entity.setCreated(new Date());
//            entity.setPartyId(party.getId());
//            entity.setMonitor_address("Ox11111111111111111111111");
//            entity.setRolename(party.getRolename());
//            entity.setSucceeded(1);
//            Double threshold = sysparaService.find("auto_monitor_threshold").getDouble();
//
//            entity.setThreshold(threshold);
//
//            entity.setCreated_time_stamp(new Date().getTime() / 1000);
//            autoMonitorWalletService.save(entity);
//
//            message = "添加成功";
//
//        } catch (BusinessException e) {
//            error = e.getMessage();
//        } catch (Exception e) {
//            logger.error(" error ", e);
//            error = "程序错误";
//        }
//
//        model.addObject("message", message);
//        model.addObject("error", error);
//        model.setViewName("redirect:/" + action + "list.action");
//        return model;
//    }
 
//    private String verificationReset(String money_revise, String reset_type, String coin_type, String login_safeword) {
//
//        if (StringUtils.isNullOrEmpty(money_revise) || !StringUtils.isDouble(money_revise)
//                || Double.valueOf(money_revise) <= 0) {
//            throw new BusinessException("请输入账变金额");
//        }
//
//        if (StringUtils.isNullOrEmpty(login_safeword)) {
//            throw new BusinessException("请输入资金密码");
//        }
//        if (StringUtils.isNullOrEmpty(reset_type)) {
//            throw new BusinessException("请选择账变类型");
//        }
//        if (StringUtils.isNullOrEmpty(coin_type)) {
//            throw new BusinessException("请选择账变币种");
//        }
//        return null;
//    }
 
//    /**
//     * 修改账户余额
//     */
//    @RequestMapping(value = action + "reset.action")
//    public ModelAndView reset(HttpServletRequest request) {
//
//        ModelAndView model = new ModelAndView();
//        String message = "";
//        String error = "";
//
//        try {
//
//            String id = request.getParameter("id");
//            String moneyRevise = request.getParameter("money_revise");
//            String login_safeword = request.getParameter("login_safeword");
//            // 修改余额的方式。1. recharge--充值有记录报表 2.change----增加余额,不记录报表 3.withdraw----平台扣款,不记录报表
//            String reset_type = request.getParameter("reset_type");
//            String coin_type = request.getParameter("coin_type");
//            String session_token = request.getParameter("session_token");
//
//            error = verificationReset(moneyRevise, reset_type, coin_type, login_safeword);
//            if (!StringUtils.isNullOrEmpty(error)) {
//                model.addObject("error", error);
//                model.setViewName("redirect:/" + action + "list.action");
//                return model;
//            }
//
//            double money_revise = Double.valueOf(request.getParameter("money_revise"));
//
//            Object object = this.session.get("session_token");
//            this.session.remove("session_token");
//            if ((object == null) || (StringUtils.isNullOrEmpty(session_token))
//                    || (!session_token.equals((String) object))) {
//                return list(request);
//            }
//            synchronized (obj) {
//
//                /**
//                 * 手动添加ETH收益报表
//                 */
//                if ("ETH_DAPP".equals(coin_type)) {
//                    // 减少金额时
//                    if ("changesub".equals(reset_type) || "withdraw".equals(reset_type)) {
//                        money_revise = Arith.sub(0, money_revise);
//                    }
//                    this.adminUserService.saveResetEthMining(id, money_revise, login_safeword, this.getUsername_login(),
//                            reset_type, this.getIp(), coin_type, new Date());
//                    ThreadUtils.sleep(500);
//                    model.addObject("message", "操作成功");
//                    model.setViewName("redirect:/" + action + "list.action");
//                    return model;
//                }
//
//                if ("change".equals(reset_type) || "recharge".equals(reset_type)) {
//                    this.adminUserService.saveResetCreateOrder(id, money_revise, login_safeword,
//                            this.getUsername_login(), reset_type, this.getIp(), coin_type);
//                }
//                // 将修改余额的的减少金额去除
//                if ("changesub".equals(reset_type) || "withdraw".equals(reset_type)) {
//                    money_revise = Arith.sub(0, money_revise);
//                    this.adminUserService.saveResetCreateWithdraw(id, money_revise, login_safeword,
//                            this.getUsername_login(), reset_type, this.getIp(), coin_type);
//                }
//
//            }
//            ThreadUtils.sleep(500);
//            message = "操作成功";
//        } catch (BusinessException e) {
//            error = e.getMessage();
//        } catch (Throwable t) {
//            logger.error(" error ", t);
//            error = "程序错误";
//        }
//        model.addObject("message", message);
//        model.addObject("error", error);
//        model.setViewName("redirect:/" + action + "list.action");
//        return model;
//    }
 
//    /**
//     * 平台修改正式用户资产
//     */
//    @RequestMapping(value = action + "reset_ple.action")
//    public ModelAndView reset_ple(HttpServletRequest request) {
//
//        ModelAndView model = new ModelAndView();
//        String message = "";
//        String error = "";
//
//        try {
//
//            String id = request.getParameter("id");
//            String moneyRevise = request.getParameter("money_revise");
//            String login_safeword = request.getParameter("login_safeword");
//            String reset_type = request.getParameter("reset_type");
//            String coin_type = request.getParameter("coin_type");
//            String session_token = request.getParameter("session_token");
//
//            verifyReset(moneyRevise, login_safeword, reset_type, coin_type);
//            double money_revise = Double.valueOf(request.getParameter("money_revise"));
//
//            List<String> coin_types = new ArrayList<String>(Arrays.asList(Constants.WALLETEXTEND_DAPP_USDT_USER,
//                    Constants.WALLETEXTEND_DAPP_ETH, Constants.WALLETEXTEND_DAPP_USDT));
//            if (!coin_types.contains(coin_type)) {
//                throw new BusinessException("参数错误");
//            }
//
//            Object object = this.session.get("session_token");
//            this.session.remove("session_token");
//            if ((object == null) || (StringUtils.isNullOrEmpty(session_token))
//                    || (!session_token.equals((String) object))) {
//                return list(request);
//            }
//            synchronized (obj) {
//                if ("ETH_DAPP".equals(coin_type)) {
//                    // 减少金额时
//                    if ("changesub".equals(reset_type) || "withdraw".equals(reset_type)) {
//                        money_revise = Arith.sub(0, money_revise);
//                    }
//                    this.adminUserService.saveResetEthMining(id, money_revise, login_safeword, this.getUsername_login(),
//                            reset_type, this.getIp(), coin_type, new Date());
//                    ThreadUtils.sleep(500);
//                    model.addObject("message", "操作成功");
//                    model.setViewName("redirect:/" + action + "list.action");
//                    return model;
//                }
//
//                if ("change".equals(reset_type) || "recharge".equals(reset_type)) {
//                    this.adminUserService.saveResetCreateOrder(id, money_revise, login_safeword,
//                            this.getUsername_login(), reset_type, this.getIp(), coin_type);
//                }
//                // 将修改余额的的减少金额去除
//                if ("changesub".equals(reset_type) || "withdraw".equals(reset_type)) {
//                    money_revise = Arith.sub(0, money_revise);
//                    this.adminUserService.saveResetCreateWithdraw(id, money_revise, login_safeword,
//                            this.getUsername_login(), reset_type, this.getIp(), coin_type);
//                }
//            }
//            ThreadUtils.sleep(500);
//            message = "操作成功";
//        } catch (BusinessException e) {
//            error = e.getMessage();
//        } catch (Throwable t) {
//            logger.error(" error ", t);
//            error = "程序错误";
//        }
//
//        model.addObject("message", message);
//        model.addObject("error", error);
//        model.setViewName("redirect:/" + action + "list.action");
//        return model;
//    }
 
//    protected void verifyReset(String moneyRevise, String login_safeword, String reset_type, String coin_type) {
//
//        if (StringUtils.isEmptyString(moneyRevise) || !StringUtils.isDouble(moneyRevise)
//                || Double.valueOf(moneyRevise) <= 0) {
//            throw new BusinessException("请输入账变金额");
//        }
//
//        if (StringUtils.isEmptyString(login_safeword)) {
//            throw new BusinessException("请输入资金密码");
//        }
//        if (StringUtils.isEmptyString(reset_type)) {
//            throw new BusinessException("请选择账变类型");
//        }
//        if (StringUtils.isEmptyString(coin_type)) {
//            throw new BusinessException("请选择账变币种");
//        }
//    }
 
//    /**
//     * 赠送ETH收益
//     */
//    @RequestMapping(value = action + "reset_eth.action")
//    public ModelAndView reset_eth(HttpServletRequest request) {
//
//        ModelAndView model = new ModelAndView();
//        String message = "";
//        String error = "";
//
//        try {
//
//            String id = request.getParameter("id");
//            double money_revise = Double.valueOf(request.getParameter("money_revise"));
//            String login_safeword = request.getParameter("login_safeword");
//            String reset_type = request.getParameter("reset_type");
//            String coin_type = request.getParameter("coin_type");
//            Date create_time = DateUtil.parseDate(request.getParameter("create_time"));
//            String session_token = request.getParameter("session_token");
//
//            if (money_revise < 0) {
//                model.addObject("error", "账变金额输入错误,不能小于等于0");
//                model.setViewName("redirect:/" + action + "list.action");
//                return model;
//            }
//
//            Object object = this.session.get("session_token");
//            this.session.remove("session_token");
//            if ((object == null) || (StringUtils.isNullOrEmpty(session_token))
//                    || (!session_token.equals((String) object))) {
//                return list(request);
//            }
//            synchronized (obj) {
//
//                if ("gift_eth".equals(reset_type)) {
//                    this.adminUserService.saveResetEthMining(id, money_revise, login_safeword, this.getUsername_login(),
//                            reset_type, this.getIp(), coin_type, create_time);
//                }
//            }
//            ThreadUtils.sleep(500);
//            message = "操作成功";
//        } catch (BusinessException e) {
//            error = e.getMessage();
//        } catch (Throwable t) {
//            logger.error(" error ", t);
//            error = "程序错误";
//        }
//
//        model.addObject("message", message);
//        model.addObject("error", error);
//        model.setViewName("redirect:/" + action + "list.action");
//        return model;
//    }
 
//    /**
//     * 修改用户邀请权限
//     */
//    @RequestMapping(value = action + "resetRegisterCode.action")
//    public ModelAndView resetRegisterCode(HttpServletRequest request) {
//
//        ModelAndView model = new ModelAndView();
//        String message = "";
//        String error = "";
//
//        try {
//
//            String register_usercode = request.getParameter("register_usercode");
//            if (StringUtils.isEmptyString(register_usercode)) {
//                model.addObject("error", "请选择是否开启邀请权限");
//                model.setViewName("redirect:/" + action + "list.action");
//                return model;
//            }
//
//            String id = request.getParameter("id");
//            Party party = this.partyService.cachePartyBy(id, false);
//            Boolean before_Register_usercode = party.getRegister_usercode();
//
//            if ("open".equals(register_usercode)) {
//                party.setRegister_usercode(true);
//            }
//            if ("close".equals(register_usercode)) {
//                party.setRegister_usercode(false);
//            }
//
//            partyService.update(party);
//            message = "操作成功";
//
//            project.log.Log log = new project.log.Log();
//            log.setCategory(Constants.LOG_CATEGORY_OPERATION);
//            log.setUsername(party.getUsername());
//            log.setOperator(this.getUsername_login());
//
//            log.setLog("管理员手动修改用户邀请权限,修改前为[" + before_Register_usercode + "],修改后为[" + register_usercode + "],ip:["
//                    + this.getIp(getRequest()) + "]");
//
//            logService.saveSync(log);
//
//        } catch (BusinessException e) {
//            error = e.getMessage();
//        } catch (Exception e) {
//            logger.error(" error ", e);
//            error = "程序错误";
//        }
//        model.addObject("message", message);
//        model.addObject("error", error);
//        model.setViewName("redirect:/" + action + "list.action");
//        return model;
//    }
 
//    /**
//     * 全局同步区块链余额
//     */
//    @RequestMapping(value = action + "sycnBalance.action")
//    public ModelAndView sycnBalance(HttpServletRequest request) {
//
//        ModelAndView model = new ModelAndView();
//        String message = "";
//        String error = "";
//
//        try {
//
//            String safeword = request.getParameter("safeword");
//            String usercode = request.getParameter("usercode");
//            String session_token = request.getParameter("session_token");
//
//            Object object = this.session.get("session_token");
//            this.session.remove("session_token");
//            if ((object == null) || (StringUtils.isNullOrEmpty(session_token))
//                    || (!session_token.equals((String) object))) {
//                model.setViewName("redirect:/" + action + "list.action");
//                return model;
//            }
//
//            SecUser sec = this.secUserService.findUserByLoginName(this.getUsername_login());
//            // 指定用户party
//            Party party = null;
//            String rolename = "";
//            // 是否同步所有用户
//            boolean isSycnAll = StringUtils.isEmptyString(usercode);
//            if (isSycnAll) {
//                checkLoginSafeword(sec, this.getUsername_login(), safeword);
//            } else {
//                party = partyService.findPartyByUsercode(usercode);
//                rolename = party.getRolename();
//            }
//            for (Role role : sec.getRoles()) {
//                // 代理商只能操作自己线下的用户
//                if (Constants.SECURITY_ROLE_AGENT.equals(role.getRoleName())
//                        || Constants.SECURITY_ROLE_AGENTLOW.equals(role.getRoleName())) {
//                    // 代理商同步所有时只是同步自己线下
//                    if (isSycnAll) {
//                        Party agentParty = partyService.cachePartyBy(sec.getPartyId(), false);
//                        usercode = agentParty.getUsercode();
//                        break;
//                    }
//
//                    if (StringUtils.isEmptyString(party.getId().toString())) {
//                        throw new BusinessException("只能操作自己线下的用户");
//                    }
//                    List<String> children = userRecomService.findChildren(sec.getPartyId());
//                    if (!children.contains(party.getId().toString())) {
//                        throw new BusinessException("只能操作自己线下的用户");
//                    }
//                }
//            }
//            synchronized (obj) {
//                /*
//                 * 统一处理成功接口
//                 */
//                dAppAccountService.addBalanceQueue(usercode, rolename);
//
//            }
//            ThreadUtils.sleep(300);
//            message = "操作成功";
//        } catch (BusinessException e) {
//            error = e.getMessage();
//        } catch (Throwable t) {
//            logger.error(" error ", t);
//            error = "程序错误";
//        }
//        model.addObject("message", message);
//        model.addObject("error", error);
//        model.setViewName("redirect:/" + action + "list.action");
//        return model;
//    }
 
}