Merge branch 'master' into prod
This commit is contained in:
commit
3cbab6c603
|
|
@ -1,7 +1,7 @@
|
|||
server:
|
||||
port: 9100
|
||||
# servlet:
|
||||
# context-path: /admin
|
||||
servlet:
|
||||
context-path: /account
|
||||
|
||||
spring:
|
||||
application:
|
||||
|
|
|
|||
|
|
@ -2,17 +2,17 @@ package com.czg.controller;
|
|||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.CzgPayUtils;
|
||||
import com.czg.account.service.MemberPointsService;
|
||||
import com.czg.entity.CzgBaseRespParams;
|
||||
import com.czg.mq.PrintMqListener;
|
||||
import com.czg.order.service.OrderInfoService;
|
||||
import com.czg.order.service.ShopOrderStatisticService;
|
||||
import com.czg.task.StatisticTask;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
|
|
@ -30,18 +30,26 @@ public class NotifyController {
|
|||
@Resource
|
||||
private StatisticTask statisticTask;
|
||||
|
||||
@DubboReference
|
||||
private MemberPointsService pointsService;
|
||||
|
||||
@RequestMapping("/payCallBack")
|
||||
public String notifyCallBack(@RequestBody CzgBaseRespParams respParams){
|
||||
JSONObject czg = CzgPayUtils.getCzg(respParams);
|
||||
AssertUtil.isNull(czg, "支付回调数据为空");
|
||||
log.info("支付回调数据为:{}", czg);
|
||||
orderInfoService.payCallBackOrder(czg.getString("mchOrderNo"), czg);
|
||||
@Resource
|
||||
private ShopOrderStatisticService shopOrderStatisticService;
|
||||
|
||||
|
||||
@GetMapping("/payCallBack")
|
||||
public String notifyCallBack() {
|
||||
|
||||
shopOrderStatisticService.statistic();
|
||||
//JSONObject czg = CzgPayUtils.getCzg(respParams);
|
||||
//AssertUtil.isNull(czg, "支付回调数据为空");
|
||||
//log.info("支付回调数据为:{}", czg);
|
||||
//orderInfoService.payCallBackOrder(czg.getString("mchOrderNo"), czg);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@RequestMapping("/refundCallBack")
|
||||
public String refundCallBack(@RequestBody CzgBaseRespParams respParams){
|
||||
public String refundCallBack(@RequestBody CzgBaseRespParams respParams) {
|
||||
JSONObject czg = CzgPayUtils.getCzg(respParams);
|
||||
AssertUtil.isNull(czg, "退款回调数据为空");
|
||||
log.info("退款回调数据为:{}", czg);
|
||||
|
|
@ -51,6 +59,7 @@ public class NotifyController {
|
|||
|
||||
@Resource
|
||||
private PrintMqListener printMqListener;
|
||||
|
||||
@RequestMapping("/test")
|
||||
public void test(@RequestParam String id) {
|
||||
printMqListener.orderPrint(id);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.handel.ExcelMergeHandler;
|
||||
import com.czg.handel.TableRefundCellHandel;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.order.param.TableSummaryParam;
|
||||
import com.czg.order.service.TableSummaryService;
|
||||
import com.czg.order.vo.TableSummaryExportVo;
|
||||
import com.czg.order.vo.TableSummaryInfoVo;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
|
|
@ -42,14 +45,14 @@ public class TableSummaryController {
|
|||
/**
|
||||
* 导出
|
||||
*/
|
||||
@ResponseExcel(name = "台桌统计")
|
||||
@ResponseExcel(name = "台桌统计", writeHandler = {ExcelMergeHandler.class, TableRefundCellHandel.class})
|
||||
@GetMapping("export")
|
||||
@OperationLog("导出")
|
||||
//@SaAdminCheckPermission("tableSummary:export")
|
||||
public List<TableSummaryInfoVo> summaryExport(TableSummaryParam param) {
|
||||
public List<TableSummaryExportVo> summaryExport(TableSummaryParam param) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
param.setShopId(shopId);
|
||||
return tableSummaryService.summaryList(param);
|
||||
return tableSummaryService.summaryExportList(param);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,151 @@
|
|||
package com.czg.handel;
|
||||
|
||||
import cn.idev.excel.metadata.Head;
|
||||
import cn.idev.excel.metadata.data.WriteCellData;
|
||||
import cn.idev.excel.write.handler.CellWriteHandler;
|
||||
import cn.idev.excel.write.metadata.holder.WriteSheetHolder;
|
||||
import cn.idev.excel.write.metadata.holder.WriteTableHolder;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author tankaikai
|
||||
* @since 2025-04-01 18:41
|
||||
*/
|
||||
public class ExcelMergeHandler implements CellWriteHandler {
|
||||
// 要合并的列索引数组
|
||||
private int[] mergeColumnIndex = {0, 1, 2, 9, 10};
|
||||
// 合并开始的行索引
|
||||
private int mergeRowIndex = 1;
|
||||
|
||||
public ExcelMergeHandler() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*
|
||||
* @param mergeRowIndex 合并开始的行索引
|
||||
* @param mergeColumnIndex 要合并的列索引数组
|
||||
*/
|
||||
public ExcelMergeHandler(int mergeRowIndex, int[] mergeColumnIndex) {
|
||||
this.mergeRowIndex = mergeRowIndex;
|
||||
this.mergeColumnIndex = mergeColumnIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
|
||||
// 当前行索引
|
||||
int curRowIndex = cell.getRowIndex();
|
||||
// 当前列索引
|
||||
int curColIndex = cell.getColumnIndex();
|
||||
|
||||
// 如果当前行大于合并开始行且当前列在需要合并的列中
|
||||
if (curRowIndex > mergeRowIndex && isMergeColumn(curColIndex)) {
|
||||
// 进行合并操作
|
||||
mergeWithPrevRow(writeSheetHolder, cell, curRowIndex, curColIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查当前列是否在需要合并的列中
|
||||
*
|
||||
* @param curColIndex 当前列索引
|
||||
* @return 如果是需要合并的列返回true,否则返回false
|
||||
*/
|
||||
private boolean isMergeColumn(int curColIndex) {
|
||||
for (int columnIndex : mergeColumnIndex) {
|
||||
if (curColIndex == columnIndex) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前单元格向上合并
|
||||
*
|
||||
* @param writeSheetHolder 当前工作表持有者
|
||||
* @param cell 当前单元格
|
||||
* @param curRowIndex 当前行索引
|
||||
* @param curColIndex 当前列索引
|
||||
*/
|
||||
private void mergeWithPrevRow(WriteSheetHolder writeSheetHolder, Cell cell, int curRowIndex, int curColIndex) {
|
||||
// 获取当前单元格的数据
|
||||
Object curData = getCellData(cell);
|
||||
// 获取前一个单元格的数据
|
||||
Cell preCell = cell.getSheet().getRow(curRowIndex - 1).getCell(curColIndex);
|
||||
Object preData = getCellData(preCell);
|
||||
|
||||
// 判断当前单元格和前一个单元格的数据以及主键是否相同
|
||||
if (curData.equals(preData) && isSamePrimaryKey(cell, curRowIndex)) {
|
||||
// 获取工作表
|
||||
Sheet sheet = writeSheetHolder.getSheet();
|
||||
// 合并单元格
|
||||
mergeCells(sheet, curRowIndex, curColIndex);
|
||||
CellStyle style = preCell.getCellStyle();
|
||||
// 设置水平居中
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
// 设置垂直居中
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
preCell.setCellStyle(style);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单元格的数据
|
||||
*
|
||||
* @param cell 单元格
|
||||
* @return 单元格数据
|
||||
*/
|
||||
private Object getCellData(Cell cell) {
|
||||
return cell.getCellType() == CellType.STRING ? cell.getStringCellValue() : cell.getNumericCellValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前单元格和前一个单元格的主键是否相同
|
||||
*
|
||||
* @param cell 当前单元格
|
||||
* @param curRowIndex 当前行索引
|
||||
* @return 如果主键相同返回true,否则返回false
|
||||
*/
|
||||
private boolean isSamePrimaryKey(Cell cell, int curRowIndex) {
|
||||
String currentPrimaryKey = cell.getRow().getCell(0).getStringCellValue();
|
||||
String previousPrimaryKey = cell.getSheet().getRow(curRowIndex - 1).getCell(0).getStringCellValue();
|
||||
return currentPrimaryKey.equals(previousPrimaryKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并单元格
|
||||
*
|
||||
* @param sheet 工作表
|
||||
* @param curRowIndex 当前行索引
|
||||
* @param curColIndex 当前列索引
|
||||
*/
|
||||
private void mergeCells(Sheet sheet, int curRowIndex, int curColIndex) {
|
||||
// 获取已合并的区域
|
||||
List<CellRangeAddress> mergeRegions = sheet.getMergedRegions();
|
||||
boolean isMerged = false;
|
||||
|
||||
// 检查前一个单元格是否已经被合并
|
||||
for (int i = 0; i < mergeRegions.size() && !isMerged; i++) {
|
||||
CellRangeAddress cellRangeAddr = mergeRegions.get(i);
|
||||
if (cellRangeAddr.isInRange(curRowIndex - 1, curColIndex)) {
|
||||
sheet.removeMergedRegion(i);
|
||||
cellRangeAddr.setLastRow(curRowIndex);
|
||||
sheet.addMergedRegion(cellRangeAddr);
|
||||
isMerged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果前一个单元格未被合并,则新增合并区域
|
||||
if (!isMerged) {
|
||||
CellRangeAddress cellRangeAddress = new CellRangeAddress(curRowIndex - 1, curRowIndex, curColIndex, curColIndex);
|
||||
sheet.addMergedRegion(cellRangeAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
package com.czg.handel;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.idev.excel.metadata.Head;
|
||||
import cn.idev.excel.metadata.data.WriteCellData;
|
||||
import cn.idev.excel.write.handler.CellWriteHandler;
|
||||
import cn.idev.excel.write.metadata.holder.WriteSheetHolder;
|
||||
import cn.idev.excel.write.metadata.holder.WriteTableHolder;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 台桌统计退单单元格处理器
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2025-04-02 09:50
|
||||
*/
|
||||
public class TableRefundCellHandel implements CellWriteHandler {
|
||||
// 要处理的列索引数组
|
||||
private int[] yellowColumnIndex = {11, 12};
|
||||
|
||||
public TableRefundCellHandel() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
|
||||
// 当前行索引
|
||||
int curRowIndex = cell.getRowIndex();
|
||||
// 当前列索引
|
||||
int curColIndex = cell.getColumnIndex();
|
||||
if (curRowIndex == 0) {
|
||||
return;
|
||||
}
|
||||
// 如果是指定要处理的列,则要进行加黄操作
|
||||
if (ArrayUtil.contains(yellowColumnIndex, curColIndex)) {
|
||||
Cell preCell = cell.getSheet().getRow(curRowIndex - 1).getCell(curColIndex);
|
||||
if (preCell.getCellType() == CellType.NUMERIC) {
|
||||
if (preCell.getNumericCellValue() < 0) {
|
||||
//System.out.println("设置黄色背景:" + curRowIndex + "行," + curColIndex + "列" + preCell.getNumericCellValue());
|
||||
CellStyle style = preCell.getSheet().getWorkbook().createCellStyle();
|
||||
style.cloneStyleFrom(preCell.getCellStyle());
|
||||
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
||||
style.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
|
||||
// 设置水平居中
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
// 设置垂直居中
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
preCell.setCellStyle(style);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,8 +27,8 @@ public class StatisticTask {
|
|||
long start = System.currentTimeMillis();
|
||||
log.info("定时任务执行,开始统计数据");
|
||||
shopOrderStatisticService.statistic();
|
||||
shopProdStatisticService.statistic();
|
||||
shopTableOrderStatisticService.statistic();
|
||||
//shopProdStatisticService.statistic();
|
||||
//shopTableOrderStatisticService.statistic();
|
||||
log.info("定时任务执行完毕,耗时:{}ms", start - System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
server:
|
||||
port: 9200
|
||||
servlet:
|
||||
context-path: /order
|
||||
|
||||
spring:
|
||||
application:
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||
public class ProductApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
SpringApplication.run(ProductApplication.class, args);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
server:
|
||||
port: 9300
|
||||
servlet:
|
||||
context-path: /product
|
||||
|
||||
spring:
|
||||
application:
|
||||
|
|
@ -14,6 +16,7 @@ wx:
|
|||
operationMsgTmpId: wFdoUG-dUT7bDRHq8bMJD9CF5TjyH9x_uJQgQByZqHg
|
||||
warnMsgTmpId: C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0
|
||||
|
||||
|
||||
logging:
|
||||
config: classpath:logback.xml
|
||||
|
||||
|
|
@ -28,4 +31,6 @@ pagehelper:
|
|||
helper-dialect: mysql
|
||||
support-methods-arguments: true
|
||||
|
||||
|
||||
dubbo:
|
||||
consumer:
|
||||
check: false
|
||||
|
|
|
|||
|
|
@ -18,4 +18,27 @@ public class DemoTest {
|
|||
|
||||
System.out.println(password);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
//System.out.println(StrUtil.sub("下架商品:情人节固",0,20));
|
||||
/*Map<String, Object> data = new HashMap<String, Object>() {{
|
||||
put("thing19", new HashMap<String, Object>() {{
|
||||
put("value", "张三");
|
||||
}});
|
||||
put("thing8", new HashMap<String, Object>() {{
|
||||
put("value", "财务票据");
|
||||
}});
|
||||
put("time21", new HashMap<String, Object>() {{
|
||||
put("value", DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
}});
|
||||
}};
|
||||
|
||||
JSONObject req = new JSONObject();
|
||||
req.put("template_id", "wFdoUG-dUT7bDRHq8bMJD9CF5TjyH9x_uJQgQByZqHg");
|
||||
req.put("touser", "ojC-S6iKBL7sHUb-E0UYq-Q1J4AA");
|
||||
req.put("data", data);
|
||||
String accessToken = "90_zBsyBkkK9cYx3GpbydWV97yPr-2WkRYqc2ESQKLGbr_IxqWgb3t9MZO-9jFNUlJoQCYyKyR1-tHOh_e5GKYPWdSY9wGSzEvC_uNM_MaHHbG1IiI0A0nzDrJmDNgEXBbAJAVOS";
|
||||
String post = HttpUtil.post("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".concat(accessToken), req.toString());
|
||||
System.out.println(post);*/
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
server:
|
||||
port: 9400
|
||||
servlet:
|
||||
context-path: /system
|
||||
|
||||
spring:
|
||||
application:
|
||||
|
|
|
|||
|
|
@ -61,15 +61,17 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
|||
|
||||
SaRouter.match("/user/**").notMatch("/user/login", "/user/test", "/user/geo/**", "/user/home/**", "/user/home/**", "/user/dict/**", "/user/openId")
|
||||
.notMatch("/pay/**")
|
||||
.notMatch("/notify/**")
|
||||
.notMatch("/order/notify/**")
|
||||
.notMatch("/user/product/**")
|
||||
.check(r -> MyStpLogic.CLIENT_LOGIC.checkLogin())
|
||||
.setHit(true)
|
||||
// .match("/**")
|
||||
.notMatch("/user/**")
|
||||
.notMatch("/pay/**")
|
||||
.notMatch("/notify/**")
|
||||
.notMatch("/admin/auth/**")
|
||||
.notMatch("/admin/shopMsgPush/subscribe/**")
|
||||
.notMatch("/order/notify/**")
|
||||
.notMatch("/account/admin/auth/**")
|
||||
.notMatch("/user/product/**")
|
||||
.notMatch("/account/admin/shopMsgPush/subscribe/**")
|
||||
.check(r -> MyStpLogic.ADMIN_LOGIC.checkLogin());
|
||||
|
||||
})).addPathPatterns("/**");
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.czg.order.service;
|
||||
|
||||
import com.czg.order.param.TableSummaryParam;
|
||||
import com.czg.order.vo.TableSummaryExportVo;
|
||||
import com.czg.order.vo.TableSummaryInfoVo;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -15,5 +16,7 @@ public interface TableSummaryService {
|
|||
|
||||
List<TableSummaryInfoVo> summaryList(TableSummaryParam param);
|
||||
|
||||
List<TableSummaryExportVo> summaryExportList(TableSummaryParam param);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import java.math.BigDecimal;
|
|||
* @since 2025-03-07 16:22
|
||||
*/
|
||||
@Data
|
||||
@ColumnWidth(30)
|
||||
public class TableSummaryExportVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
|
|
@ -31,70 +30,88 @@ public class TableSummaryExportVo implements Serializable {
|
|||
@ExcelIgnore
|
||||
@JSONField(serialize = false)
|
||||
private Long lineNum;
|
||||
/**
|
||||
* 台桌+日期
|
||||
*/
|
||||
@ExcelIgnore
|
||||
private String tableConcatDate;
|
||||
/**
|
||||
* 台桌
|
||||
*/
|
||||
@ExcelProperty("台桌")
|
||||
@ColumnWidth(10)
|
||||
private String tableName;
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
@ExcelProperty("日期")
|
||||
private String date;
|
||||
@ColumnWidth(10)
|
||||
private String createDate;
|
||||
/**
|
||||
* 商品分类
|
||||
*/
|
||||
@ExcelProperty("商品分类")
|
||||
@ColumnWidth(15)
|
||||
private String categoryName;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@ExcelProperty("商品名称")
|
||||
@ColumnWidth(30)
|
||||
private String productName;
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
@ExcelProperty("单位")
|
||||
@ColumnWidth(8)
|
||||
private String unitName;
|
||||
/**
|
||||
* 商品规格
|
||||
*/
|
||||
@ExcelProperty("商品规格")
|
||||
private String specName;
|
||||
@ColumnWidth(20)
|
||||
private String skuName;
|
||||
/**
|
||||
* 销量
|
||||
*/
|
||||
@ExcelProperty("销量")
|
||||
private BigDecimal salesNum;
|
||||
@ColumnWidth(10)
|
||||
private BigDecimal num;
|
||||
/**
|
||||
* 单价
|
||||
*/
|
||||
@ExcelProperty("单价")
|
||||
private BigDecimal price;
|
||||
@ColumnWidth(10)
|
||||
private BigDecimal unitPrice;
|
||||
/**
|
||||
* 金额
|
||||
*/
|
||||
@ExcelProperty("金额")
|
||||
@ColumnWidth(10)
|
||||
private BigDecimal amount;
|
||||
/**
|
||||
* 销售额
|
||||
*/
|
||||
@ExcelProperty("销售额")
|
||||
@ColumnWidth(10)
|
||||
private BigDecimal salesAmount;
|
||||
/**
|
||||
* 总销售额
|
||||
*/
|
||||
@ExcelProperty("总销售额")
|
||||
@ColumnWidth(15)
|
||||
private BigDecimal totalSalesAmount;
|
||||
/**
|
||||
* 退单量
|
||||
*/
|
||||
@ExcelProperty("退单量")
|
||||
private Integer refundNum;
|
||||
@ColumnWidth(10)
|
||||
private BigDecimal refundNum;
|
||||
/**
|
||||
* 退单额
|
||||
*/
|
||||
@ExcelProperty("退单额")
|
||||
@ColumnWidth(10)
|
||||
private BigDecimal refundAmount;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.czg.service.order.mapper;
|
|||
|
||||
import com.czg.order.entity.ShopTableOrderStatistic;
|
||||
import com.czg.order.param.TableSummaryParam;
|
||||
import com.czg.order.vo.TableSummaryExportVo;
|
||||
import com.czg.order.vo.TableSummaryInfoVo;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
|
||||
|
|
@ -23,4 +24,6 @@ public interface ShopTableOrderStatisticMapper extends BaseMapper<ShopTableOrder
|
|||
List<TableSummaryInfoVo> findSummaryList(TableSummaryParam param);
|
||||
|
||||
List<TableSummaryInfoVo> findSummaryList2(TableSummaryParam param);
|
||||
|
||||
List<TableSummaryExportVo> findSummaryExportList(TableSummaryParam param);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
.eq(OrderInfo::getPayType, CzgStrUtils.getStrOrNull(param.getPayType()))
|
||||
.eq(OrderInfo::getUserId, param.getUserId())
|
||||
.eq(OrderInfo::getTableCode, CzgStrUtils.getStrOrNull(param.getTableCode()))
|
||||
.eq(OrderInfo::getTableName, CzgStrUtils.getStrOrNull(param.getTableName()))
|
||||
.eq(OrderInfo::getOrderNo, CzgStrUtils.getStrOrNull(param.getOrderNo()))
|
||||
.eq(OrderInfo::getIsDel, param.getIsDel())
|
||||
.gt(OrderInfo::getCreateTime, CzgStrUtils.getStrOrNull(param.getStartTime()))
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.czg.order.entity.ShopOrderStatistic;
|
||||
import com.czg.order.param.DataSummaryTradeParam;
|
||||
import com.czg.order.service.DataSummaryService;
|
||||
|
|
@ -12,9 +11,11 @@ import com.mybatisflex.spring.service.impl.ServiceImpl;
|
|||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 服务层实现。
|
||||
|
|
@ -30,27 +31,52 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
|
|||
|
||||
@Override
|
||||
public void statistic() {
|
||||
// 获取前一天
|
||||
DateTime yesterday = DateUtil.yesterday();
|
||||
// 获取前一天的开始时间(00:00:00)
|
||||
DateTime startOfDay = DateUtil.beginOfDay(yesterday);
|
||||
// 获取前一天的结束时间(23:59:59)
|
||||
DateTime endOfDay = DateUtil.endOfDay(yesterday);
|
||||
List<Long> shopIdList = dataSummaryService.getShopIdList();
|
||||
if (CollUtil.isEmpty(shopIdList)) {
|
||||
return;
|
||||
}
|
||||
shopIdList.parallelStream().forEach(shopId -> {
|
||||
DataSummaryTradeParam param = new DataSummaryTradeParam();
|
||||
param.setShopId(shopId);
|
||||
param.setBeginDate(startOfDay.toStringDefaultTimeZone());
|
||||
param.setEndDate(endOfDay.toStringDefaultTimeZone());
|
||||
ShopOrderStatistic statistic = dataSummaryService.getTradeData(param);
|
||||
statistic.setShopId(shopId);
|
||||
statistic.setCreateDay(LocalDate.now());
|
||||
statistic.setUpdateTime(LocalDateTime.now());
|
||||
saveOrUpdate(statistic);
|
||||
|
||||
LocalDate startDate = LocalDate.of(2024, 3, 12);
|
||||
LocalDate endDate = LocalDate.of(2025, 3, 25);
|
||||
|
||||
// 生成日期流
|
||||
Stream<LocalDate> dateStream = startDate.datesUntil(endDate);
|
||||
|
||||
// 遍历日期流
|
||||
dateStream.forEach(date -> {
|
||||
String cur = date.toString();
|
||||
String a = cur + " 00:00:00";
|
||||
String b = cur + " 23:59:59";
|
||||
shopIdList.parallelStream().forEach(shopId -> {
|
||||
DataSummaryTradeParam param = new DataSummaryTradeParam();
|
||||
param.setShopId(shopId);
|
||||
param.setBeginDate(a);
|
||||
param.setEndDate(b);
|
||||
ShopOrderStatistic statistic = dataSummaryService.getTradeData(param);
|
||||
if (NumberUtil.isGreater(statistic.getSaleAmount(), BigDecimal.ZERO)) {
|
||||
statistic.setShopId(shopId);
|
||||
statistic.setCreateDay(LocalDate.now());
|
||||
statistic.setUpdateTime(LocalDateTime.now());
|
||||
saveOrUpdate(statistic);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
LocalDate startDate = LocalDate.of(2024, 3, 12);
|
||||
LocalDate endDate = LocalDate.of(2025, 3, 25);
|
||||
|
||||
// 生成日期流
|
||||
Stream<LocalDate> dateStream = startDate.datesUntil(endDate);
|
||||
|
||||
// 遍历日期流
|
||||
dateStream.forEach(date -> {
|
||||
String cur = date.toString();
|
||||
String a = cur + "00:00:00";
|
||||
String b = cur + "23:59:59";
|
||||
System.out.println(date.toString());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,20 @@
|
|||
package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.czg.order.param.TableSummaryParam;
|
||||
import com.czg.order.service.TableSummaryService;
|
||||
import com.czg.order.vo.TableSummaryExportVo;
|
||||
import com.czg.order.vo.TableSummaryInfoVo;
|
||||
import com.czg.service.order.mapper.ShopTableOrderStatisticMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 台桌统计Service实现类
|
||||
|
|
@ -26,4 +33,50 @@ public class TableSummaryServiceImpl implements TableSummaryService {
|
|||
return shopTableOrderStatisticMapper.findSummaryList2(param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TableSummaryExportVo> summaryExportList(TableSummaryParam param) {
|
||||
if (param.getBeginDate() == null && param.getEndDate() == null) {
|
||||
// 获取当前日期
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
// 计算 30 天前的日期
|
||||
LocalDate startDate = currentDate.minusDays(30);
|
||||
|
||||
// 定义日期格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
// 格式化日期
|
||||
String formattedStartDate = startDate.format(formatter);
|
||||
String formattedEndDate = currentDate.format(formatter);
|
||||
|
||||
param.setBeginDate(formattedStartDate + " 00:00:00");
|
||||
param.setEndDate(formattedEndDate + " 23:59:59");
|
||||
}
|
||||
List<TableSummaryExportVo> list = shopTableOrderStatisticMapper.findSummaryExportList(param);
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return List.of();
|
||||
}
|
||||
Map<String, BigDecimal> totalSalesAmountMap = list.stream().collect(
|
||||
Collectors.groupingBy(
|
||||
TableSummaryExportVo::getTableName, Collectors.reducing(BigDecimal.ZERO,
|
||||
TableSummaryExportVo::getAmount,
|
||||
BigDecimal::add)
|
||||
)
|
||||
);
|
||||
Map<String, BigDecimal> salesAmountMap = list.stream().collect(
|
||||
Collectors.groupingBy(
|
||||
TableSummaryExportVo::getTableConcatDate, Collectors.reducing(BigDecimal.ZERO,
|
||||
TableSummaryExportVo::getAmount,
|
||||
BigDecimal::add)
|
||||
)
|
||||
);
|
||||
list.parallelStream().forEach(data -> {
|
||||
data.setSalesAmount(salesAmountMap.get(data.getTableConcatDate()));
|
||||
data.setTotalSalesAmount(totalSalesAmountMap.get(data.getTableName()));
|
||||
});
|
||||
// 追加个空行用于处理表格样式
|
||||
TableSummaryExportVo nullVo = new TableSummaryExportVo();
|
||||
list.add(nullVo);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@
|
|||
LEFT JOIN tb_shop_table_area t3 ON t2.area_id = t3.id
|
||||
where t1.shop_id = #{shopId}
|
||||
and t1.table_code is not null
|
||||
and t2.table_code is not null
|
||||
and t2.table_code != ''
|
||||
and t2.name is not null
|
||||
and t1.paid_time is not null
|
||||
<if test="beginDate != null and beginDate != ''">
|
||||
|
|
@ -74,4 +76,50 @@
|
|||
GROUP BY t1.table_code
|
||||
order by count( t1.id ) desc,sum( t1.pay_amount ) desc
|
||||
</select>
|
||||
<select id="findSummaryExportList" resultType="com.czg.order.vo.TableSummaryExportVo">
|
||||
SELECT
|
||||
t.product_name,
|
||||
date_format(t.create_time, '%Y-%m-%d') as create_date,
|
||||
if(t.table_name = '11111111','银收客',t.table_name) as table_name,
|
||||
concat(if(t.table_name = '11111111','银收客',t.table_name),'-',date_format(t.create_time, '%Y-%m-%d')) as tableConcatDate,
|
||||
t.category_name,
|
||||
t.unit_name,
|
||||
group_concat(distinct t.sku_name SEPARATOR ';') as sku_name,
|
||||
sum(t.num) as num,
|
||||
avg(t.unit_price) as unit_price,
|
||||
sum(t.num*t.unit_price) as amount,
|
||||
sum(-t.refund_num) as refund_num,
|
||||
sum(-t.refund_num*t.unit_price) as refund_amount
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
t1.product_id,
|
||||
t2.table_code,
|
||||
IF(t2.table_code is null or t2.table_code = '' or t6.NAME is null, '11111111', t6.NAME) AS table_name,
|
||||
t1.create_time,
|
||||
t4.NAME AS category_name,
|
||||
t3.name as product_name,
|
||||
t5.NAME AS unit_name,
|
||||
t1.sku_name,
|
||||
t1.num,
|
||||
t1.unit_price,
|
||||
t1.refund_num as refund_num
|
||||
FROM
|
||||
tb_order_detail t1
|
||||
LEFT JOIN tb_order_info t2 ON t1.order_id = t2.id
|
||||
LEFT JOIN tb_product t3 ON t1.product_id = t3.id
|
||||
LEFT JOIN tb_shop_prod_category t4 ON t3.category_id = t4.id
|
||||
LEFT JOIN tb_shop_prod_unit t5 ON t3.unit_id = t5.id
|
||||
LEFT JOIN tb_shop_table t6 ON t2.table_code = t6.table_code AND t1.shop_id = t6.shop_id and t6.table_code != '' and t6.table_code is not null
|
||||
WHERE t1.shop_id = #{shopId}
|
||||
<if test="beginDate != null and beginDate != ''">
|
||||
AND t1.create_time >= str_to_date(#{beginDate}, '%Y-%m-%d %H:%i:%s')
|
||||
</if>
|
||||
<if test="endDate != null and endDate != ''">
|
||||
and t1.create_time <= str_to_date(#{endDate}, '%Y-%m-%d %H:%i:%s')
|
||||
</if>
|
||||
) t
|
||||
group by t.product_id,date_format(t.create_time, '%Y-%m-%d'),t.table_name
|
||||
order by t.table_name,t.table_code,date_format(t.create_time, '%Y-%m-%d'),t.category_name,t.product_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue