From 6fa0ff1354a604741cb2fbb3104419caa84ca8aa Mon Sep 17 00:00:00 2001 From: caiyuchao Date: Tue, 24 Dec 2024 19:02:50 +0800 Subject: [PATCH] fix: stat traffic --- .../java/org/wfc/common/core/config/JacksonConfig.java | 2 +- .../java/org/wfc/user/controller/UOrderController.java | 2 -- .../org/wfc/user/service/impl/UAccountServiceImpl.java | 9 ++++++--- .../org/wfc/user/service/impl/UOrderServiceImpl.java | 2 ++ .../src/main/resources/mapper/user/UCdrMapper.xml | 7 ++++--- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/config/JacksonConfig.java b/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/config/JacksonConfig.java index c8f5ec7..f5d7849 100644 --- a/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/config/JacksonConfig.java +++ b/wfc-common/wfc-common-core/src/main/java/org/wfc/common/core/config/JacksonConfig.java @@ -40,7 +40,7 @@ public class JacksonConfig { javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(formatter)); builder.modules(javaTimeModule); builder.timeZone(TimeZone.getDefault()); - log.info("初始化 jackson 配置"); + log.info("init jackson config"); }; } diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UOrderController.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UOrderController.java index f87009c..12aac4e 100644 --- a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UOrderController.java +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/controller/UOrderController.java @@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.RestController; import org.wfc.common.core.web.controller.BaseController; import org.wfc.common.core.web.domain.AjaxResult; import org.wfc.common.core.web.page.TableDataInfo; -import org.wfc.common.security.utils.SecurityUtils; import org.wfc.user.domain.UOrder; import org.wfc.user.service.IUOrderService; @@ -54,7 +53,6 @@ public class UOrderController extends BaseController { @PostMapping public AjaxResult add(@RequestBody UOrder uOrder) { - uOrder.setUserId(SecurityUtils.getUserId()); return toAjax(uOrderService.saveOrder(uOrder)); } diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java index 4a7cd0b..a52afc1 100644 --- a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UAccountServiceImpl.java @@ -1,5 +1,6 @@ package org.wfc.user.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.ObjectUtil; @@ -74,9 +75,11 @@ public class UAccountServiceImpl extends ServiceImpl i .map(UAccount::getUserId) .collect(Collectors.toList()); - List clients = clientMapper.selectList(Wrappers.lambdaQuery().in(UClient::getUserId, userIds)); - for (UClient client : clients) { - omadaAuthorizedClientApi.cancelAuthClient(client.getSiteId(), client.getClientMac()); + if (CollUtil.isNotEmpty(userIds)) { + List clients = clientMapper.selectList(Wrappers.lambdaQuery().in(UClient::getUserId, userIds)); + for (UClient client : clients) { + omadaAuthorizedClientApi.cancelAuthClient(client.getSiteId(), client.getClientMac()); + } } } diff --git a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java index 220f786..739c2f0 100644 --- a/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java +++ b/wfc-modules/wfc-modules-user/src/main/java/org/wfc/user/service/impl/UOrderServiceImpl.java @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.wfc.common.security.utils.SecurityUtils; import org.wfc.omada.api.hotspot.OmadaAuthorizedClientApi; import org.wfc.user.domain.UAccount; import org.wfc.user.domain.UClient; @@ -131,6 +132,7 @@ public class UOrderServiceImpl extends ServiceImpl impleme @Override public boolean saveOrder(UOrder order) { + order.setUserId(SecurityUtils.getUserId()); order.setStatus(OrderStatusEnum.UNPAID.getCode()); this.save(order); // 支付成功回调 diff --git a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UCdrMapper.xml b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UCdrMapper.xml index 22184e0..af938b1 100644 --- a/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UCdrMapper.xml +++ b/wfc-modules/wfc-modules-user/src/main/resources/mapper/user/UCdrMapper.xml @@ -26,17 +26,18 @@ WHERE cdr.del_flag = 0 AND cdr.last_seen_time != ifnull( ch.end_time, 0 ) - AND cdr.user_id = #{userId} + + AND cdr.user_id = #{userId} GROUP BY cdr.user_id ) t - t.last_seen_time <= #{endTime} + AND t.end_time <= #{endTime} - t.start_time >= #{startTime} + AND t.start_time >= #{startTime}