Browse Source

Merge branch 'dev' of huangwenjie/patient-co-management into dev

huangwenjie 7 years ago
parent
commit
bd9be94786

+ 84 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/health/bank/CreditLogService.java

@ -6,9 +6,15 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
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.app.device.PatientDeviceService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -46,6 +52,15 @@ public class CreditLogService {
    private StringRedisTemplate redisTemplate;
    @Autowired
    private PatientDeviceService patientDeviceService;
    
    @Autowired
    private PatientService patientService;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    private PatientDao patientDao;
@ -93,6 +108,9 @@ public class CreditLogService {
     * @return
     */
    public JSONObject insert(JSONObject object) throws Exception {
    
        JSONObject result = new JSONObject();
        
        init();
        String response = null;
        String integrate = getIntegrate("health:blank:integrate:"+object.getString("flag"));
@ -112,7 +130,72 @@ public class CreditLogService {
            e.printStackTrace();
            logger.error(e.getMessage());
        }
        return JSONObject.parseObject(response);
    
        result = JSONObject.parseObject(response);
    
    
        String status = result.getString("status");
    
        logger.info("健康银行居民新增积分:"+result.toString());
        if ("200".equals(status)){
            List<Map<String,Object>> list = (List<Map<String,Object>>)result.get("detailModelList");
            if (list!=null && list.size()>0){
                //积分
                String integrateresult = String.valueOf(list.get(0).get("integrate"));
                String patientid = String.valueOf(list.get(0).get("patientId"));
                String total = String.valueOf(list.get(0).get("total"));
            
            
                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 urlresult = "";
                
                    WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_healthbank_credit","jfdztz");
                    first = templateConfig.getFirst();
                    remark = templateConfig.getRemark();
//                    String keyword1 = templateConfig.getKeyword1();
                
                    sendJson.put("keyword1", integrateresult);
                    sendJson.put("keyword2", DateUtil.getStringDate());
                    sendJson.put("keyword3", total);
                    sendJson.put("first", first);
                    sendJson.put("remark", remark);
                    urlresult = templateConfig.getUrl();
                    urlresult = urlresult.replace("key1",(integrate==null?"":integrate));
                    sendJson.put("url", urlresult);//带参数的模板跳转链接
                    System.out.println(sendJson.toString());
                    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);
//		                    }
//	                    }
                }catch (Exception e){
                    logger.info("健康银行居民新增积分,微信模板消息发送失败:"+e.getMessage());
//	                        e.printStackTrace();
                }
            
            }
        }
        return result;
    }

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/survey/PatientQuestionnaireController.java

@ -32,7 +32,7 @@ import java.util.concurrent.ConcurrentHashMap;
@Controller
@RequestMapping(value = "/patient/questionnaire")
@Api(description = "居民端问卷调查")
public class PatientQuestionnaireController extends BaseController {
public class    PatientQuestionnaireController extends BaseController {
    @Autowired
    private PatientQuestionnaireService patientQuestionnaireService;
    @Autowired

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

@ -40,16 +40,7 @@ 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;
    /**
     * 查询积分排名
@ -89,68 +80,6 @@ public class CreditsLogController extends BaseController {
        try {
            JSONObject object = JSONObject.parseObject(creditsDetail);
            JSONObject result = service.insert(object);
    
            String status = result.getString("status");
    
            logger.info("健康银行居民新增积分:"+result.toString());
            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"));
                    String total = String.valueOf(list.get(0).get("total"));
                    
                    
                    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();
//                    String keyword1 = templateConfig.getKeyword1();
    
                        sendJson.put("keyword1", integrate);
                        sendJson.put("keyword2", DateUtil.getStringDate());
                        sendJson.put("keyword3", total);
                        sendJson.put("first", first);
                        sendJson.put("remark", remark);
                        url = templateConfig.getUrl();
                        url = url.replace("key1",(integrate==null?"":integrate));
                        sendJson.put("url", url);//带参数的模板跳转链接
                        System.out.println(sendJson.toString());
                        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);
//		                    }
//	                    }
                    }catch (Exception e){
                        logger.info("健康银行居民新增积分,微信模板消息发送失败:"+e.getMessage());
//	                        e.printStackTrace();
                    }
                }
            }
            return write(200,"添加成功","data",result);
        }catch (Exception e){
            error(e);

+ 88 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/ylzpay/ThirdOnepayController.java

@ -3,10 +3,13 @@ package com.yihu.wlyy.web.third.ylzpay;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.service.third.ylz.PayLogService;
import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
import com.yihu.wlyy.service.weixin.wxpay.model.Charge;
import com.yihu.wlyy.service.weixin.wxpay.service.OnePayService;
import com.yihu.wlyy.util.HttpClientUtil;
@ -16,13 +19,15 @@ import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.exception.PayException;
import com.ylzinfo.onepay.sdk.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -32,6 +37,7 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.List;
/**
 * Created by Reece on 2017/8/30/030.
@ -55,6 +61,8 @@ public class ThirdOnepayController extends WeixinBaseController {
    private HospitalMappingDao mappingDao;
    @Autowired
    ObjectMapper objectMapper;
    @Autowired
    private PatientDao patientDao;
    /**
     * 支付真正完成,异步回调返回支付参数 后台做数据操作
@ -123,5 +131,83 @@ public class ThirdOnepayController extends WeixinBaseController {
        //                记录log日志到数据库
        logService.saveHttpLog(isSuccess, config.getReceiveNotify(), "异步支付通知", "POST", null, params, responses, error, logService.onepayType);
    }
    
//
//    @RequestMapping(value = "bindCard", method = RequestMethod.POST)
//    @ApiOperation("查询绑卡信息")
//    @ResponseBody
//    public String bindCard(
//            @ApiParam(name = "uid", value = "居民CODE", defaultValue = "")
//            @RequestParam String uid,
//            @ApiParam(name = "repUid", value = "家人居民CODE", defaultValue = "")
//            @RequestParam String repUid) throws Exception {
//        try {
//            JSONObject json = new JSONObject();
//            String msg = null;
//
//            Patient people = patientDao.findByCode(uid);
//            String openid = people.getOpenid();
//            String ssc = people.getSsc();
//            String createType = "sicard";
//            if (!repUid.equals(uid)) {
//                createType = "family";
//                people = patientDao.findByCode(repUid);
//                ssc = people.getSsc();
//            }
//            if("undefined".equals(openid)|| StringUtils.isEmpty(openid)){
//                people.setOpenid(null);
//                patientDao.save(people);
//                return write(-1, "用户微信信息格式不正确!");
//            }
//
////            BindCard bindCard = pay.bindCard(patient, openid);
//            List<BindCard> bindCard = pay.bindCardList(openid);
//            String sicardUrl = pay.createSicard(uid, openid, createType);
//            for (BindCard cards : bindCard) {
//                String attachCardNo = cards.getAttachCardNo();
//                if (StringUtil.isNotEmpty(attachCardNo) && StringUtil.isNotEmpty(ssc) && ssc.equals(attachCardNo)) {
//                    String attachRelation = cards.getAttachRelation();
//                    String attachIdType = cards.getAttachIdType();
//                    String attachIdNo = cards.getAttachIdNo();
//                    String attachName = cards.getAttachName();
//                    json.put("attachRelation", attachRelation);
//                    json.put("attachCardNo", attachCardNo);
//                    json.put("attachIdType", attachIdType);
//                    json.put("attachIdNo", attachIdNo);
//                    json.put("attachName", attachName);
//                    json.put("bindStatus", "000000");
//                    json.put("sicardUrl", sicardUrl);
//                    msg = "查询绑卡信息成功!";
//                    return write(200, msg, "data", json);
//                } else {
//                    json.put("sicardUrl", sicardUrl);
//                    json.put("bindStatus", "030007");
//                    msg = "生成电子社保卡成功!";
//                }
//            }
//            if (bindCard.size() == 0 || bindCard == null) {
//                json.put("sicardUrl", sicardUrl);
//                json.put("bindStatus", "030007");
//                msg = "生成电子社保卡成功!";
//            }
//            return write(200, msg, "data", json);
//            /*if (bindCard != null) {
//                JSONObject json = new JSONObject(bindCard);
//                json.put("bindStatus", "000000");
//                json.put("sicardUrl", sicardUrl);
//                return write(200, "查询绑卡信息成功!", "data", json);
//            } else {
////                返回电子社保卡链接
//                JSONObject json = new JSONObject();
//                json.put("sicardUrl", sicardUrl);
//                json.put("bindStatus", "030007");
//                return write(200, "生成电子社保卡成功!", "data", json);
//            }*/
//
//        } catch (Exception e) {
//            error(e);
//            return write(-1, "查询电子社保卡失败!");
//        }
//    }
}

+ 37 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/zysoft/BookingController.java

@ -33,11 +33,9 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@ -79,6 +77,9 @@ public class BookingController extends WeixinBaseController {
    private PushMsgTask pushMsgTask;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    
    @Autowired
    private StringRedisTemplate redisTemplate;
    /**
@ -309,7 +310,38 @@ public class BookingController extends WeixinBaseController {
                              @ApiParam(name = "clinicCard", value = "市民卡号", defaultValue = "D57117706")
                              @RequestParam(value = "clinicCard", required = true) String clinicCard,
                              @ApiParam(name = "patientPhone", value = "患者手机", defaultValue = "13950116510")
                              @RequestParam(value = "patientPhone", required = true) String patientPhone) {
                              @RequestParam(value = "patientPhone", required = true) String patientPhone,
                              @ApiParam(name = "key", value = "验证码key")
                              @RequestParam(value = "key", required = true) String key,
                              @ApiParam(name = "openId", value = "openId")
                              @RequestParam(value = "openId", required = true) String openId,
                              @ApiParam(name = "text", value = "text")
                              @RequestParam(value = "text", required = true) String text
        ) {
    
        try{
            boolean pass = false;
            key = key.replaceFirst(":",":"+openId+"_");
        
            String captcha = redisTemplate.opsForValue().get(key);
            if (captcha != null && captcha.equals(text.toLowerCase())){
                pass = true;
                redisTemplate.delete(key);
            }
            
            if(!pass){
                return error(-1, "验证码校验失败");
            }
//            else{
//                return write(200, "ok", "pass", pass);
//            }
        
            
        } catch (Exception e){
            error(e);
            return error(-1, e.getMessage());
        }
        
        try {
            if (StringUtils.isEmpty(patientName)) {
                return error(-1, "未设置姓名!");

+ 36 - 32
patient-co/patient-co-wlyy/src/main/resources/application-local.yml

@ -53,38 +53,42 @@ wechat:
  wechat_base_url: http%3a%2f%2fwww.xmtyw.cn%2fwlyy
  accId: gh_ffd64560fb21
  message:
     ##医生追加建议提醒 --签约邀请
     doctor_invitel_template: MQn79bx1ofb6hekhmRIuqLU7KjySJQzaBzrimgqVrzA
     #咨询回复
     template_consult_notice: 0mF_vHj-ILx8EH8DwzmAi7LqzjqYiU9IrSRRmziTZyc
     #签约成功
     template_sign_success: 0D2vYZVRzFz15p9Y_pkZ1DKutDq8UOsks79FXUKS0tA
     #签约失败
     template_sign_failed: My2VNERjJt4NXR4Ibh42pdrP6B6ka8rQxZeWinQh99s
     #健康指导提醒
     template_health_notice: uv31ES_VCmq3tBYtyGmEQvIwU_zh9LDhF3bFpbIUt5g
     #解约提醒
     template_termination:  C0tdXtA_8k-Cy4a1EkzQuI877vqaqAtRkc-e_Gsd7sk
     #预约成功
     template_appoint_success:  FY3Pqa66tHIE1Fv-irbFBPOh5cYP71fkOzfZKH4S-Fo
     #预约取消
     template_appoint_failed:  tldWEb9AN7p_RoHoD8ml0GxWW3V1V_mpEEhp2v6p56s
     #缴费提醒
     template_expenses_remind:  AcrlihhoGbm22A8cdFFDQ4u38ptRw0aiIPf-aGvNxMM
     #健康教育
     template_healthy_article: a5-ZGf-IUUULsuRNoHWQiBMU6pSYhLgPPqV67SjdLRo
     #医生变更
     template_doctor_change:  dtzSHImbPKfwcrjWlJEjAw3lGlvrLjsobSOE8g4adZA
     #问卷调查
     template_doctor_survey:  8ZWKJmoJ7VR7Uk4YS7aa0Z94QzCkxsyTW6R4CHhUJII
     #审核结果通知
     template_doctor_audit:  egrX5Larpkv8opQW67_hwsZoT0OHwwUpE1v7HeU_Jnw
     #服务结果通知
     template_doctor_service:  xhi1LEudiZwJfZylOHuZNo8EiA73GtSshPQv5XOt9Lk
     #体检报告提醒
     template_physical_examination:  jTsvKU3iFw0yiJi5ESyFGDTmFSVcWlMot3yHier39Vc
     #处理结果通知
     template_deal_with:  GyXCmXVYCD7PXi0IbHdPOD8apa-RQoSrSw-4-0pj9Go
   ##医生追加建议提醒 --签约邀请
   doctor_invitel_template: MQn79bx1ofb6hekhmRIuqLU7KjySJQzaBzrimgqVrzA
   #咨询回复
   template_consult_notice: 0mF_vHj-ILx8EH8DwzmAi7LqzjqYiU9IrSRRmziTZyc
   #签约成功
   template_sign_success: 0D2vYZVRzFz15p9Y_pkZ1DKutDq8UOsks79FXUKS0tA
   #签约失败
   template_sign_failed: My2VNERjJt4NXR4Ibh42pdrP6B6ka8rQxZeWinQh99s
   #健康指导提醒
   template_health_notice: uv31ES_VCmq3tBYtyGmEQvIwU_zh9LDhF3bFpbIUt5g
   #解约提醒
   template_termination:  C0tdXtA_8k-Cy4a1EkzQuI877vqaqAtRkc-e_Gsd7sk
   #预约成功
   template_appoint_success:  FY3Pqa66tHIE1Fv-irbFBPOh5cYP71fkOzfZKH4S-Fo
   #预约取消
   template_appoint_failed:  tldWEb9AN7p_RoHoD8ml0GxWW3V1V_mpEEhp2v6p56s
   #缴费提醒
   template_expenses_remind:  AcrlihhoGbm22A8cdFFDQ4u38ptRw0aiIPf-aGvNxMM
   #健康教育
   template_healthy_article: a5-ZGf-IUUULsuRNoHWQiBMU6pSYhLgPPqV67SjdLRo
   #医生变更
   template_doctor_change:  dtzSHImbPKfwcrjWlJEjAw3lGlvrLjsobSOE8g4adZA
   #代办事项
   template_doctor_survey:  8ZWKJmoJ7VR7Uk4YS7aa0Z94QzCkxsyTW6R4CHhUJII
   #审核结果通知
   template_doctor_audit:  egrX5Larpkv8opQW67_hwsZoT0OHwwUpE1v7HeU_Jnw
   #服务结果通知
   template_doctor_service:  xhi1LEudiZwJfZylOHuZNo8EiA73GtSshPQv5XOt9Lk
   #体检报告提醒
   template_physical_examination:  jTsvKU3iFw0yiJi5ESyFGDTmFSVcWlMot3yHier39Vc
   #处理结果通知
   template_deal_with:  GyXCmXVYCD7PXi0IbHdPOD8apa-RQoSrSw-4-0pj9Go
   #设备绑定结果通知
   template_patient_bind_device: 1GWPw6LFcSuz2LFTo6LhE-YY8abtmcKRvor1fUzfxBE
   #积分到账通知
   template_healthbank_credit: A2L6WBm1p6bDPYGkGnUmoMvpWlRruP2lapYwHfLV7Rg
yihu: