feat: 完成多模块功能迭代与优化
1. 新增宠物皮肤初始枚举值、下拉列表接口及相关DTO 2. 完善商品实体与DTO,新增虚拟商品标记和类型ID字段 3. 重构用户认证体系,支持多用户切换并重新生成JWT令牌 4. 新增签到配置管理全套功能,包括增删改查和状态管理 5. 优化模型验证过滤器和基础响应类的命名规范 6. 新增补签功能,完善签到服务逻辑 7. 拆分用户详情DTO,新增各子数据分页查询接口 8. 重构微信控制器的用户ID获取逻辑,统一使用激活用户ID 9. 修复背包服务中补签卡的扣减逻辑 10. 新增家长姓名修改接口和相关服务实现
This commit is contained in:
@ -82,7 +82,9 @@ public class CheckInService(
|
||||
GrowthPointsAwarded = growthReward,
|
||||
ConsecutiveDays = consecutiveDays,
|
||||
Type = CheckInRecordTypeEnum.Normal,
|
||||
Status = (int)CheckInRecordStatusEnum.Success
|
||||
Status = (int)CheckInRecordStatusEnum.Success,
|
||||
CreatedBy = userId.ToString(),
|
||||
UpdatedBy = userId.ToString()
|
||||
};
|
||||
var recordId = await checkInRecordRepository.Insertable(checkInRecord).ExecuteReturnIdentityAsync();
|
||||
checkInRecord.Id = recordId;
|
||||
@ -198,8 +200,8 @@ public class CheckInService(
|
||||
.Where(u => u.Id == userId && !u.IsDeleted)
|
||||
.FirstAsync();
|
||||
|
||||
// 最近 30 天签到记录
|
||||
var thirtyDaysAgo = today.AddDays(-29);
|
||||
// 最近 7 天签到记录
|
||||
var thirtyDaysAgo = today.AddDays(-6);
|
||||
var recentRecords = await checkInRecordRepository.Context.Queryable<CheckInRecord>()
|
||||
.Where(r => r.UserId == userId && !r.IsDeleted && r.CheckInDate >= thirtyDaysAgo)
|
||||
.OrderBy(r => r.CheckInDate, SqlSugar.OrderByType.Desc)
|
||||
@ -207,6 +209,7 @@ public class CheckInService(
|
||||
{
|
||||
Id = (long)r.Id,
|
||||
CheckInDate = r.CheckInDate,
|
||||
CreatedAt = r.CreatedAt,
|
||||
ConsecutiveDays = r.ConsecutiveDays,
|
||||
PointsAwarded = r.PointsAwarded,
|
||||
GrowthPointsAwarded = r.GrowthPointsAwarded,
|
||||
@ -247,6 +250,19 @@ public class CheckInService(
|
||||
if (alreadyCheckedIn)
|
||||
throw new BusinessException($"{targetDate:yyyy-MM-dd} 已签到,无需补签", 400);
|
||||
|
||||
// 检查用户背包中是否有补签卡
|
||||
var makeUpCard = await checkInRecordRepository.Context.Queryable<UserBag>()
|
||||
.Where(b => b.UserId == userId
|
||||
&& b.ItemType == "MakeUpCard"
|
||||
&& b.Quantity > 0
|
||||
&& b.Status == (int)UserBagStatusEnum.Available
|
||||
&& !b.IsDeleted)
|
||||
.OrderByDescending(b => b.CreatedAt)
|
||||
.FirstAsync();
|
||||
|
||||
if (makeUpCard == null)
|
||||
throw new BusinessException("补签卡不足,无法补签", 400);
|
||||
|
||||
// 查询用户信息
|
||||
var user = await checkInRecordRepository.Context.Queryable<Users>()
|
||||
.Where(u => u.Id == userId && !u.IsDeleted)
|
||||
@ -304,6 +320,25 @@ public class CheckInService(
|
||||
Description = $"补签奖励({targetDate:yyyy-MM-dd})"
|
||||
});
|
||||
|
||||
// 扣减补签卡
|
||||
if (makeUpCard.Quantity <= 1)
|
||||
{
|
||||
await checkInRecordRepository.Context.Updateable<UserBag>()
|
||||
.SetColumns(b => b.Status == (int)UserBagStatusEnum.Expired)
|
||||
.SetColumns(b => b.Quantity == 0)
|
||||
.SetColumns(b => b.UpdatedAt == DateTime.Now)
|
||||
.Where(b => b.Id == makeUpCard.Id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
await checkInRecordRepository.Context.Updateable<UserBag>()
|
||||
.SetColumns(b => b.Quantity == makeUpCard.Quantity - 1)
|
||||
.SetColumns(b => b.UpdatedAt == DateTime.Now)
|
||||
.Where(b => b.Id == makeUpCard.Id)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
result.RecordId = (long)recordId;
|
||||
result.CheckInDate = targetDate;
|
||||
result.ConsecutiveDays = 0;
|
||||
@ -344,7 +379,7 @@ public class CheckInService(
|
||||
/// <summary>
|
||||
/// 获取用户漏签日期列表
|
||||
/// </summary>
|
||||
public async Task<List<DateTime>> GetMissedDatesAsync(long userId, int days = 30)
|
||||
public async Task<List<DateTime>> GetMissedDatesAsync(long userId, int days = 7)
|
||||
{
|
||||
var startDate = DateTime.Now.Date.AddDays(-days);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user