Explorar o código

统一支付功能

hzp %!s(int64=7) %!d(string=hai) anos
pai
achega
e6327d91b8

+ 237 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/charge/WlyyCharge.java

@ -0,0 +1,237 @@
package com.yihu.wlyy.entity.charge;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * 扣费记录
 * @author hzp
 */
@Entity
@Table(name = "wlyy_charge")
public class WlyyCharge extends IdEntity {
	private String signCode;   //签约代码
	private String code;   //  接入应用支付业务流水号
	private Date createTime;   //  接入应用内支付时间
	private String patient;   //  用户
	private String openid;   //  用戶微信openid
	private String ssc;   // 医保卡号
	private String name;   //  姓名
	private String idType;   //  证件类型
	private String idNo;   //  证件号码
	private String hospital;   //  机构代码
	private String hospitalName;   //  机构名称
	private Integer totalAmount;   //  交易总金额
	private Integer selfpayAmount;   //  自费金额
	private Integer insuranceAmount;   //  医保支付金额
	private Integer feeDetail;   //  费用明细
	private String channel;   //  医保支付渠道
	private String merchName;   //  收款单位名称
	private String subject;   //  订单名称
	private String tradeStatus;   //  交易状态0 成功 1 失败 2 已退款
	private String chargeNo;   //  流水号
	private Date chargeTime;   // 扣费时间
	private String medOrgNo;   //  医疗机构编码
	private String medOrgName;   //  医疗机构名称
	private String billNo;   //  待结算费用单据号
	public String getSignCode() {
		return signCode;
	}
	public void setSignCode(String signCode) {
		this.signCode = signCode;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	@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;
	}
	public String getPatient() {
		return patient;
	}
	public void setPatient(String patient) {
		this.patient = patient;
	}
	public String getOpenid() {
		return openid;
	}
	public void setOpenid(String openid) {
		this.openid = openid;
	}
	public String getSsc() {
		return ssc;
	}
	public void setSsc(String ssc) {
		this.ssc = ssc;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getIdType() {
		return idType;
	}
	public void setIdType(String idType) {
		this.idType = idType;
	}
	public String getIdNo() {
		return idNo;
	}
	public void setIdNo(String idNo) {
		this.idNo = idNo;
	}
	public String getHospital() {
		return hospital;
	}
	public void setHospital(String hospital) {
		this.hospital = hospital;
	}
	public String getHospitalName() {
		return hospitalName;
	}
	public void setHospitalName(String hospitalName) {
		this.hospitalName = hospitalName;
	}
	public Integer getTotalAmount() {
		return totalAmount;
	}
	public void setTotalAmount(Integer totalAmount) {
		this.totalAmount = totalAmount;
	}
	public Integer getSelfpayAmount() {
		return selfpayAmount;
	}
	public void setSelfpayAmount(Integer selfpayAmount) {
		this.selfpayAmount = selfpayAmount;
	}
	public Integer getInsuranceAmount() {
		return insuranceAmount;
	}
	public void setInsuranceAmount(Integer insuranceAmount) {
		this.insuranceAmount = insuranceAmount;
	}
	public Integer getFeeDetail() {
		return feeDetail;
	}
	public void setFeeDetail(Integer feeDetail) {
		this.feeDetail = feeDetail;
	}
	public String getChannel() {
		return channel;
	}
	public void setChannel(String channel) {
		this.channel = channel;
	}
	public String getMerchName() {
		return merchName;
	}
	public void setMerchName(String merchName) {
		this.merchName = merchName;
	}
	public String getSubject() {
		return subject;
	}
	public void setSubject(String subject) {
		this.subject = subject;
	}
	public String getTradeStatus() {
		return tradeStatus;
	}
	public void setTradeStatus(String tradeStatus) {
		this.tradeStatus = tradeStatus;
	}
	public String getChargeNo() {
		return chargeNo;
	}
	public void setChargeNo(String chargeNo) {
		this.chargeNo = chargeNo;
	}
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getChargeTime() {
		return chargeTime;
	}
	public void setChargeTime(Date chargeTime) {
		this.chargeTime = chargeTime;
	}
	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 String getBillNo() {
		return billNo;
	}
	public void setBillNo(String billNo) {
		this.billNo = billNo;
	}
}

+ 15 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/charge/ChargeDao.java

@ -0,0 +1,15 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.wlyy.repository.charge;
import com.yihu.wlyy.entity.charge.WlyyCharge;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface ChargeDao extends PagingAndSortingRepository<WlyyCharge, Long>, JpaSpecificationExecutor<WlyyCharge> {
	
}

+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwArchivesService.java

@ -778,6 +778,8 @@ public class JwArchivesService {
        }
    }
    /**
     * 上传随访记录接口
     */

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

@ -18,6 +18,7 @@ public class Configure {
	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 = "";
	public String getOnepayApi() {
		return onepayApi;
@ -41,6 +42,10 @@ public class Configure {
		return chargeQueryType;
	}
	public String getCreateSicardType() {
		return createSicardType;
	}
	/******************* 微信社保支付配置 ******************************************/
	//这个就是自己要保管好的私有Key了(切记只能放在自己的后台代码里,不能放在任何可能被看到源代码的客户端程序中)
	// 每次自己Post数据给API的时候都要用这个key来对所有字段进行签名,生成的签名会放在Sign这个字段,API收到Post数据的时候也会用同样的签名算法对Post过来的数据进行签名和验证

+ 21 - 28
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/model/Charge.java

@ -6,10 +6,10 @@ package com.yihu.wlyy.service.weixin.wxpay.model;
 */
public class Charge {
    private String tradeStatus; //交易状态    0 成功 1 失败  2 已退款
    private String settleNo;  //医保业务流水号
    private String settleTime;  //  医保交易成功时间
    private String outSettleNo;  //  接入应用业务流水号
    private String outSettleTime;  //  接入应用内业务时间
    private String chargeNo;  //医保业务流水号
    private String chargeTime;  //  医保交易成功时间
    private String outChargeNo;  //  接入应用业务流水号
    private String outChargeTime;  //  接入应用内业务时间
    private String medOrgNo;  //  医疗机构编号
    private String medOrgName;  //  医疗机构名称
    private String billNo;  //  待结算费用单据号
@ -21,7 +21,7 @@ public class Charge {
    private String userName;  // 用户姓名
    private String idType;  // 证件号码
    private String idNo;  // 证件类型
    private String responseContent;  //扣费详情
    //private String responseContent;  //扣费详情
    public String getTradeStatus() {
        return tradeStatus;
@ -31,36 +31,36 @@ public class Charge {
        this.tradeStatus = tradeStatus;
    }
    public String getSettleNo() {
        return settleNo;
    public String getChargeNo() {
        return chargeNo;
    }
    public void setSettleNo(String settleNo) {
        this.settleNo = settleNo;
    public void setChargeNo(String chargeNo) {
        this.chargeNo = chargeNo;
    }
    public String getSettleTime() {
        return settleTime;
    public String getChargeTime() {
        return chargeTime;
    }
    public void setSettleTime(String settleTime) {
        this.settleTime = settleTime;
    public void setChargeTime(String chargeTime) {
        this.chargeTime = chargeTime;
    }
    public String getOutSettleNo() {
        return outSettleNo;
    public String getOutChargeNo() {
        return outChargeNo;
    }
    public void setOutSettleNo(String outSettleNo) {
        this.outSettleNo = outSettleNo;
    public void setOutChargeNo(String outChargeNo) {
        this.outChargeNo = outChargeNo;
    }
    public String getOutSettleTime() {
        return outSettleTime;
    public String getOutChargeTime() {
        return outChargeTime;
    }
    public void setOutSettleTime(String outSettleTime) {
        this.outSettleTime = outSettleTime;
    public void setOutChargeTime(String outChargeTime) {
        this.outChargeTime = outChargeTime;
    }
    public String getMedOrgNo() {
@ -151,11 +151,4 @@ public class Charge {
        this.idNo = idNo;
    }
    public String getResponseContent() {
        return responseContent;
    }
    public void setResponseContent(String responseContent) {
        this.responseContent = responseContent;
    }
}

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

@ -2,12 +2,18 @@ package com.yihu.wlyy.service.weixin.wxpay.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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.patient.Patient;
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.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;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.domain.RequestParams;
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
@ -17,6 +23,11 @@ import org.springframework.stereotype.Service;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
 * 易联众统一支付服务类
@ -37,10 +48,42 @@ public class OnePayService {
    @Autowired
    private HospitalMappingDao hospitalMappingDao;
    @Autowired
    ObjectMapper objectMapper;
    @Autowired
    ChargeDao chargeDao;
    @Autowired
    PatientDao patientDao;
    /**
     *  查询绑卡信息
     */
    public BindCard bindCard(String patient,String openid)  throws Exception
    {
        BindCard card = bindCard(openid);
        //更新患者信息
        if(card!=null)
        {
            Patient p = patientDao.findByCode(patient);
            p.setOpenid(openid);
            p.setSsc(card.getCardNo());
            if(card.getIdType()=="01")      //身份证
            {
                p.setIdcard(card.getIdNo());
            }
            p.setName(card.getUserName());
            patientDao.save(p);
        }
        return card;
    }
    /**
     * 查询绑卡信息
     */
    public BindCard bindCard(String openid) throws Exception
    private BindCard bindCard(String openid) throws Exception
    {
        Boolean isSuccess = true;
        String msgBody = "";
@ -64,11 +107,12 @@ public class OnePayService {
            // 如医保绑卡信息请求参数
            JSONObject params = new JSONObject();
            params.put("userId", openid);
            params.put("accId", SystemConf.getInstance().getAppId());  //微信公众号开发者ID
            requestParams.setParam(params);
            requestParams.setTransType(config.getBindCardType());
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            msgBody =  JSON.toJSONString(requestParams);
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            response =  JSON.toJSONString(res);
            // 如医保卡绑卡信息返回参数
@ -106,7 +150,7 @@ public class OnePayService {
    /**
     * 家庭医生签约支付
     */
    public String charge(String orgCode,String code,String date,String cardNo,String openid) throws Exception
    public String charge(String orgCode,String signCode,String patient,String openid) throws Exception
    {
        //获取机构映射
        HospitalMapping hos = hospitalMappingDao.findByCode(orgCode);
@ -115,60 +159,106 @@ public class OnePayService {
            throw new Exception("no hospital mapping!");
        }
        return charge(hos.getAppId(), hos.getAppSecret(), code, date, cardNo, openid);
        return charge(orgCode,hos.getName(),hos.getAppId(), hos.getAppSecret(), signCode,patient,openid);
    }
    /**
     * 家庭医生签约支付
     * 家庭医生签约支付,成功则返回支付路径
     */
    public String charge(String appId,String appSecret,String code,String date,String cardNo,String openid) throws Exception
    private String charge(String orgCode,String orgName,String appId,String appSecret,String signCode,String patient,String openid) throws Exception
    {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        String result = "";
        String channel = "WX_MMP";   //  医保支付渠道
        String subject = "家庭医生签约支付";   //  订单名称
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(),appId, appSecret, signType, encryptType);
        WlyyCharge charge = new WlyyCharge();
        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
        charge.setSignCode(signCode);    //签约代码
        charge.setCode(uuid);  //  接入应用支付业务流水号
        Date now = new Date();
        charge.setCreateTime(now);
        charge.setPatient(patient);     //  用户
        charge.setOpenid(openid);     //  用戶微信openid
        try {
            BindCard card= bindCard(openid);
            String name = card.getUserName();
            String ssc = card.getCardNo();
            String idType = card.getIdType();
            String idNo = card.getIdNo();
            charge.setName(name);
            charge.setIdType(idType);
            charge.setIdNo(idNo);
            charge.setHospital(orgCode);
            charge.setHospitalName(orgName);
            charge.setChannel(channel);
            charge.setMerchName(orgName);
            charge.setSubject(subject);
            /*private Integer totalAmount;   //  交易总金额
            private Integer selfpayAmount;   //  自费金额
            private Integer insuranceAmount;   //  医保支付金额
            private Integer feeDetail;   //  费用明细*/
            SimpleDateFormat formatter =   new SimpleDateFormat("yyyyMMddHHmmss");
            String currentDateTime = formatter.format(now);
            RequestParams requestParams = new RequestParams();
            requestParams.setAppId(appId);
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());
            requestParams.setTimestamp(currentDateTime);
            requestParams.setSignType(signType);
            requestParams.setEncryptType(encryptType);
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());
            requestParams.setTransType(config.getChargeType());
            //业务参数
            JSONObject params = new JSONObject();
            params.put("outSettleNo",code);  //接入应用结算业务流水号
            params.put("outSettleTime",date);    //接入应用内结算时间
            params.put("outChargeNo",uuid);  //接入应用结算业务流水号
            params.put("outChargeTime",currentDateTime);    //接入应用内结算时间
            params.put("userId",openid);   //用户 ID
            params.put("cardNo",cardNo);   //医保卡号"D64775061"
            params.put("cardNo",ssc);   //医保卡号"D64775061"
            //获取绑卡信息
            params.put("userName",name);
            params.put("idType",idType);
            params.put("idNo",idNo);
            params.put("totalAmount","1");   //交易总金额
            params.put("selfpayAmount","0");   //自费金额
            params.put("insuranceAmount","1");   //医保支付金额
            params.put("returnUrl","http://");   //页面跳转地址
            params.put("feeDetail","{\"itemName\":\"家庭医生签约支付\",\"itemDesc\":\"家庭医生签约支付\",\"itemOrigPrice\":\"120\",\"itemNowPrice\":\"120\",\"itemNum\":\"1\",\"itemTotalAmt\":\"120\"}");   //费用明细
            params.put("channel","WX_MMP");  //微信医保支付
            //extendParams 扩展入参
            //requestContent 请求结构体
            params.put("returnUrl","https://mp.weixin.qq.com/insurance/pay/detail");   //页面跳转地址
            params.put("feeDetail","[{\"itemName\":\"家庭医生签约支付\",\"itemDesc\":\"家庭医生签约支付\",\"itemOrigPrice\":\"1\",\"itemNowPrice\":\"1\",\"itemNum\":\"1\",\"itemTotalAmt\":\"1\"}]");   //费用明细
            params.put("channel",channel);  //微信医保支付
            params.put("merchName",orgName);  //收款单位名称
            params.put("subject",subject);  //订单名称
            //params.put("wxToken","");
            //extendParams 扩展入参
            Map<String,String> map = new HashMap<>();
            map.put("feeType","04");//家庭医生签约
            map.put("settleType","02"); //健康账户支付
            params.put("requestContent",objectMapper.writeValueAsString(map));// 请求结构体
            requestParams.setParam(params);
            msgBody =  JSON.toJSONString(requestParams);
            //执行支付
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            msgBody =  JSON.toJSONString(requestParams);
            response =  JSON.toJSONString(res);
            if (OnepayDefaultClient.isSuccessful(res)) {
                JSONObject json = res.getParam();
                result = String.valueOf(json.get("settleNo"));      //医保结算业务流水号
                String payUrl =  String.valueOf(json.get("payUrl"));
                //业务处理***********
                String chargeNo = String.valueOf(json.get("chargeNo"));      //医保结算业务流水号
                result =  String.valueOf(json.get("payUrl"));
                charge.setTradeStatus("0");//交易状态0 成功 1 失败 2 已退款
                charge.setChargeNo(chargeNo);
            } else {
                charge.setTradeStatus("1");
                isSuccess = false;
                error = "请求失败,返回结果:" + res.getRespCode() + "," + res.getRespMsg();
            }
@ -180,6 +270,8 @@ public class OnePayService {
            error = sw.toString();
        }
        //保存交易记录
        chargeDao.save(charge);
        //保存http日志
        logService.saveHttpLog(isSuccess,config.getChargeType(),"家庭医生签约支付","POST",null,msgBody,response,error,logService.onepayType);
@ -217,12 +309,12 @@ public class OnePayService {
            //业务参数
            JSONObject params = new JSONObject();
            params.put("outSettleNo",code);  //接入应用结算业务流水号
            params.put("settleNo","");
            params.put("outChargeNo",code);  //接入应用结算业务流水号
            requestParams.setParam(params);
            msgBody =  JSON.toJSONString(requestParams);
            //执行支付
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            msgBody =  JSON.toJSONString(requestParams);
            response =  JSON.toJSONString(res);
            if (OnepayDefaultClient.isSuccessful(res)) {
@ -244,7 +336,71 @@ public class OnePayService {
        }
        //保存http日志
        logService.saveHttpLog(isSuccess,config.getChargeType(),"家庭医生签约支付","POST",null,msgBody,response,error,logService.onepayType);
        logService.saveHttpLog(isSuccess,config.getChargeType(),"家庭医生签约支付查询","POST",null,msgBody,response,error,logService.onepayType);
        if(!isSuccess)
        {
            throw new Exception(error);
        }
        return result;
    }
    /**
     * 生成电子社保卡
     */
    public String createSicard(String patient,String openid) throws Exception
    {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        String result = "";
        String appId = config.getOnepayAppId();
        String appSecret = config.getOnepayAppSecret();
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(),appId, appSecret, signType, encryptType);
        try {
            RequestParams requestParams = new RequestParams();
            requestParams.setAppId(appId);
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());
            requestParams.setSignType(signType);
            requestParams.setEncryptType(encryptType);
            requestParams.setTimestamp(DateUtil.getCurrentDateTime());
            // 请求报文体参数,详见接口文档各接口——请求参数定义
            // 如医保绑卡信息请求参数
            JSONObject params = new JSONObject();
            params.put("userId", openid);
            params.put("accId", SystemConf.getInstance().getAppId());  //微信公众号开发者ID
            requestParams.setParam(params);
            requestParams.setTransType(config.getCreateSicardType());
            msgBody =  JSON.toJSONString(requestParams);
            ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
            response =  JSON.toJSONString(res);
            // 如医保卡绑卡信息返回参数
            if (OnepayDefaultClient.isSuccessful(res)) {
                JSONObject json = res.getParam();
                result = String.valueOf(json.get("sicardUrl"));      //电子社保卡连接
            }
            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();
        }
        //保存http日志
        logService.saveHttpLog(isSuccess,config.getBindCardType(),"生成电子社保卡","POST",null,msgBody,response,error,logService.onepayType);
        if(!isSuccess)
        {

+ 117 - 9
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

@ -4,6 +4,9 @@ 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.web.WeixinBaseController;
import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
import com.ylzinfo.onepay.sdk.exception.PayException;
import com.ylzinfo.onepay.sdk.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -15,6 +18,13 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by hzp on 2017/05/23.
 */
@ -32,7 +42,7 @@ public class OnePayController extends WeixinBaseController {
    @ResponseBody
    public String bindCard() throws Exception {
        try {
            BindCard bindCard = pay.bindCard(getOpenid());         //oULM4xOARzTFqr9y1aTWuzCQdUL0
            BindCard bindCard = pay.bindCard("patient","ohNH9sh4uwuJCxIwcLJtGTX-BaSk");         //ohNH9sh4uwuJCxIwcLJtGTX-BaSk  //o4Ma2t5665rS7uNfA9EF-VnOJx30      getUID()getOpenid()
            return write(200, "查询绑卡信息成功!","data",bindCard);
        }
        catch (Exception e)
@ -47,14 +57,10 @@ public class OnePayController extends WeixinBaseController {
    public String charge(
                         @ApiParam(name="orgCode",value="医疗机构编号",defaultValue = "3502050300")
                         @RequestParam String orgCode,
                         @ApiParam(name="code",value="签约代码",defaultValue = "044701ea5b2311e68344fa163e8aee56")
                         @RequestParam String code,
                         @ApiParam(name="date",value="签约付款时间yyyyMMddHHmmss",defaultValue = "20170523172400")
                         @RequestParam String date,
                         @ApiParam(name="cardNo",value="社保卡号",defaultValue = "DC0261911")
                         @RequestParam String cardNo) throws Exception {
                         @ApiParam(name="signCode",value="签约代码",defaultValue = "044701ea5b2311e68344fa163e8aee56")
                         @RequestParam String signCode) throws Exception {
        try {
            String settleNo = pay.charge(orgCode,code,date,cardNo,getOpenid());  //"oULM4xOARzTFqr9y1aTWuzCQdUL0"
            String settleNo = pay.charge(orgCode,signCode,"patient","ohNH9sh4uwuJCxIwcLJtGTX-BaSk");  //ohNH9sh4uwuJCxIwcLJtGTX-BaSk    getUID(),getOpenid()
            return write(200, "家庭医生签约支付成功!","data",settleNo);
        }
        catch (Exception e)
@ -67,7 +73,7 @@ public class OnePayController extends WeixinBaseController {
    @RequestMapping(value = "chargeQuery", method = RequestMethod.POST)
    @ApiOperation("家庭医生签约支付查询")
    @ResponseBody
    public String chargeQuery(@ApiParam(name="code",value="签约代码",defaultValue = "20170523172835")
    public String chargeQuery(@ApiParam(name="code",value="支付流水号",defaultValue = "")
                               @RequestParam String code) throws Exception {
        try {
            Charge charge = pay.chargeQuery(code);
@ -79,5 +85,107 @@ public class OnePayController extends WeixinBaseController {
        }
    }
    @RequestMapping(value = "createSicard", method = RequestMethod.POST)
    @ApiOperation("生成电子社保卡")
    @ResponseBody
    public String createSicard() throws Exception {
        try {
            String sicardUrl = pay.createSicard("patient","ohNH9sh4uwuJCxIwcLJtGTX-BaSk");         //ohNH9sh4uwuJCxIwcLJtGTX-BaSk  //o4Ma2t5665rS7uNfA9EF-VnOJx30  getUID(),getOpenid()
            return write(200, "生成电子社保卡成功!","data",sicardUrl);
        }
        catch (Exception e)
        {
            return error(-1, e.getMessage());
        }
    }
    /**
     * 解析URL参数串
     * @param formContext
     * @param wordFirstsplitRegex
     * @param wordSecondsplitRegex
     * @return
     */
    private 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;
    }
    /**
     * 转换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, "=", "&");
        } catch (Exception e) {
            throw new PayException("跳转参数处理异常," + reqQueryString);
        }
        return targetMap;
    }
    @RequestMapping(value = "/returnUrl", method = RequestMethod.GET)
    @ApiOperation("商户页面跳转(模拟测试)")
    public void testReturnUrl(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        response.setContentType("text/html;charset=utf-8");
        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"));
            if (isVerify) {
                response.getWriter().write("签名结果:\nSIGN SUCCESS.\n");
                // TODO 继续处理业务
                //		如:查询显示订单信息
            } else {
                response.getWriter().write("签名结果:\nSIGN ERROR !!!\n");
            }*/
        } catch (Exception e) {
            response.getWriter().write(e.getMessage());
        }
    }
}