台桌统计报表

This commit is contained in:
Tankaikai
2025-04-02 13:51:15 +08:00
parent 7986f023ba
commit 3ffa3609d1
9 changed files with 36 additions and 82 deletions

View File

@@ -1,7 +1,5 @@
server: server:
port: 9100 port: 9100
servlet:
context-path: /account
spring: spring:
application: application:

View File

@@ -2,17 +2,17 @@ package com.czg.controller;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.czg.CzgPayUtils; import com.czg.CzgPayUtils;
import com.czg.account.service.MemberPointsService;
import com.czg.entity.CzgBaseRespParams; import com.czg.entity.CzgBaseRespParams;
import com.czg.mq.PrintMqListener; import com.czg.mq.PrintMqListener;
import com.czg.order.service.OrderInfoService; import com.czg.order.service.OrderInfoService;
import com.czg.order.service.ShopOrderStatisticService;
import com.czg.task.StatisticTask; import com.czg.task.StatisticTask;
import com.czg.utils.AssertUtil; import com.czg.utils.AssertUtil;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @author ww * @author ww
@@ -30,26 +30,18 @@ public class NotifyController {
@Resource @Resource
private StatisticTask statisticTask; private StatisticTask statisticTask;
@DubboReference
private MemberPointsService pointsService;
@Resource @RequestMapping("/payCallBack")
private ShopOrderStatisticService shopOrderStatisticService; public String notifyCallBack(@RequestBody CzgBaseRespParams respParams){
JSONObject czg = CzgPayUtils.getCzg(respParams);
AssertUtil.isNull(czg, "支付回调数据为空");
@GetMapping("/payCallBack") log.info("支付回调数据为:{}", czg);
public String notifyCallBack() { orderInfoService.payCallBackOrder(czg.getString("mchOrderNo"), czg);
shopOrderStatisticService.statistic();
//JSONObject czg = CzgPayUtils.getCzg(respParams);
//AssertUtil.isNull(czg, "支付回调数据为空");
//log.info("支付回调数据为:{}", czg);
//orderInfoService.payCallBackOrder(czg.getString("mchOrderNo"), czg);
return SUCCESS; return SUCCESS;
} }
@RequestMapping("/refundCallBack") @RequestMapping("/refundCallBack")
public String refundCallBack(@RequestBody CzgBaseRespParams respParams) { public String refundCallBack(@RequestBody CzgBaseRespParams respParams){
JSONObject czg = CzgPayUtils.getCzg(respParams); JSONObject czg = CzgPayUtils.getCzg(respParams);
AssertUtil.isNull(czg, "退款回调数据为空"); AssertUtil.isNull(czg, "退款回调数据为空");
log.info("退款回调数据为:{}", czg); log.info("退款回调数据为:{}", czg);
@@ -59,7 +51,6 @@ public class NotifyController {
@Resource @Resource
private PrintMqListener printMqListener; private PrintMqListener printMqListener;
@RequestMapping("/test") @RequestMapping("/test")
public void test(@RequestParam String id) { public void test(@RequestParam String id) {
printMqListener.orderPrint(id); printMqListener.orderPrint(id);

View File

@@ -27,8 +27,8 @@ public class StatisticTask {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
log.info("定时任务执行,开始统计数据"); log.info("定时任务执行,开始统计数据");
shopOrderStatisticService.statistic(); shopOrderStatisticService.statistic();
//shopProdStatisticService.statistic(); shopProdStatisticService.statistic();
//shopTableOrderStatisticService.statistic(); shopTableOrderStatisticService.statistic();
log.info("定时任务执行完毕,耗时:{}ms", start - System.currentTimeMillis()); log.info("定时任务执行完毕,耗时:{}ms", start - System.currentTimeMillis());
} }
} }

View File

@@ -1,7 +1,5 @@
server: server:
port: 9200 port: 9200
servlet:
context-path: /order
spring: spring:
application: application:

View File

@@ -18,7 +18,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
public class ProductApplication { public class ProductApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(ProductApplication.class, args); SpringApplication.run(ProductApplication.class, args);
} }

View File

@@ -1,7 +1,5 @@
server: server:
port: 9300 port: 9300
servlet:
context-path: /product
spring: spring:
application: application:

View File

@@ -1,7 +1,5 @@
server: server:
port: 9400 port: 9400
servlet:
context-path: /system
spring: spring:
application: application:

View File

@@ -61,17 +61,15 @@ public class SaTokenConfigure implements WebMvcConfigurer {
SaRouter.match("/user/**").notMatch("/user/login", "/user/test", "/user/geo/**", "/user/home/**", "/user/home/**", "/user/dict/**", "/user/openId") SaRouter.match("/user/**").notMatch("/user/login", "/user/test", "/user/geo/**", "/user/home/**", "/user/home/**", "/user/dict/**", "/user/openId")
.notMatch("/pay/**") .notMatch("/pay/**")
.notMatch("/order/notify/**") .notMatch("/notify/**")
.notMatch("/user/product/**")
.check(r -> MyStpLogic.CLIENT_LOGIC.checkLogin()) .check(r -> MyStpLogic.CLIENT_LOGIC.checkLogin())
.setHit(true) .setHit(true)
// .match("/**") // .match("/**")
.notMatch("/user/**") .notMatch("/user/**")
.notMatch("/pay/**") .notMatch("/pay/**")
.notMatch("/order/notify/**") .notMatch("/notify/**")
.notMatch("/account/admin/auth/**") .notMatch("/admin/auth/**")
.notMatch("/user/product/**") .notMatch("/admin/shopMsgPush/subscribe/**")
.notMatch("/account/admin/shopMsgPush/subscribe/**")
.check(r -> MyStpLogic.ADMIN_LOGIC.checkLogin()); .check(r -> MyStpLogic.ADMIN_LOGIC.checkLogin());
})).addPathPatterns("/**"); })).addPathPatterns("/**");

View File

@@ -1,7 +1,8 @@
package com.czg.service.order.service.impl; package com.czg.service.order.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.czg.order.entity.ShopOrderStatistic; import com.czg.order.entity.ShopOrderStatistic;
import com.czg.order.param.DataSummaryTradeParam; import com.czg.order.param.DataSummaryTradeParam;
import com.czg.order.service.DataSummaryService; import com.czg.order.service.DataSummaryService;
@@ -11,11 +12,9 @@ import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.stream.Stream;
/** /**
* 服务层实现。 * 服务层实现。
@@ -31,52 +30,27 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl<ShopOrderStatisti
@Override @Override
public void statistic() { 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(); List<Long> shopIdList = dataSummaryService.getShopIdList();
if (CollUtil.isEmpty(shopIdList)) { if (CollUtil.isEmpty(shopIdList)) {
return; return;
} }
shopIdList.parallelStream().forEach(shopId -> {
LocalDate startDate = LocalDate.of(2024, 3, 12); DataSummaryTradeParam param = new DataSummaryTradeParam();
LocalDate endDate = LocalDate.of(2025, 3, 25); param.setShopId(shopId);
param.setBeginDate(startOfDay.toStringDefaultTimeZone());
// 生成日期流 param.setEndDate(endOfDay.toStringDefaultTimeZone());
Stream<LocalDate> dateStream = startDate.datesUntil(endDate); ShopOrderStatistic statistic = dataSummaryService.getTradeData(param);
statistic.setShopId(shopId);
// 遍历日期流 statistic.setCreateDay(LocalDate.now());
dateStream.forEach(date -> { statistic.setUpdateTime(LocalDateTime.now());
String cur = date.toString(); saveOrUpdate(statistic);
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());
}); });
} }
} }