peternameyakj
2025-04-29 acf1c75a32aa05f34d9d60b6ae3f3e052b532e9f
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
package project.web.admin.controller.user;
 
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
 
import javax.servlet.http.HttpServletRequest;
 
import kernel.web.ApplicationUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.http.util.TextUtils;
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.Arith;
import kernel.util.StringUtils;
import kernel.util.ThreadUtils;
import kernel.web.Page;
import kernel.web.PageActionSupport;
import project.Constants;
import project.log.LogService;
import project.monitor.job.transferfrom.LockFilter;
import project.party.PartyService;
import project.party.model.Party;
import project.syspara.SysparaService;
import project.user.UserData;
import project.user.UserDataService;
import project.user.googleauth.GoogleAuthService;
import project.user.token.Token;
import project.user.token.TokenService;
import project.web.admin.service.user.AdminUserService;
import security.SecUser;
import security.internal.SecUserService;
 
/**
 * 交易所_用户管理
 */
@RestController
public class ExchangeAdminUserController extends PageActionSupport {
 
    private Logger logger = LoggerFactory.getLogger(ExchangeAdminUserController.class);
 
    @Autowired
    protected AdminUserService adminUserService;
    @Autowired
    protected UserDataService userDataService;
    @Autowired
    protected SysparaService sysparaService;
    @Autowired    
    protected PartyService partyService;
    @Autowired
    protected SecUserService secUserService;
    @Autowired
    protected GoogleAuthService googleAuthService;
    @Autowired
    protected PasswordEncoder passwordEncoder;
    @Autowired
    protected LogService logService;
    @Autowired
    protected TokenService tokenService;
 
    private final String action = "normal/exchangeAdminUserAction!";
 
    /**
     * 获取用户列表
     */
    @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_exchange");
 
        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.exchangePagedQuery(pageNo, pageSize, name_para, rolename_para,
                    checkedPartyId, null, loginIp_para);
            List<Map> list = page.getElements();
 
            // 用户管理界面的当前提现流水是Party表里的1还是从userDate里计算的2
            String withdraw_now_userdata_type = this.sysparaService.find("withdraw_now_userdata_type").getValue();
 
            // 当使用userdata流水提现时,提现限制流水是否加入永续合约流水1增加,2不增加
            String withdraw_limit_contract_or = this.sysparaService.find("withdraw_limit_contract_or").getValue();
 
            for (int i = 0; i < list.size(); i++) {
                Map map = list.get(i);
                if(ObjectUtils.isNotEmpty(map)) {
                    if(ObjectUtils.isNotEmpty(map.get("money"))) {
                        map.put("money", new BigDecimal(map.get("money").toString()).setScale(2, RoundingMode.DOWN));
                    }
                }                                
                // 用户当前流水Party表
                if ("1".equals(withdraw_now_userdata_type)) {
                    map.put("userdata_turnover", map.get("withdraw_limit_now_amount"));
                }
 
                // 用户当前流水UserData表实时计算
                if ("2".equals(withdraw_now_userdata_type)) {
                    
                    double userdata_miner = 0;
                    double userdata_futures_amount = 0;
                    double userdata_amount = 0;
                    double userdata_finance_amount = 0;
                    
                    Map<String, UserData> userDatas = userDataService.cacheByPartyId(map.get("id").toString());
                    if (userDatas != null) {
                        
                        Set<Map.Entry<String, UserData>> entrySet = userDatas.entrySet();
                        Iterator<Map.Entry<String, UserData>> it = entrySet.iterator();
                        
                        while (it.hasNext()) {
                            Map.Entry<String, UserData> me = it.next();
                            UserData userData = me.getValue();
                            if (userData != null) {
                                if (isNow(userData.getCreateTime())) {
                                    userdata_miner = userData.getMiner_amount();
                                    userdata_futures_amount = userData.getFurtures_amount();
                                    userdata_amount = userData.getAmount();
                                    userdata_finance_amount = userData.getFinance_amount();
                                }
                            }
                        }
                    }
                    
                    if ("2".equals(withdraw_limit_contract_or)) {
                        userdata_amount = 0;
                    }
                    
                    map.put("userdata_turnover", Arith.add(Arith.add(userdata_miner, userdata_futures_amount),
                            Arith.add(userdata_finance_amount, userdata_amount)));
                }
 
                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);
                }
            }
 
        } 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("loginIp_para", loginIp_para);
        return modelAndView;
    }
    
 
    /**
     * 交易所 修改冻结余额
     */
    @RequestMapping(value = action + "resetFreeze.action")
    public ModelAndView resetFreeze(HttpServletRequest request) {    
        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");
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("redirect:/" + action + "list.action");
 
        boolean lock = false;
        try {
            
            String error = this.verificationResetLock(moneyRevise, reset_type, coin_type, login_safeword);
            if (!StringUtils.isNullOrEmpty(error)) {
                throw new BusinessException(error);
            }
 
            if (!LockFilter.add(id)) {
                throw new BusinessException("请稍后再试");
            }
            lock = true;
 
            double money_revise = Double.valueOf(moneyRevise).doubleValue();
 
            adminUserService.saveResetLock(id, money_revise,login_safeword,this.getUsername_login(),reset_type,this.getIp(),coin_type);            
            
            ThreadUtils.sleep(300);
            
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());
            return modelAndView;
        } catch (Throwable t) {
            logger.error("update error ", t);
            modelAndView.addObject("error", "程序错误");
            return modelAndView;
        } finally {
            if (lock) {
                LockFilter.remove(id);
            }
        }
        
        modelAndView.addObject("message", "操作成功");
        return modelAndView;
        
    }
 
    /**
     * 交易所 修改锁定余额
     */
    @RequestMapping(value = action + "resetLock.action")
    public ModelAndView resetLock(HttpServletRequest request) {    
        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");
        
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("redirect:/" + action + "list.action");
 
        boolean lock = false;
        try {
 
            String error = this.verificationResetLock(moneyRevise, reset_type, coin_type, login_safeword);
            if (!StringUtils.isNullOrEmpty(error)) {
                throw new BusinessException(error);
            }
 
            if (!LockFilter.add(id)) {
                throw new BusinessException("请稍后再试");
            }
            lock = true;
 
            double money_revise = Double.valueOf(moneyRevise).doubleValue();
 
            adminUserService.saveResetLock(id, money_revise,login_safeword,this.getUsername_login(),reset_type,this.getIp(),coin_type);            
            
            ThreadUtils.sleep(300);
            
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());
            return modelAndView;
        } catch (Throwable t) {
            logger.error("update error ", t);
            modelAndView.addObject("error", "程序错误");
            return modelAndView;
        } finally {
            if (lock) {
                LockFilter.remove(id);
            }
        }
        
        modelAndView.addObject("message", "操作成功");
        return modelAndView;
        
    }
 
    /**
     * 交易所 修改账户余额
     */
    @RequestMapping(value = action + "reset_exchange.action")
    public ModelAndView reset_exchange(HttpServletRequest request) {
        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 changeType = request.getParameter("changeType");
        if(StringUtils.isNotEmpty(changeType)) {
            reset_type = "change";
            coin_type = "usdt";
        }
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("redirect:/" + action + "list.action");
 
        boolean lock = false;
        try {
 
            String error = this.verificationReset(moneyRevise, reset_type, coin_type, login_safeword);
            if (!StringUtils.isNullOrEmpty(error)) {
                throw new BusinessException(error);
            }
 
            if (!LockFilter.add(id)) {
                throw new BusinessException("请稍后再试");
            }
            lock = true;
 
            double money_revise = Double.valueOf(moneyRevise).doubleValue();
 
            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(100);
            
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());
            return modelAndView;
        } catch (Throwable t) {
            logger.error("update error ", t);
            modelAndView.addObject("error", "程序错误");
            return modelAndView;
        } finally {
            if (lock) {
                LockFilter.remove(id);
            }
        }
        
        modelAndView.addObject("message", "操作成功");
        return modelAndView;
    }
 
    /**
     * 在提现限额开启情况下,修改可提现流水限制
     */
    @RequestMapping(value = action + "resetWithdraw.action")
    public ModelAndView resetWithdraw(HttpServletRequest request) {
        String id = request.getParameter("id");
        // 可提现额度
        String money_withdraw = request.getParameter("money_withdraw");
 
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("redirect:/" + action + "list.action");
 
        boolean lock = false;
        try {
            
            if (StringUtils.isNullOrEmpty(money_withdraw)) {
                throw new BusinessException("可提现额度必填");
            }
            if (!StringUtils.isDouble(money_withdraw)) {
                throw new BusinessException("可提现额度输入错误,请输入浮点数");
            }
            
            // 可提现额度
            double money_withdraw_double = Double.valueOf(money_withdraw).doubleValue();
 
            if (!LockFilter.add(id)) {
                throw new BusinessException("请稍后再试");
            }
            lock = true;
            
            this.adminUserService.saveResetWithdraw(id, money_withdraw_double, this.getUsername_login(), this.getIp());
            
            ThreadUtils.sleep(300);
            
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());
            return modelAndView;
        } catch (Throwable t) {
            logger.error("update error ", t);
            modelAndView.addObject("error", "程序错误");
            return modelAndView;
        } finally {
            if (lock) {
                LockFilter.remove(id);
            }
        }
        
        modelAndView.addObject("message", "操作成功");
        return modelAndView;
    }
 
    /**
     * 重置登录密码
     */
    @RequestMapping(value = action + "resetpsw.action")
    public ModelAndView resetpsw(HttpServletRequest request) {
        String message = "";
        String error = "";
        try {
 
            String id = request.getParameter("id");
            String google_auth_code = request.getParameter("google_auth_code");
            String login_safeword = request.getParameter("login_safeword");
            String email_code = request.getParameter("email_code");
 
            SecUser sec = this.secUserService.findUserByLoginName(this.getUsername_login());
 
            googleAuthService.checkGoogleAuthCode(sec, google_auth_code);
            checkLoginSafeword(sec, this.getUsername_login(), login_safeword);
 
            String password = request.getParameter("password").replace(" ", "");
            Party party = this.partyService.cachePartyBy(id, true);
            this.secUserService.updatePassword(party.getUsername(), password);
            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("管理员手动修改登录密码,验证码:[" + email_code + "]" + ",ip:[" + this.getIp(getRequest()) + "]");
            logService.saveSync(log);
 
        } catch (BusinessException e) {
            error = e.getMessage();
        } catch (Exception e) {
            logger.error(" error ", e);
            error = "程序错误";
        }
 
        ModelAndView model = new ModelAndView();
        model.addObject("message", message);
        model.addObject("error", error);
        model.setViewName("redirect:/" + action + "list.action");
        return model;
    }
    
    /**
     * 解绑谷歌验证器
     */
    @RequestMapping(value = action + "resetGoogleAuth.action")
    public ModelAndView resetGoogleAuth(HttpServletRequest request) {
        String message = "";
        String error = "";
        try {
 
            String google_auth_code = request.getParameter("google_auth_code");
            String login_safeword = request.getParameter("login_safeword");
            String id = request.getParameter("id");
 
            SecUser sec = this.secUserService.findUserByLoginName(this.getUsername_login());
            googleAuthService.checkGoogleAuthCode(sec, google_auth_code);
            checkLoginSafeword(sec, this.getUsername_login(), login_safeword);
            Party party = this.partyService.cachePartyBy(id, true);
            SecUser sec_user = this.secUserService.findUserByPartyId(party.getId());
            sec_user.setGoogle_auth_bind(false);
            sec_user.setGoogle_auth_secret("");
            this.secUserService.update(sec_user);
            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("管理员手动解绑用户谷歌验证器,ip:[" + this.getIp(getRequest()) + "]");
            this.logService.saveSync(log);
 
        } catch (BusinessException e) {
            error = e.getMessage();
        } catch (Exception e) {
            logger.error(" error ", e);
            error = "程序错误";
        }
        ModelAndView model = new ModelAndView();
        model.addObject("message", message);
        model.addObject("error", error);
        model.setViewName("redirect:/" + action + "list.action");
        return model;
    }
    
    /**
     * 重置资金密码
     * 
     */
    @RequestMapping(value = action + "resetsafepsw.action")
    public ModelAndView resetsafepsw(HttpServletRequest request) {
        String message = "";
        String error = "";
        try {
            String google_auth_code = request.getParameter("google_auth_code");
            String login_safeword = request.getParameter("login_safeword");
            String safeword = request.getParameter("safeword");
            String id = request.getParameter("id");
            if (!StringUtils.isNullOrEmpty(safeword)) {
                SecUser sec = this.secUserService.findUserByLoginName(this.getUsername_login());
                googleAuthService.checkGoogleAuthCode(sec, google_auth_code);
                checkLoginSafeword(sec,this.getUsername_login(), login_safeword);
                
                safeword = safeword.replace(" ", "");
                Party party = this.partyService.cachePartyBy(id,false);
                this.partyService.updateSafeword(party, safeword);
                message = "操作成功";
 
                if(!"root".equals(this.getUsername_login())) {
                    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("管理员手动修改资金密码,ip:["+this.getIp(getRequest())+"]");
 
                    logService.saveSync(log);
                }
            }
        } catch (BusinessException e) {
            error = e.getMessage();
        } catch (Exception e) {
            logger.error(" error ", e);
            error = "程序错误";
        }
        ModelAndView model = new ModelAndView();
        model.addObject("message", message);
        model.addObject("error", error);
        model.setViewName("redirect:/" + action + "list.action");
        return model;
    }
 
 
 
    @RequestMapping(value = action + "openBlack.action")
    public ModelAndView openBlack(HttpServletRequest request) {
        String message = "";
        String error = "";
        try {
            String id = request.getParameter("id");
            String openBlack = request.getParameter("openBlack");
            String level = request.getParameter("level");
            String lever = request.getParameter("lever");
            Party party = partyService.cachePartyBy(id,false);
            if(party == null){
                message = "操作失败";
                error = "修改错误";
            }else{
                if(!TextUtils.isEmpty(level)){
                    party.setUser_level(Integer.parseInt(level));
                }
 
                if(!TextUtils.isEmpty(lever)){
                    party.setLever(lever);
                }
 
                if(!TextUtils.isEmpty(openBlack)){
                    if(openBlack.equals("0")){
                        openBlack = "1";
                    }else{
                        openBlack = "0";
                    }
                    party.setOpenBlank(Integer.parseInt(openBlack));
                }
                this.partyService.update(party);
                message = "操作成功";
            }
 
        } catch (BusinessException e) {
            error = e.getMessage();
        } catch (Exception e) {
            logger.error(" error ", e);
            System.out.println("修改做空");
            e.printStackTrace();
            error = "程序错误";
        }
        ModelAndView model = new ModelAndView();
        model.addObject("message", message);
        model.addObject("error", error);
        model.setViewName("redirect:/" + action + "list.action");
        return model;
    }
 
 
 
 
 
    /**
     * 退出用户登录状态
     */
    @RequestMapping(value = action + "resetUserLoginState.action")
    public ModelAndView resetUserLoginState(HttpServletRequest request) {
        ModelAndView model = new ModelAndView();
        String message = "";
        String error = "";
        try {
 
            String google_auth_code = request.getParameter("google_auth_code");
            String login_safeword = request.getParameter("login_safeword");
            String id = request.getParameter("id");
 
            SecUser sec = this.secUserService.findUserByLoginName(this.getUsername_login());
            googleAuthService.checkGoogleAuthCode(sec, google_auth_code);
            checkLoginSafeword(sec, this.getUsername_login(), login_safeword);
            Party party = this.partyService.cachePartyBy(id, true);
 
            Token token = this.tokenService.find(party.getId().toString());
            if (token != null) {
                tokenService.delete(token.getToken());
 
                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("管理员手动退出用户登录状态,ip:[" + this.getIp(getRequest()) + "]");
                this.logService.saveSync(log);
            } else {
                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;
    }
 
 
 
    /**
     * 退出用户登录状态
     */
    @RequestMapping(value = action + "deleteUser.action")
    public ModelAndView deleteUser(HttpServletRequest request) {
        ModelAndView model = new ModelAndView();
        String message = "";
        String error = "";
        try {
 
            String google_auth_code = request.getParameter("google_auth_code");
            String login_safeword = request.getParameter("login_safeword");
            String id = request.getParameter("id");
 
            SecUser sec = this.secUserService.findUserByLoginName(this.getUsername_login());
            googleAuthService.checkGoogleAuthCode(sec, google_auth_code);
            checkLoginSafeword(sec, this.getUsername_login(), login_safeword);
            this.partyService.updateOpenBlack(id, "");
            Token token = this.tokenService.find(id);
            if (token != null) {
                tokenService.delete(token.getToken());
            }
            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 static boolean isNow(Date date) {
        // 当前时间
        Date now = new Date();
        SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
        // 获取今天的日期
        String nowDay = sf.format(now);
        String day = sf.format(date);
        return day.equals(nowDay);
    }
    
    private String verificationResetLock(String money_revise, String reset_type, String coin_type, String login_safeword) {
        if (StringUtils.isNullOrEmpty(money_revise)) {
            throw new BusinessException("账变金额必填");
        }
        if (!StringUtils.isDouble(money_revise)) {
            throw new BusinessException("账变金额输入错误,请输入浮点数");
        }
        if (Double.valueOf(money_revise).doubleValue() <= 0) {
            throw new BusinessException("账变金额不能小于等于0");
        }
 
        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;
    }
    
 
    private String verificationReset(String money_revise, String reset_type, String coin_type, String login_safeword) {
                
        if (StringUtils.isNullOrEmpty(money_revise)) {
            throw new BusinessException("账变金额必填11");
        }
        if (!StringUtils.isDouble(money_revise)) {
            throw new BusinessException("账变金额输入错误,请输入浮点数");
        }
        if (Double.valueOf(money_revise).doubleValue() <= 0) {
            throw new BusinessException("账变金额不能小于等于0");
        }
 
        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;
    }
    
    /**
     * 验证登录人资金密码
     */
    protected void checkLoginSafeword(SecUser secUser, String operatorUsername, String loginSafeword) {
        String sysSafeword = secUser.getSafeword();
        String safeword_md5 = passwordEncoder.encodePassword(loginSafeword, operatorUsername);
        if (!safeword_md5.equals(sysSafeword)) {
            throw new BusinessException("登录人资金密码错误");
        }
    }
 
}