|
@ -39,7 +39,7 @@ import java.util.*;
|
|
|
* @author calvin
|
|
|
*/
|
|
|
@Controller
|
|
|
@RequestMapping(value = "/weixin", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})
|
|
|
@RequestMapping(value = "/weixin", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
|
|
|
@Api(description = "微信端用户注册")
|
|
|
public class WechatController extends WeixinBaseController {
|
|
|
|
|
@ -68,28 +68,6 @@ public class WechatController extends WeixinBaseController {
|
|
|
@Autowired
|
|
|
private PushMsgTask pushMsgTask;
|
|
|
|
|
|
/**
|
|
|
* 患者注册-验证手机号
|
|
|
*
|
|
|
* @param phone 登录手机号
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "checkmobile")
|
|
|
@ResponseBody
|
|
|
public String checkmobile(String phone) {
|
|
|
try {
|
|
|
/**modify by linz 2017年2月28日10:11:49 校验手机号码的时候返回使用此号码的所有人员**/
|
|
|
List<Patient> temp = patientService.findByMobile(phone);
|
|
|
if (temp != null && temp.size() > 0) {
|
|
|
// 设置身份证号
|
|
|
return write(200, "患者信息查询成功!", "data", temp);
|
|
|
}
|
|
|
return error(1, "该手机号未被注册");
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "手机号验证失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取验证码发送的手机号码
|
|
@ -97,7 +75,7 @@ public class WechatController extends WeixinBaseController {
|
|
|
* @param idCard
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "getMobile")
|
|
|
@RequestMapping(value = "getMobile",method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public String getPatientInfoByIdCard(@RequestParam(value = "idCard", required = true) String idCard) {
|
|
|
Patient temp = patientService.findByIdcard(idCard);
|
|
@ -117,51 +95,6 @@ public class WechatController extends WeixinBaseController {
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 患者注册-验证身份证
|
|
|
*
|
|
|
* @param idcard 身份證號
|
|
|
* @param mobile 登录手机号
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "checkidcard")
|
|
|
@ResponseBody
|
|
|
public String checkidcard(String idcard, String mobile) {
|
|
|
try {
|
|
|
// 解密身份证号
|
|
|
idcard = RSAUtils.getInstance(patientService).decryptString(idcard);
|
|
|
idcard = URLDecoder.decode(idcard, "UTF-8");
|
|
|
idcard = StringUtils.reverse(idcard);
|
|
|
Patient temp = patientService.findByIdcard(idcard);
|
|
|
if (temp != null) {
|
|
|
JSONObject json = new JSONObject();
|
|
|
// 设置患者标识
|
|
|
json.put("code", temp.getCode());
|
|
|
// 设置手机号码
|
|
|
json.put("mobile", temp.getMobile());
|
|
|
// 设置身份证号
|
|
|
json.put("idcard", temp.getIdcard());
|
|
|
return write(1, "患者信息查询成功!", "data", json);
|
|
|
} else {
|
|
|
List<Patient> temp1 = patientService.findByMobile(mobile);
|
|
|
if (temp1 != null && temp1.size() > 0) {
|
|
|
//JSONObject json = new JSONObject();
|
|
|
// 设置患者标识
|
|
|
//json.put("code", temp1.getCode());
|
|
|
//// 设置手机号码
|
|
|
//json.put("mobile", temp1.getMobile());
|
|
|
//// 设置身份证号
|
|
|
//json.put("idcard", temp1.getIdcard());
|
|
|
return write(2, "患者信息查询成功!", "data", temp1);
|
|
|
}
|
|
|
}
|
|
|
return success("该身份证和手机号未被注册");
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "身份证验证失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 注册信息验证
|
|
|
*
|
|
@ -171,7 +104,7 @@ public class WechatController extends WeixinBaseController {
|
|
|
* @param mobile 手机号
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/check_regist_info")
|
|
|
@RequestMapping(value = "/check_regist_info",method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public String checkRegistInfo(String name, String idcard, String ssc, String mobile) {
|
|
|
try {
|
|
@ -241,7 +174,7 @@ public class WechatController extends WeixinBaseController {
|
|
|
* @param captcha 手机验证码
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "regist")
|
|
|
@RequestMapping(value = "regist",method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public String regist(@RequestParam(value = "name", required = true) String name,
|
|
|
@RequestParam(value = "idcard", required = true) String idcard,
|
|
@ -366,7 +299,7 @@ public class WechatController extends WeixinBaseController {
|
|
|
* @param password 登录密码
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "login")
|
|
|
@RequestMapping(value = "login",method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public String login(
|
|
|
@RequestParam(required = false) String mobile,
|
|
@ -563,7 +496,7 @@ public class WechatController extends WeixinBaseController {
|
|
|
* @param pageUrl 需要签名的页面全地址(?后的也需要除了#后的不需要)
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "getSign")
|
|
|
@RequestMapping(value = "getSign",method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
public String getSign(String pageUrl) {
|
|
|
try {
|
|
@ -590,98 +523,6 @@ public class WechatController extends WeixinBaseController {
|
|
|
return error(-1, "获取签名失败");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发送微信签约成功的消息
|
|
|
*
|
|
|
* @param code 患者编号
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "sendSign")
|
|
|
@ResponseBody
|
|
|
public String sendSignSucess(String code) {
|
|
|
try {
|
|
|
Patient patient = patientService.findByCode(code);
|
|
|
JSONObject json = new JSONObject();
|
|
|
json.put("first", "开始");
|
|
|
json.put("remark", "指导备注");
|
|
|
json.put("date", "2016-06-08");
|
|
|
json.put("doctorName", "徐小鹏");
|
|
|
json.put("orgName", "厦门第一医院");
|
|
|
|
|
|
//判断是否判定openId,有没有发则查找家人发送
|
|
|
if (StringUtils.isNotBlank(patient.getOpenid())) {
|
|
|
// 添加到发送队列
|
|
|
pushMsgTask.putWxMsg(getAccessToken(), 5, patient.getOpenid(), patient.getName(), json);
|
|
|
} else {
|
|
|
JSONObject j = weiXinOpenIdUtils.getFamilyOpenId(patient.getCode());
|
|
|
Patient member = (Patient) j.get("member");
|
|
|
if (StringUtils.isNotBlank(member.getOpenid())) {
|
|
|
String first = (String) json.get("first");
|
|
|
json.remove("first");
|
|
|
json.put("first", weiXinOpenIdUtils.getTitleMes(patient, j.getInt("relation"), patient.getName()) + first);
|
|
|
pushMsgTask.putWxMsg(getAccessToken(), 5, member.getOpenid(), patient.getName(), json);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return write(200, "发送成功");
|
|
|
} catch (Exception e) {
|
|
|
error(e);
|
|
|
return error(-1, "发送失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取微信用户身份
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
// @RequestMapping(value = "identity")
|
|
|
// @ResponseBody
|
|
|
// public String identity(String code) {
|
|
|
// try {
|
|
|
// String openid = getOpenid();
|
|
|
// if(StringUtils.isEmpty(openid)){
|
|
|
// openid = getOpenidByCode(code);
|
|
|
// }
|
|
|
// if (StringUtils.isEmpty(openid)) {
|
|
|
// return error(-1, "获取openid异常!");
|
|
|
// }
|
|
|
// JSONObject userAgent = new JSONObject();
|
|
|
// Patient patient = patientService.findByOpenid(openid);
|
|
|
// long id = 0;
|
|
|
// String uid = "";
|
|
|
// String name = "";
|
|
|
// String photo = "";
|
|
|
// String tokenStr = "";
|
|
|
// if (patient != null) {
|
|
|
// id = patient.getId();
|
|
|
// uid = patient.getCode();
|
|
|
// name = patient.getName();
|
|
|
// photo = patient.getPhoto();
|
|
|
// // 查询token
|
|
|
// Token token = SystemData.wxPatientTokens.get(patient.getCode());
|
|
|
// if (token == null) {
|
|
|
// // 从数据库加载
|
|
|
// token = tokenService.findWxToken(patient.getCode());
|
|
|
// }
|
|
|
// if (token == null) {
|
|
|
// // 生成新的token
|
|
|
// token = tokenService.newTxToken(patient.getCode(), openid);
|
|
|
// }
|
|
|
// tokenStr = token.getToken();
|
|
|
// }
|
|
|
// userAgent.put("id", id);
|
|
|
// userAgent.put("uid", uid);
|
|
|
// userAgent.put("openid", openid);
|
|
|
// userAgent.put("name", name);
|
|
|
// userAgent.put("photo", photo);
|
|
|
// userAgent.put("token", tokenStr);
|
|
|
// return write(200, "获取身份信息成功!", "data", userAgent);
|
|
|
// } catch (Exception e) {
|
|
|
// error(e);
|
|
|
// return error(-1, "获取身份信息失败!");
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
/**
|
|
|
* 获取微信openid
|
|
@ -689,7 +530,7 @@ public class WechatController extends WeixinBaseController {
|
|
|
* @param code
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "getOpenidByCode")
|
|
|
@RequestMapping(value = "getOpenidByCode",method = {RequestMethod.POST,RequestMethod.GET})
|
|
|
@ResponseBody
|
|
|
public String getOpenidByCode(String code) {
|
|
|
try {
|
|
@ -705,29 +546,5 @@ public class WechatController extends WeixinBaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 判断是否关注
|
|
|
*
|
|
|
* @param openid
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/is_subscribe")
|
|
|
@ResponseBody
|
|
|
public String getIsSubscribe(String openid) {
|
|
|
try {
|
|
|
String userInfo_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" + getAccessToken() + "&openid=" + openid + "&lang=zh_CN";
|
|
|
String params = "";
|
|
|
String result = HttpUtil.sendGet(userInfo_url, params);
|
|
|
JSONObject json = new JSONObject(result);
|
|
|
if (json.has("subscribe")) {
|
|
|
return write(200, "查询成功", "subsribe", json.get("subscribe").toString());
|
|
|
} else {
|
|
|
return error(-1, json.getString("errmsg"));
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return error(-1, "查询失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|