Browse Source

代码修改

yeshijie 8 năm trước cách đây
mục cha
commit
4b0d112348

+ 49 - 16
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -1636,6 +1636,8 @@ public class SignWebService extends BaseService {
        //发送微信模板消息
        Patient p = patientService.findByCode(patientCode);
        JSONObject json = new JSONObject();
        json.put("toUser", patientCode);
        json.put("represented",patientCode);//被代理人
        json.put("keyword1", "续签家庭医生");
        json.put("keyword2", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
        json.put("remark", "提醒医生 :" + d.getName() + "\n"
@ -1649,27 +1651,58 @@ public class SignWebService extends BaseService {
            PushMsgTask.getInstance().putWxMsg(access_token, 16, openid, name, json);
            patientSetReminFlag(patientCode);
            return 1;
        } else {
            //如果自己没有绑定,则发给家人
            JSONObject j = weiXinOpenIdUtils.getFamilyOpenId(patientCode);
            Patient member = (Patient) j.get("member");
            if (StringUtils.isNotBlank(member.getOpenid())) {
                json.put("first", weiXinOpenIdUtils.getTitleMes(p, (int) j.get("relation"), name) + "\n" +
        }
        //发送代理人
        boolean flag = true;
        JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(patientCode,openid);
        if(jsonArray!=null&&jsonArray.length()>0){
            for (int i = 0;i<jsonArray.length();i++){
                flag = false;
                JSONObject j  = jsonArray.getJSONObject(i);
                Patient member = (Patient) j.get("member");
                JSONObject data = json;
                data.remove("toUser");
                data.put("toUser",member.getCode());
                json.put("first", weiXinOpenIdUtils.getTitleMes(p, (int) j.get("relation"), p.getName()) + "\n" +
                        name + ",您好!\n" +
                        "您的家庭医生签约将于6月30日到期,为了能继续给您提供健康服务,诚邀您续签家庭医生。");
                PushMsgTask.getInstance().putWxMsg(access_token, 16, member.getOpenid(), name, json);
                PushMsgTask.getInstance().putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 16, member.getOpenid(), p.getName(), data);
            }
        }
        if(flag){
            //发送短信
            String mobile = p.getMobile();
            if (StringUtils.isNotBlank(mobile)) {
                SMSService.sendMsg(mobile, name + "您好!您的家庭医生将于6月30日到期,为了继续给您提供健康服务,请关注“厦门i健康”公众号,回复“续签”,进行家庭医生线上续签。");
                patientSetReminFlag(patientCode);
                return 1;
            } else {
                //发送短信
                String mobile = p.getMobile();
                if (StringUtils.isNotBlank(mobile)) {
                    SMSService.sendMsg(mobile, name + "您好!您的家庭医生将于6月30日到期,为了继续给您提供健康服务,请关注“厦门i健康”公众号,回复“续签”,进行家庭医生线上续签。");
                    patientSetReminFlag(patientCode);
                    return 2;
                }
                return 2;
            }
        }else {
            return 1;
        }
//        else {
//            //如果自己没有绑定,则发给家人
//            JSONObject j = weiXinOpenIdUtils.getFamilyOpenId(patientCode);
//            Patient member = (Patient) j.get("member");
//            if (StringUtils.isNotBlank(member.getOpenid())) {
//                json.put("first", weiXinOpenIdUtils.getTitleMes(p, (int) j.get("relation"), name) + "\n" +
//                        name + ",您好!\n" +
//                        "您的家庭医生签约将于6月30日到期,为了能继续给您提供健康服务,诚邀您续签家庭医生。");
//                PushMsgTask.getInstance().putWxMsg(access_token, 16, member.getOpenid(), name, json);
//                patientSetReminFlag(patientCode);
//                return 1;
//            } else {
//                //发送短信
//                String mobile = p.getMobile();
//                if (StringUtils.isNotBlank(mobile)) {
//                    SMSService.sendMsg(mobile, name + "您好!您的家庭医生将于6月30日到期,为了继续给您提供健康服务,请关注“厦门i健康”公众号,回复“续签”,进行家庭医生线上续签。");
//                    patientSetReminFlag(patientCode);
//                    return 2;
//                }
//            }
//        }
        return -1;
    }