Explorar o código

健康积分微信模板推送

huangwenjie %!s(int64=7) %!d(string=hai) anos
pai
achega
565a0ee957

+ 1 - 0
patient-co-service/wlyy_device/src/main/java/com/yihu/hos/device/service/DeviceService.java

@ -480,6 +480,7 @@ public class DeviceService extends BaseService{
                        if (list!=null && list.size()>0){
                            String integrate = String.valueOf(list.get(0).get("integrate"));
                            //@TODO 调用发送微信模板接口
                            //这里调整到新增积分的接口中发送微信模板
                        }
                    }
                }

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

@ -122,26 +122,26 @@ 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);
	                    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) {

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

@ -4,8 +4,16 @@
package com.yihu.wlyy.web.third.health.bank;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.common.account.PatientService;
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.wechat.util.WeiXinAccessTokenUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -13,6 +21,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
 * @author wangzhinan
 * @create 2018-05-07 8:50
@ -25,6 +36,16 @@ public class CreditsLogController extends BaseController {
    @Autowired
    private CreditLogService service;
    @Autowired
    private PatientService patientService;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private PatientDao patientDao;
    /**
     * 查询积分排名
@ -64,6 +85,57 @@ public class CreditsLogController extends BaseController {
        try {
            JSONObject object = JSONObject.parseObject(creditsDetail);
            JSONObject result = service.insert(object);
    
            String status = result.getString("status");
            if ("200".equals(status)){
                List<Map<String,Object>> list = (List<Map<String,Object>>)result.get("detailModelList");
                if (list!=null && list.size()>0){
                    //积分
                    String integrate = String.valueOf(list.get(0).get("integrate"));
                    String patientid = String.valueOf(list.get(0).get("patientId"));
                    
                    
                    //@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();
//                    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);
//	                    //发送代理人
//	                    jsonArray = weiXinOpenIdUtils.getAgentOpenId(patient, openId);
//	                    if (jsonArray != null && jsonArray.length() > 0) {
//		                    for (int i = 0; i < jsonArray.length(); i++) {
//			                    org.json.JSONObject j = jsonArray.getJSONObject(i);
//			                    Patient member = (Patient) j.get("member");
//			                    int start = url.indexOf("&toUser=");
//			                    int end = url.indexOf("&", start + 1);
//			                    String touser = url.substring(start, end);
//			                    url = url.replace(touser, "&toUser=" + member.getCode());
//			                    //name患者姓名
//			                    sendJson.put("first", weiXinOpenIdUtils.getTitleMes(people, (int) j.get("relation"), name) + first);
//			                    sendJson.put("url", url);
//			                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 19, member.getOpenid(), name, sendJson);
//		                    }
//	                    }
                }
            }
            return write(200,"添加成功","data",result);
        }catch (Exception e){
            error(e);