|
@ -392,9 +392,9 @@ public class OnePayService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 家庭医生签约支付查询
|
|
|
* 家庭医生签约支付查询(v1.4.0作废)
|
|
|
*/
|
|
|
public String chargeQuery(String code, String accessToken) throws Exception {
|
|
|
public String chargeQueryBak(String code, String accessToken) throws Exception {
|
|
|
Boolean isSuccess = true;
|
|
|
String msgBody = "";
|
|
|
String response = "";
|
|
@ -538,9 +538,9 @@ public class OnePayService {
|
|
|
|
|
|
}
|
|
|
if ("0".equals(chargeStatus) || "SUCCESS".equals(chargeStatus)) {
|
|
|
chargePay.setTradeStatus("1");//交易状态 成功1 失败0
|
|
|
chargePay.setTradeStatus("0");//交易状态 成功0 失败1
|
|
|
} else {
|
|
|
chargePay.setTradeStatus("0");//交易状态 成功1 失败0
|
|
|
chargePay.setTradeStatus("1");//交易状态 成功0 失败1
|
|
|
}
|
|
|
chargePay.setChargeNo(chargeNo);//支付流水号
|
|
|
SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
@ -583,6 +583,68 @@ public class OnePayService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 家庭医生签约支付查询
|
|
|
*/
|
|
|
public String chargeQuery(String code, String accessToken) throws Exception {
|
|
|
Boolean isSuccess = true;
|
|
|
String msgBody = "";
|
|
|
String response = "";
|
|
|
String error = "";
|
|
|
String result = null;
|
|
|
PayConfigura config = configuraDao.findWorkConfigura();
|
|
|
|
|
|
try {
|
|
|
WlyyCharge charge = chargeDao.findByCode(code);
|
|
|
HospitalMapping hospitalMapping = hospitalMappingDao.findByCode(charge.getHospital());
|
|
|
OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), hospitalMapping.getAppId(), hospitalMapping.getAppSecret(), signType, encryptType);
|
|
|
|
|
|
RequestParams requestParams = new RequestParams();
|
|
|
requestParams.setAppId(hospitalMapping.getAppId());
|
|
|
requestParams.setTimestamp(DateUtil.getCurrentDateTime());
|
|
|
requestParams.setSignType(signType);
|
|
|
requestParams.setEncryptType(encryptType);
|
|
|
requestParams.setTransType(config.getChargeQueryType());
|
|
|
|
|
|
//业务参数
|
|
|
JSONObject params = new JSONObject();
|
|
|
params.put("outChargeNo", code); //接入应用结算业务流水号
|
|
|
params.put("wxToken", accessToken);
|
|
|
|
|
|
requestParams.setParam(params);
|
|
|
msgBody = JSON.toJSONString(requestParams);
|
|
|
//执行支付 返回原生返回值
|
|
|
ResponseParams<JSONObject> res = onepayClient.execute(requestParams);
|
|
|
response = JSON.toJSONString(res);
|
|
|
|
|
|
if (OnepayDefaultClient.isSuccessful(res)) {
|
|
|
//业务处理*******************
|
|
|
result = JSON.toJSONString(res.getParam());
|
|
|
Charge chargeView = objectMapper.readValue(result, Charge.class);
|
|
|
saveToWlyyCharge(chargeView);
|
|
|
LOGGER.info("请求成功,返回参数: " + result);
|
|
|
} 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();
|
|
|
}
|
|
|
|
|
|
//type = 3易联众接口保存http日志
|
|
|
logService.saveHttpLog(isSuccess, config.getChargeType(), "家庭医生签约支付查询", "POST", null, msgBody, response, error, logService.onepayType);
|
|
|
|
|
|
if (!isSuccess) {
|
|
|
throw new Exception(error);
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 生成电子社保卡
|
|
|
*/
|
|
@ -712,12 +774,135 @@ public class OnePayService {
|
|
|
* 更改数据 wlyy_sign_family wlyy_charge
|
|
|
*/
|
|
|
public void updateData(String chargeStatus, Date chargeTime, String chargeNo, WlyyCharge charge) throws Exception {
|
|
|
charge.setUploadLog("1");
|
|
|
if ("0".equals(chargeStatus) || "SUCCESS".equals(chargeStatus)) {
|
|
|
charge.setNeedUpload("1");
|
|
|
charge.setTradeStatus("0");//交易状态 0 成功 1 失败
|
|
|
// 成功支付根据wlyy_charge的code 去查找关联代码signCode在更新签约表
|
|
|
signFamilyDao.updatePatientBegin(charge.getChargeRelation(), chargeTime, chargeNo, "1", 2);
|
|
|
} else {
|
|
|
charge.setTradeStatus("1");//交易状态 0 成功 1 失败
|
|
|
}
|
|
|
charge.setUpdateTime(new Date());
|
|
|
chargeDao.save(charge);
|
|
|
// 成功支付根据wlyy_charge的code 去查找关联代码signCode在更新签约表
|
|
|
if ("0".equals(chargeStatus)) {
|
|
|
signFamilyDao.updatePatientBegin(charge.getChargeRelation(), chargeTime, chargeNo, "1", 2);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 只保存到家庭签约支付表
|
|
|
*
|
|
|
* @param chargeView 家庭签约支付展示类Charge
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public void saveToWlyyCharge(Charge chargeView) throws Exception {
|
|
|
String outChargeNo = chargeView.getOutChargeNo();
|
|
|
WlyyCharge chargePay = chargeDao.findByCode(outChargeNo);
|
|
|
|
|
|
String tradeStatus = chargeView.getTradeStatus();
|
|
|
String chargeNo = chargeView.getChargeNo();
|
|
|
String chargeTime = chargeView.getChargeTime();
|
|
|
String outChargeTime = chargeView.getOutChargeTime();
|
|
|
String medOrgNo = chargeView.getMedOrgNo();
|
|
|
String medOrgName = chargeView.getMedOrgName();
|
|
|
String billNo = chargeView.getBillNo();
|
|
|
String cardNo = chargeView.getCardNo();
|
|
|
String totalAmount = chargeView.getTotalAmount();
|
|
|
String insuranceAmount = chargeView.getInsuranceAmount();
|
|
|
String selfPayAmount = chargeView.getSelfPayAmount();
|
|
|
String userId = chargeView.getUserId();
|
|
|
String userName = chargeView.getUserName();
|
|
|
String idType = chargeView.getIdType();
|
|
|
String idNo = chargeView.getIdNo();
|
|
|
String responseContent = chargeView.getResponseContent();
|
|
|
|
|
|
chargePay.setChargeNo(chargeNo);//支付流水号
|
|
|
SimpleDateFormat formatDate = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
chargePay.setChargeTime(chargeTime);//支付平台交易成功时间
|
|
|
chargePay.setCreateTime(formatDate.parse(outChargeTime));//接入应用内业务时间
|
|
|
chargePay.setMedOrgNo(medOrgNo);//医疗机构编号
|
|
|
chargePay.setMedOrgName(medOrgName);//医疗机构名称
|
|
|
chargePay.setBillNo(billNo);//待结算费用单据号
|
|
|
chargePay.setSsc(cardNo);//医保卡号
|
|
|
chargePay.setTotalAmount(Integer.parseInt(totalAmount));//交易总金额
|
|
|
chargePay.setInsuranceAmount(Integer.parseInt(insuranceAmount));//医保支付金额
|
|
|
chargePay.setSelfpayAmount(Integer.parseInt(selfPayAmount));//自付金额
|
|
|
chargePay.setOpenid(userId);
|
|
|
chargePay.setName(userName);
|
|
|
chargePay.setIdType(idType);//证件类型
|
|
|
chargePay.setIdNo(idNo);//证件号码
|
|
|
|
|
|
JSONObject response = JSON.parseObject(responseContent);
|
|
|
String miRegisterNo = null;//医保挂号
|
|
|
String miCollectDate = null;//收费日期
|
|
|
String miCollectTime = null;//收费时间
|
|
|
String miSettleNo = null;//医保收费单据号 (医保签约号)
|
|
|
String miCollectStatus = null;//扣费状态
|
|
|
String miRegisterStatus = null;//登记状态
|
|
|
String cadresPay = "0";//公务员补助
|
|
|
String miTotalFee = "0";//本次报销总额
|
|
|
String healthCarePay = "0";//保健基金支付
|
|
|
String heathPay = "0";//健康账户支付
|
|
|
String accountPay = "0";//个人账户支付
|
|
|
String selfPay = "0";//个人现金支付
|
|
|
String civilPay = "0";//民政补助金额
|
|
|
|
|
|
if (response != null && response.containsKey("miRegisterNo")) {
|
|
|
miRegisterNo = response.getString("miRegisterNo");
|
|
|
}
|
|
|
if (response != null && response.containsKey("miCollectDate")) {
|
|
|
miCollectDate = response.getString("miCollectDate");
|
|
|
}
|
|
|
if (response != null && response.containsKey("miCollectTime")) {
|
|
|
miCollectTime = response.getString("miCollectTime");
|
|
|
}
|
|
|
if (response != null && response.containsKey("miSettleNo")) {
|
|
|
miSettleNo = response.getString("miSettleNo");
|
|
|
}
|
|
|
if (response != null && response.containsKey("miCollectStatus")) {
|
|
|
miCollectStatus = response.getString("miCollectStatus");
|
|
|
}
|
|
|
if (response != null && response.containsKey("miRegisterStatus")) {
|
|
|
miRegisterStatus = response.getString("miRegisterStatus");
|
|
|
}
|
|
|
if (response != null && response.containsKey("cadresPay")) {
|
|
|
cadresPay = response.getString("cadresPay");
|
|
|
}
|
|
|
if (response != null && response.containsKey("miTotalFee")) {
|
|
|
miTotalFee = response.getString("miTotalFee");
|
|
|
}
|
|
|
if (response != null && response.containsKey("healthCarePay")) {
|
|
|
healthCarePay = response.getString("healthCarePay");
|
|
|
}
|
|
|
if (response != null && response.containsKey("heathPay")) {
|
|
|
heathPay = response.getString("heathPay");
|
|
|
}
|
|
|
if (response != null && response.containsKey("accountPay")) {
|
|
|
accountPay = response.getString("accountPay");
|
|
|
}
|
|
|
if (response != null && response.containsKey("selfPay")) {
|
|
|
selfPay = response.getString("selfPay");
|
|
|
}
|
|
|
if (response != null && response.containsKey("civilPay")) {
|
|
|
civilPay = response.getString("civilPay");
|
|
|
}
|
|
|
|
|
|
chargePay.setMiRegisterNo(miRegisterNo);//医保挂号
|
|
|
chargePay.setMiCollectDate(miCollectDate);
|
|
|
chargePay.setMiCollectTime(miCollectTime);
|
|
|
chargePay.setMiSettleNo(miSettleNo);
|
|
|
chargePay.setMiCollectStatus(miCollectStatus);
|
|
|
chargePay.setMiRegisterStatus(miRegisterStatus);
|
|
|
chargePay.setCadresPay(cadresPay);
|
|
|
chargePay.setMiTotalFee(miTotalFee);
|
|
|
chargePay.setHealthCarePay(healthCarePay);
|
|
|
chargePay.setHeathPay(heathPay);
|
|
|
chargePay.setAccountPay(accountPay);
|
|
|
chargePay.setSelfPay(selfPay);
|
|
|
chargePay.setCivilPay(civilPay);
|
|
|
|
|
|
// 判断是否需要更新数据 needUpload为0不需要更新
|
|
|
LOGGER.info("before goto " + chargePay.getNeedUpload() + " == " + outChargeNo);
|
|
|
if (chargePay != null && !("0".equals(chargePay.getNeedUpload()))) {
|
|
|
updateData(tradeStatus, formatDate.parse(chargeTime), chargeNo, chargePay);
|
|
|
LOGGER.info("after goto " + chargePay.getNeedUpload() + " == " + outChargeNo);
|
|
|
}
|
|
|
}
|
|
|
|