|
@ -82,6 +82,12 @@ public class OnePayService {
|
|
|
Patient p = patientDao.findByCode(patient);
|
|
|
p.setOpenid(openid);
|
|
|
p.setSsc(card.getAttachCardNo());
|
|
|
// 增加绑定电子社保卡信息
|
|
|
p.setSicardStatus(1);
|
|
|
if (p.getSicardTime() == null) {
|
|
|
p.setSicardTime(new Date());
|
|
|
}
|
|
|
;
|
|
|
if (card.getAttachIdType() == "01") //身份证
|
|
|
{
|
|
|
p.setIdcard(card.getAttachIdNo());
|
|
@ -141,7 +147,6 @@ public class OnePayService {
|
|
|
requestParams.setEncryptType(encryptType);
|
|
|
|
|
|
|
|
|
|
|
|
// 请求报文体参数,详见接口文档各接口——请求参数定义
|
|
|
// 如医保绑卡信息请求参数
|
|
|
JSONObject params = new JSONObject();
|
|
@ -184,7 +189,7 @@ public class OnePayService {
|
|
|
/**
|
|
|
* 家庭医生签约支付
|
|
|
*/
|
|
|
public String charge(String orgCode, String chargeType, String chargeRelation, Integer totalAmount, String patient, String openid,String accessToken) throws Exception {
|
|
|
public String charge(String orgCode, String chargeType, String chargeRelation, Integer totalAmount, String patient, String openid, String accessToken) throws Exception {
|
|
|
//获取机构映射
|
|
|
HospitalMapping hos = hospitalMappingDao.findByCode(orgCode);
|
|
|
if (hos == null) {
|
|
@ -193,13 +198,13 @@ public class OnePayService {
|
|
|
// return charge(orgCode, hos.getName(), hos.getAppId(), hos.getAppSecret(),hos.getSbCode(), chargeType, chargeRelation, totalAmount,patient, openid,accessToken);
|
|
|
// 对应机构的APPID和appsecret
|
|
|
// return charge(orgCode, hos.getName(), "54BBAF5148521AC9E053F000660AC502", "54BBAF5148531AC9E053F000660AC502",hos.getSbCode(), chargeType, chargeRelation, totalAmount,patient, openid,accessToken);
|
|
|
return charge(orgCode, hos.getName(), "54BBAF5148521AC9E053F000660AC502", "54BBAF5148531AC9E053F000660AC502","0380", chargeType, chargeRelation, totalAmount,patient, openid,accessToken);
|
|
|
return charge(orgCode, hos.getName(), "54BBAF5148521AC9E053F000660AC502", "54BBAF5148531AC9E053F000660AC502", "0380", chargeType, chargeRelation, totalAmount, patient, openid, accessToken);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 家庭医生签约支付,成功则返回支付路径
|
|
|
*/
|
|
|
private String charge(String orgCode, String orgName, String appId, String appSecret,String sbCode, String chargeType, String chargeRelation, Integer totalAmount,String patient, String openid,String accessToken) throws Exception {
|
|
|
private String charge(String orgCode, String orgName, String appId, String appSecret, String sbCode, String chargeType, String chargeRelation, Integer totalAmount, String patient, String openid, String accessToken) throws Exception {
|
|
|
Boolean isSuccess = true;
|
|
|
String msgBody = "";
|
|
|
String response = "";
|
|
@ -266,18 +271,18 @@ public class OnePayService {
|
|
|
Properties systemConf = SystemConf.getInstance().getSystemProperties();
|
|
|
String returnUrl = systemConf.getProperty("return_url");
|
|
|
returnUrl = returnUrl.replace("{server}", serverUrl);
|
|
|
params.put("returnUrl",returnUrl); //页面跳转地址
|
|
|
params.put("returnUrl", returnUrl); //页面跳转地址
|
|
|
params.put("channel", channel); //微信医保支付
|
|
|
params.put("merchName", orgName); //收款单位名称
|
|
|
params.put("subject", subject); //订单名称
|
|
|
params.put("wxToken",accessToken);
|
|
|
params.put("wxToken", accessToken);
|
|
|
|
|
|
|
|
|
//extendParams 扩展入参
|
|
|
//家庭医生签约信息
|
|
|
// 根据签约code查询签约信息
|
|
|
SignFamily signFamily = signFamilyDao.findByCode(chargeRelation);
|
|
|
if (signFamily!=null){
|
|
|
if (signFamily != null) {
|
|
|
// //签约人Code
|
|
|
String signDoctorCode = signFamily.getSignDoctorCode();
|
|
|
String people = signFamily.getPatient();
|
|
@ -289,8 +294,8 @@ public class OnePayService {
|
|
|
Map<String, String> familyContent = new HashMap<>();
|
|
|
familyContent.put("moRegNo", "1481497932");//医院签约号限长20
|
|
|
// familyContent.put("moRegName",signFamily.getName()); //签约人姓名
|
|
|
familyContent.put("moRegName","林逸祥"); //签约人姓名
|
|
|
familyContent.put("moRegAddr",user.getAddress() ); //签约人地址
|
|
|
familyContent.put("moRegName", "林逸祥"); //签约人姓名
|
|
|
familyContent.put("moRegAddr", user.getAddress()); //签约人地址
|
|
|
familyContent.put("moRegTelephone", signFamily.getMobile());//签约人联系电话
|
|
|
familyContent.put("moRegOrgNo", sbCode); //签约机构 限长4
|
|
|
familyContent.put("moRegDocNo", doctor.getIdcard());//签约医生编号 限长18 身份证号
|
|
@ -302,7 +307,7 @@ public class OnePayService {
|
|
|
familyContent.put("moRegSource", signFamily.getSignSource()); //签约来源
|
|
|
familyContent.put("moCollectOrgNo", sbCode); //扣费机构 签约机构
|
|
|
familyContent.put("moCollectorNo", signFamily.getSignDoctorName());//扣费人 签约医生姓名
|
|
|
familyContent.put("benefitType", signFamily.getExpensesType() ); //补贴类型
|
|
|
familyContent.put("benefitType", signFamily.getExpensesType()); //补贴类型
|
|
|
familyContent.put("moBookOrgNo", sbCode);//登记机构 签约机构
|
|
|
familyContent.put("moBookerNo", signFamily.getSignDoctorName()); //登记人 签约医生姓名
|
|
|
familyContent.put("moBookTime", sdf.format(signFamily.getBegin())); //登记时间 签约时间
|
|
@ -353,7 +358,7 @@ public class OnePayService {
|
|
|
/**
|
|
|
* 家庭医生签约支付查询
|
|
|
*/
|
|
|
public Charge chargeQuery(String code,String accessToken) throws Exception {
|
|
|
public Charge chargeQuery(String code, String accessToken) throws Exception {
|
|
|
Boolean isSuccess = true;
|
|
|
String msgBody = "";
|
|
|
String response = "";
|
|
@ -460,6 +465,11 @@ public class OnePayService {
|
|
|
result = String.valueOf(json.get("sicardUrl")); //电子社保卡连接
|
|
|
|
|
|
//保存到患者表
|
|
|
Patient p = patientDao.findByCode(patient);
|
|
|
p.setOpenid(openid);
|
|
|
// 增加绑定电子社保卡信息
|
|
|
p.setSicardTime(new Date());
|
|
|
patientDao.save(p);
|
|
|
} else {
|
|
|
isSuccess = false;
|
|
|
error = "请求失败,返回结果:" + res.getRespCode() + "," + res.getRespMsg();
|
|
@ -486,12 +496,12 @@ public class OnePayService {
|
|
|
/**
|
|
|
* 更新所有记录的交易状态
|
|
|
*/
|
|
|
private List<WlyyCharge> updateTradeStatus(List<WlyyCharge> list,String accessToken) {
|
|
|
private List<WlyyCharge> updateTradeStatus(List<WlyyCharge> list, String accessToken) {
|
|
|
//更新交易状态
|
|
|
if (list != null && list.size() > 0) {
|
|
|
for (WlyyCharge item : list) {
|
|
|
try {
|
|
|
Charge charge = chargeQuery(item.getCode(),accessToken);
|
|
|
Charge charge = chargeQuery(item.getCode(), accessToken);
|
|
|
if (charge != null) {
|
|
|
item.setTradeStatus(charge.getTradeStatus()); // 交易状态0 成功 1 失败 2 已退款
|
|
|
item.setChargeNo(charge.getChargeNo()); // 流水号
|
|
@ -515,32 +525,32 @@ public class OnePayService {
|
|
|
/**
|
|
|
* 通过交易关联代码获取交易列表
|
|
|
*/
|
|
|
public List<WlyyCharge> chargeList(String chargeType, String chargeRelation,String accessToken) throws Exception {
|
|
|
public List<WlyyCharge> chargeList(String chargeType, String chargeRelation, String accessToken) throws Exception {
|
|
|
List<WlyyCharge> list = chargeDao.findByChargeTypeAndChargeRelation(chargeType, chargeRelation);
|
|
|
|
|
|
return updateTradeStatus(list,accessToken);
|
|
|
return updateTradeStatus(list, accessToken);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 通过患者代码获取交易列表
|
|
|
*/
|
|
|
public List<WlyyCharge> chargeListByPatient(String patient, String accessToken,Integer page, Integer size) throws Exception {
|
|
|
public List<WlyyCharge> chargeListByPatient(String patient, String accessToken, Integer page, Integer size) throws Exception {
|
|
|
|
|
|
PageRequest pageRequest = new PageRequest(page - 1, size);
|
|
|
List<WlyyCharge> list = chargeDao.findByPatient(patient, pageRequest);
|
|
|
|
|
|
return updateTradeStatus(list,accessToken);
|
|
|
return updateTradeStatus(list, accessToken);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更改数据 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 {
|
|
|
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();
|
|
|
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");
|
|
|
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");
|