|
|
@ -17,6 +17,7 @@ import com.ruoyi.system.domain.TWechatUser;
|
|
|
|
import com.ruoyi.system.domain.req.GetOpenidReq;
|
|
|
|
import com.ruoyi.system.domain.req.GetOpenidReq;
|
|
|
|
import com.ruoyi.system.domain.req.LoginForAppReq;
|
|
|
|
import com.ruoyi.system.domain.req.LoginForAppReq;
|
|
|
|
import com.ruoyi.system.domain.req.LoginForMpReq;
|
|
|
|
import com.ruoyi.system.domain.req.LoginForMpReq;
|
|
|
|
|
|
|
|
import com.ruoyi.system.domain.req.LoginForMultiPatientReq;
|
|
|
|
import com.ruoyi.system.domain.resp.GetOpenidResp;
|
|
|
|
import com.ruoyi.system.domain.resp.GetOpenidResp;
|
|
|
|
import com.ruoyi.system.mapper.TDoctorMapper;
|
|
|
|
import com.ruoyi.system.mapper.TDoctorMapper;
|
|
|
|
import com.ruoyi.system.mapper.TPatientMapper;
|
|
|
|
import com.ruoyi.system.mapper.TPatientMapper;
|
|
|
@ -29,13 +30,11 @@ import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class WechatServiceImpl implements IWechatService {
|
|
|
|
public class WechatServiceImpl implements IWechatService {
|
|
|
@ -86,11 +85,19 @@ public class WechatServiceImpl implements IWechatService {
|
|
|
|
if (Objects.isNull(wechatUser.getUserId())) {
|
|
|
|
if (Objects.isNull(wechatUser.getUserId())) {
|
|
|
|
resp.setBindFlag(false);
|
|
|
|
resp.setBindFlag(false);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// 已绑定信息 直接登录
|
|
|
|
// 已绑定患者
|
|
|
|
resp.setBindFlag(true);
|
|
|
|
resp.setBindFlag(true);
|
|
|
|
TPatient tPatient = tPatientMapper.selectTPatientById(wechatUser.getUserId());
|
|
|
|
// 查询该患者手机号是否存在多条数据
|
|
|
|
String token = buildTokenByPatient(tPatient);
|
|
|
|
List<TPatient> patients = tPatientMapper.querySamePhonePatientsById(wechatUser.getUserId());
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(patients)) {
|
|
|
|
|
|
|
|
resp.setBindFlag(false);
|
|
|
|
|
|
|
|
} else if (!CollectionUtils.isEmpty(patients) && patients.size() == 1) {
|
|
|
|
|
|
|
|
String token = buildTokenByPatient(patients.get(0));
|
|
|
|
resp.setToken(token);
|
|
|
|
resp.setToken(token);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
resp.setMultiPatient(true);
|
|
|
|
|
|
|
|
resp.setPatients(patients);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resp.setOpenid(openid);
|
|
|
|
resp.setOpenid(openid);
|
|
|
|
return resp;
|
|
|
|
return resp;
|
|
|
@ -120,7 +127,7 @@ public class WechatServiceImpl implements IWechatService {
|
|
|
|
// 查询手机号是否存在患者信息
|
|
|
|
// 查询手机号是否存在患者信息
|
|
|
|
TPatient tPatient = new TPatient();
|
|
|
|
TPatient tPatient = new TPatient();
|
|
|
|
BeanUtils.copyProperties(req, tPatient);
|
|
|
|
BeanUtils.copyProperties(req, tPatient);
|
|
|
|
TPatient currentPatient = tPatientMapper.queryTPatient(tPatient);
|
|
|
|
TPatient currentPatient = tPatientMapper.queryTPatientByPhoneAndName(tPatient);
|
|
|
|
TWechatUser wechatUser = new TWechatUser();
|
|
|
|
TWechatUser wechatUser = new TWechatUser();
|
|
|
|
if (Objects.nonNull(currentPatient)) {
|
|
|
|
if (Objects.nonNull(currentPatient)) {
|
|
|
|
// 存在 需要把患者信息更新 并绑定openid
|
|
|
|
// 存在 需要把患者信息更新 并绑定openid
|
|
|
@ -205,6 +212,17 @@ public class WechatServiceImpl implements IWechatService {
|
|
|
|
return token;
|
|
|
|
return token;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public String loginForMultiPatient(LoginForMultiPatientReq req) {
|
|
|
|
|
|
|
|
TPatient tPatient = tPatientMapper.queryPatientByOpenidAndPatientId(req);
|
|
|
|
|
|
|
|
String token = "";
|
|
|
|
|
|
|
|
if (Objects.nonNull(tPatient)) {
|
|
|
|
|
|
|
|
logger.info("query patient info :{}", tPatient);
|
|
|
|
|
|
|
|
token = buildTokenByPatient(tPatient);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return token;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private String queryOpenid(GetOpenidReq req){
|
|
|
|
private String queryOpenid(GetOpenidReq req){
|
|
|
|
String url = String.format(WechatKeys.MP_CODE_TO_OPENID_URL, appId, appSecret, req.getCode());
|
|
|
|
String url = String.format(WechatKeys.MP_CODE_TO_OPENID_URL, appId, appSecret, req.getCode());
|
|
|
|
String json = HttpUtils.sendGet(url);
|
|
|
|
String json = HttpUtils.sendGet(url);
|
|
|
|