refactor(utils): 修复密码哈希比较逻辑错误 feat(user): 新增按状态筛选优惠券接口 docs: 添加虚拟发货与任务中心相关文档 fix(wechat): 修正Code2Session上下文传递问题 test: 补充订单折扣与积分转换测试用例 build: 更新配置文件与构建脚本 style: 清理多余的空行与注释
43 lines
1.6 KiB
Go
43 lines
1.6 KiB
Go
package activity
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"time"
|
|
)
|
|
|
|
type DrawConfig struct {
|
|
PlayType string
|
|
DrawMode string
|
|
MinParticipants int64
|
|
IntervalMinutes int64
|
|
ScheduledTime *time.Time
|
|
RefundCouponID int64
|
|
}
|
|
|
|
func (s *service) SaveActivityDrawConfig(ctx context.Context, activityID int64, cfg DrawConfig) error {
|
|
st := sql.NullTime{}
|
|
if cfg.ScheduledTime != nil {
|
|
st = sql.NullTime{Time: cfg.ScheduledTime.UTC(), Valid: true}
|
|
}
|
|
return s.repo.GetDbW().Exec(
|
|
"UPDATE activities SET play_type=?, draw_mode=?, min_participants=?, interval_minutes=?, scheduled_time=?, refund_coupon_id=? WHERE id=?",
|
|
cfg.PlayType, cfg.DrawMode, cfg.MinParticipants, cfg.IntervalMinutes, st, cfg.RefundCouponID, activityID,
|
|
).Error
|
|
}
|
|
|
|
func (s *service) GetActivityDrawConfig(ctx context.Context, activityID int64) (*DrawConfig, error) {
|
|
var row struct {
|
|
PlayType string `gorm:"column:play_type"`
|
|
DrawMode string `gorm:"column:draw_mode"`
|
|
MinParticipants int64 `gorm:"column:min_participants"`
|
|
IntervalMinutes int64 `gorm:"column:interval_minutes"`
|
|
ScheduledTime *time.Time `gorm:"column:scheduled_time"`
|
|
RefundCouponID int64 `gorm:"column:refund_coupon_id"`
|
|
}
|
|
if err := s.repo.GetDbR().Raw("SELECT play_type, draw_mode, min_participants, interval_minutes, scheduled_time, refund_coupon_id FROM activities WHERE id=?", activityID).Scan(&row).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return &DrawConfig{PlayType: row.PlayType, DrawMode: row.DrawMode, MinParticipants: row.MinParticipants, IntervalMinutes: row.IntervalMinutes, ScheduledTime: row.ScheduledTime, RefundCouponID: row.RefundCouponID}, nil
|
|
}
|