邹方成 e2782a69d3 feat: 添加对对碰游戏功能与Redis支持
refactor: 重构抽奖逻辑以支持可验证凭据
feat(redis): 集成Redis客户端并添加配置支持
fix: 修复订单取消时的优惠券和库存处理逻辑
docs: 添加对对碰游戏前端对接指南和示例JSON
test: 添加对对碰游戏模拟测试和验证逻辑
2025-12-21 17:31:32 +08:00

35 lines
910 B
Go

package activity
import (
"context"
"bindbox-game/internal/repository/mysql/dao"
"bindbox-game/internal/repository/mysql/model"
)
// CreateIssueRewards 批量创建期奖励
// 参数: issueID 期ID, rewards 奖励创建输入数组
// 返回: 错误信息
func (s *service) CreateIssueRewards(ctx context.Context, issueID int64, rewards []CreateRewardInput) error {
return s.writeDB.Transaction(func(tx *dao.Query) error {
for _, r := range rewards {
item := &model.ActivityRewardSettings{
IssueID: issueID,
ProductID: r.ProductID,
Name: r.Name,
Weight: r.Weight,
Quantity: r.Quantity,
OriginalQty: r.OriginalQty,
Level: r.Level,
Sort: r.Sort,
IsBoss: r.IsBoss,
MinScore: r.MinScore,
}
if err := tx.ActivityRewardSettings.WithContext(ctx).Create(item); err != nil {
return err
}
}
return nil
})
}