Merge remote-tracking branch 'origin/alipayplus_aps' into alipayplus_aps

master
dalong306 3 years ago
commit 50da3e565f

@ -4,6 +4,7 @@ import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi;
import au.com.royalpay.payment.core.TransactionService;
import au.com.royalpay.payment.core.beans.PaymentQueryResult;
import au.com.royalpay.payment.core.beans.PreOrderRequest;
import au.com.royalpay.payment.core.beans.TransactionBizSubType;
import au.com.royalpay.payment.core.beans.coupon.CashCouponInfo;
import au.com.royalpay.payment.core.beans.coupon.CouponInfo;
import au.com.royalpay.payment.core.events.PaymentFinishedEvent;
@ -163,7 +164,7 @@ public class OneDollarDayActivitySupportImpl implements OneDollarDayActivity, Pa
log.put("transaction_time", format.format(paymentQueryResult.getPayTime()));
log.put("clearing_status", 0);
log.put("remark", "Activity: Day Of One Dollar");
transactionService.saveTransaction(log);
transactionService.saveTransaction(log, TransactionBizSubType.COUPON_PAY);
String transactionId = log.getString("transaction_id");
actDietOrderMapper.setTransactionId(orderId, transactionId, log.getDate("transaction_time"));
}
@ -214,7 +215,7 @@ public class OneDollarDayActivitySupportImpl implements OneDollarDayActivity, Pa
log.put("transaction_time", new Date());
log.put("clearing_status", 0);
log.put("remark", "Activity Refund: Day Of One Dollar");
transactionService.saveTransaction(log);
transactionService.saveTransaction(log,TransactionBizSubType.COUPON_REFUND);
actDietOrderMapper.updateRefund(orderId, log.getString("transaction_id"), log.getDate("transaction_time"));
}

@ -1,6 +1,5 @@
package au.com.royalpay.payment.manage.analysis.core;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
import com.alibaba.fastjson.JSONObject;
import java.util.Date;

@ -10,10 +10,9 @@ public interface PlatformClearService {
JSONObject getChannelSettleLog(String channel);
void verifySettleLogByDate(String start_date, String end_date, String channel) throws ParseException;
void verifySettleLogByDate(String startDate, String endDate, String channel) throws ParseException;
void generateSettleLogs();
void generateAliPaySettleLogs();
}

@ -3,7 +3,7 @@ package au.com.royalpay.payment.manage.analysis.core.impls;
import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig;
import au.com.royalpay.payment.channels.wechat.config.WechatPayEnvironment;
import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi;
import au.com.royalpay.payment.channels.wechat.runtime.beans.SettlementLog;
import au.com.royalpay.payment.core.beans.SettlementLog;
import au.com.royalpay.payment.manage.analysis.core.EstimateAnalysisService;
import au.com.royalpay.payment.manage.analysis.core.EstimateCacheSupport;
import au.com.royalpay.payment.manage.analysis.mappers.EstimateAnalysisMapper;

@ -1,34 +1,30 @@
package au.com.royalpay.payment.manage.analysis.core.impls;
import au.com.royalpay.payment.channels.alipay.runtime.AlipayClient;
import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig;
import au.com.royalpay.payment.channels.wechat.config.WechatPayEnvironment;
import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi;
import au.com.royalpay.payment.channels.wechat.runtime.beans.SettlementLog;
import au.com.royalpay.payment.core.exceptions.ChannelNetworkException;
import au.com.royalpay.payment.core.ChannelSettleVerify;
import au.com.royalpay.payment.core.beans.SettlementLog;
import au.com.royalpay.payment.manage.analysis.core.PlatformClearService;
import au.com.royalpay.payment.manage.analysis.mappers.EstimateAnalysisMapper;
import au.com.royalpay.payment.manage.mappers.log.PlatformSettlementMapper;
import au.com.royalpay.payment.tools.connections.attachment.core.AttachmentClient;
import au.com.royalpay.payment.tools.defines.PayChannel;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.utils.PageListUtils;
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@Service
public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
@ -37,16 +33,10 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
public static final SimpleDateFormat sdfClear = new SimpleDateFormat("yyyy-MM-dd");
public static final SimpleDateFormat sdfNormal = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Resource
private MpPaymentApi mpPaymentApi;
@Resource
private AlipayClient alipayClient;
@Autowired(required = false)
private ChannelSettleVerify[] channelSettleVerifys;
@Resource
private PlatformSettlementMapper platformSettlementMapper;
@Resource
private EstimateAnalysisMapper estimateAnalysisMapper;
@Resource
private AttachmentClient attachmentClient;
@Override
public JSONObject getPlatformSettleLog(String channel, int page, int limit) {
@ -58,10 +48,11 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
@Override
public JSONObject getChannelSettleLog(String channel) {
JSONObject sysLogs = new JSONObject();
JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog5("2018-04-05 02:00:00", sdfNormal.format(new Date()), channel, "Credit");
Date fromDate = DateTime.parse("2018-04-05T02:00:00+10:00").toDate();
JSONObject creditLogs = platformSettlementMapper.calculateChannelSysSettleLog(fromDate, new Date(), channel, "Credit");
sysLogs.put("sys_pay_fee", creditLogs.getBigDecimal("rmb_amount"));
JSONObject debitLogs = platformSettlementMapper.calculateSysSettleLog5("2018-04-05 02:00:00", sdfNormal.format(new Date()), channel, "Debit");
JSONObject debitLogs = platformSettlementMapper.calculateChannelSysSettleLog(fromDate, new Date(), channel, "Debit");
sysLogs.put("sys_refund_fee", debitLogs.getBigDecimal("rmb_amount"));
sysLogs.put("surcharge", creditLogs.getBigDecimal("charge_amount").subtract(debitLogs.getBigDecimal("charge_amount")));
@ -74,154 +65,41 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
}
@Override
public void verifySettleLogByDate(String start_date, String end_date, String channel) {
if (StringUtils.equals("Alipay", channel)) {
try {
doVerifyAlipaySettleLog(sdfClear.parse(end_date));
} catch (Exception e) {
logger.error("PlatformClearAnalysisServiceImpl.verifySettleLogByDate ==> 校验" + end_date + "支付宝到账失败:", e);
}
public void verifySettleLogByDate(String startDate, String endDate, String channel) {
if (channelSettleVerifys == null) {
return;
}
if (StringUtils.equals("AlipayOnline", channel)) {
Arrays.stream(channelSettleVerifys).filter(verify -> verify.payChannel().getChannelCode().equalsIgnoreCase(channel))
.findFirst().ifPresent(verify -> {
try {
doVerifyAlipayOnlineSettleLog(sdfClear.parse(end_date));
} catch (Exception e) {
logger.error("PlatformClearAnalysisServiceImpl.verifySettleLogByDate ==> 校验" + end_date + "支付宝Online到账失败", e);
throw new ChannelNetworkException("校验失败:", e);
}
}
if (StringUtils.equals("Wechat", channel)) {
try {
Map<String, Date> settleDate = new HashMap<>();
settleDate.put("from", sdfClear.parse(start_date));
settleDate.put("to", sdfClear.parse(end_date));
doVerifyWechatSettleLog(settleDate);
} catch (Exception e) {
logger.error("PlatformClearAnalysisServiceImpl.verifySettleLogByDate ==> 校验" + end_date + "微信到账失败:", e);
}
}
}
@Override
// @Transactional
public void generateSettleLogs() {
// deleteSettleLogs();
generateWechatSettleLogs();
generateAlipaySettleLogs();
generateAlipayOnlineSettleLogs();
Date currentDate = sdfClear.parse(startDate);
Date end = sdfClear.parse(endDate);
while (!end.before(currentDate)) {
saveVerifyResults(currentDate, verify);
currentDate = DateUtils.addDays(currentDate, 1);
}
@Override
@Transactional
public void generateAliPaySettleLogs() {
generateAlipaySettleLogs();
generateAlipayOnlineSettleLogs();
}
@Transactional
public void generateWechatSettleLogs() {
try {
Map<String, Date> settleDate = TimeZoneUtils.getStatetimeDays();
logger.info("开始查询" + settleDate.get("from") + "到" + settleDate.get("to") + "的微信清算记录");
doVerifyWechatSettleLog(settleDate);
} catch (ParseException e) {
e.printStackTrace();
}
throw new BadRequestException("Invalid Date Format");
}
private void generateAlipaySettleLogs() {
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);
});
}
}
private void generateAlipayOnlineSettleLogs() {
try {
List<Date> dateList = TimeZoneUtils.getStatetime();
for (Date dateStr : dateList) {
try {
doVerifyAlipayOnlineSettleLog(dateStr);
} catch (Exception e) {
logger.error("获取" + dateStr + "AlipayOnline清算记录失败", e);
}
}
} catch (Exception e) {
logger.error("获取AlipayOnline清算记录时间失败", e);
}
}
@Transactional
public void doVerifyAlipaySettleLog(Date dateStr) throws Exception {
JSONObject aliSettleLog = alipayClient.oldDownloadRetailSettlements(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();
params.put("settle_date", dateStr);
params.put("start_date", dateStr);
params.put("end_date", dateStr);
params.put("pay_fee", settleFee.getBigDecimal("credit"));
params.put("refund_fee", settleFee.getBigDecimal("debit"));
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", channel);
params.put("last_update_date", new Date());
JSONObject sysClearData = getSystemClearingAmount(dateStr, aliSettleLog, channel);
if (sysClearData != null && !sysClearData.isEmpty()) {
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), channel, "All");
if (check != null) {
params.put("log_id", check.getString("log_id"));
platformSettlementMapper.update(params);
} else {
platformSettlementMapper.save(params);
}
}
}
public void doVerifyWechatSettleLog(Map<String, Date> settleDate) {
List<SettlementLog> tencentSettle = new ArrayList<>();
for (WeChatPayConfig.Merchant mch : WechatPayEnvironment.getEnv().getWechatMerchantConfigs()) {
try {
tencentSettle = mpPaymentApi.settlementLogs(settleDate.get("from"), settleDate.get("to"), mch.getMerchantId());
if (tencentSettle == null) {
logger.info("【{}】下没有清算记录", mch.getMerchantId());
} else {
for (SettlementLog settle : tencentSettle) {
private void saveVerifyResults(Date date, ChannelSettleVerify verify) {
logger.info("starting verify for channel {} on {}", verify.payChannel(), date);
List<SettlementLog> logs = verify.verifyResults(date);
logger.info("loaded {} settle logs for channel {} on {}", logs.size(), verify.payChannel(), date);
for (SettlementLog settle : logs) {
JSONObject params = new JSONObject();
params.put("settle_date", settle.getSettlementDate());
params.put("start_date", settle.getStart());
params.put("end_date", settle.getEnd());
params.put("channel", "Wechat");
params.put("start_date", TimeZoneUtils.formatTime(settle.getStart(), TimeZoneUtils.PATTERN_NORMAL, "Asia/Shanghai"));
params.put("end_date", TimeZoneUtils.formatTime(settle.getEnd(), TimeZoneUtils.PATTERN_NORMAL, "Asia/Shanghai"));
if (verify.payChannel() == PayChannel.WECHAT) {
params.put("settle_date", TimeZoneUtils.formatTime(settle.getSettlementDate(), TimeZoneUtils.PATTERN_NORMAL, "Asia/Shanghai"));
}
params.put("channel", verify.payChannel().getChannelCode());
params.put("last_update_date", new Date());
JSONObject sysClearData = getSystemClearingAmount(null, settle, "Wechat");
JSONObject sysClearData = getSystemClearingAmount(settle, verify.payChannel().getChannelCode());
if (sysClearData != null && !sysClearData.isEmpty()) {
params.put("sys_pay_fee", sysClearData.getBigDecimal("sys_pay_fee"));
params.put("sys_refund_fee", sysClearData.getBigDecimal("sys_refund_fee"));
@ -229,16 +107,22 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
params.put("sys_surcharge", sysClearData.getBigDecimal("sys_surcharge"));
params.put("sys_settlement_fee", sysClearData.getBigDecimal("sys_settle_fee"));
}
params.put("merchants", mch.getMerchantId());
params.put("merchants", settle.getMerchantId());
params.put("pay_fee", settle.getPayFee());
params.put("refund_fee", settle.getRefundFee());
params.put("net_fee", settle.getPayNetFee());
if (verify.payChannel() != PayChannel.WECHAT) {
params.put("net_fee", settle.getPayFee().subtract(settle.getRefundFee()));
}
params.put("settlement_fee", settle.getSettlementFee());
params.put("surcharge", settle.getPoundageFee());
params.put("unsettle_fee", settle.getUnsettlementFee());
JSONObject check = platformSettlementMapper.findByDateMerchant(sdfClear.format(settle.getSettlementDate()), "Wechat",
mch.getMerchantId());
try {
if (("1500474722".equals(settle.getMerchantId()) && settle.getSettlementDate().before(DateTime.parse("2018-06-02").toDate())) ||
("1492874492".equals(settle.getMerchantId()) && settle.getSettlementDate().after(DateTime.parse("2018-06-05").toDate()))) {
return;
}
JSONObject check = platformSettlementMapper.findByDateMerchant(verify.payChannel() == PayChannel.WECHAT ? TimeZoneUtils.formatTime(settle.getSettlementDate(), TimeZoneUtils.PATTERN_NORMAL, "Asia/Shanghai") : sdfClear.format(settle.getSettlementDate()), verify.payChannel().getChannelCode(), settle.getMerchantId());
if (check != null) {
params.put("log_id", check.getString("log_id"));
platformSettlementMapper.update(params);
@ -246,123 +130,51 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
platformSettlementMapper.save(params);
}
params.clear();
logger.info("{}的微信清算记录查询完成", mch.getMerchantId());
}
}
} catch (Exception e) {
logger.error("【{}】下没有清算记录", mch.getMerchantId(), e);
logger.error(e.getMessage(), e);
}
}
}
public JSONObject getAliSettle(JSONObject aliSettleLog) {
JSONObject alipaySettleLog = new JSONObject();
JSONArray payments = aliSettleLog.getJSONArray("payments");
BigDecimal credit = BigDecimal.ZERO;
BigDecimal creditFee = BigDecimal.ZERO;
BigDecimal creditSettle = BigDecimal.ZERO;
if (payments != null) {
for (int i = 0; i < payments.size(); i++) {
JSONObject json = payments.getJSONObject(i);
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));
}
}
@Override
// @Transactional
public void generateSettleLogs() {
if (channelSettleVerifys != null) {
try {
List<Date> dateList = TimeZoneUtils.getStatetime();
for (Date date : dateList) {
for (ChannelSettleVerify verify : channelSettleVerifys) {
try {
saveVerifyResults(date, verify);
} catch (Exception e) {
logger.error("[{}]{} failed to download settle file", date, verify.payChannel(), e);
}
alipaySettleLog.put("credit", credit);
JSONArray refunds = aliSettleLog.getJSONArray("refunds");
logger.info("alipay的refunds清算总信息" + refunds.toJSONString());
BigDecimal debit = BigDecimal.ZERO;
BigDecimal debitFee = BigDecimal.ZERO;
BigDecimal debitSettle = BigDecimal.ZERO;
for (int i = 0; i < refunds.size(); i++) {
JSONObject json = refunds.getJSONObject(i);
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);
alipaySettleLog.put("net_fee", credit.subtract(debit));
alipaySettleLog.put("surcharge", creditFee.subtract(debitFee));
alipaySettleLog.put("settlement_fee", creditSettle.subtract(debitSettle));
logger.info("阿里清算日志:" + alipaySettleLog.toJSONString());
return alipaySettleLog;
} catch (ParseException ignored) {
}
public JSONObject getSystemClearingAmount(Date settle_date, Object settlementLog, String channel) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 02:00:00");
JSONObject sysLogs = new JSONObject();
String start_date = null;
String end_date = null;
if (StringUtils.equals("Alipay", channel)) {
JSONObject lastClearDay = estimateAnalysisMapper.findLastCleanDays(sdfClear.format(settle_date), 1);
start_date = sdf.format(lastClearDay.getDate("date_str"));
end_date = sdf.format(settle_date);
logger.info("Alipay System Settle Logs:" + start_date + "<====>" + end_date);
} else if (StringUtils.equals("Wechat", channel)) {
SettlementLog wechatSettleLog = (SettlementLog) settlementLog;
start_date = sdf.format(wechatSettleLog.getStart());
end_date = sdf.format(wechatSettleLog.getEnd());
logger.info("Wechat System Settle Logs:" + start_date + "<====>" + end_date);
} else if (StringUtils.equals("AlipayOnline", channel)) {
JSONObject alipayOnlineSettleLog = (JSONObject) settlementLog;
logger.info("AlipayOnline System Settle Logs:" + alipayOnlineSettleLog.getDate("min_time") + "<====>" + alipayOnlineSettleLog.getDate("max_time"));
start_date = sdf.format(alipayOnlineSettleLog.getDate("min_time"));
end_date = sdf.format(DateUtils.addDays(alipayOnlineSettleLog.getDate("max_time"), 1));
} 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");
}
// 2018-09-01后Alipay_Online手续费0.006
BigDecimal alipay_online_rate;
if (end_date.compareTo("2018-09-01 02:00:00") <= 0) {
alipay_online_rate = new BigDecimal("0.018");
} else {
alipay_online_rate = new BigDecimal("0.006");
}
private JSONObject getSystemClearingAmount(SettlementLog settlementLog, String channel) {
JSONObject sysLogs = new JSONObject();
logger.info("{} System Settle Logs:{}<====>{}", channel, settlementLog.getStart(), settlementLog.getEnd());
try {
JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, channel, "Credit", wechat_rate);
JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog(settlementLog.getStart(), settlementLog.getEnd(), settlementLog.getMerchantId(), channel, "Credit");
sysLogs.put("sys_pay_fee", creditLogs.getBigDecimal("aud_amount"));
JSONObject debitLogs = platformSettlementMapper.calculateSysSettleLog(start_date, end_date, channel, "Debit", wechat_rate);
JSONObject debitLogs = platformSettlementMapper.calculateSysSettleLog(settlementLog.getStart(), settlementLog.getEnd(), settlementLog.getMerchantId(), channel, "Debit");
sysLogs.put("sys_refund_fee", debitLogs.getBigDecimal("aud_amount"));
sysLogs.put("sys_net_fee", creditLogs.getBigDecimal("aud_amount").subtract(debitLogs.getBigDecimal("aud_amount")));
if (StringUtils.equals("Alipay", channel)) {
sysLogs.put("sys_surcharge", platformSettlementMapper.calculateRmbCharge(start_date, end_date, channel, BigDecimal.valueOf(0.006)));
} else if (StringUtils.equals("AlipayOnline", channel)) {
sysLogs.put("sys_surcharge", platformSettlementMapper.calculateRmbCharge(start_date, end_date, channel, alipay_online_rate));
} 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")));
logger.info("calculated system result[{}|{}~{}]:{}", channel, settlementLog.getStart(), settlementLog.getEnd(), sysLogs);
return sysLogs;
} catch (Exception e) {
//do nothing
e.printStackTrace();
logger.error("Error caught on analysising {}", channel, e);
}
return null;
}

@ -1,7 +1,7 @@
package au.com.royalpay.payment.manage.dev.web;
import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi;
import au.com.royalpay.payment.channels.wechat.runtime.beans.SettlementLog;
import au.com.royalpay.payment.core.beans.SettlementLog;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import org.apache.commons.lang3.time.DateUtils;

@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.fund.core.impls;
import au.com.royalpay.payment.core.SettlementDetailCalculator;
import au.com.royalpay.payment.core.TransactionService;
import au.com.royalpay.payment.core.beans.TransactionBizSubType;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.manage.fund.beans.XPlanFundConfig;
import au.com.royalpay.payment.manage.fund.core.XPlanFundConfigService;
@ -303,7 +304,7 @@ public class XPlanFundProcessorImpl implements XPlanFundProcesor {
tradeTransaction.put("channel", "System");
tradeTransaction.put("system_generate", 1);
tradeTransaction.put("remark", remark);
transactionService.saveTransaction(tradeTransaction);
transactionService.saveTransaction(tradeTransaction, TransactionBizSubType.DEPOSIT);
return tradeTransaction;
}

@ -32,12 +32,14 @@ public interface PlatformSettlementMapper {
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, @Param("wechat_rate") BigDecimal wechat_rate);
JSONObject calculateSysSettleLog(@Param("start_date") Date startDate, @Param("end_date") Date endDate, @Param("channel") String channel,
@Param("pid") String pid, @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,@Param("ali_rate") BigDecimal ali_rate);
BigDecimal calculateRmbCharge(@Param("start_date") Date start_date, @Param("end_date") Date end_date, @Param("channel") String channel);
@AutoSql(SqlType.DELETE)
void delete(JSONObject params);
JSONObject calculateChannelSysSettleLog(@Param("start_date") Date startDate, @Param("end_date") Date endDate, @Param("channel") String channel,
@Param("transaction_type") String type);
}

@ -4,6 +4,7 @@ import au.com.royalpay.payment.core.PaymentApi;
import au.com.royalpay.payment.core.TransactionService;
import au.com.royalpay.payment.core.beans.PaymentQueryResult;
import au.com.royalpay.payment.core.beans.PreOrderRequest;
import au.com.royalpay.payment.core.beans.TransactionBizSubType;
import au.com.royalpay.payment.core.beans.coupon.CouponInfo;
import au.com.royalpay.payment.core.events.PaymentFinishedEvent;
import au.com.royalpay.payment.core.events.RefundSendEvent;
@ -66,6 +67,7 @@ public class CtripCouponProvideProcessor implements PaymentProcessor {
private PmtOrderMapper pmtOrderMapper;
@Resource
private TransactionService transactionService;
@Override
public String processorId() {
return COUPON_ID + "_USE";
@ -180,7 +182,7 @@ public class CtripCouponProvideProcessor implements PaymentProcessor {
useCoupontrans.put("remark", "Ctrip Coupon from Customer:" + couponLogId);
accuessCouponLog = payCouponAccuessLogMapper.findAccuessLogByOrderId(orderId, new PageBounds(Order.formString("last_update_date.desc"))).get(0);
if (accuessCouponLog != null) {
transactionService.saveTransaction(useCoupontrans);
transactionService.saveTransaction(useCoupontrans, TransactionBizSubType.COUPON_PAY);
accuessCouponLog.put("is_valid", 1);
accuessCouponLog.put("last_update_date", new Date());
accuessCouponLog.put("transaction_id", useCoupontrans.getString("transaction_id"));
@ -221,7 +223,7 @@ public class CtripCouponProvideProcessor implements PaymentProcessor {
trans.put("transaction_time", new Date());
trans.put("remark", "Refund for Customer Ctrip Coupon:" + coupon_id);
logger.info("正在退款的券的信息" + trans.toJSONString());
transactionService.saveTransaction(trans);
transactionService.saveTransaction(trans, TransactionBizSubType.COUPON_REFUND);
logger.error("订单[" + orderId + "]发送全额退款,携程优惠券【" + coupon_id + "】转为Debit");
accuessCouponLog.put("transaction_refund_id", trans.getString("transaction_id"));
accuessCouponLog.put("refund_id", refundOrder.getString("refund_id"));

@ -1,6 +1,7 @@
package au.com.royalpay.payment.manage.rservices.core.impl;
import au.com.royalpay.payment.core.TransactionService;
import au.com.royalpay.payment.core.beans.TransactionBizSubType;
import au.com.royalpay.payment.core.mappers.PmtOrderMapper;
import au.com.royalpay.payment.manage.appclient.core.RetailAppService;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
@ -166,7 +167,7 @@ public class RServicesApplyServiceImpl implements RServicesApplyService {
transaction.put("clearing_status", 0);
transaction.put("remark", applyInfo.getString("service_code") + ":" + applyInfo.getString("title"));
transaction.put("system_generate", 1);
transactionService.saveTransaction(transaction);
transactionService.saveTransaction(transaction, TransactionBizSubType.OTHER);
JSONObject order = new JSONObject();
order.put("order_id", orderId);
order.put("org_id", client.getIntValue("org_id"));

@ -40,8 +40,4 @@ public class SettleEstimateTaskManger {
synchronizedScheduler.executeProcess("manage_task:genSettleLog", 120_000, () -> platformClearService.generateSettleLogs());
}
@Scheduled(cron = "0 0 10 * * ?")
public void generateSettleLogs2() {
synchronizedScheduler.executeProcess("manage_task:generateAliPaySettleLog", 120_000, () -> platformClearService.generateAliPaySettleLogs());
}
}

@ -3,9 +3,9 @@ package au.com.royalpay.payment.manage.tradelog.core.impls;
import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig;
import au.com.royalpay.payment.channels.wechat.config.WechatPayEnvironment;
import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi;
import au.com.royalpay.payment.channels.wechat.runtime.beans.SettlementLog;
import au.com.royalpay.payment.core.PaymentApi;
import au.com.royalpay.payment.core.TransactionService;
import au.com.royalpay.payment.core.beans.SettlementLog;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.core.exceptions.OrderNotMatchException;
import au.com.royalpay.payment.core.exceptions.ParamInvalidException;

@ -11,14 +11,13 @@
</select>
<select id="calculateSysSettleLog" resultType="com.alibaba.fastjson.JSONObject">
SELECT
sum(cny_amount) rmb_amount,
ifnull(sum(clearing_amount),0.00) aud_amount,
ifnull(sum(ROUND(clearing_amount * #{wechat_rate},2)),0.00) charge_amount
FROM
pmt_transactions
WHERE
order_channel = #{channel}
SELECT sum(t.cny_amount) rmb_amount,
ifnull(sum(t.clearing_amount), 0.00) aud_amount,
ifnull(sum(t.channel_surcharge), 0.00) charge_amount
FROM pmt_transactions t
inner join pmt_orders o on o.order_id = t.order_id
WHERE o.merchant_id = #{pid}
and order_channel = #{channel}
AND transaction_type = #{transaction_type}
AND transaction_time >= #{start_date}
AND #{end_date} > transaction_time
@ -38,16 +37,12 @@
AND #{end_date} > transaction_time
AND system_generate = 0
</select>
<select id="calculateSysSettleLog5" resultType="com.alibaba.fastjson.JSONObject">
SELECT
ifnull(sum(cny_amount),0.00) rmb_amount,
ifnull(sum(clearing_amount),0.00) aud_amount,
ifnull(sum(ROUND(cny_amount * 0.005,2)),0.00) charge_amount
FROM
pmt_transactions
WHERE
order_channel = #{channel}
<select id="calculateChannelSysSettleLog" resultType="com.alibaba.fastjson.JSONObject">
SELECT sum(t.cny_amount) rmb_amount,
ifnull(sum(t.clearing_amount), 0.00) aud_amount,
ifnull(sum(t.channel_surcharge), 0.00) charge_amount
FROM pmt_transactions t
WHERE order_channel = #{channel}
AND transaction_type = #{transaction_type}
AND transaction_time >= #{start_date}
AND #{end_date} > transaction_time

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Loading…
Cancel
Save