|
|
|
@ -95,6 +95,7 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
|
|
|
|
|
// deleteSettleLogs();
|
|
|
|
|
generateWechatSettleLogs();
|
|
|
|
|
generateAlipaySettleLogs();
|
|
|
|
|
generateAlipayOnlineSettleLogs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
@ -124,9 +125,35 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void generateAlipayOnlineSettleLogs() {
|
|
|
|
|
try {
|
|
|
|
|
List<Date> dateList = TimeZoneUtils.getStatetime();
|
|
|
|
|
for (Date dateStr : dateList) {
|
|
|
|
|
try {
|
|
|
|
|
doVerifyAlipaySettleLog(dateStr);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("获取" + dateStr + "Alipay清算记录失败", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("获取Alipay清算记录时间失败", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
public void doVerifyAlipaySettleLog(Date dateStr) throws Exception {
|
|
|
|
|
JSONObject aliSettleLog = alipayClient.downloadRetailSettlements(dateStr);
|
|
|
|
|
saveAlipaySettleLog(dateStr, aliSettleLog, "Alipay");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
public void doVerifyAlipayOnlineSettleLog(Date dateStr) throws Exception {
|
|
|
|
|
JSONObject aliOnlineSettleLog = alipayClient.downloadOnlineSettlements(dateStr);
|
|
|
|
|
saveAlipaySettleLog(dateStr, aliOnlineSettleLog, "AlipayOnline");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveAlipaySettleLog(Date dateStr, JSONObject aliSettleLog, String channel) throws Exception {
|
|
|
|
|
if (aliSettleLog != null) {
|
|
|
|
|
JSONObject settleFee = getAliSettle(aliSettleLog);
|
|
|
|
|
JSONObject params = new JSONObject();
|
|
|
|
@ -138,17 +165,17 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
|
|
|
|
|
params.put("net_fee", settleFee.getBigDecimal("net_fee"));
|
|
|
|
|
params.put("surcharge", settleFee.getBigDecimal("surcharge"));
|
|
|
|
|
params.put("settlement_fee", settleFee.getBigDecimal("settlement_fee"));
|
|
|
|
|
params.put("channel", "Alipay");
|
|
|
|
|
params.put("channel", channel);
|
|
|
|
|
params.put("last_update_date", new Date());
|
|
|
|
|
JSONObject sysClearData = getSystemClearingAmount(dateStr,null,"Alipay");
|
|
|
|
|
if(sysClearData!=null && sysClearData.size()>0){
|
|
|
|
|
params.put("sys_pay_fee",sysClearData.getBigDecimal("sys_pay_fee"));
|
|
|
|
|
params.put("sys_refund_fee",sysClearData.getBigDecimal("sys_refund_fee"));
|
|
|
|
|
params.put("sys_net_fee",sysClearData.getBigDecimal("sys_net_fee"));
|
|
|
|
|
params.put("sys_surcharge",sysClearData.getBigDecimal("sys_surcharge"));
|
|
|
|
|
params.put("sys_settlement_fee",sysClearData.getBigDecimal("sys_settle_fee"));
|
|
|
|
|
JSONObject sysClearData = getSystemClearingAmount(dateStr, null, channel);
|
|
|
|
|
if (sysClearData != null && sysClearData.size() > 0) {
|
|
|
|
|
params.put("sys_pay_fee", sysClearData.getBigDecimal("sys_pay_fee"));
|
|
|
|
|
params.put("sys_refund_fee", sysClearData.getBigDecimal("sys_refund_fee"));
|
|
|
|
|
params.put("sys_net_fee", sysClearData.getBigDecimal("sys_net_fee"));
|
|
|
|
|
params.put("sys_surcharge", sysClearData.getBigDecimal("sys_surcharge"));
|
|
|
|
|
params.put("sys_settlement_fee", sysClearData.getBigDecimal("sys_settle_fee"));
|
|
|
|
|
}
|
|
|
|
|
JSONObject check = platformSettlementMapper.findByDateMerchant(sdfClear.format(dateStr), "Alipay", "All");
|
|
|
|
|
JSONObject check = platformSettlementMapper.findByDateMerchant(sdfClear.format(dateStr), channel, "All");
|
|
|
|
|
if (check != null) {
|
|
|
|
|
params.put("log_id", check.getString("log_id"));
|
|
|
|
|
platformSettlementMapper.update(params);
|
|
|
|
@ -213,14 +240,20 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
|
|
|
|
|
|
|
|
|
|
JSONArray payments = aliSettleLog.getJSONArray("payments");
|
|
|
|
|
BigDecimal credit = new BigDecimal(0.00);
|
|
|
|
|
BigDecimal creditFee = new BigDecimal(0.00);
|
|
|
|
|
BigDecimal creditSettle = new BigDecimal(0.00);
|
|
|
|
|
BigDecimal creditFee = new BigDecimal(0.00);
|
|
|
|
|
BigDecimal creditSettle = new BigDecimal(0.00);
|
|
|
|
|
if (payments != null) {
|
|
|
|
|
for (int i = 0; i < payments.size(); i++) {
|
|
|
|
|
JSONObject json = payments.getJSONObject(i);
|
|
|
|
|
credit = credit.add(json.getBigDecimal("transaction_amount"));
|
|
|
|
|
creditFee = creditFee.add(json.getBigDecimal("charge_fee"));
|
|
|
|
|
creditSettle = creditSettle.add(json.getBigDecimal("settle_amount"));
|
|
|
|
|
BigDecimal transactionAmount = json.getBigDecimal("transaction_amount");
|
|
|
|
|
BigDecimal chargeFee = json.getBigDecimal("charge_fee");
|
|
|
|
|
credit = credit.add(transactionAmount);
|
|
|
|
|
creditFee = creditFee.add(chargeFee);
|
|
|
|
|
if (json.containsKey("settle_amount")) {
|
|
|
|
|
creditSettle = creditSettle.add(json.getBigDecimal("settle_amount"));
|
|
|
|
|
} else {
|
|
|
|
|
creditSettle = creditSettle.add(transactionAmount.subtract(chargeFee));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
alipaySettleLog.put("credit", credit);
|
|
|
|
@ -233,9 +266,15 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
|
|
|
|
|
if (refunds != null) {
|
|
|
|
|
for (int i = 0; i < refunds.size(); i++) {
|
|
|
|
|
JSONObject json = refunds.getJSONObject(i);
|
|
|
|
|
debit = debit.add(json.getBigDecimal("transaction_amount"));
|
|
|
|
|
debitFee = debitFee.add(json.getBigDecimal("charge_fee"));
|
|
|
|
|
debitSettle = debitSettle.add(json.getBigDecimal("settle_amount"));
|
|
|
|
|
BigDecimal transactionAmount = json.getBigDecimal("transaction_amount");
|
|
|
|
|
BigDecimal chargeFee = json.getBigDecimal("charge_fee");
|
|
|
|
|
debit = debit.add(transactionAmount);
|
|
|
|
|
debitFee = debitFee.add(chargeFee);
|
|
|
|
|
if (json.containsKey("settle_amount")) {
|
|
|
|
|
debitSettle = debitSettle.add(json.getBigDecimal("settle_amount"));
|
|
|
|
|
} else {
|
|
|
|
|
debitSettle = debitSettle.add(transactionAmount.subtract(chargeFee));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
alipaySettleLog.put("debit", debit);
|
|
|
|
@ -246,23 +285,6 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
|
|
|
|
|
return alipaySettleLog;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void deleteSettleLogs() {
|
|
|
|
|
try {
|
|
|
|
|
List<Date> dateList = TimeZoneUtils.getStatetime();
|
|
|
|
|
for (Date dateStr : dateList) {
|
|
|
|
|
List<JSONObject> logs = platformSettlementMapper.findByDate(DateFormatUtils.format(dateStr, "yyyy-MM-dd"));
|
|
|
|
|
if (logs != null) {
|
|
|
|
|
for (JSONObject log : logs) {
|
|
|
|
|
platformSettlementMapper.delete(log);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JSONObject getSystemClearingAmount(Date settle_date, SettlementLog settlementLog, String channel) throws Exception {
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 02:00:00");
|
|
|
|
|
JSONObject sysLogs = new JSONObject();
|
|
|
|
|