From 9aa109735b29215f9a64426300095706fd137d0b Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期三, 01 一月 2025 17:49:24 +0800 Subject: [PATCH] 修改bug --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserPointServiceImpl.java | 49 +++++-------------------------------------------- 1 files changed, 5 insertions(+), 44 deletions(-) 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 71267e7..1230f20 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 @@ -21,7 +21,6 @@ import com.ruoyi.other.api.domain.PointSetting; import com.ruoyi.other.api.domain.VipSetting; import com.ruoyi.other.api.enums.PointChangeType; -import com.ruoyi.other.api.feignClient.ShopClient; import com.ruoyi.system.api.model.LoginUser; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -30,6 +29,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Collections; import java.util.List; import java.util.Map; @@ -54,8 +54,6 @@ private VipSettingService vipSettingService; @Resource private PointSettingService pointSettingService; - @Resource - private ShopClient shopClient; @Override public UserPointVO getUserPoint(Long userId) { @@ -79,13 +77,14 @@ List<UserPoint> userPointList = list(new LambdaQueryWrapper<UserPoint>() .between(startTime != null, UserPoint::getCreateTime, startTime, endTime) .eq(type != null, UserPoint::getType, type) - .eq(UserPoint::getAppUserId, userId)); + .eq(UserPoint::getAppUserId, userId).orderByDesc(UserPoint::getCreateTime)); if (CollectionUtil.isNotEmpty(userPointList)) { return userPointList.stream().map(p -> { UserPointDetailVO userPointDetailVO = new UserPointDetailVO(); userPointDetailVO.setType(p.getType()); userPointDetailVO.setVariablePoint(p.getVariablePoint()); - userPointDetailVO.setCreateTime(p.getCreateTime()); + String format = p.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + userPointDetailVO.setCreateTime(format); return userPointDetailVO; }).collect(Collectors.toList()); } @@ -121,7 +120,7 @@ throw new ServiceException("积分设置未找到"); } // 可转赠积分总数 - long adjustedPoint = getAdjustedPoint(pointSetting, appUser); + long adjustedPoint = appUser.getAvailablePoint(); if (point.compareTo(new BigDecimal(adjustedPoint)) > 0) { throw new ServiceException("转赠积分不足"); @@ -144,44 +143,6 @@ appUserService.updateById(appUser); log.info("积分转赠完成,用户ID: {}, 新积分: {}", appUserForPhoe.getId(), appUserForPhoe.getLavePoint()); } - - /** - * 获取可转赠积分 - * @param pointSetting 积分设置 - * @param appUser 用户 - * @return - */ - private long getAdjustedPoint(PointSetting pointSetting, AppUser appUser) { - if (pointSetting == null || appUser == null) { - throw new ServiceException("pointSetting和appUser不能为空"); - } - - long transferPoint = 0; - - transferPoint += calculatePoint(pointSetting.getBuyPointGift(), appUser.getShopPoint(), pointSetting.getBuyPoint()); - transferPoint += calculatePoint(pointSetting.getSharePointGift(), appUser.getSharePoint(), pointSetting.getSharePoint()); - transferPoint += calculatePoint(pointSetting.getShopSharePointGift(), appUser.getShopSharePoint(), pointSetting.getShopSharePoint()); - transferPoint += calculatePoint(pointSetting.getShopPointGift(), appUser.getShopAchievementPoint(), pointSetting.getShopPoint()); - transferPoint += calculatePoint(pointSetting.getPersonPointGift(), appUser.getTotalPerformancePoint(), pointSetting.getPersonPoint()); - transferPoint += calculatePoint(pointSetting.getGetNewPointGift(), appUser.getTotalInvitePoint(), pointSetting.getGetNewPoint()); - transferPoint += calculatePoint(pointSetting.getGetRegisPointGift(), appUser.getTotalRegisterPoint(), pointSetting.getRegisPoint()); - transferPoint += calculatePoint(pointSetting.getWorkPointGift(), appUser.getTotalSharePoint() + appUser.getTotalSignPoint() + appUser.getTotalHourPoint(), pointSetting.getWorkPoint()); - - return transferPoint; - } - - private long calculatePoint(Integer settingValue, double userValue, double pointValue) { - if (settingValue == 1) { - try { - double result = userValue * (pointValue / 100.0); - return Math.round(result); - } catch (ArithmeticException e) { - return 0; - } - } - return 0; - } - @Override -- Gitblit v1.7.1