Explorar el Código

健康银行微信模板消息

huangwenjie hace 7 años
padre
commit
56cbe34847

+ 28 - 20
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/device/DoctorDeviceController.java

@ -22,6 +22,8 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
@ -41,6 +43,7 @@ import java.util.Map;
@RequestMapping(value = "doctor/device", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(value = "患者设备管理--医生端", description = "患者设备管理--医生端")
public class DoctorDeviceController extends BaseController {
	private static Logger logger = LoggerFactory.getLogger(DoctorDeviceController.class);
	@Autowired
	private PatientDeviceService patientDeviceService;
@ -122,26 +125,27 @@ public class DoctorDeviceController extends BaseController {
                        String flagType = String.valueOf(list.get(0).get("flag"));
                        
                        //@TODO 调用发送微信模板接口
	                    Patient people = patientDao.findByCode(device.getUser());
	                    String openId = people.getOpenid();
	                    String name = people.getName();
	                    org.json.JSONObject sendJson = new org.json.JSONObject();
	                    String first = "";
	                    String remark = "";
	                    String deviceName = device.getDeviceName();
	                    WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_patient_bind_device","bdsb");
	                    first = templateConfig.getFirst();
	                    first = first.replace("key1",(deviceName==null?"":deviceName));
	                    remark = templateConfig.getRemark();
	                    String keyword1 = templateConfig.getKeyword1();
	                    sendJson.put("keyword1", keyword1);
	                    sendJson.put("keyword2", device.getCzrq());
	                    sendJson.put("first", first);
	                    sendJson.put("remark", remark);
	                    sendJson.put("url", templateConfig.getUrl());//带参数的模板跳转链接
	                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 22, openId, name, sendJson);
	                    try {
		                    Patient people = patientDao.findByCode(device.getUser());
		                    String openId = people.getOpenid();
		                    String name = people.getName();
		
		                    org.json.JSONObject sendJson = new org.json.JSONObject();
		                    String first = "";
		                    String remark = "";
		                    String deviceName = device.getDeviceName();
		                    WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_patient_bind_device","bdsb");
		                    first = templateConfig.getFirst();
		                    first = first.replace("key1",(deviceName==null?"":deviceName));
		                    remark = templateConfig.getRemark();
		                    String keyword1 = templateConfig.getKeyword1();
		
		                    sendJson.put("keyword1", keyword1);
		                    sendJson.put("keyword2", device.getCzrq());
		                    sendJson.put("first", first);
		                    sendJson.put("remark", remark);
		                    sendJson.put("url", templateConfig.getUrl());//带参数的模板跳转链接
		                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 22, openId, name, sendJson);
//	                    //发送代理人
//	                    jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
//	                    if (jsonArray != null && jsonArray.length() > 0) {
@ -158,6 +162,10 @@ public class DoctorDeviceController extends BaseController {
//			                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, member.getOpenid(), name, sendJson);
//		                    }
//	                    }
	                    }catch (Exception e){
		                    logger.info("设备绑定微信模板消息发送失败:"+e.getMessage());
//	                        e.printStackTrace();
	                    }
	                    
                    }
                }

+ 30 - 20
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/health/bank/CreditsLogController.java

@ -13,10 +13,13 @@ import com.yihu.wlyy.service.third.health.bank.CreditLogService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.doctor.device.DoctorDeviceController;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@ -33,6 +36,7 @@ import java.util.Map;
@RequestMapping(value = "/healthBank",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "积分处理机制")
public class CreditsLogController extends BaseController {
    private static Logger logger = LoggerFactory.getLogger(CreditsLogController.class);
    @Autowired
    private CreditLogService service;
@ -95,29 +99,30 @@ public class CreditsLogController extends BaseController {
                    String patientid = String.valueOf(list.get(0).get("patientId"));
                    
                    
                    //@TODO 获取积分调用发送微信模板接口
                    Patient people = patientDao.findByCode(patientid);
                    String openId = people.getOpenid();
                    String name = people.getName();
                    try {
                        //@TODO 获取积分调用发送微信模板接口
                        Patient people = patientDao.findByCode(patientid);
                        String openId = people.getOpenid();
                        String name = people.getName();
    
                    org.json.JSONObject sendJson = new org.json.JSONObject();
                    String first = "";
                    String remark = "";
                    String url = "";
                    
                    WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_healthbank_credit","jfdztz");
                    first = templateConfig.getFirst();
                    remark = templateConfig.getRemark();
                        org.json.JSONObject sendJson = new org.json.JSONObject();
                        String first = "";
                        String remark = "";
                        String url = "";
    
                        WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_healthbank_credit","jfdztz");
                        first = templateConfig.getFirst();
                        remark = templateConfig.getRemark();
//                    String keyword1 = templateConfig.getKeyword1();
    
                    sendJson.put("keyword1", integrate);
                    sendJson.put("keyword2", DateUtil.getStringDate());
                    sendJson.put("first", first);
                    sendJson.put("remark", remark);
                    url = templateConfig.getUrl();
                    url = url.replace("key1",(integrate==null?"":integrate));
                    sendJson.put("url", url);//带参数的模板跳转链接
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 23, openId, name, sendJson);
                        sendJson.put("keyword1", integrate);
                        sendJson.put("keyword2", DateUtil.getStringDate());
                        sendJson.put("first", first);
                        sendJson.put("remark", remark);
                        url = templateConfig.getUrl();
                        url = url.replace("key1",(integrate==null?"":integrate));
                        sendJson.put("url", url);//带参数的模板跳转链接
                        pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 23, openId, name, sendJson);
//	                    //发送代理人
//	                    jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
//	                    if (jsonArray != null && jsonArray.length() > 0) {
@ -134,6 +139,11 @@ public class CreditsLogController extends BaseController {
//			                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, member.getOpenid(), name, sendJson);
//		                    }
//	                    }
                    }catch (Exception e){
                        logger.info("健康银行居民新增积分,微信模板消息发送失败:"+e.getMessage());
//	                        e.printStackTrace();
                    }
                }
            }
            return write(200,"添加成功","data",result);