|  | @ -42,7 +42,6 @@ import com.yihu.jw.hospital.prescription.service.entrance.YkyyEntranceService;
 | 
	
		
			
				|  |  | import com.yihu.jw.hospital.ykyy.service.YkyyService;
 | 
	
		
			
				|  |  | import com.yihu.jw.order.BusinessOrderService;
 | 
	
		
			
				|  |  | import com.yihu.jw.order.dao.BusinessOrderDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.order.pay.wx.WeChatConfig;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.dao.BasePatientDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
 | 
	
	
		
			
				|  | @ -51,6 +50,8 @@ import com.yihu.jw.util.common.IdCardUtil;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.BasePatientWechatDao;
 | 
	
		
			
				|  |  | import com.yihu.jw.wechat.dao.WechatDao;
 | 
	
		
			
				|  |  | import com.yihu.mysql.query.BaseJpaService;
 | 
	
		
			
				|  |  | import com.yihu.utils.network.HttpResponse;
 | 
	
		
			
				|  |  | import com.yihu.utils.network.HttpUtils;
 | 
	
		
			
				|  |  | import com.yihu.utils.security.MD5;
 | 
	
		
			
				|  |  | import org.apache.commons.collections.map.HashedMap;
 | 
	
		
			
				|  |  | import org.apache.commons.lang3.StringUtils;
 | 
	
	
		
			
				|  | @ -844,7 +845,7 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      * @throws Exception
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public Map<String,Object> savePrescriptionOrder(String code,Double price,String tradeType,String wechatId) throws Exception {
 | 
	
		
			
				|  |  |     public Map<String,Object> savePrescriptionOrder(String code,Double price,String tradeType,String wechatId,String appletCode) throws Exception {
 | 
	
		
			
				|  |  |         WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
 | 
	
		
			
				|  |  |         Map<String,Object> map = new HashedMap();
 | 
	
		
			
				|  |  |         if(wxWechatDO==null){
 | 
	
	
		
			
				|  | @ -854,12 +855,22 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
 | 
	
		
			
				|  |  |         if (businessOrderDO!=null){
 | 
	
		
			
				|  |  |             List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
 | 
	
		
			
				|  |  |             String openId = "";
 | 
	
		
			
				|  |  |             if (patientWechatDos!=null&&patientWechatDos.size()!=0){
 | 
	
		
			
				|  |  |                 openId = patientWechatDos.get(0).getOpenid();
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (!StringUtils.isNoneBlank(tradeType)){
 | 
	
		
			
				|  |  |                 tradeType=WeChatConfig.TRADE_TYPE_JSAPI;
 | 
	
		
			
				|  |  |             if (StringUtils.isNotBlank(appletCode)){
 | 
	
		
			
				|  |  |                 logger.info("appletCode不为空"+appletCode);
 | 
	
		
			
				|  |  |                 Map<String,Object> objectMap = checkApplets(appletCode,wxWechatDO.getApplets(),wxWechatDO.getAppletsSecret());
 | 
	
		
			
				|  |  |                 if (objectMap!=null){
 | 
	
		
			
				|  |  |                     openId = objectMap.get("openid").toString();
 | 
	
		
			
				|  |  |                     logger.info("appletCode"+appletCode);
 | 
	
		
			
				|  |  |                     logger.info("openid"+openId);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }else {
 | 
	
		
			
				|  |  |                 logger.info("appletCode为空"+appletCode);
 | 
	
		
			
				|  |  |                 List<BasePatientWechatDo> patientWechatDo = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
 | 
	
		
			
				|  |  |                 if (patientWechatDo!=null&&patientWechatDo.size()!=0){
 | 
	
		
			
				|  |  |                     openId = patientWechatDo.get(0).getOpenid();
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             String url = wxWechatDO.getBaseUrl();
 | 
	
		
			
				|  |  |             String notifyUrl =url;
 | 
	
		
			
				|  |  |             String totalFee =businessOrderDO.getPayPrice().intValue()+"";
 | 
	
	
		
			
				|  | @ -868,6 +879,25 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
 | 
	
		
			
				|  |  |         return map;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Map<String, Object> checkApplets(String code,String appid,String appSecret) throws Exception {
 | 
	
		
			
				|  |  |         HttpUtils httpUtils = new HttpUtils();
 | 
	
		
			
				|  |  |         Map<String, Object> param = new HashedMap();
 | 
	
		
			
				|  |  |         param.put("appid", appid);
 | 
	
		
			
				|  |  |         param.put("secret", appSecret);
 | 
	
		
			
				|  |  |         param.put("js_code", code);
 | 
	
		
			
				|  |  |         param.put("grant_type", "authorization_code");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         HttpResponse response = httpUtils.doGet("https://api.weixin.qq.com/sns/jscode2session", param);
 | 
	
		
			
				|  |  |         org.json.JSONObject rs = new org.json.JSONObject(response.getContent());
 | 
	
		
			
				|  |  |         Map<String, Object> res = new HashedMap();
 | 
	
		
			
				|  |  |         logger.info("checkApplets:"+response.getContent());
 | 
	
		
			
				|  |  |         if (rs.has("openid")){
 | 
	
		
			
				|  |  |             res.put("openid", rs.getString("openid"));
 | 
	
		
			
				|  |  |             res.put("sessionKey", rs.getString("session_key"));
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return res;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 获取诊断
 |