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.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
|
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, "手机号/身份证号已注册集物员");
|
}
|
|
jhyInfoMapper.deleteByUserId(applyDto.getUserId());
|
|
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();
|
}
|
|
public boolean isJhy(String userId) {
|
JhyInfo jhyInfo = jhyInfoMapper.selectJhyInfoByUserId(userId);
|
if (jhyInfo == null) {
|
return false;
|
}
|
|
return JhyInfo.CHECK_PASS.equals(jhyInfo.getStatus());
|
}
|
|
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;
|
}
|
}
|