张延森 пре 3 година
родитељ
комит
9ebc30076b

+ 52
- 23
src/main/java/com/njyunzhi/pet_identity/controller/TaApplicationController.java Прегледај датотеку

@@ -371,6 +371,51 @@ public class TaApplicationController extends BaseController {
371 371
         }
372 372
     }
373 373
 
374
+    /**
375
+     * 绑卡
376
+     * @param id  实体ID
377
+     * @param makeCardParam 实体对象
378
+     * @return
379
+     */
380
+    @RequestMapping(value="/admin/application/{id}/bindCard",method= RequestMethod.PUT)
381
+    @ApiOperation(value="绑卡", notes = "绑卡", httpMethod = "PUT", response = ResponseBean.class)
382
+    public ResponseBean bindCard(@ApiParam("对象ID") @PathVariable Integer id,
383
+                                 @ApiParam("更新内容") @RequestBody MakeCardParam makeCardParam) throws Exception{
384
+        SysUser sysUser = currentUser();
385
+        if (!checkRole(sysUser.getRoleName(), Constants.USER_MAKER)) {
386
+            return ResponseBean.error("暂无权限");
387
+        }
388
+
389
+        TaApplication taApplication = iTaApplicationService.getById(id);
390
+        if (null == taApplication || taApplication.getStatus() == Constants.STATUS_DELETE) {
391
+            return ResponseBean.error("未找到数据");
392
+        }
393
+
394
+        if (StringUtils.isEmpty(makeCardParam.getCardNo())) {
395
+            return ResponseBean.error("卡号不能为空");
396
+        } else {
397
+            TaCardNo taCardNo = iTaCardNoService.getUnuseCard(makeCardParam.getCardNo());
398
+            if (taCardNo == null) {
399
+                return ResponseBean.error("卡号无效或者已使用");
400
+            }
401
+
402
+            // 将卡号置为已使用
403
+            taCardNo.setStatus(Constants.STATUS_NORMAL);
404
+            iTaCardNoService.updateById(taCardNo);
405
+
406
+            TaPetIdentity taPetIdentity = iTaPetIdentityService.getExistBy("card_no", makeCardParam.getCardNo(), false, true);
407
+            if (null != taPetIdentity) {
408
+                return ResponseBean.error("卡号已被占用");
409
+            }
410
+        }
411
+
412
+        taApplication.setOriginCardNo(makeCardParam.getCardNo());
413
+        iTaApplicationService.updateById(taApplication);
414
+        TaPetIdentity newCard = iTaPetIdentityService.createNewCard(taApplication, makeCardParam);
415
+        return ResponseBean.success(newCard);
416
+    }
417
+
418
+
374 419
     /**
375 420
      * 发证
376 421
      * @param id  实体ID
@@ -415,26 +460,6 @@ public class TaApplicationController extends BaseController {
415 460
             }
416 461
         }
417 462
 
418
-        if (StringUtils.isEmpty(makeCardParam.getCardNo())) {
419
-            return ResponseBean.error("卡号不能为空");
420
-        } else {
421
-            TaCardNo taCardNo = iTaCardNoService.getUnuseCard(makeCardParam.getCardNo());
422
-            if (taCardNo == null) {
423
-                return ResponseBean.error("卡号无效或者已使用");
424
-            }
425
-
426
-            // 将卡号置为已使用
427
-            taCardNo.setStatus(Constants.STATUS_NORMAL);
428
-            iTaCardNoService.updateById(taCardNo);
429
-
430
-            TaPetIdentity taPetIdentity = iTaPetIdentityService.getExistBy("card_no", makeCardParam.getCardNo(), false, true);
431
-            if (null != taPetIdentity) {
432
-                return ResponseBean.error("卡号已被占用");
433
-            }
434
-        }
435
-
436
-        // 关联证件
437
-        taApplication.setOriginCardNo(makeCardParam.getCardNo());
438 463
         taApplication.setMakeStatus(Constants.MAKE_STATUS_MADE);
439 464
         taApplication.setMakeDate(LocalDateTime.now());
440 465
         taApplication.setMakeUser(sysUser.getUserId());
@@ -443,10 +468,14 @@ public class TaApplicationController extends BaseController {
443 468
         taApplication.setTrackingNo(makeCardParam.getTrackingNo());
444 469
         taApplication.setStatus(Constants.WORKFLOW_STATUS_MADE);
445 470
 
446
-        if (iTaApplicationService.updateById(taApplication)){
447
-            TaPetIdentity newCard = iTaPetIdentityService.createNewCard(taApplication, makeCardParam);
471
+        TaPetIdentity taPetIdentity = iTaPetIdentityService.getExistBy("card_no", taApplication.getOriginCardNo(), false, true);
472
+        if (!taApplication.getApplyType().equals(Constants.APPLY_TYPE_REISSUE)) {
473
+            // 新办 续期,都需要重置有效期
474
+            iTaPetIdentityService.updateCardDate(taPetIdentity.getCardNo());
475
+        }
448 476
 
449
-            return ResponseBean.success(newCard);
477
+        if (iTaApplicationService.updateById(taApplication)){
478
+            return ResponseBean.success(taApplication);
450 479
         } else {
451 480
             return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
452 481
         }

+ 2
- 0
src/main/java/com/njyunzhi/pet_identity/service/ITaPetIdentityService.java Прегледај датотеку

@@ -16,6 +16,8 @@ public interface ITaPetIdentityService extends IBaseService<TaPetIdentity> {
16 16
 
17 17
     TaPetIdentity createNewCard(TaApplication taApplication, MakeCardParam makeCardParam) throws Exception;
18 18
 
19
+    boolean updateCardDate(String cardNo) throws Exception;
20
+
19 21
     boolean extendDate(TaPetIdentity taPetIdentity) throws Exception;
20 22
 
21 23
     TaPetIdentity getByPet(String petId, String personId);

+ 21
- 5
src/main/java/com/njyunzhi/pet_identity/service/impl/TaPetIdentityServiceImpl.java Прегледај датотеку

@@ -1,6 +1,7 @@
1 1
 package com.njyunzhi.pet_identity.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
4 5
 import com.njyunzhi.pet_identity.common.Constants;
5 6
 import com.njyunzhi.pet_identity.common.DateUtils;
6 7
 import com.njyunzhi.pet_identity.entity.SysSetting;
@@ -33,11 +34,9 @@ public class TaPetIdentityServiceImpl extends BaseServiceImpl<TaPetIdentityMappe
33 34
     @Override
34 35
     public TaPetIdentity createNewCard(TaApplication taApplication, MakeCardParam makeCardParam) throws Exception {
35 36
 
36
-        SysSetting sysSetting = sysSettingMapper.selectById(Constants.SYSSETTING_CARD_EXPIRE);
37
-
38 37
         // 北京时间
39 38
         LocalDateTime now = LocalDateTime.now(ZoneId.of("Asia/Shanghai"));
40
-        LocalDateTime expire = now.plusDays(Long.parseLong(sysSetting.getContent()));
39
+//        LocalDateTime expire = now.plusDays(Long.parseLong(sysSetting.getContent()));
41 40
 
42 41
         TaPetIdentity taPetIdentity = new TaPetIdentity();
43 42
         taPetIdentity.setCardNo(makeCardParam.getCardNo());
@@ -52,8 +51,8 @@ public class TaPetIdentityServiceImpl extends BaseServiceImpl<TaPetIdentityMappe
52 51
         taPetIdentity.setPetImg1(taApplication.getImg1());
53 52
         taPetIdentity.setPetImg2(taApplication.getImg2());
54 53
         taPetIdentity.setAddress(taApplication.getAddress());
55
-        taPetIdentity.setStartDate(DateUtils.toString(now, "yyyy-MM-dd"));
56
-        taPetIdentity.setExpireDate(DateUtils.toString(expire, "yyyy-MM-dd"));
54
+//        taPetIdentity.setStartDate(DateUtils.toString(now, "yyyy-MM-dd"));
55
+//        taPetIdentity.setExpireDate(DateUtils.toString(expire, "yyyy-MM-dd"));
57 56
         taPetIdentity.setStatus(Constants.STATUS_NORMAL);
58 57
         taPetIdentity.setCreateDate(now);
59 58
 
@@ -71,6 +70,23 @@ public class TaPetIdentityServiceImpl extends BaseServiceImpl<TaPetIdentityMappe
71 70
         return taPetIdentity;
72 71
     }
73 72
 
73
+    @Override
74
+    public boolean updateCardDate(String cardNo) throws Exception {
75
+        SysSetting sysSetting = sysSettingMapper.selectById(Constants.SYSSETTING_CARD_EXPIRE);
76
+        // 北京时间
77
+        LocalDateTime now = LocalDateTime.now(ZoneId.of("Asia/Shanghai"));
78
+        LocalDateTime expire = now.plusDays(Long.parseLong(sysSetting.getContent()));
79
+
80
+
81
+        UpdateWrapper<TaPetIdentity> updateWrapper = new UpdateWrapper<>();
82
+        updateWrapper.set("start_date", now);
83
+        updateWrapper.set("expire_date", expire);
84
+        updateWrapper.eq("card_no", cardNo);
85
+
86
+        return update(updateWrapper);
87
+    }
88
+
89
+
74 90
     @Override
75 91
     public boolean extendDate(TaPetIdentity taPetIdentity) throws Exception {
76 92