This commit is contained in:
zpc 2026-02-04 01:12:01 +08:00
parent ae169a6785
commit c61f7fc3c3
3 changed files with 61 additions and 30 deletions

View File

@ -535,13 +535,13 @@ export default {
} }
}, },
handleTabChange(index) { async handleTabChange(index) {
this.currentTab = index; this.currentTab = index;
// //
if (index === 1 && this.participantList.length > 0) { if (index === 1) {
this.animateListItems('participant-row'); await this.loadParticipants(this.goods_id);
} else if (index === 2 && this.awardRecordList.length > 0) { } else if (index === 2) {
this.animateListItems('award-row'); await this.loadAwardRecords(this.goods_id);
} }
}, },

View File

@ -238,61 +238,69 @@ public class WelfareController : ControllerBase
/// <summary> /// <summary>
/// 获取福利屋参与者列表 /// 获取福利屋参与者列表
/// POST /api/fuliwu_participants /// GET /api/fuliwu_participants
/// Requirements: 14.1
/// </summary> /// </summary>
[HttpPost("fuliwu_participants")] [HttpGet("fuliwu_participants")]
[Authorize] [Authorize]
public async Task<ApiResponse<List<ParticipantDto>>> GetParticipants([FromForm] ParticipantsRequest request) public async Task<ApiResponse<WelfareParticipantsResponse>> GetParticipants(
[FromQuery(Name = "goods_id")] int goodsId,
[FromQuery] int page = 1,
[FromQuery] int limit = 15)
{ {
var userId = GetCurrentUserId(); var userId = GetCurrentUserId();
if (userId == null) if (userId == null)
{ {
return ApiResponse<List<ParticipantDto>>.Unauthorized(); return ApiResponse<WelfareParticipantsResponse>.Unauthorized();
}
if (goodsId <= 0)
{
return ApiResponse<WelfareParticipantsResponse>.Fail("商品ID不能为空");
} }
try try
{ {
var result = await _welfareService.GetParticipantsAsync( var result = await _welfareService.GetParticipantsAsync(goodsId, page, limit);
request.GoodsId, return ApiResponse<WelfareParticipantsResponse>.Success(new WelfareParticipantsResponse { List = result });
request.Page,
request.Limit);
return ApiResponse<List<ParticipantDto>>.Success(result);
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Failed to get participants: GoodsId={GoodsId}", request.GoodsId); _logger.LogError(ex, "Failed to get participants: GoodsId={GoodsId}", goodsId);
return ApiResponse<List<ParticipantDto>>.Fail("获取参与者列表失败"); return ApiResponse<WelfareParticipantsResponse>.Fail("获取参与者列表失败");
} }
} }
/// <summary> /// <summary>
/// 获取福利屋开奖记录 /// 获取福利屋开奖记录
/// POST /api/fuliwu_records /// GET /api/fuliwu_records
/// Requirements: 14.2
/// </summary> /// </summary>
[HttpPost("fuliwu_records")] [HttpGet("fuliwu_records")]
[Authorize] [Authorize]
public async Task<ApiResponse<List<WinningRecordDto>>> GetWinningRecords([FromForm] WinningRecordsRequest request) public async Task<ApiResponse<WelfareRecordsResponse>> GetWinningRecords(
[FromQuery(Name = "goods_id")] int goodsId,
[FromQuery] int page = 1,
[FromQuery] int limit = 15)
{ {
var userId = GetCurrentUserId(); var userId = GetCurrentUserId();
if (userId == null) if (userId == null)
{ {
return ApiResponse<List<WinningRecordDto>>.Unauthorized(); return ApiResponse<WelfareRecordsResponse>.Unauthorized();
}
if (goodsId <= 0)
{
return ApiResponse<WelfareRecordsResponse>.Fail("商品ID不能为空");
} }
try try
{ {
var result = await _welfareService.GetWinningRecordsAsync( var result = await _welfareService.GetWinningRecordsAsync(goodsId, page, limit);
request.GoodsId, return ApiResponse<WelfareRecordsResponse>.Success(new WelfareRecordsResponse { List = result });
request.Page,
request.Limit);
return ApiResponse<List<WinningRecordDto>>.Success(result);
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Failed to get winning records: GoodsId={GoodsId}", request.GoodsId); _logger.LogError(ex, "Failed to get winning records: GoodsId={GoodsId}", goodsId);
return ApiResponse<List<WinningRecordDto>>.Fail("获取开奖记录失败"); return ApiResponse<WelfareRecordsResponse>.Fail("获取开奖记录失败");
} }
} }

View File

@ -629,3 +629,26 @@ public class FuliwuListResponse
/// </summary> /// </summary>
public int LastPage { get; set; } public int LastPage { get; set; }
} }
/// <summary>
/// 福利屋参与者列表响应
/// </summary>
public class WelfareParticipantsResponse
{
/// <summary>
/// 参与者列表
/// </summary>
public List<ParticipantDto> List { get; set; } = new();
}
/// <summary>
/// 福利屋开奖记录响应
/// </summary>
public class WelfareRecordsResponse
{
/// <summary>
/// 开奖记录列表
/// </summary>
public List<WinningRecordDto> List { get; set; } = new();
}