Browse Source

在线支付修改

wujunjie 7 years ago
parent
commit
49be91ca20

+ 2 - 2
patient-co/patient-co-wlyy/pom.xml

@ -410,12 +410,12 @@
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
        <!--易联众支付-->
        <dependency>
            <groupId>com.ylz</groupId>
            <artifactId>onepay-java-sdk</artifactId>
            <artifactId>onpay-java-sdk-all</artifactId>
        </dependency>
    </dependencies>
    <build>
        <finalName>wlyy</finalName>

+ 9 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/entity/patient/SignFamily.java

@ -82,6 +82,15 @@ public class SignFamily extends IdEntity {
    private String sickVillage;
    // 居委会字段名称
    private String sickVillageName;
    private Integer signPaySource;//签约支付渠道: 1线下 2线上
    public Integer getSignPaySource() {
        return signPaySource;
    }
    public void setSignPaySource(Integer signPaySource) {
        this.signPaySource = signPaySource;
    }
    public String getRenewFlag() {
        return renewFlag;

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

@ -56,7 +56,7 @@ public interface ChargeDao extends PagingAndSortingRepository<WlyyCharge, Long>,
    @Modifying
    @Query("update WlyyCharge a set a.tradeStatus = ?9,a.chargeTime = ?2, a.updateTime = ?3, a.totalAmount = ?4, " +
            " a.insuranceAmount = ?5, a.selfpayAmount =?6 ,a.billNo = ?7, a.miRegisterNo = ?8 where a.code = ?1 ")
    WlyyCharge updateByChargeCode(String chargeCode, String chargeTime, Date updateTime, Integer totalAmount, Integer insuranceAmount, Integer selfPayAmount, String billNo, String miRegisterNo,String tradeStatus);
    int updateByChargeCode(String chargeCode, String chargeTime, Date updateTime, Integer totalAmount, Integer insuranceAmount, Integer selfPayAmount, String billNo, String miRegisterNo,String tradeStatus);
    List<WlyyCharge> findByPatient(String patient, Pageable pageRequest);
}

+ 3 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/organization/HospitalMappingDao.java

@ -24,5 +24,8 @@ public interface HospitalMappingDao extends PagingAndSortingRepository<HospitalM
	@Query("select a.code from HospitalMapping a where a.mappingCode=?1 and a.type=?2")
	String getCodeByMapping(String mappingCode,String type);
	@Query("select a from HospitalMapping a where a.appId=?1 ")
	HospitalMapping findByAppId(String appId);
	HospitalMapping findByCode(String code);
}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -408,8 +408,8 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    //      完成缴费后更新签约开始时间begin 缴费状态expensesStatus 医保流水号medical_insurance_num  扣费时间expenses_time
    @Modifying
    @Query("update SignFamily a set a.begin = ?2 ,a.medicalInsuranceNum=?3,a.expensesStatus = ?4,a.expensesTime = ?2 where a.code = ?1 ")
    int updatePatientBegin(String code, Date begin,String medicalInsuranceNum,String expensesStatus );
    @Query("update SignFamily a set a.begin = ?2 ,a.medicalInsuranceNum=?3,a.expensesStatus = ?4,a.expensesTime = ?2,a.signPaySource = ?5 where a.code = ?1 ")
    int updatePatientBegin(String code, Date begin,String medicalInsuranceNum,String expensesStatus,int signPaySource );
    //查询居民的扣费状态
    @Query( " select a from SignFamily a where a.patient = ?1 ")

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

@ -14,7 +14,8 @@ public class Configure {
//	private String onepayAppId = "1BGKM1UHM03P7B2CA8C000005626EB0E";
//	private String onepayAppSecret = "1BGKM1UHM03I7B2CA8C00000AB682E9A";
//			开发环境应用信息
	private String onepayApi = "https://xmhealth.ylzpay.com:8070/";
//	private String onepayApi = "https://xmhealth.ylzpay.com:8080/";
	private String onepayApi = "http://xmhealth.ylzpay.com:8070/";
	private String onepayAppId = "1BLF5SEGN00087165F0A000027362BE5";
	private String onepayAppSecret = "1BLF5SCBO01V3E78A8C00000F3A0FFE7";
@ -25,6 +26,15 @@ public class Configure {
	private String createSicardType = "onepay.sicard.createurl";
//	易联众异步回调
	private String receiveNotify = "wlyy.onepay.receiveNotify";
	private String returnUrl = "wlyy.onepay.returnUrl";
	public String getReturnUrl() {
		return returnUrl;
	}
	public void setReturnUrl(String returnUrl) {
		this.returnUrl = returnUrl;
	}
	public String getReceiveNotify() {
		return receiveNotify;

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

@ -19,11 +19,14 @@ 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.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;
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;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageRequest;
@ -71,6 +74,9 @@ public class OnePayService {
    @Value("${wechat.accId}")
    private String accId;
    Properties systemConf = SystemConf.getInstance().getSystemProperties();
    private static final Logger LOGGER = LoggerFactory.getLogger(OnePayController.class);
    /**
     * 查询绑卡信息(本人)
     */
@ -361,16 +367,13 @@ public class OnePayService {
    /**
     * 家庭医生签约支付查询
     */
    public Charge chargeQuery(String code, String accessToken) throws Exception {
    public String chargeQuery(String code, String accessToken) throws Exception {
        Boolean isSuccess = true;
        String msgBody = "";
        String response = "";
        String error = "";
        Charge result = null;
        String result = null;
//        String appId = config.getOnepayAppId();
//        String appSecret = config.getOnepayAppSecret();
//        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), appId, appSecret, signType, encryptType);
        WlyyCharge charge = chargeDao.findByCode(code);
        HospitalMapping hospitalMapping = hospitalMappingDao.findByCode(charge.getHospital());
        OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), hospitalMapping.getAppId(), hospitalMapping.getAppSecret(), signType, encryptType);
@ -400,12 +403,15 @@ public class OnePayService {
            response = JSON.toJSONString(res);
            if (OnepayDefaultClient.isSuccessful(res)) {
//                只返回业务出参  res.getResponseContent()返回医保机构体
                //业务处理*******************
//                只返回业务出参
                result = JSON.toJavaObject(res.getParam(), Charge.class);
//                result = JSON.toJavaObject(res.getParam(), Charge.class);
                result = JSON.toJSONString(res.getParam());
//                 返回医保机构体
                //业务处理*******************
                System.out.println("请求成功,返回参数:" + result.getTradeStatus() + "  " + result.getUserName());
//                System.out.println("请求成功,返回参数:" + result.getTradeStatus() + "  " + result.getUserName());
                LOGGER.info("请求成功,返回参数: "+result);
            } else {
                isSuccess = false;
                error = "请求失败,返回结果:" + res.getRespCode() + "," + res.getRespMsg();
@ -504,7 +510,9 @@ public class OnePayService {
        if (list != null && list.size() > 0) {
            for (WlyyCharge item : list) {
                try {
                    Charge charge = chargeQuery(item.getCode(), accessToken);
//                    Charge charge = chargeQuery(item.getCode(), accessToken);
                    String result = chargeQuery(item.getCode(), accessToken);
                    Charge charge = objectMapper.readValue(result, Charge.class);
                    if (charge != null) {
                        item.setTradeStatus(charge.getTradeStatus());            //  交易状态0 成功 1 失败 2 已退款
                        item.setChargeNo(charge.getChargeNo());       //  流水号
@ -549,14 +557,14 @@ public class OnePayService {
     * 更改数据 wlyy_sign_family wlyy_charge
     */
    public void updateData(String chargeCode, String chargeNo, String chargeTime, String totalAmount, String insuranceAmount, String selfPayAmount, String billNo, String miRegisterNo) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        Date chargeSuccess = sdf.parse(chargeTime);
        Date updateTime = new Date();
        chargeDao.updateByChargeCode(chargeCode, chargeTime, updateTime, Integer.parseInt(totalAmount), Integer.parseInt(insuranceAmount), Integer.parseInt(selfPayAmount),
                billNo, miRegisterNo, "0");
//        根据wlyy_charge的code 去查找关联代码signCode在更新签约表
        WlyyCharge charge = chargeDao.findByCode(chargeCode);
        signFamilyDao.updatePatientBegin(charge.getChargeRelation(), chargeSuccess, chargeNo, "1");
        signFamilyDao.updatePatientBegin(charge.getChargeRelation(), chargeSuccess, chargeNo, "1",2);
    }
}

+ 179 - 127
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/wx/OnePayController.java

@ -1,8 +1,11 @@
package com.yihu.wlyy.web.wx;
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.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.service.third.httplog.LogService;
@ -19,6 +22,7 @@ import com.ylzinfo.onepay.sdk.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
@ -66,6 +70,10 @@ public class OnePayController extends WeixinBaseController {
    LogService logService;
    @Autowired
    private Configure config;
    @Autowired
    private HospitalMappingDao mappingDao;
    @Autowired
    ObjectMapper objectMapper;
    @RequestMapping(value = "createSicard", method = RequestMethod.POST)
@ -76,7 +84,8 @@ public class OnePayController extends WeixinBaseController {
            String sicardUrl = pay.createSicard("0cc6e4562de2437ab2dbbf51a9fc3b49", "oULM4xAj9sOsHJ95ttKYd_Fjh6Hc");//getUID(), getOpenid());
            return write(200, "生成电子社保卡成功!", "data", sicardUrl);
        } catch (Exception e) {
            return error(-1, e.getMessage());
            error(e);
            return write(-1, "生成电子社保卡失败!");
        }
    }
@ -85,14 +94,11 @@ public class OnePayController extends WeixinBaseController {
    @ResponseBody
    public String bindCard() throws Exception {
        try {
//            String patient = getUID();
//            String openid = getOpenid();
//            逸祥
//            String patient = "0cc6e4562de2437ab2dbbf51a9fc3b49";
//            String openid = "oULM4xAj9sOsHJ95ttKYd_Fjh6Hc";
            String patient = getUID();
            String openid = getOpenid();
//            在鑫
            String patient = "0cc6e4562de2437ab2dbbf51a9fc3b49";
            String openid = "o7NFZw7FlRW-Hlp0VjM71FR_1otw";
//            String patient = "0cc6e4562de2437ab2dbbf51a9fc3b49";
//            String openid = "o7NFZw7FlRW-Hlp0VjM71FR_1otw";
            BindCard bindCard = pay.bindCard(patient, openid);//getUID(), getOpenid());      oULM4xAj9sOsHJ95ttKYd_Fjh6Hc
            String sicardUrl = pay.createSicard(patient, openid);//getUID(), getOpenid());
            if (bindCard != null) {
@ -108,7 +114,8 @@ public class OnePayController extends WeixinBaseController {
                return write(200, "生成电子社保卡成功!", "data", json);
            }
        } catch (Exception e) {
            return error(-1, e.getMessage());
            error(e);
            return write(-1, "查询电子社保卡失败!");
        }
    }
@ -122,25 +129,25 @@ public class OnePayController extends WeixinBaseController {
            @RequestParam String chargeType,
            @ApiParam(name = "chargeRelation", value = "支付关联代码签约code", defaultValue = "044701ea-5b23-11e6-8344-fa163e8aee56")
            @RequestParam String chargeRelation,
            @ApiParam(name = "totalAmount", value = "交易总金额(分)", defaultValue = "12000")
            @ApiParam(name = "totalAmount", value = "交易总金额(分)", defaultValue = "9000")
            @RequestParam String totalAmount) throws Exception {
        try {
            //            获取居民个人信息
//            String patient = getUID();
//            String openId = getOpenid();
//            String patient = "0cc6e4562de2437ab2dbbf51a9fc3b49";
//            String openId = "oULM4xAj9sOsHJ95ttKYd_Fjh6Hc";
            totalAmount = "9000";
            String patient = getUID();
            String openId = getOpenid();
//            在鑫
            String patient = "0cc6e4562de2437ab2dbbf51a9fc3b49";
            String openId = "o7NFZw7FlRW-Hlp0VjM71FR_1otw";
//            String patient = "0cc6e4562de2437ab2dbbf51a9fc3b49";
//            String openId = "o7NFZw7FlRW-Hlp0VjM71FR_1otw";
            if (StringUtils.isNotEmpty(openId)) {
                String settleNo = pay.charge(orgCode, chargeType, chargeRelation, totalAmount, patient, openId,getAccessToken());  //ohNH9sh4uwuJCxIwcLJtGTX-BaSk    getUID(),getOpenid()
                String settleNo = pay.charge(orgCode, chargeType, chargeRelation, totalAmount, patient, openId, getAccessToken());  //ohNH9sh4uwuJCxIwcLJtGTX-BaSk    getUID(),getOpenid()
                return write(200, "家庭医生签约支付成功!", "data", settleNo);
            } else {
                return write(-1, "openId为空!");
            }
        } catch (Exception e) {
            return error(-1, e.getMessage());
            error(e);
            return write(-1, "家庭医生签约支付失败!");
        }
    }
@ -151,10 +158,12 @@ public class OnePayController extends WeixinBaseController {
    public String chargeQuery(@ApiParam(name = "code", value = "接入应用业务流水号", defaultValue = "")
                              @RequestParam String code) throws Exception {
        try {
            Charge charge = pay.chargeQuery(code,getAccessToken());
            String result = pay.chargeQuery(code, getAccessToken());
            Charge charge = objectMapper.readValue(result, Charge.class);
            return write(200, "家庭医生签约支付查询成功!", "data", charge);
        } catch (Exception e) {
            return error(-1, e.getMessage());
            error(e);
            return write(-1, "家庭医生签约支付查询失败!");
        }
    }
@ -167,10 +176,11 @@ public class OnePayController extends WeixinBaseController {
                             @ApiParam(name = "chargeRelation", value = "支付关联代码", defaultValue = "044701ea5b2311e68344fa163e8aee56")
                             @RequestParam String chargeRelation) throws Exception {
        try {
            List<WlyyCharge> charge = pay.chargeList(chargeType, chargeRelation,getAccessToken());
            List<WlyyCharge> charge = pay.chargeList(chargeType, chargeRelation, getAccessToken());
            return write(200, "获取某次签约的支付记录成功!", "data", charge);
        } catch (Exception e) {
            return error(-1, e.getMessage());
            error(e);
            return write(-1, "获取某次签约的支付记录失败!");
        }
    }
@ -185,10 +195,11 @@ public class OnePayController extends WeixinBaseController {
                                      @ApiParam(name = "size", value = "每页几行", defaultValue = "10")
                                      @RequestParam Integer size) throws Exception {
        try {
            List<WlyyCharge> charge = pay.chargeListByPatient(patient,getAccessToken(), page, size);
            List<WlyyCharge> charge = pay.chargeListByPatient(patient, getAccessToken(), page, size);
            return write(200, "获取患者的支付记录成功!", "data", charge);
        } catch (Exception e) {
            return error(-1, e.getMessage());
            error(e);
            return write(-1, "获取患者的支付记录失败!");
        }
    }
@ -243,56 +254,87 @@ public class OnePayController extends WeixinBaseController {
    /**
     * 页面回调更新数据
     *
     * @param request
     * @param response
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/returnUrl", method = RequestMethod.GET)
    @ApiOperation("商户页面跳转")
    public String testReturnUrl(@RequestParam String jsonData) throws IOException, PayException {
    @RequestMapping(value = "/returnUrl")
    public void returnUrl(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        Boolean isSuccess = false;
        String error = "";
        String responses = "";
        response.setContentType("text/html;charset=utf-8");
        try {
            JSONObject json = new JSONObject(jsonData);
            JSONObject requestParam = json.getJSONObject("param");//业务出参
            String chargeNo = requestParam.getString("chargeNo"); //支付平台流水号
            String chargeTime = requestParam.getString("chargeTime");//支付平台交易成功时间
            String outChargeNo = requestParam.getString("outChargeNo");//接入应用业务流水号
            String outChargeTime = requestParam.getString("outChargeTime");//接入应用时间
            String channel = requestParam.getString("channel");//支付方式
            String billNo = requestParam.getString("billNo");//待结算费用单据号
            String cardNo = requestParam.getString("cardNo");//医保卡号
            String totalAmount = requestParam.getString("totalAmount");//交易总金额
            String insuranceAmount = requestParam.getString("insuranceAmount");//医保支付金额
            String selfPayAmount = requestParam.getString("selfPayAmount");//自付金额
            String userId = requestParam.getString("userId");//用户openID
            String userName = requestParam.getString("userName");//用户名字
            String idType = requestParam.getString("idType");//证件类型
            String idNo = requestParam.getString("idNo");//证件号码
            String tradeStatus = requestParam.getString("tradeStatus");//交易状态
            JSONObject responseContents = json.getJSONObject("responseContent");//医保结构体
            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");//医保统筹支付
//                responseContents.getString("healthPay");
            String heathPay = responseContents.getString("heathPay");//健康账户支付
            String accountPay = responseContents.getString("accountPay");//医保账户支付
            String selfPay = responseContents.getString("selfPay");//个人现金支付
            //		如:查询显示订单信息
            isSuccess = true;
            String appId = request.getParameter("appId");
            String billNo = request.getParameter("billNo");//待结算费用单据号
            String cardNo = request.getParameter("cardNo");//医保卡号
            String channel = request.getParameter("channel");//支付方式
            String chargeNo = request.getParameter("chargeNo");//支付平台流水号
            String chargeTime = request.getParameter("chargeTime");//支付平台交易成功时间
            String idNo = request.getParameter("idNo");//证件号码
            String idType = request.getParameter("idType");//证件类型
            String insuranceAmount = request.getParameter("insuranceAmount");//医保支付金额
            String outChargeNo = request.getParameter("outChargeNo");//接入应用业务流水号
            String outChargeTime = request.getParameter("outChargeTime");//接入应用时间
            String selfPayAmount = request.getParameter("selfPayAmount");//自付金额
            String sign = request.getParameter("sign");
            String signType = request.getParameter("signType");
            String timestamp = request.getParameter("timestamp");
            String totalAmount = request.getParameter("totalAmount");//交易总金额
            String tradeStatus = request.getParameter("tradeStatus");//交易状态
            String userId = request.getParameter("userId");//用户openID
            String userName = request.getParameter("userName");//用户名字
            String result = pay.chargeQuery(outChargeNo, getAccessToken());//业务出参
            JSONObject param = new JSONObject(result);
            String requestParam = param.getString("responseContent");
            JSONObject responseContents = new JSONObject(requestParam);//医保结构体
            String miRegisterNo = "";
            String miCollectDate = "";
            String miCollectTime = "";
            String miSettleNo = "";
            String miCollectStatus = "";
            String miRegisterStatus = "";
            String cadresPay = "";
            String miTotalFee = "";
            String healthCarePay = "";
            String heathPay = "";
            String accountPay = "";
            String selfPay = "";
            if (responseContents != null) {
               miRegisterNo = responseContents.getString("miRegisterNo");//医保签约号
                 miCollectDate = responseContents.getString("miCollectDate");//扣费日期
                 miCollectTime = responseContents.getString("miCollectTime");//扣费时间
                 miSettleNo = responseContents.getString("miSettleNo");//扣费单据号
                 miCollectStatus = responseContents.getString("miCollectStatus");//扣费状态
                 miRegisterStatus = responseContents.getString("miRegisterStatus");//登记状态
                 cadresPay = responseContents.getString("cadresPay");//政府补贴支付
                 miTotalFee = responseContents.getString("miTotalFee");//扣费总额
                 healthCarePay = responseContents.getString("healthCarePay");//医保统筹支付
                 heathPay = responseContents.getString("heathPay");//健康账户支付
                 accountPay = responseContents.getString("accountPay");//医保账户支付
                 selfPay = responseContents.getString("selfPay");//个人现金支付
            }
//                判断是否需要更新数据 needUpload为0不需要更新
            WlyyCharge charge = chargeDao.getUploadStatus(outChargeNo);
            if (charge!=null&&!("0".equals(charge.getNeedUpload()))){
                pay.updateData(outChargeNo, chargeNo,chargeTime,totalAmount,insuranceAmount,selfPayAmount,billNo,miRegisterNo);
            if (charge != null && !("0".equals(charge.getNeedUpload()))) {
                pay.updateData(outChargeNo, chargeNo, chargeTime, totalAmount, insuranceAmount, selfPayAmount, billNo, miRegisterNo);
            }
            return write(200, "请求成功!");
        } catch (Exception e) {
            return error(-1, e.getMessage());
            isSuccess = false;
            response.getWriter().write(e.getMessage());
        }
        //                记录log日志到数据库
        logService.saveHttpLog(isSuccess, config.getReturnUrl(), "支付页面跳转", "POST", null, "", responses, error, logService.onepayType);
    }
    /**
@ -303,17 +345,21 @@ public class OnePayController extends WeixinBaseController {
     * @throws IOException
     * @throws PayException
     */
    @RequestMapping(value = "/receiveNotify", method = RequestMethod.POST)
    @ApiOperation("异步回调数据更改")
    @RequestMapping(value = "/receiveNotify")
    public void receiveNotify(HttpServletRequest request, HttpServletResponse response) throws IOException, PayException {
        Boolean isSuccess = false;
        String error= "";
        String error = "";
        String responses = "";
        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"));
        JSONObject json = new JSONObject(params);
        String appId = json.getString("appId");
        HospitalMapping hospital = mappingDao.findByAppId(appId);
        String appSecret = hospital.getAppSecret();
//        String appSecret = json.getString("appId");
        LOGGER.info("回调参数:{}", params);
        if (StringUtil.isEmpty(params)) {
            response.getWriter().write("empty");
@ -324,69 +370,75 @@ public class OnePayController extends WeixinBaseController {
        OnepayDefaultClient client = new OnepayDefaultClient("", appId, appSecret, encryptRes.getSignType(), encryptRes.getEncryptType());
        try {
//            已经封装的加解密及签名验证
            RequestParams requestParams = JSON.parseObject(params, RequestParams.class);
            ResponseParams<com.alibaba.fastjson.JSONObject> res =  client.execute(requestParams);
            responses = JSON.toJSONString(res);
            if (OnepayDefaultClient.isSuccessful(res)) {
                isSuccess = true;
                String param = request.getParameter("param");//业务出参
                JSONObject requestParam = new JSONObject(param);
                String chargeNo = requestParam.getString("chargeNo"); //支付平台流水号
                String chargeTime = requestParam.getString("chargeTime");//支付平台交易成功时间
                String outChargeNo = requestParam.getString("outChargeNo");//接入应用业务流水号
                String outChargeTime = requestParam.getString("outChargeTime");//接入应用时间
                String channel = requestParam.getString("channel");//支付方式
                String billNo = requestParam.getString("billNo");//待结算费用单据号
                String cardNo = requestParam.getString("cardNo");//医保卡号
                String totalAmount = requestParam.getString("totalAmount");//交易总金额
                String insuranceAmount = requestParam.getString("insuranceAmount");//医保支付金额
                String selfPayAmount = requestParam.getString("selfPayAmount");//自付金额
                String userId = requestParam.getString("userId");//用户openID
                String userName = requestParam.getString("userName");//用户名字
                String idType = requestParam.getString("idType");//证件类型
                String idNo = requestParam.getString("idNo");//证件号码
                String tradeStatus = requestParam.getString("tradeStatus");//交易状态
                String responseContent = request.getParameter("responseContent");//医保结构体
                JSONObject responseContents = new JSONObject(responseContent);
                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");//医保统筹支付
            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 {
//					业务逻辑代码
                    isSuccess = true;
                    responses = JSON.toJSONString(decryptRes);
                    JSONObject requestParams = new JSONObject(responses);
                    JSONObject requestParam = requestParams.getJSONObject("param");//业务出参
                    String chargeNo = requestParam.getString("chargeNo"); //支付平台流水号
                    String chargeTime = requestParam.getString("chargeTime");//支付平台交易成功时间
                    String outChargeNo = requestParam.getString("outChargeNo");//接入应用业务流水号
                    String outChargeTime = requestParam.getString("outChargeTime");//接入应用时间
                    String channel = requestParam.getString("channel");//支付方式
                    String billNo = requestParam.getString("billNo");//待结算费用单据号
                    String cardNo = requestParam.getString("cardNo");//医保卡号
                    String totalAmount = requestParam.getString("totalAmount");//交易总金额
                    String insuranceAmount = requestParam.getString("insuranceAmount");//医保支付金额
                    String selfPayAmount = requestParam.getString("selfPayAmount");//自付金额
                    String userId = requestParam.getString("userId");//用户openID
                    String userName = requestParam.getString("userName");//用户名字
                    String idType = requestParam.getString("idType");//证件类型
                    String idNo = requestParam.getString("idNo");//证件号码
                    String tradeStatus = requestParam.getString("tradeStatus");//交易状态
                    String miRegisterNo = "";//医保签约号
                    if (requestParams.has("responseContent") && (requestParams.getJSONObject("responseContent") != null)) {
                        JSONObject responseContents = requestParams.getJSONObject("responseContent");//医保结构体
                        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");//医保统筹支付
//                responseContents.getString("healthPay");
                String heathPay = responseContents.getString("heathPay");//健康账户支付
                String accountPay = responseContents.getString("accountPay");//医保账户支付
                String selfPay = responseContents.getString("selfPay");//个人现金支付
                        String heathPay = responseContents.getString("heathPay");//健康账户支付
                        String accountPay = responseContents.getString("accountPay");//医保账户支付
                        String selfPay = responseContents.getString("selfPay");//个人现金支付
                    }
//                判断是否需要更新数据 needUpload为0不需要更新
                WlyyCharge charge = chargeDao.getUploadStatus(outChargeNo);
                if (charge!=null&&!("0".equals(charge.getNeedUpload()))){
                    pay.updateData(outChargeNo, chargeNo,chargeTime,totalAmount,insuranceAmount,selfPayAmount,billNo,miRegisterNo);
                    WlyyCharge charge = chargeDao.getUploadStatus(outChargeNo);
                    if (charge != null && !("0".equals(charge.getNeedUpload()))) {
                        pay.updateData(outChargeNo, chargeNo, chargeTime, totalAmount, insuranceAmount, selfPayAmount, billNo, miRegisterNo);
                    }
                    response.getWriter().write("SUCCESS");
                }
            }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();
            response.getWriter().write(ex.getMessage());
        } catch (Exception e) {
            response.getWriter().write(e.getMessage());
        }
        //                记录log日志到数据库
                logService.saveHttpLog(isSuccess, config.getReceiveNotify(), "异步支付通知", "POST", null, params, responses, error, logService.onepayType);
        logService.saveHttpLog(isSuccess, config.getReceiveNotify(), "异步支付通知", "POST", null, params, responses, error, logService.onepayType);
    }
}

+ 16 - 16
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/wechat/process/WeiXinEventProcess.java

@ -237,22 +237,22 @@ public class WeiXinEventProcess {
        articles.add(articleExamination);
//        新增处方记录图文消息
        Map<String, String> articlePrescription = new HashMap<>();
        // 图文URL
        String prescription = systemConf.getProperty("patient_prescription_url");
        // 图文消息图片URL
        String prescription_pic = systemConf.getProperty("patient_prescription_pic");
        // URL设置服务器URL、AppId
        prescription = prescription.replace("{server}",wechat_base_url)
                .replace("{appId}",appId);
        //图片地址
        prescription_pic = prescription_pic.replace("{server}",serverUrl);
        articlePrescription.put("Url", prescription);
        articlePrescription.put("Title", "处方记录");
        articlePrescription.put("Description", "处方记录");
        articlePrescription.put("PicUrl", prescription_pic);
        articles.add(articlePrescription);
//        Map<String, String> articlePrescription = new HashMap<>();
//        // 图文URL
//        String prescription = systemConf.getProperty("patient_prescription_url");
//        // 图文消息图片URL
//        String prescription_pic = systemConf.getProperty("patient_prescription_pic");
//        // URL设置服务器URL、AppId
//        prescription = prescription.replace("{server}",wechat_base_url)
//                .replace("{appId}",appId);
//        //图片地址
//        prescription_pic = prescription_pic.replace("{server}",serverUrl);
//
//        articlePrescription.put("Url", prescription);
//        articlePrescription.put("Title", "处方记录");
//        articlePrescription.put("Description", "处方记录");
//        articlePrescription.put("PicUrl", prescription_pic);
//        articles.add(articlePrescription);
        // 构建回复消息XML
        result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);

+ 16 - 0
patient-co/patient-co-wlyy/src/main/resources/application.yml

@ -156,6 +156,11 @@ sign:
quartz:
  name: schedulerFactoryBean_test
ylzpay:
  onepayApi: http://120.42.37.94:1301/onepay-web/
  onepayAppId: 1BGKM1UHM03P7B2CA8C000005626EB0E
  onepayAppSecret: 1BGKM1UHM03I7B2CA8C00000AB682E9A
---
##正式的配置
@ -241,6 +246,12 @@ sign:
quartz:
  name: schedulerFactoryBeanWlyy
ylzpay:
#  onepayApi: https://xmhealth.ylzpay.com:8080/
  onepayApi: http://xmhealth.ylzpay.com:8070/
  onepayAppId: 1BLF5SEGN00087165F0A000027362BE5
  onepayAppSecret: 1BLF5SCBO01V3E78A8C00000F3A0FFE7
---
##开发的配置
spring:
@ -326,6 +337,11 @@ sign:
quartz:
  name: schedulerFactoryBean_dev
ylzpay:
  onepayApi: http://120.42.37.94:1301/onepay-web/
  onepayAppId: 1BGKM1UHM03P7B2CA8C000005626EB0E
  onepayAppSecret: 1BGKM1UHM03I7B2CA8C00000AB682E9A
---
##开发连测试用这个版本的配置
spring:

+ 7 - 0
patient-co/patient-co-wlyy/src/main/resources/system.properties

@ -83,4 +83,11 @@ prescription_pay_overdue_job = 0 0 0 * * ?
#统一支付平台支付成功后页面跳转地址
return_url={server}/wx/html/qygl/html/pay_result.html
#统一支付平台支付接口地址
bindCardType=onepay.sicard.bind.info
chargeType=onepay.trade.medical.charge
chargeQueryType=onepay.trade.medical.charge.query
createSicardType=onepay.sicard.createurl
receiveNotify=wlyy.onepay.receiveNotify
returnUrl=wlyy.onepay.returnUrl

+ 4 - 2
pom.xml

@ -517,11 +517,13 @@
                <artifactId>fastjson</artifactId>
                <version>${version.fastdfs}</version>
            </dependency>
            <!--易联众支付-->
            <dependency>
                <groupId>com.ylz</groupId>
                <artifactId>onepay-java-sdk</artifactId>
                <artifactId>onpay-java-sdk-all</artifactId>
                <version>${version.ylz}</version>
            </dependency> <!--elasticsearch start-->
            </dependency>
            <!--elasticsearch start-->
            <dependency>
                <groupId>org.elasticsearch</groupId>
                <artifactId>elasticsearch</artifactId>