Explorar o código

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

# Conflicts:
#	svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/wechat/WechatMenuController.java
wangzhinan %!s(int64=4) %!d(string=hai) anos
pai
achega
2a904ddc5a

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -1076,6 +1076,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                openId = patientWechatDo.getOpenid();
                openId = patientWechatDo.getOpenid();
            }
            }
            String price = businessOrderDO.getPayPrice().toString();
            String price = businessOrderDO.getPayPrice().toString();
            businessOrderDO.setOrderNo("HLWYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100);
            String notifyUrl = hospitalSysDictDO.getDictCode();
            String notifyUrl = hospitalSysDictDO.getDictCode();
            response = ylzPayService.rechargeConsume("123456",businessOrderDO.getPatientName(),"01",ssc,"01",idcard,depositType,
            response = ylzPayService.rechargeConsume("123456",businessOrderDO.getPatientName(),"01",ssc,"01",idcard,depositType,
                    price,price,businessOrderDO.getOrderNo(),idcard,"0",businessOrderDO.getPatientName(),businessOrderDO.getRematk(),openId,notifyUrl,notifyUrl,null);
                    price,price,businessOrderDO.getOrderNo(),idcard,"0",businessOrderDO.getPatientName(),businessOrderDO.getRematk(),openId,notifyUrl,notifyUrl,null);
@ -1553,6 +1554,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
            }
            }
            businessOrderDO.setPayType(4);
            businessOrderDO.setPayType(4);
            businessOrderDO.setOrderNo("HLWYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100);
            businessOrderDao.save(businessOrderDO);
            businessOrderDao.save(businessOrderDO);
            List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
            List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
            if (patientWechatDos!=null&&patientWechatDos.size()!=0){
            if (patientWechatDos!=null&&patientWechatDos.size()!=0){

+ 26 - 0
business/sms-service/src/main/java/com/yihu/jw/sms/dao/WlyyHospitalSysDictDao.java

@ -0,0 +1,26 @@
package com.yihu.jw.sms.dao;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Trick on 2019/6/17.
 */
public interface WlyyHospitalSysDictDao extends PagingAndSortingRepository<WlyyHospitalSysDictDO, String>, JpaSpecificationExecutor<WlyyHospitalSysDictDO> {
    WlyyHospitalSysDictDO findByHospitalAndDictCode(String hospital, String dictCode);
    List<WlyyHospitalSysDictDO> findByHospitalAndDictNameOrderBySortAsc(String hospital, String dictName);
    WlyyHospitalSysDictDO findById(String id);
    List<WlyyHospitalSysDictDO> findByDictName(String dictName);
    @Query("from WlyyHospitalSysDictDO where 1=1")
    List<WlyyHospitalSysDictDO> findAlldict();
    @Query("from WlyyHospitalSysDictDO where dictCode = ?1")
    List<WlyyHospitalSysDictDO> findByDictCode(String dictCode);
}

+ 115 - 0
business/sms-service/src/main/java/com/yihu/jw/sms/service/ZBSmsService.java

@ -0,0 +1,115 @@
package com.yihu.jw.sms.service;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.sms.dao.WlyyHospitalSysDictDao;
import com.yihu.jw.util.http.HttpClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 福州总部的短信接口
 */
@Service
public class ZBSmsService {
    private Logger logger= LoggerFactory.getLogger(ZBSmsService.class);
    private String clientId;
    private String resturl;
    private String smsAPI;
    private String smsHandlerId;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private WlyyHospitalSysDictDao sysDictDao;
    private String appId = "9000424";
//    private String secret = "Q1ZCTGKMCTDYHGGQP9S4VJO6KUQRTIA39RKHJ57IIQ8";//测试参数
    private String secret = "YM7WCB2LX32MCKFHWB64V4ARBGMQ36VOO8XOZ2TPP1B";//正式参数
    private String prixUrl = "https://api.yihu.com/OpenPlatform/cgiBin/1.0/";//正式参数
//    private String prixUrl = "https://ssotest.yihu.cn/OpenPlatform/cgiBin/1.0/";//测试参数
    /**
     * 初始化总部接口参数
     */
    private void init(){
        List<WlyyHospitalSysDictDO> dictDOList = sysDictDao.findByDictName("zbSms");
        for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:dictDOList){
            if (wlyyHospitalSysDictDO.getDictCode().equalsIgnoreCase("clientId")){
                clientId=wlyyHospitalSysDictDO.getDictValue();
            }else if (wlyyHospitalSysDictDO.getDictCode().equalsIgnoreCase("resturl")){
                resturl=wlyyHospitalSysDictDO.getDictValue();
            }else if (wlyyHospitalSysDictDO.getDictCode().equalsIgnoreCase("smsAPI")){
                smsAPI=wlyyHospitalSysDictDO.getDictValue();
            }else if (wlyyHospitalSysDictDO.getDictCode().equalsIgnoreCase("smsHandlerId")){
                smsHandlerId=wlyyHospitalSysDictDO.getDictValue();
            }else if (wlyyHospitalSysDictDO.getDictCode().equalsIgnoreCase("appId")){
                appId=wlyyHospitalSysDictDO.getDictValue();
            }else if (wlyyHospitalSysDictDO.getDictCode().equalsIgnoreCase("secret")){
                secret=wlyyHospitalSysDictDO.getDictValue();
            }else if (wlyyHospitalSysDictDO.getDictCode().equalsIgnoreCase("prixUrl")){
                prixUrl=wlyyHospitalSysDictDO.getDictValue();
            }
        }
    }
    /**
     * 发送短信
     * @return
     */
    public Integer sendMessage(String mobile,String content) throws Exception {
        try{
            //初始化参数
            init();
            String apiUrl = prixUrl+"MsgGW/Sms/send";
            String timestamp =
                    Long.toString(System.currentTimeMillis());//timestamp必须与服务器时间相差在5分钟以内,否则调用将失败;
            Map<String, String> paramMap = new HashMap<>();
            paramMap.put("provinceCode", "350000");
            paramMap.put("cityCode", "350200");
            paramMap.put("mobile", mobile);
            paramMap.put("content", content);
            paramMap.put("handlerId", smsHandlerId);
            paramMap.put("timestamp", timestamp);
            StringBuilder stringBuilder = new StringBuilder();
            // 对参数名进行字典排序
            String[] keyArray = paramMap.keySet().toArray(new String[0]);
            Arrays.sort(keyArray);
            // 拼接有序的参数名-值串
            stringBuilder.append(appId);
            for (String key : keyArray)
            {
                stringBuilder.append(key).append(paramMap.get(key));
            }
            String codes = stringBuilder.append(secret).toString();
            String sign = org.apache.commons.codec.digest.DigestUtils.shaHex(codes).toUpperCase();
            // 添加签名,并发送请求
            paramMap.put("appId", appId);
            paramMap.put("sign", sign);
            String rep = httpClientUtil.httpPost(apiUrl, paramMap);
            logger.info("总部短信接口请求返回值:"+rep);
            if (!StringUtils.isEmpty(rep)){
                com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(rep);
                if ( jsonObject.getInteger("Code")==10000){
                    return 0;
                }
            }
            return 1;
        }catch (Exception e){
            logger.error(e.getMessage());
        }
        return null;
    }
}

+ 65 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -30,6 +30,7 @@ import com.yihu.jw.security.utils.DateUtil;
import com.yihu.jw.security.utils.IdCardUtil;
import com.yihu.jw.security.utils.IdCardUtil;
import com.yihu.jw.security.utils.SerializeUtil;
import com.yihu.jw.security.utils.SerializeUtil;
import com.yihu.jw.sms.service.YkyySMSService;
import com.yihu.jw.sms.service.YkyySMSService;
import com.yihu.jw.sms.service.ZBSmsService;
import com.yihu.jw.sms.service.ZhongShanSMSService;
import com.yihu.jw.sms.service.ZhongShanSMSService;
import com.yihu.jw.sms.util.ykyy.vo.ResultMsg;
import com.yihu.jw.sms.util.ykyy.vo.ResultMsg;
import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpResponse;
@ -130,6 +131,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    @Autowired
    @Autowired
    private ZhongShanSMSService zhongShanSMSService;
    private ZhongShanSMSService zhongShanSMSService;
    @Autowired
    @Autowired
    private ZBSmsService zbSmsService;
    @Autowired
    private OauthCaConfigSerivce oauthCaConfigSerivce;
    private OauthCaConfigSerivce oauthCaConfigSerivce;
    @Autowired
    @Autowired
    private OauthWjwConfigService oauthWjwConfigService;
    private OauthWjwConfigService oauthWjwConfigService;
@ -606,6 +609,66 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        throw new IllegalStateException("验证码发送失败!");
        throw new IllegalStateException("验证码发送失败!");
    }
    }
    /**
     * 福州健康之路短信接口
     * @param parameters
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/oauth/sendZBCaptcha", method = RequestMethod.GET)
    public ResponseEntity<Oauth2Envelop<Captcha>> sendZBCaptcha(@RequestParam Map<String, String> parameters) throws Exception {
        String client_id = parameters.get("client_id");
        String username = parameters.get("username");
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
        }
        if (StringUtils.isEmpty(username)) {
            throw new InvalidRequestException("username");
        }
        if (username.length()>12){
            throw new InvalidRequestException("请输入正确的手机号!");
        }
        //验证请求间隔超时,防止频繁获取验证码
        if (!wlyyRedisVerifyCodeService.isIntervalTimeout(client_id, username)) {
            throw new IllegalAccessException("SMS request frequency is too fast");
        }
        WlyyHospitalSysDictDO wlyyHospitalSysDictDO = wlyyhospitalSysdictDao.findDictById("isNeedSMS");
        if (wlyyHospitalSysDictDO!=null&&!StringUtils.isEmpty(wlyyHospitalSysDictDO.getDictValue())){
            String captcha = wlyyHospitalSysDictDO.getDictValue();
            Captcha _captcha = new Captcha();
            _captcha.setCode(captcha);
            _captcha.setExpiresIn(300);
            wlyyRedisVerifyCodeService.store(client_id, username, captcha, 300);
            Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("success", 200);
            HttpHeaders headers = new HttpHeaders();
            headers.set("Cache-Control", "no-store");
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        }else {
            //发送短信获取验证码
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            int result =  zbSmsService.sendMessage(username,"您好,你的手机登录短信验证码是:"+captcha+",5分钟内有效。");
            if (0 == result) {
                Captcha _captcha = new Captcha();
                _captcha.setCode(captcha);
                _captcha.setExpiresIn(300);
                wlyyRedisVerifyCodeService.store(client_id, username, captcha, 300);
                Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200, null);
                HttpHeaders headers = new HttpHeaders();
                headers.set("Cache-Control", "no-store");
                headers.set("Pragma", "no-cache");
                return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
            }
        }
        throw new IllegalStateException("验证码发送失败!");
    }
    @RequestMapping(value = "/oauth/sendCaptcha", method = RequestMethod.GET)
    @RequestMapping(value = "/oauth/sendCaptcha", method = RequestMethod.GET)
    public ResponseEntity<Oauth2Envelop<Captcha>> sendCaptcha(@RequestParam Map<String, String> parameters) throws Exception {
    public ResponseEntity<Oauth2Envelop<Captcha>> sendCaptcha(@RequestParam Map<String, String> parameters) throws Exception {
        String wxId = parameters.get("wxId");
        String wxId = parameters.get("wxId");
@ -615,6 +678,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
           return sendZSCaptcha(parameters);
           return sendZSCaptcha(parameters);
        }else if ("xm_xzzx_wx".equals(wxId)){
        }else if ("xm_xzzx_wx".equals(wxId)){
            return sendXZCaptcha(parameters);
            return sendXZCaptcha(parameters);
        }else if ("sd_tnzyy_wx".equals(wxId)){
            return sendZBCaptcha(parameters);
        }
        }
        throw new IllegalStateException("验证码发送失败");
        throw new IllegalStateException("验证码发送失败");
    }
    }