Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
*/
|
||||
public class ExcelMergeHandler implements CellWriteHandler {
|
||||
// 要合并的列索引数组
|
||||
private int[] mergeColumnIndex = {0, 1, 2, 9, 10};
|
||||
private int[] mergeColumnIndex = {0, 1, 2, 8, 9};
|
||||
// 合并开始的行索引
|
||||
private int mergeRowIndex = 1;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.List;
|
||||
*/
|
||||
public class TableRefundCellHandel implements CellWriteHandler {
|
||||
// 要处理的列索引数组
|
||||
private int[] yellowColumnIndex = {11, 12};
|
||||
private int[] yellowColumnIndex = {10, 11};
|
||||
|
||||
public TableRefundCellHandel() {
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@ import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 台桌统计明细
|
||||
*
|
||||
* 台桌统计明细 *
|
||||
* @author tankaikai
|
||||
* @since 2025-03-07 16:22
|
||||
*/
|
||||
@@ -31,10 +30,12 @@ public class TableSummaryExportVo implements Serializable {
|
||||
@JSONField(serialize = false)
|
||||
private Long lineNum;
|
||||
/**
|
||||
* 台桌+日期
|
||||
* 台桌Code_日期
|
||||
*/
|
||||
@ExcelIgnore
|
||||
private String tableConcatDate;
|
||||
@ExcelIgnore
|
||||
private String tableCode;
|
||||
/**
|
||||
* 台桌
|
||||
*/
|
||||
@@ -53,6 +54,8 @@ public class TableSummaryExportVo implements Serializable {
|
||||
@ExcelProperty("商品分类")
|
||||
@ColumnWidth(15)
|
||||
private String categoryName;
|
||||
@ExcelIgnore
|
||||
private Long productId;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@@ -80,26 +83,26 @@ public class TableSummaryExportVo implements Serializable {
|
||||
/**
|
||||
* 单价
|
||||
*/
|
||||
@ExcelProperty("单价")
|
||||
@ColumnWidth(10)
|
||||
private BigDecimal unitPrice;
|
||||
// @ExcelProperty("单价")
|
||||
// @ColumnWidth(10)
|
||||
// private BigDecimal unitPrice;
|
||||
/**
|
||||
* 金额
|
||||
*/
|
||||
@ExcelProperty("金额")
|
||||
@ExcelProperty("销售额")
|
||||
@ColumnWidth(10)
|
||||
private BigDecimal amount;
|
||||
/**
|
||||
* 销售额
|
||||
*/
|
||||
@ExcelProperty("销售额")
|
||||
@ColumnWidth(10)
|
||||
@ExcelProperty("总销售额")
|
||||
@ColumnWidth(12)
|
||||
private BigDecimal salesAmount;
|
||||
/**
|
||||
* 总销售额
|
||||
*/
|
||||
@ExcelProperty("总销售额")
|
||||
@ColumnWidth(15)
|
||||
@ExcelProperty("当日总销售额")
|
||||
@ColumnWidth(16)
|
||||
private BigDecimal totalSalesAmount;
|
||||
/**
|
||||
* 退单量
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.springframework.stereotype.Service;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -51,7 +50,41 @@ public class TableSummaryServiceImpl implements TableSummaryService {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return List.of();
|
||||
}
|
||||
record TableSummary(String tableKey, BigDecimal totalSales, Map<Long, BigDecimal> productSales) {}
|
||||
|
||||
Map<String, TableSummary> summaryMap = list.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
vo -> vo.getTableCode() + "_" + vo.getCreateDate(),
|
||||
Collectors.collectingAndThen(
|
||||
Collectors.toList(),
|
||||
vos -> {
|
||||
String tableKey = vos.getFirst().getTableCode() + "_" + vos.getFirst().getCreateDate();
|
||||
BigDecimal totalSales = vos.stream()
|
||||
.map(TableSummaryExportVo::getAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
Map<Long, BigDecimal> productSales = vos.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
TableSummaryExportVo::getProductId,
|
||||
Collectors.reducing(
|
||||
BigDecimal.ZERO,
|
||||
TableSummaryExportVo::getAmount,
|
||||
BigDecimal::add
|
||||
)
|
||||
));
|
||||
|
||||
return new TableSummary(tableKey, totalSales, productSales);
|
||||
}
|
||||
)
|
||||
));
|
||||
|
||||
list.forEach(vo -> {
|
||||
TableSummary summary = summaryMap.get(vo.getTableConcatDate());
|
||||
if (summary != null) {
|
||||
vo.setTotalSalesAmount(summary.totalSales());
|
||||
vo.setSalesAmount(summary.productSales().getOrDefault(vo.getProductId(), BigDecimal.ZERO));
|
||||
}
|
||||
});
|
||||
// 追加个空行用于处理表格样式
|
||||
TableSummaryExportVo nullVo = new TableSummaryExportVo();
|
||||
list.add(nullVo);
|
||||
|
||||
@@ -6,17 +6,19 @@
|
||||
|
||||
<select id="findSummaryExportList" resultType="com.czg.order.vo.TableSummaryExportVo">
|
||||
SELECT `order`.table_code,
|
||||
`order`.trade_day as create_date,
|
||||
`order`.trade_day as create_date,
|
||||
concat(`order`.table_code, '_', `order`.trade_day) as tableConcatDate,
|
||||
IF(`order`.table_code IS NULL OR `order`.table_code = '' OR `table`.NAME IS NULL, '吧台',
|
||||
`table`.NAME) AS table_name,
|
||||
category.`name` AS category_name,
|
||||
product.`name` AS product_name,
|
||||
unit.`name` AS unit_name,
|
||||
`table`.NAME) AS table_name,
|
||||
category.`name` AS category_name,
|
||||
product.`name` AS product_name,
|
||||
product.`id` AS product_id,
|
||||
unit.`name` AS unit_name,
|
||||
detail.sku_name,
|
||||
sum(detail.num - detail.return_num) AS num,
|
||||
sum(detail.pay_amount) AS salesAmount,
|
||||
sum(detail.refund_num) AS refund_num,
|
||||
sum(detail.return_amount) AS refund_amount
|
||||
sum(detail.num - detail.return_num) AS num,
|
||||
sum(detail.pay_amount) AS amount,
|
||||
sum(detail.refund_num) AS refund_num,
|
||||
sum(detail.return_amount) AS refund_amount
|
||||
FROM tb_order_info `order`
|
||||
INNER JOIN tb_order_detail detail ON detail.order_id = `order`.id
|
||||
AND detail.is_temporary = 0
|
||||
@@ -31,6 +33,6 @@
|
||||
AND `order`.pay_mode != 'no-table'
|
||||
AND `order`.trade_day >= #{beginDate}
|
||||
AND `order`.trade_day <= #{endDate}
|
||||
group by `order`.trade_day, `order`.table_code, detail.product_id
|
||||
group by `order`.trade_day, `order`.table_code, detail.product_id, detail.sku_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user