邹方成 45815bfb7d chore: 清理无用文件与优化代码结构
refactor(utils): 修复密码哈希比较逻辑错误
feat(user): 新增按状态筛选优惠券接口
docs: 添加虚拟发货与任务中心相关文档
fix(wechat): 修正Code2Session上下文传递问题
test: 补充订单折扣与积分转换测试用例
build: 更新配置文件与构建脚本
style: 清理多余的空行与注释
2025-12-18 17:35:55 +08:00

55 lines
1.8 KiB
Go

package activity
import (
"bindbox-game/internal/repository/mysql/dao"
"context"
)
// DeleteIssue 删除活动期
// 参数: issueID 期ID
// 返回: 错误信息
func (s *service) DeleteIssue(ctx context.Context, issueID int64) error {
return s.writeDB.Transaction(func(tx *dao.Query) error {
logs, err := tx.ActivityDrawLogs.WithContext(ctx).Where(tx.ActivityDrawLogs.IssueID.Eq(issueID)).Find()
if err != nil {
return err
}
var drawLogIDs []int64
for _, lg := range logs {
drawLogIDs = append(drawLogIDs, lg.ID)
}
if _, err = tx.ActivityRewardSettings.WithContext(ctx).Where(tx.ActivityRewardSettings.IssueID.Eq(issueID)).Delete(); err != nil {
return err
}
if _, err = tx.ActivityDrawEffects.WithContext(ctx).Where(tx.ActivityDrawEffects.IssueID.Eq(issueID)).Delete(); err != nil {
return err
}
if len(drawLogIDs) > 0 {
if _, err = tx.ActivityDrawEffects.WithContext(ctx).Where(tx.ActivityDrawEffects.DrawLogID.In(drawLogIDs...)).Delete(); err != nil {
return err
}
if _, err = tx.ActivityDrawReceipts.WithContext(ctx).Where(tx.ActivityDrawReceipts.DrawLogID.In(drawLogIDs...)).Delete(); err != nil {
return err
}
if _, err = tx.UserItemCards.WithContext(ctx).Where(tx.UserItemCards.UsedDrawLogID.In(drawLogIDs...)).Delete(); err != nil {
return err
}
}
if _, err = tx.UserItemCards.WithContext(ctx).Where(tx.UserItemCards.UsedIssueID.Eq(issueID)).Delete(); err != nil {
return err
}
if _, err = tx.SystemItemCards.WithContext(ctx).Where(tx.SystemItemCards.IssueID.Eq(issueID)).Delete(); err != nil {
return err
}
if _, err = tx.ActivityDrawLogs.WithContext(ctx).Where(tx.ActivityDrawLogs.IssueID.Eq(issueID)).Delete(); err != nil {
return err
}
if _, err = tx.ActivityIssues.WithContext(ctx).Where(tx.ActivityIssues.ID.Eq(issueID)).Delete(); err != nil {
return err
}
return nil
})
}