diff --git a/pom.xml b/pom.xml index ac75bc895..1176eb0a5 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 manage - 2.1.3 + 2.1.4 UTF-8 1.8.0 diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java index 5d48e8e1c..df8299a7b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/core/impl/CleanServiceImpl.java @@ -301,6 +301,14 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider } cleanLog.put("channels", channelsObj); cleanLog.put("client_moniker", client.getString("client_moniker")); + //跨境商城支持 +// JSONObject incremental = clientIncrementalMapper.findByClinetIdAndChannel(client.getIntValue("client_id"), "RP跨境商城"); +// if (incremental != null) { +// cleanLog.put("incremental_rate", incremental.getBigDecimal("incremental_rate_value")); +// cleanLog.putAll(incrementalAnalysisTransLogs(transactions)); +// BigDecimal royalpayTax = cleanLog.getBigDecimal("tax_amount").subtract(cleanLog.getBigDecimal("incremental_tax")); +// cleanLog.put("royalpay_tax", royalpayTax.setScale(2, RoundingMode.HALF_UP)); +// } return cleanLog; } @@ -1714,4 +1722,23 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider notices.add(new TodoNotice("settlement", settleDateSettingMsg, "#/analysis/clearing_logs/date_setting")); } } + + private JSONObject incrementalAnalysisTransLogs(List logs) { + final JSONObject analysis = new JSONObject(); + analysis.put("real_royalpay_charge", logs.parallelStream() + .map(log -> getSymbol(log).multiply(log.getBigDecimal("royal_surcharge"))) + .reduce(BigDecimal::add).orElse(BigDecimal.ZERO)); + analysis.put("incremental_charge", logs.parallelStream() + .map(log -> getSymbol(log).multiply(log.getBigDecimal("incremental_surcharge"))) + .reduce(BigDecimal::add).orElse(BigDecimal.ZERO)); + analysis.put("incremental_tax", logs.parallelStream() + .filter(log -> StringUtils.equalsIgnoreCase("RP跨境商城", log.getString("source"))) + .map(log -> getSymbol(log).multiply(log.getBigDecimal("incremental_surcharge")).divide(new BigDecimal(10), 2, RoundingMode.HALF_UP)) + .reduce(BigDecimal::add).orElse(BigDecimal.ZERO)); + return analysis; + } + + private BigDecimal getSymbol(JSONObject log) { + return "Credit".equals(log.getString("transaction_type")) || "Settlement".equals(log.getString("channel")) ? BigDecimal.ONE : BigDecimal.valueOf(-1); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/tradelog/beans/TradeLogQuery.java b/src/main/java/au/com/royalpay/payment/manage/tradelog/beans/TradeLogQuery.java index 0df88e908..1cfccc151 100644 --- a/src/main/java/au/com/royalpay/payment/manage/tradelog/beans/TradeLogQuery.java +++ b/src/main/java/au/com/royalpay/payment/manage/tradelog/beans/TradeLogQuery.java @@ -38,6 +38,7 @@ public class TradeLogQuery { private int group_bd; private String org_id; private String org_id2; + private boolean onlyIncrementAmount = false; public Integer getGatewayChild() { return gatewayChild; @@ -105,6 +106,9 @@ public class TradeLogQuery { if (StringUtils.isNotEmpty(org_id2)) { params.put("org_id2", org_id2); } + if (onlyIncrementAmount) { + params.put("onlyIncrementAmount", "1"); + } return params; } @@ -252,4 +256,12 @@ public class TradeLogQuery { public void setSource(String source) { this.source = source; } + + public boolean isOnlyIncrementAmount() { + return onlyIncrementAmount; + } + + public void setOnlyIncrementAmount(boolean onlyIncrementAmount) { + this.onlyIncrementAmount = onlyIncrementAmount; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java index aeb24fa8c..670392a95 100644 --- a/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/tradelog/core/impls/TradeLogServiceImpl.java @@ -63,10 +63,7 @@ import org.springframework.ui.Model; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintWriter; +import java.io.*; import java.math.BigDecimal; import java.math.RoundingMode; import java.text.DateFormat; @@ -137,6 +134,8 @@ public class TradeLogServiceImpl implements TradeLogService { // @Value("classpath:/jasper/trans_flow_new.jasper") @Value("classpath:/jasper/partner_invoice_gst.jasper") private org.springframework.core.io.Resource trans_flow; + @Value("classpath:/jasper/incremental_partner_invoice_gst.jasper") + private org.springframework.core.io.Resource incremental_trans_flow; @Value("classpath:/jasper/royalpay_logo.png") private org.springframework.core.io.Resource logo; @Value("classpath:/jasper/trans_excel.jasper") @@ -256,13 +255,6 @@ public class TradeLogServiceImpl implements TradeLogService { if (ManagerRole.BD_USER.hasRole(manager.getIntValue("role")) && !ManagerRole.ORG_MANAGER.hasRole(manager.getIntValue("role"))) { params.put("bd_user", manager.getString("manager_id")); } - if (query.isOnlyGroup() && ManagerRole.BD_LEADER.hasRole(manager.getIntValue("role"))) { - params.remove("bd_user"); - params.put("bd_group", manager.getString("manager_id")); - if (query.getGroup_bd() > 0) { - params.put("bd_group_bd", query.getGroup_bd()); - } - } orgManager.checkOrgIds(manager, params); if (query.getGatewayChild() != null) { params.put("trade_type", new ArrayList() {{ @@ -624,6 +616,20 @@ public class TradeLogServiceImpl implements TradeLogService { .filter(log -> log.getBigDecimal("settle_amount") != null) .map(log -> getSymbol(log).multiply(log.getBigDecimal("royal_surcharge"))) .reduce(BigDecimal::add).orElse(BigDecimal.ZERO)); + analysis.put("total_royalpay_fee", logs.parallelStream() + .filter(log -> log.getBigDecimal("settle_amount") != null) + .map(log -> getSymbol(log).multiply(log.getBigDecimal("royal_surcharge") + .add(log.getBigDecimal("surcharge_cashback")) + .add(log.getBigDecimal("channel_surcharge")))) + .reduce(BigDecimal::add).orElse(BigDecimal.ZERO)); + analysis.put("total_incremental_surcharge", logs.parallelStream() + .filter(log -> log.getBigDecimal("settle_amount") != null) + .map(log -> getSymbol(log).multiply(log.getBigDecimal("incremental_surcharge"))) + .reduce(BigDecimal::add).orElse(BigDecimal.ZERO)); + analysis.put("total_incremental_tax", logs.parallelStream() + .filter(log -> log.getBigDecimal("settle_amount") != null) + .map(log -> getSymbol(log).multiply(log.getBigDecimal("incremental_surcharge").divide(new BigDecimal(10), 2, RoundingMode.HALF_UP))) + .reduce(BigDecimal::add).orElse(BigDecimal.ZERO)); analysis.put("total_surcharge", logs.parallelStream() .filter(log -> log.getBigDecimal("settle_amount") != null) .map(log -> getSymbol(log).multiply(log.getBigDecimal("total_surcharge").add(log.getBigDecimal("tax_amount")))) @@ -696,7 +702,25 @@ public class TradeLogServiceImpl implements TradeLogService { parmerters.put("jd_fee", takeDecimalOrDefault(analysis, "jd_fee", BigDecimal.ZERO)); parmerters.put("alipay_online_fee", takeDecimalOrDefault(analysis, "alipay_online_fee", BigDecimal.ZERO)); parmerters.put("gst", takeDecimalOrDefault(analysis, "tax_amount", BigDecimal.ZERO)); + parmerters.put("royalpay_fee", takeDecimalOrDefault(analysis, "total_royalpay_fee", BigDecimal.ZERO)); + parmerters.put("incremental_fee", takeDecimalOrDefault(analysis, "total_incremental_surcharge", BigDecimal.ZERO)); + parmerters.put("incremental_gst", takeDecimalOrDefault(analysis, "total_incremental_tax", BigDecimal.ZERO)); + parmerters.put("royalpay_gst", analysis.getBigDecimal("tax_amount").subtract(analysis.getBigDecimal("total_incremental_tax")).setScale(2,RoundingMode.HALF_UP)); + dataList.parallelStream().forEach(item -> { + BigDecimal incrementalSurcharge = item.containsKey("incremental_surcharge") ? item.getBigDecimal("incremental_surcharge") : BigDecimal.ZERO; + BigDecimal taxAmount = item.containsKey("tax_amount") ? item.getBigDecimal("tax_amount") : BigDecimal.ZERO; + BigDecimal royalpaySurhcarge = item.containsKey("royal_surcharge") ? item.getBigDecimal("royal_surcharge") : BigDecimal.ZERO; + BigDecimal surhcargeBack = item.containsKey("surcharge_cashback") ? item.getBigDecimal("surcharge_cashback") : BigDecimal.ZERO; + BigDecimal channelSurcharge = item.containsKey("channel_surcharge") ? item.getBigDecimal("channel_surcharge") : BigDecimal.ZERO; + BigDecimal incrementalTax = incrementalSurcharge.divide(new BigDecimal(10), 2, RoundingMode.HALF_UP); + BigDecimal royalpayTax = taxAmount.subtract(incrementalTax); + BigDecimal realRoyalpayCharge = royalpaySurhcarge + .add(surhcargeBack) + .add(channelSurcharge) + .add(royalpayTax); + item.put("incremental_surcharge", incrementalSurcharge.add(incrementalTax).setScale(2, RoundingMode.HALF_UP)); + item.put("real_royalpay_surcharge", realRoyalpayCharge.setScale(2, RoundingMode.HALF_UP)); scaleDecimalVal(item, "display_amount", item.getString("currency")); String platformCurrency = PlatformEnvironment.getEnv().getForeignCurrency(); scaleDecimalVal(item, "clearing_amount", platformCurrency); @@ -708,7 +732,10 @@ public class TradeLogServiceImpl implements TradeLogService { String fileName = client.getString("client_moniker") + "_" + parmerters.getString("dateRange").replaceAll("/", ""); response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".pdf"); OutputStream outs = response.getOutputStream(); - byte[] bytes = JasperRunManager.runReportToPdf(trans_flow.getInputStream(), parmerters, jrDataSource); +// JSONObject clientIncrement = clientIncrementalMapper.findByClinetIdAndChannel(client.getIntValue("client_id"), "RP跨境商城"); + JSONObject clientIncrement = null; + InputStream jasper = clientIncrement == null ? trans_flow.getInputStream() : incremental_trans_flow.getInputStream(); + byte[] bytes = JasperRunManager.runReportToPdf(jasper, parmerters, jrDataSource); outs.write(bytes, 0, bytes.length); outs.flush(); outs.close(); diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml index 9cad5b62b..c186147d4 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml @@ -363,7 +363,7 @@ AND p.client_id = #{client_id} - LEFT JOIN pmt_transactions t + INNER JOIN pmt_transactions t ON t.order_id = o.order_id AND t.refund_id IS NULL AND t.transaction_type = 'Credit' @@ -391,6 +391,9 @@ AND t.system_transaction_id = #{search_text} + + AND t.incremental_surcharge >0 + AND p.org_id = #{org_id} @@ -668,6 +671,9 @@ and o.create_time < #{to} and date(o.create_time)=date(#{date}) and binary o.dev_id=#{dev_id} + + AND t.incremental_surcharge >0 + and o.status=#{std} diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml index d8785a7d8..a71c233a1 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml @@ -1146,6 +1146,9 @@ + diff --git a/src/main/ui/static/templates/payment/v1/qrpay.js b/src/main/ui/static/templates/payment/v1/qrpay.js index d1c2fbef8..9d7996ae0 100644 --- a/src/main/ui/static/templates/payment/v1/qrpay.js +++ b/src/main/ui/static/templates/payment/v1/qrpay.js @@ -14,27 +14,27 @@ $(function () { window.redirect = redirect; } } - - if (window.disable_ws) { - setTimeout(checkStatus, 3000); - - } else { - - var sock = new SockJS('/register'); - var client = Stomp.over(sock); - client.connect({}, function () { - client.subscribe('/app/payment/orders/' + window.order_id, function (msg) { - var json = JSON.parse(msg.body); - var concat = '?'; - if (window.redirect.indexOf('?') > 0) { - concat = '&'; - } - location.href = window.redirect + concat + 'time=' + json.time + '&nonce_str=' + json.nonce_str + '&sign=' + json.sign; - }) - },function () { - setTimeout(checkStatus, 3000); - }) - } + setTimeout(checkStatus, 3000); + // if (window.disable_ws) { + // + // + // } else { + // + // var sock = new SockJS('/register'); + // var client = Stomp.over(sock); + // client.connect({}, function () { + // client.subscribe('/app/payment/orders/' + window.order_id, function (msg) { + // var json = JSON.parse(msg.body); + // var concat = '?'; + // if (window.redirect.indexOf('?') > 0) { + // concat = '&'; + // } + // location.href = window.redirect + concat + 'time=' + json.time + '&nonce_str=' + json.nonce_str + '&sign=' + json.sign; + // }) + // },function () { + // setTimeout(checkStatus, 3000); + // }) + // } function checkStatus() { $.ajax({ url: 'status', @@ -54,4 +54,4 @@ $(function () { } }) } -}); \ No newline at end of file +});