Merge remote-tracking branch 'origin/develop' into develop

master
yixian 5 years ago
commit 6740488ef1

@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId> <artifactId>manage</artifactId>
<version>1.1.15</version> <version>1.1.17</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

@ -30,4 +30,10 @@ public interface BDAnalysisService {
* @return bd_id, bd_name, num * @return bd_id, bd_name, num
*/ */
List<JSONObject> approvedAnalysis(JSONObject params); List<JSONObject> approvedAnalysis(JSONObject params);
/**
* BD
* @param format
*/
void generateReport(String format);
} }

@ -3,10 +3,13 @@ package au.com.royalpay.payment.manage.analysis.core.impls;
import au.com.royalpay.payment.manage.analysis.beans.AnalysisBean; import au.com.royalpay.payment.manage.analysis.beans.AnalysisBean;
import au.com.royalpay.payment.manage.analysis.core.BDAnalysisService; import au.com.royalpay.payment.manage.analysis.core.BDAnalysisService;
import au.com.royalpay.payment.manage.analysis.mappers.BDAnalysisMapper; import au.com.royalpay.payment.manage.analysis.mappers.BDAnalysisMapper;
import au.com.royalpay.payment.manage.mappers.log.StatisticsBDSalesReportMapper;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
@ -18,8 +21,12 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID;
/** /**
* Created by yishuqian on 30/09/2016. * Created by yishuqian on 30/09/2016.
@ -30,24 +37,50 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
@Resource @Resource
private BDAnalysisMapper bdAnalysisMapper; private BDAnalysisMapper bdAnalysisMapper;
@Resource
private StatisticsBDSalesReportMapper bdSalesReportMapper;
@Override @Override
public List<JSONObject> getSalesAnalysis(JSONObject jsonObject) { public List<JSONObject> getSalesAnalysis(JSONObject jsonObject) {
return listSalesAnalysis(jsonObject); return listSalesAnalysis(jsonObject);
} }
private List<JSONObject> listSalesAnalysis(JSONObject jsonObject){ private List<JSONObject> listSalesAnalysis(JSONObject jsonObject) {
List<JSONObject> listCountApproved = bdAnalysisMapper.countApproved(jsonObject); List<JSONObject> listCountApproved = bdAnalysisMapper.countApproved(jsonObject);
List<JSONObject> bdSaleList = bdAnalysisMapper.getBDSaleList(jsonObject); List<JSONObject> bdSaleList = bdSalesReportMapper.getBDSaleList(jsonObject);
for(JSONObject countApproved : listCountApproved){ for (JSONObject countApproved : listCountApproved) {
for(JSONObject saleList : bdSaleList){ for (JSONObject saleList : bdSaleList) {
if(countApproved.getString("bd_id").equals(saleList.getString("bd_id"))){ if (countApproved.getString("bd_id").equals(saleList.getString("bd_id"))) {
saleList.put("num",countApproved.getString("num")); saleList.put("num", countApproved.getString("num"));
}
}
}
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
if (sd.format(jsonObject.getDate("end")).equals(sd.format(DateUtils.addDays(new Date(), 1)))) {
jsonObject.put("begin", DateUtils.addDays(jsonObject.getDate("end"), -1));
// jsonObject.put("end", DateUtils.addDays(jsonObject.getDate("end"), -2));
jsonObject.put("end",jsonObject.getDate("end"));
List<JSONObject> todaySaleList = bdAnalysisMapper.getBDSaleList(jsonObject);
for (JSONObject todayBDSaleItem : todaySaleList) {
boolean flag = false;
for(JSONObject baSaleItem: bdSaleList){
if (baSaleItem.getString("bd_id").equals(todayBDSaleItem.getString("bd_id"))) {
BigDecimal newAmount = baSaleItem.getBigDecimal("total").add(todayBDSaleItem.getBigDecimal("total"));
baSaleItem.put("total",newAmount);
flag = true;
}
} }
if (!flag) {
bdSaleList.add(todayBDSaleItem);
} }
} }
}
return bdSaleList; return bdSaleList;
} }
//单独计算当日数据
@Override @Override
public List<JSONObject> getSalesPartnersByBD(JSONObject jsonObject) { public List<JSONObject> getSalesPartnersByBD(JSONObject jsonObject) {
@ -58,32 +91,32 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
public List<JSONObject> getSalesPartnersReportByBD(JSONObject jsonObject) { public List<JSONObject> getSalesPartnersReportByBD(JSONObject jsonObject) {
List<JSONObject> bdAnalysis = bdAnalysisMapper.getBDSalePartnerReport(jsonObject); List<JSONObject> bdAnalysis = bdAnalysisMapper.getBDSalePartnerReport(jsonObject);
List<JSONObject> result = new ArrayList<>(); List<JSONObject> result = new ArrayList<>();
String keys_1[] = {"1","2","3","4","5","6","7","8","9"}; String keys_1[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9"};
String key_2[] = {"10","11","12"}; String key_2[] = {"10", "11", "12"};
result = getPartnerTypes(keys_1,result,1,5,bdAnalysis); result = getPartnerTypes(keys_1, result, 1, 5, bdAnalysis);
return getPartnerTypes(key_2,result,2,6,bdAnalysis); return getPartnerTypes(key_2, result, 2, 6, bdAnalysis);
} }
private List<JSONObject> getPartnerTypes(String keys[],List<JSONObject> result,int short_length,int long_length,List<JSONObject> bdAnalysis){ private List<JSONObject> getPartnerTypes(String keys[], List<JSONObject> result, int short_length, int long_length, List<JSONObject> bdAnalysis) {
for(String key : keys){ for (String key : keys) {
int countValue = 0; int countValue = 0;
int countTotal = 0; int countTotal = 0;
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
JSONArray list = new JSONArray(); JSONArray list = new JSONArray();
for(JSONObject type : bdAnalysis){ for (JSONObject type : bdAnalysis) {
if(type.getString("royalpayindustry") != null && type.getString("royalpayindustry").startsWith(key) && (type.getString("royalpayindustry").length()==short_length || type.getString("royalpayindustry").length()==long_length)){ if (type.getString("royalpayindustry") != null && type.getString("royalpayindustry").startsWith(key) && (type.getString("royalpayindustry").length() == short_length || type.getString("royalpayindustry").length() == long_length)) {
countValue += type.getIntValue("partner_counts"); countValue += type.getIntValue("partner_counts");
countTotal += type.getIntValue("total"); countTotal += type.getIntValue("total");
list.add(type); list.add(type);
} }
} }
if(countValue == 0){ if (countValue == 0) {
continue; continue;
} }
object.put("count_value",countValue); object.put("count_value", countValue);
object.put("count_total",countTotal); object.put("count_total", countTotal);
object.put("mccCode",key); object.put("mccCode", key);
object.put("children",list); object.put("children", list);
result.add(object); result.add(object);
} }
return result; return result;
@ -92,7 +125,7 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
@Override @Override
public void exportSalesExcel(AnalysisBean analysisBean, HttpServletResponse httpResponse, JSONObject manager) throws IOException { public void exportSalesExcel(AnalysisBean analysisBean, HttpServletResponse httpResponse, JSONObject manager) throws IOException {
httpResponse.setContentType("application/vnd.ms-excel"); httpResponse.setContentType("application/vnd.ms-excel");
String fileName = analysisBean.getBegin_month()+"~"+analysisBean.getEnd_month(); String fileName = analysisBean.getBegin_month() + "~" + analysisBean.getEnd_month();
// String fileName = new String(URLEncoder.encode(defaultname,"utf8")); // String fileName = new String(URLEncoder.encode(defaultname,"utf8"));
httpResponse.setHeader("Content-Disposition", "attachment;filename=" httpResponse.setHeader("Content-Disposition", "attachment;filename="
+ fileName + ".xls"); + fileName + ".xls");
@ -113,20 +146,20 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
List<JSONObject> bds = bdAnalysisMapper.getBDSaleList(params); List<JSONObject> bds = bdAnalysisMapper.getBDSaleList(params);
HSSFWorkbook workbook = new HSSFWorkbook(); HSSFWorkbook workbook = new HSSFWorkbook();
for (JSONObject bd:bds){ for (JSONObject bd : bds) {
String bd_id = bd.getString("bd_id"); String bd_id = bd.getString("bd_id");
String bd_name = bd.getString("bd_name"); String bd_name = bd.getString("bd_name");
JSONObject monthParams = new JSONObject(); JSONObject monthParams = new JSONObject();
monthParams.put("bd_id",bd_id); monthParams.put("bd_id", bd_id);
monthParams.put("begin_month",analysisBean.getBegin_month()); monthParams.put("begin_month", analysisBean.getBegin_month());
monthParams.put("end_month",analysisBean.getEnd_month()); monthParams.put("end_month", analysisBean.getEnd_month());
List<JSONObject> monthTotalSale = bdAnalysisMapper.getMonthSalesList(monthParams); List<JSONObject> monthTotalSale = bdAnalysisMapper.getMonthSalesList(monthParams);
for (JSONObject month:monthTotalSale){ for (JSONObject month : monthTotalSale) {
monthParams.put("month",month.getString("y_m")); monthParams.put("month", month.getString("y_m"));
List<JSONObject> clientsMonthSale = bdAnalysisMapper.getClientsMonthSale(bd_id,analysisBean.getBegin_month(),analysisBean.getEnd_month(),month.getString("y_m")); List<JSONObject> clientsMonthSale = bdAnalysisMapper.getClientsMonthSale(bd_id, analysisBean.getBegin_month(), analysisBean.getEnd_month(), month.getString("y_m"));
month.put("clients",clientsMonthSale); month.put("clients", clientsMonthSale);
} }
exportExcel(workbook,bd_name,monthTotalSale); exportExcel(workbook, bd_name, monthTotalSale);
} }
OutputStream outputStream = httpResponse.getOutputStream(); OutputStream outputStream = httpResponse.getOutputStream();
try { try {
@ -144,14 +177,52 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
return bdAnalysisMapper.countApproved(params); return bdAnalysisMapper.countApproved(params);
} }
/**
* BD
* @param date
*/
@Override
public void generateReport(String date) {
try {
Date beginTime = DateUtils.parseDate(date, new String[]{"yyyy-MM-dd"});
Date yesterdayEndTime = DateUtils.addDays(beginTime, 1);
String endDate = DateFormatUtils.format(yesterdayEndTime, "yyyy-MM-dd");
Date endTime = DateUtils.parseDate(endDate, new String[]{"yyyy-MM-dd"});
JSONObject params = new JSONObject();
params.put("begin", beginTime);
params.put("end", endTime);
List<JSONObject> bdSaleList = bdAnalysisMapper.getOneDayBDSaleList(params);
if (bdSaleList.size() != 0) {
for (JSONObject item : bdSaleList) {
JSONObject existBDSalesReport = bdSalesReportMapper.findByBDIdAndLogDate(item.getString("bd_id"),beginTime);
if(existBDSalesReport==null){
JSONObject object = new JSONObject(item);
object.put("log_id", UUID.randomUUID().toString());
object.put("log_date", beginTime);
object.put("create_time", new Date());
bdSalesReportMapper.save(object);
}else{
existBDSalesReport.put("pay_amount",item.getString("pay_amount"));
existBDSalesReport.put("refund_amount",item.getString("refund_amount"));
existBDSalesReport.put("net_amount",item.getString("net_amount"));
bdSalesReportMapper.update(existBDSalesReport);
}
}
}
} catch (ParseException e) {
e.printStackTrace();
}
}
@Override @Override
public void exportPartnerExcelByBd(AnalysisBean analysisBean, HttpServletResponse httpResponse, JSONObject manager) throws IOException { public void exportPartnerExcelByBd(AnalysisBean analysisBean, HttpServletResponse httpResponse, JSONObject manager) throws IOException {
OutputStream ous = null; OutputStream ous = null;
try{ try {
JSONObject parmerters = analysisBean.toParams(null); JSONObject parmerters = analysisBean.toParams(null);
List<JSONObject> listPartnerByBd = bdAnalysisMapper.getBDSalePartnerList(parmerters); List<JSONObject> listPartnerByBd = bdAnalysisMapper.getBDSalePartnerList(parmerters);
httpResponse.setContentType("application/octet-stream;"); httpResponse.setContentType("application/octet-stream;");
httpResponse.addHeader("Content-Disposition", "attachment; filename=" + "Merchant_list--" +parmerters.getString("bd_name") + analysisBean.getBegin() + "~" + analysisBean.getEnd() + ".xls"); httpResponse.addHeader("Content-Disposition", "attachment; filename=" + "Merchant_list--" + parmerters.getString("bd_name") + analysisBean.getBegin() + "~" + analysisBean.getEnd() + ".xls");
ous = httpResponse.getOutputStream(); ous = httpResponse.getOutputStream();
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
HSSFFont font = wb.createFont(); HSSFFont font = wb.createFont();
@ -159,7 +230,7 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
font.setFontHeightInPoints((short) 15); font.setFontHeightInPoints((short) 15);
CellStyle analysisStyle = wb.createCellStyle(); CellStyle analysisStyle = wb.createCellStyle();
analysisStyle.setFont(font); analysisStyle.setFont(font);
Sheet sheet = wb.createSheet("Merchant list" ); Sheet sheet = wb.createSheet("Merchant list");
sheet.createFreezePane(1, 2); sheet.createFreezePane(1, 2);
sheet.setDefaultColumnWidth((short) 25); sheet.setDefaultColumnWidth((short) 25);
int rowNum = 0; int rowNum = 0;
@ -168,7 +239,7 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
for (int i = 0; i < title.length; i++) { for (int i = 0; i < title.length; i++) {
row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]); row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]);
} }
for(JSONObject partner : listPartnerByBd){ for (JSONObject partner : listPartnerByBd) {
row = sheet.createRow(++rowNum); row = sheet.createRow(++rowNum);
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("short_name")); row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("short_name"));
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("client_moniker")); row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(partner.getString("client_moniker"));
@ -176,7 +247,7 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
} }
wb.write(ous); wb.write(ous);
ous.flush(); ous.flush();
}catch (IOException e){ } catch (IOException e) {
} finally { } finally {
IOUtils.closeQuietly(ous); IOUtils.closeQuietly(ous);
} }
@ -186,7 +257,7 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
@Override @Override
public void exportPartnerExcelByData(AnalysisBean analysisBean, HttpServletResponse httpResponse, JSONObject manager) throws IOException { public void exportPartnerExcelByData(AnalysisBean analysisBean, HttpServletResponse httpResponse, JSONObject manager) throws IOException {
OutputStream ous = null; OutputStream ous = null;
try{ try {
JSONObject parmerters = analysisBean.toParams(null); JSONObject parmerters = analysisBean.toParams(null);
List<JSONObject> listPartnerByData = listSalesAnalysis(parmerters); List<JSONObject> listPartnerByData = listSalesAnalysis(parmerters);
httpResponse.setContentType("application/octet-stream;"); httpResponse.setContentType("application/octet-stream;");
@ -198,31 +269,31 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
font.setFontHeightInPoints((short) 15); font.setFontHeightInPoints((short) 15);
CellStyle analysisStyle = wb.createCellStyle(); CellStyle analysisStyle = wb.createCellStyle();
analysisStyle.setFont(font); analysisStyle.setFont(font);
Sheet sheet = wb.createSheet("Merchant Sale List" ); Sheet sheet = wb.createSheet("Merchant Sale List");
sheet.createFreezePane(1, 2); sheet.createFreezePane(1, 2);
sheet.setDefaultColumnWidth((short) 25); sheet.setDefaultColumnWidth((short) 25);
int rowNum = 0; int rowNum = 0;
Row row = sheet.createRow(rowNum); Row row = sheet.createRow(rowNum);
String[] title = {"BD Name", "AUD Amount", "Refund Fee","New Merchants"}; String[] title = {"BD Name", "AUD Amount", "Refund Fee", "New Merchants"};
for (int i = 0; i < title.length; i++) { for (int i = 0; i < title.length; i++) {
row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]); row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]);
} }
for(JSONObject dataSale : listPartnerByData){ for (JSONObject dataSale : listPartnerByData) {
row = sheet.createRow(++rowNum); row = sheet.createRow(++rowNum);
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(dataSale.getString("bd_name")); row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(dataSale.getString("bd_name"));
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(dataSale.getString("total")); row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(dataSale.getString("total"));
row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(dataSale.getString("refund_fee")); row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(dataSale.getString("refund_fee"));
row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(dataSale.getString("num") == null? "0" : dataSale.getString("num")); row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(dataSale.getString("num") == null ? "0" : dataSale.getString("num"));
} }
wb.write(ous); wb.write(ous);
ous.flush(); ous.flush();
}catch (IOException e){ } catch (IOException e) {
} finally { } finally {
IOUtils.closeQuietly(ous); IOUtils.closeQuietly(ous);
} }
} }
private void exportExcel(HSSFWorkbook workbook,String title,List<JSONObject> monthTotalSale) { private void exportExcel(HSSFWorkbook workbook, String title, List<JSONObject> monthTotalSale) {
// 声明一个工作薄 // 声明一个工作薄
// 生成一个表格 // 生成一个表格
HSSFSheet sheet = workbook.createSheet(title); HSSFSheet sheet = workbook.createSheet(title);
@ -271,9 +342,9 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
// comment.setAuthor("leno"); // comment.setAuthor("leno");
//产生表格标题行 //产生表格标题行
HSSFRow row0= sheet.createRow(0); HSSFRow row0 = sheet.createRow(0);
HSSFRow row1= sheet.createRow(1); HSSFRow row1 = sheet.createRow(1);
HSSFRow row2= sheet.createRow(2); HSSFRow row2 = sheet.createRow(2);
HSSFCell cell00 = row0.createCell(0); HSSFCell cell00 = row0.createCell(0);
HSSFCell cell01 = row0.createCell(1); HSSFCell cell01 = row0.createCell(1);
HSSFCell cell20 = row2.createCell(0); HSSFCell cell20 = row2.createCell(0);
@ -294,15 +365,13 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
cell20.setCellValue(text20); cell20.setCellValue(text20);
for (int i = 0; i < monthTotalSale.size(); i++) { for (int i = 0; i < monthTotalSale.size(); i++) {
sheet.addMergedRegion(new CellRangeAddress(0,0,2*i+2,2*i+3)); sheet.addMergedRegion(new CellRangeAddress(0, 0, 2 * i + 2, 2 * i + 3));
HSSFCell cell02 = row0.createCell(i*2+2); HSSFCell cell02 = row0.createCell(i * 2 + 2);
HSSFCell cell12 = row1.createCell(i*2+2); HSSFCell cell12 = row1.createCell(i * 2 + 2);
HSSFCell cell13 = row1.createCell(i*2+3); HSSFCell cell13 = row1.createCell(i * 2 + 3);
HSSFCell cell22 = row2.createCell(i*2+2); HSSFCell cell22 = row2.createCell(i * 2 + 2);
HSSFCell cell23 = row2.createCell(i*2+3); HSSFCell cell23 = row2.createCell(i * 2 + 3);
cell02.setCellStyle(style); cell02.setCellStyle(style);
cell12.setCellStyle(style); cell12.setCellStyle(style);
@ -314,19 +383,18 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
HSSFRichTextString text13 = new HSSFRichTextString("增长百分比"); HSSFRichTextString text13 = new HSSFRichTextString("增长百分比");
HSSFRichTextString text22 = new HSSFRichTextString(monthTotalSale.get(i).getString("total")); HSSFRichTextString text22 = new HSSFRichTextString(monthTotalSale.get(i).getString("total"));
double rate = 0; double rate = 0;
if (i>0){ if (i > 0) {
BigDecimal lastTotal = monthTotalSale.get(i-1).getBigDecimal("total"); BigDecimal lastTotal = monthTotalSale.get(i - 1).getBigDecimal("total");
BigDecimal total = monthTotalSale.get(i).getBigDecimal("total"); BigDecimal total = monthTotalSale.get(i).getBigDecimal("total");
if (lastTotal.compareTo(new BigDecimal(0))==0 && total.compareTo(new BigDecimal(0)) !=0){ if (lastTotal.compareTo(new BigDecimal(0)) == 0 && total.compareTo(new BigDecimal(0)) != 0) {
rate=100; rate = 100;
} } else if (lastTotal.compareTo(new BigDecimal(0)) == 0 && total.compareTo(new BigDecimal(0)) == 0) {
else if (lastTotal.compareTo(new BigDecimal(0))==0 && total.compareTo(new BigDecimal(0)) ==0){ rate = 0;
rate=0; } else {
}else { rate = total.subtract(lastTotal).multiply(new BigDecimal(100)).divide(lastTotal, 2, BigDecimal.ROUND_DOWN).doubleValue();
rate = total.subtract(lastTotal).multiply(new BigDecimal(100)).divide(lastTotal,2,BigDecimal.ROUND_DOWN).doubleValue();
} }
} }
HSSFRichTextString text23 = i==0?new HSSFRichTextString("-"):new HSSFRichTextString(String.valueOf(rate)); HSSFRichTextString text23 = i == 0 ? new HSSFRichTextString("-") : new HSSFRichTextString(String.valueOf(rate));
cell02.setCellValue(text0); cell02.setCellValue(text0);
cell12.setCellValue(text12); cell12.setCellValue(text12);
cell13.setCellValue(text13); cell13.setCellValue(text13);
@ -335,35 +403,34 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
} }
List<JSONObject> partnersSale = (List<JSONObject>) monthTotalSale.get(0).get("clients"); List<JSONObject> partnersSale = (List<JSONObject>) monthTotalSale.get(0).get("clients");
for (int m=0;m<partnersSale.size();m++){ for (int m = 0; m < partnersSale.size(); m++) {
HSSFRow row = sheet.createRow(m+3); HSSFRow row = sheet.createRow(m + 3);
HSSFCell cell_client_name = row.createCell(0); HSSFCell cell_client_name = row.createCell(0);
HSSFCell cell_approve_time = row.createCell(1); HSSFCell cell_approve_time = row.createCell(1);
cell_client_name.setCellStyle(style); cell_client_name.setCellStyle(style);
cell_approve_time.setCellStyle(style); cell_approve_time.setCellStyle(style);
HSSFRichTextString text_client_name = new HSSFRichTextString(partnersSale.get(m).getString("short_name")); HSSFRichTextString text_client_name = new HSSFRichTextString(partnersSale.get(m).getString("short_name"));
HSSFRichTextString text_approve_time= new HSSFRichTextString(partnersSale.get(m).getString("approve_time")); HSSFRichTextString text_approve_time = new HSSFRichTextString(partnersSale.get(m).getString("approve_time"));
cell_client_name.setCellValue(text_client_name); cell_client_name.setCellValue(text_client_name);
cell_approve_time.setCellValue(text_approve_time); cell_approve_time.setCellValue(text_approve_time);
for (int n = 0; n < monthTotalSale.size(); n++) { for (int n = 0; n < monthTotalSale.size(); n++) {
List<JSONObject> clients = (List<JSONObject>) monthTotalSale.get(n).get("clients"); List<JSONObject> clients = (List<JSONObject>) monthTotalSale.get(n).get("clients");
HSSFCell celli2 = row.createCell(n*2+2); HSSFCell celli2 = row.createCell(n * 2 + 2);
HSSFCell celli3 = row.createCell(n*2+3); HSSFCell celli3 = row.createCell(n * 2 + 3);
celli2.setCellStyle(style2); celli2.setCellStyle(style2);
celli3.setCellStyle(style2); celli3.setCellStyle(style2);
HSSFRichTextString texti2 = new HSSFRichTextString(clients.get(m).getString("month_total")); HSSFRichTextString texti2 = new HSSFRichTextString(clients.get(m).getString("month_total"));
double rate = 0; double rate = 0;
if (n>0){ if (n > 0) {
List<JSONObject> lastClients = (List<JSONObject>) monthTotalSale.get(n-1).get("clients"); List<JSONObject> lastClients = (List<JSONObject>) monthTotalSale.get(n - 1).get("clients");
BigDecimal lastTotal = lastClients.get(m).getBigDecimal("month_total"); BigDecimal lastTotal = lastClients.get(m).getBigDecimal("month_total");
BigDecimal total = clients.get(m).getBigDecimal("month_total"); BigDecimal total = clients.get(m).getBigDecimal("month_total");
if (lastTotal.compareTo(new BigDecimal(0))==0 && total.compareTo(new BigDecimal(0)) !=0){ if (lastTotal.compareTo(new BigDecimal(0)) == 0 && total.compareTo(new BigDecimal(0)) != 0) {
rate=100; rate = 100;
} } else if (lastTotal.compareTo(new BigDecimal(0)) == 0 && total.compareTo(new BigDecimal(0)) == 0) {
else if (lastTotal.compareTo(new BigDecimal(0))==0 && total.compareTo(new BigDecimal(0)) ==0){ rate = 0;
rate=0; } else {
}else { rate = total.subtract(lastTotal).multiply(new BigDecimal(100)).divide(lastTotal, 2, BigDecimal.ROUND_DOWN).doubleValue();
rate = total.subtract(lastTotal).multiply(new BigDecimal(100)).divide(lastTotal,2,BigDecimal.ROUND_DOWN).doubleValue();
} }
} }
HSSFRichTextString texti3 = new HSSFRichTextString(String.valueOf(rate)); HSSFRichTextString texti3 = new HSSFRichTextString(String.valueOf(rate));

@ -1,12 +1,19 @@
package au.com.royalpay.payment.manage.analysis.core.impls; package au.com.royalpay.payment.manage.analysis.core.impls;
import au.com.royalpay.payment.manage.analysis.core.OrgAnalysisService; import au.com.royalpay.payment.manage.analysis.core.OrgAnalysisService;
import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper;
import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper;
import au.com.royalpay.payment.manage.mappers.log.StatisticsBDSalesReportMapper;
import au.com.royalpay.payment.manage.organizations.core.OrgManager; import au.com.royalpay.payment.manage.organizations.core.OrgManager;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -17,14 +24,52 @@ public class OrgAnalysisServiceImp implements OrgAnalysisService {
@Resource @Resource
private TransactionAnalysisMapper transactionAnalysisMapper; private TransactionAnalysisMapper transactionAnalysisMapper;
@Resource
private StatisticsBDSalesReportMapper statisticsBDSalesReportMapper;
@Resource @Resource
private OrgManager orgManager; private OrgManager orgManager;
@Resource
private CustomerAndOrdersStatisticsMapper customerAndOrdersStatisticsMapper;
@Override @Override
public List<JSONObject> getSalesAnalysis(JSONObject params,JSONObject manager) { public List<JSONObject> getSalesAnalysis(JSONObject params,JSONObject manager) {
orgManager.checkOrgIds(manager,params); orgManager.checkOrgIds(manager,params);
List<JSONObject> OrgTransaction = transactionAnalysisMapper.getOrgTransactionAnalysis(params); params.put("org_type",0);
return OrgTransaction; List<JSONObject> OrgTransaction = statisticsBDSalesReportMapper.getPartnerAmountList(params);
List<JSONObject> newOrgTransaction = new ArrayList<>();
OrgTransaction.forEach(item->{
newOrgTransaction.add(new JSONObject(){{
put("org_id",item.getString("org_id"));
put("org_name",item.getString("org_name"));
put("amount",item.getString("clearing_amount"));
}}
);
});
//判断查询的最后一天是否是当日,若是当日,将当日数据添加至结果集内
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
if (sd.format(params.getDate("end")).equals(sd.format(DateUtils.addDays(new Date(), 1)))) {
params.put("begin", DateUtils.addDays(params.getDate("end"), -1));
params.put("end",params.getDate("end"));
List<JSONObject> todayOrgTransaction = transactionAnalysisMapper.getOrgTransactionAnalysis(params);
if(todayOrgTransaction.size()!=0){
for (JSONObject todayOrgTransactionItem : todayOrgTransaction) {
boolean flag = false;
for (JSONObject orgTransaction : newOrgTransaction) {
if (orgTransaction.getString("org_id").equals(todayOrgTransactionItem.getString("org_id"))) {
BigDecimal newAmount = orgTransaction.getBigDecimal("clearing_amount").add(todayOrgTransactionItem.getBigDecimal("amount"));
orgTransaction.put("amount", newAmount);
flag = true;
}
}
if (!flag) {
newOrgTransaction.add(todayOrgTransactionItem);
}
}
}
}
return newOrgTransaction;
} }
@Override @Override

@ -26,4 +26,7 @@ public interface BDAnalysisMapper {
List<JSONObject> countApproved(JSONObject params); List<JSONObject> countApproved(JSONObject params);
List<JSONObject> getBDSalePartnerReport(JSONObject jsonObject); List<JSONObject> getBDSalePartnerReport(JSONObject jsonObject);
//获取指定一天销售数据
List<JSONObject> getOneDayBDSaleList(JSONObject params);
} }

@ -108,6 +108,5 @@ public class ManualServiceimpl implements ManualService {
} }
}); });
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(null, client_moniker, "tax_in_surcharge", false));
} }
} }

@ -0,0 +1,28 @@
package au.com.royalpay.payment.manage.dev.web;
import au.com.royalpay.payment.manage.analysis.core.BDAnalysisService;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@RestController
@RequestMapping("/analysis")
public class AnalysisController {
@Resource
private BDAnalysisService bdAnalysisService;
@GetMapping("/report/bd/sales")
public void reportDBSalesList(@RequestParam("date") String date) throws ParseException {
Date newDate = new SimpleDateFormat("yyyy-MM-dd").parse(date);
bdAnalysisService.generateReport(DateFormatUtils.format(newDate, "yyyy-MM-dd"));
}
}

@ -0,0 +1,29 @@
package au.com.royalpay.payment.manage.mappers.log;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
* Created by dulingling on 2019-08-14
*/
@AutoMapper(tablename = "statistics_bd_sales", pkName = "log_id")
public interface StatisticsBDSalesReportMapper {
@AutoSql(type = SqlType.INSERT)
void save(JSONObject report);
List<JSONObject> getBDSaleList(JSONObject params);
List<JSONObject> getPartnerAmountList(JSONObject params);
JSONObject findByBDIdAndLogDate(@Param("bd_id") String bd_id, @Param("log_date")Date beginTime);
@AutoSql(type = SqlType.UPDATE)
void update(JSONObject existBDSalesReport);
}

@ -4997,7 +4997,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
rpayApi.modifySurchargeConfig(clientMapper.findClient(client_id)); rpayApi.modifySurchargeConfig(clientMapper.findClient(client_id));
} }
} }
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(null, client.getString("client_moniker"), "tax_in_surcharge", false));
adminAccounts.forEach(o -> { adminAccounts.forEach(o -> {
sendClientPostponeNotify(o, expireDate); sendClientPostponeNotify(o, expireDate);
}); });
@ -5017,7 +5016,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
public boolean postponeClientRate(int clientId, String clientMoniker, String nextYearExipryDate) { public boolean postponeClientRate(int clientId, String clientMoniker, String nextYearExipryDate) {
try { try {
clientRateMapper.postponeMerchantRateByClientId(clientId); clientRateMapper.postponeMerchantRateByClientId(clientId);
clientModifySupport.processClientConfigModify(new SwitchPermissionModify(null, clientMoniker, "tax_in_surcharge", false));
List<JSONObject> adminAccounts = clientAccountMapper.listAdminAccounts(clientId); List<JSONObject> adminAccounts = clientAccountMapper.listAdminAccounts(clientId);
adminAccounts.forEach(o -> { adminAccounts.forEach(o -> {
sendClientPostponeNotify(o, nextYearExipryDate); sendClientPostponeNotify(o, nextYearExipryDate);

@ -104,7 +104,6 @@ public class ClientContractServiceImpl implements ClientContractService {
contract.put("confirm_time", now); contract.put("confirm_time", now);
contract.put("signatory", account.getString("display_name")); contract.put("signatory", account.getString("display_name"));
clientsContractMapper.update(contract); clientsContractMapper.update(contract);
clientManager.setClientTaxInSurcharge(clientAccountMapper.findById(account_id),client.getString("client_moniker"), false);
} }
@Override @Override

@ -0,0 +1,34 @@
package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.analysis.core.BDAnalysisService;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
/**
* Created by dulingling on 2019-08-14
*/
@Component
@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true")
public class DBSaleAnalysisTask {
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Resource
private BDAnalysisService bdAnalysisService;
@Scheduled(cron = "0 0 10 * * ?")
public void dailyReportAutoGenerateReport() {
synchronizedScheduler.executeProcess("manage_task:dailyReportAutoGenerateReport", 120_000, () -> {
Date yesterday = DateUtils.addDays(new Date(), -1);
bdAnalysisService.generateReport(DateFormatUtils.format(yesterday, "yyyy-MM-dd"));
});
}
}

@ -3,67 +3,41 @@
<mapper namespace="au.com.royalpay.payment.manage.analysis.mappers.BDAnalysisMapper"> <mapper namespace="au.com.royalpay.payment.manage.analysis.mappers.BDAnalysisMapper">
<select id="getBDSaleList" resultType="com.alibaba.fastjson.JSONObject"> <select id="getBDSaleList" resultType="com.alibaba.fastjson.JSONObject">
SELECT SELECT
d.bd_name, clinetBD.bd_name,
d.bd_id, clinetBD.bd_id,
SUM(if(temp.transaction_type = 'Credit', temp.clearing_amount * d.proportion, -temp.clearing_amount * d.proportion)) total, SUM(if(temp.transaction_type = 'Credit', temp.clearing_amount * clinetBD.proportion, -temp.clearing_amount * clinetBD.proportion)) total,
ifnull(SUM(if(temp.refund_id IS NOT NULL, if(temp.transaction_type='Debit', temp.clearing_amount, -temp.clearing_amount) * d.proportion, 0)), 0) refund_fee ifnull(SUM(if(temp.refund_id IS NOT NULL, if(temp.transaction_type='Debit', temp.clearing_amount, -temp.clearing_amount) * clinetBD.proportion, 0)), 0) refund_fee
FROM( FROM(
SELECT SELECT
l.client_id, trans.client_id,
l.clearing_amount, trans.clearing_amount,
l.refund_id, trans.refund_id,
l.transaction_type, trans.transaction_type,
l.create_time trans.create_time
FROM pmt_transactions l FROM pmt_transactions AS trans
INNER JOIN pmt_orders o WHERE (trans.transaction_type = 'Credit' OR trans.refund_id IS NOT NULL)
ON o.order_id = l.order_id AND trans.system_generate = 0
AND trans.channel !='Settlement'
<if test="begin != null"> <if test="begin != null">
AND l.create_time &gt;= #{begin} AND trans.create_time &gt;= #{begin}
</if> </if>
<if test="end != null"> <if test="end != null">
AND l.create_time &lt; #{end} AND trans.create_time &lt; #{end}
</if> </if>
<if test="begin_month"> ) AS temp
AND DATE_FORMAT(l.create_time, '%Y-%m') &gt;= #{begin_month} INNER JOIN sys_client_bd AS clinetBD
</if> ON temp.client_id = clinetBD.client_id
<if test="end_month"> AND clinetBD.start_date &lt;= temp.create_time
AND DATE_FORMAT(l.create_time, '%Y-%m') &lt;= #{end_month} AND clinetBD.is_valid = '1'
</if> AND (clinetBD.end_date IS NULL OR clinetBD.end_date > temp.create_time)
WHERE (l.transaction_type = 'Credit' OR l.refund_id IS NOT NULL)
) temp INNER JOIN sys_managers AS manage
INNER JOIN sys_client_bd d ON manage.manager_id = clinetBD.bd_id
ON temp.client_id = d.client_id <if test="org_id != null">
AND d.start_date &lt;= temp.create_time AND manage.org_id = #{org_id}
AND d.is_valid = '1'
AND (d.end_date IS NULL OR d.end_date > temp.create_time)
<if test="org_id != null and org_ids == null">
INNER JOIN sys_managers m
ON m.manager_id = d.bd_id
AND m.org_id = #{org_id}
</if>
<if test="org_ids != null">
INNER JOIN sys_managers m
ON m.manager_id = d.bd_id
AND m.org_id IN
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">
#{org_id}
</foreach></if>
<if test="bd_group != null">
AND temp.client_id IN(
SELECT b.client_id
FROM sys_client_bd b
INNER JOIN financial_bd_config c
ON c.manager_id = b.bd_id
WHERE b.is_valid = 1
AND b.start_date &lt;= now()
AND (b.end_date IS NULL OR b.end_date &gt;= now())
AND (c.bd_group = #{bd_group} OR c.manager_id = #{bd_group})
<if test="bd_group_bd">
AND c.manager_id = #{bd_group_bd}
</if>
)
</if> </if>
GROUP BY d.bd_id
GROUP BY clinetBD.bd_id
ORDER BY total DESC ORDER BY total DESC
</select> </select>
@ -220,4 +194,54 @@
ORDER BY partner_counts DESC; ORDER BY partner_counts DESC;
</select> </select>
<select id="getOneDayBDSaleList" resultType="com.alibaba.fastjson.JSONObject">
SELECT
clinetBD.bd_name,
clinetBD.bd_id,
manage.org_id,
org.type AS org_type,
org.name AS org_name,
if(org.org_id=1,1,0) AS isOrg,
SUM( IF ( temp.transaction_type = 'Credit', temp.clearing_amount, 0 )) clearing_amount,
SUM(if(temp.transaction_type = 'Credit',temp.clearing_amount * clinetBD.proportion, -temp.clearing_amount * clinetBD.proportion)) pay_amount,
ifnull(SUM(if(temp.refund_id IS NOT NULL, if(temp.transaction_type='Debit', temp.clearing_amount, -temp.clearing_amount) * clinetBD.proportion, 0)), 0) refund_amount,
(SUM(if(temp.transaction_type = 'Credit', temp.clearing_amount * clinetBD.proportion, -temp.clearing_amount * clinetBD.proportion))) - (ifnull(SUM(if(temp.refund_id IS NOT NULL, if(temp.transaction_type='Debit', temp.clearing_amount, -temp.clearing_amount) * clinetBD.proportion, 0)), 0)) AS net_amount
FROM(
SELECT
trans.client_id,
trans.clearing_amount,
trans.refund_id,
trans.transaction_type,
trans.create_time
FROM pmt_transactions AS trans
WHERE (trans.transaction_type = 'Credit' OR trans.refund_id IS NOT NULL)
AND trans.system_generate = 0
AND trans.channel !='Settlement'
<if test="begin != null">
AND trans.create_time &gt;= #{begin}
</if>
<if test="end != null">
AND trans.create_time &lt; #{end}
</if>
)
AS temp
INNER JOIN sys_client_bd AS clinetBD
ON temp.client_id = clinetBD.client_id
AND clinetBD.start_date &lt;= temp.create_time
AND clinetBD.is_valid = '1'
AND (clinetBD.end_date IS NULL OR clinetBD.end_date > temp.create_time)
INNER JOIN sys_managers AS manage
ON manage.manager_id = clinetBD.bd_id
AND manage.org_id IS NOT NULL
INNER JOIN sys_org AS org
ON org.org_id = manage.org_id
<if test="org_id != null">
AND manage.org_id = #{org_id}
</if>
GROUP BY clinetBD.bd_id
ORDER BY pay_amount DESC
</select>
</mapper> </mapper>

@ -716,20 +716,37 @@
<select id="getOrgTransactionAnalysis" resultType="com.alibaba.fastjson.JSONObject"> <select id="getOrgTransactionAnalysis" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT o.org_id, o.name org_name,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) amount SELECT
FROM pmt_transactions t org.org_id,
INNER JOIN pmt_orders ord on ord.order_id = t.order_id org.name org_name,
RIGHT JOIN sys_clients c on t.client_id = c.client_id and c.is_valid = 1 SUM(if(trans.transaction_type='Credit',trans.clearing_amount,0)) AS amount
RIGHT JOIN sys_org o on o.org_id = c.org_id and o.org_id != 1 and o.type=0 FROM pmt_transactions AS trans
where (t.transaction_type = 'Credit' or t.refund_id is not null) RIGHT JOIN sys_clients AS clinet
]]> ON trans.client_id = clinet.client_id
<if test="begin!=null">and t.transaction_time &gt;= #{begin}</if> AND clinet.is_valid = 1
<if test="end!=null">and t.transaction_time &lt;= #{end}</if> RIGHT JOIN sys_org org
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if> ON org.org_id = clinet.org_id
<if test="org_ids!=null">and o.org_id in AND org.org_id != 1
AND org.type=0
WHERE trans.system_generate=0
AND trans.channel !='Settlement'
AND( trans.transaction_type = 'Credit' OR trans.refund_id IS NOT NULL )
]]>
<if test="begin!=null">
AND trans.transaction_time &gt;= #{begin}
</if>
<if test="end!=null">
AND trans.transaction_time &lt;= #{end}
</if>
<if test="org_id!=null and org_ids==null">
AND org.org_id=#{org_id}
</if>
<if test="org_ids!=null">
AND org.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach> <foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if> </if>
GROUP BY o.org_id order by amount desc GROUP BY org.org_id
ORDER BY amount DESC
</select> </select>
<select id="getPartnersAmountByOrg" resultType="com.alibaba.fastjson.JSONObject"> <select id="getPartnersAmountByOrg" resultType="com.alibaba.fastjson.JSONObject">

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="au.com.royalpay.payment.manage.mappers.log.StatisticsBDSalesReportMapper">
<select id="getBDSaleList" resultType="com.alibaba.fastjson.JSONObject">
SELECT
bd_id,
bd_name,
org_id,
org_name,
SUM(pay_amount) AS total,
SUM(refund_amount) AS refund_fee
FROM statistics_bd_sales
<where>
<if test="org_id != null">
AND org_id = #{org_id}
</if>
<if test="org_type != null">
AND org_type = #{org_type}
</if>
<if test="begin != null">
AND log_date &gt;= #{begin}
</if>
<if test="end != null">
AND log_date &lt; #{end}
</if>
<if test="org_ids!=null">
AND org.org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
</where>
GROUP BY bd_id
ORDER BY total DESC
</select>
<select id="getPartnerAmountList" resultType="com.alibaba.fastjson.JSONObject">
SELECT
bd_id,
bd_name,
org_id,
org_name,
SUM(clearing_amount) AS clearing_amount,
SUM(pay_amount) AS total,
SUM(refund_amount) AS refund_fee
FROM statistics_bd_sales
WHERE org_id !=1
<if test="org_id != null">
AND org_id = #{org_id}
</if>
<if test="org_type != null">
AND org_type = #{org_type}
</if>
<if test="begin != null">
AND log_date &gt;= #{begin}
</if>
<if test="end != null">
AND log_date &lt; #{end}
</if>
<if test="org_ids!=null">
AND org_id in
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if>
GROUP BY bd_id
ORDER BY total DESC
</select>
<select id="findByBDIdAndLogDate" resultType="com.alibaba.fastjson.JSONObject">
SELECT
log_id,
org_id,
isOrg,
org_name,
org_type,
bd_id,
bd_name,
log_date,
pay_amount,
refund_amount,
net_amount,
create_time,
clearing_amount
FROM statistics_bd_sales
WHERE bd_id = #{bd_id} AND log_date = #{log_date}
</select>
</mapper>

@ -76,7 +76,6 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts', './bd/analysis-b
}; };
$scope.loadSale = function () { $scope.loadSale = function () {
var params = angular.copy($scope.params); var params = angular.copy($scope.params);
if (params.begin) { if (params.begin) {
params.begin = $filter('date')(params.begin, 'yyyyMMdd'); params.begin = $filter('date')(params.begin, 'yyyyMMdd');
@ -88,6 +87,7 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts', './bd/analysis-b
} else { } else {
params.end = $filter('date')(new Date(), 'yyyyMMdd'); params.end = $filter('date')(new Date(), 'yyyyMMdd');
} }
params.org_id =1;
$http.get('/analysis/bd/sales', {params: params}).then(function (resp) { $http.get('/analysis/bd/sales', {params: params}).then(function (resp) {
$scope.sales = resp.data; $scope.sales = resp.data;
loadSaleChart(); loadSaleChart();

@ -59,6 +59,7 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts','./org/analysis-o
$scope.showOrg = 'Organization'; $scope.showOrg = 'Organization';
$http.get('/sys/orgs', {params: {}}).then(function (resp) { $http.get('/sys/orgs', {params: {}}).then(function (resp) {
$scope.orgs = resp.data; $scope.orgs = resp.data;
$scope.orgs.splice($scope.orgs.findIndex(item => item.org_id === 1), 1)
}); });
} }
@ -98,6 +99,7 @@ define(['angular', 'uiBootstrap', 'uiRouter', 'angularEcharts','./org/analysis-o
$scope.future_loading = false; $scope.future_loading = false;
}); });
}; };
$scope.chooseToday()
$scope.chooseOrgId = function (org) { $scope.chooseOrgId = function (org) {
if (org == 'all') { if (org == 'all') {
delete $scope.params.org_id; delete $scope.params.org_id;

@ -68,19 +68,6 @@
<a role="button" class="btn btn-default btn-sm" <a role="button" class="btn btn-default btn-sm"
ng-click="thisYear()">This Year</a> ng-click="thisYear()">This Year</a>
</div> </div>
<div uib-dropdown ng-if="orgs" class="btn-group">
<button id="single-button" type="button" class="btn btn-default"
uib-dropdown-toggle ng-disabled="disabled">
{{showOrg}} <span class="caret"></span>
</button>
<ul class="dropdown-menu" uib-dropdown-menu
aria-labelledby="single-button">
<li><a ng-click="chooseOrg('all')">All</a></li>
<li ng-repeat="org in orgs"><a ng-click="chooseOrg(org)">{{org.name}}</a>
</li>
</ul>
</div>
<button class="btn btn-success" type="button" ng-click="loadSale()"> <button class="btn btn-success" type="button" ng-click="loadSale()">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>

@ -60,10 +60,6 @@
<a role="button" class="btn btn-default btn-sm" ng-click="lastMonth()">Last <a role="button" class="btn btn-default btn-sm" ng-click="lastMonth()">Last
Month</a> Month</a>
</div> </div>
<div class="btn-group">
<a role="button" class="btn btn-default btn-sm" ng-click="thisYear()">This
Year</a>
</div>
<div uib-dropdown ng-if="orgs" class="btn-group"> <div uib-dropdown ng-if="orgs" class="btn-group">
<button id="single-button" type="button" class="btn btn-default" <button id="single-button" type="button" class="btn btn-default"
uib-dropdown-toggle ng-disabled="disabled"> uib-dropdown-toggle ng-disabled="disabled">

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

@ -3751,7 +3751,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
$scope.uploadAgreementFile = function (file) { $scope.uploadAgreementFile = function (file) {
if (file != null) { if (file != null) {
if (file.size > 10 * 1024 * 1024) { if (file.size > 10 * 1024 * 1024) {
commonDialog.alert({title: 'Error', content: '文件大小不能超过5MB请压缩后重试', type: 'error'}) commonDialog.alert({title: 'Error', content: '文件大小不能超过10MB请压缩后重试', type: 'error'})
} else { } else {
$scope.agreementFileProgress = {value: 0}; $scope.agreementFileProgress = {value: 0};
Upload.upload({ Upload.upload({

@ -261,7 +261,7 @@ $(function () {
}); });
$('#key_P').click(function () { $('#key_P').click(function () {
dataCache.remark = $('.remark-textarea').val(); dataCache.remark = $('.remark-textarea-new').val();
if (window.requireRemark) { if (window.requireRemark) {
if (!dataCache.remark) { if (!dataCache.remark) {
var config = { var config = {
@ -275,7 +275,7 @@ $(function () {
}); });
$('#key_P').bind('touchstart', function () { $('#key_P').bind('touchstart', function () {
dataCache.remark = $('.remark-textarea').val(); dataCache.remark = $('.remark-textarea-new').val();
if (window.requireRemark) { if (window.requireRemark) {
if (!dataCache.remark) { if (!dataCache.remark) {
return; return;

@ -1,21 +1,22 @@
.header-banner { .header-banner {
background:url(/static/images/pay_v4_banner.png) no-repeat; background: url(/static/images/pay_v4_banner.png) no-repeat;
background-size: 92% 100%; background-size: 92% 100%;
background-position: center; background-position: center;
box-shadow:0 0 10px #dddddd inset; box-shadow: 0 0 10px #dddddd inset;
} }
.merchant-title{ .merchant-title {
font-family: PingFang-SC-Medium; font-family: PingFang-SC-Medium;
font-size: 13px; font-size: 13px;
color: #FFFFFF; color: #FFFFFF;
letter-spacing: 0; letter-spacing: 0;
} }
.line{ .line {
margin-top: 15px; margin-top: 15px;
margin-bottom: 15px; margin-bottom: 15px;
} }
body { body {
-webkit-touch-callout: auto; -webkit-touch-callout: auto;
-webkit-user-select: auto; -webkit-user-select: auto;
@ -30,12 +31,14 @@ body {
div, span, p, ul, li { div, span, p, ul, li {
box-sizing: border-box; box-sizing: border-box;
} }
.warning-sm{
color:red; .warning-sm {
font-size:10px; color: red;
font-size: 10px;
transform-origin: left; transform-origin: left;
transform: scale(0.8); transform: scale(0.8);
} }
.weui_grid { .weui_grid {
padding: 7px; padding: 7px;
height: 53px; height: 53px;
@ -169,31 +172,33 @@ input.value:focus {
right: 0; right: 0;
bottom: 0; bottom: 0;
overflow-x: hidden; overflow-x: hidden;
background-color: #fbf9fe; background-color: #FFFFFF;
} }
.new_year { .new_year {
width:100%; width: 100%;
height:100%; height: 100%;
position:absolute; position: absolute;
top:18%; top: 18%;
left:0; left: 0;
z-index:-1; z-index: -1;
border-radius: 0 0 25px 25px; border-radius: 0 0 25px 25px;
} }
.bankpay { .bankpay {
text-align: center; text-align: center;
padding: 20px; padding: 20px;
color: #FFFFFF; color: #FFFFFF;
} }
@media screen and (max-height: 520px){ @media screen and (max-height: 520px) {
.bankpay { .bankpay {
text-align: center; text-align: center;
padding: 0; padding: 0;
color: #FFFFFF; color: #FFFFFF;
} }
} }
.row { .row {
width: 100%; width: 100%;
padding: 0 30px; padding: 0 30px;
@ -266,7 +271,7 @@ input.value:focus {
} }
@media screen and (max-height:670px){ @media screen and (max-height: 670px) {
.currencyrow { .currencyrow {
box-sizing: border-box; box-sizing: border-box;
margin-top: 0; margin-top: 0;
@ -275,7 +280,7 @@ input.value:focus {
} }
} }
@media screen and (max-height: 520px){ @media screen and (max-height: 520px) {
.currencyrow { .currencyrow {
box-sizing: border-box; box-sizing: border-box;
margin-top: 20px; margin-top: 20px;
@ -466,8 +471,9 @@ input.value:focus {
#coupon-box-toggle { #coupon-box-toggle {
padding: 0 20px; padding: 0 20px;
margin-bottom: 10px; margin-bottom: 10px;
margin-top: 15px;
text-align: right; text-align: right;
color: #30af69; color: #FF7E28;
font-size: 12px; font-size: 12px;
cursor: pointer; cursor: pointer;
} }
@ -492,7 +498,7 @@ input.value:focus {
display: none; display: none;
} }
.coupons-container.show{ .coupons-container.show {
display: block; display: block;
} }
@ -517,7 +523,7 @@ input.value:focus {
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
.coupons-container .coupon-box-title{ .coupons-container .coupon-box-title {
width: 100%; width: 100%;
display: block; display: block;
background: #fff; background: #fff;
@ -526,19 +532,19 @@ input.value:focus {
border-bottom: 1px solid #d0d0d0; border-bottom: 1px solid #d0d0d0;
} }
.coupons-container .coupon-box-title:after{ .coupons-container .coupon-box-title:after {
content: ''; content: '';
display: block; display: block;
clear: both; clear: both;
} }
.coupons-container .coupon-box-title>.title{ .coupons-container .coupon-box-title > .title {
float: left; float: left;
display: block; display: block;
color: #0BB20C; color: #FF7E28;
} }
.coupons-container .coupon-box-title>#close-coupon-box{ .coupons-container .coupon-box-title > #close-coupon-box {
color: #700; color: #700;
float: right; float: right;
display: block; display: block;
@ -546,12 +552,12 @@ input.value:focus {
} }
.actCharity-red{ .actCharity-red {
color: #FB5252; color: #FB5252;
display: inline; display: inline;
} }
.actCharity{ .actCharity {
display: inline; display: inline;
font-family: PingFang-SC-Medium; font-family: PingFang-SC-Medium;
font-size: 13px; font-size: 13px;
@ -571,12 +577,31 @@ input.value:focus {
-webkit-appearance: none; -webkit-appearance: none;
} }
.remark-textarea-new {
background-color: #FFFFFF;
box-shadow: none;
font-size: 13px;
width: calc(100% - 40px);
margin: 0 20px;
padding: 10px 0;
height: 18px;
border: 1px solid #FFFFFF;
border-radius: 0;
border-bottom-color: #BCBCBC;
-webkit-appearance: none;
}
.remark-textarea-new::-webkit-input-placeholder {
font-size: 13px;
color: #BCBCBC;
}
.remark-textarea::-webkit-input-placeholder { .remark-textarea::-webkit-input-placeholder {
font-size: 13px; font-size: 13px;
color: #BCBCBC; color: #BCBCBC;
} }
.paynow-button{ .paynow-button {
background: #19AD18; background: #19AD18;
border: 1px solid #179B16; border: 1px solid #179B16;
border-radius: 3px; border-radius: 3px;
@ -592,7 +617,7 @@ input.value:focus {
margin-top: 31px; margin-top: 31px;
} }
.bankpay-button{ .bankpay-button {
border: 1px solid #FF6600; border: 1px solid #FF6600;
border-radius: 3px; border-radius: 3px;
font-size: 16px; font-size: 16px;
@ -605,7 +630,7 @@ input.value:focus {
background-color: white; background-color: white;
} }
#coupon-box-toggle.canUse-coupon{ #coupon-box-toggle.canUse-coupon {
padding: 0 30px; padding: 0 30px;
margin-bottom: 10px; margin-bottom: 10px;
text-align: right; text-align: right;
@ -614,7 +639,8 @@ input.value:focus {
cursor: pointer; cursor: pointer;
margin: 11px; margin: 11px;
} }
input::-webkit-input-placeholder{
input::-webkit-input-placeholder {
font-size: 50px; font-size: 50px;
color: #FFFFFF; color: #FFFFFF;
line-height: 60px; line-height: 60px;
@ -628,8 +654,18 @@ input::-webkit-input-placeholder{
padding-top: 10px; padding-top: 10px;
} }
.merchant-div{ .merchant-div {
display: inline-block; display: inline-block;
padding-left: 10px; padding-left: 10px;
padding-top: 20px; padding-top: 20px;
} }
.advertisement {
display: flex;
justify-content: center;
margin-top: 10px;
}
.arrow-color {
color: #FF7E28;
}

@ -253,7 +253,7 @@ $(function () {
}); });
$('#key_P').click(function () { $('#key_P').click(function () {
dataCache.remark = $('.remark-textarea').val(); dataCache.remark = $('.remark-textarea-new').val();
if (window.requireRemark) { if (window.requireRemark) {
if (!dataCache.remark) { if (!dataCache.remark) {
var config = { var config = {
@ -267,7 +267,7 @@ $(function () {
}); });
$('#key_P').bind('touchstart', function () { $('#key_P').bind('touchstart', function () {
dataCache.remark = $('.remark-textarea').val(); dataCache.remark = $('.remark-textarea-new').val();
if (window.requireRemark) { if (window.requireRemark) {
if (!dataCache.remark) { if (!dataCache.remark) {
return; return;

@ -0,0 +1,28 @@
package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.analysis.core.BDAnalysisService;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.util.Date;
@SpringBootTest
@RunWith(SpringRunner.class)
public class DBAnalysisTaskTest {
@Resource
private BDAnalysisService bdAnalysisService;
@Test
public void test(){
for (int i = 1;i<=365;i++){
Date yesterday = DateUtils.addDays(new Date(), -i);
bdAnalysisService.generateReport(DateFormatUtils.format(yesterday, "yyyy-MM-dd"));
}
}
}
Loading…
Cancel
Save