Pārlūkot izejas kodu

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

# Conflicts:
#	business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
wangzhinan 4 gadi atpakaļ
vecāks
revīzija
5246dbe871

+ 44 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/ykyy/service/YkyyService.java

@ -523,6 +523,50 @@ public class YkyyService {
    }
    /**
     * 推送眼科通居民消息
     * @param patientId 眼科通id对应patient表里的yktId
     * @param attach
     * @param pushcontent
     * @return
     */
    public String pushNotificationToYktPatient(String patientId,String attach,String pushcontent){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("patientId",patientId);
        jsonObject.put("attach",attach);
        jsonObject.put("pushcontent",pushcontent);
        String url = "http://www.yanketong.com:90/api/share/PushNotificationToPatient";
        response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
        logger.info("推送眼科通消息:"+response);
        return response;
    }
    /**
     * 眼科通支付
     *
     * @param body
     * @param out_trade_no
     * @param total_fee
     * @param spbill_create_ip
     * @param notify_url
     * @return
     */
    public String getPayCDATA4Jkzl(String body,String out_trade_no,String total_fee,String spbill_create_ip,String notify_url){
        String response="";
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("body",body);
        jsonObject.put("out_trade_no",out_trade_no);
        jsonObject.put("total_fee",total_fee);
        jsonObject.put("spbill_create_ip",spbill_create_ip);
        jsonObject.put("notify_url",notify_url);
        String url = "http://www.yanketong.com/api/Doctor/GetPayCDATA4Jkzl";
        response = httpClientUtil.sendPost(url,jsonObject.toJSONString());
        logger.info("眼科通支付:"+response);
        return response;
    }

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

@ -897,12 +897,12 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
    /**
     *
     * @param traceNo
     * @param orderNo
     * @return
     */
    public BusinessOrderDO updatePayStatus(String traceNo) throws Exception {
        logger.info("入参:"+traceNo);
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(traceNo);
    public BusinessOrderDO updatePayStatus(String orderNo) throws Exception {
        logger.info("入参:"+orderNo);
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderNo);
        if (businessOrderDO==null){
            throw new Exception("查不到订单!");
        }
@ -949,4 +949,60 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        return object;
    }
    /**
     * 预交金支付
     * @param code
     * @param depositType
     * @param wechatId
     * @return
     * @throws Exception
     */
    public String ylzRechargeJson(String code,String depositType,String wechatId,String cardType,String cardNo) throws Exception {
        String response = null;
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        if(wxWechatDO==null){
            throw new Exception("can't find wechat:the wxId is "+wechatId);
        }
        WlyyHospitalSysDictDO hospitalSysDictDO =hospitalSysDictDao.findById("YLZ_NOTIFY_URL");
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(code);
        if (businessOrderDO!=null){
            BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
            String idcard = "";
            String ssc = "";
            if (patientDO!=null){
                idcard = patientDO.getIdcard();
            }
            String openId = "";
            List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
            if (patientWechatDos!=null&&patientWechatDos.size()!=0){
                BasePatientWechatDo patientWechatDo = patientWechatDos.get(0);
                openId = patientWechatDo.getOpenid();
            }
            String price = businessOrderDO.getPayPrice().toString();
            String notifyUrl = hospitalSysDictDO.getDictCode();
            response = ylzPayService.recharge("123456",businessOrderDO.getPatientName(),cardType,"01",cardNo,idcard,depositType,price,businessOrderDO.getOrderNo(),openId,patientDO.getName(),notifyUrl);
            if (depositType.equalsIgnoreCase("WX_QR")){
                JSONObject object = JSONObject.parseObject(response);
                if (object!=null){
                    JSONObject jsonObject = object.getJSONObject("param");
                    if (object.getString("respCode").equalsIgnoreCase("000000")){
                        InputStream qrcode = QrcodeUtil.createQrcode(jsonObject.getString("qrcode"),300,"jpg");
                        ByteToInputStream byteToInputStream = new ByteToInputStream();
                        String QRCodeImg = byteToInputStream.getBase64FromInputStream(qrcode);
                        jsonObject.put("qrcodeUrl","data:image/png;base64,"+ QRCodeImg);
                        String traceNo = jsonObject.getString("traceNo");
                        businessOrderDO.setTraceNo(traceNo);
                        businessOrderDao.save(businessOrderDO);
                    }
                    response = object.toJSONString();
                }
            }
        }else {
            return "找不到订单!";
        }
        return response;
    }
}

+ 195 - 0
business/base-service/src/main/java/com/yihu/jw/order/pay/ylz/YlzPayService.java

@ -11,6 +11,7 @@ import com.ylzinfo.onepay.sdk.HisOnepayClient;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.domain.ext.*;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -346,4 +347,198 @@ public class YlzPayService {
        logService.saveHttpLog(isSuccess, "hop.mmpay.sicard.url", "互联网医院支付地址", "POST", null,JSON.toJSONString(jsonObject), object, error,logService.pushType);
        return object;
    }
//============================================预交金充值 start======================================================
    /**
     * 预交金充值支付
     *
     * @param operatorId 操作员编码
     * @param operatorName  操作员姓名
     * @param cardType 卡类型
     * @param accountType 账户类型
     * @param cardNo 卡号
     * @param idNo 身份证号
     * @param depositType 充值方式 WX_PUB
     * @param amount 充值金额
     * @param outChargeNo 商户充值业务流水号
     * @param userName 用户姓名
     * @param openId 微信公共号支付需入参openId
     * @return
     */
    public String recharge(String operatorId,String operatorName,String cardType,String accountType,String cardNo,String idNo,String depositType,String amount,String outChargeNo,String openId,String userName,String notifyUrl){
        Boolean isSuccess = true;
        String jsonObject = null;
        RechargeParams param = new RechargeParams();
        String error = null;
        try {
            OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("ylz_pay_config");
            if(oauthYlzConfigDO==null){
                return "未找到支付配置文件";
            }
            String appId = oauthYlzConfigDO.getAppId();
            String appSecret = oauthYlzConfigDO.getAppKey();
            String onepayUrl = oauthYlzConfigDO.getUrl();
            String signType=oauthYlzConfigDO.getSignType();
            String encryptType = oauthYlzConfigDO.getEncType();
            HisOnepayClient onepayClient = new HisOnepayClient(onepayUrl, appId, appSecret, signType, encryptType);
            param.setOperatorId(operatorId);
            param.setOperatorName(operatorName);
            param.setCardType(cardType);
            param.setAccountType(accountType);
            param.setCardNo(cardNo);
            param.setIdNo(idNo);
            param.setDepositType(depositType);
            param.setAmount(amount);
            param.setOutChargeNo(outChargeNo);
            param.setUserName(userName);
            Map<String, String> extra = new HashedMap();
            if(StringUtils.isNoneBlank(openId)){
                extra.put("openId",openId);
            }
		/*	String value = systemDictDao.findByDictNameAndCode("RETURN_URL","RETURN_URL");
			extra.put("returnUrl",value);*/
            extra.put("notifyUrl", notifyUrl);
            param.setExtra(extra);
            ResponseParams<RechargeResult> respnse = onepayClient.recharge(param);
            if (respnse.getRespCode().equals("000000")){
                jsonObject = JSON.toJSONString(respnse);
            }else {
                isSuccess = false;
                jsonObject = JSON.toJSONString(respnse);
                error = "请求失败,返回结果:" + respnse.getRespCode() + "," + respnse.getRespMsg();
            }
            if (respnse!=null){
            }
        } catch (Exception e) {
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            error = sw.toString();
        }
        logService.saveHttpLog(isSuccess, "hop.trade.recharge", "互联网预交金充值", "POST", null,JSON.toJSONString(param), jsonObject, error,logService.shoppatType);
        return jsonObject;
    }
    /**
     *
     * 预交金退款
     *
     * @param operatorId 操作者id
     * @param operatorName 操作者名字
     * @param cardType 卡类型
     * @param accountType 账号类型
     * @param cardNo 卡号
     * @param idNo 身份证号
     * @param amount 退款金额
     * @param outChargeNo 原充值订单号
     * @param userName 用户名字
     * @param withdrawMode 退款方式         0 现金退回1 原路退回2 银企转账3 医保自费退回
     * @param traceNo 平台交易跟踪号
     * @param outRefundNo 退款订单号
     * @return
     */
    public String refund(String operatorId,String operatorName,String cardType,String accountType,String cardNo,String idNo,String amount,String outChargeNo,String userName,String withdrawMode,String traceNo,String outRefundNo,String hisCustId){
        Boolean isSuccess = true;
        String jsonObject = null;
        RefundParams param = new RefundParams();
        String error = null;
        try {
            OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("ylz_pay_config");
            if(oauthYlzConfigDO==null){
                return "未找到支付配置文件";
            }
            String appId = oauthYlzConfigDO.getAppId();
            String appSecret = oauthYlzConfigDO.getAppKey();
            String onepayUrl = oauthYlzConfigDO.getUrl();
            String signType=oauthYlzConfigDO.getSignType();
            String encryptType = oauthYlzConfigDO.getEncType();
            HisOnepayClient onepayClient = new HisOnepayClient(onepayUrl, appId, appSecret, signType, encryptType);
            param.setOperatorId(operatorId);
            param.setOperatorName(operatorName);
            param.setOutChargeNo(outChargeNo);
            param.setCardType(cardType);
            param.setCardNo(cardNo);
            param.setAccountType(accountType);
            param.setAmount(amount);
            param.setWithdrawMode(withdrawMode);
            param.setOutChargeNo(outChargeNo);
            param.setTraceNo(traceNo);
            param.setOutRefundNo(outRefundNo);
            param.setHisCustId(hisCustId);
            param.setIdNo(idNo);
            param.setUserName(userName);
            ResponseParams<RefundResult> respnse = onepayClient.refund(param);
            if (respnse.getRespCode().equals("000000")){
                jsonObject = JSON.toJSONString(respnse);
            }else {
                jsonObject = JSON.toJSONString(respnse);
                isSuccess = false;
                error = "请求失败,返回结果:" + respnse.getRespCode() + "," + respnse.getRespMsg();
            }
        } catch (Exception e) {
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            error = sw.toString();
        }
        logService.saveHttpLog(isSuccess, "hop.trade.refund", "互联网预交金退款", "POST", null,JSON.toJSONString(param), jsonObject, error, logService.shoppatType);
        return jsonObject;
    }
    /**
     * 预交金查询余额
     *
     * @param operatorId
     * @param operatorName
     * @param termNo
     * @param tradeType
     * @param outTradeNo
     * @param traceNo
     * @return
     */
    public String ylzTradeQuery(String operatorId,String operatorName,String termNo,String tradeType,String outTradeNo,String traceNo){
        Boolean isSuccess = true;
        String jsonObject = null;
        TradeQueryParams param = new TradeQueryParams();
        String error = null;
        try {
            OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("ylz_pay_config");
            if(oauthYlzConfigDO==null){
                return "未找到支付配置文件";
            }
            String appId = oauthYlzConfigDO.getAppId();
            String appSecret = oauthYlzConfigDO.getAppKey();
            String onepayUrl = oauthYlzConfigDO.getUrl();
            String signType=oauthYlzConfigDO.getSignType();
            String encryptType = oauthYlzConfigDO.getEncType();
            HisOnepayClient onepayClient = new HisOnepayClient(onepayUrl, appId, appSecret, signType, encryptType);
            param.setOperatorId(operatorId);
            param.setOperatorName(operatorName);
            param.setTradeType(tradeType);
            param.setOutTradeNo(outTradeNo);
            param.setTraceNo(traceNo);
            ResponseParams<TradeQueryResult> respnse = onepayClient.tradeQuery(param);
            if (respnse.getRespCode().equals("000000")){
                jsonObject = JSON.toJSONString(respnse);
            }else {
                isSuccess = false;
                jsonObject = JSON.toJSONString(respnse);
                error = "请求失败,返回结果:" + respnse.getRespCode() + "," + respnse.getRespMsg();
            }
        } catch (Exception e) {
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            error = sw.toString();
        }
        logService.saveHttpLog(isSuccess, "hop.trade.query", "互联网预交金查询", "POST", null,JSON.toJSONString(param), jsonObject, error,logService.shoppatType);
        return jsonObject;
    }
//============================================预交金充值 end======================================================
}

+ 2 - 2
server/svr-authentication/pom.xml

@ -93,7 +93,7 @@
        <!-- Redis  -->
        <!-- JdbcTemplate-->
        <dependency>
      <!--  <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
@ -105,7 +105,7 @@
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-dbcp2</artifactId>
        </dependency>
        </dependency>-->
        <!-- JdbcTemplate-->
        <dependency>

+ 109 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java

@ -20,6 +20,7 @@ import com.yihu.jw.hospital.service.consult.SysDictService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.pay.utils.PayLogService;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.web.Envelop;
@ -31,9 +32,12 @@ import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.util.common.XMLUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.service.WechatInfoService;
import com.ylzinfo.onepay.sdk.OnepayClient;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.domain.WebHook;
import com.ylzinfo.onepay.sdk.exception.PayException;
import com.ylzinfo.onepay.sdk.utils.SecurityUtil;
import com.ylzinfo.onepay.sdk.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -100,6 +104,8 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private PayLogService logService;
@ -453,4 +459,107 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
        return appId;
    }
    @RequestMapping(value = "/receiveNotify")
    @ApiOperation("支付回调")
    public String receiveNotify(HttpServletRequest request, HttpServletResponse response) throws IOException, IOException {
        response.setContentType("text/html;charset=utf-8");
        OauthYlzConfigDO oauthYlzConfigDO = oauthYlzConfigDao.findById("ylz_pay_config");
        if(oauthYlzConfigDO==null){
            return "未找到支付配置文件";
        }
        String appId = oauthYlzConfigDO.getAppId();
        String appSecret = oauthYlzConfigDO.getAppKey();
        InputStream inputStream = request.getInputStream();
        logger.info("转换前的回调参数:"+inputStream);
        String params = StreamUtils.copyToString(inputStream, Charset.forName("UTF-8"));
        // 回调参数:{"appId":"1A3VL0KVK0000B020A0A0000CC3F48AD","encryptData":"qPebDp0xBA/0qdr2lDvY2zBp2kB5em5GOr29y7o2WnHvm0tswnbyxDjCIUGI74yNGWFyCeJfeU5A\nK+Zr/yPs6nnsyzIFTSSljrKZCkzgbj3mjMax/3NzByfvE7R2MO+fljJUYqE93AvuRDc1wcdSUuKK\nmcryOvaU","encryptType":"DES","sign":"24635D0085CC72447657BD0713F0FB7C","signType":"MD5","timestamp":"20161018171127869","transType":"charge.success"}
        logger.info("回调参数:{}", params);
        if (StringUtil.isEmpty(params)) {
            response.getWriter().write("empty");
            return null;
        }
        // 参数转换
        ResponseParams<?> res = JSON.parseObject(params, ResponseParams.class);
        // 解密报文
        System.out.println("解密前报文:" + JSONObject.toJSONString(res.getEncryptData()));
        String decryptData;
        ResponseParams<WebHook> responseParams = new ResponseParams<WebHook>();
        WebHook webhook = new WebHook();
        try {
            decryptData = SecurityUtil.decrypt(res.getEncryptData(), res.getEncryptType(), appSecret, appId);
            System.out.println("解密后报文:" + decryptData);
            webhook = JSON.parseObject(decryptData, WebHook.class);
            // 参数转换
            responseParams.setAppId(appId);
            responseParams.setSign(res.getSign());
            responseParams.setSignType(res.getSignType());
            responseParams.setEncryptType(res.getEncryptType());
            responseParams.setTimestamp(res.getTimestamp());
            responseParams.setRespCode(res.getRespCode());
            responseParams.setRespMsg(res.getRespMsg());
            responseParams.setPageParams(res.getPageParams());
            responseParams.setTransType(res.getTransType());
            // 解密后设置param
            responseParams.setParam(webhook);
        } catch (Exception e1) {
            logger.error("解密回调报文错误");
            response.getWriter().write("ERROR:" + e1.getMessage());
        }
        OnepayClient payService = new OnepayClient("", appId, appSecret, res.getSignType(), res.getEncryptType());
        boolean isSuccess = false;
        String jsonObject = null;
        String error = null;
        try {
            // boolean isVerify = payService.verifyResponseSign(responseParams);
            boolean isVerify = payService.verifyResponseSign(responseParams);
            //boolean isVerify = true;
            isSuccess = true;
            jsonObject = isVerify+"";
            logger.info("验签结果:{}", isVerify);
            if (isVerify) {
                if (responseParams.getTransType().equalsIgnoreCase("charge.success")){
                    if (webhook!=null){
                        String outChargeNo = webhook.getOutChargeNo();
                        //im处方发消息
                        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(outChargeNo);
                        if (businessOrderDO.getStatus()!=1){
                            if (businessOrderDO!=null&&businessOrderDO.getOrderCategory().equalsIgnoreCase("4")){
                                WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDao.findOne(businessOrderDO.getRelationCode());
                                JSONObject object = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDO);
                                logger.info("wlyyPrescriptionDO参数入参"+object.toJSONString());
                                WlyyPrescriptionVO prescriptionVO = JSONObject.toJavaObject(object,WlyyPrescriptionVO.class);
                                List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
                                List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOS = new ArrayList<>();
                                for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:wlyyPrescriptionInfoDOS){
                                    JSONObject jsonObject1 = (JSONObject) JSONObject.toJSON(wlyyPrescriptionInfoDO);
                                    logger.info("wlyyPrescriptionInfoDO参数入参"+jsonObject1.toJSONString());
                                    WlyyPrescriptionInfoVO prescriptionInfoVO = JSONObject.toJavaObject(jsonObject1,WlyyPrescriptionInfoVO.class);
                                    wlyyPrescriptionInfoVOS.add(prescriptionInfoVO);
                                }
                                prescriptionVO.setInfoVOs(wlyyPrescriptionInfoVOS);
                                prescriptionVO.setPayStatus(1);
                                imService.pushPrescriptionImMessage(prescriptionVO);
                            }
                        }
                        businessOrderService.updatePayStatus(outChargeNo);
                    }
                }
                response.getWriter().write("SUCCESS");
            } else {
                response.getWriter().write("FAIL");
            }
        } catch (Exception e) {
            error = e.getMessage();
            response.getWriter().write(e.getMessage());
        }
        logService.saveHttpLog(isSuccess, "hop.trade.verifyResponseSign", "支付回调", "POST", null,JSON.toJSONString(responseParams), jsonObject, error,logService.shoppatType);
        return appId;
    }
}