From 3ffa3609d1175151871c4dd421bc6a034fef21aa Mon Sep 17 00:00:00 2001 From: Tankaikai Date: Wed, 2 Apr 2025 13:51:15 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E5=8F=B0=E6=A1=8C=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=8A=A5=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 403ca595..7cd6922c 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 1420a12d..ab2857f5 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 fef8334c..e387fe68 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 516f3d32..aad8910e 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 ad8c9c62..2a249f20 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 f6c8d284..b923d51f 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 cb8965a5..414d20b9 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 cf58f951..c07aac7f 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 9be41ded..7d59aed8 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); }); } + } From 0fe7eeaf70d87d126ccba2ccb921a26f75e93d4f Mon Sep 17 00:00:00 2001 From: GYJ <1157756119@qq.com> Date: Wed, 2 Apr 2025 14:12:28 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E7=89=88=E6=9C=AC=E8=8E=B7=E5=8F=96=20?= =?UTF-8?q?=E4=B8=8D=E5=81=9A=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/czg/controller/admin/VersionController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cash-api/system-server/src/main/java/com/czg/controller/admin/VersionController.java b/cash-api/system-server/src/main/java/com/czg/controller/admin/VersionController.java index 8eb0d5d0..6e000705 100644 --- a/cash-api/system-server/src/main/java/com/czg/controller/admin/VersionController.java +++ b/cash-api/system-server/src/main/java/com/czg/controller/admin/VersionController.java @@ -71,7 +71,7 @@ public class VersionController { * @return VersionDTO */ @GetMapping("/{source}/{type}") - @SaAdminCheckPermission(value = "version:get", name = "版本获取") +// @SaAdminCheckPermission(value = "version:get", name = "版本获取") public CzgResult getVersionInfo(@PathVariable("source") String source, @PathVariable("type") String type) { return versionService.getVersionInfo(source, type); } From 3e3269e8bc51464a9219c4bb61d5d94a62e2dcee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 2 Apr 2025 14:18:48 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E4=BC=9A=E5=91=98=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/mapper/ShopUserMapper.xml | 48 +++++++++++++------ 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/cash-service/account-service/src/main/resources/mapper/ShopUserMapper.xml b/cash-service/account-service/src/main/resources/mapper/ShopUserMapper.xml index 52c513ff..e7349116 100644 --- a/cash-service/account-service/src/main/resources/mapper/ShopUserMapper.xml +++ b/cash-service/account-service/src/main/resources/mapper/ShopUserMapper.xml @@ -56,29 +56,47 @@ SELECT a.*, - (SELECT COUNT(*) - FROM tb_shop_activate_coupon_record c - WHERE c.shop_user_id = a.id - AND c.status = 0 - AND c.use_start_time < NOW() - AND c.use_end_time > NOW() - ) AS couponNum, - - (SELECT COUNT(*) - FROM tb_order_info d - WHERE d.user_id = a.user_id - AND d.shop_id = a.shop_id - ) AS orderNumber, - - (SELECT IFNULL(SUM(f.amount), 0) - FROM tb_shop_user_flow f - WHERE f.user_id = a.user_id - AND f.shop_id = a.shop_id - AND f.biz_code IN ('cashIn', 'wechatIn', 'alipayIn') - ) AS rechargeAmount - + IFNULL(c.couponNum, 0) AS couponNum, + IFNULL(d.orderNumber, 0) AS orderNumber, + IFNULL(f.rechargeAmount, 0) AS rechargeAmount FROM tb_shop_user a LEFT JOIN tb_user_info b ON b.id = a.user_id + -- 预计算优惠券数量 + LEFT JOIN ( + SELECT shop_user_id, COUNT(*) AS couponNum + FROM tb_shop_activate_coupon_record + WHERE status = 0 + AND use_start_time < NOW() + AND use_end_time > NOW() + GROUP BY shop_user_id + ) c ON c.shop_user_id = a.id + + -- 预计算订单数量 + LEFT JOIN ( + SELECT user_id, shop_id, COUNT(*) AS orderNumber + FROM tb_order_info + GROUP BY user_id, shop_id + ) d ON d.user_id = a.user_id AND d.shop_id = a.shop_id + + -- 预计算充值总金额 + LEFT JOIN ( + SELECT user_id, shop_id, SUM(amount) AS rechargeAmount + FROM tb_shop_user_flow + WHERE biz_code IN ('cashIn', 'wechatIn', 'alipayIn') + GROUP BY user_id, shop_id + ) f ON f.user_id = a.user_id AND f.shop_id = a.shop_id + WHERE a.shop_id = #{shopId} From 989945d85e83d909e69619f94a27f19faeb554db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=9D=BE?= <8605635+zhang3064194730@user.noreply.gitee.com> Date: Wed, 2 Apr 2025 16:03:00 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E4=BC=9A=E5=91=98=E5=88=97=E8=A1=A8sql?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/ShopUserMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cash-service/account-service/src/main/resources/mapper/ShopUserMapper.xml b/cash-service/account-service/src/main/resources/mapper/ShopUserMapper.xml index 6194b852..b908fc82 100644 --- a/cash-service/account-service/src/main/resources/mapper/ShopUserMapper.xml +++ b/cash-service/account-service/src/main/resources/mapper/ShopUserMapper.xml @@ -68,7 +68,7 @@ SELECT shop_user_id, COUNT(*) AS couponNum FROM tb_shop_activate_coupon_record WHERE status = 0 - AND use_start_time < NOW() + AND use_start_time < NOW() AND use_end_time > NOW() GROUP BY shop_user_id ) c ON c.shop_user_id = a.id