| 
															
																@ -17,7 +17,7 @@ import com.yihu.jw.wechat.service.WechatInfoService; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import io.swagger.annotations.Api; 
															 | 
															
															 | 
															
																import io.swagger.annotations.Api; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import io.swagger.annotations.ApiOperation; 
															 | 
															
															 | 
															
																import io.swagger.annotations.ApiOperation; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import io.swagger.annotations.ApiParam; 
															 | 
															
															 | 
															
																import io.swagger.annotations.ApiParam; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																import org.apache.axis.utils.StringUtils; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																import org.apache.commons.lang3.StringUtils; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																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.data.redis.core.StringRedisTemplate; 
															 | 
															
															 | 
															
																import org.springframework.data.redis.core.StringRedisTemplate; 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -61,8 +61,7 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     * @return 
															 | 
															
															 | 
															
																     * @return 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     */ 
															 | 
															
															 | 
															
																     */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    @RequestMapping(value = "/getXOpenidByCode", method = {RequestMethod.POST, RequestMethod.GET}) 
															 | 
															
															 | 
															
																    @RequestMapping(value = "/getXOpenidByCode", method = {RequestMethod.POST, RequestMethod.GET}) 
															 | 
														
													
												
													
														
															| 
															 | 
															
																    public Envelop getXOpenidByCode(String code, @RequestParam(value = "patientId", required = false)String patientId) throws Exception { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																    public Envelop getXOpenidByCode(String code){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        try { 
															 | 
															
															 | 
															
																        try { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            //通过redis获取openid, 获取不到,则调用微信接口去取 
															 | 
															
															 | 
															
																            //通过redis获取openid, 获取不到,则调用微信接口去取 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            String key = wxId+":code"; 
															 | 
															
															 | 
															
																            String key = wxId+":code"; 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@ -71,29 +70,19 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                return success(PatientRequestMapping.Wechat.api_success,openid); 
															 | 
															
															 | 
															
																                return success(PatientRequestMapping.Wechat.api_success,openid); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            } 
															 | 
															
															 | 
															
																            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            org.json.JSONObject json = wechatInfoService.getXOpenidByCode(code, wxId); 
															 | 
															
															 | 
															
																            org.json.JSONObject json = wechatInfoService.getXOpenidByCode(code, wxId); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            if (!StringUtils.isEmpty(patientId)){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            if(json.has("openid")){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                openid = json.getString("openid"); 
															 | 
															
															 | 
															
																                openid = json.getString("openid"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                String unionid = json.getString("unionid"); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                List<BasePatientWechatDo> list = basePatientWechatDao.findByWechatIdAndPatientId(wxId,patientId); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                if (list!=null&&list.size()>0){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    for (BasePatientWechatDo basePatientWechatDo:list){ 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                        basePatientWechatDo.setXopenid(openid); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                        basePatientWechatDo.setUnionid(unionid); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                        basePatientWechatDao.save(basePatientWechatDo); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    } 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                }else { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    BasePatientWechatDo basePatientWechatDo = new BasePatientWechatDo(); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    basePatientWechatDo.setPatientId(patientId); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    basePatientWechatDo.setWechatId(wxId); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    basePatientWechatDo.setCreateTime(new Date()); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    basePatientWechatDo.setXopenid(openid); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    basePatientWechatDo.setUnionid(unionid); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                    basePatientWechatDao.save(basePatientWechatDo); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                } 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                JSONObject res = new JSONObject(); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                res.put("openid",openid); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                res.put("unionid",json.getString("unionid")); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                res.put("session_key",json.getString("session_key")); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                redisTemplate.opsForValue().set(key,openid); 
															 | 
															
															 | 
															
																                redisTemplate.opsForValue().set(key,openid); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                redisTemplate.expire(key,10, TimeUnit.SECONDS); 
															 | 
															
															 | 
															
																                redisTemplate.expire(key,10, TimeUnit.SECONDS); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                return success(PatientRequestMapping.Wechat.api_success,res); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																            }else { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																                return Envelop.getError("获取失败"); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            } 
															 | 
															
															 | 
															
																            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            return success(PatientRequestMapping.Wechat.api_success,json); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } catch (Exception e){ 
															 | 
															
															 | 
															
																        } catch (Exception e){ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																            return  failedException2(e); 
															 | 
															
															 | 
															
																            return  failedException2(e); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																        } 
															 | 
															
															 | 
															
																        } 
															 |