|
|
@ -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,6 +37,9 @@ 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) {
|
|
|
@ -38,7 +48,7 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
|
|
|
|
|
|
|
|
|
|
|
|
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"))) {
|
|
|
@ -46,8 +56,31 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
@ -144,6 +177,44 @@ 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;
|
|
|
@ -294,8 +365,6 @@ 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);
|
|
|
@ -319,8 +388,7 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
|
|
|
|
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();
|
|
|
@ -359,8 +427,7 @@ public class BDAnalysisServiceImpl implements BDAnalysisService {
|
|
|
|
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();
|
|
|
|