From 57783d16d2769aac41f2be508321951f8c5d7ebe Mon Sep 17 00:00:00 2001 From: duLingLing Date: Mon, 2 Dec 2019 15:28:34 +0800 Subject: [PATCH] =?UTF-8?q?Upd:=E5=95=86=E6=88=B7=E7=AB=AF=E6=B8=85?= =?UTF-8?q?=E7=AE=97=E6=96=87=E4=BB=B6=EF=BC=8C=E4=BA=A4=E6=98=93=E6=B5=81?= =?UTF-8?q?=E6=B0=B4=E6=B8=85=E7=AE=97=E6=96=87=E4=BB=B6=EF=BC=8C=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E6=98=BE=E7=A4=BA=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clearing/core/impl/CleanServiceImpl.java | 46 +++++++++++--- .../core/impls/TradeLogServiceImpl.java | 63 ++++++++++++++++--- 2 files changed, 90 insertions(+), 19 deletions(-) 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 d26342ad5..1baa6564e 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 @@ -49,6 +49,7 @@ import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateUtils; +import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.joda.time.DateTime; @@ -823,6 +824,15 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider 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_" + DateFormatUtils.format(reportDate, "yyyyMMdd")); int rowNum = 0; Row row = sheet.createRow(rowNum); @@ -853,18 +863,36 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider 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()); - row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("transaction_type")); + 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")); - row.createCell(8, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("display_amount") == null ? "" - : settle.getBigDecimal("display_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString()); - row.createCell(9, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("transaction_amount") == null ? "" - : settle.getBigDecimal("transaction_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString()); - row.createCell(10, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("clearing_amount") == null ? "" - : settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString()); + 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() + "%"); - row.createCell(12, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("settle_amount") == null ? "" - : settle.getBigDecimal("settle_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString()); + cell = row.createCell(12, 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(13, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("order_detail")); device = clientDeviceMapper.find(settle.getString("dev_id")); if (device != null) 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 1f1fe29ac..e09a749e1 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 @@ -848,6 +848,20 @@ public class TradeLogServiceImpl implements TradeLogService { font2.setBoldweight(Font.BOLDWEIGHT_NORMAL); // 把字体应用到当前的样式 style2.setFont(font2); + + HSSFCellStyle style3 = workbook.createCellStyle(); + style3.setFillForegroundColor(HSSFColor.WHITE.index); + style3.setFillPattern(CellStyle.SOLID_FOREGROUND); + style3.setBorderBottom(CellStyle.BORDER_THIN); + style3.setBorderLeft(CellStyle.BORDER_THIN); + style3.setBorderRight(CellStyle.BORDER_THIN); + style3.setBorderTop(CellStyle.BORDER_THIN); + style3.setAlignment(CellStyle.ALIGN_CENTER); + HSSFFont font3 = workbook.createFont(); + font3.setFontHeightInPoints((short) 12); + font3.setBoldweight(Font.BOLDWEIGHT_NORMAL); + font3.setColor(HSSFColor.RED.index); + style3.setFont(font3); HSSFRow row0 = sheet.createRow(0); HSSFCell cell00 = row0.createCell(0); HSSFCell cell01 = row0.createCell(1); @@ -879,7 +893,6 @@ public class TradeLogServiceImpl implements TradeLogService { cell0.setCellStyle(style2); cell1.setCellStyle(style2); cell2.setCellStyle(style2); - cell3.setCellStyle(style2); cell4.setCellStyle(style2); JSONObject dataItem = dataList.get(i); HSSFRichTextString text0 = new HSSFRichTextString(dataItem.getString("transaction_time")); @@ -894,6 +907,11 @@ public class TradeLogServiceImpl implements TradeLogService { cell0.setCellValue(text0); cell1.setCellValue(text1); cell2.setCellValue(text2); + if(dataItem.getString("transaction_type").equals("Debit") ){ + cell2.setCellStyle(style3); + }else{ + cell2.setCellStyle(style2); + } cell3.setCellValue(text3); cell4.setCellValue(text4); } @@ -1414,6 +1432,13 @@ public class TradeLogServiceImpl implements TradeLogService { 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_" + begin + "_" + end); int rowNum = 0; Row row = sheet.createRow(rowNum); @@ -1441,17 +1466,35 @@ public class TradeLogServiceImpl implements TradeLogService { row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue("-"); } row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("exchange_rate").setScale(5, RoundingMode.DOWN).toPlainString()); - row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("transaction_type")); + 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")); - row.createCell(8, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("display_amount") == null ? "" - : settle.getBigDecimal("display_amount").setScale(2, RoundingMode.DOWN).toPlainString()); - row.createCell(9, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("transaction_amount") == null ? "" - : settle.getBigDecimal("transaction_amount").setScale(2, RoundingMode.DOWN).toPlainString()); - row.createCell(10, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("clearing_amount") == null ? "" - : settle.getBigDecimal("clearing_amount").setScale(2, RoundingMode.DOWN).toPlainString()); + 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(settle.getBigDecimal("rate") == null ? "" : settle.getBigDecimal("rate").toPlainString() + "%"); - row.createCell(12, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("settle_amount") == null ? "" - : settle.getBigDecimal("settle_amount").setScale(2, RoundingMode.DOWN).toPlainString()); + cell = row.createCell(12, 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(13, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("total_surcharge") == null ? "" : settle.getBigDecimal("total_surcharge").setScale(2, RoundingMode.DOWN).toPlainString()); row.createCell(14, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("tax_amount") == null ? ""