From d95f158b9dfa0149e74bc60a0c5a386dbbdad484 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Tue, 29 Jun 2021 16:07:52 +0800
Subject: [PATCH] fix applyJhy

---
 gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java b/gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java
index db78b96..7d45998 100644
--- a/gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java
+++ b/gc-user/src/main/java/com/xzx/gc/user/service/JhyInfoService.java
@@ -1,15 +1,24 @@
 package com.xzx.gc.user.service;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.convert.Convert;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import com.xzx.gc.common.exception.RestException;
 import com.xzx.gc.entity.JhyInfo;
+import com.xzx.gc.user.dto.ExamineJwyDto;
 import com.xzx.gc.user.dto.JhyApplyDto;
+import com.xzx.gc.user.dto.JhyInfoListDto;
 import com.xzx.gc.user.mapper.JhyInfoMapper;
+import com.xzx.gc.user.vo.JhyInfoListVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 @Service
 @Transactional
@@ -28,9 +37,14 @@
             throw new RestException(-3, "手机号/身份证号已注册集物员");
         }
 
+        jhyInfoMapper.deleteByUserId(applyDto.getUserId());
+
         JhyInfo jhyInfo = new JhyInfo();
         BeanUtil.copyProperties(applyDto, jhyInfo);
         jhyInfo.setCreatedTime(new Date());
+        jhyInfo.setIsJhy(JhyInfo.IS_JHY_N);
+        jhyInfo.setCardPos(applyDto.getCardPos());
+        jhyInfo.setStatus(JhyInfo.CHECK_WAIT);
         jhyInfoMapper.insert(jhyInfo);
     }
 
@@ -42,4 +56,48 @@
 
         return jhyInfo.getStatus();
     }
+
+    public int isJhy(String userId) {
+        JhyInfo jhyInfo = jhyInfoMapper.selectJhyInfoByUserId(userId);
+        if (jhyInfo == null) {
+            return 0;
+        }
+
+        if (JhyInfo.CHECK_REFUSE.equals(jhyInfo.getStatus())) {
+            return 0;
+        }
+
+        if (JhyInfo.CHECK_PASS.equals(jhyInfo.getStatus())) {
+            return 1;
+        } else {
+            return 2;
+        }
+    }
+
+    public Map<String, Object> queryList(JhyInfoListDto jhyInfoListDto) {
+        PageHelper.startPage(jhyInfoListDto.getPage(), jhyInfoListDto.getLimit());
+        List<JhyInfoListVo> jhyInfoListVos = jhyInfoMapper.selectJhyInfoList(jhyInfoListDto);
+        PageInfo<JhyInfoListVo> pageInfo = new PageInfo<>(jhyInfoListVos);
+
+        Map<String, Object> data = new HashMap<>();
+        int count = Convert.toInt(pageInfo.getTotal());
+        data.put("data", jhyInfoListVos);
+        data.put("count", count);
+        data.put("code", 0);
+        return data;
+    }
+
+    public void examineJwy(ExamineJwyDto model) {
+        long id = model.getId();
+        JhyInfo jhyInfo = jhyInfoMapper.selectByPrimaryKey(id);
+        Integer type = model.getType();
+        if(1 == type){
+            jhyInfo.setStatus(2);
+            jhyInfo.setIsJhy(1+"");
+        }else if(2 == type){
+            jhyInfo.setStatus(3);
+            jhyInfo.setIsJhy(2+"");
+        }
+        jhyInfoMapper.updateByPrimaryKey(jhyInfo);
+    }
 }

--
Gitblit v1.9.1