|
|
@ -8,6 +8,7 @@ import au.com.royalpay.payment.channels.wechat.runtime.beans.SettlementLog;
|
|
|
|
import au.com.royalpay.payment.manage.analysis.core.PlatformClearService;
|
|
|
|
import au.com.royalpay.payment.manage.analysis.core.PlatformClearService;
|
|
|
|
import au.com.royalpay.payment.manage.analysis.mappers.EstimateAnalysisMapper;
|
|
|
|
import au.com.royalpay.payment.manage.analysis.mappers.EstimateAnalysisMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.log.PlatformSettlementMapper;
|
|
|
|
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.utils.PageListUtils;
|
|
|
|
import au.com.royalpay.payment.tools.utils.PageListUtils;
|
|
|
|
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
|
|
|
|
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
|
|
|
|
|
|
|
|
|
|
|
@ -20,17 +21,17 @@ import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
|
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
|
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.text.ParseException;
|
|
|
|
import java.text.ParseException;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
@ -43,6 +44,8 @@ import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.yixblog.platform.http.HttpRequestGenerator;
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
|
|
|
|
public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
|
|
|
|
|
|
|
|
|
|
|
@ -58,6 +61,8 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
|
|
|
|
private PlatformSettlementMapper platformSettlementMapper;
|
|
|
|
private PlatformSettlementMapper platformSettlementMapper;
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private EstimateAnalysisMapper estimateAnalysisMapper;
|
|
|
|
private EstimateAnalysisMapper estimateAnalysisMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private AttachmentClient attachmentClient;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject getPlatformSettleLog(String channel, int page, int limit) {
|
|
|
|
public JSONObject getPlatformSettleLog(String channel, int page, int limit) {
|
|
|
@ -366,8 +371,11 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void doVerifyHFSettleLog(MultipartFile file, String start, String end) {
|
|
|
|
public void doVerifyHFSettleLog(JSONObject param) {
|
|
|
|
JSONObject hfSettle = handleHFSettleFile(file);
|
|
|
|
|
|
|
|
|
|
|
|
String end = param.getString("end");
|
|
|
|
|
|
|
|
String start = param.getString("start");
|
|
|
|
|
|
|
|
JSONObject hfSettle = handleHFSettleFile(param.getString("fileId"));
|
|
|
|
if (hfSettle == null) {
|
|
|
|
if (hfSettle == null) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -394,7 +402,7 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
|
|
|
|
|
|
|
|
|
|
|
|
List<JSONObject> check = null;
|
|
|
|
List<JSONObject> check = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
check = platformSettlementMapper.findBySettleDate(DateUtils.parseDate(end, "YYYY-MM-dd"), "hf");
|
|
|
|
check = platformSettlementMapper.findBySettleDate(DateUtils.parseDate(end, "yyyy-MM-dd"), "hf");
|
|
|
|
} catch (ParseException e) {
|
|
|
|
} catch (ParseException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -408,10 +416,11 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private JSONObject handleHFSettleFile(MultipartFile file) {
|
|
|
|
private JSONObject handleHFSettleFile(String fileId) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
XSSFWorkbook workbook = new XSSFWorkbook(file.getInputStream());
|
|
|
|
HttpRequestGenerator gen = new HttpRequestGenerator(attachmentClient.getFileUrl(fileId), RequestMethod.GET);
|
|
|
|
XSSFSheet sheet = workbook.getSheetAt(0);
|
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook(gen.execute().getResponseContentStream());
|
|
|
|
|
|
|
|
HSSFSheet sheet = workbook.getSheetAt(0);
|
|
|
|
Iterator<Row> rowIterator = sheet.rowIterator();
|
|
|
|
Iterator<Row> rowIterator = sheet.rowIterator();
|
|
|
|
Row row = null;
|
|
|
|
Row row = null;
|
|
|
|
Cell cell = null;
|
|
|
|
Cell cell = null;
|
|
|
@ -423,46 +432,38 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
|
|
|
|
BigDecimal clearingAmount = BigDecimal.ZERO;
|
|
|
|
BigDecimal clearingAmount = BigDecimal.ZERO;
|
|
|
|
while (rowIterator.hasNext()) {
|
|
|
|
while (rowIterator.hasNext()) {
|
|
|
|
row = rowIterator.next();
|
|
|
|
row = rowIterator.next();
|
|
|
|
cell = row.getCell(14);
|
|
|
|
|
|
|
|
|
|
|
|
cell = row.getCell(0);
|
|
|
|
|
|
|
|
if (cell != null) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cell = row.getCell(15);
|
|
|
|
|
|
|
|
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
|
|
|
if (cell != null) {
|
|
|
|
if (cell != null) {
|
|
|
|
String orderAmountStr = cell.getStringCellValue().trim();
|
|
|
|
String orderAmountStr = cell.getStringCellValue().trim();
|
|
|
|
if (StringUtils.isNotEmpty(orderAmountStr)) {
|
|
|
|
if (StringUtils.isNotEmpty(orderAmountStr)) {
|
|
|
|
BigDecimal cellVar = new BigDecimal(orderAmountStr);
|
|
|
|
result.put("orderAmount", new BigDecimal(orderAmountStr));
|
|
|
|
if (orderAmount.compareTo(cellVar) == 0) {
|
|
|
|
|
|
|
|
result.put("orderAmount", orderAmount);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
orderAmount = orderAmount.add(cellVar);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cell = row.getCell(15);
|
|
|
|
cell = row.getCell(16);
|
|
|
|
|
|
|
|
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
|
|
|
if (cell != null) {
|
|
|
|
if (cell != null) {
|
|
|
|
String surchargeStr = cell.getStringCellValue().trim();
|
|
|
|
String surchargeStr = cell.getStringCellValue().trim();
|
|
|
|
if (StringUtils.isNotEmpty(surchargeStr)) {
|
|
|
|
if (StringUtils.isNotEmpty(surchargeStr)) {
|
|
|
|
BigDecimal cellVar = new BigDecimal(surchargeStr);
|
|
|
|
result.put("surcharge", new BigDecimal(surchargeStr));
|
|
|
|
if (surcharge.compareTo(cellVar) == 0) {
|
|
|
|
|
|
|
|
result.put("orderAmount", surcharge);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
surcharge = surcharge.add(cellVar);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cell = row.getCell(16);
|
|
|
|
cell = row.getCell(17);
|
|
|
|
|
|
|
|
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
|
|
|
|
if (cell != null) {
|
|
|
|
if (cell != null) {
|
|
|
|
String clearingAmounStr = cell.getStringCellValue().trim();
|
|
|
|
String clearingAmounStr = cell.getStringCellValue().trim();
|
|
|
|
if (StringUtils.isNotEmpty(clearingAmounStr)) {
|
|
|
|
if (StringUtils.isNotEmpty(clearingAmounStr)) {
|
|
|
|
BigDecimal cellVar = new BigDecimal(clearingAmounStr);
|
|
|
|
result.put("clearingAmount", new BigDecimal(clearingAmounStr));
|
|
|
|
if (clearingAmount.compareTo(cellVar) == 0) {
|
|
|
|
|
|
|
|
result.put("clearingAmount", clearingAmount);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
clearingAmount = clearingAmount.add(cellVar);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
logger.debug("处理汇付清算文件出错", e);
|
|
|
|
logger.debug("处理汇付清算文件出错", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
@ -474,13 +475,15 @@ public class PlatformClearAnalysisServiceImpl implements PlatformClearService {
|
|
|
|
JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog(start, end, "hf", "Credit", new BigDecimal(0.008));
|
|
|
|
JSONObject creditLogs = platformSettlementMapper.calculateSysSettleLog(start, end, "hf", "Credit", new BigDecimal(0.008));
|
|
|
|
result.put("sys_pay_fee", creditLogs.getBigDecimal("aud_amount"));
|
|
|
|
result.put("sys_pay_fee", creditLogs.getBigDecimal("aud_amount"));
|
|
|
|
JSONObject debitLogs = platformSettlementMapper.calculateSysSettleLog(start, end, "hf", "Debit", new BigDecimal(0.008));
|
|
|
|
JSONObject debitLogs = platformSettlementMapper.calculateSysSettleLog(start, end, "hf", "Debit", new BigDecimal(0.008));
|
|
|
|
|
|
|
|
result.put("sys_surcharge", platformSettlementMapper.calculateRmbCharge(start, end, "hf", new BigDecimal(0.008)));
|
|
|
|
result.put("sys_refund_fee", debitLogs.getBigDecimal("aud_amount"));
|
|
|
|
result.put("sys_refund_fee", debitLogs.getBigDecimal("aud_amount"));
|
|
|
|
result.put("sys_net_fee", creditLogs.getBigDecimal("aud_amount").subtract(debitLogs.getBigDecimal("aud_amount")));
|
|
|
|
result.put("sys_net_fee", creditLogs.getBigDecimal("aud_amount").subtract(debitLogs.getBigDecimal("aud_amount")));
|
|
|
|
result.put("sys_settle_fee", result.getBigDecimal("sys_net_fee").subtract(result.getBigDecimal("sys_surcharge")));
|
|
|
|
result.put("sys_settle_fee", result.getBigDecimal("sys_net_fee").subtract(result.getBigDecimal("sys_surcharge")));
|
|
|
|
result.put("sys_surcharge", platformSettlementMapper.calculateRmbCharge(start, end, "hf", new BigDecimal(0.008)));
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
} catch (Exception ignore) {
|
|
|
|
} catch (Exception ignore) {
|
|
|
|
|
|
|
|
ignore.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|