Merge branch 'develop'

# Conflicts:
#	pom.xml
master
luoyang 5 years ago
commit bf447acd9b

@ -9,7 +9,7 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId> <artifactId>manage</artifactId>
<version>1.4.22</version> <version>1.4.23</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.8.0</jib-maven-plugin.version> <jib-maven-plugin.version>1.8.0</jib-maven-plugin.version>

@ -5,17 +5,20 @@ import au.com.royalpay.payment.manage.logview.beans.ClientLoginLogQueryBean;
import au.com.royalpay.payment.manage.management.clearing.core.CleanService; import au.com.royalpay.payment.manage.management.clearing.core.CleanService;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.manage.pos.datasource.ReadOnlyConnection; import au.com.royalpay.payment.manage.pos.datasource.ReadOnlyConnection;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.manage.signin.core.ClientLoginLogRepository; import au.com.royalpay.payment.manage.signin.core.ClientLoginLogRepository;
import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery;
import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.ParseException; import java.text.ParseException;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -27,6 +30,7 @@ import java.util.Map;
value = "/analysis/partner_card", method = RequestMethod.GET) value = "/analysis/partner_card", method = RequestMethod.GET)
public class PartnerCardDashboardController { public class PartnerCardDashboardController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Resource @Resource
private PartnerCardDashboardService partnerCardDashboardService; private PartnerCardDashboardService partnerCardDashboardService;
@Resource @Resource
@ -89,6 +93,19 @@ public class PartnerCardDashboardController {
return cleanService.getCleanLogTransactions(detailId, manager); return cleanService.getCleanLogTransactions(detailId, manager);
} }
@RequestMapping("/{client_id}/settlement_logs/report_date/{reportDate}")
@ReadOnlyConnection
public JSONObject listClearingTransactionsOfMergeSettle(@PathVariable int client_id, @PathVariable String reportDate,@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
Date date = new Date();
try {
date = DateUtils.parseDate(reportDate, "yyyy-MM-dd");
} catch (ParseException e) {
logger.error("parse report date error:{}", e.getMessage());
}
String realRDate = DateFormatUtils.format(DateUtils.addDays(date, 1), "yyyy-MM-dd");
return cleanService.getCleanLogTransactionsOfMergeSettle(client_id,realRDate, manager);
}
@RequestMapping("/settlement_logs/{detailId}/analysis/{channel}") @RequestMapping("/settlement_logs/{detailId}/analysis/{channel}")
@ReadOnlyConnection @ReadOnlyConnection
public Map<String,JSONObject> getDayAndChannelOfAnalysisMap(@PathVariable int detailId, public Map<String,JSONObject> getDayAndChannelOfAnalysisMap(@PathVariable int detailId,

@ -34,6 +34,8 @@ public interface CleanService {
JSONObject getCleanLogTransactions(int detailId, JSONObject manager); JSONObject getCleanLogTransactions(int detailId, JSONObject manager);
JSONObject getCleanLogTransactionsOfMergeSettle(int clientId, String repotDate, JSONObject manager);
Map<String,JSONObject> getDayAndChannelOfAnalysisMap(int detailId, String channel,JSONObject manager); Map<String,JSONObject> getDayAndChannelOfAnalysisMap(int detailId, String channel,JSONObject manager);
JSONObject getCleanLogTransactions(int client_id, String detailId); JSONObject getCleanLogTransactions(int client_id, String detailId);
@ -69,10 +71,16 @@ public interface CleanService {
JSONObject listClearingTransactions(int client_id, String clearingDetailId, JSONObject partner); JSONObject listClearingTransactions(int client_id, String clearingDetailId, JSONObject partner);
JSONObject listClearingTransactionsByMergeSettle(int client_id, String clearingDetailId, JSONObject partner);
Map<String,JSONObject> channelAndDayOfAnalysis(int client_id, String clearingDetailId, String channel,JSONObject partner); Map<String,JSONObject> channelAndDayOfAnalysis(int client_id, String clearingDetailId, String channel,JSONObject partner);
Map<String,JSONObject> channelAndDayOfMergeSettleAnalysis(int client_id, String reportDate, String channel,JSONObject partner);
void exportListClearingTransactions(int client_id, String clearingDetailId, JSONObject partner, HttpServletResponse resp); void exportListClearingTransactions(int client_id, String clearingDetailId, JSONObject partner, HttpServletResponse resp);
void exportTransactionsByReportDate(String reportDate, JSONObject partner, HttpServletResponse resp);
List<JSONObject> getSettlementMonthReport(int year, int monthOfYear); List<JSONObject> getSettlementMonthReport(int year, int monthOfYear);
void writeSettlementMonthReportToExcel(int year, int monthOfYear, OutputStream ous) throws IOException; void writeSettlementMonthReportToExcel(int year, int monthOfYear, OutputStream ous) throws IOException;

@ -304,6 +304,28 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
return cleanLog; return cleanLog;
} }
@Override
public JSONObject getCleanLogTransactionsOfMergeSettle(int clientId, String reportDate, JSONObject manager) {
JSONObject clearClient = clearingDetailMapper.listReportOfMergeSettle(reportDate, clientId);
if (clearClient == null) {
throw new NotFoundException();
}
JSONObject client = clientManager.getClientInfo(clientId);
Assert.notNull(client, "Client ID invalid");
checkOrgPermission(manager, client);
List<JSONObject> transactions = transactionMapper.listTransactionsOfMergeSettleClearingOrder(reportDate,clientId,
new PageBounds(Order.formString("order_id.asc")));
clearClient.put("report", transactions);
List<JSONObject> channels = clearingDetailAnalysisMapper.listReportChannelsOfMergeSettle(reportDate, clientId);
JSONObject channelsObj = new JSONObject();
for (JSONObject channel : channels) {
channelsObj.put(channel.getString("channel"), channel);
}
clearClient.put("channels", channelsObj);
clearClient.put("client_moniker", client.getString("client_moniker"));
return clearClient;
}
@Override @Override
public Map<String, JSONObject> getDayAndChannelOfAnalysisMap(int detailId, String channel, JSONObject manager) { public Map<String, JSONObject> getDayAndChannelOfAnalysisMap(int detailId, String channel, JSONObject manager) {
JSONObject cleanLog = clearingDetailMapper.findByDetailId(detailId); JSONObject cleanLog = clearingDetailMapper.findByDetailId(detailId);
@ -850,6 +872,40 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
return clearClient; return clearClient;
} }
@Override
public JSONObject listClearingTransactionsByMergeSettle(int client_id, String reportDate, JSONObject partner) {
JSONObject client = clientManager.getClientInfo(client_id);
Assert.notNull(client, "Client not exists");
int parent_client_id = client.getIntValue("parent_client_id");
if (partner.get("client_id") != null) {
if (client_id != partner.getIntValue("client_id") && parent_client_id != partner.getIntValue("client_id")) {
throw new ForbiddenException("No Permission");
}
}
JSONObject clearClient = clearingDetailMapper.listReportOfMergeSettle(reportDate, client_id);
if (clearClient == null) {
throw new NotFoundException();
}
List<JSONObject> transactions = transactionMapper.listTransactionsOfMergeSettleClearingOrder(reportDate,client_id,
new PageBounds(Order.formString("order_id.asc")));
String timezone_client = client.getString("timezone");
if (timezone_client != null) {
transactions.parallelStream().forEach(p -> {
TimeZoneUtils.switchTimeZone(p, timezone_client, "transaction_time");
});
}
clearClient.put("report", transactions);
List<JSONObject> channels = clearingDetailAnalysisMapper.listReportChannelsOfMergeSettle(reportDate, client_id);
JSONObject channelsObj = new JSONObject();
for (JSONObject channel : channels) {
channelsObj.put(channel.getString("channel"), channel);
}
clearClient.put("channels", channelsObj);
clearClient.put("client_moniker", client.getString("client_moniker"));
return clearClient;
}
@Override @Override
public Map<String, JSONObject> channelAndDayOfAnalysis(int client_id, String clearingDetailId, String channel, JSONObject partner) { public Map<String, JSONObject> channelAndDayOfAnalysis(int client_id, String clearingDetailId, String channel, JSONObject partner) {
JSONObject client = clientManager.getClientInfo(client_id); JSONObject client = clientManager.getClientInfo(client_id);
@ -862,6 +918,19 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
return getDayAnalysisMap(clearingDetailId, channel, client); return getDayAnalysisMap(clearingDetailId, channel, client);
} }
@Override
public Map<String, JSONObject> channelAndDayOfMergeSettleAnalysis(int client_id, String reportDate, String channel, JSONObject partner) {
JSONObject client = clientManager.getClientInfo(client_id);
Assert.notNull(client, "Client not exists");
int parent_client_id = client.getIntValue("parent_client_id");
if (client_id != partner.getIntValue("client_id") && parent_client_id != partner.getIntValue("client_id")) {
throw new ForbiddenException("No Permission");
}
JSONObject parentClient = clientManager.getClientInfo(parent_client_id);
return getDayAnalysisMapOfMergeSettle(reportDate, channel, parentClient);
}
private Map<String, JSONObject> getDayAnalysisMap(String clearingDetailId, String channel, JSONObject client) { private Map<String, JSONObject> getDayAnalysisMap(String clearingDetailId, String channel, JSONObject client) {
List<JSONObject> transactions = transactionMapper.listTransactionsOfClearingOrder(Integer.parseInt(clearingDetailId), List<JSONObject> transactions = transactionMapper.listTransactionsOfClearingOrder(Integer.parseInt(clearingDetailId),
new PageBounds(Order.formString("order_id.asc"))); new PageBounds(Order.formString("order_id.asc")));
@ -907,6 +976,51 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
return dayAnalysisMap; return dayAnalysisMap;
} }
private Map<String, JSONObject> getDayAnalysisMapOfMergeSettle(String reportDate, String channel, JSONObject client) {
List<JSONObject> transactions = transactionMapper.listTransactionsOfMergeSettleClearingOrder(reportDate, client.getIntValue("client_id"),
new PageBounds(Order.formString("order_id.asc")));
String timezone_client = client.getString("timezone");
if (!channel.equals("null")) {
transactions = transactions.stream().filter(t -> t.getString("channel").equals(channel)).collect(Collectors.toList());
}
List<String> dateKeysList = new ArrayList<>();
dateKeysList.add("transaction_time");
if (timezone_client != null) {
transactions.parallelStream().forEach(p -> {
TimeZoneUtils.switchTimeZone(p, timezone_client, "transaction_time");
});
TimeZoneUtils.switchTimeZoneToString(transactions, timezone_client, TimeZoneUtils.PATTERN_DATE, dateKeysList);
}
Map<String, List<JSONObject>> dayTransactionsMap = transactions.stream().collect(Collectors.groupingBy(x -> x.getString("transaction_time").substring(0, 10)));
Map<String, JSONObject> dayAnalysisMap = new TreeMap<>();
for (Map.Entry<String, List<JSONObject>> entry : dayTransactionsMap.entrySet()) {
JSONObject analysis = new JSONObject();
List<JSONObject> transactionsOfDay = entry.getValue();
BigDecimal total_credit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Credit")).filter(t -> t.containsKey("clearing_amount")).map(t -> t.getBigDecimal("clearing_amount")).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal total_debit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Debit")).filter(t -> t.containsKey("clearing_amount")).map(t -> t.getBigDecimal("clearing_amount")).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal total_charge_credit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Credit")).filter(t -> t.containsKey("total_surcharge")).map(t -> t.getBigDecimal("total_surcharge")).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal total_charge_debit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Debit")).filter(t -> t.containsKey("total_surcharge")).map(t -> t.getBigDecimal("total_surcharge")).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal net_amount_credit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Credit")).filter(t -> t.containsKey("settle_amount")).map(t -> t.getBigDecimal("settle_amount")).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal net_amount_debit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Debit")).filter(t -> t.containsKey("settle_amount")).map(t -> t.getBigDecimal("settle_amount")).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal tax_amount_credit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Credit")).filter(t -> t.containsKey("tax_amount")).map(t -> t.getBigDecimal("tax_amount")).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal tax_amount_debit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Debit")).filter(t -> t.containsKey("tax_amount")).map(t -> t.getBigDecimal("tax_amount")).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal tax_amount = tax_amount_credit.subtract(tax_amount_debit);
analysis.put("total_credit", total_credit.setScale(2, RoundingMode.HALF_UP));
analysis.put("total_debit", total_debit.setScale(2, RoundingMode.HALF_UP));
analysis.put("net_amount", net_amount_credit.subtract(net_amount_debit).setScale(2, RoundingMode.HALF_UP));
analysis.put("clearing_amount", net_amount_credit.subtract(net_amount_debit).setScale(2, RoundingMode.HALF_UP));
analysis.put("tax_amount", tax_amount.setScale(2, RoundingMode.HALF_UP));
analysis.put("total_surcharge", total_charge_credit.subtract(total_charge_debit).setScale(2, RoundingMode.HALF_UP));
analysis.put("total_charge", total_charge_credit.subtract(total_charge_debit).add(tax_amount).setScale(2, RoundingMode.HALF_UP));
analysis.put("gross_amount", total_credit.subtract(total_debit).setScale(2, RoundingMode.HALF_UP));
dayAnalysisMap.put(entry.getKey(), analysis);
}
return dayAnalysisMap;
}
@Override @Override
public void exportListClearingTransactions(int client_id, String clearingDetailId, JSONObject partner, HttpServletResponse resp) { public void exportListClearingTransactions(int client_id, String clearingDetailId, JSONObject partner, HttpServletResponse resp) {
OutputStream ous = null; OutputStream ous = null;
@ -1028,6 +1142,126 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
} }
} }
@Override
public void exportTransactionsByReportDate(String reportDate, JSONObject partner, HttpServletResponse resp) {
OutputStream ous = null;
try {
JSONObject clearTransation = listClearingTransactionsByMergeSettle(partner.getIntValue("client_id"), reportDate, partner);
resp.setContentType("application/octet-stream;");
resp.addHeader("Content-Disposition",
"attachment; filename=" + "Merchant_Settlement_Info_" + reportDate + ".xlsx");
ous = resp.getOutputStream();
Workbook wb = new XSSFWorkbook();
Cell cell = null;
Font font = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 10);
CellStyle analysisStyle = wb.createCellStyle();
analysisStyle.setFont(font);
//红色字体提示
Font font2 = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font2.setFontHeightInPoints((short) 10);
font2.setColor(HSSFColor.RED.index);
CellStyle analysisStyle2 = wb.createCellStyle();
analysisStyle2.setFont(font2);
Sheet sheet = wb.createSheet("Merchant_Settlement_Info_" + reportDate);
int rowNum = 0;
Row row = sheet.createRow(rowNum);
String[] title = {"order Id", "Client Order Id", "Transaction Time", "Channel", "Gateway", "Exchange Rate", "Transaction Type", "Currency",
"Input Amount", "Total Amount", "Clearing Amount(AUD)", "Sruchange Rate", "Surcharge(AUD)", "GST(AUD)", "Settle Amount(AUD)", "Remark", "Dev No", "Dev Remark"};
String[] analysis = {"Total Credit(AUD)", "Total Debit(AUD)", "Gross Amount(AUD)", "Total GST(AUD)", "Total Charge(AUD)", "Net Amount(AUD)"};
for (int i = 0; i < title.length; i++) {
row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]);
}
JSONObject channels = clearTransation.getJSONObject("channels");
for (Object o : clearTransation.getJSONArray("report")) {
JSONObject settle = (JSONObject) o;
if (settle.getBigDecimal("clearing_amount").compareTo(BigDecimal.ZERO) == 0) {
continue;
}
row = sheet.createRow(++rowNum);
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("order_id"));
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("client_order_id"));
Calendar calendar = (Calendar) settle.get("transaction_time");
row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(DateFormatUtils.format(calendar, "yyyy-MM-dd HH:mm:ss", calendar.getTimeZone()));
row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("channel"));
if (settle.getInteger("gateway") != null) {
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(TradeType.fromGatewayNumber(settle.getIntValue("gateway")).getTradeType());
} else {
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue("-");
}
row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("exchange_rate").setScale(5, BigDecimal.ROUND_DOWN).toPlainString());
cell = row.createCell(6, Cell.CELL_TYPE_STRING);
cell.setCellValue(settle.getString("transaction_type"));
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null);
row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("transaction_currency"));
cell = row.createCell(8, Cell.CELL_TYPE_STRING);
cell.setCellValue(settle.getBigDecimal("display_amount") == null ? ""
: "Credit".equals(settle.getString("transaction_type")) ?
settle.getBigDecimal("display_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString() :
"-" + settle.getBigDecimal("display_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null);
cell = row.createCell(9, Cell.CELL_TYPE_STRING);
cell.setCellValue(settle.getBigDecimal("transaction_amount") == null ? ""
: "Credit".equals(settle.getString("transaction_type")) ?
settle.getBigDecimal("transaction_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString() :
"-" + settle.getBigDecimal("transaction_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null);
cell = row.createCell(10, Cell.CELL_TYPE_STRING);
cell.setCellValue(settle.getBigDecimal("clearing_amount") == null ? ""
: "Credit".equals(settle.getString("transaction_type")) ?
settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString() :
"-" + settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null);
row.createCell(11, Cell.CELL_TYPE_STRING).setCellValue(channels.getString(settle.getString("channel")) == null ? ""
: channels.getJSONObject(settle.getString("channel")).getBigDecimal("rate").toPlainString() + "%");
//手续费 + gst
row.createCell(12, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("total_surcharge") == null ? ""
: settle.getBigDecimal("total_surcharge").setScale(2, RoundingMode.DOWN).toPlainString());
row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("tax_amount") == null ? ""
: settle.getBigDecimal("tax_amount").setScale(2, RoundingMode.DOWN).toPlainString());
cell = row.createCell(14, Cell.CELL_TYPE_STRING);
cell.setCellValue(settle.getBigDecimal("settle_amount") == null ? ""
: "Credit".equals(settle.getString("transaction_type")) ?
settle.getBigDecimal("settle_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString() :
"-" + settle.getBigDecimal("settle_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null);
row.createCell(15, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("order_detail"));
String clientDevId = StringUtils.defaultString(settle.getString("dev_id"), "-");
JSONObject device = clientDeviceMapper.find(settle.getString("dev_id"));
String clientDevRemark = "-";
if (device != null) {
clientDevId = device.getString("client_dev_id");
clientDevRemark = device.getString("remark");
}
row.createCell(16, Cell.CELL_TYPE_STRING).setCellValue(clientDevId);
row.createCell(17, Cell.CELL_TYPE_STRING).setCellValue(clientDevRemark);
}
row = sheet.createRow(++rowNum);
for (int i = 0; i < analysis.length; i++) {
cell = row.createCell(i, Cell.CELL_TYPE_STRING);
cell.setCellStyle(analysisStyle);
cell.setCellValue(analysis[i]);
}
row = sheet.createRow(++rowNum);
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(clearTransation.getString("total_payment"));
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(clearTransation.getString("total_refund"));
row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(clearTransation.getString("gross_amount"));
row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(clearTransation.getString("tax_amount"));
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(clearTransation.getString("total_charge"));
row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(clearTransation.getString("clearing_amount"));
wb.write(ous);
ous.flush();
} catch (IOException e) {
} finally {
IOUtils.closeQuietly(ous);
}
}
@Override @Override
public List<JSONObject> getSettlementMonthReport(int year, int monthOfYear) { public List<JSONObject> getSettlementMonthReport(int year, int monthOfYear) {
return clearingLogMapper.getSettlementMonthReport(year, monthOfYear); return clearingLogMapper.getSettlementMonthReport(year, monthOfYear);

@ -2,16 +2,19 @@ package au.com.royalpay.payment.manage.management.clearing.web;
import au.com.royalpay.payment.manage.management.clearing.core.CleanService; import au.com.royalpay.payment.manage.management.clearing.core.CleanService;
import au.com.royalpay.payment.manage.permission.manager.PartnerMapping; import au.com.royalpay.payment.manage.permission.manager.PartnerMapping;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.text.ParseException; import java.text.ParseException;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -23,6 +26,7 @@ import java.util.Map;
public class CleanLogClientController { public class CleanLogClientController {
@Resource @Resource
private CleanService cleanService; private CleanService cleanService;
private Logger logger = LoggerFactory.getLogger(getClass());
@RequestMapping @RequestMapping
public List<JSONObject> listMonthCleanLogs(@RequestParam String month, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject client) { public List<JSONObject> listMonthCleanLogs(@RequestParam String month, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject client) {
@ -39,18 +43,59 @@ public class CleanLogClientController {
return cleanService.listClearingTransactions(client_id, clearingDetailId, partner); return cleanService.listClearingTransactions(client_id, clearingDetailId, partner);
} }
@RequestMapping("/{client_id}/settlement_logs/report_date/{reportDate}")
public JSONObject listClearingTransactionsOfMergeSettle(@PathVariable int client_id, @PathVariable String reportDate,
@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner) {
Date date = new Date();
try {
date = DateUtils.parseDate(reportDate, "yyyy-MM-dd");
} catch (ParseException e) {
logger.error("parse report date error:{}", e.getMessage());
}
String realRDate = DateFormatUtils.format(DateUtils.addDays(date, 1), "yyyy-MM-dd");
JSONObject data = cleanService.listClearingTransactionsByMergeSettle(partner.getIntValue("client_id"), realRDate, partner);
data.put("report_date", reportDate);
return data;
}
@RequestMapping("/{client_id}/settlement_logs/{clearingDetailId}/analysis/{channel}") @RequestMapping("/{client_id}/settlement_logs/{clearingDetailId}/analysis/{channel}")
public Map<String,JSONObject> channelAndDayOfAnalysis(@PathVariable int client_id, @PathVariable String clearingDetailId, public Map<String,JSONObject> channelAndDayOfAnalysis(@PathVariable int client_id, @PathVariable String clearingDetailId,
@PathVariable String channel, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner) { @PathVariable String channel, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner) {
return cleanService.channelAndDayOfAnalysis(client_id, clearingDetailId,channel,partner); return cleanService.channelAndDayOfAnalysis(client_id, clearingDetailId,channel,partner);
} }
@RequestMapping("/{client_id}/settlement_logs/report_date/{reportDate}/analysis/{channel}")
public Map<String,JSONObject> channelAndDayOfMergeSettleAnalysis(@PathVariable int client_id, @PathVariable String reportDate,
@PathVariable String channel, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner) {
Date date = new Date();
try {
date = DateUtils.parseDate(reportDate, "yyyy-MM-dd");
} catch (ParseException e) {
logger.error("parse report date error:{}", e.getMessage());
}
String realRDate = DateFormatUtils.format(DateUtils.addDays(date, 1), "yyyy-MM-dd");
return cleanService.channelAndDayOfMergeSettleAnalysis(client_id, realRDate,channel,partner);
}
@PartnerMapping("/{client_id}/settlement_logs/{clearingDetailId}/export") @PartnerMapping("/{client_id}/settlement_logs/{clearingDetailId}/export")
public void exportListClearingTransactions(@PathVariable int client_id, @PathVariable String clearingDetailId, public void exportListClearingTransactions(@PathVariable int client_id, @PathVariable String clearingDetailId,
@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse resp) { @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse resp) {
cleanService.exportListClearingTransactions(client_id, clearingDetailId, partner, resp); cleanService.exportListClearingTransactions(client_id, clearingDetailId, partner, resp);
} }
@PartnerMapping("/{client_id}/settlement_logs/report_date/{reportDate}/export")
public void exportTransactionsByReportDate(@PathVariable int client_id, @PathVariable String reportDate,
@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse resp) {
Date date = new Date();
try {
date = DateUtils.parseDate(reportDate, "yyyy-MM-dd");
} catch (ParseException e) {
logger.error("parse report date error:{}", e.getMessage());
}
String realRDate = DateFormatUtils.format(DateUtils.addDays(date, 1), "yyyy-MM-dd");
cleanService.exportTransactionsByReportDate(realRDate, partner, resp);
}
// @RequestMapping(value = "/{clearId}.json") // @RequestMapping(value = "/{clearId}.json")
// public JSONObject getCleanLog(@PathVariable int clearId, @ModelAttribute(Consts.PARTNER_STATUS) JSONObject // public JSONObject getCleanLog(@PathVariable int clearId, @ModelAttribute(Consts.PARTNER_STATUS) JSONObject
// client) { // client) {

@ -26,6 +26,8 @@ public interface ClearingDetailAnalysisMapper {
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
List<JSONObject> listReportChannels(@Param("clearing_detail_id") String clearDetailId); List<JSONObject> listReportChannels(@Param("clearing_detail_id") String clearDetailId);
List<JSONObject> listReportChannelsOfMergeSettle(@Param("report_date") String reportDate, @Param("client_id") int clientId);
BigDecimal getSysCleaingAmount(@Param("settle_date") String settle_date, @Param("channel") String channel); BigDecimal getSysCleaingAmount(@Param("settle_date") String settle_date, @Param("channel") String channel);
void clearAnalysis(@Param("clearing_id") int clearingId); void clearAnalysis(@Param("clearing_id") int clearingId);

@ -37,6 +37,8 @@ public interface ClearingDetailMapper {
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
JSONObject listReport(@Param("clear_detail_id") String clearDetailId, @Param("client_id") int client_id); JSONObject listReport(@Param("clear_detail_id") String clearDetailId, @Param("client_id") int client_id);
JSONObject listReportOfMergeSettle(@Param("report_date") String reportDate, @Param("client_id") int client_id);
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
JSONObject listReportByDate(@Param("report_date") Date date, @Param("client_id") int clientId); JSONObject listReportByDate(@Param("report_date") Date date, @Param("client_id") int clientId);

@ -58,6 +58,8 @@ public interface TransactionMapper {
List<JSONObject> listTransactionsOfClearingOrder(@Param("clearing_order") int detailId, PageBounds pagination); List<JSONObject> listTransactionsOfClearingOrder(@Param("clearing_order") int detailId, PageBounds pagination);
List<JSONObject> listTransactionsOfMergeSettleClearingOrder(@Param("report_date") String reportDate, @Param("client_id") int clientId, PageBounds pagination);
List<JSONObject> listSettlementTransactions(@Param("clearing_order") int detailId); List<JSONObject> listSettlementTransactions(@Param("clearing_order") int detailId);
PageList<JSONObject> listSettlementLog(JSONObject params, PageBounds pagination); PageList<JSONObject> listSettlementLog(JSONObject params, PageBounds pagination);

@ -558,4 +558,6 @@ public interface ClientManager {
RSvcMchBean findSvcMchByAccountId(String accountId); RSvcMchBean findSvcMchByAccountId(String accountId);
void queryModifyClientIds(int clientId, JSONObject params); void queryModifyClientIds(int clientId, JSONObject params);
boolean getMergeSettleStatus(JSONObject client);
} }

@ -82,6 +82,7 @@ import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult; import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
@ -4004,6 +4005,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
JSONObject params = query.toParams(timezone); JSONObject params = query.toParams(timezone);
params.put("client_id", client_id); params.put("client_id", client_id);
queryModifyClientIds(client_id, params); queryModifyClientIds(client_id, params);
boolean mergeSettle = getMergeSettleStatus(client);
if (mergeSettle && query.getClient_ids() == null) {
params.remove("client_ids");
params.put("merge_settle", true);
}
PageList<JSONObject> logs = transactionMapper.listSettlementLog(params, PageList<JSONObject> logs = transactionMapper.listSettlementLog(params,
new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc"))); new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc")));
JSONObject result = PageListUtils.buildPageListResult(logs); JSONObject result = PageListUtils.buildPageListResult(logs);
@ -4047,17 +4054,25 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
JSONObject params = query.toParams(timezone); JSONObject params = query.toParams(timezone);
params.put("client_id", client_id); params.put("client_id", client_id);
queryModifyClientIds(client_id, params); queryModifyClientIds(client_id, params);
boolean mergeSettle = getMergeSettleStatus(client);
if (mergeSettle && query.getClient_ids() == null) {
params.remove("client_ids");
params.put("merge_settle", true);
}
PageList<JSONObject> logs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), 10000, Order.formString("clearing_time.desc"))); PageList<JSONObject> logs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), 10000, Order.formString("clearing_time.desc")));
//Excel 多sheet导出 //Excel 多sheet导出
try (HSSFWorkbook workbook = new HSSFWorkbook()) { try (HSSFWorkbook workbook = new HSSFWorkbook()) {
if (query.getClient_ids() == null) { if (query.getClient_ids() == null) {
addSheet(0, workbook, client, logs); addSheet(0, workbook, client, logs);
List<JSONObject> childs = clientMapper.listChildClients(client.getIntValue("client_id")); if (!mergeSettle) {
for (int i = 0; i < childs.size(); i++) { List<JSONObject> childs = clientMapper.listChildClients(client.getIntValue("client_id"));
params.put("client_id", childs.get(i).getInteger("client_id")); for (int i = 0; i < childs.size(); i++) {
PageList<JSONObject> childLogs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), 10000, Order.formString("clearing_time.desc"))); params.put("client_id", childs.get(i).getInteger("client_id"));
if (childLogs.size() > 0) { PageList<JSONObject> childLogs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), 10000, Order.formString("clearing_time.desc")));
addSheet(i + 1, workbook, childs.get(i), childLogs); if (childLogs.size() > 0) {
addSheet(i + 1, workbook, childs.get(i), childLogs);
}
} }
} }
} else { } else {
@ -6671,6 +6686,20 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
} }
} }
@Override
public boolean getMergeSettleStatus(JSONObject client) {
String extParams = client.getString("ext_params");
if (extParams != null) {
try {
JSONObject ext = JSON.parseObject(extParams);
return ext.getBooleanValue("merge_settle");
} catch (JSONException e) {
return false;
}
}
return false;
}
private void afterGeekShopSave(JSONObject serviceInfo, JSONObject client) { private void afterGeekShopSave(JSONObject serviceInfo, JSONObject client) {
JSONObject clientConfig = clientConfigMapper.find(client.getIntValue("client_id")); JSONObject clientConfig = clientConfigMapper.find(client.getIntValue("client_id"));
clientConfig.put("geek_shop_status", 1); clientConfig.put("geek_shop_status", 1);

@ -1000,15 +1000,22 @@ public class TradeLogServiceImpl implements TradeLogService {
@Override @Override
public JSONObject listSettlementLog(TradeLogQuery query, JSONObject partner) { public JSONObject listSettlementLog(TradeLogQuery query, JSONObject partner) {
JSONObject client = clientManager.getClientInfoByMoniker(partner.getString("client_moniker"));
int clientId = partner.getIntValue("client_id"); int clientId = partner.getIntValue("client_id");
String timezone = partner.getJSONObject("client").getString("timezone"); String timezone = partner.getJSONObject("client").getString("timezone");
JSONObject params = query.toParams(timezone); JSONObject params = query.toParams(timezone);
params.put("client_id", clientId); params.put("client_id", clientId);
clientManager.queryModifyClientIds(clientId, params); clientManager.queryModifyClientIds(clientId, params);
JSONObject result = new JSONObject();
result.put("analysis", transactionMapper.getClientAmountAnalysis(params));
boolean mergeSettle = clientManager.getMergeSettleStatus(client);
if (mergeSettle && query.getClient_ids() == null) {
params.remove("client_ids");
params.put("merge_settle", true);
}
PageList<JSONObject> logs = transactionMapper.listSettlementLog(params, PageList<JSONObject> logs = transactionMapper.listSettlementLog(params,
new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc"))); new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc")));
JSONObject result = PageListUtils.buildPageListResult(logs); result.putAll(PageListUtils.buildPageListResult(logs));
result.put("analysis", transactionMapper.getClientAmountAnalysis(params));
if (query.getPage() == 1) { if (query.getPage() == 1) {
if (!logs.isEmpty()) { if (!logs.isEmpty()) {
JSONObject clearingDetail = clearingDetailMapper.findByDetailId(logs.get(0).getIntValue("clear_detail_id")); JSONObject clearingDetail = clearingDetailMapper.findByDetailId(logs.get(0).getIntValue("clear_detail_id"));
@ -1039,17 +1046,25 @@ public class TradeLogServiceImpl implements TradeLogService {
JSONObject params = query.toParams(timezone); JSONObject params = query.toParams(timezone);
params.put("client_id", clientId); params.put("client_id", clientId);
clientManager.queryModifyClientIds(clientId, params); clientManager.queryModifyClientIds(clientId, params);
boolean mergeSettle = clientManager.getMergeSettleStatus(client);
if (mergeSettle && query.getClient_ids() == null) {
params.remove("client_ids");
params.put("merge_settle", true);
}
PageList<JSONObject> logs = transactionMapper.listSettlementLog(params, PageList<JSONObject> logs = transactionMapper.listSettlementLog(params,
new PageBounds(1, 100000000, Order.formString("clearing_time.desc"))); new PageBounds(1, 100000000, Order.formString("clearing_time.desc")));
try (HSSFWorkbook workbook = new HSSFWorkbook()) { try (HSSFWorkbook workbook = new HSSFWorkbook()) {
if (query.getClient_ids() == null) { if (query.getClient_ids() == null) {
addSheet(0, workbook, client, logs); addSheet(0, workbook, client, logs);
List<JSONObject> childs = clientMapper.listChildClients(client.getIntValue("client_id")); if (!mergeSettle) {
for (int i = 0; i < childs.size(); i++) { List<JSONObject> childs = clientMapper.listChildClients(client.getIntValue("client_id"));
params.put("client_id", childs.get(i).getInteger("client_id")); for (int i = 0; i < childs.size(); i++) {
PageList<JSONObject> childLogs = transactionMapper.listSettlementLog(params, new PageBounds(1, 100000000, Order.formString("clearing_time.desc"))); params.put("client_id", childs.get(i).getInteger("client_id"));
if (childLogs.size() > 0) { PageList<JSONObject> childLogs = transactionMapper.listSettlementLog(params, new PageBounds(1, 100000000, Order.formString("clearing_time.desc")));
addSheet(i + 1, workbook, childs.get(i), childLogs); if (childLogs.size() > 0) {
addSheet(i + 1, workbook, childs.get(i), childLogs);
}
} }
} }
} else { } else {

@ -3,14 +3,14 @@ spring.datasource.type = com.zaxxer.hikari.HikariDataSource
#数据源master #数据源master
spring.datasource.master.schema-name=royalpay_production spring.datasource.master.schema-name=royalpay_production
spring.datasource.master.host=192.168.0.4:3306 spring.datasource.master.host=119.28.3.196:3310
spring.datasource.master.jdbc-url=jdbc:mysql://${spring.datasource.master.host}/${spring.datasource.master.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false spring.datasource.master.jdbc-url=jdbc:mysql://${spring.datasource.master.host}/${spring.datasource.master.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.master.username=taylor spring.datasource.master.username=readonly
spring.datasource.master.password=taylor spring.datasource.master.password=read0nly
#数据源salve #数据源salve
spring.datasource.slave.schema-name=royalpay_production spring.datasource.slave.schema-name=royalpay_production
spring.datasource.slave.host=192.168.0.4:3306 spring.datasource.slave.host=119.28.3.196:3310
spring.datasource.slave.jdbc-url=jdbc:mysql://${spring.datasource.slave.host}/${spring.datasource.slave.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false spring.datasource.slave.jdbc-url=jdbc:mysql://${spring.datasource.slave.host}/${spring.datasource.slave.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.slave.username=taylor spring.datasource.slave.username=readonly
spring.datasource.slave.password=taylor spring.datasource.slave.password=read0nly

@ -1,6 +1,16 @@
spring.datasource.driver-class-name=com.mysql.jdbc.Driver #多数据源配置
spring.datasource.schema-name=royalpay_production spring.datasource.type = com.zaxxer.hikari.HikariDataSource
spring.datasource.host=127.0.0.1:3306 #数据源master
spring.datasource.url=jdbc:mysql://${spring.datasource.host}/${spring.datasource.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.username=root spring.datasource.master.schema-name=royalpay_production
spring.datasource.password=root spring.datasource.master.host=119.28.3.196:3310
spring.datasource.master.jdbc-url=jdbc:mysql://${spring.datasource.master.host}/${spring.datasource.master.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.master.username=readonly
spring.datasource.master.password=read0nly
#数据源salve
spring.datasource.slave.schema-name=royalpay_production
spring.datasource.slave.host=119.28.3.196:3310
spring.datasource.slave.jdbc-url=jdbc:mysql://${spring.datasource.slave.host}/${spring.datasource.slave.schema-name}?useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.slave.username=readonly
spring.datasource.slave.password=read0nly

@ -31,6 +31,29 @@
WHERE c.settle_date = #{settle_date} WHERE c.settle_date = #{settle_date}
GROUP BY a.channel GROUP BY a.channel
</select> </select>
<select id="listReportChannelsOfMergeSettle" resultType="com.alibaba.fastjson.JSONObject">
SELECT
lcda.channel,
lcda.rate,
SUM( lcda.total_credit ) AS total_credit,
SUM( lcda.total_debit ) AS total_debit,
SUM( lcda.gross_amount ) AS gross_amount,
SUM( lcda.total_charge ) AS total_charge,
SUM( lcda.third_charge ) AS third_charge,
SUM( lcda.royalpay_charge ) AS royalpay_charge,
SUM( lcda.tax_amount ) AS tax_amount,
SUM( lcda.distributed_surcharge ) AS distributed_surcharge
FROM
log_clearing_detail lcd
INNER JOIN log_clearing_detail_analysis lcda ON lcda.clearing_detail_id = lcd.clear_detail_id
INNER JOIN sys_clients c ON lcda.client_id = c.client_id
WHERE
lcd.report_date = #{report_date}
AND ( c.client_id = #{client_id} OR c.parent_client_id = #{client_id} )
GROUP BY
lcda.channel
</select>
<select id="getSysCleaingAmount" resultType="decimal"> <select id="getSysCleaingAmount" resultType="decimal">
SELECT (SUM(lcda.gross_amount) - SUM(lcda.total_charge)) sys_clearing_amount SELECT (SUM(lcda.gross_amount) - SUM(lcda.total_charge)) sys_clearing_amount
FROM log_clearing_detail_analysis lcda FROM log_clearing_detail_analysis lcda
@ -42,4 +65,4 @@
WHERE lc.settle_date = #{settle_date})) WHERE lc.settle_date = #{settle_date}))
AND lcda.channel = #{channel} AND lcda.channel = #{channel}
</select> </select>
</mapper> </mapper>

@ -68,6 +68,27 @@
</where> </where>
</select> </select>
<select id="listReportOfMergeSettle" resultType="com.alibaba.fastjson.JSONObject">
SELECT
SUM( lcd.total_payment ) AS total_payment,
SUM( lcd.total_refund ) AS total_refund,
SUM( lcd.gross_amount ) AS gross_amount,
SUM( lcd.clearing_amount ) AS clearing_amount,
SUM( lcd.total_charge ) AS total_charge,
SUM( lcd.wechat_charge ) AS wechat_charge,
SUM( lcd.royalpay_charge ) AS royalpay_charge,
SUM( lcd.ext_charge ) AS ext_charge,
SUM( lcd.tax_amount ) AS tax_amount,
SUM( lcd.total_cashback ) AS total_cashback,
SUM( lcd.total_cashback ) AS total_cashback
FROM
log_clearing_detail lcd
INNER JOIN sys_clients c ON c.client_id = lcd.client_id
WHERE
( c.client_id = #{client_id} OR c.parent_client_id = #{client_id} )
AND lcd.report_date = #{report_date}
</select>
<select id="listClientSettlementLog" resultType="com.alibaba.fastjson.JSONObject"> <select id="listClientSettlementLog" resultType="com.alibaba.fastjson.JSONObject">
select select
*,DATE_FORMAT(report_date,'%y-%m-%d')clear_date,DATE_FORMAT(settle_date_from,'%m-%d')settle_from,DATE_FORMAT(settle_date_to,'%m-%d')settle_to *,DATE_FORMAT(report_date,'%y-%m-%d')clear_date,DATE_FORMAT(settle_date_from,'%m-%d')settle_from,DATE_FORMAT(settle_date_to,'%m-%d')settle_to
@ -117,4 +138,4 @@
ORDER BY clearing_amount DESC ORDER BY clearing_amount DESC
]]> ]]>
</select> </select>
</mapper> </mapper>

@ -559,23 +559,23 @@
</select> </select>
<select id="listSettlementLog" resultType="com.alibaba.fastjson.JSONObject"> <select id="listSettlementLog" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT t.client_id,DATE(t.transaction_time) clearing_time, SELECT t.client_id,DATE(t.transaction_time) clearing_time,
ifnull(cd.report_date,date(t.transaction_time)) report_date, ifnull(cd.report_date,date(t.transaction_time)) report_date,
cd.tax_amount, <if test="merge_settle!=null">1 as merge_settle,</if>
cd.total_charge, SUM(cd.tax_amount) tax_amount,
SUM(cd.total_charge) total_charge,
SUM(t.clearing_amount) total, SUM(t.clearing_amount) total,
sum(if(LOCATE('MERCHANT',t.system_transaction_id),t.clearing_amount,0)) income, sum(if(LOCATE('MERCHANT',t.system_transaction_id),t.clearing_amount,0)) income,
sum(if(LOCATE('SURCHARGE',t.system_transaction_id),t.clearing_amount,0)) fee, sum(if(LOCATE('SURCHARGE',t.system_transaction_id),t.clearing_amount,0)) fee,
(SELECT min(r.rate_value) FROM sys_client_rates r WHERE r.client_id = t.client_id (SELECT min(r.rate_value) FROM sys_client_rates r WHERE r.client_id = t.client_id
AND date(r.expiry_time) >= DATE(t.clearing_time) AND date(r.expiry_time) >= DATE(t.clearing_time)
AND date(r.active_time) <= DATE(t.clearing_time)) rate, AND date(r.active_time) &lt;= DATE(t.clearing_time)) rate,
t.clearing_order clear_detail_id t.clearing_order clear_detail_id
FROM pmt_transactions t FROM pmt_transactions t
left join log_clearing_detail cd on cd.clear_detail_id=t.clearing_order left join log_clearing_detail cd on cd.clear_detail_id=t.clearing_order
left join sys_clients sc on t.client_id = sc.client_id left join sys_clients sc on t.client_id = sc.client_id
WHERE t.channel='Settlement' WHERE t.channel='Settlement'
]]>
<if test="client_ids!=null"> <if test="client_ids!=null">
AND t.client_id IN AND t.client_id IN
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id"> <foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
@ -587,7 +587,8 @@
</if> </if>
<if test="from!=null">and t.transaction_time &gt;= #{from}</if> <if test="from!=null">and t.transaction_time &gt;= #{from}</if>
<if test="to!=null">and t.transaction_time &lt; #{to}</if> <if test="to!=null">and t.transaction_time &lt; #{to}</if>
GROUP BY t.order_id <if test="merge_settle!=null">GROUP BY report_date</if>
<if test="merge_settle==null">GROUP BY t.order_id</if>
order by t.clearing_time desc order by t.clearing_time desc
</select> </select>
@ -1155,6 +1156,30 @@
AND t.clearing_order = #{clearing_order} AND t.clearing_order = #{clearing_order}
]]> ]]>
</select> </select>
<select id="listTransactionsOfMergeSettleClearingOrder" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT t.*,
IFNULL(t.incremental_surcharge, 0.00) incremental_surcharge_settle,
o.display_amount,
o.client_order_id,
o.gateway,
r.out_refund_id,
r.client_refund_id,
o.order_detail,
o.dev_id,
o.source
FROM pmt_transactions t
LEFT JOIN pmt_orders o ON o.order_id = t.order_id
LEFT JOIN pmt_refunds r ON r.refund_id = t.refund_id
INNER JOIN log_clearing_detail lcd ON t.clearing_order = lcd.clear_detail_id
INNER JOIN sys_clients c ON c.client_id = t.client_id
WHERE t.channel != 'Settlement'
AND lcd.report_date = #{report_date}
AND (c.client_id = #{client_id} or c.parent_client_id = #{client_id})
]]>
</select>
<select id="listSettlementTransactions" resultType="com.alibaba.fastjson.JSONObject"> <select id="listSettlementTransactions" resultType="com.alibaba.fastjson.JSONObject">
SELECT t.* SELECT t.*
FROM pmt_transactions t FROM pmt_transactions t

@ -4,7 +4,7 @@
define(['../app','decimal'], function (app,Decimal) { define(['../app','decimal'], function (app,Decimal) {
'use strict'; 'use strict';
app.factory('clearingDetailService', ['$uibModal', function ($uibModal) { app.factory('clearingDetailService', ['$uibModal', function ($uibModal) {
function openDetail(url, is_partner,client_id,detailId) { function openDetail(url, is_partner, client_id, detailId) {
$uibModal.open({ $uibModal.open({
templateUrl: '/static/payment/tradelog/templates/partner_settlement_dialog.html', templateUrl: '/static/payment/tradelog/templates/partner_settlement_dialog.html',
controller: 'clearingDetailCtrl', controller: 'clearingDetailCtrl',
@ -13,8 +13,21 @@ define(['../app','decimal'], function (app,Decimal) {
return $http.get(url); return $http.get(url);
}], }],
is_partner: is_partner, is_partner: is_partner,
client_id:client_id, client_id: client_id,
detailId:detailId detailId: detailId
},
size: 'lg'
})
}
function openDetailOfMergeSettle(url,client_id) {
$uibModal.open({
templateUrl: '/static/payment/tradelog/templates/partner_settlement_dialog.html',
controller: 'clearingDetailOfMergeSettleCtrl',
resolve: {
detail: ['$http', function ($http) {
return $http.get(url);
}],
client_id:client_id
}, },
size: 'lg' size: 'lg'
}) })
@ -23,6 +36,9 @@ define(['../app','decimal'], function (app,Decimal) {
return { return {
clientClearingDetail: function (client_id, detailId, is_partner) { clientClearingDetail: function (client_id, detailId, is_partner) {
openDetail('/client/clean_logs/' + client_id + '/settlement_logs/' + detailId, is_partner,client_id,detailId); openDetail('/client/clean_logs/' + client_id + '/settlement_logs/' + detailId, is_partner,client_id,detailId);
},
clientClearingDetailOfMergeSettle: function (client_id, reportDate) {
openDetailOfMergeSettle('/client/clean_logs/' + client_id + '/settlement_logs/report_date/' + reportDate, client_id);
} }
} }
@ -39,6 +55,19 @@ define(['../app','decimal'], function (app,Decimal) {
} }
$scope.channelAndDayOfAnalysis(); $scope.channelAndDayOfAnalysis();
}]); }]);
app.controller('clearingDetailOfMergeSettleCtrl', ['$scope', 'detail','client_id','$http', function ($scope, detail,client_id,$http) {
$scope.ctrl = {channel: null,day:null};
$scope.report = detail.data;
$scope.is_partner = true;
$scope.channelAndDayOfAnalysis = function () {
$http.get('/client/clean_logs/' + client_id + '/settlement_logs/report_date/' + $scope.report.report_date+'/analysis/'+$scope.ctrl.channel).then(function (resp) {
$scope.channelAndDayMap = resp.data;
$scope.index = 0;
})
}
$scope.channelAndDayOfAnalysis();
}]);
app.filter('channel_image', function () { app.filter('channel_image', function () {
return function (channel) { return function (channel) {
switch (channel) { switch (channel) {
@ -61,4 +90,4 @@ define(['../app','decimal'], function (app,Decimal) {
} }
} }
}); });
}); });

@ -52,12 +52,19 @@ define(['../app'], function (app) {
} }
}; };
}]); }]);
app.controller('refundPDialogCtrl', ['$scope', '$http', 'order', function ($scope, $http, order) { app.controller('refundPDialogCtrl', ['$scope', '$http', 'order', 'commonDialog','$sce', function ($scope, $http, order, commonDialog,$sce) {
$scope.order = order.data; $scope.order = order.data;
$scope.fee = {fee: 0}; $scope.fee = {fee: 0};
$scope.refundAll = function () { $scope.refundAll = function () {
$scope.fee.fee = $scope.order.available; var contentHtml = $sce.trustAsHtml('You will refund the order <span style="color: red">[' + $scope.order.order_id + ']</span>, the refund amount: ' +
$scope.submitRefundOrder(); '<span style="color: red">[' + $scope.order.available + ']</span>');
commonDialog.confirm({
title: 'Confirm Refund',
contentHtml: contentHtml
}).then(function () {
$scope.fee.fee = $scope.order.available;
$scope.submitRefundOrder();
})
}; };
$scope.submitRefundOrder = function () { $scope.submitRefundOrder = function () {
$scope.sending = true; $scope.sending = true;
@ -67,19 +74,26 @@ define(['../app'], function (app) {
$scope.sending = remark; $scope.sending = remark;
return; return;
} }
var contentHtml = $sce.trustAsHtml('You will refund the order <span style="color: red">[' + $scope.order.order_id + ']</span>, the refund amount: ' +
$http.post('/api/payment/v1.0/refund/orders/' + $scope.order.order_id, { '<span style="color: red">[' + $scope.fee.fee + ']</span>');
fee: $scope.fee.fee, commonDialog.confirm({
original_number: true, title: 'Confirm Refund',
remark: $scope.fee.remark contentHtml: contentHtml
}).then(function (resp) { }).then(function () {
$scope.sending = false; $http.post('/api/payment/v1.0/refund/orders/' + $scope.order.order_id, {
$scope.$close(resp.data.audition ? 'Waiting for audition by manager or shop keeper' : null); fee: $scope.fee.fee,
}, function (resp) { original_number: true,
$scope.sending = false; remark: $scope.fee.remark
$scope.$dismiss(resp); }).then(function (resp) {
// $scope.errmsg = resp.data.message; $scope.sending = false;
}) $scope.$close(resp.data.audition ? 'Waiting for audition by manager or shop keeper' : null);
}, function (resp) {
$scope.sending = false;
$scope.$dismiss(resp);
// $scope.errmsg = resp.data.message;
})
});
$scope.sending = false;
}; };
$scope.agreeRefund = function (agree) { $scope.agreeRefund = function (agree) {
if ($scope.order.applying && $scope.order.auditable) { if ($scope.order.applying && $scope.order.auditable) {
@ -95,4 +109,4 @@ define(['../app'], function (app) {
app.controller('refundLogPDialogCtrl', ['$scope', 'logs', function ($scope, logs) { app.controller('refundLogPDialogCtrl', ['$scope', 'logs', function ($scope, logs) {
$scope.logs = logs.data; $scope.logs = logs.data;
}]) }])
}); });

@ -4570,6 +4570,20 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
}); });
}; };
$scope.getClearingTransactionsOfMergeSettle = function (reportDate) {
$uibModal.open({
templateUrl: '/static/analysis/templates/settlement_transactions.html',
controller: 'managerSettlementDetailOfMergeSettleCtrl',
resolve: {
detail: ['$http', '$stateParams', function ($http) {
return $http.get('/analysis/partner_card/' + $scope.client.client_id + '/settlement_logs/report_date/' + reportDate);
}],
client_id: $scope.client.client_id
},
size: 'lg'
});
};
$scope.checkSubClientChoseShow = function (client) { $scope.checkSubClientChoseShow = function (client) {
$scope.more20ChoseSubClient = !$scope.more20ChoseSubClient; $scope.more20ChoseSubClient = !$scope.more20ChoseSubClient;
if (client != '') { if (client != '') {
@ -4668,6 +4682,15 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
}; };
$scope.channelAndDayOfAnalysis(1); $scope.channelAndDayOfAnalysis(1);
}]); }]);
app.controller('managerSettlementDetailOfMergeSettleCtrl', ['$scope', 'detail','client_id','$http', function ($scope, detail,client_id,$http) {
$scope.ctrl = {channel: null};
$scope.show = true;
$scope.report = detail.data;
$scope.report.total_charge = Decimal.add($scope.report.total_charge, $scope.report.tax_amount).toFixed(2);
angular.forEach($scope.report.channels, function (e) {
e.total_charge = Decimal.add(e.tax_amount, e.total_charge).toFixed(2);
});
}]);
app.controller('productCtrl', ['$scope', '$http', '$uibModal', 'commonDialog', '$state', 'Upload', 'wechatGoodMcc', function ($scope, $http, $uibModal, commonDialog, $state, Upload, wechatGoodMcc) { app.controller('productCtrl', ['$scope', '$http', '$uibModal', 'commonDialog', '$state', 'Upload', 'wechatGoodMcc', function ($scope, $http, $uibModal, commonDialog, $state, Upload, wechatGoodMcc) {
$scope.importShow = 0; $scope.importShow = 0;
$scope.pagination = {}; $scope.pagination = {};

@ -1,7 +1,7 @@
<div class="row"> <div class="row">
<div class="col-sm-12"> <div class="col-sm-12">
<div class="table-responsive col-sm-12"> <div class="table-responsive col-sm-12">
<button class="btn btn-success" role="button" ng-if="channelOptions.length>0" ng-click="newServiceChannelDialog()" style="margin: 5px">新增增值服务</button> <button class="btn btn-success" role="button" ng-if="channelOptions.length>0 && ('11'|withRole)" ng-click="newServiceChannelDialog()" style="margin: 5px">新增增值服务</button>
<table class="table table-bordered table-hover table-striped"> <table class="table table-bordered table-hover table-striped">
<thead> <thead>
<tr> <tr>

@ -238,7 +238,7 @@
<td ng-bind="log.income"></td> <td ng-bind="log.income"></td>
<td ng-bind="log.fee"></td> <td ng-bind="log.fee"></td>
<td> <td ng-if="!log.merge_settle">
<a role="button" class="text-bold" <a role="button" class="text-bold"
ng-if="(log.clearing_time|limitTo:10) >= '2017-01-12'" ng-if="(log.clearing_time|limitTo:10) >= '2017-01-12'"
ng-click="getClearingTransactions(log.client_id,log.clear_detail_id)" ng-click="getClearingTransactions(log.client_id,log.clear_detail_id)"
@ -246,6 +246,14 @@
<i class="fa fa-list-alt"></i> <i class="fa fa-list-alt"></i>
</a> </a>
</td> </td>
<td ng-if="log.merge_settle">
<a role="button" class="text-bold"
ng-if="(log.clearing_time|limitTo:10) >= '2017-01-12'"
ng-click="getClearingTransactionsOfMergeSettle((log.report_date|limitTo:10))"
title="Detail">
<i class="fa fa-list-alt"></i>
</a>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

@ -222,6 +222,9 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
$scope.getClearingTransactions = function (client_id, detailId) { $scope.getClearingTransactions = function (client_id, detailId) {
clearingDetailService.clientClearingDetail(client_id, detailId, true) clearingDetailService.clientClearingDetail(client_id, detailId, true)
} }
$scope.getClearingTransactionsOfMergeSettle = function (client_id, reportDate) {
clearingDetailService.clientClearingDetailOfMergeSettle(client_id, reportDate)
}
$scope.checkSubClientChoseShow = function (client) { $scope.checkSubClientChoseShow = function (client) {
$scope.more20ChoseSubClient = !$scope.more20ChoseSubClient; $scope.more20ChoseSubClient = !$scope.more20ChoseSubClient;
if (client != '') { if (client != '') {

@ -291,7 +291,7 @@
<td ng-bind="log.total_charge"></td> <td ng-bind="log.total_charge"></td>
<td>{{log.fee}}</td> <td>{{log.fee}}</td>
<!--<td ng-bind="log.rate"></td>--> <!--<td ng-bind="log.rate"></td>-->
<td> <td ng-if="!log.merge_settle">
<a role="button" class="text-bold" <a role="button" class="text-bold"
ng-if="(log.clearing_time|limitTo:10) >= '2017-01-12'" ng-if="(log.clearing_time|limitTo:10) >= '2017-01-12'"
ng-click="getClearingTransactions(log.client_id,log.clear_detail_id)" ng-click="getClearingTransactions(log.client_id,log.clear_detail_id)"
@ -304,6 +304,19 @@
<i class="fa fa-download"></i> <i class="fa fa-download"></i>
</a> </a>
</td> </td>
<td ng-if="log.merge_settle">
<a role="button" class="text-bold"
ng-if="(log.clearing_time|limitTo:10) >= '2017-01-12'"
ng-click="getClearingTransactionsOfMergeSettle(log.client_id,(log.report_date|limitTo:10))"
title="Detail">
<i class="fa fa-list-alt"></i>
</a>
<a ng-href="/client/clean_logs/{{log.client_id}}/settlement_logs/report_date/{{log.report_date|limitTo:10}}/export"
target="_blank" ng-if="(log.clearing_time|limitTo:10) >= '2017-01-12'"
title="Download">
<i class="fa fa-download"></i>
</a>
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

Loading…
Cancel
Save