|
@ -18,16 +18,15 @@ import com.ylzinfo.onepay.sdk.OnepayDefaultClient;
|
|
import com.ylzinfo.onepay.sdk.domain.RequestParams;
|
|
import com.ylzinfo.onepay.sdk.domain.RequestParams;
|
|
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
|
|
import com.ylzinfo.onepay.sdk.domain.ResponseParams;
|
|
import com.ylzinfo.onepay.sdk.utils.DateUtil;
|
|
import com.ylzinfo.onepay.sdk.utils.DateUtil;
|
|
|
|
import io.swagger.models.auth.In;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.PrintWriter;
|
|
import java.io.PrintWriter;
|
|
import java.io.StringWriter;
|
|
import java.io.StringWriter;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 易联众统一支付服务类
|
|
* 易联众统一支付服务类
|
|
@ -150,7 +149,7 @@ public class OnePayService {
|
|
/**
|
|
/**
|
|
* 家庭医生签约支付
|
|
* 家庭医生签约支付
|
|
*/
|
|
*/
|
|
public String charge(String orgCode,String signCode,String patient,String openid) throws Exception
|
|
|
|
|
|
public String charge(String orgCode,String chargeType,String chargeRelation,Integer totalAmount,Integer selfpayAmount,Integer insuranceAmount,String feeDetail,String patient,String openid) throws Exception
|
|
{
|
|
{
|
|
//获取机构映射
|
|
//获取机构映射
|
|
HospitalMapping hos = hospitalMappingDao.findByCode(orgCode);
|
|
HospitalMapping hos = hospitalMappingDao.findByCode(orgCode);
|
|
@ -159,13 +158,13 @@ public class OnePayService {
|
|
throw new Exception("no hospital mapping!");
|
|
throw new Exception("no hospital mapping!");
|
|
}
|
|
}
|
|
|
|
|
|
return charge(orgCode,hos.getName(),hos.getAppId(), hos.getAppSecret(), signCode,patient,openid);
|
|
|
|
|
|
return charge(orgCode,hos.getName(),hos.getAppId(), hos.getAppSecret(), chargeType,chargeRelation,totalAmount, selfpayAmount, insuranceAmount, feeDetail,patient,openid);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 家庭医生签约支付,成功则返回支付路径
|
|
* 家庭医生签约支付,成功则返回支付路径
|
|
*/
|
|
*/
|
|
private String charge(String orgCode,String orgName,String appId,String appSecret,String signCode,String patient,String openid) throws Exception
|
|
|
|
|
|
private String charge(String orgCode,String orgName,String appId,String appSecret,String chargeType,String chargeRelation,Integer totalAmount,Integer selfpayAmount,Integer insuranceAmount,String feeDetail,String patient,String openid) throws Exception
|
|
{
|
|
{
|
|
Boolean isSuccess = true;
|
|
Boolean isSuccess = true;
|
|
String msgBody = "";
|
|
String msgBody = "";
|
|
@ -179,7 +178,9 @@ public class OnePayService {
|
|
|
|
|
|
WlyyCharge charge = new WlyyCharge();
|
|
WlyyCharge charge = new WlyyCharge();
|
|
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
|
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
|
charge.setSignCode(signCode); //签约代码
|
|
|
|
|
|
|
|
|
|
charge.setChargeType(chargeType); //交易类型
|
|
|
|
charge.setChargeRelation(chargeRelation); //交易关联代码
|
|
charge.setCode(uuid); // 接入应用支付业务流水号
|
|
charge.setCode(uuid); // 接入应用支付业务流水号
|
|
Date now = new Date();
|
|
Date now = new Date();
|
|
charge.setCreateTime(now);
|
|
charge.setCreateTime(now);
|
|
@ -199,11 +200,10 @@ public class OnePayService {
|
|
charge.setChannel(channel);
|
|
charge.setChannel(channel);
|
|
charge.setMerchName(orgName);
|
|
charge.setMerchName(orgName);
|
|
charge.setSubject(subject);
|
|
charge.setSubject(subject);
|
|
|
|
|
|
/*private Integer totalAmount; // 交易总金额
|
|
|
|
private Integer selfpayAmount; // 自费金额
|
|
|
|
private Integer insuranceAmount; // 医保支付金额
|
|
|
|
private Integer feeDetail; // 费用明细*/
|
|
|
|
|
|
charge.setTotalAmount(totalAmount); // 交易总金额
|
|
|
|
charge.setSelfpayAmount(selfpayAmount); // 自费金额
|
|
|
|
charge.setInsuranceAmount(insuranceAmount); // 医保支付金额
|
|
|
|
charge.setFeeDetail(feeDetail); // 费用明细
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -228,11 +228,11 @@ public class OnePayService {
|
|
params.put("userName",name);
|
|
params.put("userName",name);
|
|
params.put("idType",idType);
|
|
params.put("idType",idType);
|
|
params.put("idNo",idNo);
|
|
params.put("idNo",idNo);
|
|
params.put("totalAmount","1"); //交易总金额
|
|
|
|
params.put("selfpayAmount","0"); //自费金额
|
|
|
|
params.put("insuranceAmount","1"); //医保支付金额
|
|
|
|
|
|
params.put("totalAmount",totalAmount); //交易总金额
|
|
|
|
params.put("selfpayAmount",selfpayAmount); //自费金额
|
|
|
|
params.put("insuranceAmount",insuranceAmount); //医保支付金额
|
|
params.put("returnUrl","https://mp.weixin.qq.com/insurance/pay/detail"); //页面跳转地址
|
|
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("feeDetail",feeDetail); //费用明细
|
|
params.put("channel",channel); //微信医保支付
|
|
params.put("channel",channel); //微信医保支付
|
|
params.put("merchName",orgName); //收款单位名称
|
|
params.put("merchName",orgName); //收款单位名称
|
|
params.put("subject",subject); //订单名称
|
|
params.put("subject",subject); //订单名称
|
|
@ -385,6 +385,8 @@ public class OnePayService {
|
|
if (OnepayDefaultClient.isSuccessful(res)) {
|
|
if (OnepayDefaultClient.isSuccessful(res)) {
|
|
JSONObject json = res.getParam();
|
|
JSONObject json = res.getParam();
|
|
result = String.valueOf(json.get("sicardUrl")); //电子社保卡连接
|
|
result = String.valueOf(json.get("sicardUrl")); //电子社保卡连接
|
|
|
|
|
|
|
|
//保存到患者表
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
isSuccess = false;
|
|
isSuccess = false;
|
|
@ -409,4 +411,62 @@ public class OnePayService {
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*更新所有记录的交易状态
|
|
|
|
*/
|
|
|
|
private List<WlyyCharge> updateTradeStatus(List<WlyyCharge> list)
|
|
|
|
{
|
|
|
|
//更新交易状态
|
|
|
|
if(list!=null &&list.size()>0)
|
|
|
|
{
|
|
|
|
for(WlyyCharge item:list)
|
|
|
|
{
|
|
|
|
try{
|
|
|
|
Charge charge = chargeQuery(item.getCode());
|
|
|
|
if(charge!=null)
|
|
|
|
{
|
|
|
|
item.setTradeStatus(charge.getTradeStatus()); // 交易状态0 成功 1 失败 2 已退款
|
|
|
|
item.setChargeNo(charge.getChargeNo()); // 流水号
|
|
|
|
item.setChargeTime(charge.getChargeTime()); // 扣费时间
|
|
|
|
item.setMedOrgNo(charge.getMedOrgNo()); // 医疗机构编码
|
|
|
|
item.setMedOrgName(charge.getMedOrgName()); //医疗机构名称
|
|
|
|
item.setBillNo(charge.getBillNo()); //待结算费用单据号
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
System.out.print("update trade status fail!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
chargeDao.save(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过交易关联代码获取交易列表
|
|
|
|
*/
|
|
|
|
public List<WlyyCharge> chargeList(String chargeType,String chargeRelation) throws Exception
|
|
|
|
{
|
|
|
|
List<WlyyCharge> list = chargeDao.findByChargeTypeAndChargeRelation(chargeType,chargeRelation);
|
|
|
|
|
|
|
|
return updateTradeStatus(list);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过患者代码获取交易列表
|
|
|
|
*/
|
|
|
|
public List<WlyyCharge> chargeListByPatient(String patient, Integer page, Integer size) throws Exception
|
|
|
|
{
|
|
|
|
|
|
|
|
PageRequest pageRequest = new PageRequest(page - 1, size);
|
|
|
|
List<WlyyCharge> list = chargeDao.findByPatient(patient,pageRequest);
|
|
|
|
|
|
|
|
return updateTradeStatus(list);
|
|
|
|
}
|
|
}
|
|
}
|