add 代理商提成下载表格

master
luoyang 8 years ago
parent 13c2dce603
commit 25e27dfd4b

@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.citypartner.core;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
@ -43,6 +44,5 @@ public interface CityPartnerPrizeService {
JSONObject getSenior(String monthStr, String orgId); JSONObject getSenior(String monthStr, String orgId);
void exportMonthFiles(String monthStr, HttpServletResponse httpResponse) throws Exception;
} }

@ -31,6 +31,11 @@ import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -684,7 +689,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
} }
@Override @Override
@Transactional @Transactional
public void generateReferrer(String monthStr) { public void generateReferrer(String monthStr) {
@ -857,8 +861,6 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
// } // }
} }
@Override @Override
@ -1224,4 +1226,73 @@ public class CityPartnerPrizeServiceImpl implements CityPartnerPrizeService {
return financialSeniorPartnerCommissionMapper.find(year, month, orgId); return financialSeniorPartnerCommissionMapper.find(year, month, orgId);
} }
@Override
public void exportMonthFiles(String monthStr, HttpServletResponse resp) throws Exception {
OutputStream ous = null;
Date monthDate = parseMonth(monthStr);
Calendar monthCal = Calendar.getInstance();
monthCal.setTime(monthDate);
int year = monthCal.get(Calendar.YEAR);
int month = monthCal.get(Calendar.MONTH) + 1;
List<JSONObject> report = financialPartnerCommissionMapper.listWithOrgInfo(year, month);
if (report != null) {
resp.setContentType("application/octet-stream;");
resp.addHeader("Content-Disposition", "attachment; filename=" + "CityPartner_Commission_Info_" + monthStr + ".xls");
ous = resp.getOutputStream();
HSSFWorkbook wb = new HSSFWorkbook();
Cell cell = null;
HSSFFont font = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 10);
CellStyle titleStyle = wb.createCellStyle();
titleStyle.setFont(font);
HSSFCellStyle style = wb.createCellStyle();
style.setFillForegroundColor(HSSFColor.RED.index);
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
Sheet sheet = wb.createSheet("CityPartner_Commission_Info_" + month);
sheet.setDefaultColumnWidth(20);
int rowNum = 0;
Row row = sheet.createRow(rowNum);
String[] CommissionTitle = {"City Partner Name", "Transaction Amount", "Total Charge", "RoyalPay Charge", "Net Charge", "City Partner Charge", "Share Charge", "Type"};
for (int i = 0; i < CommissionTitle.length; i++) {
cell = row.createCell(i, Cell.CELL_TYPE_STRING);
cell.setCellStyle(titleStyle);
cell.setCellValue(CommissionTitle[i]);
}
for (JSONObject log : report) {
row = sheet.createRow(++rowNum);
StringBuffer name = new StringBuffer(log.getString("name"));
if (log.get("parent_org_id") == null) {
name.append("(一级代理)");
} else {
name.append("(二级代理)");
}
String type = "";
switch (log.getIntValue("commission_type")) {
case 1:
type = "渠道计算法";
break;
case 2:
type = "总交易额比例";
break;
case 3:
type = "收益比例";
break;
default:
break;
}
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(name.toString());
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("gross_amount") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("gross_amount").toPlainString());
row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("total_charge") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("total_charge").toPlainString());
row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("royalpay_charge") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("royalpay_charge").toPlainString());
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("net_charge") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("net_charge").toPlainString());
row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("org_charge") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("org_charge").toPlainString());
row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(log.getBigDecimal("share_charge") == null ? BigDecimal.ZERO.toPlainString() : log.getBigDecimal("share_charge").toPlainString());
row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(type);
}
wb.write(ous);
ous.flush();
}
}
} }

@ -20,6 +20,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
/** /**
* Created by yixian on 2017-03-08. * Created by yixian on 2017-03-08.
@ -42,6 +43,11 @@ public class CityPartnerPrizeController {
return cityPartnerPrizeService.listAvailableMonths(year); return cityPartnerPrizeService.listAvailableMonths(year);
} }
@RequestMapping(value = "/export/{monthStr}", method = RequestMethod.GET)
public void exportExcel(@PathVariable String monthStr,HttpServletResponse httpResponse) throws Exception {
cityPartnerPrizeService.exportMonthFiles(monthStr,httpResponse);
}
@RequestMapping(value = "/months/{monthStr}") @RequestMapping(value = "/months/{monthStr}")
public JSONObject getCityPartnersPrizeInfo(@PathVariable String monthStr) { public JSONObject getCityPartnersPrizeInfo(@PathVariable String monthStr) {
List<JSONObject> partnerPrizeInfos = cityPartnerPrizeService.getCityPartnerPrizeInfoList(monthStr); List<JSONObject> partnerPrizeInfos = cityPartnerPrizeService.getCityPartnerPrizeInfoList(monthStr);

@ -27,9 +27,13 @@
SELECT SELECT
sum(c.gross_amount) gross_amount, sum(c.total_charge) total_charge, sum(c.gross_amount) gross_amount, sum(c.total_charge) total_charge,
sum(c.royalpay_charge) royalpay_charge, sum(c.org_charge) org_charge, sum(c.royalpay_charge) royalpay_charge, sum(c.org_charge) org_charge,
sum(c.net_charge) net_charge,
sum(c.share_charge) share_charge,
c.commission_type,
o.parent_org_id,
o.name `name`, o.org_id org_id o.name `name`, o.org_id org_id
FROM financial_partner_commission c FROM financial_partner_commission c
INNER JOIN sys_org o ON o.org_id = c.org_id and o.type=0 INNER JOIN sys_org o ON o.org_id = c.org_id
WHERE c.year = #{year} AND c.month = #{month} WHERE c.year = #{year} AND c.month = #{month}
GROUP BY `name` GROUP BY `name`
</select> </select>

@ -24,6 +24,9 @@
<div class="box box-default"> <div class="box box-default">
<div class="box-header">Details</div> <div class="box-header">Details</div>
<div class="box-body table-responsive"> <div class="box-body table-responsive">
<div style="float:right"><a role="button" class="btn-group btn btn-warning" type="button" ng-href="/sys/citypartner_prizes/export/{{monthData.monthstr}}">
<i class="fa fa-download"></i>提成明细文件</a>
</div>
<table class="table table-bordered table-hover table-striped"> <table class="table table-bordered table-hover table-striped">
<thead> <thead>
<tr> <tr>

Loading…
Cancel
Save