记得上下班打卡 | git大法好,push需谨慎

Commit cfdf4132 authored by 姜秀龙's avatar 姜秀龙

Merge branch 'dev-ticket-data-V2' into 'master'

Dev ticket data v2

See merge request !395
parents b3ea589a 1a1448f6
...@@ -11,7 +11,9 @@ import com.liquidnet.client.admin.common.utils.poi.ExcelUtil; ...@@ -11,7 +11,9 @@ import com.liquidnet.client.admin.common.utils.poi.ExcelUtil;
import com.liquidnet.client.admin.zhengzai.kylin.dto.KylinPerformanceSubscribeTicketStatisticalExportDao; import com.liquidnet.client.admin.zhengzai.kylin.dto.KylinPerformanceSubscribeTicketStatisticalExportDao;
import com.liquidnet.client.admin.zhengzai.kylin.dto.PerformanceOrderStatisCountResp; import com.liquidnet.client.admin.zhengzai.kylin.dto.PerformanceOrderStatisCountResp;
import com.liquidnet.client.admin.zhengzai.kylin.dto.PerformanceTicketSalesDto; import com.liquidnet.client.admin.zhengzai.kylin.dto.PerformanceTicketSalesDto;
import com.liquidnet.client.admin.zhengzai.kylin.dto.PerformanceTicketSumDto;
import com.liquidnet.client.admin.zhengzai.kylin.service.IOpenDataService; import com.liquidnet.client.admin.zhengzai.kylin.service.IOpenDataService;
import com.liquidnet.client.admin.zhengzai.kylin.utils.DataSumUtils;
import com.liquidnet.commons.lang.util.JsonUtils; import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.kylin.dao.PerformanceAdminListDao; import com.liquidnet.service.kylin.dao.PerformanceAdminListDao;
...@@ -28,12 +30,19 @@ import com.liquidnet.service.kylin.entity.KylinOrderImport; ...@@ -28,12 +30,19 @@ import com.liquidnet.service.kylin.entity.KylinOrderImport;
import com.liquidnet.service.kylin.service.admin.IKylinPerformancesAdminService; import com.liquidnet.service.kylin.service.admin.IKylinPerformancesAdminService;
import com.liquidnet.service.kylin.service.other.DamaiService; import com.liquidnet.service.kylin.service.other.DamaiService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -182,6 +191,7 @@ public class KylinPerformancesController extends BaseController { ...@@ -182,6 +191,7 @@ public class KylinPerformancesController extends BaseController {
statisticalDao.setHandlingFeeRefundTicketTotal(ticketSales.getHandlingFeeRefundTicketTotal()); statisticalDao.setHandlingFeeRefundTicketTotal(ticketSales.getHandlingFeeRefundTicketTotal());
statisticalDao.setRefundFeeRevenueTotal(new BigDecimal(ticketSales.getRefundFeeRevenueTotal())); statisticalDao.setRefundFeeRevenueTotal(new BigDecimal(ticketSales.getRefundFeeRevenueTotal()));
statisticalDao.setAudienceSalesAmountTotal(new BigDecimal(ticketSales.getAudienceSalesAmountTotal())); statisticalDao.setAudienceSalesAmountTotal(new BigDecimal(ticketSales.getAudienceSalesAmountTotal()));
statisticalDao.setSurplusGeneral(new BigDecimal(ticketSales.getSurplusGeneral()));
result.add(statisticalDao); result.add(statisticalDao);
} }
} }
...@@ -206,6 +216,7 @@ public class KylinPerformancesController extends BaseController { ...@@ -206,6 +216,7 @@ public class KylinPerformancesController extends BaseController {
mmap.put("perCountResp", perCountResp); mmap.put("perCountResp", perCountResp);
mmap.put("perOrderStaticList", result); mmap.put("perOrderStaticList", result);
mmap.put("sumResp", DataSumUtils.sumStatistics(result));
return prefix + "/performancesStatic"; return prefix + "/performancesStatic";
} }
...@@ -411,4 +422,111 @@ public class KylinPerformancesController extends BaseController { ...@@ -411,4 +422,111 @@ public class KylinPerformancesController extends BaseController {
List<KylinPerformancesVo> kylinPerformancesVoList = kylinPerformancesService.searchPerformanceByTitle(title); List<KylinPerformancesVo> kylinPerformancesVoList = kylinPerformancesService.searchPerformanceByTitle(title);
return ResponseDto.success(kylinPerformancesVoList); return ResponseDto.success(kylinPerformancesVoList);
} }
@GetMapping("/performance/export")
public void exportPerformance(@RequestParam(value = "performanceId") String performanceId, HttpServletResponse response) {
try {
PerformanceOrderStatisCountResp perCountResp = new PerformanceOrderStatisCountResp();
List<PerformanceOrderStatisticalDao> result = new ArrayList<>();
PerformanceTicketSalesDto ticketSalesInfo = openDataService.getPerformanceTicketSalesInfo(performanceId);
if (ticketSalesInfo != null) {
perCountResp.setPerformanceTitle(ticketSalesInfo.getPerformanceTitle());
perCountResp.setTotalSalePrice(new BigDecimal(ticketSalesInfo.getFullSalesAmountTotal()));
perCountResp.setSaleGeneral(new BigDecimal(ticketSalesInfo.getFullAudienceTicketTotal()));
perCountResp.setTotalGeneral(new BigDecimal(ticketSalesInfo.getFullTotalGeneral()));
perCountResp.setTotalRefundGeneral(new BigDecimal(ticketSalesInfo.getFullRefundTicketTotal()));
perCountResp.setTotalBuyUsers(new BigDecimal(ticketSalesInfo.getFullBuyTotal()));
List<PerformanceTicketSalesDto.TicketSales> fullTicketDataList = ticketSalesInfo.getFullTicketDataList();
if (!fullTicketDataList.isEmpty()) {
for (PerformanceTicketSalesDto.TicketSales ticketSales : fullTicketDataList) {
PerformanceOrderStatisticalDao statisticalDao = new PerformanceOrderStatisticalDao();
statisticalDao.setPerformancesId(ticketSalesInfo.getPerformanceId());
statisticalDao.setTicketsId(ticketSales.getTicketId());
statisticalDao.setTitle(ticketSales.getTicketTitle());
statisticalDao.setPrice(new BigDecimal(ticketSales.getTicketPrice()));
statisticalDao.setType(ticketSales.getTicketType());
statisticalDao.setTotalGeneral(new BigDecimal(ticketSales.getTotalGeneral()));
statisticalDao.setSaleGeneral(new BigDecimal(ticketSales.getAudienceTicketTotal()));
statisticalDao.setTotalRefundGeneral(new BigDecimal(ticketSales.getRefundTicketTotal()));
statisticalDao.setTotalPayingNumber(new BigDecimal(ticketSales.getPayingTotal()));
statisticalDao.setTimeId(ticketSales.getTimeId());
statisticalDao.setTimeTitle(ticketSales.getTimeTitle());
statisticalDao.setVipBuyTotal(ticketSales.getVipBuyTotal());
statisticalDao.setFullRefundTicketTotal(ticketSales.getFullRefundTicketTotal());
statisticalDao.setHandlingFeeRefundTicketTotal(ticketSales.getHandlingFeeRefundTicketTotal());
statisticalDao.setRefundFeeRevenueTotal(new BigDecimal(ticketSales.getRefundFeeRevenueTotal()));
statisticalDao.setAudienceSalesAmountTotal(new BigDecimal(ticketSales.getAudienceSalesAmountTotal()));
statisticalDao.setSurplusGeneral(new BigDecimal(ticketSales.getSurplusGeneral()));
result.add(statisticalDao);
}
}
}
// 汇总数据
PerformanceTicketSumDto sumResp = DataSumUtils.sumStatistics(result);
// 创建 Excel
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("演出数据");
// 表头
String[] headers = {
"场次", "票种类型", "票种名称", "票种价格", "库存数量", "销售数量", "余票数量",
"登登登VIP购票数量", "正在支付数量", "退票总数量", "全额退票数量",
"手续费退票数量", "退票手续费收益", "票面销售金额"
};
XSSFRow headerRow = sheet.createRow(0);
for (int i = 0; i < headers.length; i++) {
headerRow.createCell(i).setCellValue(headers[i]);
}
// 数据行
int rowNum = 1;
for (PerformanceOrderStatisticalDao item : result) {
XSSFRow row = sheet.createRow(rowNum++);
row.createCell(0).setCellValue(item.getTimeTitle());
row.createCell(1).setCellValue(item.getType().equals(1) ? "单日票" : "通票"); // 记得在后端先做字典翻译
row.createCell(2).setCellValue(item.getTitle());
row.createCell(3).setCellValue(item.getPrice().toPlainString());
row.createCell(4).setCellValue(item.getTotalGeneral().toPlainString());
row.createCell(5).setCellValue(item.getSaleGeneral().toPlainString());
row.createCell(6).setCellValue(item.getSurplusGeneral().toPlainString());
row.createCell(7).setCellValue(item.getVipBuyTotal());
row.createCell(8).setCellValue(item.getTotalPayingNumber().toPlainString());
row.createCell(9).setCellValue(item.getTotalRefundGeneral().toPlainString());
row.createCell(10).setCellValue(item.getFullRefundTicketTotal());
row.createCell(11).setCellValue(item.getHandlingFeeRefundTicketTotal());
row.createCell(12).setCellValue(item.getRefundFeeRevenueTotal().toPlainString());
row.createCell(13).setCellValue(item.getAudienceSalesAmountTotal().toPlainString());
}
// 合计行
XSSFRow totalRow = sheet.createRow(rowNum);
totalRow.createCell(0).setCellValue("总计");
totalRow.createCell(4).setCellValue(sumResp.getTotalGeneralSum().toPlainString());
totalRow.createCell(5).setCellValue(sumResp.getSaleGeneralSum().toPlainString());
totalRow.createCell(6).setCellValue(sumResp.getSurplusGeneralSum().toPlainString());
totalRow.createCell(7).setCellValue(sumResp.getVipBuyTotalSum().toPlainString());
totalRow.createCell(8).setCellValue(sumResp.getTotalPayingNumberSum().toPlainString());
totalRow.createCell(9).setCellValue(sumResp.getTotalRefundGeneralSum().toPlainString());
totalRow.createCell(10).setCellValue(sumResp.getFullRefundTicketTotalSum().toPlainString());
totalRow.createCell(11).setCellValue(sumResp.getHandlingFeeRefundTicketTotalSum().toPlainString());
totalRow.createCell(12).setCellValue(sumResp.getRefundFeeRevenueTotalSum().toPlainString());
totalRow.createCell(13).setCellValue(sumResp.getAudienceSalesAmountTotalSum().toPlainString());
// 响应头
String fileName = URLEncoder.encode("演出统计数据.xlsx", StandardCharsets.UTF_8.name());
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
// 写出文件
workbook.write(response.getOutputStream());
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
...@@ -47,6 +47,10 @@ ...@@ -47,6 +47,10 @@
<div class="tab-content"> <div class="tab-content">
<div id="tab-1" class="tab-pane"> <div id="tab-1" class="tab-pane">
<div class="panel-body"> <div class="panel-body">
<!-- 导出按钮 -->
<div class="m-t-md" style="text-align: left; margin-bottom: 2px">
<button type="button" class="btn btn-primary" onclick="exportTableData()">导出数据</button>
</div>
<div id="tab-1" class="tab-pane"> <div id="tab-1" class="tab-pane">
<iframe id="tab_iframe_1" name="tab_iframe_1" marginwidth=0 marginheight=0 width=100% <iframe id="tab_iframe_1" name="tab_iframe_1" marginwidth=0 marginheight=0 width=100%
height=800px frameborder=0></iframe> height=800px frameborder=0></iframe>
...@@ -575,6 +579,15 @@ ...@@ -575,6 +579,15 @@
anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数) anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机(请注意,3.0之前的版本用shift参数)
}); });
} }
/**
* 导出文件
*/
function exportTableData() {
var performancesId = '[[${kylinPerformanceMisVo.performancesId}]]'.replaceAll("\"", "")
var url = prefix + '/performance/export?performanceId=' + performancesId;
window.location.href = url; // 直接触发下载
}
</script> </script>
</body> </body>
</html> </html>
...@@ -88,6 +88,9 @@ ...@@ -88,6 +88,9 @@
<th> <th>
<div class="cell">销售数量</div> <div class="cell">销售数量</div>
</th> </th>
<th>
<div class="cell">余票数量</div>
</th>
<th> <th>
<div class="cell">登登登VIP购票数量</div> <div class="cell">登登登VIP购票数量</div>
</th> </th>
...@@ -131,6 +134,9 @@ ...@@ -131,6 +134,9 @@
<td> <td>
<div class="cell" th:text="${respBean.saleGeneral}">0</div> <div class="cell" th:text="${respBean.saleGeneral}">0</div>
</td> </td>
<td>
<div class="cell" th:text="${respBean.surplusGeneral}">0</div>
</td>
<td> <td>
<div class="cell" th:text="${respBean.vipBuyTotal}">0</div> <div class="cell" th:text="${respBean.vipBuyTotal}">0</div>
</td> </td>
...@@ -157,6 +163,24 @@ ...@@ -157,6 +163,24 @@
<!-- </td>--> <!-- </td>-->
</tr> </tr>
</tbody> </tbody>
<tfoot>
<tr th:object="${sumResp}">
<td><div class="cell">总计</div></td>
<td><div class="cell"></div></td>
<td><div class="cell"></div></td>
<td><div class="cell"></div></td>
<td><div class="cell" th:text="*{totalGeneralSum}">0</div></td>
<td><div class="cell" th:text="*{saleGeneralSum}">0</div></td>
<td><div class="cell" th:text="*{surplusGeneralSum}">0</div></td>
<td><div class="cell" th:text="*{vipBuyTotalSum}">0</div></td>
<td><div class="cell" th:text="*{totalPayingNumberSum}">0</div></td>
<td><div class="cell" th:text="*{totalRefundGeneralSum}">0</div></td>
<td><div class="cell" th:text="*{fullRefundTicketTotalSum}">0</div></td>
<td><div class="cell" th:text="*{handlingFeeRefundTicketTotalSum}">0</div></td>
<td><div class="cell" th:text="*{refundFeeRevenueTotalSum}">0</div></td>
<td><div class="cell" th:text="*{audienceSalesAmountTotalSum}">0</div></td>
</tr>
</tfoot>
</table> </table>
<div style="display: none;"> <div style="display: none;">
<button type="button" class="el-button main el-button--primary el-button--medium"><!----> <button type="button" class="el-button main el-button--primary el-button--medium"><!---->
......
...@@ -97,5 +97,8 @@ public class PerformanceTicketSalesDto { ...@@ -97,5 +97,8 @@ public class PerformanceTicketSalesDto {
// 正在支付数量 // 正在支付数量
private String payingTotal; private String payingTotal;
// 剩余库存
private String surplusGeneral;
} }
} }
package com.liquidnet.client.admin.zhengzai.kylin.dto;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class PerformanceTicketSumDto {
// 库存数量
private BigDecimal totalGeneralSum = BigDecimal.ZERO;
// 销售数量
private BigDecimal saleGeneralSum = BigDecimal.ZERO;
// 余票数量
private BigDecimal surplusGeneralSum = BigDecimal.ZERO;
//VIP购票数量
private BigDecimal vipBuyTotalSum = BigDecimal.ZERO;
//正在支付数量
private BigDecimal totalPayingNumberSum = BigDecimal.ZERO;
//退票总数量
private BigDecimal totalRefundGeneralSum = BigDecimal.ZERO;
//全额退票数量
private BigDecimal fullRefundTicketTotalSum = BigDecimal.ZERO;
//手续费退票数量
private BigDecimal handlingFeeRefundTicketTotalSum = BigDecimal.ZERO;
//退票手续费收益
private BigDecimal refundFeeRevenueTotalSum = BigDecimal.ZERO;
//票面销售金额
private BigDecimal audienceSalesAmountTotalSum = BigDecimal.ZERO;
}
package com.liquidnet.client.admin.zhengzai.kylin.utils;
import com.liquidnet.client.admin.zhengzai.kylin.dto.PerformanceTicketSumDto;
import com.liquidnet.service.kylin.dao.PerformanceOrderStatisticalDao;
import java.math.BigDecimal;
import java.util.List;
public class DataSumUtils {
public static PerformanceTicketSumDto sumStatistics(List<PerformanceOrderStatisticalDao> list) {
// 初始化所有需要统计的字段(BigDecimal类型)
BigDecimal totalGeneralSum = BigDecimal.ZERO;
BigDecimal saleGeneralSum = BigDecimal.ZERO;
BigDecimal surplusGeneralSum = BigDecimal.ZERO;
BigDecimal vipBuyTotalSum = BigDecimal.ZERO;
BigDecimal totalPayingNumberSum = BigDecimal.ZERO;
BigDecimal totalRefundGeneralSum = BigDecimal.ZERO;
BigDecimal fullRefundTicketTotalSum = BigDecimal.ZERO;
BigDecimal handlingFeeRefundTicketTotalSum = BigDecimal.ZERO;
BigDecimal refundFeeRevenueTotalSum = BigDecimal.ZERO;
BigDecimal audienceSalesAmountTotalSum = BigDecimal.ZERO;
// 遍历列表进行累加
for (PerformanceOrderStatisticalDao item : list) {
// BigDecimal类型字段
totalGeneralSum = safeAdd(totalGeneralSum, item.getTotalGeneral());
saleGeneralSum = safeAdd(saleGeneralSum, item.getSaleGeneral());
surplusGeneralSum = safeAdd(surplusGeneralSum, item.getSurplusGeneral());
totalPayingNumberSum = safeAdd(totalPayingNumberSum, item.getTotalPayingNumber());
totalRefundGeneralSum = safeAdd(totalRefundGeneralSum, item.getTotalRefundGeneral());
refundFeeRevenueTotalSum = safeAdd(refundFeeRevenueTotalSum, item.getRefundFeeRevenueTotal());
audienceSalesAmountTotalSum = safeAdd(audienceSalesAmountTotalSum, item.getAudienceSalesAmountTotal());
// Integer类型字段转换
vipBuyTotalSum = safeAdd(vipBuyTotalSum, BigDecimal.valueOf(item.getVipBuyTotal()));
fullRefundTicketTotalSum = safeAdd(fullRefundTicketTotalSum, BigDecimal.valueOf(item.getFullRefundTicketTotal()));
handlingFeeRefundTicketTotalSum = safeAdd(handlingFeeRefundTicketTotalSum,
BigDecimal.valueOf(item.getHandlingFeeRefundTicketTotal()));
}
PerformanceTicketSumDto sumDto = new PerformanceTicketSumDto();
sumDto.setTotalGeneralSum(totalGeneralSum); // 库存数量
sumDto.setSaleGeneralSum(saleGeneralSum); // 销售数量
sumDto.setSurplusGeneralSum(surplusGeneralSum); // 余票数量
sumDto.setVipBuyTotalSum(vipBuyTotalSum);//VIP购票数量
sumDto.setTotalPayingNumberSum(totalPayingNumberSum);//正在支付数量
sumDto.setTotalRefundGeneralSum(totalRefundGeneralSum);//退票总数量
sumDto.setFullRefundTicketTotalSum(fullRefundTicketTotalSum);//全额退票数量
sumDto.setHandlingFeeRefundTicketTotalSum(handlingFeeRefundTicketTotalSum);//手续费退票数量
sumDto.setRefundFeeRevenueTotalSum(refundFeeRevenueTotalSum);//退票手续费收益
sumDto.setAudienceSalesAmountTotalSum(audienceSalesAmountTotalSum);//票面销售金额
return sumDto;
}
// 安全的BigDecimal加法(处理null值)
private static BigDecimal safeAdd(BigDecimal sum, BigDecimal value) {
if (value == null) {
return sum;
}
return sum.add(value);
}
}
...@@ -24,7 +24,7 @@ public class PerformanceOrderStatisticalDao implements Cloneable{ ...@@ -24,7 +24,7 @@ public class PerformanceOrderStatisticalDao implements Cloneable{
private String useEnd; private String useEnd;
private BigDecimal totalGeneral = BigDecimal.ZERO;// 库存数量 private BigDecimal totalGeneral = BigDecimal.ZERO;// 库存数量
private BigDecimal saleGeneral = BigDecimal.ZERO;// 销售数量 private BigDecimal saleGeneral = BigDecimal.ZERO;// 销售数量
private BigDecimal surplusGeneral = BigDecimal.ZERO; private BigDecimal surplusGeneral = BigDecimal.ZERO; // 余票数量
private BigDecimal totalSalePrice = BigDecimal.ZERO; private BigDecimal totalSalePrice = BigDecimal.ZERO;
private BigDecimal totalExchange = BigDecimal.ZERO; private BigDecimal totalExchange = BigDecimal.ZERO;
private BigDecimal totalRefundGeneral = BigDecimal.ZERO; // 退票总数量 private BigDecimal totalRefundGeneral = BigDecimal.ZERO; // 退票总数量
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment