From 3ffa3609d1175151871c4dd421bc6a034fef21aa Mon Sep 17 00:00:00 2001 From: Tankaikai Date: Wed, 2 Apr 2025 13:51:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=B0=E6=A1=8C=E7=BB=9F=E8=AE=A1=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 2 - .../com/czg/controller/NotifyController.java | 31 ++++----- .../main/java/com/czg/task/StatisticTask.java | 4 +- .../src/main/resources/application.yml | 2 - .../main/java/com/czg/ProductApplication.java | 1 - .../src/main/resources/application.yml | 2 - .../src/main/resources/application.yml | 2 - .../java/com/czg/config/SaTokenConfigure.java | 10 ++- .../impl/ShopOrderStatisticServiceImpl.java | 64 ++++++------------- 9 files changed, 36 insertions(+), 82 deletions(-) diff --git a/cash-api/account-server/src/main/resources/application.yml b/cash-api/account-server/src/main/resources/application.yml index 403ca5958..7cd6922cb 100644 --- a/cash-api/account-server/src/main/resources/application.yml +++ b/cash-api/account-server/src/main/resources/application.yml @@ -1,7 +1,5 @@ server: port: 9100 - servlet: - context-path: /account spring: application: diff --git a/cash-api/order-server/src/main/java/com/czg/controller/NotifyController.java b/cash-api/order-server/src/main/java/com/czg/controller/NotifyController.java index 1420a12d0..ab2857f59 100644 --- a/cash-api/order-server/src/main/java/com/czg/controller/NotifyController.java +++ b/cash-api/order-server/src/main/java/com/czg/controller/NotifyController.java @@ -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.apache.dubbo.config.annotation.DubboReference; -import org.springframework.web.bind.annotation.*; +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; /** * @author ww @@ -30,26 +30,18 @@ public class NotifyController { @Resource private StatisticTask statisticTask; - @DubboReference - private MemberPointsService pointsService; - @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); + @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); 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); @@ -59,7 +51,6 @@ public class NotifyController { @Resource private PrintMqListener printMqListener; - @RequestMapping("/test") public void test(@RequestParam String id) { printMqListener.orderPrint(id); diff --git a/cash-api/order-server/src/main/java/com/czg/task/StatisticTask.java b/cash-api/order-server/src/main/java/com/czg/task/StatisticTask.java index fef8334ce..e387fe681 100644 --- a/cash-api/order-server/src/main/java/com/czg/task/StatisticTask.java +++ b/cash-api/order-server/src/main/java/com/czg/task/StatisticTask.java @@ -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()); } } diff --git a/cash-api/order-server/src/main/resources/application.yml b/cash-api/order-server/src/main/resources/application.yml index 516f3d329..aad8910e3 100644 --- a/cash-api/order-server/src/main/resources/application.yml +++ b/cash-api/order-server/src/main/resources/application.yml @@ -1,7 +1,5 @@ server: port: 9200 - servlet: - context-path: /order spring: application: diff --git a/cash-api/product-server/src/main/java/com/czg/ProductApplication.java b/cash-api/product-server/src/main/java/com/czg/ProductApplication.java index ad8c9c62d..2a249f206 100644 --- a/cash-api/product-server/src/main/java/com/czg/ProductApplication.java +++ b/cash-api/product-server/src/main/java/com/czg/ProductApplication.java @@ -18,7 +18,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; public class ProductApplication { public static void main(String[] args) { - SpringApplication.run(ProductApplication.class, args); } diff --git a/cash-api/product-server/src/main/resources/application.yml b/cash-api/product-server/src/main/resources/application.yml index f6c8d2841..b923d51f4 100644 --- a/cash-api/product-server/src/main/resources/application.yml +++ b/cash-api/product-server/src/main/resources/application.yml @@ -1,7 +1,5 @@ server: port: 9300 - servlet: - context-path: /product spring: application: diff --git a/cash-api/system-server/src/main/resources/application.yml b/cash-api/system-server/src/main/resources/application.yml index cb8965a5b..414d20b9c 100644 --- a/cash-api/system-server/src/main/resources/application.yml +++ b/cash-api/system-server/src/main/resources/application.yml @@ -1,7 +1,5 @@ server: port: 9400 - servlet: - context-path: /system spring: application: diff --git a/cash-common/cash-common-sa-token/src/main/java/com/czg/config/SaTokenConfigure.java b/cash-common/cash-common-sa-token/src/main/java/com/czg/config/SaTokenConfigure.java index cf58f9514..c07aac7fc 100644 --- a/cash-common/cash-common-sa-token/src/main/java/com/czg/config/SaTokenConfigure.java +++ b/cash-common/cash-common-sa-token/src/main/java/com/czg/config/SaTokenConfigure.java @@ -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") .notMatch("/pay/**") - .notMatch("/order/notify/**") - .notMatch("/user/product/**") + .notMatch("/notify/**") .check(r -> MyStpLogic.CLIENT_LOGIC.checkLogin()) .setHit(true) // .match("/**") .notMatch("/user/**") .notMatch("/pay/**") - .notMatch("/order/notify/**") - .notMatch("/account/admin/auth/**") - .notMatch("/user/product/**") - .notMatch("/account/admin/shopMsgPush/subscribe/**") + .notMatch("/notify/**") + .notMatch("/admin/auth/**") + .notMatch("/admin/shopMsgPush/subscribe/**") .check(r -> MyStpLogic.ADMIN_LOGIC.checkLogin()); })).addPathPatterns("/**"); diff --git a/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/ShopOrderStatisticServiceImpl.java b/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/ShopOrderStatisticServiceImpl.java index 9be41ded1..7d59aed8a 100644 --- a/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/ShopOrderStatisticServiceImpl.java +++ b/cash-service/order-service/src/main/java/com/czg/service/order/service/impl/ShopOrderStatisticServiceImpl.java @@ -1,7 +1,8 @@ package com.czg.service.order.service.impl; 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.param.DataSummaryTradeParam; import com.czg.order.service.DataSummaryService; @@ -11,11 +12,9 @@ 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; /** * 服务层实现。 @@ -31,52 +30,27 @@ public class ShopOrderStatisticServiceImpl extends ServiceImpl shopIdList = dataSummaryService.getShopIdList(); if (CollUtil.isEmpty(shopIdList)) { return; } - - LocalDate startDate = LocalDate.of(2024, 3, 12); - LocalDate endDate = LocalDate.of(2025, 3, 25); - - // 生成日期流 - Stream 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 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()); + 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); }); } + }