|
|
|
@ -23,7 +23,12 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.text.NumberFormat;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created by yuan on 2018/6/5.
|
|
|
|
@ -68,13 +73,21 @@ public class AreaMerchantTradeAnalysisImpl implements AreaMerchantTradeAnalysis{
|
|
|
|
|
JSONObject params = queryBean.toParams();
|
|
|
|
|
orgManager.checkOrgIds(manager,params);
|
|
|
|
|
PageList<JSONObject> clientAmount = null;
|
|
|
|
|
List<JSONObject> clientAmountLastCycle = null;
|
|
|
|
|
|
|
|
|
|
if(params.containsKey("begin") && params.containsKey("end")){
|
|
|
|
|
if (params.getDate("end").after(new Date()) && params.getDate("begin").compareTo(DateUtils.addDays(params.getDate("end"), -1))==0){
|
|
|
|
|
clientAmount = transactionAnalysisMapper.getAreaMerchantAmountAnalysis(params,new PageBounds());
|
|
|
|
|
clientAmountLastCycle = transactionAnalysisMapper.getAreaMerchantAmountByCycle(params);
|
|
|
|
|
}else {
|
|
|
|
|
clientAmount = customerAndOrdersStatisticsMapper.getAreaMerchantTradeAnalysis(params,new PageBounds());
|
|
|
|
|
clientAmountLastCycle = customerAndOrdersStatisticsMapper.getAreaMerchantTradeByLastCycle(params);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Map<String, JSONObject> cycleMap = clientAmountLastCycle.stream().collect(
|
|
|
|
|
Collectors.toMap(cylce -> cylce.getString("client_moniker"), cylce -> cylce));
|
|
|
|
|
List<JSONObject> allAmount = clientAmount.stream().map(amount -> {return toAmount(cycleMap.get(amount.getString("client_moniker")), amount);}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
|
|
// 声明一个工作薄
|
|
|
|
|
// 生成一个表格
|
|
|
|
@ -111,6 +124,33 @@ public class AreaMerchantTradeAnalysisImpl implements AreaMerchantTradeAnalysis{
|
|
|
|
|
font2.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
|
|
|
|
|
// 把字体应用到当前的样式
|
|
|
|
|
style2.setFont(font2);
|
|
|
|
|
|
|
|
|
|
HSSFCellStyle style3 = workbook.createCellStyle();
|
|
|
|
|
style3.setFillForegroundColor(HSSFColor.WHITE.index);
|
|
|
|
|
style3.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
|
|
|
|
|
style3.setBorderBottom(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style3.setBorderLeft(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style3.setBorderRight(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style3.setBorderTop(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style3.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
|
|
HSSFFont font3 = workbook.createFont();
|
|
|
|
|
font3.setFontHeightInPoints((short) 12);
|
|
|
|
|
font3.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
|
|
|
|
|
font3.setColor(HSSFColor.RED.index);
|
|
|
|
|
style3.setFont(font3);
|
|
|
|
|
HSSFCellStyle style4 = workbook.createCellStyle();
|
|
|
|
|
style4.setFillForegroundColor(HSSFColor.WHITE.index);
|
|
|
|
|
style4.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
|
|
|
|
|
style4.setBorderBottom(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style4.setBorderLeft(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style4.setBorderRight(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style4.setBorderTop(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style4.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
|
|
HSSFFont font4 = workbook.createFont();
|
|
|
|
|
font4.setFontHeightInPoints((short) 12);
|
|
|
|
|
font4.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
|
|
|
|
|
font4.setColor(HSSFColor.GREEN.index);
|
|
|
|
|
style4.setFont(font4);
|
|
|
|
|
HSSFRow row0 = sheet.createRow(0);
|
|
|
|
|
HSSFCell cell00 = row0.createCell(0);
|
|
|
|
|
HSSFCell cell01 = row0.createCell(1);
|
|
|
|
@ -124,6 +164,9 @@ public class AreaMerchantTradeAnalysisImpl implements AreaMerchantTradeAnalysis{
|
|
|
|
|
HSSFCell cell09 = row0.createCell(9);
|
|
|
|
|
HSSFCell cell10 = row0.createCell(10);
|
|
|
|
|
HSSFCell cell11 = row0.createCell(11);
|
|
|
|
|
HSSFCell cell12 = row0.createCell(12);
|
|
|
|
|
HSSFCell cell13 = row0.createCell(13);
|
|
|
|
|
HSSFCell cell14 = row0.createCell(14);
|
|
|
|
|
cell00.setCellStyle(style);
|
|
|
|
|
cell01.setCellStyle(style);
|
|
|
|
|
cell02.setCellStyle(style);
|
|
|
|
@ -136,6 +179,9 @@ public class AreaMerchantTradeAnalysisImpl implements AreaMerchantTradeAnalysis{
|
|
|
|
|
cell09.setCellStyle(style);
|
|
|
|
|
cell10.setCellStyle(style);
|
|
|
|
|
cell11.setCellStyle(style);
|
|
|
|
|
cell12.setCellStyle(style);
|
|
|
|
|
cell13.setCellStyle(style);
|
|
|
|
|
cell14.setCellStyle(style);
|
|
|
|
|
|
|
|
|
|
HSSFRichTextString text00 = new HSSFRichTextString("Partner Code");
|
|
|
|
|
HSSFRichTextString text01 = new HSSFRichTextString("Short name");
|
|
|
|
@ -144,11 +190,14 @@ public class AreaMerchantTradeAnalysisImpl implements AreaMerchantTradeAnalysis{
|
|
|
|
|
HSSFRichTextString text04 = new HSSFRichTextString("Suburb");
|
|
|
|
|
HSSFRichTextString text05 = new HSSFRichTextString("Industry");
|
|
|
|
|
HSSFRichTextString text06 = new HSSFRichTextString("Amount");
|
|
|
|
|
HSSFRichTextString text07 = new HSSFRichTextString("Orders");
|
|
|
|
|
HSSFRichTextString text08 = new HSSFRichTextString("Alipay Amount");
|
|
|
|
|
HSSFRichTextString text09 = new HSSFRichTextString("Alipay Orders");
|
|
|
|
|
HSSFRichTextString text10 = new HSSFRichTextString("Wechat Amount");
|
|
|
|
|
HSSFRichTextString text11 = new HSSFRichTextString("Wechat Orders");
|
|
|
|
|
HSSFRichTextString text07 = new HSSFRichTextString("Last Cycle");
|
|
|
|
|
HSSFRichTextString text08 = new HSSFRichTextString("Orders");
|
|
|
|
|
HSSFRichTextString text09 = new HSSFRichTextString("Alipay Amount");
|
|
|
|
|
HSSFRichTextString text10 = new HSSFRichTextString("Last Cycle");
|
|
|
|
|
HSSFRichTextString text11 = new HSSFRichTextString("Alipay Orders");
|
|
|
|
|
HSSFRichTextString text12 = new HSSFRichTextString("Wechat Amount");
|
|
|
|
|
HSSFRichTextString text13 = new HSSFRichTextString("Last Cycle");
|
|
|
|
|
HSSFRichTextString text14 = new HSSFRichTextString("Wechat Orders");
|
|
|
|
|
cell00.setCellValue(text00);
|
|
|
|
|
cell01.setCellValue(text01);
|
|
|
|
|
cell02.setCellValue(text02);
|
|
|
|
@ -161,10 +210,13 @@ public class AreaMerchantTradeAnalysisImpl implements AreaMerchantTradeAnalysis{
|
|
|
|
|
cell09.setCellValue(text09);
|
|
|
|
|
cell10.setCellValue(text10);
|
|
|
|
|
cell11.setCellValue(text11);
|
|
|
|
|
cell12.setCellValue(text12);
|
|
|
|
|
cell13.setCellValue(text13);
|
|
|
|
|
cell14.setCellValue(text14);
|
|
|
|
|
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
|
|
|
|
String json = sysConfig.getString("royalpayindustry.json");
|
|
|
|
|
JSONArray jsonArray = JSONObject.parseArray(json);
|
|
|
|
|
for (int i = 0; i < clientAmount.size(); i++) {
|
|
|
|
|
for (int i = 0; i < allAmount.size(); i++) {
|
|
|
|
|
HSSFRow row = sheet.createRow(i + 1);
|
|
|
|
|
HSSFCell cell0 = row.createCell(0);
|
|
|
|
|
HSSFCell cell1 = row.createCell(1);
|
|
|
|
@ -178,6 +230,9 @@ public class AreaMerchantTradeAnalysisImpl implements AreaMerchantTradeAnalysis{
|
|
|
|
|
HSSFCell cell9 = row.createCell(9);
|
|
|
|
|
HSSFCell cel10 = row.createCell(10);
|
|
|
|
|
HSSFCell cel11 = row.createCell(11);
|
|
|
|
|
HSSFCell cel12 = row.createCell(12);
|
|
|
|
|
HSSFCell cel13 = row.createCell(13);
|
|
|
|
|
HSSFCell cel14 = row.createCell(14);
|
|
|
|
|
cell0.setCellStyle(style2);
|
|
|
|
|
cell1.setCellStyle(style2);
|
|
|
|
|
cell2.setCellStyle(style2);
|
|
|
|
@ -185,24 +240,94 @@ public class AreaMerchantTradeAnalysisImpl implements AreaMerchantTradeAnalysis{
|
|
|
|
|
cell4.setCellStyle(style2);
|
|
|
|
|
cell5.setCellStyle(style2);
|
|
|
|
|
cell6.setCellStyle(style2);
|
|
|
|
|
cell7.setCellStyle(style2);
|
|
|
|
|
cell8.setCellStyle(style2);
|
|
|
|
|
cell9.setCellStyle(style2);
|
|
|
|
|
cel10.setCellStyle(style2);
|
|
|
|
|
cel11.setCellStyle(style2);
|
|
|
|
|
String industry = getRoyalpayIindustry(clientAmount.get(i).getString("royalpayindustry"),jsonArray);
|
|
|
|
|
HSSFRichTextString text0 = new HSSFRichTextString(clientAmount.get(i).getString("client_moniker"));
|
|
|
|
|
HSSFRichTextString text1 = new HSSFRichTextString(clientAmount.get(i).getString("short_name"));
|
|
|
|
|
HSSFRichTextString text2 = new HSSFRichTextString(clientAmount.get(i).getString("bd_user_name"));
|
|
|
|
|
HSSFRichTextString text3 = new HSSFRichTextString(clientAmount.get(i).getString("state"));
|
|
|
|
|
HSSFRichTextString text4 = new HSSFRichTextString(clientAmount.get(i).getString("suburb"));
|
|
|
|
|
cel12.setCellStyle(style2);
|
|
|
|
|
cel14.setCellStyle(style2);
|
|
|
|
|
JSONObject thisAmount =clientAmount.get(i);
|
|
|
|
|
NumberFormat percent = NumberFormat.getPercentInstance();
|
|
|
|
|
BigDecimal lastTotal = new BigDecimal(1);
|
|
|
|
|
BigDecimal alipayTotal = new BigDecimal(1);
|
|
|
|
|
BigDecimal wechatToatl = new BigDecimal(1);
|
|
|
|
|
|
|
|
|
|
if(thisAmount.containsKey("old_total")){
|
|
|
|
|
if(thisAmount.getBigDecimal("total").compareTo(BigDecimal.ZERO)==0){
|
|
|
|
|
lastTotal = new BigDecimal(-1);
|
|
|
|
|
if(thisAmount.getBigDecimal("old_total").compareTo(BigDecimal.ZERO) == 0){
|
|
|
|
|
lastTotal = BigDecimal.ZERO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(thisAmount.getBigDecimal("total").compareTo(BigDecimal.ZERO)>0 && thisAmount.getBigDecimal("old_total").compareTo(BigDecimal.ZERO)>0) {
|
|
|
|
|
lastTotal = (thisAmount.getBigDecimal("total").subtract(thisAmount.getBigDecimal("old_total"))).divide(thisAmount.getBigDecimal("old_total"), 4, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
if(thisAmount.getBigDecimal("total").compareTo(BigDecimal.ZERO) == 0){
|
|
|
|
|
lastTotal = BigDecimal.ZERO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(thisAmount.containsKey("old_alipay_total")){
|
|
|
|
|
if(thisAmount.getBigDecimal("alipay_total").compareTo(BigDecimal.ZERO)==0){
|
|
|
|
|
alipayTotal = new BigDecimal(-1);
|
|
|
|
|
if(thisAmount.getBigDecimal("old_alipay_total").compareTo(BigDecimal.ZERO) == 0){
|
|
|
|
|
alipayTotal = BigDecimal.ZERO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(thisAmount.getBigDecimal("alipay_total").compareTo(BigDecimal.ZERO)>0 && thisAmount.getBigDecimal("old_alipay_total").compareTo(BigDecimal.ZERO)>0){
|
|
|
|
|
alipayTotal = (thisAmount.getBigDecimal("alipay_total").subtract(thisAmount.getBigDecimal("old_alipay_total"))).divide(thisAmount.getBigDecimal("old_alipay_total"),4,BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
if(thisAmount.getBigDecimal("alipay_total").compareTo(BigDecimal.ZERO) == 0){
|
|
|
|
|
alipayTotal = BigDecimal.ZERO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(thisAmount.containsKey("old_wechat_toatl")){
|
|
|
|
|
if(thisAmount.getBigDecimal("wechat_toatl").compareTo(BigDecimal.ZERO)==0){
|
|
|
|
|
wechatToatl = new BigDecimal(-1);
|
|
|
|
|
if(thisAmount.getBigDecimal("old_wechat_toatl").compareTo(BigDecimal.ZERO) == 0){
|
|
|
|
|
wechatToatl = BigDecimal.ZERO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(thisAmount.getBigDecimal("wechat_toatl").compareTo(BigDecimal.ZERO)>0 && thisAmount.getBigDecimal("old_wechat_toatl").compareTo(BigDecimal.ZERO)>0){
|
|
|
|
|
wechatToatl = (thisAmount.getBigDecimal("wechat_toatl").subtract(thisAmount.getBigDecimal("old_wechat_toatl"))).divide(thisAmount.getBigDecimal("old_wechat_toatl"),4,BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
if(thisAmount.getBigDecimal("wechat_toatl").compareTo(BigDecimal.ZERO) == 0){
|
|
|
|
|
wechatToatl = BigDecimal.ZERO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(lastTotal.compareTo(BigDecimal.ZERO)>=0){
|
|
|
|
|
cell7.setCellStyle(style4);
|
|
|
|
|
}else {
|
|
|
|
|
cell7.setCellStyle(style3);
|
|
|
|
|
}
|
|
|
|
|
if(alipayTotal.compareTo(BigDecimal.ZERO)>=0){
|
|
|
|
|
cel10.setCellStyle(style4);
|
|
|
|
|
}else {
|
|
|
|
|
cel10.setCellStyle(style3);
|
|
|
|
|
}
|
|
|
|
|
if(wechatToatl.compareTo(BigDecimal.ZERO)>=0){
|
|
|
|
|
cel13.setCellStyle(style4);
|
|
|
|
|
}else {
|
|
|
|
|
cel13.setCellStyle(style3);
|
|
|
|
|
}
|
|
|
|
|
String industry = getRoyalpayIindustry(thisAmount.getString("royalpayindustry"),jsonArray);
|
|
|
|
|
HSSFRichTextString text0 = new HSSFRichTextString(thisAmount.getString("client_moniker"));
|
|
|
|
|
HSSFRichTextString text1 = new HSSFRichTextString(thisAmount.getString("short_name"));
|
|
|
|
|
HSSFRichTextString text2 = new HSSFRichTextString(thisAmount.getString("bd_user_name"));
|
|
|
|
|
HSSFRichTextString text3 = new HSSFRichTextString(thisAmount.getString("state"));
|
|
|
|
|
HSSFRichTextString text4 = new HSSFRichTextString(thisAmount.getString("suburb"));
|
|
|
|
|
HSSFRichTextString text5 = new HSSFRichTextString(industry == null?"":industry);
|
|
|
|
|
HSSFRichTextString text6 = new HSSFRichTextString(clientAmount.get(i).getString("total"));
|
|
|
|
|
HSSFRichTextString text7 = new HSSFRichTextString(clientAmount.get(i).getString("orders"));
|
|
|
|
|
HSSFRichTextString text8 = new HSSFRichTextString(clientAmount.get(i).getString("alipay_total"));
|
|
|
|
|
HSSFRichTextString text9 = new HSSFRichTextString(clientAmount.get(i).getString("alipay_order"));
|
|
|
|
|
HSSFRichTextString text_10 = new HSSFRichTextString(clientAmount.get(i).getString("wechat_toatl"));
|
|
|
|
|
HSSFRichTextString text_11 = new HSSFRichTextString(clientAmount.get(i).getString("wechat_order"));
|
|
|
|
|
HSSFRichTextString text6 = new HSSFRichTextString(thisAmount.getString("total"));
|
|
|
|
|
HSSFRichTextString text7 = new HSSFRichTextString(percent.format(lastTotal.doubleValue()));
|
|
|
|
|
HSSFRichTextString text8 = new HSSFRichTextString(thisAmount.getString("orders"));
|
|
|
|
|
HSSFRichTextString text9 = new HSSFRichTextString(thisAmount.getString("alipay_total"));
|
|
|
|
|
HSSFRichTextString text_10 = new HSSFRichTextString(percent.format(alipayTotal.doubleValue()));
|
|
|
|
|
HSSFRichTextString text_11 = new HSSFRichTextString(thisAmount.getString("alipay_order"));
|
|
|
|
|
HSSFRichTextString text_12 = new HSSFRichTextString(thisAmount.getString("wechat_toatl"));
|
|
|
|
|
HSSFRichTextString text_13 = new HSSFRichTextString(percent.format(wechatToatl.doubleValue()));
|
|
|
|
|
HSSFRichTextString text_14 = new HSSFRichTextString(thisAmount.getString("wechat_order"));
|
|
|
|
|
cell0.setCellValue(text0);
|
|
|
|
|
cell1.setCellValue(text1);
|
|
|
|
|
cell2.setCellValue(text2);
|
|
|
|
@ -215,6 +340,9 @@ public class AreaMerchantTradeAnalysisImpl implements AreaMerchantTradeAnalysis{
|
|
|
|
|
cell9.setCellValue(text9);
|
|
|
|
|
cel10.setCellValue(text_10);
|
|
|
|
|
cel11.setCellValue(text_11);
|
|
|
|
|
cel12.setCellValue(text_12);
|
|
|
|
|
cel13.setCellValue(text_13);
|
|
|
|
|
cel14.setCellValue(text_14);
|
|
|
|
|
}
|
|
|
|
|
JSONObject parmerters = new JSONObject();
|
|
|
|
|
parmerters.put("dateFrom", StringUtils.isNotBlank(queryBean.getBegin()) ? queryBean.getBegin() : "");
|
|
|
|
@ -232,7 +360,12 @@ public class AreaMerchantTradeAnalysisImpl implements AreaMerchantTradeAnalysis{
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JSONObject toAmount(JSONObject cycle, JSONObject amount) {
|
|
|
|
|
if(amount != null && cycle!= null){
|
|
|
|
|
amount.putAll(cycle);
|
|
|
|
|
}
|
|
|
|
|
return amount;
|
|
|
|
|
}
|
|
|
|
|
private String getRoyalpayIindustry(String industryMccCode,JSONArray jsonArray) {
|
|
|
|
|
String industry = null;
|
|
|
|
|
for(int i = 0;i<jsonArray.size();i++){
|
|
|
|
|