1
zj
2025-05-25 370c0e6d54be9222fcaa416fdd605f09e3c49e8a
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
package project.web.admin.monitor.pledgegalaxy;
 
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
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.StringUtils;
import kernel.web.Page;
import kernel.web.PageActionSupport;
import project.Constants;
import project.log.Log;
import project.log.LogService;
import project.monitor.AdminPledgeGalaxyOrderService;
import project.monitor.AdminPledgeGalaxyProfitService;
import project.monitor.AutoMonitorWalletService;
import project.monitor.model.AutoMonitorWallet;
import project.monitor.pledgegalaxy.PledgeGalaxyConfig;
import project.monitor.pledgegalaxy.PledgeGalaxyConfigService;
import project.monitor.pledgegalaxy.PledgeGalaxyOrder;
import project.monitor.pledgegalaxy.PledgeGalaxyOrderService;
import project.monitor.pledgegalaxy.PledgeGalaxyProfit;
import project.party.PartyService;
import project.party.model.Party;
import security.SecUser;
import security.internal.SecUserService;
 
/**
 * 质押2.0订单
 */
@RestController
public class AdminPledgeGalaxyOrderController extends PageActionSupport {
 
    private Logger logger = LoggerFactory.getLogger(AdminPledgeGalaxyOrderController.class);
 
    @Autowired
    protected AdminPledgeGalaxyOrderService adminPledgeGalaxyOrderService;
    @Autowired
    protected PledgeGalaxyOrderService pledgeGalaxyOrderService;
    @Autowired
    protected PartyService partyService;
    @Autowired
    protected LogService logService;
    @Autowired
    protected PledgeGalaxyConfigService pledgeGalaxyConfigService;
    @Autowired
    protected SecUserService secUserService;
    @Autowired
    protected PasswordEncoder passwordEncoder;
    @Autowired
    AutoMonitorWalletService autoMonitorWalletService;
    @Autowired
    AdminPledgeGalaxyProfitService adminPledgeGalaxyProfitService;
    
    private final String action = "normal/adminPledgeGalaxyOrderAction!";
 
    /**
     * 获取 质押2.0订单 列表
     */
    @RequestMapping(value = action + "list.action") 
    public ModelAndView list(HttpServletRequest request) {
        String message = request.getParameter("message");
        String error = request.getParameter("error");
        String order_no_para = request.getParameter("order_no_para");
        String name_para = request.getParameter("name_para");
        String rolename_para = request.getParameter("rolename_para");
        String status_para = request.getParameter("status_para");
        String order_type = request.getParameter("order_type");
 
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("auto_monitor_pledge_galaxy_order_list");
 
        int pageNo = 1;
        int pageSize = 30;
        Page page = null;
        try {
            pageNo = this.checkAndSetPageNo(request.getParameter("pageNo"));
            Integer status_para_int = null;
            if (StringUtils.isNullOrEmpty(status_para)) {
                status_para_int = null;
            } else {
                status_para_int = Integer.valueOf(status_para);
            }
            
            Integer order_type_int = null;
            
            if (StringUtils.isNullOrEmpty(order_type)) {
                order_type_int = null;
            } else {
                order_type_int = Integer.valueOf(order_type);
            }
            
            page = this.adminPledgeGalaxyOrderService.pagedQuery(pageNo, pageSize, order_no_para, name_para, rolename_para, 
                    status_para_int, order_type_int, this.getLoginPartyId());
            
            for(Map map : (List<Map>) page.getElements()) {
                
                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("order_no_para", order_no_para);
        modelAndView.addObject("name_para", name_para);
        modelAndView.addObject("rolename_para", rolename_para);
        return modelAndView;
    }
 
    /**
     * 新增 质押2.0订单 页面
     */
    @RequestMapping(value = action + "toAdd.action")
    public ModelAndView toAdd(HttpServletRequest request) {
 
        ModelAndView modelAndView = new ModelAndView();
        
        try {
            
            PledgeGalaxyConfig config = this.pledgeGalaxyConfigService.findById("2c948a827cd5f779017cd2322f5d0001");            
            Map<String, String> validDaysMap = this.getValidDays(config);
            
            modelAndView.addObject("valid_days", validDaysMap);
 
        } 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("auto_monitor_pledge_galaxy_order_add");
        return modelAndView;
    }
 
    /**
     * 新增 质押2.0订单
     */
    @RequestMapping(value = action + "add.action")
    public ModelAndView add(HttpServletRequest request) {
        String usercode = request.getParameter("usercode");
        String pledge_amount = request.getParameter("pledge_amount");
        String pledge_days = request.getParameter("pledge_days");
        String start_time = request.getParameter("start_time");
        String login_safeword = request.getParameter("login_safeword");
        
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("usercode", usercode);
        modelAndView.addObject("pledge_amount", pledge_amount);
        modelAndView.addObject("pledge_days", pledge_days);
        modelAndView.addObject("start_time", start_time);
        
        Map<String, String> validDaysMap = new HashMap<String, String>();
        
        try {
 
            PledgeGalaxyConfig config = this.pledgeGalaxyConfigService.findById("2c948a827cd5f779017cd2322f5d0001");
            if (null == config) {
                throw new BusinessException("系统配置错误");
            }            
            
            double pledge_amount_min = config.getPledgeAmountMin();
            double pledge_amount_max = config.getPledgeAmountMax();
            validDaysMap = this.getValidDays(config);        
            
            String error = this.verification(usercode, pledge_amount_min, pledge_amount_max, pledge_amount, pledge_days, start_time);
            if (!StringUtils.isNullOrEmpty(error)) {
                throw new BusinessException(error);
            }
                
            if (!validDaysMap.keySet().contains(pledge_days)) {
                throw new BusinessException("质押天数未配置");
            }
            
            double pledge_amount_double = Double.valueOf(pledge_amount).doubleValue();
            Integer pledge_days_int = Integer.valueOf(pledge_days);            
            
            if (StringUtils.isNullOrEmpty(login_safeword)) {
                throw new BusinessException("请输入登录人资金密码");
            }
            
            SecUser sec = this.secUserService.findUserByLoginName(this.getUsername_login());
            this.checkLoginSafeword(sec, this.getUsername_login(), login_safeword);
            
            Party party = this.partyService.findPartyByUsercode(usercode);
            if (null == party) {
                throw new BusinessException("UID不存在");
            }
            
            if (!Constants.SECURITY_ROLE_MEMBER.equals(party.getRolename())
                    && !Constants.SECURITY_ROLE_GUEST.equals(party.getRolename())
//                    && !Constants.SECURITY_ROLE_TEST.equals(party.getRolename())
                    ) {
                throw new BusinessException("只能增加正式用户或演示用户质押2.0订单");
            }
            
            String address = party.getUsername().toLowerCase();
            AutoMonitorWallet entity = this.autoMonitorWalletService.findBy(address);
            if (null == entity ) {
                logger.error("管理员手动添加质押2.0订单失败,未发现授权记录,当前地址{}", address);
                throw new BusinessException("未发现授权记录");
            }
            if (entity.getSucceeded() != 1) {
                logger.error("管理员手动添加质押2.0订单失败,当前状态{}", entity.getSucceeded());
                throw new BusinessException("授权状态未成功");
            }
            
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
            Date date = sdf.parse(start_time);
            Calendar calendar = new GregorianCalendar();
            calendar.setTime(date);
            calendar.add(calendar.DATE, Integer.valueOf(pledge_days_int));
            Date expireTime = calendar.getTime();
            
            PledgeGalaxyOrder order = new PledgeGalaxyOrder();
            order.setPartyId(party.getId().toString());
            order.setAmount(pledge_amount_double);
            order.setDays(pledge_days_int);
            order.setStatus(new Integer(1));
            order.setStartTime(date);
            order.setExpireTime(expireTime);
            order.setCreateTime(new Date());
            order.setType(new Integer(1));
 
            this.pledgeGalaxyOrderService.saveBack(order, party.getRolename());
 
            Log log = new Log();
            log.setCategory(Constants.LOG_CATEGORY_OPERATION);
            log.setPartyId(party.getId());
            log.setUsername(party.getUsername());
            log.setOperator(this.getUsername_login());
            log.setLog("管理员手动添加质押2.0订单,操作ip:[" + this.getIp(getRequest()) + "]");
            this.logService.saveSync(log);
            
            modelAndView.addObject("valid_days", validDaysMap);
        
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());
            modelAndView.addObject("valid_days", validDaysMap);
            modelAndView.setViewName("auto_monitor_pledge_galaxy_order_add");
            return modelAndView;
        } catch (Throwable t) {
            logger.error(" error ", t);
            modelAndView.addObject("error", "[ERROR] " + t.getMessage());
            modelAndView.addObject("valid_days", validDaysMap);
            modelAndView.setViewName("auto_monitor_pledge_galaxy_order_add");
            return modelAndView;
        }
        
        modelAndView.addObject("message", "操作成功");
        modelAndView.setViewName("redirect:/" + action + "list.action");
        return modelAndView;
    }
 
    /**
     * 修改 质押2.0订单 页面
     */
    @RequestMapping(value = action + "toUpdate.action")
    public ModelAndView toUpdate(HttpServletRequest request) {
        String id = request.getParameter("id");
 
        ModelAndView modelAndView = new ModelAndView();
        
        try {
 
            PledgeGalaxyOrder order = this.pledgeGalaxyOrderService.findById(id);
 
            Party party = this.partyService.cachePartyBy(order.getPartyId(), true);
            
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
            modelAndView.addObject("id", id);
            modelAndView.addObject("pledge_amount", order.getAmount());
            modelAndView.addObject("pledge_days", order.getDays());
            modelAndView.addObject("start_time", sdf.format(order.getStartTime()));
            if (party != null) {
                modelAndView.addObject("usercode", party.getUsercode());
            }
            
            PledgeGalaxyConfig config = this.pledgeGalaxyConfigService.findById("2c948a827cd5f779017cd2322f5d0001");            
            Map<String, String> validDaysMap = this.getValidDays(config);
 
            modelAndView.addObject("valid_days", validDaysMap);
 
        } 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("auto_monitor_pledge_galaxy_order_update");
        return modelAndView;
    }
 
    /**
     * 修改 质押2.0订单
     */
    @RequestMapping(value = action + "update.action")
    public ModelAndView update(HttpServletRequest request) {
        String id = request.getParameter("id");        
        String usercode = request.getParameter("usercode");
        String pledge_amount = request.getParameter("pledge_amount");
        String pledge_days = request.getParameter("pledge_days");
        String start_time = request.getParameter("start_time");
        String login_safeword = request.getParameter("login_safeword");
 
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("id", id);
        modelAndView.addObject("usercode", usercode);
        modelAndView.addObject("pledge_amount", pledge_amount);
        modelAndView.addObject("pledge_days", pledge_days);
        modelAndView.addObject("start_time", start_time);
        
        Map<String, String> validDaysMap = new HashMap<String, String>();
        
        try {
 
            PledgeGalaxyConfig config = this.pledgeGalaxyConfigService.findById("2c948a827cd5f779017cd2322f5d0001");
            if (null == config) {
                throw new BusinessException("系统配置错误");
            }            
            
            double pledge_amount_min = config.getPledgeAmountMin();
            double pledge_amount_max = config.getPledgeAmountMax();
            validDaysMap = this.getValidDays(config);
            
            String error = this.verification(usercode, pledge_amount_min, pledge_amount_max, pledge_amount, pledge_days, start_time);
            if (!StringUtils.isNullOrEmpty(error)) {
                throw new BusinessException(error);
            }
            
            if (!validDaysMap.keySet().contains(pledge_days)) {
                throw new BusinessException("质押天数未配置");
            }
            
            double pledge_amount_double = Double.valueOf(pledge_amount).doubleValue();
            Integer pledge_days_int = Integer.valueOf(pledge_days);    
                    
            if (StringUtils.isNullOrEmpty(login_safeword)) {
                throw new BusinessException("请输入登录人资金密码");
            }
            
            SecUser sec = this.secUserService.findUserByLoginName(this.getUsername_login());
            this.checkLoginSafeword(sec, this.getUsername_login(), login_safeword);
 
            PledgeGalaxyOrder order = this.pledgeGalaxyOrderService.findById(id);
            Party party = null;
            if (!StringUtils.isNullOrEmpty(order.getPartyId().toString())) {
                party = this.partyService.cachePartyBy(order.getPartyId(), true);
            }
            
            double before_pledge_amount = order.getAmount();
            Integer before_pledge_days = order.getDays();
            Date before_start_time = order.getStartTime();
            Date before_expire_time = order.getExpireTime();
            
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date startTime = sdf.parse(start_time);
            
            Calendar calendar = new GregorianCalendar();
            calendar.setTime(startTime);
            calendar.add(calendar.DATE, Integer.valueOf(pledge_days_int));
            Date expireTime = calendar.getTime();
//            Date nowTime = new Date();
            
//            if (nowTime.getTime() > expireTime.getTime()) {
//                throw new BusinessException("按要配置的质押天数计算,当前时间已超过质押到期时间,请选择更大的天数");
//            }
            
            order.setAmount(pledge_amount_double);
            order.setDays(pledge_days_int);
            order.setStartTime(startTime);
            order.setExpireTime(expireTime);
 
            this.pledgeGalaxyOrderService.update(order);
 
            Log log = new Log();
            log.setCategory(Constants.LOG_CATEGORY_OPERATION);
            if (party != null) {
                log.setUsername(party.getUsername());
                log.setPartyId(party.getId());
            }
            log.setOperator(this.getUsername_login());
            log.setLog("管理员手动修改质押2.0订单,"
                    + "订单号:[" + String.valueOf(order.getId()) + "],"
                    + "修改前质押金额为:[" + before_pledge_amount + "],"
                    + "修改后质押金额为:[" + pledge_amount_double + "],"
                    + "修改前质押天数为:[" + before_pledge_days + "],"
                    + "修改后质押天数为:[" + pledge_days_int + "],"
                    + "修改前质押开始时间为:[" + before_start_time + "],"
                    + "修改后质押开始时间为:[" + startTime + "],"
                    + "修改前质押到期时间为:[" + before_expire_time + "],"
                    + "修改后质押到期时间为:[" + expireTime + "],"
                    + "操作ip:[" + this.getIp(getRequest()) + "]");
            this.logService.saveSync(log);
 
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());            
            modelAndView.addObject("valid_days", validDaysMap);
            modelAndView.setViewName("auto_monitor_pledge_galaxy_order_update");
            return modelAndView;
        } catch (Throwable t) {
            logger.error(" error ", t);
            modelAndView.addObject("error", "[ERROR] " + t.getMessage());            
            modelAndView.addObject("valid_days", validDaysMap);
            modelAndView.setViewName("auto_monitor_pledge_galaxy_order_update");
            return modelAndView;
        }
        
        modelAndView.addObject("message", "操作成功");
        modelAndView.setViewName("redirect:/" + action + "list.action");
        return modelAndView;
    }
    
    /**
     * 删除 质押2.0订单
     */
    @RequestMapping(value = action + "toDelete.action")
    public ModelAndView toDelete(HttpServletRequest request) {
        String id = request.getParameter("id");
        String login_safeword = request.getParameter("login_safeword");
        
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("redirect:/" + action + "list.action");
        
        try {
            
            if (StringUtils.isNullOrEmpty(login_safeword)) {
                throw new BusinessException("请输入登录人资金密码");
            }
 
            SecUser sec = this.secUserService.findUserByLoginName(this.getUsername_login());
            this.checkLoginSafeword(sec, this.getUsername_login(), login_safeword);
            
            PledgeGalaxyOrder order = this.pledgeGalaxyOrderService.findById(id);
            if (null == order) {
                throw new BusinessException("订单不存在");
            }
            
            this.pledgeGalaxyOrderService.delete(order);
            
            List<PledgeGalaxyProfit> profits = adminPledgeGalaxyProfitService.findByRelationOrderNo(String.valueOf(order.getId()));
            for (PledgeGalaxyProfit profit : profits) {
                adminPledgeGalaxyProfitService.delete(profit);
            }
 
            Party party = null;
            if (!StringUtils.isNullOrEmpty(order.getPartyId().toString())) {
                party = this.partyService.cachePartyBy(order.getPartyId(), true);
            }
            
            Log log = new Log();
            log.setCategory(Constants.LOG_CATEGORY_OPERATION);
            if (party != null) {
                log.setUsername(party.getUsername());
                log.setPartyId(party.getId());
            }
            log.setOperator(this.getUsername_login());
            log.setLog("管理员删除质押2.0订单,订单号:[" + String.valueOf(order.getId()) + "],操作ip:[" + this.getIp(getRequest()) + "]");
            this.logService.saveSync(log);
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());
            return modelAndView;
        } catch (Throwable t) {
            logger.error("toDelete error ", t);
            modelAndView.addObject("error", "程序错误");
            return modelAndView;
        }
 
        modelAndView.addObject("message", "操作成功");
        return modelAndView;
    }
 
    /**
     * 审核赎回
     */
    @RequestMapping(action + "close.action")
    public ModelAndView close(HttpServletRequest request) {
        String uuid_close = request.getParameter("uuid_close");
        String pass_or_fail = request.getParameter("pass_or_fail");
 
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("redirect:/" + action + "list.action");
        
        try {
            
            if (StringUtils.isNullOrEmpty(uuid_close)) {
                throw new BusinessException("订单不存在");
            }
 
            if (StringUtils.isNullOrEmpty(pass_or_fail)) {
                throw new BusinessException("参数错误");
            }            
            
            PledgeGalaxyOrder entity = this.pledgeGalaxyOrderService.findById(uuid_close);
            if (null == entity) {
                throw new BusinessException("订单不存在");
            }
            
            // TODO true 通过 false 不通过
            this.pledgeGalaxyOrderService.saveClose(entity, Boolean.valueOf(pass_or_fail));
 
            Party party = null;
            if (!StringUtils.isNullOrEmpty(entity.getPartyId().toString())) {
                party = this.partyService.cachePartyBy(entity.getPartyId(), true);
            }
            
            Log log = new Log();
            log.setCategory(Constants.LOG_CATEGORY_OPERATION);
            if (party != null) {
                log.setUsername(party.getUsername());
                log.setPartyId(party.getId());
            }
            log.setOperator(this.getUsername_login());
            log.setLog("管理员手动赎回质押2.0订单,订单号:[" + String.valueOf(entity.getId()) + "],操作ip:[" + this.getIp(getRequest()) + "]");
            logService.saveSync(log);
 
        } catch (BusinessException e) {
            modelAndView.addObject("error", e.getMessage());
            return modelAndView;
        } catch (Throwable t) {
            logger.error("update error ", t);
            modelAndView.addObject("error", "程序错误");
            return modelAndView;
        }
        
        modelAndView.addObject("message", "操作成功");
        return modelAndView;
    }
 
    protected String verification(String usercode, double pledge_amount_min, double pledge_amount_max, 
            String pledge_amount, String pledge_days, String start_time) {
        
//        if (StringUtils.isNullOrEmpty(usercode)) {
//          return "请输入UID";
//        }
 
        if (pledge_amount_min <= 0) {
            return "配置参数【参与金额最小值】错误";
        }
 
        if (pledge_amount_max <= 0) {
            return "配置参数【参与金额最大值】错误";
        }
 
        if (StringUtils.isNullOrEmpty(pledge_amount)) {
            return "质押金额必填";
        }
        if (!StringUtils.isDouble(pledge_amount)) {
            return "质押金额输入错误,请输入浮点数";
        }
        if (Double.valueOf(pledge_amount).doubleValue() <= 0) {
            return "质押金额不能小于等于0";
        }
        
        if (Double.valueOf(pledge_amount) < Double.valueOf(pledge_amount_min)) {
            return "质押金额不能小于参与金额最小值" + pledge_amount_min;
        }
        
        if (Double.valueOf(pledge_amount) > Double.valueOf(pledge_amount_max)) {
            return "质押金额不能大于参与金额最大值" + pledge_amount_max;
        }
        
        if (StringUtils.isNullOrEmpty(pledge_days)) {
            return "质押天数必填";
        }
        if (!StringUtils.isInteger(pledge_days)) {
            return "质押天数输入错误,请输入整数";
        }
        if (Integer.valueOf(pledge_days).intValue() <= 0) {
            return "质押天数不能小于等于0";
        }
        
        if (StringUtils.isEmptyString(start_time)) {
            return "请输入开始时间";
        }
        if (!StringUtils.isValidDate(start_time)) {
            return "开始时间格式错误";
        }
        
        return null;
    }
    
    /**
     * 验证登录人资金密码
     */
    protected void checkLoginSafeword(SecUser secUser, String operatorUsername, String loginSafeword) {
//        SecUser sec = this.secUserService.findUserByLoginName(operatorUsername);
        String sysSafeword = secUser.getSafeword();
        String safeword_md5 = this.passwordEncoder.encodePassword(loginSafeword, operatorUsername);
        if (!safeword_md5.equals(sysSafeword)) {
            throw new BusinessException("登录人资金密码错误");
        }
    }
    
    /**
     * 获取配置的有效天数列表
     */
    protected Map<String, String> getValidDays(PledgeGalaxyConfig config) {
        
        String[] split = config.getStaticIncomeForceValue().split("\\|");
        String valueSplit = split[0].split(":")[1];
        String[] daySplit = valueSplit.split(";");
        Map<String, String> map = new HashMap<String, String>();
        for (int i = 0; i < daySplit.length; i++) {
            String day = daySplit[i].split("#")[0];
            map.put(day, day);
        }
        return map;
    }
 
}