fix
Helius
2021-06-26 4e1a8c6b62ebfe4546777c55b024c33e74ac5338
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
package com.xzx.gc.user.service;
 
import cn.hutool.core.bean.BeanUtil;
import com.xzx.gc.common.exception.RestException;
import com.xzx.gc.entity.JhyInfo;
import com.xzx.gc.user.dto.JhyApplyDto;
import com.xzx.gc.user.mapper.JhyInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.Date;
 
@Service
@Transactional
public class JhyInfoService {
 
    @Autowired
    private JhyInfoMapper jhyInfoMapper;
 
    public void applyJhy(JhyApplyDto applyDto) {
        JhyInfo mobileIsExist = jhyInfoMapper.selectExistJhyByIndeityOrMobile(applyDto.getMobile(), applyDto.getIdentity());
        if (mobileIsExist != null) {
            if (applyDto.getUserId().equals(mobileIsExist.getUserId())) {
                throw new RestException(-3, "审核中或审核成功, 请勿重复提交");
            }
 
            throw new RestException(-3, "手机号/身份证号已注册集物员");
        }
 
        JhyInfo jhyInfo = new JhyInfo();
        BeanUtil.copyProperties(applyDto, jhyInfo);
        jhyInfo.setCreatedTime(new Date());
        jhyInfoMapper.insert(jhyInfo);
    }
 
    public int applyStatus(String userId) {
        JhyInfo jhyInfo = jhyInfoMapper.selectJhyInfoByUserId(userId);
        if (jhyInfo == null) {
            return 0;
        }
 
        return jhyInfo.getStatus();
    }
}