release- 修改头像自动判断老用户

release-2024-04-25
pikaqiudeshujia 4 days ago
parent d6f2a83d43
commit 8e99457934

@ -4,36 +4,24 @@ import annotation.GlobalInterceptor;
import api.PageResult; import api.PageResult;
import api.Result; import api.Result;
import com.luoo.user.dto.point.*; import com.luoo.user.dto.point.*;
import com.luoo.user.pojo.*; import com.luoo.user.pojo.Lottery;
import com.luoo.user.pojo.LotteryRegion;
import com.luoo.user.pojo.TaskPoint;
import com.luoo.user.service.DrawLotteryService; import com.luoo.user.service.DrawLotteryService;
import com.luoo.user.service.LotteryService; import com.luoo.user.service.LotteryService;
import com.luoo.user.service.TaskPointService; import com.luoo.user.service.TaskPointService;
import com.luoo.user.service.UserPointLogService; import com.luoo.user.service.UserPointLogService;
import com.luoo.user.vo.point.*; import com.luoo.user.vo.point.*;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import javax.annotation.Nullable;
import javax.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import javax.annotation.Nullable;
import org.springframework.web.bind.annotation.PostMapping; import javax.validation.constraints.NotNull;
import org.springframework.web.bind.annotation.RequestBody; import java.util.List;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @program: luoo_parent * @program: luoo_parent
@ -440,5 +428,12 @@ public class PointController {
return Result.success(); return Result.success();
} }
@ApiOperation(value = "4.1. 老用户已更换头像的直接发放积分", notes = "")
@PostMapping("/avatar/old")
public Result<Void> avatarOld() {
lotteryService.avatarOld();
return Result.success();
}
} }

@ -57,4 +57,7 @@ public interface UserInfoDao extends JpaRepository<UserInfo, String>, JpaSpecifi
@Query(value = "select * from tb_user_info where nick_name like ?1 limit 50", nativeQuery = true) @Query(value = "select * from tb_user_info where nick_name like ?1 limit 50", nativeQuery = true)
public List<UserInfo> getUserInfosByNickNameLikeLimit50(String nickName); public List<UserInfo> getUserInfosByNickNameLikeLimit50(String nickName);
@Query(value = "select * from tb_user_info where avatar != 'user/avatar/default.png'", nativeQuery = true)
public List<UserInfo> getOldUserListWhoIsAlreadyNewAvatar();
} }

@ -28,27 +28,12 @@ import enums.PointEnums;
import enums.UserTypeEnum; import enums.UserTypeEnum;
import enums.UserVipStatusEnum; import enums.UserVipStatusEnum;
import exception.BizException; import exception.BizException;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -56,6 +41,17 @@ import util.IdWorker;
import util.JwtUtil; import util.JwtUtil;
import util.RedisLockUtil; import util.RedisLockUtil;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
/** /**
* @program: luoo_parent * @program: luoo_parent
* @description: * @description:
@ -94,7 +90,9 @@ public class LotteryService {
private final UserinfoShippingAddressService userinfoShippingAddressService; private final UserinfoShippingAddressService userinfoShippingAddressService;
public LotteryService(LotteryDao lotteryDao, JwtUtil jwtUtil, IdWorker idWorker, RedisLockUtil redisLockUtil, RegionService regionService, LotteryRegionDao lotteryRegionDao, UserInfoDao userInfoDao, RabbitTemplate rabbitTemplate, LotteryUserDao lotteryUserDao, DrawLotteryScheduler drawLotteryScheduler, JPAQueryFactory jpaQueryFactory, EnvConfig envConfig, UserinfoShippingAddressService userinfoShippingAddressService) { private final UserPointLogService userPointLogService;
public LotteryService(LotteryDao lotteryDao, JwtUtil jwtUtil, IdWorker idWorker, RedisLockUtil redisLockUtil, RegionService regionService, LotteryRegionDao lotteryRegionDao, UserInfoDao userInfoDao, RabbitTemplate rabbitTemplate, LotteryUserDao lotteryUserDao, DrawLotteryScheduler drawLotteryScheduler, JPAQueryFactory jpaQueryFactory, EnvConfig envConfig, UserinfoShippingAddressService userinfoShippingAddressService, UserPointLogService userPointLogService) {
this.lotteryDao = lotteryDao; this.lotteryDao = lotteryDao;
this.jwtUtil = jwtUtil; this.jwtUtil = jwtUtil;
this.idWorker = idWorker; this.idWorker = idWorker;
@ -108,6 +106,7 @@ public class LotteryService {
this.jpaQueryFactory = jpaQueryFactory; this.jpaQueryFactory = jpaQueryFactory;
this.envConfig = envConfig; this.envConfig = envConfig;
this.userinfoShippingAddressService = userinfoShippingAddressService; this.userinfoShippingAddressService = userinfoShippingAddressService;
this.userPointLogService = userPointLogService;
} }
@ -905,4 +904,13 @@ public class LotteryService {
} }
} }
@Transactional(rollbackFor = Exception.class)
public void avatarOld() {
List<UserInfo> oldUserListWhoIsAlreadyNewAvatar = userInfoDao.getOldUserListWhoIsAlreadyNewAvatar();
oldUserListWhoIsAlreadyNewAvatar.forEach(userInfo -> {
log.info("用户:{},积分增加:{}", userInfo.getNickName(), TaskPointIdConstants.MODIFY_AVATAR);
userPointLogService.addByTaskDailyAndUserId(TaskPointIdConstants.MODIFY_AVATAR, userInfo.getId());
});
}
} }

@ -172,34 +172,39 @@ public class MemberShipService {
* @param one * @param one
*/ */
private void dealUserVipCalc(MembershipOrder one) { private void dealUserVipCalc(MembershipOrder one) {
// 处理用户表 try {
UserInfo userInfo = userInfoDao.findById(one.getUserId()).get(); // 处理用户表
UserInfo userInfo = userInfoDao.findById(one.getUserId()).get();
if (Objects.equals(userInfo.getVipStatus(), UserVipStatusEnum.INITIAL.getCode())) { if (Objects.equals(userInfo.getVipStatus(), UserVipStatusEnum.INITIAL.getCode())) {
// 首次开通会员 // 首次开通会员
userPointLogService.addByTaskDailyAndUserId(TaskPointIdConstants.BUY_MEMBER, one.getUserId()); userPointLogService.addByTaskDailyAndUserId(TaskPointIdConstants.BUY_MEMBER, one.getUserId());
} }
// 永久会员码 // 永久会员码
if (Objects.equals(one.getLife(), PointEnums.MEMBERSHIP_LIFE.getCode())) { if (Objects.equals(one.getLife(), PointEnums.MEMBERSHIP_LIFE.getCode())) {
userInfo.setVipStatus(UserVipStatusEnum.LIFE.getCode()); userInfo.setVipStatus(UserVipStatusEnum.LIFE.getCode());
} else {
// 非永久会员码
// 计算会员到期时间
LocalDate vipExpireTime;
if (Objects.equals(UserVipStatusEnum.ACTIVE.getCode(), userInfo.getVipStatus())) {
// 如果是当前正是会员以到期时间为基准再增加membershipCode的duration天
vipExpireTime = (userInfo.getVipExpireTime() == null ? LocalDate.now() : userInfo.getVipExpireTime()).plusDays(one.getDuration());
} else { } else {
// 如果是当前不是会员从今天开始增加membershipCode的duration天 // 非永久会员码
userInfo.setVipStatus(UserVipStatusEnum.INITIAL.getCode()); // 计算会员到期时间
vipExpireTime = LocalDate.now().plusDays(one.getDuration()); LocalDate vipExpireTime;
if (Objects.equals(UserVipStatusEnum.ACTIVE.getCode(), userInfo.getVipStatus())) {
// 如果是当前正是会员以到期时间为基准再增加membershipCode的duration天
vipExpireTime = (userInfo.getVipExpireTime() == null ? LocalDate.now() : userInfo.getVipExpireTime()).plusDays(one.getDuration());
} else {
// 如果是当前不是会员从今天开始增加membershipCode的duration天
userInfo.setVipStatus(UserVipStatusEnum.INITIAL.getCode());
vipExpireTime = LocalDate.now().plusDays(one.getDuration());
}
userInfo.setVipExpireTime(vipExpireTime);
// 无论如何当即设置为会员生效状态
userInfo.setVipStatus(UserVipStatusEnum.ACTIVE.getCode());
} }
userInfo.setVipExpireTime(vipExpireTime); userInfoDao.save(userInfo);
// 无论如何当即设置为会员生效状态 } catch (Exception e) {
userInfo.setVipStatus(UserVipStatusEnum.ACTIVE.getCode()); e.printStackTrace();
log.error("会员开通失败", e);
} }
userInfoDao.save(userInfo);
} }
/** /**

Loading…
Cancel
Save