wujunjie před 7 roky
rodič
revize
d36dfd9a7b

+ 37 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/PrescriptionPay.java

@ -58,6 +58,43 @@ public class PrescriptionPay extends IdEntity {
    private String mxlist;//处方明细
    private Date createTime;//续方确认支付时间
    private Date czrq;//续方记录最后操作时间
    //    易联众新增查询返回字段v1.3.7
    private String medOrgNo;//医疗机构编号
    private String medOrgName;//医疗机构名称
    private Date traceTime;//交易成功时间
    private String traceNo;//支付平台跟踪号
    public Date getTraceTime() {
        return traceTime;
    }
    public void setTraceTime(Date traceTime) {
        this.traceTime = traceTime;
    }
    public String getTraceNo() {
        return traceNo;
    }
    public void setTraceNo(String traceNo) {
        this.traceNo = traceNo;
    }
    public String getMedOrgNo() {
        return medOrgNo;
    }
    public void setMedOrgNo(String medOrgNo) {
        this.medOrgNo = medOrgNo;
    }
    public String getMedOrgName() {
        return medOrgName;
    }
    public void setMedOrgName(String medOrgName) {
        this.medOrgName = medOrgName;
    }
    public Integer getAccountBalance() {
        return accountBalance;

+ 8 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -98,6 +98,14 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("zy_execute_sick_settle_job reorder job job exist");
            }
            //处理当天支付,页面回调及异步回调失败的支付,每3分钟一次去主动查询并保存
            if (!quartzHelper.isExistJob("prescription_pay_query_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("prescription_pay_query_job");
                quartzHelper.addJob(PrescriptionPayQueryJob.class, trigger, "prescription_pay_query_job", new HashMap<String, Object>());
                logger.info("prescription_pay_query_job reorder job job success");
            } else {
                logger.info("prescription_pay_query_job reorder job job exist");
            }
            //居民24小时未回复的咨询自动关闭 每小时59分开始执行一次
            if (!quartzHelper.isExistJob("finish_consult_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("finish_consult_job");

+ 57 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PrescriptionPayQueryJob.java

@ -0,0 +1,57 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.repository.prescription.PrescriptionPayDao;
import com.yihu.wlyy.service.app.prescription.PatientPrescriptionPayService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
 * 处理当天支付,页面回调及异步回调失败的支付,每3分钟一次去主动查询并保存
 * Created by Reece on 2017/8/29/029.
 */
public class PrescriptionPayQueryJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(PrescriptionPayQueryJob.class);
    @Autowired
    private PrescriptionPayDao prescriptionPayDao;
    @Autowired
    private PatientPrescriptionPayService payService;
    @Autowired
    WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("PrescriptionPayQueryJob start ..........");
        try {
            String accesstoken =  weiXinAccessTokenUtils.getAccessToken();
            //获取支付完成,院内结算失败的 处方CODE 集合
            List<String> prescriptionCodeList = prescriptionPayDao.findTodayUnpay();
            if (!prescriptionCodeList.isEmpty()) {
                for (String code : prescriptionCodeList) {
                    try {
                        payService.chargeQuery(code,accesstoken);
                    } catch (Exception e) {
                        logger.info("PrescriptionPayQueryJob error ..........continue this JOB,CODE:" + code + ",message:" + e.getMessage());
                        continue;
                    }
                }
            }
            logger.info("PrescriptionPayQueryJob end ..........");
        } catch (Exception e) {
            e.printStackTrace();
            logger.info("PrescriptionPayQueryJob error ..........,message:" + e.getMessage());
        }
    }
}

+ 8 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionPayDao.java

@ -13,4 +13,12 @@ import java.util.List;
public interface PrescriptionPayDao extends PagingAndSortingRepository<PrescriptionPay, Long>, JpaSpecificationExecutor<PrescriptionPay> {
    @Query("from PrescriptionPay p where p.prescriptionCode=?1 ")
    PrescriptionPay findByPrescriptionPay(String prescriptionCode);
    //查询支付记录
    @Query("from PrescriptionPay p where p.code=?1 ")
    PrescriptionPay findByCode(String code);
    //   查询当天支付,页面回调及异步回调均失败的支付 tradeStatus为空
    @Query(value = "SELECT t.`code` FROM wlyy_prescription_pay t WHERE t.trade_status is null AND t.create_time >= date(now()) AND t.create_time < DATE_ADD(date(now()), INTERVAL 1 DAY)", nativeQuery = true)
    List<String> findTodayUnpay();
}

+ 249 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java

@ -0,0 +1,249 @@
package com.yihu.wlyy.service.app.prescription;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.entity.zydict.ZyPushLog;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.repository.prescription.PrescriptionPayDao;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.SystemConf;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StreamUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.transaction.Transactional;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by Reece on 2017/7/28/028.
 * 患者支付
 */
@Service
public class PatientPrescriptionPayService extends BaseService {
    private Logger logger=LoggerFactory.getLogger(PatientPrescriptionPayService.class);
    //公共配置文件
    Properties systemConf = SystemConf.getInstance().getSystemProperties();
    //    各环境对应配置
    @Value("${server.server_url}")
    private String serverUrl;
    @Value("${wechat.accId}")
    private String accId;
    //    Java配置文件 后续删除
    private String signType = "MD5";
    private String encryptType = "AES";
    //    引入实例
    @Autowired
    private PayConfiguraDao configuraDao;
    @Autowired
    private PrescriptionPayDao payDao;
    @Autowired
    private HospitalMappingDao mappingDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    /**
     * 家庭医生签约支付查询
     */
    public String chargeQuery(String code, String accessToken) throws Exception {
        PayConfigura config = configuraDao.findWorkConfigura();
        int flag = 0;
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        String result = null;
        PrescriptionPay charge = payDao.findByCode(code);
        String prescriptionCode = charge.getPrescriptionCode();
        Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
        HospitalMapping hospitalMapping = mappingDao.findByCode(prescription.getHospital());
//          ***************************  测通流程 ***************************************
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), hospitalMapping.getAppId(), hospitalMapping.getAppSecret(), signType, encryptType);
        try {
            RequestParams requestParams = new RequestParams();
//            requestParams.setVersion();
//            requestParams.setSign();
//            requestParams.setEncryptData();
//            requestParams.setAppId(appId);
            requestParams.setAppId(hospitalMapping.getAppId());
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());
            requestParams.setSignType(signType);
            requestParams.setEncryptType(encryptType);
            requestParams.setTransType(config.getChargeQueryType());
            //业务参数
            JSONObject params = new JSONObject();
            params.put("outChargeNo", code);  //接入应用结算业务流水号
            params.put("wxToken", accessToken);
            requestParams.setParam(params);
            msgBody = JSON.toJSONString(requestParams);
//              ***************************  测通流程 ***************************************
            //执行支付 返回原生返回值
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            response = JSON.toJSONString(res);
            if (OnepayDefaultClient.isSuccessful(res)) {
                result = JSON.toJSONString(res.getParam());
//                新增保存数据
                JSONObject request = JSON.parseObject(result);
//                String tradeStatus = request.getString("tradeStatus");//交易状态
                String chargeStatus = request.getString("chargeStatus");//交易状态
                String chargeNo = request.getString("chargeNo");//支付平台流水号
                String chargeTime = request.getString("chargeTime");//支付平台交易成功时间
                String outChargeNo = request.getString("outChargeNo");//接入应用业务流水号
                String outChargeTime = request.getString("outChargeTime");//接入应用时间
                String medOrgNo = request.getString("medOrgNo");//医疗机构编号
                String medOrgName = request.getString("medOrgName");//医疗机构名称
                String billNo = request.getString("billNo");//待结算费用单据号
                String cardNo = request.getString("cardNo");//医保卡号
                String totalAmount = request.getString("totalAmount");//交易总金额
                String insuranceAmount = request.getString("insuranceAmount");//医保支付金额
                String selfPayAmount = request.getString("selfPayAmount");//自付金额
                String userId = request.getString("userId");//用户openID
                String userName = request.getString("userName");//用户名字
                String idNo = request.getString("idNo");//证件号码
                String idType = request.getString("idType");//证件类型
//                String appId = request.getString("appId");
//                String channel = request.getString("channel");//支付方式
//                String sign = request.getString("sign");
//                String signType = request.getString("signType");
//                String timestamp = request.getString("timestamp");
                JSONObject responseContents = request.getJSONObject("responseContent");//医保结构体
                PrescriptionPay prescriptionPay = payDao.findByCode(outChargeNo);
                if (responseContents != null) {
                    String miSettleNo = responseContents.getString("miSettleNo");//医保收费单据号 (医保签约号)
                    String miRegisterNo = responseContents.getString("miRegisterNo");//医保挂号
                    String miCollectDate = responseContents.getString("miCollectDate");//收费日期
                    String miCollectTime = responseContents.getString("miCollectTime");//收费时间
                    String miCollectorName = responseContents.getString("miCollectorName");//收费人姓名
                    String miTotalFee = responseContents.getString("miTotalFee");//本次报销总额
                    String selfPay = responseContents.getString("selfPay");//个人现金支付
                    String accountPay = responseContents.getString("accountPay");//个人账户支付
                    String heathPay = responseContents.getString("heathPay");//健康账户支付
                    String cadresPay = responseContents.getString("cadresPay");//公务员补助
                    String fundPay = responseContents.getString("fundPay");//基金支付
                    String healthCarePay = responseContents.getString("healthCarePay");//保健基金支付
                    String commercePay = responseContents.getString("commercePay");//商业保险支付
                    String familyPay = responseContents.getString("familyPay");//共济账户支付
                    String civilPay = responseContents.getString("civilPay");//民政补助金额
                    String civilZone = responseContents.getString("civilZone");//民政行政区号
                    String bdrugPay = responseContents.getString("bdrugPay");//乙类支付金额
                    String unlessAmount = responseContents.getString("unlessAmount");//非医保费用
                    String exceedAmount = responseContents.getString("exceedAmount");//超封顶线金额
                    String accountBalance = responseContents.getString("accountBalance");//个人账户余额
                    String healthBalance = responseContents.getString("healthBalance");//健康账户余额
                    prescriptionPay.setMiSettleNo(miSettleNo);//医保收费单据号
                    prescriptionPay.setMiRegisterNo(miRegisterNo);//医保挂号
                    SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMdd");
                    prescriptionPay.setMiCollectDate(formatDate.parse(miCollectDate));//收费日期
                    SimpleDateFormat formatTime = new SimpleDateFormat("HHmm");
                    prescriptionPay.setMiCollectTime(formatTime.parse(miCollectTime));//收费时间
                    prescriptionPay.setMiCollectorName(miCollectorName);//收费人姓名
                    prescriptionPay.setMiTotalFee(Integer.parseInt(miTotalFee));//本次报销总额
                    prescriptionPay.setSelfPay(Integer.parseInt(selfPay));//个人现金支付
                    prescriptionPay.setAccountPay(Integer.parseInt(accountPay));//个人账户支付
                    prescriptionPay.setHeathPay(Integer.parseInt(heathPay));//健康账户支付
                    prescriptionPay.setCadresPay(Integer.parseInt(cadresPay));//公务员补助
                    prescriptionPay.setFundPay(Integer.parseInt(fundPay));//基金支付
                    prescriptionPay.setHealthCarePay(Integer.parseInt(healthCarePay));//保健基金支付
                    prescriptionPay.setCommercePay(Integer.parseInt(commercePay));//商业保险支付
                    prescriptionPay.setFamilyPay(Integer.parseInt(familyPay));//共济账户支付
                    prescriptionPay.setCivilPay(Integer.parseInt(civilPay));//民政补助金额
                    prescriptionPay.setCivilZone(civilZone);//民政行政区号
                    prescriptionPay.setBdrugPay(Integer.parseInt(bdrugPay));//乙类支付金额
                    prescriptionPay.setUnlessAmount(Integer.parseInt(unlessAmount));//非医保费用
                    prescriptionPay.setExceedAmount(Integer.parseInt(exceedAmount));//超封顶线金额
                    prescriptionPay.setAccountBalance(Integer.parseInt(accountBalance));//个人账户余额
                    prescriptionPay.setHealthBalance(Integer.parseInt(healthBalance));//健康账户余额
                }
                if ("0".equals(chargeStatus) || "SUCCESS".equals(chargeStatus)) {
                    prescriptionPay.setTradeStatus("1");//交易状态 成功1 失败0
                }else {
                    prescriptionPay.setTradeStatus("0");//交易状态 成功1 失败0
                }
                prescriptionPay.setChargeNo(chargeNo);//支付流水号
                SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
                prescriptionPay.setChargeTime(formatDate.parse(chargeTime));//支付平台交易成功时间
                prescriptionPay.setOutChargeTime(formatDate.parse(outChargeTime));//接入应用内业务时间
                prescriptionPay.setMedOrgNo(medOrgNo);//医疗机构编号
                prescriptionPay.setMedOrgName(medOrgName);//医疗机构名称
                prescriptionPay.setBillNo(billNo);//待结算费用单据号
                prescriptionPay.setCardNo(cardNo);//医保卡号
                prescriptionPay.setTotalAmount(Integer.parseInt(totalAmount));//交易总金额
                prescriptionPay.setInsuranceAmount(Integer.parseInt(insuranceAmount));//医保支付金额
                prescriptionPay.setSelfPayAmount(Integer.parseInt(selfPayAmount));//自付金额
                prescriptionPay.setOpenid(userId);
                prescriptionPay.setUserName(userName);
                prescriptionPay.setIdType(idType);//证件类型
                prescriptionPay.setIdNo(idNo);//证件号码
                //        保存数据库更改记录
                payDao.save(prescriptionPay);
                logger.info("请求成功,返回参数: " + result);
            } else {
                isSuccess = false;
                error = "请求失败,返回结果:" + res.getRespCode() + "," + res.getRespMsg();
            }
        } catch (Exception ex) {
            isSuccess = false;
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            error = sw.toString();
        }
        if (!isSuccess) {
            throw new Exception(error);
        }
        return result;
    }
}

+ 17 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java

@ -445,6 +445,23 @@ public class JobController extends BaseController {
        }
    }
    /**
     * 遍历长处方支付但回调都失败的记录,主动查询易联众支付记录并保存
     *
     * @author wujunjie
     * @date 2017/8/30 14:16
     */
    @RequestMapping(value = "/prescriptionPayQueryJob", method = RequestMethod.POST)
    @ApiOperation("遍历长处方支付但回调都失败的记录,主动查询易联众支付记录并保存")
    public String PrescriptionPayQueryJob() {
        try {
            quartzHelper.startNow(PrescriptionPayQueryJob.class, "PRESCRIPTION-PAY_QUERY", null);
            return write(200, "启动成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    //******************************长处方 end********************************
    /**
     * 居民监测方案提醒通知

+ 51 - 32
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PatientPrescriptionPayService.java

@ -3,12 +3,17 @@ package com.yihu.wlyy.service.app.prescription;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.charge.WlyyCharge;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.entity.zydict.ZyPushLog;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
@ -17,19 +22,19 @@ import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.repository.prescription.PrescriptionPayDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.repository.zydict.ZyPushLogDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.httplog.LogService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.service.weixin.wxpay.common.Configure;
import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
import com.yihu.wlyy.service.weixin.wxpay.model.Charge;
import com.yihu.wlyy.service.weixin.wxpay.service.OnePayService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.MessageType;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.web.wx.OnePayController;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
@ -41,6 +46,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.access.method.P;
import org.springframework.stereotype.Service;
import org.springframework.util.StreamUtils;
@ -50,6 +56,7 @@ import javax.transaction.Transactional;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.*;
@ -76,7 +83,7 @@ public class PatientPrescriptionPayService extends BaseService {
    //    引入实例
    @Autowired
    private Configure config;
    private PayConfiguraDao configuraDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
@ -252,6 +259,7 @@ public class PatientPrescriptionPayService extends BaseService {
     * @return
     */
    public Map recipeReturnUrl(HttpServletRequest request, HttpServletResponse response, String accessToken) throws Exception {
        PayConfigura config = configuraDao.findWorkConfigura();
        Map resultMap = new HashMap();
        Prescription prescription = null;
        int flag = 0;
@ -283,37 +291,37 @@ public class PatientPrescriptionPayService extends BaseService {
            String signType = request.getParameter("signType");
            String timestamp = request.getParameter("timestamp");
            String totalAmount = request.getParameter("totalAmount");//交易总金额
            String tradeStatus = request.getParameter("tradeStatus");//交易状态
//            String tradeStatus = request.getParameter("tradeStatus");//交易状态
            String tradeStatus = request.getParameter("chargeStatus");//交易状态
            String userId = request.getParameter("userId");//用户openID
            String userName = request.getParameter("userName");//用户名字
            String result = chargeQuery(outChargeNo, accessToken);//业务出参
            org.json.JSONObject param = new org.json.JSONObject(result);
            String requestParam = param.getString("responseContent");
			System.out.println("requestParam:"+requestParam);
            org.json.JSONObject responseContents = new org.json.JSONObject(requestParam);//医保结构体
//            构建请求结构体
            msbody.put("appId", appId);
            msbody.put("billNo", billNo);
            msbody.put("cardNo", cardNo);
            msbody.put("channel", channel);
            msbody.put("chargeNo", chargeNo);
            msbody.put("chargeTime", chargeTime);
            msbody.put("idNo", idNo);
            msbody.put("idType", idType);
            msbody.put("insuranceAmount", insuranceAmount);
            msbody.put("outChargeNo", outChargeNo);
            msbody.put("outChargeTime", outChargeTime);
            msbody.put("selfPayAmount", selfPayAmount);
            msbody.put("sign", sign);
            msbody.put("signType", signType);
            msbody.put("timestamp", timestamp);
            msbody.put("totalAmount", totalAmount);
            msbody.put("tradeStatus", tradeStatus);
            msbody.put("userId", userId);
            msbody.put("userName", userName);
            msbody.put("responseContent", responseContents);
			System.out.println("recipeReturnUrl responseContents "+responseContents.toString());
            msbody.put("appId",appId);
            msbody.put("billNo",billNo);
            msbody.put("cardNo",cardNo);
            msbody.put("channel",channel);
            msbody.put("chargeNo",chargeNo);
            msbody.put("chargeTime",chargeTime);
            msbody.put("idNo",idNo);
            msbody.put("idType",idType);
            msbody.put("insuranceAmount",insuranceAmount);
            msbody.put("outChargeNo",outChargeNo);
            msbody.put("outChargeTime",outChargeTime);
            msbody.put("selfPayAmount",selfPayAmount);
            msbody.put("sign",sign);
            msbody.put("signType",signType);
            msbody.put("timestamp",timestamp);
            msbody.put("totalAmount",totalAmount);
            msbody.put("tradeStatus",tradeStatus);
            msbody.put("userId",userId);
            msbody.put("userName",userName);
            msbody.put("responseContent",responseContents);
            PrescriptionPay prescriptionPay = payDao.findByCode(outChargeNo);
            if (responseContents != null) {
                String miSettleNo = "";
@ -493,6 +501,7 @@ public class PatientPrescriptionPayService extends BaseService {
     * @return
     */
    public String receiveRecipeNotify(HttpServletRequest request, HttpServletResponse response) throws Exception {
        PayConfigura config = configuraDao.findWorkConfigura();
        String result = null;
        Prescription prescription = null;
@ -798,7 +807,8 @@ public class PatientPrescriptionPayService extends BaseService {
     * 长处方支付,成功则返回支付路径
     */
    @Transactional
    public Map charge(int type, String addressJson, String orgCode, String prescriptionCode, int totalAmount, String people, String accessToken, String returnUrl, String deliveryTime) throws Exception {
    public Map charge(int type, String addressJson, String orgCode, String prescriptionCode, int totalAmount, String people, String accessToken, String returnUrl,String deliveryTime) throws Exception {
        PayConfigura config = configuraDao.findWorkConfigura();
        Map resultMap = new HashMap();
        Prescription prescription = null;
@ -1110,6 +1120,8 @@ public class PatientPrescriptionPayService extends BaseService {
            Map<String, String> map = new HashMap<>();//请求结构体
            map.put("feeType", "06");//长处方结算
            map.put("settleType", "01"); //诊间医保结算
//            易联众新增字段代支付v1.3.7
            map.put("principalCardNo",ssc); //实际结算卡号( 默认为绑卡主体卡号)
            params.put("requestContent", objectMapper.writeValueAsString(map));// 请求结构体
            logger.info("================================>" + "Before msBody");
            requestParams.setParam(params);
@ -1124,7 +1136,12 @@ public class PatientPrescriptionPayService extends BaseService {
                JSONObject json = res.getParam();
                String chargeNo = String.valueOf(json.get("chargeNo"));      //医保结算业务流水号
                result = String.valueOf(json.get("payUrl"));
//                易联众新增字段代支付v1.3.7
                String traceTime = String.valueOf(json.get("traceTime"));
                String  traceNo = String.valueOf(json.get("traceNo"));
                prescriptionPay.setChargeNo(chargeNo);//支付后返回的流水号
                prescriptionPay.setTraceTime(formatter.parse(traceTime));//交易成功时间
                prescriptionPay.setTraceNo(traceNo);//支付平台跟踪号
            } else {
                isSuccess = false;
                flag = 0;
@ -1167,7 +1184,7 @@ public class PatientPrescriptionPayService extends BaseService {
        log.setType("3");
        zyPushLogDao.save(log);
        //保存长处方日志  type=2易联众对接 flag =1成功 flag=0 0失败 userType 1 患者 2医生
        logService.saveHttpLog(isSuccess, config.getRecipeChargeType(), "长处方结算", "POST", null, msgBody, response, error, logService.onepayType);
        //logService.saveHttpLog(isSuccess, config.getRecipeChargeType(), "长处方结算", "POST", null, msgBody, response, error, logService.onepayType);
        payLogService.addLog(prescription, PrescriptionLog.PrescriptionLogType.pay.getValue(), flag, 1);
        if (!isSuccess) {
            throw new Exception(error);
@ -1182,6 +1199,8 @@ public class PatientPrescriptionPayService extends BaseService {
     * 家庭医生签约支付查询
     */
    public String chargeQuery(String code, String accessToken) throws Exception {
        PayConfigura config = configuraDao.findWorkConfigura();
        int flag = 0;
        Boolean isSuccess = true;
        String msgBody = "";
@ -1340,7 +1359,7 @@ public class PatientPrescriptionPayService extends BaseService {
        log.setStatus(Integer.toString(flag));
        log.setType("3");
        zyPushLogDao.save(log);
        logService.saveHttpLog(isSuccess, config.getChargeQueryType(), "长处方支付查询", "POST", null, msgBody, response, error, logService.onepayType);
//        logService.saveHttpLog(isSuccess, config.getChargeQueryType(), "长处方支付查询", "POST", null, msgBody, response, error, logService.onepayType);
        if (!isSuccess) {
            throw new Exception(error);
        }

+ 0 - 129
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/common/Configure.java

@ -1,129 +0,0 @@
package com.yihu.wlyy.service.weixin.wxpay.common;
import org.springframework.context.annotation.Configuration;
/**
 * User: hzp
 * Date: 20170518
 * 这里放置各种配置数据
 */
@Configuration
public class Configure {
	/******************************* 易联众统一支付平台 ***********************************************************/
//	private String onepayApi = "http://120.42.37.94:1301/onepay-web/";
//	private String onepayAppId = "1BGKM1UHM03P7B2CA8C000005626EB0E";
//	private String onepayAppSecret = "1BGKM1UHM03I7B2CA8C00000AB682E9A";
//			开发环境应用信息
//	private String onepayApi = "https://xmhealth.ylzpay.com:8080/";
	private String onepayApi = "http://xmhealth.ylzpay.com:8070/";
	private String onepayAppId = "1BLF5SEGN00087165F0A000027362BE5";
	private String onepayAppSecret = "1BLF5SCBO01V3E78A8C00000F3A0FFE7";
	private String bindCardType = "onepay.sicard.bind.info";
	private String chargeType = "onepay.trade.medical.charge";
	private String chargeQueryType = "onepay.trade.medical.charge.query";
	private String createSicardType = "onepay.sicard.createurl";
//	易联众异步回调
	private String receiveNotify = "wlyy.onepay.receiveNotify";
	private String returnUrl = "wlyy.onepay.returnUrl";
//  长处方系列
	private String recipeChargeType = "onepay.trade.long.recipe.charge";
	private String recipeReturnUrl = "wlyy.patient.prescription.pay.recipeReturnUrl";
	private String receiveRecipeNotify = "wlyy.patient.prescription.pay.receiveRecipeNotify";
	public String getRecipeChargeType() {
		return recipeChargeType;
	}
	public void setRecipeChargeType(String recipeChargeType) {
		this.recipeChargeType = recipeChargeType;
	}
	public String getRecipeReturnUrl() {
		return recipeReturnUrl;
	}
	public void setRecipeReturnUrl(String recipeReturnUrl) {
		this.recipeReturnUrl = recipeReturnUrl;
	}
	public String getReceiveRecipeNotify() {
		return receiveRecipeNotify;
	}
	public void setReceiveRecipeNotify(String receiveRecipeNotify) {
		this.receiveRecipeNotify = receiveRecipeNotify;
	}
	public String getReturnUrl() {
		return returnUrl;
	}
	public void setReturnUrl(String returnUrl) {
		this.returnUrl = returnUrl;
	}
	public String getReceiveNotify() {
		return receiveNotify;
	}
	public void setReceiveNotify(String receiveNotify) {
		this.receiveNotify = receiveNotify;
	}
	public String getOnepayApi() {
		return onepayApi;
	}
	public String getOnepayAppId() {
		return onepayAppId;
	}
	public String getOnepayAppSecret() {
		return onepayAppSecret;
	}
	public String getBindCardType() {
		return bindCardType;
	}
	public String getChargeType() {
		return chargeType;
	}
	public String getChargeQueryType() {
		return chargeQueryType;
	}
	public String getCreateSicardType() {
		return createSicardType;
	}
	/******************* 微信社保支付配置 ******************************************/
	//这个就是自己要保管好的私有Key了(切记只能放在自己的后台代码里,不能放在任何可能被看到源代码的客户端程序中)
	// 每次自己Post数据给API的时候都要用这个key来对所有字段进行签名,生成的签名会放在Sign这个字段,API收到Post数据的时候也会用同样的签名算法对Post过来的数据进行签名和验证
	// 收到API的返回的时候也要用这个key来对返回的数据算下签名,跟API的Sign数据进行比较,如果值不一致,有可能数据被第三方给篡改
	private String key = "2935b54b53a957d9516c920a544f2537";
	//微信分配的公众号ID(开通公众号之后可以获取到)
	private String appID = "wxd03f859efdf0873d";
	public String getKey(){
		return key;
	}
	public String getAppid(){
		return appID;
	}
	//获取token地址
	public String TOKEN_API = "https://api.weixin.qq.com/payinsurance/gettoken";
	//挂号/诊间支付统一下单 API 接口
	public String ORDER_API = "https://api.weixin.qq.com/payinsurance/unifiedorder?access_token ACCESS_TOKEN";
}

+ 114 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java

@ -9,13 +9,14 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.service.third.httplog.LogService;
import com.yihu.wlyy.service.weixin.wxpay.common.Configure;
import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
import com.yihu.wlyy.service.weixin.wxpay.model.Charge;
import com.yihu.wlyy.util.SystemConf;
@ -24,7 +25,6 @@ import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
import com.ylzinfo.onepay.sdk.utils.DateUtil;
import io.swagger.models.auth.In;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -47,7 +47,7 @@ import java.util.*;
public class OnePayService {
    @Autowired
    private Configure config;
    private PayConfiguraDao configuraDao;
    @Autowired
    private LogService logService;
@ -137,6 +137,7 @@ public class OnePayService {
        String error = "";
        List<BindCard> result = new ArrayList<BindCard>();
        PayConfigura config = configuraDao.findWorkConfigura();
        String appId = config.getOnepayAppId();
        String appSecret = config.getOnepayAppSecret();
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), appId, appSecret, signType, encryptType);
@ -218,6 +219,7 @@ public class OnePayService {
        String result = "";
        String channel = "WX_MMP";   //  医保支付渠道
        String subject = "家庭医生签约支付";   //  订单名称
        PayConfigura config = configuraDao.findWorkConfigura();
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), appId, appSecret, signType, encryptType);
//     未真正完成支付以前预存储支付信息到wlyy_charge表
@ -326,6 +328,8 @@ public class OnePayService {
            Map<String, String> map = new HashMap<>();
            map.put("feeType", "04");//家庭医生签约
            map.put("settleType", "03"); //健康账户支付
            //易联众新增字段v1.3.7
            map.put("principalCardNo", ssc); //实际签约卡号( 默认为绑卡主体卡号)
            params.put("requestContent", objectMapper.writeValueAsString(map));// 请求结构体
            requestParams.setParam(params);
            msgBody = JSON.toJSONString(requestParams);
@ -373,6 +377,7 @@ public class OnePayService {
        String response = "";
        String error = "";
        String result = null;
        PayConfigura config = configuraDao.findWorkConfigura();
        WlyyCharge charge = chargeDao.findByCode(code);
        HospitalMapping hospitalMapping = hospitalMappingDao.findByCode(charge.getHospital());
@ -408,7 +413,109 @@ public class OnePayService {
//                result = JSON.toJavaObject(res.getParam(), Charge.class);
                result = JSON.toJSONString(res.getParam());
//                 返回医保机构体
//                 新增保存数据
                JSONObject request = JSON.parseObject(result);
//                String tradeStatus = request.getString("tradeStatus");//交易状态
                String chargeStatus = request.getString("chargeStatus");//交易状态
                String chargeNo = request.getString("chargeNo");//支付平台流水号
                String chargeTime = request.getString("chargeTime");//支付平台交易成功时间
                String outChargeNo = request.getString("outChargeNo");//接入应用业务流水号
                String outChargeTime = request.getString("outChargeTime");//接入应用时间
                String medOrgNo = request.getString("medOrgNo");//医疗机构编号
                String medOrgName = request.getString("medOrgName");//医疗机构名称
                String billNo = request.getString("billNo");//待结算费用单据号
                String cardNo = request.getString("cardNo");//医保卡号
                String totalAmount = request.getString("totalAmount");//交易总金额
                String insuranceAmount = request.getString("insuranceAmount");//医保支付金额
                String selfPayAmount = request.getString("selfPayAmount");//自付金额
                String userId = request.getString("userId");//用户openID
                String userName = request.getString("userName");//用户名字
                String idNo = request.getString("idNo");//证件号码
                String idType = request.getString("idType");//证件类型
//                String appId = request.getString("appId");
//                String channel = request.getString("channel");//支付方式
//                String sign = request.getString("sign");
//                String signType = request.getString("signType");
//                String timestamp = request.getString("timestamp");
                JSONObject responseContents = request.getJSONObject("responseContent");//医保结构体
                WlyyCharge prescriptionPay = chargeDao.findByCode(outChargeNo);
                if (responseContents != null) {
                    String miRegisterNo = responseContents.getString("miRegisterNo");//医保挂号
                    String miCollectDate = responseContents.getString("miCollectDate");//收费日期
                    String miCollectTime = responseContents.getString("miCollectTime");//收费时间
                    String miSettleNo = responseContents.getString("miSettleNo");//医保收费单据号 (医保签约号)
                    String miCollectStatus = responseContents.getString("miCollectStatus");//扣费状态
                    String miRegisterStatus = responseContents.getString("miRegisterStatus");//登记状态
                    String cadresPay = responseContents.getString("cadresPay");//公务员补助
                    String miTotalFee = responseContents.getString("miTotalFee");//本次报销总额
                    String healthCarePay = responseContents.getString("healthCarePay");//保健基金支付
                    String heathPay = responseContents.getString("heathPay");//健康账户支付
                    String accountPay = responseContents.getString("accountPay");//个人账户支付
                    String selfPay = responseContents.getString("selfPay");//个人现金支付
                    String civilPay = responseContents.getString("civilPay");//民政补助金额
                    /*String miCollectorName = responseContents.getString("miCollectorName");//收费人姓名
                    String fundPay = responseContents.getString("fundPay");//基金支付
                    String commercePay = responseContents.getString("commercePay");//商业保险支付
                    String familyPay = responseContents.getString("familyPay");//共济账户支付
                    String civilZone = responseContents.getString("civilZone");//民政行政区号
                    String bdrugPay = responseContents.getString("bdrugPay");//乙类支付金额
                    String unlessAmount = responseContents.getString("unlessAmount");//非医保费用
                    String exceedAmount = responseContents.getString("exceedAmount");//超封顶线金额
                    String accountBalance = responseContents.getString("accountBalance");//个人账户余额
                    String healthBalance = responseContents.getString("healthBalance");//健康账户余额*/
                    prescriptionPay.setMiRegisterNo(miRegisterNo);//医保挂号
                    /*prescriptionPay.setMiSettleNo(miSettleNo);//医保收费单据号
                    SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMdd");
                    prescriptionPay.setMiCollectDate(formatDate.parse(miCollectDate));//收费日期
                    SimpleDateFormat formatTime = new SimpleDateFormat("HHmm");
                    prescriptionPay.setMiCollectTime(formatTime.parse(miCollectTime));//收费时间
                    prescriptionPay.setMiCollectorName(miCollectorName);//收费人姓名
                    prescriptionPay.setMiTotalFee(Integer.parseInt(miTotalFee));//本次报销总额
                    prescriptionPay.setSelfPay(Integer.parseInt(selfPay));//个人现金支付
                    prescriptionPay.setAccountPay(Integer.parseInt(accountPay));//个人账户支付
                    prescriptionPay.setHeathPay(Integer.parseInt(heathPay));//健康账户支付
                    prescriptionPay.setCadresPay(Integer.parseInt(cadresPay));//公务员补助
                    prescriptionPay.setFundPay(Integer.parseInt(fundPay));//基金支付
                    prescriptionPay.setHealthCarePay(Integer.parseInt(healthCarePay));//保健基金支付
                    prescriptionPay.setCommercePay(Integer.parseInt(commercePay));//商业保险支付
                    prescriptionPay.setFamilyPay(Integer.parseInt(familyPay));//共济账户支付
                    prescriptionPay.setCivilPay(Integer.parseInt(civilPay));//民政补助金额
                    prescriptionPay.setCivilZone(civilZone);//民政行政区号
                    prescriptionPay.setBdrugPay(Integer.parseInt(bdrugPay));//乙类支付金额
                    prescriptionPay.setUnlessAmount(Integer.parseInt(unlessAmount));//非医保费用
                    prescriptionPay.setExceedAmount(Integer.parseInt(exceedAmount));//超封顶线金额
                    prescriptionPay.setAccountBalance(Integer.parseInt(accountBalance));//个人账户余额
                    prescriptionPay.setHealthBalance(Integer.parseInt(healthBalance));//健康账户余额*/
                }
                if ("0".equals(chargeStatus) || "SUCCESS".equals(chargeStatus)) {
                    prescriptionPay.setTradeStatus("1");//交易状态 成功1 失败0
                }else {
                    prescriptionPay.setTradeStatus("0");//交易状态 成功1 失败0
                }
                prescriptionPay.setChargeNo(chargeNo);//支付流水号
                SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
                prescriptionPay.setChargeTime(chargeTime);//支付平台交易成功时间
//                prescriptionPay.setOutChargeTime(formatDate.parse(outChargeTime));//接入应用内业务时间
                prescriptionPay.setMedOrgNo(medOrgNo);//医疗机构编号
                prescriptionPay.setMedOrgName(medOrgName);//医疗机构名称
                prescriptionPay.setBillNo(billNo);//待结算费用单据号
                prescriptionPay.setSsc(cardNo);//医保卡号
                prescriptionPay.setTotalAmount(Integer.parseInt(totalAmount));//交易总金额
                prescriptionPay.setInsuranceAmount(Integer.parseInt(insuranceAmount));//医保支付金额
                prescriptionPay.setSelfpayAmount(Integer.parseInt(selfPayAmount));//自付金额
                prescriptionPay.setOpenid(userId);
                prescriptionPay.setName(userName);
                prescriptionPay.setIdType(idType);//证件类型
                prescriptionPay.setIdNo(idNo);//证件号码
                //        保存数据库更改记录
                chargeDao.save(prescriptionPay);
//                System.out.println("请求成功,返回参数:" + result.getTradeStatus() + "  " + result.getUserName());
                LOGGER.info("请求成功,返回参数: "+result);
@ -443,6 +550,7 @@ public class OnePayService {
        String response = "";
        String error = "";
        String result = "";
        PayConfigura config = configuraDao.findWorkConfigura();
        String appId = config.getOnepayAppId();
        String appSecret = config.getOnepayAppSecret();
@ -461,6 +569,8 @@ public class OnePayService {
            JSONObject params = new JSONObject();
            params.put("openId", openid);
            params.put("accId", accId);  //微信公众号开发者ID
//           易联众新增字段代支付v1.3.7
            params.put("createType", "sicard");  //生成类型 sicard 个人电子社保卡 OR family 家庭成员绑卡 ( 默认 sicard)
            requestParams.setParam(params);
            requestParams.setTransType(config.getCreateSicardType());

+ 5 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

@ -4,12 +4,13 @@ import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.charge.WlyyCharge;
import com.yihu.wlyy.entity.organization.HospitalMapping;
import com.yihu.wlyy.entity.ylz.PayConfigura;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.organization.HospitalMappingDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.ylz.PayConfiguraDao;
import com.yihu.wlyy.service.third.httplog.LogService;
import com.yihu.wlyy.service.weixin.wxpay.common.Configure;
import com.yihu.wlyy.service.weixin.wxpay.model.BindCard;
import com.yihu.wlyy.service.weixin.wxpay.model.Charge;
import com.yihu.wlyy.service.weixin.wxpay.service.OnePayService;
@ -69,7 +70,7 @@ public class OnePayController extends WeixinBaseController {
    @Autowired
    LogService logService;
    @Autowired
    private Configure config;
    private PayConfiguraDao configuraDao;
    @Autowired
    private HospitalMappingDao mappingDao;
    @Autowired
@ -262,6 +263,7 @@ public class OnePayController extends WeixinBaseController {
     */
    @RequestMapping(value = "/returnUrl")
    public void returnUrl(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        PayConfigura config = configuraDao.findWorkConfigura();
        Boolean isSuccess = false;
        String error = "";
        String responses = "";
@ -347,6 +349,7 @@ public class OnePayController extends WeixinBaseController {
     */
    @RequestMapping(value = "/receiveNotify")
    public void receiveNotify(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        PayConfigura config = configuraDao.findWorkConfigura();
        Boolean isSuccess = false;
        String error = "";
        String responses = "";