Some checks failed
Build docker and publish / linux (1.24.5) (push) Failing after 50s
更新了前端构建产物包括JavaScript、CSS和HTML文件,主要涉及以下变更: 1. 新增了多个组件和工具函数,包括异常页面组件、iframe组件等 2. 更新了活动管理、产品管理、优惠券管理等业务模块 3. 优化了构建配置和依赖管理 4. 修复了一些样式和功能问题 5. 更新了测试相关文件 同时更新了部分后端服务接口和测试用例。这些变更主要是为了支持新功能和改进现有功能的用户体验。
288 lines
9.0 KiB
Go
288 lines
9.0 KiB
Go
package activity
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"bindbox-game/internal/pkg/logger"
|
|
"bindbox-game/internal/repository/mysql"
|
|
"bindbox-game/internal/repository/mysql/dao"
|
|
"bindbox-game/internal/repository/mysql/model"
|
|
)
|
|
|
|
type Service interface {
|
|
// CreateActivity 创建活动
|
|
// 参数: in 活动创建输入
|
|
// 返回: 活动记录与错误
|
|
CreateActivity(ctx context.Context, in CreateActivityInput) (*model.Activities, error)
|
|
// ModifyActivity 修改活动
|
|
// 参数: id 活动ID, in 修改输入
|
|
// 返回: 错误信息
|
|
ModifyActivity(ctx context.Context, id int64, in ModifyActivityInput) error
|
|
// DeleteActivity 删除活动
|
|
// 参数: id 活动ID
|
|
// 返回: 错误信息
|
|
DeleteActivity(ctx context.Context, id int64) error
|
|
// GetActivity 获取活动详情
|
|
// 参数: id 活动ID
|
|
// 返回: 活动记录与错误
|
|
GetActivity(ctx context.Context, id int64) (*model.Activities, error)
|
|
// ListActivities 活动列表
|
|
// 参数: in 列表查询输入
|
|
// 返回: 活动集合、总数与错误
|
|
ListActivities(ctx context.Context, in ListActivitiesInput) (items []*model.Activities, total int64, err error)
|
|
|
|
// ListIssues 活动期列表
|
|
// 参数: activityID 活动ID, page 页码, pageSize 每页数量
|
|
// 返回: 期列表、总数与错误
|
|
ListIssues(ctx context.Context, activityID int64, page, pageSize int) (items []*model.ActivityIssues, total int64, err error)
|
|
// CreateIssue 创建期
|
|
// 参数: activityID 活动ID, in 创建输入
|
|
// 返回: 期记录与错误
|
|
CreateIssue(ctx context.Context, activityID int64, in CreateIssueInput) (*model.ActivityIssues, error)
|
|
// ModifyIssue 修改期
|
|
// 参数: issueID 期ID, in 修改输入
|
|
// 返回: 错误信息
|
|
ModifyIssue(ctx context.Context, issueID int64, in ModifyIssueInput) error
|
|
// DeleteIssue 删除期
|
|
// 参数: issueID 期ID
|
|
// 返回: 错误信息
|
|
DeleteIssue(ctx context.Context, issueID int64) error
|
|
|
|
// CreateIssueRewards 批量创建期奖励
|
|
// 参数: issueID 期ID, rewards 奖励创建输入数组
|
|
// 返回: 错误信息
|
|
CreateIssueRewards(ctx context.Context, issueID int64, rewards []CreateRewardInput) error
|
|
// ListIssueRewards 查询期奖励列表
|
|
// 参数: issueID 期ID
|
|
// 返回: 奖励集合与错误
|
|
ListIssueRewards(ctx context.Context, issueID int64) (items []*model.ActivityRewardSettings, err error)
|
|
// ModifyIssueReward 修改单个奖励
|
|
// 参数: rewardID 奖励ID, in 修改输入
|
|
// 返回: 错误信息
|
|
ModifyIssueReward(ctx context.Context, rewardID int64, in ModifyRewardInput) error
|
|
// DeleteIssueReward 删除单个奖励
|
|
// 参数: rewardID 奖励ID
|
|
// 返回: 错误信息
|
|
DeleteIssueReward(ctx context.Context, rewardID int64) error
|
|
|
|
// ListDrawLogs 抽奖记录列表
|
|
// 参数: issueID 期ID, page/pageSize 分页
|
|
// 返回: 抽奖记录集合、总数与错误
|
|
ListDrawLogs(ctx context.Context, issueID int64, page, pageSize int) (items []*model.ActivityDrawLogs, total int64, err error)
|
|
|
|
// CommitIssueRandom 提交期随机承诺
|
|
// 参数: issueID 期ID
|
|
// 返回: 承诺对象与错误
|
|
CommitIssueRandom(ctx context.Context, issueID int64) (*IssueRandomCommitment, error)
|
|
// GetIssueRandomCommit 获取期随机承诺
|
|
// 参数: issueID 期ID
|
|
// 返回: 承诺对象与错误
|
|
GetIssueRandomCommit(ctx context.Context, issueID int64) (*IssueRandomCommitment, error)
|
|
// GetIssueRandomCommitHistory 获取期随机承诺历史
|
|
// 参数: issueID 期ID
|
|
// 返回: 承诺历史数组与错误
|
|
GetIssueRandomCommitHistory(ctx context.Context, issueID int64) ([]*IssueRandomCommitment, error)
|
|
|
|
// ExecuteDraw 执行抽奖
|
|
// 参数: issueID 期ID
|
|
// 返回: 抽奖收据与错误
|
|
ExecuteDraw(ctx context.Context, issueID int64) (*Receipt, error)
|
|
// ExecuteDrawWithEffects 执行抽奖并应用效果
|
|
// 参数: issueID 期ID, userID 用户ID
|
|
// 返回: 抽奖收据与错误
|
|
ExecuteDrawWithEffects(ctx context.Context, issueID int64, userID int64) (*Receipt, error)
|
|
|
|
// BatchDrawForUsers 批量为用户执行抽奖并写入日志与收据
|
|
// 参数: issueID 期ID, userIDs 用户ID数组
|
|
// 返回: 抽奖结果集合与错误
|
|
BatchDrawForUsers(ctx context.Context, issueID int64, userIDs []int64) ([]BatchDrawItem, error)
|
|
|
|
// GetDrawReceipt 通过抽奖ID查询收据
|
|
// 参数: drawID 抽奖ID
|
|
// 返回: 收据记录与错误
|
|
GetDrawReceipt(ctx context.Context, drawID int64) (*model.ActivityDrawReceipts, error)
|
|
// GetDrawReceiptByLogID 通过日志ID查询收据
|
|
// 参数: logID 日志ID
|
|
// 返回: 收据记录与错误
|
|
GetDrawReceiptByLogID(ctx context.Context, logID int64) (*model.ActivityDrawReceipts, error)
|
|
// GetCategoryNames 批量查询分类名称
|
|
// 参数: ids 分类ID数组
|
|
// 返回: id->名称映射与错误
|
|
GetCategoryNames(ctx context.Context, ids []int64) (map[int64]string, error)
|
|
|
|
// CopyActivity 复制活动及其期次与奖励
|
|
// 参数: activityID 源活动ID
|
|
// 返回: 新活动ID与错误
|
|
CopyActivity(ctx context.Context, activityID int64) (int64, error)
|
|
}
|
|
|
|
type IssueRandomCommitment struct {
|
|
AlgoVersion string
|
|
IssueID int64
|
|
ServerSeedMaster []byte
|
|
ServerSeedHash []byte
|
|
ItemsRoot []byte
|
|
WeightsTotal int64
|
|
StateVersion int32
|
|
}
|
|
|
|
type Receipt struct {
|
|
AlgoVersion string
|
|
RoundId int64
|
|
DrawId int64
|
|
ClientId int64
|
|
Timestamp int64
|
|
ServerSeedHash []byte
|
|
ServerSubSeed []byte
|
|
ClientSeed []byte
|
|
Nonce uint64
|
|
Items []ReceiptItem
|
|
ItemsRoot []byte
|
|
WeightsTotal uint64
|
|
SelectedIndex int
|
|
SelectedItemId int64
|
|
RandProof []byte
|
|
Signature []byte
|
|
}
|
|
|
|
type ReceiptItem struct {
|
|
ID int64
|
|
Name string
|
|
Weight int32
|
|
QuantityBefore int64
|
|
}
|
|
|
|
// BatchDrawItem 批量抽奖结果项
|
|
type BatchDrawItem struct {
|
|
UserID int64
|
|
DrawID int64
|
|
RewardID int64
|
|
RewardName string
|
|
IsWinner bool
|
|
Receipt *Receipt
|
|
}
|
|
|
|
type service struct {
|
|
logger logger.CustomLogger
|
|
readDB *dao.Query
|
|
writeDB *dao.Query
|
|
}
|
|
|
|
func New(l logger.CustomLogger, db mysql.Repo) Service {
|
|
return &service{
|
|
logger: l,
|
|
readDB: dao.Use(db.GetDbR()),
|
|
writeDB: dao.Use(db.GetDbW()),
|
|
}
|
|
}
|
|
|
|
type CreateActivityInput struct {
|
|
// Name 活动名称
|
|
Name string
|
|
// Banner 活动头图
|
|
Banner string
|
|
// ActivityCategoryID 活动分类ID
|
|
ActivityCategoryID int64
|
|
// Status 活动状态
|
|
Status int32
|
|
// PriceDraw 单次抽奖价格(分)
|
|
PriceDraw int64
|
|
// IsBoss 是否Boss活动
|
|
IsBoss int32
|
|
// StartTime 活动开始时间(可选)
|
|
StartTime *time.Time
|
|
// EndTime 活动结束时间(可选)
|
|
EndTime *time.Time
|
|
}
|
|
|
|
type ModifyActivityInput struct {
|
|
// Name 活动名称
|
|
Name string
|
|
// Banner 活动头图
|
|
Banner string
|
|
// ActivityCategoryID 活动分类ID
|
|
ActivityCategoryID int64
|
|
// Status 活动状态
|
|
Status int32
|
|
// PriceDraw 单次抽奖价格(分)
|
|
PriceDraw int64
|
|
// IsBoss 是否Boss活动
|
|
IsBoss int32
|
|
// StartTime 活动开始时间(可选)
|
|
StartTime *time.Time
|
|
// EndTime 活动结束时间(可选)
|
|
EndTime *time.Time
|
|
}
|
|
|
|
type ListActivitiesInput struct {
|
|
// Name 名称过滤
|
|
Name string
|
|
// CategoryID 分类过滤
|
|
CategoryID int64
|
|
// IsBoss Boss过滤
|
|
IsBoss *int32
|
|
// Status 状态过滤
|
|
Status *int32
|
|
// Page 页码
|
|
Page int
|
|
// PageSize 每页数量
|
|
PageSize int
|
|
}
|
|
|
|
type CreateIssueInput struct {
|
|
// IssueNumber 期号
|
|
IssueNumber string
|
|
// Status 状态
|
|
Status int32
|
|
// Sort 排序
|
|
Sort int32
|
|
}
|
|
|
|
type ModifyIssueInput struct {
|
|
// IssueNumber 期号
|
|
IssueNumber string
|
|
// Status 状态
|
|
Status int32
|
|
// Sort 排序
|
|
Sort int32
|
|
}
|
|
|
|
type CreateRewardInput struct {
|
|
// ProductID 商品ID
|
|
ProductID int64
|
|
// Name 奖励名称
|
|
Name string
|
|
// Weight 权重
|
|
Weight int32
|
|
// Quantity 数量(-1 表示不限)
|
|
Quantity int64
|
|
// OriginalQty 初始数量
|
|
OriginalQty int64
|
|
// Level 奖励等级
|
|
Level int32
|
|
// Sort 排序
|
|
Sort int32
|
|
// IsBoss 是否Boss奖励
|
|
IsBoss int32
|
|
}
|
|
|
|
type ModifyRewardInput struct {
|
|
// ProductID 商品ID
|
|
ProductID *int64
|
|
// Name 奖励名称
|
|
Name string
|
|
// Weight 权重
|
|
Weight *int32
|
|
// Quantity 数量(-1 表示不限)
|
|
Quantity *int64
|
|
// OriginalQty 初始数量
|
|
OriginalQty *int64
|
|
// Level 奖励等级
|
|
Level *int32
|
|
// Sort 排序
|
|
Sort *int32
|
|
// IsBoss 是否Boss奖励
|
|
IsBoss *int32
|
|
}
|