瀏覽代碼

邀请医生模板消息推送

lyr 8 年之前
父節點
當前提交
7a0ac6c636

+ 5 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/security/TokenDao.java

@ -1,5 +1,7 @@
package com.yihu.wlyy.repository.security;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -35,4 +37,7 @@ public interface TokenDao extends PagingAndSortingRepository<Token, Long> {
	@Query("delete Token a where a.user = ?1 and a.platform = 3 and a.del = '1'")
	int deleteWxTokenByPatient(String patient);
	@Query("select a from Token a where a.imei = ?1 and a.platform = 3 and a.del = '1'")
	Page<Token> findByOpenid(String openid, Pageable pageable);
}

+ 2 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyService.java

@ -382,7 +382,8 @@ public class FamilyService {
                .replace("{doctorCode}", doctor.getCode())//医生code;
                .replace("{invilogcode}", code)//邀请记录code
                .replace("{currentPatient}", currentPatient.getCode())//当前用户的code
                .replace("{currentZH}", currentPatient.getMobile());//当前用户的账号
                .replace("{currentZH}", currentPatient.getMobile())//当前用户的账号
                .replace("{currentName}", currentPatient.getName()); //当前用户名;
        //发送模板
        JSONObject end = new JSONObject();
        end.put("value", "【点击帮助您的家庭成员完成签约】");

+ 20 - 8
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -14,9 +14,11 @@ import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.security.TokenDao;
import com.yihu.wlyy.task.SignSsGetTask;
import com.yihu.wlyy.util.EncodesUtil;
import com.yihu.wlyy.util.IdcardInfoExtractor;
import com.yihu.wlyy.util.SystemData;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -47,6 +49,8 @@ public class PatientService extends TokenService {
    private DoctorDao doctorDao;
    @Autowired
    private DoctorPatientDao doctorPatientDao;
    @Autowired
    TokenDao tokenDao;
    private Clock clock = Clock.DEFAULT;
@ -96,16 +100,24 @@ public class PatientService extends TokenService {
     *
     * @param patient
     */
    public void updatePatient(Patient patient, String openid) {
        if (patientDao.countByOpenid(openid) >= 10) {
            Sort sort = new Sort(Sort.Direction.ASC, "czrq");
            PageRequest pageRequest = new PageRequest(0, 1, sort);
            Page<Patient> pPage = patientDao.findPatientByOpenid(openid, pageRequest);
            for (Patient p : pPage) {
                p.setOpenid("");
                patientDao.save(p);
    public void updatePatient(Patient patient, String openid) throws Exception {
        Sort sort = new Sort(Sort.Direction.ASC, "czrq");
        PageRequest pageRequest = new PageRequest(0, 10, sort);
        Page<Token> tokens = tokenDao.findByOpenid(openid, pageRequest);
        if (tokens != null && tokens.getSize() >= 10) {
            Token token = tokens.getContent().get(0);
            Patient p = patientDao.findByCode(token.getUser());
            if (p == null) {
                throw new Exception("> 10 openid patient info can not find");
            }
            p.setOpenid("");
            signFamilyDao.updateOpenidByPatient("", p.getCode());
            patientDao.save(p);
            tokenDao.delete(token);
            SystemData.wxPatientTokens.remove(p.getCode());
        }
        patient.setOpenid(openid);
        patientDao.save(patient);
        if (StringUtils.isNotEmpty(patient.getOpenid())) {

+ 1 - 1
patient-co-wlyy/src/main/resources/system.properties

@ -17,7 +17,7 @@ doctor_hos_qrcode_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid=
doctor_subscribe_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fqygl%2fhtml%2fsigning-welcome.html&amp;response_type=code&amp;scope=snsapi_base&amp;state=code#wechat_redirect
doctor_town_qrcode_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri={server}%2fwx%2fhtml%2fqygl%2fhtml%2fsearch-community.html&amp;response_type=code&amp;scope=snsapi_base&amp;state={town}#wechat_redirect
doctor_qrcode_pic_url={server}/images/familycontract.png
doctor_invitel_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&redirect_uri={server}%2fwx%2fhtml%2fssgg%2fhtml%2fdoctor-homepage-new.html&response_type=code&scope=snsapi_base&state={doctorCode}__{invilogcode}__{currentPatient}__{currentZH}#wechat_redirect
doctor_invitel_url=https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&redirect_uri={server}%2fwx%2fhtml%2fssgg%2fhtml%2fdoctor-homepage-new.html&response_type=code&scope=snsapi_base&state={doctorCode}__{invilogcode}__{currentPatient__{currentZH}__{currentName}#wechat_redirect
# SMS短信配置
yihu_sms_url=https://smsapi.ums86.com:9600/sms/Api/Send.do