You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1549 lines
38 KiB
1549 lines
38 KiB
|
1 year ago
|
package handler
|
||
|
|
|
||
|
|
import (
|
||
|
|
"fmt"
|
||
|
|
"math/rand"
|
||
|
|
"server/call"
|
||
|
|
"server/common"
|
||
|
|
"server/config"
|
||
|
|
"server/db"
|
||
|
|
"server/modules/web/app"
|
||
|
|
"server/modules/web/values"
|
||
|
|
"server/util"
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
"github.com/liangdas/mqant/log"
|
||
|
|
"github.com/olivere/elastic/v7"
|
||
|
|
"gorm.io/gorm"
|
||
|
|
)
|
||
|
|
|
||
|
|
func GetPromotions(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
ret := &values.GetPromotionsResp{}
|
||
|
|
a.Data = ret
|
||
|
|
a.GetUID()
|
||
|
|
ret.ActivityList = call.GetConfigActivityActiveAll(a.UID)
|
||
|
|
ret.TaskList = a.GetUserTaskStatus()
|
||
|
|
}
|
||
|
|
|
||
|
|
func UploadActivityData(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
req := new(values.UploadActivityReq)
|
||
|
|
if !a.S(req) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
call.UploadActivityData(a.UID, req.ActivityID, common.ActivityDataClick, 0)
|
||
|
|
}
|
||
|
|
|
||
|
|
func GetAllActivity(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
ret := values.GetAllActivityResp{
|
||
|
|
List: call.GetConfigActivityActiveAll(a.UID),
|
||
|
|
}
|
||
|
|
a.Data = ret
|
||
|
|
}
|
||
|
|
|
||
|
|
func GetActivityAppSpinInfo(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDAppSpin) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := &values.ActivityAppSpinInfoResp{}
|
||
|
|
a.Data = resp
|
||
|
|
resp.List = call.GetConfigAppSpin()
|
||
|
|
}
|
||
|
|
|
||
|
|
func DrawActivityAppSpin(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDAppSpin) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
pd := call.GetPlayerData(a.UID)
|
||
|
|
if pd.LastAppSpinDraw > 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
total := 0
|
||
|
|
list := call.GetConfigAppSpin()
|
||
|
|
for _, v := range list {
|
||
|
|
total += v.Weight
|
||
|
|
}
|
||
|
|
weight := rand.Intn(total)
|
||
|
|
per := 0
|
||
|
|
var win *common.ConfigAppSpin
|
||
|
|
for _, v := range list {
|
||
|
|
per += v.Weight
|
||
|
|
if weight < per {
|
||
|
|
win = v
|
||
|
|
break
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if win == nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
rows, err := db.Mysql().UpdateResW(&common.PlayerData{}, map[string]interface{}{"last_app_spin_draw": time.Now().Unix()}, fmt.Sprintf("uid = %v and last_app_spin_draw = 0", a.UID))
|
||
|
|
if err != nil || rows == 0 {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
call.UpdateCurrencyPro(&common.UpdateCurrency{
|
||
|
|
CurrencyBalance: &common.CurrencyBalance{
|
||
|
|
UID: a.UID,
|
||
|
|
ChannelID: a.Channel,
|
||
|
|
Type: win.CurrencyType,
|
||
|
|
Value: win.Amount,
|
||
|
|
Event: common.CurrencyEventActivityAppSpin,
|
||
|
|
NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, win.Amount),
|
||
|
|
},
|
||
|
|
})
|
||
|
|
call.UploadActivityData(a.UID, common.ActivityIDAppSpin, common.ActivityDataJoin, win.Amount)
|
||
|
|
a.Data = values.ActivityAppSpinDrawResp{ID: win.ID}
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivityPddInfo(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDPDD) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
con := call.GetConfigActivityPdd()
|
||
|
|
if con == nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := &values.ActivityPddInfoResp{WithdrawAmount: con.WithdrawAmount, Spin: 1}
|
||
|
|
a.GetUID()
|
||
|
|
pddData := &common.PddData{UID: a.UID}
|
||
|
|
if pddData.UID > 0 {
|
||
|
|
pddData = call.GetAcitivityPddData(pddData.UID)
|
||
|
|
if pddData == nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp.Spin = pddData.Spin
|
||
|
|
resp.Amount = pddData.Amount
|
||
|
|
channel := call.GetChannelByID(a.Channel)
|
||
|
|
if channel != nil {
|
||
|
|
resp.ShareLink = channel.URL + "?code=" + call.GetShareInfo(a.UID).Share
|
||
|
|
}
|
||
|
|
resp.Expire = con.Expire*60 + pddData.Time - time.Now().Unix()
|
||
|
|
resp.NewPddShare = call.HasNewAcitivityPddShare(a.UID)
|
||
|
|
}
|
||
|
|
|
||
|
|
list := call.GetConfigActivityPddSpinByAmount(pddData.Amount)
|
||
|
|
for _, v := range list {
|
||
|
|
resp.Items = append(resp.Items, values.OnePddSpinItem{
|
||
|
|
ID: v.ID,
|
||
|
|
Type: v.Type,
|
||
|
|
Amount: v.Amount,
|
||
|
|
Sort: v.Sort,
|
||
|
|
})
|
||
|
|
}
|
||
|
|
a.Data = resp
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivityPddSpin(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDPDD) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
con := call.GetConfigActivityPdd()
|
||
|
|
if con == nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
pddData := call.GetAcitivityPddData(a.UID)
|
||
|
|
if pddData == nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
now := time.Now().Unix()
|
||
|
|
todaySpin := util.IsSameDayTimeStamp(now, pddData.FreeSpinTime)
|
||
|
|
if pddData.Spin <= 0 {
|
||
|
|
a.Code = values.CodeParam
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if pddData.Amount >= con.WithdrawAmount {
|
||
|
|
a.Code = values.CodeParam
|
||
|
|
a.Msg = "You can withdraw now."
|
||
|
|
return
|
||
|
|
}
|
||
|
|
items := call.GetConfigActivityPddSpinByAmount(pddData.Amount)
|
||
|
|
var bingo *common.ConfigActivityPddSpin
|
||
|
|
var amount int64
|
||
|
|
if pddData.Amount == 0 { // 第一次转
|
||
|
|
for _, v := range items {
|
||
|
|
if v.Type == common.ActivityPddItemTypeRandomCash {
|
||
|
|
bingo = v
|
||
|
|
break
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if bingo == nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
diff := con.AmountUp - con.AmountDown
|
||
|
|
if diff > 0 {
|
||
|
|
amount = rand.Int63n(con.AmountUp-con.AmountDown) + con.AmountDown
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
totalWeight := 0
|
||
|
|
for _, v := range items {
|
||
|
|
totalWeight += v.Weight
|
||
|
|
}
|
||
|
|
if totalWeight == 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
thisWeight := 0
|
||
|
|
rans := rand.Intn(totalWeight)
|
||
|
|
for _, v := range items {
|
||
|
|
thisWeight += v.Weight
|
||
|
|
if rans < thisWeight {
|
||
|
|
bingo = v
|
||
|
|
break
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if bingo == nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
amount = bingo.Amount
|
||
|
|
if bingo.Type == common.ActivityPddItemTypeRandomCash {
|
||
|
|
diff := bingo.CashUp - bingo.CashDown
|
||
|
|
if diff > 0 {
|
||
|
|
amount = rand.Int63n(diff) + bingo.CashDown
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if amount == 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
update := map[string]interface{}{}
|
||
|
|
sql := ""
|
||
|
|
// 今天旋转过则扣除已有旋转次数
|
||
|
|
if todaySpin {
|
||
|
|
update["spin"] = gorm.Expr("spin - 1")
|
||
|
|
sql = fmt.Sprintf("uid = %d and spin >= 1 and amount = %d", a.UID, pddData.Amount)
|
||
|
|
} else {
|
||
|
|
update["free_spin_time"] = now
|
||
|
|
sql = fmt.Sprintf("uid = %d and free_spin_time = %d ", a.UID, pddData.FreeSpinTime)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ok
|
||
|
|
switch bingo.Type {
|
||
|
|
case common.ActivityPddItemTypeFinish:
|
||
|
|
update["amount"] = con.WithdrawAmount
|
||
|
|
case common.ActivityPddItemTypeCash:
|
||
|
|
if pddData.Amount+amount > con.WithdrawAmount {
|
||
|
|
update["amount"] = con.WithdrawAmount
|
||
|
|
} else {
|
||
|
|
update["amount"] = gorm.Expr("amount + ?", amount)
|
||
|
|
}
|
||
|
|
case common.ActivityPddItemTypeRandomCash:
|
||
|
|
if pddData.Amount+amount > con.WithdrawAmount {
|
||
|
|
update["amount"] = con.WithdrawAmount
|
||
|
|
} else {
|
||
|
|
update["amount"] = gorm.Expr("amount + ?", amount)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
rows, err := db.Mysql().UpdateResW(&common.PddData{}, update, sql)
|
||
|
|
if err != nil {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if rows == 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := &values.ActivityPddSpinResp{
|
||
|
|
ID: bingo.Sort,
|
||
|
|
Amount: amount,
|
||
|
|
}
|
||
|
|
a.Data = resp
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivityPddWithdraw(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDPDD) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
con := call.GetConfigActivityPdd()
|
||
|
|
if con == nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
pddData := call.GetAcitivityPddData(a.UID)
|
||
|
|
if pddData == nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if pddData.Amount < con.WithdrawAmount {
|
||
|
|
a.Code = values.CodeParam
|
||
|
|
return
|
||
|
|
}
|
||
|
|
// 转走并重置玩家pdd活动
|
||
|
|
spinCount := 1
|
||
|
|
if !config.GetBase().Release {
|
||
|
|
spinCount = 100
|
||
|
|
}
|
||
|
|
rows, err := db.Mysql().UpdateResW(&common.PddData{}, map[string]interface{}{"amount": 0, "spin": spinCount, "time": time.Now().Unix(), "free_spin_time": 0},
|
||
|
|
fmt.Sprintf("uid = %d and amount >= %d", a.UID, con.WithdrawAmount))
|
||
|
|
if err != nil {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if rows == 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
call.UpdateCurrencyPro(&common.UpdateCurrency{
|
||
|
|
CurrencyBalance: &common.CurrencyBalance{
|
||
|
|
UID: a.UID,
|
||
|
|
Value: con.WithdrawAmount,
|
||
|
|
Type: common.CurrencyBrazil,
|
||
|
|
Event: common.CurrencyEventActivityPdd,
|
||
|
|
NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, con.WithdrawAmount),
|
||
|
|
},
|
||
|
|
})
|
||
|
|
call.UploadActivityData(a.UID, common.ActivityIDPDD, common.ActivityDataJoin, con.WithdrawAmount)
|
||
|
|
a.Data = values.ActivityPddWithdrawResp{ExpireTime: con.Expire * 60}
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivityPddNewReference(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDPDD) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
con := call.GetConfigActivityPdd()
|
||
|
|
if con == nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := &values.ActivityPddNewReferenceResp{}
|
||
|
|
a.Data = resp
|
||
|
|
pddData := call.GetAcitivityPddData(a.UID)
|
||
|
|
if pddData == nil {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
list := []common.ESPddRecord{}
|
||
|
|
q := elastic.NewBoolQuery()
|
||
|
|
t := pddData.Time
|
||
|
|
if pddData.NewRecordTime > 0 {
|
||
|
|
t = pddData.NewRecordTime
|
||
|
|
}
|
||
|
|
q.Filter(elastic.NewTermQuery("Referer", a.UID))
|
||
|
|
q.Filter(elastic.NewRangeQuery("Time").Gte(t))
|
||
|
|
db.ES().QueryList(common.ESIndexBackPddRecord, 0, 5000, q, &list, "Time", false)
|
||
|
|
for _, v := range list {
|
||
|
|
resp.List = append(resp.List, values.OnePddRecord{
|
||
|
|
UID: v.UID,
|
||
|
|
Avatar: v.Avatar,
|
||
|
|
Nick: v.Nick,
|
||
|
|
Time: v.Time,
|
||
|
|
SpinCount: 1,
|
||
|
|
})
|
||
|
|
}
|
||
|
|
resp.NewCount = len(list)
|
||
|
|
resp.NewSpinCount = len(list)
|
||
|
|
resp.SpinLeft = pddData.Spin
|
||
|
|
db.Mysql().Update(&common.PddData{UID: a.UID}, map[string]interface{}{"new_record_time": time.Now().Unix()})
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivityPddReference(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDPDD) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
req := new(values.ActivityPddReferenceReq)
|
||
|
|
if !a.S(req) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := &values.ActivityPddReferenceResp{}
|
||
|
|
a.Data = resp
|
||
|
|
pddData := call.GetAcitivityPddData(a.UID)
|
||
|
|
if pddData == nil {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
list := []common.ESPddRecord{}
|
||
|
|
q := elastic.NewBoolQuery()
|
||
|
|
q.Filter(elastic.NewRangeQuery("Time").Gte(pddData.Time))
|
||
|
|
db.ES().QueryList(common.ESIndexBackPddRecord, req.Page, req.Num, q, &list, "Time", false)
|
||
|
|
for _, v := range list {
|
||
|
|
resp.List = append(resp.List, values.OnePddRecord{
|
||
|
|
UID: v.UID,
|
||
|
|
Avatar: v.Avatar,
|
||
|
|
Nick: v.Nick,
|
||
|
|
Time: v.Time,
|
||
|
|
SpinCount: 1,
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivityFreeSpinInfo(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDFreeSpin) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
con := call.GetConfigActivityFreeSpin()
|
||
|
|
if con == nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := &values.ActivityFreeSpinInfoResp{
|
||
|
|
List: con,
|
||
|
|
NewReward: config.GetConfig().Web.FreeSpinFirst,
|
||
|
|
}
|
||
|
|
a.Data = resp
|
||
|
|
a.GetUID()
|
||
|
|
if a.UID > 0 {
|
||
|
|
freeSpin := call.GetUserFreeSpinData(a.UID)
|
||
|
|
if freeSpin.LastSpin == 0 {
|
||
|
|
now := time.Now().Unix()
|
||
|
|
p, _ := call.GetUserXInfo(a.UID, "birth")
|
||
|
|
data := &common.ActivityFreeSpinData{UID: a.UID}
|
||
|
|
if !util.IsSameDayTimeStamp(now, p.Birth) {
|
||
|
|
resp.Count = 1
|
||
|
|
} else {
|
||
|
|
data.LastSpin = now
|
||
|
|
}
|
||
|
|
db.Mysql().Create(data)
|
||
|
|
} else if !util.IsSameDayTimeStamp(time.Now().Unix(), freeSpin.LastSpin) {
|
||
|
|
resp.Count = 1
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
resp.Count = 1
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivityFreeSpinDraw(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDFreeSpin) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
freeSpin := call.GetUserFreeSpinData(a.UID)
|
||
|
|
now := time.Now().Unix()
|
||
|
|
if config.GetBase().Release {
|
||
|
|
if util.IsSameDayTimeStamp(now, freeSpin.LastSpin) {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
}
|
||
|
|
resp := &values.ActivityFreeSpinDrawResp{}
|
||
|
|
a.Data = resp
|
||
|
|
|
||
|
|
// 首次旋转,给予固定奖励
|
||
|
|
// if freeSpin.LastSpin == 0 {
|
||
|
|
// items := call.GetConfigActivityFreeSpinByType(common.ActivityFreeSpinItemRandomCash)
|
||
|
|
// if len(items) == 0 {
|
||
|
|
// a.Code = values.CodeRetry
|
||
|
|
// return
|
||
|
|
// }
|
||
|
|
// err := db.Mysql().Create(&common.ActivityFreeSpinData{UID: a.UID, LastSpin: time.Now().Unix()})
|
||
|
|
// if err != nil {
|
||
|
|
// a.Code = values.CodeRetry
|
||
|
|
// return
|
||
|
|
// }
|
||
|
|
// resp.Reward = config.GetConfig().Web.FreeSpinFirst
|
||
|
|
// if resp.Reward == 0 {
|
||
|
|
// resp.Reward = 5 * common.DecimalDigits
|
||
|
|
// }
|
||
|
|
// _, err = call.UpdateCurrencyPro(&common.UpdateCurrency{
|
||
|
|
// CurrencyBalance: &common.CurrencyBalance{
|
||
|
|
// Type: common.CurrencyBrazil,
|
||
|
|
// UID: a.UID,
|
||
|
|
// Event: common.CurrencyEventActivityFreeSpin,
|
||
|
|
// Value: resp.Reward,
|
||
|
|
// ChannelID: a.Channel,
|
||
|
|
// NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, resp.Reward),
|
||
|
|
// },
|
||
|
|
// })
|
||
|
|
// if err != nil {
|
||
|
|
// a.Code = values.CodeRetry
|
||
|
|
// return
|
||
|
|
// }
|
||
|
|
// ran := rand.Intn(len(items))
|
||
|
|
// resp.ID = items[ran].ID
|
||
|
|
// call.UploadActivityData(a.UID, common.ActivityIDFreeSpin, common.ActivityDataJoin, resp.Reward)
|
||
|
|
// return
|
||
|
|
// }
|
||
|
|
|
||
|
|
con := call.GetConfigActivityFreeSpin()
|
||
|
|
if con == nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
total := 0
|
||
|
|
for _, v := range con {
|
||
|
|
total += v.Weight
|
||
|
|
}
|
||
|
|
ran := rand.Intn(total)
|
||
|
|
rans := 0
|
||
|
|
for _, v := range con {
|
||
|
|
rans += v.Weight
|
||
|
|
if ran < rans {
|
||
|
|
resp.ID = v.ID
|
||
|
|
resp.Reward = v.Amount
|
||
|
|
if v.Type == common.ActivityFreeSpinItemRandomCash {
|
||
|
|
resp.Reward = rand.Int63n(v.CashUp-v.CashDown) + v.CashDown
|
||
|
|
}
|
||
|
|
rows, err := db.Mysql().UpdateRes(&common.ActivityFreeSpinData{UID: a.UID, LastSpin: freeSpin.LastSpin}, map[string]interface{}{"last_spin": time.Now().Unix()})
|
||
|
|
if rows == 0 || err != nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if v.Type == common.ActivityFreeSpinItemNone {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
_, err = call.UpdateCurrencyPro(&common.UpdateCurrency{
|
||
|
|
CurrencyBalance: &common.CurrencyBalance{
|
||
|
|
Type: common.CurrencyBrazil,
|
||
|
|
UID: a.UID,
|
||
|
|
Event: common.CurrencyEventActivityFreeSpin,
|
||
|
|
Value: resp.Reward,
|
||
|
|
ChannelID: a.Channel,
|
||
|
|
NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, resp.Reward),
|
||
|
|
},
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
break
|
||
|
|
}
|
||
|
|
}
|
||
|
|
call.UploadActivityData(a.UID, common.ActivityIDFreeSpin, common.ActivityDataJoin, resp.Reward)
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivityFirstRechargeBackInfo(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDFirstRechargeBack) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := &values.ActivityFirstRechargeBackInfoResp{}
|
||
|
|
a.Data = resp
|
||
|
|
data := call.GetUserFirstRechargeBackData(a.UID)
|
||
|
|
diff := time.Now().Unix() - data.RechargeTime
|
||
|
|
log.Debug("ActivityFirstRechargeBackInfo:%+v", data)
|
||
|
|
if data.RechargeTime == 0 {
|
||
|
|
resp.CanRecharge = true
|
||
|
|
} else {
|
||
|
|
if diff > common.ActivityFirstRechargeBackTime*2 {
|
||
|
|
a.Code = values.CodeActivityExpire
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp.CanRecharge = diff < common.ActivityFirstRechargeBackTime
|
||
|
|
}
|
||
|
|
resp.Recharge = data.Amount
|
||
|
|
if data.Amount < call.GetConfigActivityFirstRechargeBack().MinRecharge {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
val := data.Amount - call.GetUserCurrencyTotal(a.UID, common.CurrencyBrazil)
|
||
|
|
if val < 0 {
|
||
|
|
val = 0
|
||
|
|
}
|
||
|
|
max := call.GetConfigActivityFirstRechargeBack().MaxBack
|
||
|
|
if max > 0 && val > max {
|
||
|
|
val = max
|
||
|
|
}
|
||
|
|
if val > data.Amount {
|
||
|
|
val = data.Amount
|
||
|
|
}
|
||
|
|
resp.Back = val
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivityFirstRechargeBackDraw(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDFirstRechargeBack) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
data := call.GetUserFirstRechargeBackData(a.UID)
|
||
|
|
val := data.Amount - call.GetUserCurrencyTotal(a.UID, common.CurrencyBrazil)
|
||
|
|
if val <= 0 {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if time.Now().Unix()-data.RechargeTime < common.ActivityFirstRechargeBackTime {
|
||
|
|
log.Error("not ActivityFirstRechargeBackDraw time:%+v", data)
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if time.Now().Unix()-data.RechargeTime > common.ActivityFirstRechargeBackTime*2 {
|
||
|
|
a.Code = values.CodeActivityExpire
|
||
|
|
return
|
||
|
|
}
|
||
|
|
rows, err := db.Mysql().UpdateRes(&common.ActivityFirstRechargeBackData{UID: a.UID}, map[string]interface{}{"lost": 0})
|
||
|
|
if err != nil || rows == 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
max := call.GetConfigActivityFirstRechargeBack().MaxBack
|
||
|
|
if max > 0 || val > max {
|
||
|
|
val = max
|
||
|
|
}
|
||
|
|
if val > data.Amount {
|
||
|
|
val = data.Amount
|
||
|
|
}
|
||
|
|
_, err = call.UpdateCurrencyPro(&common.UpdateCurrency{
|
||
|
|
CurrencyBalance: &common.CurrencyBalance{
|
||
|
|
UID: a.UID,
|
||
|
|
ChannelID: a.Channel,
|
||
|
|
Type: common.CurrencyBrazil,
|
||
|
|
Value: val,
|
||
|
|
Event: common.CurrencyEventActivityFirstRechargeBack,
|
||
|
|
},
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
call.UploadActivityData(a.UID, common.ActivityIDFirstRechargeBack, common.ActivityDataJoin, val)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 幸运码活动
|
||
|
|
func ActivityLuckyCodeInfo(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDLuckyCode) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := &values.ActivityLuckyCodeInfoResp{
|
||
|
|
TelegramChannel: config.GetBase().Server.TelegramChannel,
|
||
|
|
}
|
||
|
|
a.Data = resp
|
||
|
|
con := call.GetConfigAcitivityLuckyCode()
|
||
|
|
total := call.GetConfigAcitivityLuckyCodeTotalWeight()
|
||
|
|
for _, v := range con {
|
||
|
|
resp.List = append(resp.List, values.OneActivityLuckyCodeConfig{
|
||
|
|
ID: v.ID,
|
||
|
|
Reward: v.Reward,
|
||
|
|
Per: util.FormatFloat(float64(v.Per*100)/float64(total), 2) + "%",
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivityLuckyCodeDraw(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDLuckyCode) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
req := new(values.ActivityLuckyCodeDrawReq)
|
||
|
|
if !a.S(req) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
now := time.Now()
|
||
|
|
luckyCode := &common.ActivityLuckyCode{Date: now.Format("20060102")}
|
||
|
|
if !a.MGet(luckyCode) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if req.LuckyCode != luckyCode.Code {
|
||
|
|
a.Code = values.CodeParam
|
||
|
|
a.Msg = "O código que você digitou está incorreto"
|
||
|
|
return
|
||
|
|
}
|
||
|
|
t := req.Type
|
||
|
|
if t == 0 {
|
||
|
|
t = common.LuckyCodeTypeNormal
|
||
|
|
}
|
||
|
|
|
||
|
|
resp := &values.ActivityLuckyCodeDrawResp{}
|
||
|
|
a.Data = resp
|
||
|
|
|
||
|
|
data := &common.ActivityLuckyCodeData{UID: a.UID}
|
||
|
|
db.Mysql().Get(data)
|
||
|
|
|
||
|
|
if util.IsSameDayTimeStamp(now.Unix(), data.LastDraw) {
|
||
|
|
a.Code = values.CodeParam
|
||
|
|
a.Msg = "Esse código já foi usado"
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
// 开始发奖
|
||
|
|
con := call.GetConfigAcitivityLuckyCode()
|
||
|
|
total := call.GetConfigAcitivityLuckyCodeTotalWeight()
|
||
|
|
if total == 0 {
|
||
|
|
log.Error("con:%+v invalid,uid:%d", con, a.UID)
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
if data.ID == 0 {
|
||
|
|
err := db.Mysql().Create(&common.ActivityLuckyCodeData{UID: a.UID, LastDraw: now.Unix()})
|
||
|
|
if err != nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
rows, err := db.Mysql().UpdateRes(&common.ActivityLuckyCodeData{UID: a.UID, LastDraw: data.LastDraw},
|
||
|
|
map[string]interface{}{"last_draw": now.Unix()})
|
||
|
|
if rows == 0 || err != nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
ran := rand.Int63n(total)
|
||
|
|
var rans, reward int64
|
||
|
|
id := 0
|
||
|
|
for _, v := range con {
|
||
|
|
rans += v.Per
|
||
|
|
if ran < rans {
|
||
|
|
id = v.ID
|
||
|
|
reward = v.Reward
|
||
|
|
break
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
_, err := call.UpdateCurrencyPro(&common.UpdateCurrency{
|
||
|
|
CurrencyBalance: &common.CurrencyBalance{
|
||
|
|
UID: a.UID,
|
||
|
|
Type: common.CurrencyBrazil,
|
||
|
|
Value: reward,
|
||
|
|
Event: common.CurrencyEventTask,
|
||
|
|
Exs1: fmt.Sprintf("%d", t),
|
||
|
|
Exi1: req.LuckyCode,
|
||
|
|
NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, reward),
|
||
|
|
},
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
call.UploadActivityData(a.UID, common.ActivityIDLuckyCode, common.ActivityDataJoin, reward)
|
||
|
|
resp.ID = id
|
||
|
|
}
|
||
|
|
|
||
|
|
// day 二进制从0位开始,实际签到日期需减1
|
||
|
|
func CanSign(sign, day int) bool {
|
||
|
|
tmp := sign >> (day - 1)
|
||
|
|
return tmp&1 == 0
|
||
|
|
}
|
||
|
|
|
||
|
|
func Sign(day int) int {
|
||
|
|
ret := 0
|
||
|
|
for i := 0; i < day; i++ {
|
||
|
|
ret <<= 1
|
||
|
|
ret |= 1
|
||
|
|
}
|
||
|
|
return ret
|
||
|
|
}
|
||
|
|
|
||
|
|
// CanSignDays 返回可以签到的天数
|
||
|
|
func CanSignDays(sign, day int) (ret []int) {
|
||
|
|
for i := 0; i < day; i++ {
|
||
|
|
if sign&1 == 0 {
|
||
|
|
ret = append(ret, i+1)
|
||
|
|
}
|
||
|
|
sign >>= 1
|
||
|
|
}
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
func GetSignInfo(uid int) (resp *values.ActivitySignInfoResp) {
|
||
|
|
if !call.IsActivityValid(common.ActivityIDSign) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
list := call.GetConfigActivitySign()
|
||
|
|
if len(list) == 0 {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp = &values.ActivitySignInfoResp{List: list}
|
||
|
|
if uid == 0 {
|
||
|
|
resp.Day = 1
|
||
|
|
resp.CanSign = true
|
||
|
|
return
|
||
|
|
}
|
||
|
|
data := &common.ActivitySignData{UID: uid}
|
||
|
|
db.Mysql().Get(data)
|
||
|
|
if data.ID == 0 {
|
||
|
|
user, _ := call.GetUserXInfo(uid, "birth")
|
||
|
|
db.Mysql().Create(&common.ActivitySignData{UID: uid, Time: user.Birth})
|
||
|
|
data.Time = user.Birth
|
||
|
|
}
|
||
|
|
resp.Sign = data.Sign
|
||
|
|
first := util.GetZeroTime(time.Unix(data.Time, 0)).Unix()
|
||
|
|
today := util.GetZeroTime(time.Now()).Unix()
|
||
|
|
day := (today - first) / common.OneDay
|
||
|
|
resp.Day = int(day) + 1
|
||
|
|
|
||
|
|
if resp.Day > list[len(list)-1].Day {
|
||
|
|
resp.Day = list[len(list)-1].Day
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
// 说明已签到过,不需要再判断
|
||
|
|
if !CanSign(resp.Sign, resp.Day) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp.CanSign = true
|
||
|
|
for _, v := range resp.List {
|
||
|
|
if v.Day == resp.Day {
|
||
|
|
if v.Recharge > 0 {
|
||
|
|
re := call.GetRechargeInfo(uid)
|
||
|
|
if re.DayRecharge < v.Recharge {
|
||
|
|
resp.CanSign = false
|
||
|
|
}
|
||
|
|
}
|
||
|
|
break
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivitySignInfo(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDSign) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
a.GetUID()
|
||
|
|
resp := GetSignInfo(a.UID)
|
||
|
|
if resp == nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
a.Data = resp
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivitySignDraw(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDSign) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
list := call.GetConfigActivitySign()
|
||
|
|
if len(list) == 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
data := &common.ActivitySignData{UID: a.UID}
|
||
|
|
db.Mysql().Get(data)
|
||
|
|
if data.ID == 0 {
|
||
|
|
user, _ := call.GetUserXInfo(a.UID, "birth")
|
||
|
|
db.Mysql().Create(&common.ActivitySignData{UID: a.UID, Time: user.Birth})
|
||
|
|
data.Time = user.Birth
|
||
|
|
}
|
||
|
|
first := util.GetZeroTime(time.Unix(data.Time, 0)).Unix()
|
||
|
|
today := util.GetZeroTime(time.Now()).Unix()
|
||
|
|
day := int((today-first)/common.OneDay) + 1
|
||
|
|
|
||
|
|
// 最大签到天数
|
||
|
|
if day > list[len(list)-1].Day {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
// if !CanSign(data.Sign, day) {
|
||
|
|
// a.Code = values.CodeParam
|
||
|
|
// return
|
||
|
|
// }
|
||
|
|
days := CanSignDays(data.Sign, day)
|
||
|
|
log.Debug("uid:%v,data.Sign:%v,day:%v,days:%v", a.UID, data.Sign, day, days)
|
||
|
|
if len(days) == 0 {
|
||
|
|
a.Code = values.CodeParam
|
||
|
|
a.Msg = "Check-in repetido."
|
||
|
|
return
|
||
|
|
}
|
||
|
|
var reward int64
|
||
|
|
for _, v := range list {
|
||
|
|
if util.SliceContain(days, v.Day) {
|
||
|
|
reward += v.Reward
|
||
|
|
if v.Day == day {
|
||
|
|
if v.Recharge > 0 {
|
||
|
|
re := call.GetRechargeInfo(a.UID)
|
||
|
|
if re.DayRecharge < v.Recharge {
|
||
|
|
a.Code = values.CodeParam
|
||
|
|
return
|
||
|
|
}
|
||
|
|
}
|
||
|
|
break
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if reward == 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
// ok
|
||
|
|
newSign := Sign(day)
|
||
|
|
rows, err := db.Mysql().UpdateRes(&common.ActivitySignData{UID: a.UID, Sign: data.Sign}, map[string]interface{}{"sign": newSign})
|
||
|
|
if rows == 0 || err != nil {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
_, err = call.UpdateCurrencyPro(&common.UpdateCurrency{
|
||
|
|
CurrencyBalance: &common.CurrencyBalance{
|
||
|
|
UID: a.UID,
|
||
|
|
Type: common.CurrencyBrazil,
|
||
|
|
ChannelID: a.Channel,
|
||
|
|
Value: reward,
|
||
|
|
Event: common.CurrencyEventActivitySign,
|
||
|
|
NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, reward),
|
||
|
|
},
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
a.Data = values.ActivitySignDrawResp{Reward: reward, Day: day, Sign: newSign}
|
||
|
|
call.UploadActivityData(a.UID, common.ActivityIDSign, common.ActivityDataJoin, reward)
|
||
|
|
}
|
||
|
|
|
||
|
|
// 破产礼包活动
|
||
|
|
func ActivityBreakGiftInfo(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDBreakGift) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := &values.ActivityBreakGiftInfoResp{}
|
||
|
|
limit := config.GetConfig().Web.BreakLimit
|
||
|
|
if limit <= 0 {
|
||
|
|
limit = 1 * common.DecimalDigits
|
||
|
|
}
|
||
|
|
if call.GetUserCurrency(a.UID, common.CurrencyBrazil) > limit {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
payData := call.GetPlayerPayData(a.UID)
|
||
|
|
re := call.GetRechargeInfo(a.UID)
|
||
|
|
con := call.GetConfigActivityBreakGiftByRecharge(re.TotalRecharge, payData)
|
||
|
|
log.Debug("con:%+v,total:%v", con, re.TotalRecharge)
|
||
|
|
if con == nil {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
if util.SliceContain(payData.SubBreakGift, con.Level) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
product := call.GetConfigPayProductByID(con.ProductID)
|
||
|
|
log.Debug("product:%+v", product)
|
||
|
|
if product == nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp.Amount = product.Amount
|
||
|
|
resp.Reward = product.Value
|
||
|
|
resp.ProductID = con.ProductID
|
||
|
|
resp.CountDown = con.CountDown
|
||
|
|
a.Data = resp
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivityWeekCardInfo(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDWeekCard) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
cons := call.GetConfigActivityWeekCard()
|
||
|
|
list := call.GetUserWeekCards(a.UID)
|
||
|
|
resp := &values.ActivityWeekCardInfoResp{}
|
||
|
|
a.Data = resp
|
||
|
|
for _, v := range cons {
|
||
|
|
product := call.GetConfigPayProductByID(v.ProductID)
|
||
|
|
if product == nil {
|
||
|
|
continue
|
||
|
|
}
|
||
|
|
one := values.OneWeekCard{
|
||
|
|
Level: v.Level,
|
||
|
|
Rebate: fmt.Sprintf("%d", v.Rebate) + "%",
|
||
|
|
OriginPrice: v.OriginPrice,
|
||
|
|
Price: product.Amount,
|
||
|
|
Reward: product.Value,
|
||
|
|
DayReward: v.DayReward,
|
||
|
|
DayCount: v.Day,
|
||
|
|
Discount: fmt.Sprintf("%d", 100-v.Discount),
|
||
|
|
Next: -1,
|
||
|
|
ProductID: v.ProductID,
|
||
|
|
TotalReward: v.DayReward*int64(v.Day) + product.Value,
|
||
|
|
}
|
||
|
|
for _, k := range list {
|
||
|
|
if k.Level == v.Level && k.Day > 0 {
|
||
|
|
one.DayReward = k.DayReward
|
||
|
|
one.Day = k.Day
|
||
|
|
if !util.IsSameDayTimeStamp(k.LastDraw, time.Now().Unix()) {
|
||
|
|
one.Next = 0
|
||
|
|
} else {
|
||
|
|
one.Next = util.GetZeroTime(time.Now().AddDate(0, 0, 1)).Unix() - k.LastDraw
|
||
|
|
}
|
||
|
|
break
|
||
|
|
}
|
||
|
|
}
|
||
|
|
resp.List = append(resp.List, one)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivityWeekCardDraw(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDWeekCard) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
req := new(values.ActivityWeekCardDrawReq)
|
||
|
|
if !a.S(req) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
card := call.GetUserWeekCard(a.UID, req.Level)
|
||
|
|
if card.ID == 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if card.Day <= 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
now := time.Now().Unix()
|
||
|
|
if util.IsSameDayTimeStamp(now, card.LastDraw) {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
rows, err := db.Mysql().UpdateRes(&common.ActivityWeekCardData{UID: a.UID, Level: req.Level, Day: card.Day},
|
||
|
|
map[string]interface{}{"day": gorm.Expr("day - 1"), "last_draw": now})
|
||
|
|
if rows == 0 || err != nil {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := &values.ActivityWeekCardDrawResp{
|
||
|
|
Reward: card.DayReward,
|
||
|
|
}
|
||
|
|
a.Data = resp
|
||
|
|
call.UpdateCurrencyPro(&common.UpdateCurrency{
|
||
|
|
CurrencyBalance: &common.CurrencyBalance{
|
||
|
|
UID: a.UID,
|
||
|
|
Type: common.CurrencyBrazil,
|
||
|
|
Value: card.DayReward,
|
||
|
|
Event: common.CurrencyEventActivityWeekCard,
|
||
|
|
ChannelID: a.Channel,
|
||
|
|
NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, card.DayReward),
|
||
|
|
},
|
||
|
|
})
|
||
|
|
con := call.GetConfigActivityWeekCardByLevel(card.Level)
|
||
|
|
if con != nil {
|
||
|
|
// 最后一天必得一次
|
||
|
|
if card.Day == 1 {
|
||
|
|
call.AddUserDiscountTicket(a.UID, con.Discount)
|
||
|
|
resp.DiscountTicket = fmt.Sprintf("%d", 100-con.Discount)
|
||
|
|
} else if card.GetDiscount == 0 { // 未领取过则随机一次
|
||
|
|
ran := rand.Intn(card.Day)
|
||
|
|
if ran == 0 {
|
||
|
|
db.Mysql().Update(&common.ActivityWeekCardData{UID: a.UID, Level: req.Level}, map[string]interface{}{"get_discount": 1})
|
||
|
|
call.AddUserDiscountTicket(a.UID, con.Discount)
|
||
|
|
resp.DiscountTicket = fmt.Sprintf("%d", 100-con.Discount)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivitySlotsInfo(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDSlots) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := &values.ActivitySlotsResp{ActivityID: common.ActivityIDSlots}
|
||
|
|
a.Data = resp
|
||
|
|
isSingle := call.IsActivitySingleDay(common.ActivityIDSlots)
|
||
|
|
for _, v := range values.ActivitySlotsRank {
|
||
|
|
one := &values.OneActivitySlotsRank{
|
||
|
|
UID: v.UID,
|
||
|
|
Avatar: v.Avatar,
|
||
|
|
Nick: v.Nick,
|
||
|
|
}
|
||
|
|
if v.Avatar == "" || v.Nick == "" {
|
||
|
|
p, _ := call.GetUserXInfo(v.UID, "mobile", "avatar")
|
||
|
|
v.Avatar = p.Avatar
|
||
|
|
v.Nick = p.Mobile
|
||
|
|
}
|
||
|
|
one.Nick = "*******" + v.Nick[len(v.Nick)-3:]
|
||
|
|
if isSingle {
|
||
|
|
one.Number = v.BestNumber1
|
||
|
|
} else {
|
||
|
|
one.Number = v.BestNumber2
|
||
|
|
}
|
||
|
|
resp.RankList = append(resp.RankList, one)
|
||
|
|
}
|
||
|
|
|
||
|
|
a.GetUID()
|
||
|
|
if a.UID == 0 {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
data := call.GetUserActivitySlotsData(a.UID)
|
||
|
|
resp.Spin = data.Spin
|
||
|
|
if isSingle {
|
||
|
|
if data.Time1 >= util.GetZeroTime(time.Now()).Unix() {
|
||
|
|
resp.BestNumber = data.BestNumber1
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
if data.Time2 >= util.GetZeroTime(time.Now()).Unix() {
|
||
|
|
resp.BestNumber = data.BestNumber2
|
||
|
|
}
|
||
|
|
}
|
||
|
|
lastDate := time.Now().AddDate(0, 0, -1).Format("20060102")
|
||
|
|
record := &common.ActivitySlotsRecord{UID: a.UID, Date: lastDate}
|
||
|
|
db.Mysql().Get(record)
|
||
|
|
if record.ID > 0 {
|
||
|
|
if record.Settle == 0 {
|
||
|
|
resp.LastReward = &values.OneActivitySlotsLastReward{
|
||
|
|
Rank: record.Rank,
|
||
|
|
Number: record.MyNumber,
|
||
|
|
Reward: record.Reward,
|
||
|
|
Draw: record.Settle == 1,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
// 查询昨天是否参与
|
||
|
|
t := data.Time1
|
||
|
|
number := data.BestNumber1
|
||
|
|
if isSingle {
|
||
|
|
t = data.Time2
|
||
|
|
number = data.BestNumber2
|
||
|
|
}
|
||
|
|
if util.IsSameDayTimeStamp(t, time.Now().AddDate(0, 0, -1).Unix()) {
|
||
|
|
resp.LastReward = &values.OneActivitySlotsLastReward{
|
||
|
|
Number: number,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 商品
|
||
|
|
product := call.GetConfigPayProductByActivityID(common.ActivityIDSlots)
|
||
|
|
if len(product) > 0 {
|
||
|
|
resp.Product = values.OneActivitySlotsProduct{
|
||
|
|
ProductID: product[0].ProductID,
|
||
|
|
OriginAmount: product[0].OriginAmount,
|
||
|
|
Amount: product[0].Amount,
|
||
|
|
Reward: product[0].Value,
|
||
|
|
SpinCount: product[0].Exi,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivitySlotsDraw(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDSlots) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
data := call.GetUserActivitySlotsData(a.UID)
|
||
|
|
if data.Spin <= 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := &values.ActivitySlotsDrawResp{}
|
||
|
|
a.Data = resp
|
||
|
|
/*
|
||
|
|
真人玩家若充值大于200则每次抽奖会有75%的概率抽取到900-910之间的数字,25%的概率抽取到850—900以下的数字
|
||
|
|
真人玩家若充值大于50则每次抽奖会有75%的概率抽取到850-900之间的数字,25%的概率抽取到850以下的数字
|
||
|
|
充值小于50的真人玩家抽取到的数字只能小于850(暂定数字),随机选取
|
||
|
|
*/
|
||
|
|
re := call.GetRechargeInfo(a.UID)
|
||
|
|
ran := rand.Intn(100)
|
||
|
|
if re.DayRecharge >= 20000000000 {
|
||
|
|
if ran < 75 {
|
||
|
|
resp.Number = rand.Intn(11) + 900
|
||
|
|
} else {
|
||
|
|
resp.Number = rand.Intn(50) + 850
|
||
|
|
}
|
||
|
|
} else if re.DayRecharge >= 5000000000 {
|
||
|
|
if ran < 75 {
|
||
|
|
resp.Number = rand.Intn(50) + 850
|
||
|
|
} else {
|
||
|
|
resp.Number = rand.Intn(850)
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
resp.Number = rand.Intn(850)
|
||
|
|
}
|
||
|
|
now := time.Now().Unix()
|
||
|
|
|
||
|
|
t := data.Time2
|
||
|
|
number := data.BestNumber2
|
||
|
|
str := "best_number2"
|
||
|
|
tstr := "time2"
|
||
|
|
if call.IsActivitySingleDay(common.ActivityIDSlots) {
|
||
|
|
t = data.Time1
|
||
|
|
number = data.BestNumber1
|
||
|
|
str = "best_number1"
|
||
|
|
tstr = "time1"
|
||
|
|
}
|
||
|
|
u := map[string]interface{}{"spin": gorm.Expr("spin - 1"), tstr: now}
|
||
|
|
|
||
|
|
if resp.Number > number || !util.IsSameDayTimeStamp(now, t) {
|
||
|
|
u[str] = resp.Number
|
||
|
|
}
|
||
|
|
rows, err := db.Mysql().UpdateResW(&common.ActivitySlotsData{UID: a.UID}, u, fmt.Sprintf("uid = %d and %s = %d", a.UID, tstr, t))
|
||
|
|
if err != nil || rows == 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
return
|
||
|
|
}
|
||
|
|
call.UploadActivityData(a.UID, common.ActivityIDSlots, 2, 0)
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivitySlotsDrawLast(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
lastDate := time.Now().AddDate(0, 0, -1).Format("20060102")
|
||
|
|
record := &common.ActivitySlotsRecord{UID: a.UID, Date: lastDate}
|
||
|
|
db.Mysql().Get(record)
|
||
|
|
resp := &values.ActivitySlotsDrawLastResp{}
|
||
|
|
a.Data = resp
|
||
|
|
if record.ID == 0 || record.Settle == 1 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
rows, err := db.Mysql().UpdateResW(&common.ActivitySlotsRecord{}, map[string]interface{}{"settle": 1}, fmt.Sprintf("uid = %d and date = '%s' and settle = 0", a.UID, lastDate))
|
||
|
|
if err != nil || rows == 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if record.Reward == 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
call.UpdateCurrencyPro(&common.UpdateCurrency{
|
||
|
|
CurrencyBalance: &common.CurrencyBalance{
|
||
|
|
UID: a.UID,
|
||
|
|
Time: time.Now().Unix(),
|
||
|
|
Value: record.Reward,
|
||
|
|
Type: common.CurrencyBrazil,
|
||
|
|
Event: common.CurrencyEventActivitySlots,
|
||
|
|
NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, record.Reward),
|
||
|
|
},
|
||
|
|
})
|
||
|
|
resp.Reward = record.Reward
|
||
|
|
call.UploadActivityData(a.UID, common.ActivityIDSlots, 2, record.Reward)
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivityLuckyShopInfo(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDLuckyShop) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := &values.ActivityLuckyShopResp{}
|
||
|
|
a.Data = resp
|
||
|
|
data := call.GetShowActivityLuckShopData(a.UID)
|
||
|
|
if data == nil {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if data.ProductID == 0 {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
product := call.GetConfigPayProductByID(data.ProductID)
|
||
|
|
if product == nil {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if data.ID == 0 {
|
||
|
|
db.Mysql().Create(data)
|
||
|
|
}
|
||
|
|
resp.Recharge = product.Amount
|
||
|
|
resp.Value = product.Value
|
||
|
|
resp.ProductID = product.ProductID
|
||
|
|
resp.CountDown = common.ActivityLuckyShopExpire + data.Push - time.Now().Unix()
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivitySevenDayBoxInfo(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDSevenDayBox) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := &values.ActivitySevenDayBoxInfoResp{}
|
||
|
|
a.Data = resp
|
||
|
|
re := call.GetRechargeInfo(a.UID)
|
||
|
|
con := call.GetConfigActivitySevenDayBoxByRechargeAndType(re.TotalRecharge, common.ActivitySevenDayBoxTypeCash)
|
||
|
|
if len(con) == 0 {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
var least int64 = -1
|
||
|
|
var max int64 = -1
|
||
|
|
for _, v := range con {
|
||
|
|
if len(v.SubCashRange) == 2 {
|
||
|
|
if v.SubCashRange[0] < least || least < 0 {
|
||
|
|
least = v.SubCashRange[0]
|
||
|
|
}
|
||
|
|
if v.SubCashRange[1] > max {
|
||
|
|
max = v.SubCashRange[1]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
resp.ProductID = con[0].ProductID
|
||
|
|
resp.RewardRange = []int64{least, max}
|
||
|
|
data := &common.ActivitySevenDayBoxData{UID: a.UID}
|
||
|
|
db.Mysql().Get(data)
|
||
|
|
resp.Buy = !util.IsSameDayTimeStamp(data.Time, time.Now().Unix())
|
||
|
|
resp.Open = data.Count > 0
|
||
|
|
|
||
|
|
product := call.GetConfigPayProductByID(resp.ProductID)
|
||
|
|
if product != nil {
|
||
|
|
resp.Recharge = product.Amount
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivitySevenDayBoxDraw(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
resp := &values.ActivitySevenDayBoxDrawResp{}
|
||
|
|
a.Data = resp
|
||
|
|
|
||
|
|
re := call.GetRechargeInfo(a.UID)
|
||
|
|
cashCon := call.GetConfigActivitySevenDayBoxByRechargeAndType(re.TotalRecharge, common.ActivitySevenDayBoxTypeCash)
|
||
|
|
discountCon := call.GetConfigActivitySevenDayBoxByRechargeAndType(re.TotalRecharge, common.ActivitySevenDayBoxTypeDiscountTicket)
|
||
|
|
|
||
|
|
if len(cashCon) == 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
if len(discountCon) == 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
oneCash := cashCon[util.RandomOneEleFromSlice(cashCon, "Per")]
|
||
|
|
oneDiscount := discountCon[util.RandomOneEleFromSlice(discountCon, "Per")]
|
||
|
|
|
||
|
|
if len(oneCash.SubCashRange) != 2 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
data := &common.ActivitySevenDayBoxData{UID: a.UID}
|
||
|
|
db.Mysql().Get(data)
|
||
|
|
if data.Count <= 0 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
rows, err := db.Mysql().UpdateResW(&common.ActivitySevenDayBoxData{}, map[string]interface{}{"count": gorm.Expr("count - 1")},
|
||
|
|
fmt.Sprintf("uid = %d and count = %d", a.UID, data.Count))
|
||
|
|
if rows == 0 || err != nil {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
var reward int64
|
||
|
|
diff := oneCash.SubCashRange[1] - oneCash.SubCashRange[0]
|
||
|
|
if diff <= 0 {
|
||
|
|
reward = oneCash.SubCashRange[0]
|
||
|
|
} else {
|
||
|
|
diff /= common.DecimalDigits
|
||
|
|
reward = rand.Int63n(diff)*common.DecimalDigits + oneCash.SubCashRange[0]
|
||
|
|
}
|
||
|
|
if reward > 0 {
|
||
|
|
call.UpdateCurrencyPro(&common.UpdateCurrency{
|
||
|
|
CurrencyBalance: &common.CurrencyBalance{
|
||
|
|
UID: a.UID,
|
||
|
|
Event: common.CurrencyEventActivityAppSpin,
|
||
|
|
Type: common.CurrencyBrazil,
|
||
|
|
Value: reward,
|
||
|
|
NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, reward),
|
||
|
|
},
|
||
|
|
})
|
||
|
|
resp.Reward = reward
|
||
|
|
call.UploadActivityData(a.UID, common.ActivityIDSevenDayBox, common.ActivityDataJoin, reward)
|
||
|
|
}
|
||
|
|
if oneDiscount.Discount > 0 {
|
||
|
|
call.AddUserDiscountTicket(a.UID, oneDiscount.Discount)
|
||
|
|
resp.Discount = oneDiscount.Discount
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivitySuperInfo(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDSuper) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
resp := &values.ActivitySuperInfoResp{}
|
||
|
|
a.Data = resp
|
||
|
|
data := call.GetUserActivitySuperData(a.UID)
|
||
|
|
con := call.GetConfigActivitySuperByType(data.Type)
|
||
|
|
resp.Buy = data.CanBuy
|
||
|
|
if len(con) > 0 {
|
||
|
|
product := call.GetConfigPayProductByID(con[0].ProductID)
|
||
|
|
if product != nil {
|
||
|
|
resp.Recharge = product.Amount
|
||
|
|
resp.ProductID = con[0].ProductID
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
for i := 1; i <= 3; i++ {
|
||
|
|
one := values.OneActivitySuperBox{
|
||
|
|
Index: i,
|
||
|
|
}
|
||
|
|
if data.CanBuy { // 说明未付费
|
||
|
|
one.Status = 0
|
||
|
|
} else {
|
||
|
|
tmp := data.Open >> (i - 1)
|
||
|
|
if tmp&1 == 0 {
|
||
|
|
one.Status = 1
|
||
|
|
} else {
|
||
|
|
one.Status = 2
|
||
|
|
}
|
||
|
|
}
|
||
|
|
for _, v := range con {
|
||
|
|
if v.Index != i {
|
||
|
|
continue
|
||
|
|
}
|
||
|
|
one.Rewards = append(one.Rewards, values.ActivitySuperOneReward{
|
||
|
|
RewardType: v.RewardType,
|
||
|
|
Reward: v.Reward,
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func ActivitySuperDraw(c *gin.Context) {
|
||
|
|
a := app.NewApp(c)
|
||
|
|
defer func() {
|
||
|
|
a.Response()
|
||
|
|
}()
|
||
|
|
if !a.CheckActivityExpire(common.ActivityIDSuper) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
req := new(values.ActivitySuperDrawReq)
|
||
|
|
if !a.S(req) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
if req.Index > 3 || req.Index < 1 {
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
data := call.GetUserActivitySuperData(a.UID)
|
||
|
|
if data.Time == 0 { // 未购买
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
tmp := data.Open >> (req.Index - 1)
|
||
|
|
if tmp&1 == 1 {
|
||
|
|
a.Code = values.CodeParam
|
||
|
|
a.Msg = "Coleta repetida."
|
||
|
|
return
|
||
|
|
}
|
||
|
|
cons := call.GetConfigActivitySuperByTypeAndIndex(data.Type, req.Index)
|
||
|
|
index := util.RandomOneEleFromSlice(cons, "Per")
|
||
|
|
|
||
|
|
reward := cons[index]
|
||
|
|
|
||
|
|
open := 1 << (req.Index - 1) & data.Open
|
||
|
|
rows, err := db.Mysql().UpdateResW(&common.ActivitySuperData{}, map[string]interface{}{"open": open}, fmt.Sprintf("uid = %d and open = %d", a.UID, data.Open))
|
||
|
|
if rows == 0 || err != nil {
|
||
|
|
log.Error("err:%v", err)
|
||
|
|
a.Code = values.CodeRetry
|
||
|
|
return
|
||
|
|
}
|
||
|
|
// 发奖
|
||
|
|
if reward.RewardType == 1 {
|
||
|
|
call.UpdateCurrencyPro(&common.UpdateCurrency{
|
||
|
|
CurrencyBalance: &common.CurrencyBalance{
|
||
|
|
UID: a.UID,
|
||
|
|
Event: common.CurrencyEventActivitySuper,
|
||
|
|
Value: reward.Reward,
|
||
|
|
Type: common.CurrencyBrazil,
|
||
|
|
NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, reward.Reward),
|
||
|
|
},
|
||
|
|
})
|
||
|
|
call.UploadActivityData(a.UID, common.ActivityIDSuper, 2, reward.Reward)
|
||
|
|
} else {
|
||
|
|
call.AddUserDiscountTicket(a.UID, int(reward.Reward))
|
||
|
|
}
|
||
|
|
a.Data = &values.ActivitySuperDrawResp{
|
||
|
|
Reward: values.ActivitySuperOneReward{
|
||
|
|
RewardType: reward.RewardType,
|
||
|
|
Reward: reward.Reward,
|
||
|
|
},
|
||
|
|
}
|
||
|
|
}
|