|
|
@ -9,11 +9,10 @@ import com.ccsens.cloudutil.feign.TallFeignClient; |
|
|
|
import com.ccsens.health.bean.dto.JourneyDto; |
|
|
|
import com.ccsens.health.bean.dto.UserDto; |
|
|
|
import com.ccsens.health.bean.po.*; |
|
|
|
import com.ccsens.health.bean.vo.MemberVo; |
|
|
|
import com.ccsens.health.bean.vo.UserVo; |
|
|
|
import com.ccsens.health.persist.dao.EmployeeDao; |
|
|
|
import com.ccsens.health.persist.dao.HealthRecordsDao; |
|
|
|
import com.ccsens.health.persist.dao.RealNameAuthDao; |
|
|
|
import com.ccsens.health.persist.mapper.HealthQRCodeMapper; |
|
|
|
import com.ccsens.health.persist.dao.*; |
|
|
|
import com.ccsens.health.util.HealthConstant; |
|
|
|
import com.ccsens.util.CodeEnum; |
|
|
|
import com.ccsens.util.DateUtil; |
|
|
|
import com.ccsens.util.bean.dto.QueryDto; |
|
|
@ -24,7 +23,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
@ -42,6 +41,10 @@ public class UserService implements IUserService{ |
|
|
|
private TallFeignClient tallFeignClient; |
|
|
|
@Autowired |
|
|
|
private HealthRecordsDao healthRecordsDao; |
|
|
|
@Resource |
|
|
|
private MemberDao memberDao; |
|
|
|
@Resource |
|
|
|
private JourneyDao journeyDao; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询个人信息 |
|
|
@ -75,7 +78,16 @@ public class UserService implements IUserService{ |
|
|
|
if(CollectionUtil.isNotEmpty(realNameAuthList)){ |
|
|
|
userInfoVo = new UserVo.UserInfo(); |
|
|
|
BeanUtil.copyProperties(realNameAuthList.get(0),userInfoVo); |
|
|
|
// userInfoVo.setRealName(HealthConstant.REAL_NAME_YES);
|
|
|
|
} |
|
|
|
// //判断是否为学校成员
|
|
|
|
// EmployeeExample newExample = new EmployeeExample();
|
|
|
|
// newExample.createCriteria().andTallUserIdEqualTo(userId);
|
|
|
|
// long newCount = employeeDao.countByExample(newExample);
|
|
|
|
// log.info("绑定企业微信帐号数:{}", newCount);
|
|
|
|
// if (newCount > 0) {
|
|
|
|
// userInfoVo.setSchoolMember(HealthConstant.SCHOOL_MEMBER_YES);
|
|
|
|
// }
|
|
|
|
|
|
|
|
//查询健康码
|
|
|
|
List<UserVo.HealthCode> healthCodeList = healthRecordsDao.getHealthQrCodeByEmployeeId(userId,startTime,endTime); |
|
|
@ -95,15 +107,57 @@ public class UserService implements IUserService{ |
|
|
|
//获取个人信息和tall的userId
|
|
|
|
UserDto.UserInfo userInfo = params.getParam(); |
|
|
|
Long userId = params.getUserId(); |
|
|
|
//判断是否绑定企业微信
|
|
|
|
EmployeeExample newExample = new EmployeeExample(); |
|
|
|
newExample.createCriteria().andTallUserIdEqualTo(userId); |
|
|
|
long bindQyCount = employeeDao.countByExample(newExample); |
|
|
|
|
|
|
|
//检查是否认证过
|
|
|
|
RealNameAuthExample realNameAuthExample = new RealNameAuthExample(); |
|
|
|
realNameAuthExample.createCriteria().andUserIdEqualTo(userId); |
|
|
|
List<RealNameAuth> realNameAuthList = realNameAuthDao.selectByExample(realNameAuthExample); |
|
|
|
if(CollectionUtil.isNotEmpty(realNameAuthList)){ |
|
|
|
//如果不为空代表已经认证过,直接返回认证信息
|
|
|
|
throw new BaseException(CodeEnum.ALREADY_REAL_AUTH); |
|
|
|
//判断是否为同一个user_id
|
|
|
|
RealNameAuth auth = realNameAuthList.get(0); |
|
|
|
if (auth.getUserId().longValue() == userId.longValue()) { |
|
|
|
//如果不为空代表已经认证过,直接返回认证信息
|
|
|
|
throw new BaseException(CodeEnum.ALREADY_REAL_AUTH); |
|
|
|
} else { |
|
|
|
// 判断哪个userid和企业微信绑定
|
|
|
|
|
|
|
|
EmployeeExample oldExample = new EmployeeExample(); |
|
|
|
oldExample.createCriteria().andTallUserIdEqualTo(auth.getUserId()); |
|
|
|
long authCount = employeeDao.countByExample(oldExample); |
|
|
|
boolean hasBind = bindQyCount > 0 && authCount <= 0 || bindQyCount <= 0 && authCount > 0; |
|
|
|
if (!hasBind) { |
|
|
|
throw new BaseException(CodeEnum.ALREADY_REAL_AUTH); |
|
|
|
} else { |
|
|
|
//更新返校行程,健康打卡,
|
|
|
|
if (bindQyCount > 0) { |
|
|
|
bindUser(auth.getUserId(), userId); |
|
|
|
} else { |
|
|
|
bindUser(userId, auth.getUserId()); |
|
|
|
} |
|
|
|
throw new BaseException(CodeEnum.ACCOUNT_BIND); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
//实名认证,检查是否属于该学校的学生
|
|
|
|
MemberExample memberExample = new MemberExample(); |
|
|
|
memberExample.createCriteria().andWknoEqualTo(userInfo.getNo()).andNameEqualTo(userInfo.getName()); |
|
|
|
List<Member> memberList = memberDao.selectByExample(memberExample); |
|
|
|
log.info("校验身份信息:{}", memberList); |
|
|
|
if (CollectionUtil.isEmpty(memberList)) { |
|
|
|
throw new BaseException(CodeEnum.FILL_ERROR); |
|
|
|
} |
|
|
|
//TODO 实名认证,检查是否属于该学校的学生
|
|
|
|
Member member = memberList.get(0); |
|
|
|
//如果是 1, 2 是学生
|
|
|
|
boolean isStu = member.getType() == null |
|
|
|
|| member.getType().byteValue() == HealthConstant.MEMBER_UNDERGRADUATE |
|
|
|
|| member.getType().byteValue() == HealthConstant.MEMBER_GRADUATE; |
|
|
|
userInfo.setPost(isStu ? HealthConstant.REAL_NAME_STUDENG : userInfo.getPost()); |
|
|
|
|
|
|
|
//保存信息
|
|
|
|
RealNameAuth realNameAuth = new RealNameAuth(); |
|
|
|
realNameAuth.setId(snowflake.nextId()); |
|
|
@ -117,9 +171,49 @@ public class UserService implements IUserService{ |
|
|
|
//返回
|
|
|
|
UserVo.UserInfo userInfoVo = new UserVo.UserInfo(); |
|
|
|
BeanUtil.copyProperties(realNameAuth,userInfoVo); |
|
|
|
// userInfoVo.setRealName(HealthConstant.REAL_NAME_YES);
|
|
|
|
// userInfoVo.setSchoolMember(bindQyCount > 0 ? HealthConstant.SCHOOL_MEMBER_YES : HealthConstant.SCHOOL_MEMBER_NO);
|
|
|
|
return userInfoVo; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 绑定帐号 |
|
|
|
* @param sourceUserId 源userId(舍) |
|
|
|
* @param targetUserId 替换的userId(留) |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private void bindUser(Long sourceUserId, Long targetUserId) { |
|
|
|
//TODO 帐号绑定
|
|
|
|
|
|
|
|
// 绑定实名认证
|
|
|
|
RealNameAuth auth = new RealNameAuth(); |
|
|
|
auth.setUserId(targetUserId); |
|
|
|
RealNameAuthExample authExample = new RealNameAuthExample(); |
|
|
|
authExample.createCriteria().andUserIdEqualTo(sourceUserId); |
|
|
|
realNameAuthDao.updateByExampleSelective(auth, authExample); |
|
|
|
log.info("实名认证更新"); |
|
|
|
// 绑定健康打卡
|
|
|
|
HealthRecords healthRecords = new HealthRecords(); |
|
|
|
healthRecords.setUserId(targetUserId); |
|
|
|
HealthRecordsExample recordsExample = new HealthRecordsExample(); |
|
|
|
recordsExample.createCriteria().andUserIdEqualTo(sourceUserId); |
|
|
|
healthRecordsDao.updateByExampleSelective(healthRecords, recordsExample); |
|
|
|
log.info("绑定健康上报"); |
|
|
|
// 绑定行程上报
|
|
|
|
Journey journey = new Journey(); |
|
|
|
journey.setUserId(targetUserId); |
|
|
|
JourneyExample journeyExample = new JourneyExample(); |
|
|
|
journeyExample.createCriteria().andUserIdEqualTo(sourceUserId); |
|
|
|
journeyDao.updateByExampleSelective(journey, journeyExample); |
|
|
|
log.info("绑定行程上报"); |
|
|
|
// 绑定校园打卡
|
|
|
|
SiteClockIn clockIn = new SiteClockIn(); |
|
|
|
clockIn.setUserId(targetUserId); |
|
|
|
SiteClockInExample clockInExample = new SiteClockInExample(); |
|
|
|
clockInExample.createCriteria().andUserIdEqualTo(sourceUserId); |
|
|
|
log.info("绑定校园打卡"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询个人轨迹 |
|
|
|
* @param params |
|
|
|