Browse Source

抽奖

master
黄梓健 5 years ago
parent
commit
3c20b96588
  1. 12
      controllers/client/lottery.go
  2. 5
      models/lottery_draw_record.go
  3. 1
      utils/code/code.go

12
controllers/client/lottery.go

@ -4,6 +4,7 @@ import (
"github.com/ouxuanserver/osmanthuswine/src/core"
"hudongzhuanjia/controllers"
"hudongzhuanjia/models"
"hudongzhuanjia/utils/code"
)
type LotteryCtl struct {
@ -43,3 +44,14 @@ func (t *LotteryCtl) CashLottery() {
t.CheckErr(err)
t.SUCCESS("兑奖成功")
}
func (t *LotteryCtl) CheckLottery() {
uid := t.MustGetUID()
ladderId := t.MustGetInt64("lottery_draw_ladder_id")
record := new(models.LotteryDrawRecord)
exist, err := record.GetByUserIdAndLadderId(uid, ladderId)
t.CheckErr(err)
t.Assert(exist, code.MSG_LOTTERY_DRAW_NOT_HIT, "没有中奖")
t.JSON(record)
}

5
models/lottery_draw_record.go

@ -1,6 +1,7 @@
package models
import (
"github.com/ouxuanserver/osmanthuswine/src/core"
"time"
)
@ -30,3 +31,7 @@ type LotteryDrawRecord struct {
func (t *LotteryDrawRecord) TableName() string {
return LotteryDrawRecordTableName
}
func (t *LotteryDrawRecord) GetByUserIdAndLadderId(userId, ladderId interface{}) (bool, error) {
return core.GetXormAuto().Where("is_delete=0 and user_id=? and lottery_draw_rule_ladder_id=?", userId, ladderId).Get(t)
}

1
utils/code/code.go

@ -33,6 +33,7 @@ const (
MSG_CUSTOMER_ORDER_NOT_EXIST = 4007 // 客户订单不存在
MSG_CUSTOMER_ORDER_NO_PAY = 4008 // 订单未支付
MSG_CUSTOMER_ORDER_SEND = 4009 // 订单已发货
MSG_LOTTERY_DRAW_NOT_HIT = 4010 // 没有抽中奖
MSG_ORDER_NOT_EXIST = 5000 // 订单活动不存在
MSG_CUSTOMER_ORDER_ERROR = 5001 // 订单已完成
MSG_SIGN_UP_NOT_EXIST = 5000 // 签到规则不存在

Loading…
Cancel
Save