| 
					
				 | 
			
			
				@ -1,6 +1,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				package com.yihu.wlyy.web.patient.prescription; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.app.prescription.PatientPrescriptionPayService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.app.prescription.PrescriptionNoticesService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.service.app.prescription.PrescriptionService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import com.yihu.wlyy.web.WeixinBaseController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				import io.swagger.annotations.Api; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -30,11 +31,13 @@ public class PatientPrescriptionPayController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionService prescriptionService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    private PrescriptionNoticesService noticesService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 患者长处方支付接口 可配送方式查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param orgCode 居民签约社区code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param orgCode          居民签约社区code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param prescriptionCode 续方code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @throws Exception 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -45,8 +48,8 @@ public class PatientPrescriptionPayController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(required = true) @ApiParam(value = "续方code", name = "prescriptionCode") String prescriptionCode, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(required = true) @ApiParam(value = "居民签约社区code", name = "orgCode") String orgCode) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            com.alibaba.fastjson.JSONObject result = payService.dispatch(prescriptionCode,orgCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(200, "获取成功!","data",result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            com.alibaba.fastjson.JSONObject result = payService.dispatch(prescriptionCode, orgCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(200, "获取成功!", "data", result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return error(-1, "获取失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -70,7 +73,7 @@ public class PatientPrescriptionPayController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(required = true) @ApiParam(value = "居民社区code", name = "orgCode") String orgCode, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(required = true) @ApiParam(value = "续方code", name = "prescriptionCode") String prescriptionCode, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(required = true) @ApiParam(value = "配送方式", name = "type") int type, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(required = true) @ApiParam(value = "配送地址json", name = "addressJson",defaultValue = "{\"townName\":\"海沧区\",\"code\":\"3502050100\",\"address\":" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(required = true) @ApiParam(value = "配送地址json", name = "addressJson", defaultValue = "{\"townName\":\"海沧区\",\"code\":\"3502050100\",\"address\":" + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\"冰岛\",\"cityName\":\"厦门市\",\"townCode\":\"350205\",\"provinceCode\":\"350000\",\"cityCode\":\"350200\",\"name\":\"海沧区嵩屿街道社区卫生服务中心\"," + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                    "\"provinceName\":\"福建省\",\"streeCode\":\"35020501\",\"streeName\":\"皇后大道东\",\"phone\":\"13253541190\"}") String addressJson, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(required = true) @ApiParam(value = "页面回调地址", name = "returnUrl") String returnUrl, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -78,8 +81,12 @@ public class PatientPrescriptionPayController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String accessToken = getAccessToken(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String patient = getUID(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map result = payService.charge(type,addressJson,orgCode, prescriptionCode, totalAmount, patient, accessToken,returnUrl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(200, "支付成功!","data",result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map result = payService.charge(type, addressJson, orgCode, prescriptionCode, totalAmount, patient, accessToken, returnUrl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            if ("-1".equals(result.get("status").toString())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return error(-1, "续方居民信息与微信支付身份信息不一致!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                return write(200, "支付成功!", "data", result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return error(-1, "支付失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -97,7 +104,7 @@ public class PatientPrescriptionPayController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String accessToken = getAccessToken(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String result = payService.chargeQuery(outChargeNo, accessToken); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(200, "获取成功!","data",result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(200, "获取成功!", "data", result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return error(-1, "获取失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -116,7 +123,7 @@ public class PatientPrescriptionPayController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            String accessToken = getAccessToken(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            Map result = payService.recipeReturnUrl(request, response, accessToken); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(200, "页面回调成功!","data",result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(200, "页面回调成功!", "data", result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return error(-1, "页面回调失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@ -143,13 +150,46 @@ public class PatientPrescriptionPayController extends WeixinBaseController { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "cardNo", value = "社保卡号", defaultValue = "D21085562") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "cardNo", required = true) String cardNo, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "visitNo", value = "挂号号", defaultValue = "3277865") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "visitNo", required = true) String visitNo){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "visitNo", required = true) String visitNo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            com.alibaba.fastjson.JSONObject jsonParams = prescriptionService.getPayInfo(cardNo,visitNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(200, "获取成功!","data",jsonParams); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            com.alibaba.fastjson.JSONObject jsonParams = prescriptionService.getPayInfo(cardNo, visitNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(200, "获取成功!", "data", jsonParams); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return error(-1, "获取失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 测试长处方相关模板通知消息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param patient   要发送对象居民code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param doctName  相关医生姓名(type=1审核医生、type=2 null、type=3配送健管师、type=4审核医生) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param ordenTime 订单完成时间(type=1 null、type=2 null、type=3 null、type=4 订单完成时间) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param type      1:续方审核通知 2:取药代办通知 3:配送中信息变更 4:已完成服务结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param status    续方通知状态 0不通过 1通过 2调整处方  其余状态均为0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     * @param url       带参数的模板跳转链接 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @RequestMapping(value = "/testSendMassages", method = RequestMethod.POST) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    @ApiOperation(value = "测试长处方相关模板通知消息") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    public String testSendMassages( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "patient", value = "要发送对象居民code") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "patient", required = true) String patient, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "doctName", value = "相关医生姓名(type=1审核医生、type=2 null、type=3配送健管师、type=4审核医生)") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "doctName", required = false) String doctName, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "ordenTime", value = "订单完成时间(type=1 null、type=2 null、type=3 null、type=4 订单完成时间)") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "ordenTime", required = false) String ordenTime, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "type", value = "1:续方审核通知 2:取药代办通知 3:配送中信息变更 4:已完成服务结果") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "type", required = true) int type, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "status", value = "续方通知状态 0不通过 1通过 2调整处方  其余状态均为0") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "status", required = true) int status, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @ApiParam(name = "url", value = "带参数的模板跳转链接") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            @RequestParam(value = "url", required = true) String url) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            noticesService.sendMessages(patient, doctName, ordenTime, type, status, url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return write(200, "发送成功!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				            return error(-1, "发送失败!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				} 
			 |