@@ -0,0 +1,42 @@
|
||||
package userser
|
||||
|
||||
import (
|
||||
"91porn-server/models/v/advanceordermod"
|
||||
"errors"
|
||||
)
|
||||
|
||||
const (
|
||||
TypeCoinVideo = "coinVideo"
|
||||
TypeLuckDraw = "luckDraw"
|
||||
TypeAiUndress = "aiUndress"
|
||||
TypeDownload = "download"
|
||||
)
|
||||
|
||||
type ConsumeReq struct {
|
||||
PrivilegeType string `form:"privilegeType" json:"privilegeType" binding:"required"` // coinVideo:金币视频 luckDraw:抽奖 aiUndress:AI脱衣 download:下载
|
||||
Count int64 `form:"count" json:"count" binding:"required"`
|
||||
}
|
||||
|
||||
// Consume 消费预付权益次数
|
||||
func Consume(uid uint64, privilegeType string, count int64) error {
|
||||
if count < 1 {
|
||||
return errors.New("debit count illegal")
|
||||
}
|
||||
|
||||
debitPlan := advanceordermod.DebitPlan{}
|
||||
switch privilegeType {
|
||||
case TypeCoinVideo:
|
||||
debitPlan.CoinVideoCount = &count
|
||||
//case TypeLuckDraw:
|
||||
// debitPlan.LuckyDrawCount = &count
|
||||
//case TypeAiUndress:
|
||||
// debitPlan.AiUndressCount = &count
|
||||
case TypeDownload:
|
||||
debitPlan.DownloadCount = &count
|
||||
default:
|
||||
return errors.New("debit type illegal")
|
||||
}
|
||||
|
||||
err := advanceordermod.Debit(nil, uid, debitPlan)
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user