mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 07:11:52 +08:00
营销活动:完善 review 提到的问题
This commit is contained in:
parent
ec27a1bae5
commit
6723cae781
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.framework.common.enums;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
@ -34,4 +35,12 @@ public enum CommonStatusEnum implements IntArrayValuable {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
public static boolean isEnable(Integer status) {
|
||||
return ObjUtil.equal(ENABLE.status, status);
|
||||
}
|
||||
|
||||
public static boolean isDisable(Integer status) {
|
||||
return ObjUtil.equal(DISABLE.status, status);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -59,6 +59,15 @@ public class BargainActivityController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/close")
|
||||
@Operation(summary = "关闭砍价活动")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('promotion:bargain-activity:close')")
|
||||
public CommonResult<Boolean> closeSeckillActivity(@RequestParam("id") Long id) {
|
||||
bargainActivityService.closeBargainActivityById(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除砍价活动")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
|
@ -59,6 +59,15 @@ public class CombinationActivityController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/close")
|
||||
@Operation(summary = "关闭拼团活动")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('promotion:combination-activity:close')")
|
||||
public CommonResult<Boolean> closeSeckillActivity(@RequestParam("id") Long id) {
|
||||
combinationActivityService.closeCombinationActivityById(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除拼团活动")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
|
@ -5,8 +5,6 @@ import cn.iocoder.yudao.module.promotion.controller.app.banner.vo.AppBannerRespV
|
||||
import cn.iocoder.yudao.module.promotion.convert.banner.BannerConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.banner.BannerDO;
|
||||
import cn.iocoder.yudao.module.promotion.service.banner.BannerService;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -14,11 +12,9 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsyncReloadingCache;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/promotion/banner")
|
||||
@ -26,20 +22,6 @@ import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsync
|
||||
@Validated
|
||||
public class AppBannerController {
|
||||
|
||||
// TODO @puhui999:这个目前不缓存,也没问题,因为首页没用到。
|
||||
/**
|
||||
* {@link AppBannerRespVO} 缓存,通过它异步刷新 {@link #getBannerList0(Integer)} 所要的首页数据
|
||||
*/
|
||||
private final LoadingCache<Integer, List<AppBannerRespVO>> bannerListCache = buildAsyncReloadingCache(Duration.ofSeconds(10L),
|
||||
new CacheLoader<Integer, List<AppBannerRespVO>>() {
|
||||
|
||||
@Override
|
||||
public List<AppBannerRespVO> load(Integer position) {
|
||||
return getBannerList0(position);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@Resource
|
||||
private BannerService bannerService;
|
||||
|
||||
@ -47,12 +29,8 @@ public class AppBannerController {
|
||||
@Operation(summary = "获得 banner 列表")
|
||||
@Parameter(name = "position", description = "Banner position", example = "1")
|
||||
public CommonResult<List<AppBannerRespVO>> getBannerList(@RequestParam("position") Integer position) {
|
||||
return success(bannerListCache.getUnchecked(position));
|
||||
}
|
||||
|
||||
private List<AppBannerRespVO> getBannerList0(Integer position) {
|
||||
List<BannerDO> bannerList = bannerService.getBannerListByPosition(position);
|
||||
return BannerConvert.INSTANCE.convertList01(bannerList);
|
||||
return success(BannerConvert.INSTANCE.convertList01(bannerList));
|
||||
}
|
||||
|
||||
@PutMapping("/add-browse-count")
|
||||
|
@ -6,13 +6,12 @@ import cn.iocoder.yudao.module.promotion.enums.banner.BannerPositionEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
// TODO @puhui999:表名改成 promotion_banner,然后有序加下;另外,sql 给我下哈;还有那个 position 字典,嘿嘿。
|
||||
/**
|
||||
* banner DO
|
||||
*
|
||||
* @author xia
|
||||
*/
|
||||
@TableName("market_banner")
|
||||
@TableName("promotion_banner")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
|
@ -45,6 +45,13 @@ public interface BargainActivityService {
|
||||
*/
|
||||
void updateBargainActivityStock(Long id, Integer count);
|
||||
|
||||
/**
|
||||
* 关闭砍价活动
|
||||
*
|
||||
* @param id 砍价活动编号
|
||||
*/
|
||||
void closeBargainActivityById(Long id);
|
||||
|
||||
/**
|
||||
* 删除砍价活动
|
||||
*
|
||||
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.promotion.service.bargain;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
@ -96,6 +95,19 @@ public class BargainActivityServiceImpl implements BargainActivityService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void closeBargainActivityById(Long id) {
|
||||
// 校验砍价活动是否存在
|
||||
BargainActivityDO activity = validateBargainActivityExists(id);
|
||||
if (CommonStatusEnum.isDisable(activity.getStatus())) {
|
||||
throw exception(BARGAIN_ACTIVITY_STATUS_DISABLE);
|
||||
}
|
||||
|
||||
bargainActivityMapper.updateById(new BargainActivityDO().setId(id)
|
||||
.setStatus(CommonStatusEnum.DISABLE.getStatus()));
|
||||
}
|
||||
|
||||
private void validateBargainConflict(Long spuId, Long activityId) {
|
||||
// 查询所有开启的砍价活动
|
||||
List<BargainActivityDO> activityList = bargainActivityMapper.selectListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
@ -121,7 +133,7 @@ public class BargainActivityServiceImpl implements BargainActivityService {
|
||||
// 校验存在
|
||||
BargainActivityDO activityDO = validateBargainActivityExists(id);
|
||||
// 校验状态
|
||||
if (ObjectUtil.equal(activityDO.getStatus(), CommonStatusEnum.ENABLE.getStatus())) {
|
||||
if (CommonStatusEnum.isEnable(activityDO.getStatus())) {
|
||||
throw exception(BARGAIN_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END);
|
||||
}
|
||||
|
||||
@ -153,7 +165,7 @@ public class BargainActivityServiceImpl implements BargainActivityService {
|
||||
if (activity == null) {
|
||||
throw exception(BARGAIN_ACTIVITY_NOT_EXISTS);
|
||||
}
|
||||
if (ObjUtil.notEqual(activity.getStatus(), CommonStatusEnum.ENABLE.getStatus())) {
|
||||
if (CommonStatusEnum.isDisable(activity.getStatus())) {
|
||||
throw exception(BARGAIN_ACTIVITY_STATUS_CLOSED);
|
||||
}
|
||||
if (activity.getStock() <= 0) {
|
||||
|
@ -36,7 +36,12 @@ public interface CombinationActivityService {
|
||||
*/
|
||||
void updateCombinationActivity(@Valid CombinationActivityUpdateReqVO updateReqVO);
|
||||
|
||||
// TODO @puhui999:这里少了一个关闭活动的接口;因为关闭的活动,才可以删除
|
||||
/**
|
||||
* 关闭拼团活动
|
||||
*
|
||||
* @param id 拼团活动编号
|
||||
*/
|
||||
void closeCombinationActivityById(Long id);
|
||||
|
||||
/**
|
||||
* 删除拼团活动
|
||||
|
@ -138,6 +138,20 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic
|
||||
updateCombinationProduct(updateObj, updateReqVO.getProducts());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void closeCombinationActivityById(Long id) {
|
||||
// 校验活动是否存在
|
||||
CombinationActivityDO activity = validateCombinationActivityExists(id);
|
||||
if (CommonStatusEnum.isDisable(activity.getStatus())) {
|
||||
throw exception(COMBINATION_ACTIVITY_STATUS_DISABLE_NOT_UPDATE);
|
||||
}
|
||||
|
||||
// 关闭活动
|
||||
combinationActivityMapper.updateById(new CombinationActivityDO().setId(id)
|
||||
.setStatus(CommonStatusEnum.DISABLE.getStatus()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新拼团商品
|
||||
*
|
||||
@ -172,9 +186,9 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteCombinationActivity(Long id) {
|
||||
// 校验存在
|
||||
CombinationActivityDO activityDO = validateCombinationActivityExists(id);
|
||||
CombinationActivityDO activity = validateCombinationActivityExists(id);
|
||||
// 校验状态
|
||||
if (ObjectUtil.equal(activityDO.getStatus(), CommonStatusEnum.ENABLE.getStatus())) {
|
||||
if (CommonStatusEnum.isEnable(activity.getStatus())) {
|
||||
throw exception(COMBINATION_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END);
|
||||
}
|
||||
|
||||
|
@ -147,8 +147,8 @@ public class DiscountActivityServiceImpl implements DiscountActivityService {
|
||||
@Override
|
||||
public void deleteDiscountActivity(Long id) {
|
||||
// 校验存在
|
||||
DiscountActivityDO discountActivity = validateDiscountActivityExists(id);
|
||||
if (!discountActivity.getStatus().equals(CommonStatusEnum.ENABLE.getStatus())) { // 未关闭的活动,不能删除噢
|
||||
DiscountActivityDO activity = validateDiscountActivityExists(id);
|
||||
if (CommonStatusEnum.isEnable(activity.getStatus())) { // 未关闭的活动,不能删除噢
|
||||
throw exception(DISCOUNT_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED);
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
||||
public SeckillValidateJoinRespDTO validateJoinSeckill(Long activityId, Long skuId, Integer count) {
|
||||
// 1.1 校验秒杀活动是否存在
|
||||
SeckillActivityDO activity = validateSeckillActivityExists(activityId);
|
||||
if (ObjectUtil.notEqual(activity.getStatus(), CommonStatusEnum.ENABLE.getStatus())) {
|
||||
if (CommonStatusEnum.isDisable(activity.getStatus())) {
|
||||
throw exception(SECKILL_JOIN_ACTIVITY_STATUS_CLOSED);
|
||||
}
|
||||
// 1.2 是否在活动时间范围内
|
||||
|
@ -12,8 +12,7 @@ import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -44,31 +43,33 @@ public interface MemberSignInRecordConvert {
|
||||
|
||||
AppMemberSignInRecordRespVO coverRecordToAppRecordVo(MemberSignInRecordDO memberSignInRecordDO);
|
||||
|
||||
default MemberSignInRecordDO convert(Long userId, MemberSignInRecordDO firstRecord, List<MemberSignInConfigDO> signInConfigs) {
|
||||
// 1. 计算今天是第几天签到
|
||||
long day = ChronoUnit.DAYS.between(firstRecord.getCreateTime(), LocalDateTime.now());
|
||||
// 2. 初始化签到信息
|
||||
// TODO @puhui999:signInRecord=》record
|
||||
MemberSignInRecordDO signInRecord = new MemberSignInRecordDO().setUserId(userId)
|
||||
.setDay(Integer.parseInt(Long.toString(day))) // 设置签到天数 TODO @puhui999:day 应该跟着第几天签到走;不是累加哈;另外 long 转 int,应该 (int) day 就可以了。。。
|
||||
.setPoint(0) // 设置签到积分默认为
|
||||
default MemberSignInRecordDO convert(Long userId, MemberSignInRecordDO lastRecord, List<MemberSignInConfigDO> signInConfigs) {
|
||||
// 1. 获取最大签到天数积分配置
|
||||
signInConfigs.sort(Comparator.comparing(MemberSignInConfigDO::getDay));
|
||||
MemberSignInConfigDO lastConfig = signInConfigs.get(signInConfigs.size() - 1); // 最大签到天数配置
|
||||
// 1.2. 计算今天是第几天签到
|
||||
int day = 1;
|
||||
if (lastRecord != null) {
|
||||
day = lastRecord.getDay() + 1;
|
||||
}
|
||||
// 1.3 判断是否超出了最大签到配置
|
||||
if (day > lastConfig.getDay()) {
|
||||
day = 1; // 超过最大配置的天数,重置到第一天。(也就是说开启下一轮签到)
|
||||
}
|
||||
// 1.4 初始化签到信息
|
||||
MemberSignInRecordDO record = new MemberSignInRecordDO().setUserId(userId)
|
||||
.setDay(day) // 设置签到天数
|
||||
.setPoint(0) // 设置签到积分默认为 0
|
||||
.setExperience(0); // 设置签到经验默认为 0
|
||||
// 3. 获取签到对应的积分数
|
||||
MemberSignInConfigDO lastConfig = signInConfigs.get(signInConfigs.size() - 1); // 最大签到天数
|
||||
if (day > lastConfig.getDay()) { // 超出范围按第一天的经验计算
|
||||
// TODO @puhui999:不能直接取 0,万一它 day 不匹配哈。就是第一天没奖励。。。
|
||||
signInRecord.setPoint(signInConfigs.get(0).getPoint());
|
||||
signInRecord.setExperience(signInConfigs.get(0).getExperience());
|
||||
return signInRecord;
|
||||
|
||||
// 2. 获取签到对应的积分
|
||||
MemberSignInConfigDO config = CollUtil.findOne(signInConfigs, item -> ObjUtil.equal(item.getDay(), record.getDay()));
|
||||
if (config == null) {
|
||||
return record;
|
||||
}
|
||||
// TODO @puhui999:signInConfig 可以改成 config;
|
||||
MemberSignInConfigDO signInConfig = CollUtil.findOne(signInConfigs, config -> ObjUtil.equal(config.getDay(), day));
|
||||
if (signInConfig == null) {
|
||||
return signInRecord;
|
||||
}
|
||||
signInRecord.setPoint(signInConfig.getPoint());
|
||||
signInRecord.setExperience(signInConfig.getExperience());
|
||||
return signInRecord;
|
||||
record.setPoint(config.getPoint());
|
||||
record.setExperience(config.getExperience());
|
||||
return record;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,50 +35,31 @@ public interface MemberSignInRecordMapper extends BaseMapperX<MemberSignInRecord
|
||||
.orderByDesc(MemberSignInRecordDO::getId));
|
||||
}
|
||||
|
||||
// TODO @puhui999:这 2 个方法,是不是一个 first;一个 last 就可以了。。
|
||||
/**
|
||||
* 获取用户最近的签到记录信息,根据签到时间倒序
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @return 签到记录列表
|
||||
*/
|
||||
default MemberSignInRecordDO selectLastRecordByUserIdDesc(Long userId) {
|
||||
default MemberSignInRecordDO selectLastRecordByUserId(Long userId) {
|
||||
return selectOne(new QueryWrapper<MemberSignInRecordDO>()
|
||||
.eq("user_id", userId)
|
||||
.orderByDesc("create_time")
|
||||
.last("limit 1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户最早的签到记录信息,根据签到时间倒序
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @return 签到记录列表
|
||||
*/
|
||||
default MemberSignInRecordDO selectLastRecordByUserIdAsc(Long userId) {
|
||||
return selectOne(new QueryWrapper<MemberSignInRecordDO>()
|
||||
.eq("user_id", userId)
|
||||
.orderByAsc("create_time")
|
||||
.last("limit 1"));
|
||||
}
|
||||
|
||||
default Long selectCountByUserId(Long userId) {
|
||||
// TODO @puhui999:可以使用 selectCount 里面允许传递字段的方法
|
||||
return selectCount(new LambdaQueryWrapperX<MemberSignInRecordDO>()
|
||||
.eq(MemberSignInRecordDO::getUserId, userId));
|
||||
return selectCount(MemberSignInRecordDO::getUserId, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户的签到记录列表信息,根据签到时间倒序
|
||||
* 获取用户的签到记录列表信息
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @return 签到记录信息
|
||||
*/
|
||||
// TODO @puhui999:这个排序,可以交给 service 哈;
|
||||
default List<MemberSignInRecordDO> selectListByUserId(Long userId) {
|
||||
return selectList(new LambdaQueryWrapperX<MemberSignInRecordDO>()
|
||||
.eq(MemberSignInRecordDO::getUserId, userId)
|
||||
.orderByDesc(MemberSignInRecordDO::getCreateTime));
|
||||
return selectList(MemberSignInRecordDO::getUserId, userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,36 +58,37 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService
|
||||
@Override
|
||||
public AppMemberSignInRecordSummaryRespVO getSignInRecordSummary(Long userId) {
|
||||
// 1. 初始化默认返回信息
|
||||
// TODO @puhui999:这里 vo 改成 summary 会更好理解;
|
||||
AppMemberSignInRecordSummaryRespVO vo = new AppMemberSignInRecordSummaryRespVO();
|
||||
vo.setTotalDay(0);
|
||||
vo.setContinuousDay(0);
|
||||
vo.setTodaySignIn(false);
|
||||
AppMemberSignInRecordSummaryRespVO summary = new AppMemberSignInRecordSummaryRespVO();
|
||||
summary.setTotalDay(0);
|
||||
summary.setContinuousDay(0);
|
||||
summary.setTodaySignIn(false);
|
||||
|
||||
// 2. 获取用户签到的记录数
|
||||
Long signCount = signInRecordMapper.selectCountByUserId(userId);
|
||||
if (ObjUtil.equal(signCount, 0L)) {
|
||||
return vo;
|
||||
return summary;
|
||||
}
|
||||
vo.setTotalDay(signCount.intValue()); // 设置总签到天数
|
||||
summary.setTotalDay(signCount.intValue()); // 设置总签到天数
|
||||
|
||||
// 3. 校验当天是否有签到
|
||||
// TODO @puhui999:是不是 signInRecord 可以精简成 record 哈;另外,Desc 貌似可以去掉哈;最后一条了;
|
||||
MemberSignInRecordDO signInRecord = signInRecordMapper.selectLastRecordByUserIdDesc(userId);
|
||||
if (signInRecord == null) {
|
||||
return vo;
|
||||
MemberSignInRecordDO lastRecord = signInRecordMapper.selectLastRecordByUserId(userId);
|
||||
if (lastRecord == null) {
|
||||
return summary;
|
||||
}
|
||||
vo.setTodaySignIn(DateUtils.isToday(signInRecord.getCreateTime()));
|
||||
summary.setTodaySignIn(DateUtils.isToday(lastRecord.getCreateTime()));
|
||||
|
||||
// 4. 校验今天是否签到,没有签到则直接返回
|
||||
if (!vo.getTodaySignIn()) {
|
||||
return vo;
|
||||
if (!summary.getTodaySignIn()) {
|
||||
return summary;
|
||||
}
|
||||
// 4.1. 判断连续签到天数
|
||||
// TODO @puhui999:连续签到,可以基于 signInRecord 的 day 和当前时间判断呀?
|
||||
// TODO @puhui999:连续签到,可以基于 lastRecord 的 day 和当前时间判断呀?按 day 统计连续签到天数可能不准确
|
||||
// 1. day 只是记录第几天签到的有可能不连续,比如第一次签到是周一,第二次签到是周三这样 lastRecord 的 day 为 2 但是并不是连续的两天
|
||||
// 2. day 超出签到规则的最大天数会重置到从第一天开始签到(我理解为开始下一轮,类似一周签到七天七天结束下周又从周一开始签到)
|
||||
List<MemberSignInRecordDO> signInRecords = signInRecordMapper.selectListByUserId(userId);
|
||||
vo.setContinuousDay(calculateConsecutiveDays(signInRecords));
|
||||
return vo;
|
||||
signInRecords.sort(Comparator.comparing(MemberSignInRecordDO::getCreateTime).reversed()); // 根据签到时间倒序
|
||||
summary.setContinuousDay(calculateConsecutiveDays(signInRecords));
|
||||
return summary;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,17 +145,14 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public MemberSignInRecordDO createSignRecord(Long userId) {
|
||||
// 1. 获取当前用户最近的签到
|
||||
MemberSignInRecordDO lastRecord = signInRecordMapper.selectLastRecordByUserIdDesc(userId);
|
||||
MemberSignInRecordDO lastRecord = signInRecordMapper.selectLastRecordByUserId(userId);
|
||||
// 1.1. 判断是否重复签到
|
||||
validateSigned(lastRecord);
|
||||
|
||||
// 2. 获取当前用户最早的一次前端记录,用于计算今天是第几天签到
|
||||
MemberSignInRecordDO firstRecord = signInRecordMapper.selectLastRecordByUserIdAsc(userId);
|
||||
// 2.1. 获取所有的签到规则
|
||||
List<MemberSignInConfigDO> signInConfigs = signInConfigService.getSignInConfigList(CommonStatusEnum.ENABLE.getStatus());
|
||||
signInConfigs.sort(Comparator.comparing(MemberSignInConfigDO::getDay));
|
||||
// 2.2. 组合数据
|
||||
MemberSignInRecordDO record = MemberSignInRecordConvert.INSTANCE.convert(userId, firstRecord, signInConfigs);
|
||||
MemberSignInRecordDO record = MemberSignInRecordConvert.INSTANCE.convert(userId, lastRecord, signInConfigs);
|
||||
|
||||
// 3. 插入签到记录
|
||||
signInRecordMapper.insert(record);
|
||||
|
@ -23,10 +23,10 @@ import cn.iocoder.yudao.module.system.service.member.MemberService;
|
||||
import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService;
|
||||
import cn.iocoder.yudao.module.system.service.social.SocialUserService;
|
||||
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.xingyuv.captcha.model.common.ResponseModel;
|
||||
import com.xingyuv.captcha.model.vo.CaptchaVO;
|
||||
import com.xingyuv.captcha.service.CaptchaService;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -85,7 +85,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
||||
throw exception(AUTH_LOGIN_BAD_CREDENTIALS);
|
||||
}
|
||||
// 校验是否禁用
|
||||
if (ObjectUtil.notEqual(user.getStatus(), CommonStatusEnum.ENABLE.getStatus())) {
|
||||
if (CommonStatusEnum.isDisable(user.getStatus())) {
|
||||
createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.USER_DISABLED);
|
||||
throw exception(AUTH_LOGIN_USER_DISABLED);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public class OAuth2ClientServiceImpl implements OAuth2ClientService {
|
||||
if (client == null) {
|
||||
throw exception(OAUTH2_CLIENT_NOT_EXISTS);
|
||||
}
|
||||
if (ObjectUtil.notEqual(client.getStatus(), CommonStatusEnum.ENABLE.getStatus())) {
|
||||
if (CommonStatusEnum.isDisable(client.getStatus())) {
|
||||
throw exception(OAUTH2_CLIENT_DISABLE);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ import org.springframework.util.Assert;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -144,7 +143,7 @@ public class SmsTemplateServiceImpl implements SmsTemplateService {
|
||||
if (channelDO == null) {
|
||||
throw exception(SMS_CHANNEL_NOT_EXISTS);
|
||||
}
|
||||
if (!Objects.equals(channelDO.getStatus(), CommonStatusEnum.ENABLE.getStatus())) {
|
||||
if (CommonStatusEnum.isDisable(channelDO.getStatus())) {
|
||||
throw exception(SMS_CHANNEL_DISABLE);
|
||||
}
|
||||
return channelDO;
|
||||
|
Loading…
Reference in New Issue
Block a user