|
@ -227,6 +227,17 @@ public class OnePayService {
|
|
|
OnepayDefaultClient onepayClient = new OnepayDefaultClient(config.getOnepayApi(), appId, appSecret, signType, encryptType);
|
|
|
String uuid = format.format(new Date()) + UUID.randomUUID().toString().replaceAll("-", "").substring(0, 4);
|
|
|
|
|
|
// 根据签约code查询签约信息
|
|
|
SignFamily signFamily = signFamilyDao.findByCode(chargeRelation);
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
Date begin = signFamily.getBegin();
|
|
|
Date end = signFamily.getEnd();
|
|
|
if (begin != null && end != null) {
|
|
|
totalAmount = getTotalAmount(sdf.format(begin), sdf.format(end), "yyyy-MM-dd");
|
|
|
} else {
|
|
|
return "-2";
|
|
|
}
|
|
|
|
|
|
charge.setChargeType(chargeType); //交易类型
|
|
|
charge.setChargeRelation(chargeRelation); //交易关联代码 wlyy_sign_family字段code
|
|
|
charge.setCode(uuid); // 接入应用支付业务流水号
|
|
@ -285,8 +296,6 @@ public class OnePayService {
|
|
|
params.put("subject", subject); //订单名称
|
|
|
params.put("wxToken", accessToken);
|
|
|
|
|
|
// 根据签约code查询签约信息
|
|
|
SignFamily signFamily = signFamilyDao.findByCode(chargeRelation);
|
|
|
if (signFamily != null) {
|
|
|
// //签约人Code
|
|
|
String signDoctorCode = signFamily.getSignDoctorCode();
|
|
@ -334,10 +343,10 @@ public class OnePayService {
|
|
|
principalCardNo = repSsc;
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(principalCardNo)){
|
|
|
if (StringUtils.isNotEmpty(principalCardNo)) {
|
|
|
map.put("principalCardNo", principalCardNo); //实际签约卡号( 默认为绑卡主体卡号)
|
|
|
charge.setPrincipalSsc(principalCardNo);
|
|
|
}else {
|
|
|
} else {
|
|
|
return "-1";
|
|
|
}
|
|
|
|
|
@ -453,7 +462,7 @@ public class OnePayService {
|
|
|
|
|
|
|
|
|
WlyyCharge chargePay = chargeDao.findByCode(outChargeNo);
|
|
|
if (request.containsKey("responseContent")){
|
|
|
if (request.containsKey("responseContent")) {
|
|
|
JSONObject responseContents = request.getJSONObject("responseContent");//医保结构体
|
|
|
if (responseContents != null) {
|
|
|
String miRegisterNo = null;//医保挂号
|
|
@ -523,7 +532,7 @@ public class OnePayService {
|
|
|
chargePay.setAccountPay(accountPay);
|
|
|
chargePay.setSelfPay(selfPay);
|
|
|
chargePay.setCivilPay(civilPay);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
@ -709,4 +718,46 @@ public class OnePayService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按月缴费获取签约月数
|
|
|
*
|
|
|
* @param fromStr
|
|
|
* @param toStr
|
|
|
* @param formatStr
|
|
|
* @return
|
|
|
*/
|
|
|
public static int monthBetween(String fromStr, String toStr, String formatStr) {
|
|
|
try {
|
|
|
SimpleDateFormat format = new SimpleDateFormat(formatStr);
|
|
|
Calendar bef = Calendar.getInstance();
|
|
|
Calendar aft = Calendar.getInstance();
|
|
|
bef.setTime(format.parse(fromStr));
|
|
|
aft.setTime(format.parse(toStr));
|
|
|
int result = aft.get(Calendar.MONTH) - bef.get(Calendar.MONTH);
|
|
|
int month = (aft.get(Calendar.YEAR) - bef.get(Calendar.YEAR)) * 12;
|
|
|
return Math.abs(month + result);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按月缴费获取总金额
|
|
|
*
|
|
|
* @param fromStr
|
|
|
* @param toStr
|
|
|
* @param formatStr
|
|
|
* @return
|
|
|
*/
|
|
|
public static String getTotalAmount(String fromStr, String toStr, String formatStr) {
|
|
|
try {
|
|
|
Double amount = monthBetween(fromStr, toStr, formatStr) * 7.5;
|
|
|
return "" + (int) (amount * 100);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return "0";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|