Merge branch 'develop'

master
Tayl0r 7 years ago
commit 0600b30702

@ -292,30 +292,52 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
return alipaySettleLog; return alipaySettleLog;
} }
public JSONObject getSystemClearingAmount(Date settle_date, SettlementLog settlementLog, String channel){ public JSONObject getSystemClearingAmount(Date settle_date, SettlementLog settlementLog, String channel) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 02:00:00"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 02:00:00");
JSONObject sysLogs = new JSONObject(); JSONObject sysLogs = new JSONObject();
String start_date = null; String start_date = null;
String end_date = null; String end_date = null;
if (StringUtils.equals("Wechat", channel)) { if (StringUtils.equals("Alipay", channel)) {
start_date = sdf.format(settlementLog.getStart());
end_date = sdf.format(settlementLog.getEnd());
logger.info("Wechat System Settle Logs:" + start_date + "<====>" + end_date);
} else {
JSONObject lastClearDay = estimateAnalysisMapper.findLastCleanDays(sdfClear.format(settle_date), 1); JSONObject lastClearDay = estimateAnalysisMapper.findLastCleanDays(sdfClear.format(settle_date), 1);
start_date = sdf.format(lastClearDay.getDate("date_str")); start_date = sdf.format(lastClearDay.getDate("date_str"));
end_date = sdf.format(settle_date); end_date = sdf.format(settle_date);
logger.info("Alipay System Settle Logs:" + start_date + "<====>" + end_date); logger.info("Alipay System Settle Logs:"+start_date+"<====>" +end_date);
} else if (StringUtils.equals("Wechat", channel)) {
start_date = sdf.format(settlementLog.getStart());
end_date = sdf.format(settlementLog.getEnd());
logger.info("Wechat System Settle Logs:"+start_date+"<====>" +end_date);
} else {
return null;
}
//2017-11-01后微信手续费0.5
BigDecimal wechat_rate;
if(end_date.compareTo("2017-11-01 03:00:00")<=0){
wechat_rate = new BigDecimal("0.006");
}else {
wechat_rate = new BigDecimal("0.005");
} }
try { try {
JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, channel, "Credit"); JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, channel, "Credit", wechat_rate);
sysLogs.put("sys_pay_fee", creditLogs.getBigDecimal("aud_amount")); sysLogs.put("sys_pay_fee", creditLogs.getBigDecimal("aud_amount"));
JSONObject debitLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, channel, "Debit");
JSONObject debitLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, channel, "Debit", wechat_rate);
sysLogs.put("sys_refund_fee", debitLogs.getBigDecimal("aud_amount")); sysLogs.put("sys_refund_fee", debitLogs.getBigDecimal("aud_amount"));
sysLogs.put("sys_net_fee", creditLogs.getBigDecimal("aud_amount").subtract(debitLogs.getBigDecimal("aud_amount"))); sysLogs.put("sys_net_fee", creditLogs.getBigDecimal("aud_amount").subtract(debitLogs.getBigDecimal("aud_amount")));
sysLogs.put("sys_surcharge", creditLogs.getBigDecimal("charge_amount").subtract(debitLogs.getBigDecimal("charge_amount"))); if (StringUtils.equals("Alipay", channel)) {
sysLogs.put("sys_surcharge", platformSettlementMapper.calculateRmbCharge(start_date, end_date, channel, new BigDecimal(0.006)));
} else if (StringUtils.equals("AlipayOnline", channel)) {
sysLogs.put("sys_surcharge", platformSettlementMapper.calculateRmbCharge(start_date, end_date, channel, new BigDecimal(0.018)));
} else {
sysLogs.put("sys_surcharge", creditLogs.getBigDecimal("charge_amount").subtract(debitLogs.getBigDecimal("charge_amount")));
}
sysLogs.put("sys_settle_fee", sysLogs.getBigDecimal("sys_net_fee").subtract(sysLogs.getBigDecimal("sys_surcharge"))); sysLogs.put("sys_settle_fee", sysLogs.getBigDecimal("sys_net_fee").subtract(sysLogs.getBigDecimal("sys_surcharge")));
return sysLogs; return sysLogs;
} catch (Exception e) { } catch (Exception e) {
//do nothing //do nothing
e.printStackTrace(); e.printStackTrace();

@ -32,11 +32,11 @@ public interface PlatformSettlementMapper {
PageList<JSONObject> findSettleLogsAllMerchant(@Param("channel") String channel, PageBounds pageBounds); PageList<JSONObject> findSettleLogsAllMerchant(@Param("channel") String channel, PageBounds pageBounds);
JSONObject calculateSysSettleLog(@Param("start_date") String start_date, @Param("end_date") String end_date, @Param("channel") String channel, @Param("transaction_type") String type); JSONObject calculateSysSettleLog(@Param("start_date") String start_date, @Param("end_date") String end_date, @Param("channel") String channel, @Param("transaction_type") String type, @Param("wechat_rate") BigDecimal wechat_rate);
JSONObject calculateSysSettleLog5(@Param("start_date") String start_date, @Param("end_date") String end_date, @Param("channel") String channel, @Param("transaction_type") String type); JSONObject calculateSysSettleLog5(@Param("start_date") String start_date, @Param("end_date") String end_date, @Param("channel") String channel, @Param("transaction_type") String type);
BigDecimal calculateRmbCharge(@Param("start_date") String start_date, @Param("end_date") String end_date, @Param("channel") String channel); BigDecimal calculateRmbCharge(@Param("start_date") String start_date, @Param("end_date") String end_date, @Param("channel") String channel,@Param("ali_rate") BigDecimal ali_rate);
@AutoSql(type = SqlType.DELETE) @AutoSql(type = SqlType.DELETE)
void delete(JSONObject params); void delete(JSONObject params);

@ -14,7 +14,7 @@
SELECT SELECT
sum(cny_amount) rmb_amount, sum(cny_amount) rmb_amount,
ifnull(sum(clearing_amount),0.00) aud_amount, ifnull(sum(clearing_amount),0.00) aud_amount,
ifnull(sum(ROUND(channel_surcharge)),0.00) charge_amount ifnull(sum(ROUND(clearing_amount * #{wechat_rate},2)),0.00) charge_amount
FROM FROM
pmt_transactions pmt_transactions
WHERE WHERE
@ -28,8 +28,8 @@
<select id="calculateRmbCharge" resultType="decimal"> <select id="calculateRmbCharge" resultType="decimal">
SELECT SELECT
IFNULL( IFNULL(
SUM(CASE transaction_type WHEN 'Credit' THEN channel_surcharge) SUM(CASE transaction_type WHEN 'Credit' THEN ROUND(ROUND(cny_amount * #{ali_rate}, 2) / exchange_rate,2)
WHEN 'Debit' THEN -channel_surcharge) WHEN 'Debit' THEN -ROUND(ROUND(cny_amount * #{ali_rate}, 2) / exchange_rate,2)
ELSE 0 END), ELSE 0 END),
0.00) ali_charge_amount 0.00) ali_charge_amount
FROM pmt_transactions FROM pmt_transactions

Loading…
Cancel
Save