|
|
|
@ -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<Integer>() {{
|
|
|
|
@ -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();
|
|
|
|
|