From db446eb947ee5851fdbd1f16c4cc360b4e32b95a Mon Sep 17 00:00:00 2001
From: phpcjl <phpcjl@gmail.com>
Date: 星期一, 16 十二月 2024 11:22:44 +0800
Subject: [PATCH] 1
---
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java | 54 +++++++++++++++++++++++++++++++++++++++---------------
ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml | 2 +-
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java | 4 ++++
3 files changed, 44 insertions(+), 16 deletions(-)
diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java
index d954b30..b47c109 100644
--- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java
+++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/UserPoint.java
@@ -11,6 +11,7 @@
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
+import java.util.List;
/**
* <p>
@@ -77,5 +78,8 @@
@TableField(exist = false)
private LocalDateTime endTime;
+ @TableField(exist = false)
+ private List<Long> userIds;
+
}
diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml
index 47651b2..aa57ef3 100644
--- a/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml
+++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapping/system/SysUserMapper.xml
@@ -49,7 +49,7 @@
</resultMap>
<sql id="selectUserVo">
- select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
+ select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.role_type, u.create_by, u.create_time, u.remark,
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
r.role_id, r.role_name, r.role_key, r.data_scope, r.status as role_status ,u.roleType as roleType,u.objectId AS objectId
from sys_user u
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java
index 590c636..39c2e17 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java
@@ -18,6 +18,7 @@
import com.ruoyi.account.vo.UserPointVO;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.PhoneNumberValidator;
+import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.other.api.domain.PointSetting;
import com.ruoyi.other.api.domain.VipSetting;
@@ -30,10 +31,7 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -165,18 +163,45 @@
@Override
public UserPointStatistics getStatistics(UserPoint userPoint) {
- List<AppUser> appUserList = appUserService.list(new LambdaQueryWrapper<AppUser>()
- .eq(AppUser::getPhone, userPoint.getPhone())
- .like(AppUser::getName, userPoint.getUserName()));
- List<Long> userIds = appUserList.stream().map(AppUser::getId).collect(Collectors.toList());
- list(new LambdaQueryWrapper<UserPoint>()
- .in(!CollectionUtils.isEmpty(userIds), UserPoint::getAppUserId, userIds)
- .eq(UserPoint::getType, userPoint.getType())
- .between(UserPoint::getCreateTime, userPoint.getStartTime(), userPoint.getEndTime()));
+ List<Long> userIds = new ArrayList<>();
+ if (StringUtils.isNotEmpty(userPoint.getUserName())) {
+ userIds = appUserService.listObjs(new LambdaQueryWrapper<AppUser>()
+ .select(AppUser::getId)
+ .like(AppUser::getName, userPoint.getUserName()))
+ .stream()
+ .map(appUserId -> (Long) appUserId)
+ .collect(Collectors.toList());
+ }
+
+ List<UserPoint> userPointList = userPointMapper.findLatestChangeByType(userPoint);
+ Map<Integer, Integer> userBalanceMap = userPointList.stream()
+ .collect(Collectors.toMap(UserPoint::getType, UserPoint::getBalance));
- return null;
+
+ Integer consumePoint = Optional.ofNullable(userBalanceMap.get(PointChangeType.CONSUME.getCode())).orElse(0);
+ Integer sharePoint = Optional.ofNullable(userBalanceMap.get(PointChangeType.COMMISSION_RETURN.getCode())).orElse(0);
+ Integer pullNewPoint = Optional.ofNullable(userBalanceMap.get(PointChangeType.NEW_USER_REFERRAL.getCode())).orElse(0);
+ Integer registerPoint = Optional.ofNullable(userBalanceMap.get(PointChangeType.REGISTRATION.getCode())).orElse(0);
+ Integer workPoint = Optional.ofNullable(userBalanceMap.get(PointChangeType.WORK_PERFORMANCE.getCode())).orElse(0);
+ Integer shopAchievementPoint = Optional.ofNullable(userBalanceMap.get(PointChangeType.TECHNICIAN_PERFORMANCE.getCode())).orElse(0);
+ Integer exchangeGoodsPoint = Optional.ofNullable(userBalanceMap.get(PointChangeType.EXCHANGE_GOODS.getCode())).orElse(0);
+ Integer storeAchievementPoint = Optional.ofNullable(userBalanceMap.get(PointChangeType.STORE_PERFORMANCE.getCode())).orElse(0);
+ Integer storeCommissionPoint = Optional.ofNullable(userBalanceMap.get(PointChangeType.STORE_COMMISSION_RETURN.getCode())).orElse(0);
+ Integer transferPoint = Optional.ofNullable(userBalanceMap.get(PointChangeType.TRANSFER_POINTS.getCode())).orElse(0);
+ Integer totalPoint = consumePoint + sharePoint + pullNewPoint + registerPoint + workPoint + shopAchievementPoint + exchangeGoodsPoint + storeAchievementPoint + storeCommissionPoint + transferPoint;
+
+
+ UserPointStatistics userPointStatistics = new UserPointStatistics();
+ userPointStatistics.setTotalPoint(totalPoint);
+ userPointStatistics.setConsumePoint(consumePoint);
+ userPointStatistics.setSharePoint(sharePoint);
+ userPointStatistics.setPullNewPoint(pullNewPoint);
+ userPointStatistics.setRegisterPoint(registerPoint);
+ userPointStatistics.setWorkPoint(workPoint);
+ userPointStatistics.setShopAchievementPoint(shopAchievementPoint);
+ return userPointStatistics;
}
@Override
@@ -189,8 +214,7 @@
Page<UserPoint> userPointPage = page(page, new LambdaQueryWrapper<UserPoint>()
.in(!CollectionUtils.isEmpty(userIds), UserPoint::getAppUserId, userIds)
.eq(UserPoint::getType, userPoint.getType())
- .between(userPoint.getStartTime() !=null && userPoint.getEndTime() != null,
- UserPoint::getCreateTime, userPoint.getStartTime(), userPoint.getEndTime())
+ .between(UserPoint::getCreateTime, userPoint.getStartTime(), userPoint.getEndTime())
.orderByDesc(UserPoint::getCreateTime));
userPointPage.getRecords().forEach(userPoint1 -> appUserList.stream()
--
Gitblit v1.7.1