浏览代码

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/entrance/YkyyEntranceService.java
wangzhinan 5 年之前
父节点
当前提交
9a3b0b258b
共有 19 个文件被更改,包括 1041 次插入21 次删除
  1. 17 6
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  2. 15 1
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/YkyyPrescriptionService.java
  3. 24 2
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java
  4. 1 1
      business/base-service/src/main/java/com/yihu/jw/hospital/ykyy/service/YkyyService.java
  5. 161 4
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  6. 1 1
      business/base-service/src/main/java/com/yihu/jw/order/dao/BusinessOrderRefundDao.java
  7. 17 0
      business/base-service/src/main/java/com/yihu/jw/order/dao/PayLogDao.java
  8. 52 0
      business/base-service/src/main/java/com/yihu/jw/order/pay/utils/PayLogService.java
  9. 228 0
      business/base-service/src/main/java/com/yihu/jw/order/pay/ylz/YlzPayService.java
  10. 3 3
      common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java
  11. 2 2
      common/common-entity/src/main/java/com/yihu/jw/entity/order/BusinessOrderDO.java
  12. 182 0
      common/common-entity/src/main/java/com/yihu/jw/entity/order/PayLog.java
  13. 9 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  14. 11 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionVO.java
  15. 3 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java
  16. 62 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/patient/PatientNoLoginEndPoint.java
  17. 77 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java
  18. 9 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/YkyyPrescriptionEndpoint.java
  19. 167 0
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/ylz/YlzNotifyController.java

+ 17 - 6
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -634,6 +634,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        WlyyOutpatientDO outpatient = outpatientDao.save(outpatientDO);
        Double price = 0.01;
        businessOrderService.recharge(outpatient.getId(),"复诊-诊查费","2","复诊-诊查费",patientDO.getId(),patientDO.getName(),outpatient.getDoctor(),price);
        WlyyPatientRegisterTimeDO registerTimeDO = null;
        try {
@ -1655,7 +1659,6 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
    public JSONArray getICD10(String pyKey) throws Exception {
        return entranceService.MS25001(pyKey, demoFlag);
    }
    /**
     * 获取药品
     *
@ -1929,22 +1932,30 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
            if (wechatId.equalsIgnoreCase("xm_ykyy_wx")){
                outpatientDO.setStatus("2");
                outpatientDao.save(outpatientDO);
                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                BusinessOrderDO businessOrderDO1 = businessOrderDao.selectByRelationCode(prescription.getId());
                //先下单
                businessOrderService.savePrescriptionOrder(prescription.getId());
                //同步his
                ykyyEntranceService.findByRealOrder(prescription.getId());
                List<WlyyPrescriptionDO> prescriptionDOList = prescriptionDao.findById(prescription.getId());
                businessOrderService.savePrescriptionOrder(prescription.getId());
                if(prescriptionDOList!=null&&prescriptionDOList.size()!=0){
                    WlyyPrescriptionDO wlyyPrescriptionDO = prescriptionDOList.get(0);
                    ykyyService.updateDrugorderInfo(businessOrderDO.getOrderNo(),businessOrderDO1.getYkOrderId(),wlyyPrescriptionDO.getRealOrder());
                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(outpatientDO.getId());
                    logger.info("cfsb",wlyyPrescriptionDO.getRealOrder());
                    ykyyService.updateDrugorderInfo(businessOrderDO.getOrderNo(),wlyyPrescriptionDO.getOrderId(),wlyyPrescriptionDO.getRealOrder());
                }
                result.put("code", 1);
                result.put("mes", "诊断完成");
                return result;
            }else{
            }else if (wechatId.equalsIgnoreCase("xm_zsyy_wx")){
                Double price = 0.01;
                businessOrderService.recharge(prescription.getId(),"处方收费","4","处方收费",prescription.getPatientCode(),prescription.getPatientName(),prescription.getDoctor(),price);
                //上传his开方
                return sendHisDiagnosis(jsonData, outpatientDO, prescription);
            }else {
                result.put("code", 1);
                result.put("mes", "诊断完成");
                return result;
            }
        } else {

+ 15 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/YkyyPrescriptionService.java

@ -427,7 +427,7 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
    public JSONArray synYkICD10() throws Exception {
        JSONArray jsonArray = ykyyEntranceService.findIcd10();
        JSONArray jsonArray = ykyyEntranceService.synYkICD10();
        return jsonArray;
    }
@ -461,4 +461,18 @@ public class YkyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
        return map;
    }
    /**
     * 获取诊断
     *
     * @param pyKey
     * @return
     * @throws Exception
     */
    public JSONArray getICD10(String pyKey) throws Exception {
        JSONArray array = ykyyEntranceService.findIcd10(pyKey);
        return array;
    }
}

+ 24 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/YkyyEntranceService.java

@ -1006,7 +1006,7 @@ public class YkyyEntranceService {
    }
    public JSONArray findIcd10() throws Exception {
    public JSONArray synYkICD10() throws Exception {
        String sql = "select i.code as \"code\",i.name as \"name\",i.disea_reason as \"disea_reason\",i.death_reason as \"death_reason\",i.py_code as \"py_code\",i.flag as \"flag\",i.add_code as \"add_code\",i.emr as \"emr\" from v_hlw_icd10 i";
        JSONArray array = new JSONArray();
        Map<String,Object> params = new HashedMap();
@ -1025,6 +1025,7 @@ public class YkyyEntranceService {
                DictIcd10DO dictIcd10DO = new DictIcd10DO();
                dictIcd10DO.setCode(object.getString("code"));
                dictIcd10DO.setName(object.getString("name"));
                dictIcd10DO.setDescription(object.getString("py_code"));
                ykDictIcd10Dao.save(dictIcd10DO);
            }
        }
@ -1032,6 +1033,27 @@ public class YkyyEntranceService {
    }
    public JSONArray findIcd10(String pyCode) throws Exception {
        String sql = "select i.code as \"code\",i.name as \"name\",i.disea_reason as \"disea_reason\",i.death_reason as \"death_reason\",i.py_code as \"py_code\",i.flag as \"flag\",i.add_code as \"add_code\",i.emr as \"emr\" from v_hlw_icd10 i";
        JSONArray array = new JSONArray();
        if (StringUtils.isNoneBlank(pyCode)){
            sql +="  where i.py_code like '%"+pyCode+"%'";
        }
        Map<String,Object> params = new HashedMap();
        params.put("sql",sql);
        logger.info("ICD10:"+sql);
        HttpResponse response = HttpUtils.doGet(url,params);
        String content = response.getContent();
        logger.info("response:"+content);
        JSONObject rs = JSON.parseObject(content);
        Integer status = rs.getInteger("status");
        if (status==200){
            array = rs.getJSONArray("detailModelList");
        }
        return array;
    }
    public String findByRealOrder(String code) throws Exception {
@ -1356,7 +1378,7 @@ public class YkyyEntranceService {
                DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
                hlwCf01DO.setYSDM(doctorMappingDO.getMappingCode());
                hlwCf01DO.setJZKH(wlyyPrescriptionVO.getSsc());
                hlwCf01DO.setGUID(getCode());
                hlwCf01DO.setGUID(wlyyPrescriptionVO.getOrderId());
                hlwCf01DO.setSJLY(1);
                if (StringUtils.isNoneBlank(wlyyPrescriptionVO.getAdmNo())){
                    hlwCf01DO.setJZXH(Integer.parseInt(wlyyPrescriptionVO.getAdmNo()));

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

@ -308,7 +308,7 @@ public class YkyyService {
     */
    public String updateDrugorderInfo(String orderNo,String drugorder,String cfsb){
        String response="";
        String url = yktUrl+"doc_jkzl/update_drugorder_infor?order_no="+orderNo+"&drugorder="+drugorder+"$cfsb="+cfsb;
        String url = yktUrl+"doc_jkzl/update_drugorder_infor?order_no="+orderNo+"&drugorder="+drugorder+"&cfsb="+cfsb;
        response = httpClientUtil.get(url,"GBK");
        logger.info("更新药品订单信息:"+response);
        return response;

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

@ -3,6 +3,8 @@ package com.yihu.jw.order;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import com.yihu.jw.entity.IntegerIdentityEntity;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
@ -26,14 +28,17 @@ import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
import com.yihu.jw.order.dao.ConsultOrderDao;
import com.yihu.jw.order.pay.wx.WeChatConfig;
import com.yihu.jw.order.pay.ylz.YlzPayService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.BeanUtils;
import com.yihu.jw.util.common.XMLUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.wechat.WeiXinPayUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.dao.WxPayLogDao;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -51,7 +56,7 @@ import java.util.*;
 * 业务订单
 */
@Service
public class BusinessOrderService {
public class BusinessOrderService extends BaseJpaService {
    private Logger logger = LoggerFactory.getLogger(BusinessOrderService.class);
@ -83,6 +88,8 @@ public class BusinessOrderService {
    private YkyyEntranceService ykyyEntranceService;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private YlzPayService ylzPayService;
@ -130,7 +137,8 @@ public class BusinessOrderService {
                businessOrderDO = businessOrderDao.save(businessOrderDO);
                businessOrderDOS.add(businessOrderDO);
                wlyyPrescriptionDO.setOrderNo(businessOrderDO.getOrderNo());
                prescriptionDao.save(wlyyPrescriptionDO);
                wlyyPrescriptionDO.setOrderId(getCode());
                wlyyPrescriptionDO = prescriptionDao.save(wlyyPrescriptionDO);
                JSONArray array = new JSONArray();
                List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(code);
                for (WlyyPrescriptionInfoDO prescriptionInfoDO:wlyyPrescriptionInfoDOS){
@ -259,7 +267,7 @@ public class BusinessOrderService {
        businessOrderDO.setStatus(0);
        businessOrderDO.setCreateTime(new Date());
        businessOrderDO.setUpdateTime(new Date());
        businessOrderDO.setOrderNo("VAS"+businessOrderDO.getOrderType()+System.currentTimeMillis());
        businessOrderDO.setOrderNo("HLWLYY"+businessOrderDO.getOrderType()+System.currentTimeMillis());
        businessOrderDO = businessOrderDao.save(businessOrderDO);
        List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
        String openId = "";
@ -457,7 +465,7 @@ public class BusinessOrderService {
        orderRefundDO.setRefundPrice(refundPrice);
        orderRefundDO.setAppId(wxWechatDO.getAppId());
        orderRefundDO.setMchId(wxWechatDO.getMchId());
        orderRefundDO.setOutRefundNo("VAS"+businessOrderDO.getOrderType()+System.currentTimeMillis());
        orderRefundDO.setOutRefundNo("HLWLYY"+businessOrderDO.getOrderType()+System.currentTimeMillis());
        orderRefundDO.setPatient(patient);
        orderRefundDO.setPatientName(patientDO.getName());
        orderRefundDO.setRefundDesc(description);
@ -665,4 +673,153 @@ public class BusinessOrderService {
    public void setPrescriptionDao(PrescriptionDao prescriptionDao) {
        this.prescriptionDao = prescriptionDao;
    }
    /**
     *
     * 中山医院统一支付
     *
     * @param relationCode
     * @param relationName
     * @param orderCategory 1专家咨询2复诊4处方
     * @param remark
     * @param patient
     * @param patientName
     * @param doctor
     * @return
     */
    public BusinessOrderDO recharge(String relationCode,String relationName,String orderCategory,String remark,String patient,String patientName,String doctor,Double payPrice){
        logger.info("参数========="+relationCode+"=="+orderCategory+"=="+patient+"=="+doctor+"==="+payPrice);
        BusinessOrderDO businessOrderDO = new BusinessOrderDO();
        if (orderCategory.equalsIgnoreCase("4")){
             businessOrderDO = businessOrderDao.selectByRelationCode(relationCode);
             if (businessOrderDO==null){
                 businessOrderDO = new BusinessOrderDO();
             }
        }
        businessOrderDO.setOrderNo("HLWLYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100);
        businessOrderDO.setCreateTime(new Date());
        businessOrderDO.setUpdateTime(new Date());
        businessOrderDO.setUploadStatus(0);
        businessOrderDO.setRelationCode(relationCode);
        businessOrderDO.setRelationName(relationName);
        businessOrderDO.setOrderCategory(orderCategory);
        businessOrderDO.setOrderType(1);
        businessOrderDO.setRematk(remark);
        businessOrderDO.setPatient(patient);
        businessOrderDO.setPatientName(patientName);
        businessOrderDO.setPayType(3);
        businessOrderDO.setStatus(0);
        businessOrderDO.setPayPrice(payPrice);
        businessOrderDO.setDoctor(doctor);
        businessOrderDO = businessOrderDao.save(businessOrderDO);
        return businessOrderDO;
    }
    /**
     *
     * @param code
     * @param depositType WX_MIN 微信小程序,WX_PUB 微信公众号 ,ALI_WAP 支付宝生活号 WX_QR pc扫码,ALI_QR支付宝扫码
     * @param wechatId
     * @return
     * @throws Exception
     */
    public String reChargeJSON(String code,String depositType,String wechatId) 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.rechargeConsume("123456",businessOrderDO.getPatientName(),"01",ssc,"01",idcard,depositType,
                    price,price,businessOrderDO.getOrderNo(),idcard,"1",businessOrderDO.getPatientName(),businessOrderDO.getRematk(),openId,notifyUrl,notifyUrl,null);
        }else {
            return "找不到订单!";
        }
        return response;
    }
    /**
     * 易联众退款
     * @param wechatId
     * @param patient
     * @param orderNo
     * @param refundPrice
     * @param description
     * @return
     * @throws Exception
     */
    public Map<String,Object> ylzOrderRefund(String wechatId,String patient,String orderNo,Double refundPrice,String description) throws Exception {
        WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
        if (wxWechatDO==null){
            throw new Exception("this wechatId is null");
        }
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderNo);
        if (businessOrderDO==null){
            throw new Exception("this orderId not exit");
        }
        BasePatientDO patientDO = patientDao.findById(patient);
        if (patientDO==null){
            throw new Exception("this patient not exit");
        }
        BusinessOrderRefundDO orderRefundDO = new BusinessOrderRefundDO();
        orderRefundDO = orderRefundDao.selectByOrderNo(orderNo);
        if (orderRefundDO==null){
            orderRefundDO = new BusinessOrderRefundDO();
        }
        orderRefundDO.setCreateTime(new Date());
        orderRefundDO.setUpdateTime(new Date());
        orderRefundDO.setStatus(1);
        orderRefundDO.setOrderNo(orderNo);
        orderRefundDO.setOrderPrice(businessOrderDO.getPayPrice());
        orderRefundDO.setRefundPrice(refundPrice);
        orderRefundDO.setAppId(wxWechatDO.getAppId());
        orderRefundDO.setMchId(wxWechatDO.getMchId());
        orderRefundDO.setOutRefundNo("HLWLYY"+businessOrderDO.getOrderCategory()+System.currentTimeMillis());
        orderRefundDO.setPatient(patient);
        orderRefundDO.setPatientName(patientDO.getName());
        orderRefundDO.setRefundDesc(description);
        orderRefundDO = orderRefundDao.save(orderRefundDO);
        String map = ylzPayService.refund(patientDO.getIdcard(),"123456",patientDO.getName(),"01",patientDO.getIdcard(),"01",orderRefundDO.getRefundPrice().toString(),"1",orderRefundDO.getOrderNo(),orderRefundDO.getOutRefundNo(),patientDO.getIdcard());
        JSONObject object = JSONObject.parseObject(map);
        if (object.get("respCode").toString().equalsIgnoreCase("000000")){
            orderRefundDO.setStatus(2);
            orderRefundDO.setRefundTime(new Date());
            orderRefundDao.save(orderRefundDO);
        }
        return object;
    }
    /**
     * 易联众查询交易订单
     *
     * @param orderNo
     * @param tradeType
     * @return
     */
    public JSONObject tradeQuery(String orderNo,String tradeType){
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderNo);
        String response = ylzPayService.tradeQuery(null,null,businessOrderDO.getPatientName(),orderNo,tradeType,businessOrderDO.getRematk());
        JSONObject object = JSONObject.parseObject(response);
        return object;
    }
}

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/order/dao/BusinessOrderRefundDao.java

@ -11,7 +11,7 @@ public interface BusinessOrderRefundDao extends PagingAndSortingRepository<Busin
    @Query("from BusinessOrderDO w where w.orderNo = ?1 ")
    @Query("from BusinessOrderRefundDO w where w.orderNo = ?1 ")
    BusinessOrderRefundDO selectByOrderNo(String orderNo);
}

+ 17 - 0
business/base-service/src/main/java/com/yihu/jw/order/dao/PayLogDao.java

@ -0,0 +1,17 @@
package com.yihu.jw.order.dao;
import com.yihu.jw.entity.order.PayLog;
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 Reece on 2017/9/20.
 */
public interface PayLogDao extends PagingAndSortingRepository<PayLog, Long>,JpaSpecificationExecutor<PayLog> {
	
	@Query("select p from PayLog p where p.operateCode=?1 ORDER BY createTime desc ")
	List<PayLog> getPayLogsByPrescriptionCode(String prescriptionCode);
}

+ 52 - 0
business/base-service/src/main/java/com/yihu/jw/order/pay/utils/PayLogService.java

@ -0,0 +1,52 @@
package com.yihu.jw.order.pay.utils;
import com.yihu.jw.entity.order.PayLog;
import com.yihu.jw.order.dao.PayLogDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
 * Created by Reece on 2017/9/20.
 * 日志服务
 */
@Service
public class PayLogService {
    @Autowired
    private PayLogDao payLogDao;
    public String onepayType = "0"; //诊断支付
    public String onepayRecipeType = "1";     //1续方支付
    public String shoppatType="2";//商城支付
    /**
     * 保存http调用日志  type 1续方支付
     */
    public void saveHttpLog(Boolean isSuccess,String url,String content,String method,String header,String params,String response,String error,String type)
    {
        try {
                //新增日志
                PayLog log = new PayLog();
                log.setType(type);
                log.setApi(url);
                log.setContent(content);
                log.setMethod(method);
                log.setHeader(header);
                log.setParams(params);
                log.setCreateTime(new Date());
                log.setResponse(response);
                log.setError(error);
                log.setStatus(isSuccess?"1":"0");
                payLogDao.save(log);
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }
}

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

@ -0,0 +1,228 @@
package com.yihu.jw.order.pay.ylz;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
import com.yihu.jw.hospital.prescription.dao.OauthDzqmConfigDao;
import com.yihu.jw.hospital.prescription.dao.OauthYlzConfigDao;
import com.yihu.jw.order.pay.utils.PayLogService;
import com.yihu.jw.utils.StringUtil;
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.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by wangzhinan on 2020/5/9.
 */
@Service
public class YlzPayService {
    @Autowired
    private OauthYlzConfigDao oauthYlzConfigDao;
    @Autowired
    private PayLogService logService;
    /**
     private String termNo;
     private String operatorId; 操作人员id
     private String operatorName;操作人员型
     private String cardType;卡类型 ---01 社保卡 06 临时卡
     private String cardNo;---卡号
     private String accountType;---帐户类型
     private String idNo;--身份证号
     private String depositType;---充值方式WX_MIN 微信小程序 WX_PUB 微信公众号 ALI_WAP 支付宝生活号
     private String rechargeAmount;--单位:元充值金额(自费金额)
     private String consumeAmount;---消费金额
     private String outTradeNo;---商户扣费流水号
     private String tradeKind;----消费种类门诊自费结算 长处方自费结算 互联网医院自费结算
     private String hisCustId;---HIS 患者唯一 ID若无,请传卡号
     private String rechargeHis;---是否往 HIS 充值0:不往 HIS 充值 1:往 HIS 充值 默认为 0
     private String userName;----用户姓名
     private String notes;---备注
     openId---openid
     * @return
     */
    public String rechargeConsume(String operatorId,String operatorName,String cardType,String cardNo,String accountType,String idNo,String depositType,String rechargeAmount,
                                  String consumeAmount,String outTradeNo,String hisCustId,String rechargeHis,String userName,String notes,String openid,String returnUrl,String notifyUrl,String wxMinId){
        String object  = null;
        Boolean isSuccess = true;
        String error = null;
        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);
        RechargeConsumeParams param = new RechargeConsumeParams();
        try {
            param.setRechargeHis(rechargeHis);//HIS 充值
            param.setAccountType(accountType);
            param.setOutTradeNo(outTradeNo);
            param.setCardNo(cardNo);
            param.setCardType(cardType);
            param.setAccountType(accountType);
            param.setDepositType(depositType);
            param.setRechargeAmount(rechargeAmount);
            param.setConsumeAmount(consumeAmount);
            param.setIdNo(idNo);
            param.setHisCustId(hisCustId);
            param.setUserName(userName);
            param.setTermNo("123456");
            param.setNotes(notes);
            param.setOperatorId(operatorId);
            param.setOperatorName(operatorName);
            Map<String,String> extra = new HashMap<String,String>();
            extra.put("openId", openid);
            extra.put("returnUrl",returnUrl);
            extra.put("notifyUrl",notifyUrl);
            if (StringUtils.isNoneBlank(wxMinId)){
                extra.put("wxMinId",wxMinId);
            }
            param.setExtra(extra);
            ResponseParams<RechargeConsumeResult> respnse = onepayClient.rechargeConsume(param);
            if (respnse.getRespCode().equals("000000")){
                object = JSON.toJSONString(respnse);
            }else {
                isSuccess = false;
                object = JSON.toJSONString(respnse);
                error = "请求失败,返回结果:" + respnse.getRespCode() + "," + respnse.getRespMsg();
            }
        } catch (Exception e) {
            e.printStackTrace();
            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), object, error,logService.onepayType);
        return object;
    }
    /**
     * termNo 终端编号 String(50) Y
     * operatorId 操作员编号 String(30) N
     * operatorName 操作员姓名 String(50) N
     * cardType 卡类型 String(2) N
     * cardNo 卡号 String(32) N
     * accountType 帐户类型 String(2) N 01:门诊,02:住院
     * amount 退款金额 String(12) N
     * withdrawMode 退款方式 String(1) N 0 现金退回 1 原路退回 2 银企转账 3 医保自费退回
     * outChargeNo 商户原充值订单号 String(30) N 二选一,两者同时存在 时,
     * traceNo>outCharge No,两者不能同时为空
     * traceNo 平台交易跟踪号(调 用平台充值接口后返 回的 traceNo) String(30)
     * outRefundNo 商户退款订单号 String(30) N
     * idNo 身份证号 String(32) Y
     * hisCustId HIS 系统唯一性 患者 String(30) N 没有则传卡号
     ID userName 用户姓名 String(30) Y extra 扩展参数 JSON Y checkCash String 当 withdrawMode=0 时,checkCash=1 校验 现金充值流水号及可退 金额是否合法,放空或 其他值不校验
     * @return
     */
    public String refund(String hisCustId,String operatorId,String operatorName,String cardType,String cardNo,String accountType,String amount,
                         String withdrawMode,String outChargeNo,String outRefundNo,String idNo){
        String object  = null;
        Boolean isSuccess = true;
        String error = null;
        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);
        RefundParams param = new RefundParams();
        try {
            param.setTermNo("123456");
            param.setHisCustId(hisCustId);
            param.setOperatorId(operatorId);
            param.setOperatorName(operatorName);
            param.setCardType(cardType);
            param.setCardNo(cardNo);
            param.setAccountType(accountType);
            param.setAmount(amount);
            param.setWithdrawMode(withdrawMode);
            param.setOutChargeNo(outChargeNo);
            param.setOutRefundNo(outRefundNo);
            param.setIdNo(idNo);
            ResponseParams<RefundResult> response = onepayClient.refund(param);
            if (response.getRespCode().equals("000000")){
                object = JSON.toJSONString(response);
            }else {
                isSuccess = false;
                object = JSON.toJSONString(response);
                error = "请求失败,返回结果:" + response.getRespCode() + "," + response.getRespMsg();
            }
        } catch (Exception e) {
            e.printStackTrace();
            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), object, error,logService.onepayType);
        return object;
    }
    public String tradeQuery(String termNo,String operatorId,String operatorName,String outTradeNo,String tradeType,String notes){
        String object  = null;
        Boolean isSuccess = true;
        String error = null;
        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);
        TradeQueryParams param = new TradeQueryParams();
        try {
            param.setTermNo("123456");
            param.setOperatorId("123456");
            param.setOperatorName(operatorName);
            param.setTradeType(tradeType);
            param.setOutTradeNo(outTradeNo);
            param.setNotes(notes);
            ResponseParams<TradeQueryResult> response = onepayClient.tradeQuery(param);
            if (response.getRespCode().equals("000000")){
                object = JSON.toJSONString(response);
            }else {
                isSuccess = false;
                object = JSON.toJSONString(response);
                error = "请求失败,返回结果:" + response.getRespCode() + "," + response.getRespMsg();
            }
        } catch (Exception e) {
            e.printStackTrace();
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            error = sw.toString();
        }
        logService.saveHttpLog(isSuccess, "hop.trade.tradeQuery", "互联网医院查询订单", "POST", null,JSON.toJSONString(param), object, error,logService.onepayType);
        return object;
    }
}

+ 3 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java

@ -19,13 +19,13 @@ public abstract class IntegerIdentityEntity implements Serializable {
    @Id
//==========mysql 环境 id策略======================================================
/*    @GeneratedValue(generator = "generator")
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "identity")
    @Column(name = "id", unique = true, nullable = false)*/
    @Column(name = "id", unique = true, nullable = false)
//==========mysql 环境 id策略 end======================================================
//==========Oracle 环境id策略 =========================================================
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")
/*    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")*/
//==========Oracle 环境id策略 =========================================================
    public Integer getId() {
        return id;

+ 2 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/order/BusinessOrderDO.java

@ -23,13 +23,13 @@ public class BusinessOrderDO extends IntegerIdentityEntity {
    private String patient;//居民code
    private String patientName;//居民名字
    private String orderNo;//订单号
    private Integer orderType;//订单类型
    private Integer orderType;//订单类型订单类型:目前只能1表示图文,3表示视频大类细分如下:专家咨询:1图文咨询 |2电话咨询|3视频咨询|4免费义诊图文诊室:1图文复诊视频诊室:3视频复诊| 5社区协同
    private String orderCategory;//1:专家咨询|2:图文诊室|3:视频诊室|)
    private String relationCode;//业务关联code
    private String relationName;//业务关联名称
    private String description;//支付备注
    private String rematk;//病人描述
    private Integer payType;//支付类型1微信2支付宝
    private Integer payType;//支付类型1微信2支付宝3易联众支付
    private Double payPrice;//支付金额
    private Date payTime;//支付时间
    private String doctor;//医生code

+ 182 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/order/PayLog.java

@ -0,0 +1,182 @@
package com.yihu.jw.entity.order;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 易联众相关支付log表
 * Created by Reece on 2017/9/20.
 */
@Entity
@Table(name = "ylz_pay_log")
public class PayLog extends UuidIdentityEntity {
    // 接口类型 0家庭签约支付 1续方支付
    private String type;
    // 业务内容
    private String content;
    // 调用接口
    private String api;
    // 调用方式
    private String method;
    // 调用参数
    private String params;
    // 调用头部信息
    private String header;
    // 返回结果
    private String response;
    // 状态 0失败 1成功 2已重试
    private String status;
    // 重试次数
    private Integer retryTimes;
    // 创建时间
    private Date createTime;
    //异常信息
    private String error;
    //居民CODE
    private String patientCode;
    //业务CODE
    private String operateCode;
    //缴费人身份证
    private String idcard;
    //缴费人社保卡
    private String ssc;
    
    @Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "content")
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    @Column(name = "api")
    public String getApi() {
        return api;
    }
    public void setApi(String api) {
        this.api = api;
    }
    @Column(name = "method")
    public String getMethod() {
        return method;
    }
    public void setMethod(String method) {
        this.method = method;
    }
    @Column(name = "params")
    public String getParams() {
        return params;
    }
    public void setParams(String params) {
        this.params = params;
    }
    @Column(name = "header")
    public String getHeader() {
        return header;
    }
    public void setHeader(String header) {
        this.header = header;
    }
    @Column(name = "response")
    public String getResponse() {
        return response;
    }
    public void setResponse(String response) {
        this.response = response;
    }
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Column(name = "retry_times")
    public Integer getRetryTimes() {
        return retryTimes;
    }
    public void setRetryTimes(Integer retryTimes) {
        this.retryTimes = retryTimes;
    }
    @Column(name = "create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "error")
    public String getError() {
        return error;
    }
    public void setError(String error) {
        this.error = error;
    }
    
    public String getPatientCode() {
        return patientCode;
    }
    
    public void setPatientCode(String patientCode) {
        this.patientCode = patientCode;
    }
    
    public String getOperateCode() {
        return operateCode;
    }
    
    public void setOperateCode(String operateCode) {
        this.operateCode = operateCode;
    }
    
    public String getIdcard() {
        return idcard;
    }
    
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    
    public String getSsc() {
        return ssc;
    }
    
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
}

+ 9 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -378,6 +378,15 @@ public class BaseHospitalRequestMapping {
        public static final String importDoctorWork = "/importDoctorWork";
        public static final String selectOrderByRelationCode = "/selectOrderByRelationCode";
        public static final String ylzRefund = "/ylzRefund";
        public static final String tradeQuery= "/tradeQuery";
    }
    public static class YkyyPrescription extends BaseHospitalRequestMapping.Basic {

+ 11 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/hospital/prescription/WlyyPrescriptionVO.java

@ -296,6 +296,9 @@ public class WlyyPrescriptionVO extends UuidIdentityVOWithOperator {
    @ApiModelProperty(value = "订单号",example = "订单号")
    private String orderNo;
    @ApiModelProperty(value = "订单id",example = "订单号")
    private String orderId;
    /**
     * 处方结算状态,0为未结算,1为结算成功,默认为0
     */
@ -713,4 +716,12 @@ public class WlyyPrescriptionVO extends UuidIdentityVOWithOperator {
    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }
    public String getOrderId() {
        return orderId;
    }
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
}

+ 3 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/PatientConsultEndpoint.java

@ -442,6 +442,9 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
						businessOrderDO.setRelationName("新增专家咨询");
					}
					businessOrderService.saveOrder(businessOrderDO);
				}else if (wxId.equalsIgnoreCase("xm_zsyy_wx")){
					Double price = 0.01;
					businessOrderService.recharge(re.getString("consult"),"新增专家咨询","1","专家咨询费",patient,re.getString("patientName"),doctor,price);
				}
			}catch (Exception e){
			    logger.info("支付订单失败:"+e.getMessage());

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

@ -1,10 +1,13 @@
package com.yihu.jw.hospital.endpoint.patient;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.dict.service.BaseDictJobTitleService;
import com.yihu.jw.doctor.service.BaseDoctorInfoService;
import com.yihu.jw.entity.base.dict.DictJobTitleDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.ylzinfo.OauthYlzConfigDO;
import com.yihu.jw.hospital.prescription.dao.OauthYlzConfigDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.service.consult.SysDictService;
import com.yihu.jw.im.service.ImService;
@ -17,7 +20,9 @@ import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.service.WechatInfoService;
import com.yihu.jw.wechat.service.WxUrlConfigService;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.exception.PayException;
import com.ylzinfo.onepay.sdk.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -28,11 +33,14 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -70,6 +78,8 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    private String wxId;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private OauthYlzConfigDao oauthYlzConfigDao;
@ -297,4 +307,55 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
        return map;
    }
    /**
     * 商户回调通知
     * @param request
     * @param response
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/ylzReceiveNotify")
    public String mmpReceiveNotify(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        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();
        String params = StreamUtils.copyToString(inputStream, Charset.forName("UTF-8"));
        logger.info("回调参数:{}", params);
        if (StringUtil.isEmpty(params)) {
            response.getWriter().write("empty");
            return appId;
        }
        // 参数转换
        ResponseParams<?> encryptRes = JSON.parseObject(params, ResponseParams.class);
        OnepayDefaultClient client = new OnepayDefaultClient("", appId, appSecret, encryptRes.getSignType(), encryptRes.getEncryptType());
        try {
            logger.info("解密前:{}", JSON.toJSONString(encryptRes));
            ResponseParams<?> decryptRes = client.decryptNotifyResponse(encryptRes);
            logger.info("解密后:{}", JSON.toJSONString(decryptRes));
            boolean isDecrypt = ("-1".equals(decryptRes.getRespCode()) ? false : true); // 是否解密失败
            if (!isDecrypt) {
                response.getWriter().write("DECRYPT FAILURE");
            } else {
                boolean isVerify = client.verifyResponseSign(decryptRes);
                logger.info("验签结果:{}", isVerify);
                if (!isVerify) {
                    response.getWriter().write("FAILURE");
                } else {
                    response.getWriter().write("SUCCESS");
                }
            }
        } catch (Exception e) {
            response.getWriter().write(e.getMessage());
        }
        return appId;
    }
}

+ 77 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/PrescriptionEndpoint.java

@ -15,6 +15,7 @@ import com.yihu.jw.hospital.prescription.service.entrance.DoctorPreSignService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.hospital.service.SystemMessage.HospitalSystemMessageService;
import com.yihu.jw.im.service.ImService;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.restmodel.hospital.prescription.WlyyOutpatientVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.im.ConsultVO;
@ -79,9 +80,15 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private XzzxEntranceService xzzxEntranceService;
    @Autowired
    private BusinessOrderService businessOrderService;
    @Value("${demo.flag}")
    private boolean demoFlag;
    @Value("${wechat.id}")
    private String wxId;
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findOutpatientList)
    @ApiOperation(value = " 查询某个时间段的患者门诊就诊记录")
    public ListEnvelop findOutpatientList(@ApiParam(name = "patient", value = "居民id")
@ -1102,4 +1109,74 @@ public class PrescriptionEndpoint extends EnvelopRestEndpoint {
        envelop.setDetailModelList(error);
        return envelop;
    }
    /**
     * 易联众统一支付
     * @param relationCode
     * @return
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.selectOrderByRelationCode)
    @ApiOperation("统一支付")
    public ObjEnvelop selectOrderByRelationCode(
            @ApiParam(name = "relationCode", value = "relationCode", required = true)
            @RequestParam(required = true)String relationCode,
            @ApiParam(name = "depositType", value = "depositType", required = true)
            @RequestParam(required = true)String depositType) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.reChargeJSON(relationCode,depositType,wxId));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    /**
     * 易联众统一退款
     *
     *
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.ylzRefund)
    @ApiOperation("易联众统一退款")
    public ObjEnvelop ylzRefund(
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(required = true)String patient,
            @ApiParam(name = "orderNo", value = "orderNo", required = true)
            @RequestParam(required = true)String orderNo,
            @ApiParam(name = "refundPrice", value = "refundPrice", required = true)
            @RequestParam(required = true)Double refundPrice,
            @ApiParam(name = "description", value = "description", required = true)
            @RequestParam(required = true)String description) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.ylzOrderRefund(wxId,patient,orderNo,refundPrice,description));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    /**
     * 易联众统一订单查询
     *
     * @param tradeType
     * @param orderNo
     * @return
     * @throws Exception
     */
    @PostMapping(value= BaseHospitalRequestMapping.Prescription.tradeQuery)
    @ApiOperation("易联众统一订单查询")
    public ObjEnvelop tradeQuery(
            @ApiParam(name = "tradeType", value = "tradeType", required = true)
            @RequestParam(required = true)String tradeType,
            @ApiParam(name = "orderNo", value = "orderNo", required = true)
            @RequestParam(required = true)String orderNo) throws Exception {
        try {
            return ObjEnvelop.getSuccess("ok",businessOrderService.tradeQuery(orderNo,tradeType));
        } catch (Exception e) {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
}

+ 9 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/YkyyPrescriptionEndpoint.java

@ -162,4 +162,13 @@ public class YkyyPrescriptionEndpoint extends EnvelopRestEndpoint {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getICD10)
    @ApiOperation(value = "获取ICD10诊断编码", notes = "获取ICD10诊断编码")
    public ListEnvelop getICD10(@ApiParam(name = "pyKey", value = "拼音关键字")
                                @RequestParam(value = "pyKey", required = false)String pyKey)throws Exception {
        return success(prescriptionService.getICD10(pyKey));
    }
}

+ 167 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/ylz/YlzNotifyController.java

@ -0,0 +1,167 @@
/**
 * 软件著作权:易联众
 * 系统名称:支付平台
 */
package com.yihu.jw.hospital.endpoint.ylz;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import com.alibaba.fastjson.JSON;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.exception.PayException;
import com.ylzinfo.onepay.sdk.utils.StringUtil;
/**
 * 医保移动支付商户端模拟测试
 * 
 * @date 2015年10月21日
 * @author sunzhiwei
 * @version 1.0.0
 * @param <T>
 */
@Controller
public class YlzNotifyController<T> {
	private static final Logger LOGGER = LoggerFactory.getLogger(YlzNotifyController.class);
	/**
	 * 商户页面跳转(模拟测试)
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws PayException
	 */
	@RequestMapping(value = "/mmp/returnUrl")
	public void testReturnUrl(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
		response.setContentType("text/html;charset=utf-8");
		LOGGER.info("跳转参数:{}", request.getQueryString());
		response.getWriter().write("返回结果:\n" + request.getQueryString() +"\n");
		String onepayUrl = request.getParameter("onepayUrl");
		String appId = "1BHEOI11C00J7B2CA8C0000071FA53E1";
		String appSecret = "1BHEOH8HB0006E0A0A0A00002DB28BC5";
		String signType = "MD5";
		String encryptType = "DES";
		try {
			OnepayDefaultClient client = new OnepayDefaultClient(onepayUrl, appId, appSecret, signType, encryptType);
			Map<String, String> returnParams = getRequestMap(request.getQueryString());
			boolean isVerify = client.verifyReturnSign(returnParams, returnParams.get("sign"));
			LOGGER.info("验签结果:{}", isVerify);
			if (isVerify) {
				response.getWriter().write("签名结果:\nSIGN SUCCESS.\n");
				// TODO 继续处理业务
				//		如:查询显示订单信息
			} else {
				response.getWriter().write("签名结果:\nSIGN ERROR !!!\n");
			}
		} catch (Exception e) {
			response.getWriter().write(e.getMessage());
		}
	}
	/**
	 * 转换URL参数中为Map
	 * @param reqQueryString
	 * @return
	 * @throws PayException
	 */
	private Map<String, String> getRequestMap(String reqQueryString) throws PayException {
		if (StringUtil.isEmpty(reqQueryString)) {
			throw new PayException("跳转参数为空");
		}
		Map<String, String> targetMap = null;
		try {
			reqQueryString = URLDecoder.decode(reqQueryString, "utf-8");
			targetMap = resolveFormContext(reqQueryString, "=", "&");
			LOGGER.info("targetMap=={}", targetMap);
		} catch (Exception e) {
			throw new PayException("跳转参数处理异常," + reqQueryString);
		}
		return targetMap;
	}
	/**
	 * 解析URL参数串
	 * @param formContext
	 * @param wordFirstsplitRegex
	 * @param wordSecondsplitRegex
	 * @return
	 */
	public static Map<String, String> resolveFormContext(String formContext, String wordFirstsplitRegex, String wordSecondsplitRegex) {
		if (StringUtil.isEmpty(formContext)) {
			return null;
		}
		Map<String, String> targetMap = new HashMap<String, String>();
		String[] wordSeconds = formContext.split(wordSecondsplitRegex);
		for (String wordSecond : wordSeconds) {
			if (StringUtil.isEmpty(wordSecond)) {
				continue;
			}
			int idx = wordSecond.indexOf(wordFirstsplitRegex);
			targetMap.put(wordSecond.substring(0, idx), wordSecond.substring(idx + 1, wordSecond.length()));
		}
		return targetMap;
	}
	
	/**
	 * 商户回调通知(模拟测试)
	 * @param request
	 * @param response
	 * @throws IOException
	 * @throws PayException
	 */
	@RequestMapping(value = "/mmp/receiveNotify")
	public void mmpReceiveNotify(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
		response.setContentType("text/html;charset=utf-8");
		String appId = "1BHEOI11C00J7B2CA8C0000071FA53E1";
		String appSecret = "1BHEOH8HB0006E0A0A0A00002DB28BC5";
		InputStream inputStream = request.getInputStream();
		String params = StreamUtils.copyToString(inputStream, Charset.forName("UTF-8"));
		LOGGER.info("回调参数:{}", params);
		if (StringUtil.isEmpty(params)) {
			response.getWriter().write("empty");
			return;
		}
		// 参数转换
		ResponseParams<?> encryptRes = JSON.parseObject(params, ResponseParams.class);
		OnepayDefaultClient client = new OnepayDefaultClient("", appId, appSecret, encryptRes.getSignType(), encryptRes.getEncryptType());
		try {
			LOGGER.info("解密前:{}", JSON.toJSONString(encryptRes));
			ResponseParams<?> decryptRes = client.decryptNotifyResponse(encryptRes);
			LOGGER.info("解密后:{}", JSON.toJSONString(decryptRes));
			boolean isDecrypt = ("-1".equals(decryptRes.getRespCode()) ? false : true); // 是否解密失败
			if (!isDecrypt) {
				response.getWriter().write("DECRYPT FAILURE");
			} else {
				boolean isVerify = client.verifyResponseSign(decryptRes);
				LOGGER.info("验签结果:{}", isVerify);
				if (!isVerify) {
					response.getWriter().write("FAILURE");
				} else {
					response.getWriter().write("SUCCESS");
				}
			}
		} catch (Exception e) {
			response.getWriter().write(e.getMessage());
		}
	}
}