Browse Source

留言锦旗限制

wangjun 4 years ago
parent
commit
d4306d3ffb

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/message/dao/BaseBannerDoctorDao.java

@ -20,5 +20,7 @@ public interface BaseBannerDoctorDao extends PagingAndSortingRepository<BaseBann
    Integer getTotalBannerCount(String doctor);
    @Query( value = "SELECT * from base_banner_doctor t where t.doctor = ?1 and t.patient_id =?2 and t.relation_code =?3" ,nativeQuery = true)
    List<BaseBannerDoctorDO> getBanners(String doctor,String patientId,String relationCode);
    @Query("from BaseBannerDoctorDO t where t.patientId =?1 order by t.createTime desc ")
    List<BaseBannerDoctorDO> getBannersBypatients(String patientId);
}

+ 37 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/message/service/BaseBannerDoctorService.java

@ -2,9 +2,11 @@ package com.yihu.jw.hospital.message.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.message.BaseBannerDO;
import com.yihu.jw.entity.hospital.message.BaseBannerDoctorDO;
import com.yihu.jw.entity.hospital.message.BaseUserMessageDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.hospital.message.dao.BaseBannerDao;
import com.yihu.jw.hospital.message.dao.BaseBannerDoctorDao;
import com.yihu.jw.hospital.message.dao.BaseUserMessageDao;
@ -38,6 +40,8 @@ public class BaseBannerDoctorService extends BaseJpaService<BaseBannerDoctorDO,
    private BasePatientDao patientDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    //批量新增锦旗
    @Transactional
@ -45,6 +49,7 @@ public class BaseBannerDoctorService extends BaseJpaService<BaseBannerDoctorDO,
                           String doctor,String doctorName,Integer type){
        String patientName = null;
        BasePatientDO basePatientDO=patientDao.findById(patientId);
        boolean checkTimeOut = this.checkGiveTimeOut(patientId);
        List<BaseBannerDoctorDO> bannerList = new ArrayList<>();
        String relationCode= UUID.randomUUID().toString();
        if(null!=basePatientDO){
@ -174,4 +179,36 @@ public class BaseBannerDoctorService extends BaseJpaService<BaseBannerDoctorDO,
        jsonObject.put("totalCount",count);
        return jsonObject;
    }
    public boolean checkGiveTimeOut(String patientId){
        boolean flag = false;
        List<BaseBannerDoctorDO> baseBannerDoctorDOS = baseBannerDoctorDao.getBannersBypatients(patientId);
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("banner_give_timeout");
        if (null!=baseBannerDoctorDOS){
            BaseBannerDoctorDO lastOne = baseBannerDoctorDOS.get(0);
            Date lastDate = lastOne.getCreateTime();
            long timeOut = wlyyHospitalSysDictDO.getDictValue()!=null?Long.valueOf(wlyyHospitalSysDictDO.getDictValue()):5;
            Date current = new Date();
            if(current.getTime()-lastDate.getTime()>timeOut*1000*60){
                return true;
            }else{
                return false;
            }
        }else {
            return true;
        }
    }
    public boolean checkGiveTimes(String patientId){
        boolean flag = false;
        StringBuffer sql = new StringBuffer();
        sql.append("select t.relation_code as \"relation_code\",t.patient_id as \"patient_id\" from base_banner_doctor t");
        sql.append(" where 1=1 ");
        if (StringUtils.isNotBlank(patientId)){
            sql.append(" and t.patient_id = '"+patientId+"'");
        }
        sql.append(" group by t.relation_code,t.patientId");
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql.toString());
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findById("leave_message_times");
        return false;
    }
}

+ 60 - 23
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -108,6 +108,9 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
    private XzzxEntranceService xzzxEntranceService;
    @Value("${wechat.flag}")
    private boolean flag;
    @Value("${wechat.id}")
    private String wechatId;
@ -430,12 +433,18 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        if (tradeType.equalsIgnoreCase("JSAPI")){
            map.put("openid", openId);
        }
        String wapUrl = "";
        String wapName = "";
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            wapUrl = "https://www1.yanketong.com";
            wapName = "厦门大学附中厦门眼科中心";
        }
        if (tradeType.equalsIgnoreCase("MWEB")){
            JSONObject jsonObject = new JSONObject();
            JSONObject object = new JSONObject();
            object.put("type","Wap");
            object.put("wap_url","");
            object.put("wap_name","");
            object.put("wap_url",wapUrl);
            object.put("wap_name",wapName);
            jsonObject.put("h5_info",object);
            map.put("scene_info",jsonObject.toJSONString());
        }
@ -462,30 +471,58 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
            String mchId = pay.get("mch_id").toString();
            String nonceStr = pay.get("nonce_str").toString();
            String prepayId = pay.get("prepay_id").toString();
            String trade = pay.get("trade_type").toString();
            if (trade.equalsIgnoreCase("Native")){
            String trade = "";
            if ("SUCCESS".equalsIgnoreCase(resultCode)){
                trade = pay.get("trade_type").toString();
                if (trade.equalsIgnoreCase("Native")){
                    Map<String,String> param = new HashedMap();
                    param.put("appId",appid);
                    param.put("package","prepay_id="+prepayId);
                    param.put("nonceStr",nonceStr);
                    param.put("signType","MD5");
                    param.put("timeStamp",getTimeStamp());
                    param = WeiXinPayUtils.getMapAfterUnifiedorder(param,wxWechatDO.getAppKey());
                    InputStream qrcode = QrcodeUtil.createQrcode(pay.get("code_url").toString(),300,"jpg");
                    ByteToInputStream byteToInputStream = new ByteToInputStream();
                    String QRCodeImg = byteToInputStream.getBase64FromInputStream(qrcode);
                    param.put("qrcode","data:image/png;base64,"+ QRCodeImg);
                    pay.put("native",param);
                }//h5支付方法 返回跳转的微信收银台地址
                else if("MWEB".equalsIgnoreCase(trade)){
                    Map<String,String> param = new HashedMap();
                    param.put("appId",appid);
                    param.put("package","prepay_id="+prepayId);
                    param.put("nonceStr",nonceStr);
                    param.put("signType","MD5");
                    param.put("timeStamp",getTimeStamp());
                    param = WeiXinPayUtils.getMapAfterUnifiedorder(param,wxWechatDO.getAppKey());
                    //微信收银台地址
                    String mwebUrl = pay.get("mweb_url").toString();
                    param.put("mweb_url",mwebUrl);
                    pay.put("MWEB",param);
                }else {
                    Map<String,String> param = new HashedMap();
                    param.put("appId",appid);
                    param.put("package","prepay_id="+prepayId);
                    param.put("nonceStr",nonceStr);
                    param.put("signType","MD5");
                    param.put("timeStamp",getTimeStamp());
                    param = WeiXinPayUtils.getMapAfterUnifiedorder(param,wxWechatDO.getAppKey());
                    pay.put("jsapi",param);
            }
            }else {
                //支付失败返回信息
                Map<String,String> param = new HashedMap();
                param.put("appId",appid);
                param.put("package","prepay_id="+prepayId);
                param.put("nonceStr",nonceStr);
                param.put("signType","MD5");
                param.put("timeStamp",getTimeStamp());
                param = WeiXinPayUtils.getMapAfterUnifiedorder(param,wxWechatDO.getAppKey());
                InputStream qrcode = QrcodeUtil.createQrcode(pay.get("code_url").toString(),300,"jpg");
                ByteToInputStream byteToInputStream = new ByteToInputStream();
                String QRCodeImg = byteToInputStream.getBase64FromInputStream(qrcode);
                param.put("qrcode","data:image/png;base64,"+ QRCodeImg);
                pay.put("native",param);
                param.put("err_code",pay.get("err_code").toString());
                param.put("err_code_des",pay.get("err_code_des").toString());
                pay.put("payFailed",param);
            }
        }else {
            //通信失败返回信息
            Map<String,String> param = new HashedMap();
            param.put("appId",appid);
            param.put("package","prepay_id="+prepayId);
            param.put("nonceStr",nonceStr);
            param.put("signType","MD5");
            param.put("timeStamp",getTimeStamp());
            param = WeiXinPayUtils.getMapAfterUnifiedorder(param,wxWechatDO.getAppKey());
            pay.put("jsapi",param);
            param.put("return_code",pay.get("return_code").toString());
            param.put("return_msg",pay.get("return_msg").toString());
            pay.put("connectFailed",param);
        }
        return pay;
    }