|
@ -4,8 +4,16 @@
|
|
package com.yihu.wlyy.web.third.health.bank;
|
|
package com.yihu.wlyy.web.third.health.bank;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
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.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.BaseController;
|
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
|
|
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;
|
|
@ -13,6 +21,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author wangzhinan
|
|
* @author wangzhinan
|
|
* @create 2018-05-07 8:50
|
|
* @create 2018-05-07 8:50
|
|
@ -25,6 +36,16 @@ public class CreditsLogController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private CreditLogService service;
|
|
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 {
|
|
try {
|
|
JSONObject object = JSONObject.parseObject(creditsDetail);
|
|
JSONObject object = JSONObject.parseObject(creditsDetail);
|
|
JSONObject result = service.insert(object);
|
|
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);
|
|
return write(200,"添加成功","data",result);
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
error(e);
|
|
error(e);
|