|
@ -1,6 +1,10 @@
|
|
|
package com.yihu.wlyy.web.wx;
|
|
|
|
|
|
import com.yihu.wlyy.entity.charge.WlyyCharge;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.SignFamily;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.repository.patient.SignFamilyDao;
|
|
|
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;
|
|
@ -11,6 +15,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.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.stereotype.Controller;
|
|
@ -23,6 +28,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.net.URLDecoder;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@ -37,18 +43,55 @@ public class OnePayController extends WeixinBaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private OnePayService pay;
|
|
|
@Autowired
|
|
|
private PatientDao patientDao;
|
|
|
@Autowired
|
|
|
private SignFamilyDao signFamilyDao;
|
|
|
|
|
|
@RequestMapping(value = "expensesStatus", method = RequestMethod.GET)
|
|
|
@ApiOperation("居民缴费状态查询")
|
|
|
@ResponseBody
|
|
|
public String expensesStatus() throws Exception {
|
|
|
try {
|
|
|
// 获取居民个人信息 要根据签约code去查找签约扣费状态
|
|
|
// String userCode = getUID();
|
|
|
String userCode = "915cc456-5b1d-11e6-8344-fa163e8aee56";
|
|
|
SignFamily signFamily = signFamilyDao.findPatientExpensesStatus(userCode);
|
|
|
String expensesStatus = signFamily.getExpensesStatus();
|
|
|
if ("0".equals(expensesStatus)){
|
|
|
return write(200, "未扣费!","expensesStatus",expensesStatus);
|
|
|
}else if ("1".equals(expensesStatus)){
|
|
|
return write(200, "已扣费!","expensesStatus",expensesStatus);
|
|
|
}else if ("2".equals(expensesStatus)){
|
|
|
return write(200, "已退费!","expensesStatus",expensesStatus);
|
|
|
}else {
|
|
|
return write(200, "扣费状态数据有误!","expensesStatus",expensesStatus);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
return error(-1, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "bindCard", method = RequestMethod.POST)
|
|
|
@ApiOperation("查询绑卡信息")
|
|
|
@ResponseBody
|
|
|
public String bindCard() throws Exception {
|
|
|
try {
|
|
|
// 获取居民个人信息
|
|
|
/* String userCode = getUID();
|
|
|
Patient patient = patientDao.findByCode(userCode);
|
|
|
String openId = patient.getOpenid();
|
|
|
if (StringUtils.isNotEmpty(openId)) {
|
|
|
BindCard bindCard = pay.bindCard(userCode, openId);
|
|
|
return write(200, "查询绑卡信息成功!", "data", bindCard);
|
|
|
} else {
|
|
|
return write(-1, "openId为空!");
|
|
|
}*/
|
|
|
BindCard bindCard = pay.bindCard("915cc456-5b1d-11e6-8344-fa163e8aee56","o4Ma2t5665rS7uNfA9EF-VnOJx30"); //ohNH9sh4uwuJCxIwcLJtGTX-BaSk //o4Ma2t5665rS7uNfA9EF-VnOJx30 getUID()getOpenid()
|
|
|
// BindCard bindCard = pay.bindCard("915cc456-5b1d-11e6-8344-fa163e8aee56","ohNH9sh4uwuJCxIwcLJtGTX-BaSk"); //ohNH9sh4uwuJCxIwcLJtGTX-BaSk //o4Ma2t5665rS7uNfA9EF-VnOJx30 getUID()getOpenid()
|
|
|
return write(200, "查询绑卡信息成功!","data",bindCard);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
return error(-1, e.getMessage());
|
|
|
}
|
|
|
}
|
|
@ -57,26 +100,37 @@ public class OnePayController extends WeixinBaseController {
|
|
|
@ApiOperation("家庭医生签约支付")
|
|
|
@ResponseBody
|
|
|
public String charge(
|
|
|
@ApiParam(name="orgCode",value="医疗机构编号",defaultValue = "3502050300")
|
|
|
@RequestParam String orgCode,
|
|
|
@ApiParam(name="chargeType",value="支付类型",defaultValue = "1")
|
|
|
@RequestParam String chargeType,
|
|
|
@ApiParam(name="chargeRelation",value="支付关联代码",defaultValue = "044701ea5b2311e68344fa163e8aee56")
|
|
|
@RequestParam String chargeRelation,
|
|
|
@ApiParam(name="totalAmount",value="交易总金额(分)",defaultValue = "1")
|
|
|
@RequestParam Integer totalAmount,
|
|
|
@ApiParam(name="selfpayAmount",value="自费金额(分)",defaultValue = "0")
|
|
|
@RequestParam Integer selfpayAmount,
|
|
|
@ApiParam(name="insuranceAmount",value="医保支付金额(分)",defaultValue = "1")
|
|
|
@RequestParam Integer insuranceAmount,
|
|
|
@ApiParam(name="feeDetail",value="费用明细",defaultValue = "[{\"itemName\":\"家庭医生签约支付\",\"itemDesc\":\"家庭医生签约支付\",\"itemOrigPrice\":\"1\",\"itemNowPrice\":\"1\",\"itemNum\":\"1\",\"itemTotalAmt\":\"1\"}]")
|
|
|
@RequestParam String feeDetail) throws Exception {
|
|
|
@ApiParam(name = "orgCode", value = "医疗机构编号", defaultValue = "3502050300")
|
|
|
@RequestParam String orgCode,
|
|
|
@ApiParam(name = "chargeType", value = "支付类型", defaultValue = "1")
|
|
|
@RequestParam String chargeType,
|
|
|
@ApiParam(name = "chargeRelation", value = "支付关联代码", defaultValue = "044701ea5b2311e68344fa163e8aee56")
|
|
|
@RequestParam String chargeRelation,
|
|
|
@ApiParam(name = "totalAmount", value = "交易总金额(分)", defaultValue = "1")
|
|
|
@RequestParam Integer totalAmount,
|
|
|
@ApiParam(name = "selfpayAmount", value = "自费金额(分)", defaultValue = "0")
|
|
|
@RequestParam Integer selfpayAmount,
|
|
|
@ApiParam(name = "insuranceAmount", value = "医保支付金额(分)", defaultValue = "1")
|
|
|
@RequestParam Integer insuranceAmount,
|
|
|
@ApiParam(name = "feeDetail", value = "费用明细", defaultValue = "[{\"itemName\":\"家庭医生签约支付\",\"itemDesc\":\"家庭医生签约支付\",\"itemOrigPrice\":\"1\",\"itemNowPrice\":\"1\",\"itemNum\":\"1\",\"itemTotalAmt\":\"1\"}]")
|
|
|
@RequestParam String feeDetail) throws Exception {
|
|
|
try {
|
|
|
String settleNo = pay.charge(orgCode,chargeType,chargeRelation,totalAmount, selfpayAmount, insuranceAmount, feeDetail,"915cc456-5b1d-11e6-8344-fa163e8aee56","o4Ma2t5665rS7uNfA9EF-VnOJx30"); //ohNH9sh4uwuJCxIwcLJtGTX-BaSk getUID(),getOpenid()
|
|
|
return write(200, "家庭医生签约支付成功!","data",settleNo);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
// 获取居民个人信息
|
|
|
/*String userCode = getUID();
|
|
|
Patient patient = patientDao.findByCode(userCode);
|
|
|
String openId = patient.getOpenid();
|
|
|
if (StringUtils.isNotEmpty(openId)) {
|
|
|
String settleNo = pay.charge(orgCode, chargeType, chargeRelation, totalAmount, selfpayAmount, insuranceAmount, feeDetail, userCode, openId); //ohNH9sh4uwuJCxIwcLJtGTX-BaSk getUID(),getOpenid()
|
|
|
// 更新签约表的缴费状态(begin字段),表示签约正式开始
|
|
|
signFamilyDao.updatePatientBegin(userCode, new Date());
|
|
|
return write(200, "家庭医生签约支付成功!", "data", settleNo);
|
|
|
} else {
|
|
|
return write(-1, "openId为空!");
|
|
|
}*/
|
|
|
String settleNo = pay.charge(orgCode, chargeType, chargeRelation, totalAmount, selfpayAmount, insuranceAmount, feeDetail, "915cc456-5b1d-11e6-8344-fa163e8aee56", "o4Ma2t5665rS7uNfA9EF-VnOJx30"); //ohNH9sh4uwuJCxIwcLJtGTX-BaSk getUID(),getOpenid()
|
|
|
// String settleNo = pay.charge(orgCode, chargeType, chargeRelation, totalAmount, selfpayAmount, insuranceAmount, feeDetail, "915cc456-5b1d-11e6-8344-fa163e8aee56", "ohNH9sh4uwuJCxIwcLJtGTX-BaSk"); //ohNH9sh4uwuJCxIwcLJtGTX-BaSk getUID(),getOpenid()
|
|
|
return write(200, "家庭医生签约支付成功!", "data", settleNo);
|
|
|
} catch (Exception e) {
|
|
|
return error(-1, e.getMessage());
|
|
|
}
|
|
|
}
|
|
@ -85,14 +139,12 @@ public class OnePayController extends WeixinBaseController {
|
|
|
@RequestMapping(value = "chargeQuery", method = RequestMethod.POST)
|
|
|
@ApiOperation("家庭医生签约支付查询")
|
|
|
@ResponseBody
|
|
|
public String chargeQuery(@ApiParam(name="code",value="支付流水号",defaultValue = "")
|
|
|
@RequestParam String code) throws Exception {
|
|
|
public String chargeQuery(@ApiParam(name = "code", value = "支付流水号", defaultValue = "")
|
|
|
@RequestParam String code) throws Exception {
|
|
|
try {
|
|
|
Charge charge = pay.chargeQuery(code);
|
|
|
return write(200, "家庭医生签约支付查询成功!","data",charge);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
return write(200, "家庭医生签约支付查询成功!", "data", charge);
|
|
|
} catch (Exception e) {
|
|
|
return error(-1, e.getMessage());
|
|
|
}
|
|
|
}
|
|
@ -102,11 +154,19 @@ public class OnePayController extends WeixinBaseController {
|
|
|
@ResponseBody
|
|
|
public String createSicard() throws Exception {
|
|
|
try {
|
|
|
String sicardUrl = pay.createSicard("915cc456-5b1d-11e6-8344-fa163e8aee56","o4Ma2t5665rS7uNfA9EF-VnOJx30"); //ohNH9sh4uwuJCxIwcLJtGTX-BaSk //o4Ma2t5665rS7uNfA9EF-VnOJx30 getUID(),getOpenid()
|
|
|
return write(200, "生成电子社保卡成功!","data",sicardUrl);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
// 获取居民个人信息
|
|
|
String userCode = getUID();
|
|
|
Patient patient = patientDao.findByCode(userCode);
|
|
|
String openId = patient.getOpenid();
|
|
|
if (StringUtils.isNotEmpty(openId)) {
|
|
|
String sicardUrl = pay.createSicard(userCode, openId); //ohNH9sh4uwuJCxIwcLJtGTX-BaSk //o4Ma2t5665rS7uNfA9EF-VnOJx30 getUID(),getOpenid()
|
|
|
return write(200, "生成电子社保卡成功!", "data", sicardUrl);
|
|
|
}else {
|
|
|
return write(-1, "openId为空!");
|
|
|
}
|
|
|
// String sicardUrl = pay.createSicard("915cc456-5b1d-11e6-8344-fa163e8aee56", "o4Ma2t5665rS7uNfA9EF-VnOJx30"); //ohNH9sh4uwuJCxIwcLJtGTX-BaSk //o4Ma2t5665rS7uNfA9EF-VnOJx30 getUID(),getOpenid()
|
|
|
// return write(200, "生成电子社保卡成功!", "data", sicardUrl);
|
|
|
} catch (Exception e) {
|
|
|
return error(-1, e.getMessage());
|
|
|
}
|
|
|
}
|
|
@ -115,52 +175,40 @@ public class OnePayController extends WeixinBaseController {
|
|
|
@RequestMapping(value = "chargeList", method = RequestMethod.POST)
|
|
|
@ApiOperation("获取某次签约的支付记录")
|
|
|
@ResponseBody
|
|
|
public String chargeList(@ApiParam(name="chargeType",value="支付类型",defaultValue = "1")
|
|
|
@RequestParam String chargeType,
|
|
|
@ApiParam(name="chargeRelation",value="支付关联代码",defaultValue = "044701ea5b2311e68344fa163e8aee56")
|
|
|
@RequestParam String chargeRelation) throws Exception {
|
|
|
public String chargeList(@ApiParam(name = "chargeType", value = "支付类型", defaultValue = "1")
|
|
|
@RequestParam String chargeType,
|
|
|
@ApiParam(name = "chargeRelation", value = "支付关联代码", defaultValue = "044701ea5b2311e68344fa163e8aee56")
|
|
|
@RequestParam String chargeRelation) throws Exception {
|
|
|
try {
|
|
|
List<WlyyCharge> charge = pay.chargeList(chargeType,chargeRelation);
|
|
|
return write(200, "获取某次签约的支付记录成功!","data",charge);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
List<WlyyCharge> charge = pay.chargeList(chargeType, chargeRelation);
|
|
|
return write(200, "获取某次签约的支付记录成功!", "data", charge);
|
|
|
} catch (Exception e) {
|
|
|
return error(-1, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "chargeListByPatient", method = RequestMethod.POST)
|
|
|
@ApiOperation("获取患者的支付记录")
|
|
|
@ResponseBody
|
|
|
public String chargeListByPatient(@ApiParam(name="patient",value="患者代码",defaultValue = "")
|
|
|
@RequestParam String patient,
|
|
|
@ApiParam(name="page",value="第几页,从1开始",defaultValue = "1")
|
|
|
@RequestParam Integer page,
|
|
|
@ApiParam(name="size",value="每页几行",defaultValue = "10")
|
|
|
@RequestParam Integer size) throws Exception {
|
|
|
public String chargeListByPatient(@ApiParam(name = "patient", value = "患者代码", defaultValue = "")
|
|
|
@RequestParam String patient,
|
|
|
@ApiParam(name = "page", value = "第几页,从1开始", defaultValue = "1")
|
|
|
@RequestParam Integer page,
|
|
|
@ApiParam(name = "size", value = "每页几行", defaultValue = "10")
|
|
|
@RequestParam Integer size) throws Exception {
|
|
|
try {
|
|
|
List<WlyyCharge> charge = pay.chargeListByPatient(patient,page,size);
|
|
|
return write(200, "获取患者的支付记录成功!","data",charge);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
List<WlyyCharge> charge = pay.chargeListByPatient(patient, page, size);
|
|
|
return write(200, "获取患者的支付记录成功!", "data", charge);
|
|
|
} catch (Exception e) {
|
|
|
return error(-1, e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 解析URL参数串
|
|
|
*
|
|
|
* @param formContext
|
|
|
* @param wordFirstsplitRegex
|
|
|
* @param wordSecondsplitRegex
|
|
@ -185,6 +233,7 @@ public class OnePayController extends WeixinBaseController {
|
|
|
|
|
|
/**
|
|
|
* 转换URL参数中为Map
|
|
|
*
|
|
|
* @param reqQueryString
|
|
|
* @return
|
|
|
* @throws PayException
|
|
@ -209,7 +258,7 @@ public class OnePayController extends WeixinBaseController {
|
|
|
@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");
|
|
|
response.getWriter().write("返回结果:\n" + request.getQueryString() + "\n");
|
|
|
|
|
|
String onepayUrl = request.getParameter("onepayUrl");
|
|
|
String appId = "1BHEOI11C00J7B2CA8C0000071FA53E1";
|