|
|
|
|
@ -704,7 +704,6 @@ func ActivityLuckyCodeDraw(c *gin.Context) { |
|
|
|
|
if !a.CheckActivityExpire(common.ActivityIDLuckyCode) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
req := new(values.ActivityLuckyCodeDrawReq) |
|
|
|
|
if !a.S(req) { |
|
|
|
|
return |
|
|
|
|
@ -733,7 +732,8 @@ func ActivityLuckyCodeDraw(c *gin.Context) { |
|
|
|
|
total := call.GetConfigAcitivityLuckyCodeTotalWeight(codeType) |
|
|
|
|
if total == 0 { |
|
|
|
|
log.Error("con:%+v invalid,uid:%d", con, a.UID) |
|
|
|
|
a.Code = values.CodeRetry |
|
|
|
|
a.Code = values.CodeParam |
|
|
|
|
a.Msg = "रूपांतरण कोड त्रुटि" |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if data.ID == 0 { |
|
|
|
|
@ -788,6 +788,7 @@ func ActivityLuckyCodeDraw(c *gin.Context) { |
|
|
|
|
if err != nil { |
|
|
|
|
log.Error("err:%v", err) |
|
|
|
|
a.Code = values.CodeRetry |
|
|
|
|
a.Msg = "रूपांतरण कोड त्रुटि" |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
call.UploadActivityData(a.UID, common.ActivityIDLuckyCode, common.ActivityDataJoin, reward) |
|
|
|
|
@ -809,6 +810,17 @@ func Sign(day int) int { |
|
|
|
|
return ret |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GetSignDay 获取签到天数
|
|
|
|
|
func GetSignDay(sign int) (day int) { |
|
|
|
|
for i := 0; i < 7; i++ { |
|
|
|
|
if sign&1 == 1 { |
|
|
|
|
day++ |
|
|
|
|
} |
|
|
|
|
sign >>= 1 |
|
|
|
|
} |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// CanSignDays 返回可以签到的天数
|
|
|
|
|
func CanSignDays(sign, day int) (ret []int) { |
|
|
|
|
for i := 0; i < day; i++ { |
|
|
|
|
@ -975,6 +987,187 @@ func ActivitySignDraw(c *gin.Context) { |
|
|
|
|
call.UploadActivityData(a.UID, common.ActivityIDSign, common.ActivityDataJoin, reward) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func GetSignNewInfo(uid int) (resp *values.ActivitySignInfoResp) { |
|
|
|
|
if !call.IsActivityValid(common.ActivityIDSign) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
data := &common.ActivitySignData{UID: uid} |
|
|
|
|
if uid > 0 { |
|
|
|
|
db.Mysql().Get(data) |
|
|
|
|
if data.ID == 0 { |
|
|
|
|
user, _ := call.GetUserXInfo(uid, "birth") |
|
|
|
|
data.Wheel = 1 |
|
|
|
|
db.Mysql().Create(&common.ActivitySignData{UID: uid, Time: user.Birth}) |
|
|
|
|
data.Time = user.Birth |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
data.Wheel = 1 |
|
|
|
|
} |
|
|
|
|
list := call.GetConfigActivitySignByWheel(data.Wheel) |
|
|
|
|
if len(list) == 0 { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
resp = &values.ActivitySignInfoResp{List: list} |
|
|
|
|
if uid == 0 { |
|
|
|
|
resp.Day = 1 |
|
|
|
|
resp.CanSign = true |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
re := call.GetRechargeInfo(uid) |
|
|
|
|
playerData := call.GetPlayerData(uid) |
|
|
|
|
resp.RewardCount = data.Reward |
|
|
|
|
resp.LatestSignTime = data.SignTime |
|
|
|
|
resp.Recharge = re.DayRecharge |
|
|
|
|
resp.Bet = playerData.DayBet |
|
|
|
|
signDay := GetSignDay(data.Sign) |
|
|
|
|
resp.Sign = 7*(data.Wheel-1) + signDay |
|
|
|
|
resp.Day = signDay + 1 |
|
|
|
|
now := time.Now() |
|
|
|
|
if data.Finish || util.IsSameDayTimeStamp(now.Unix(), data.SignTime) { |
|
|
|
|
for _, v := range resp.List { |
|
|
|
|
if v.Day == signDay && data.Wheel >= v.WheelStart && data.Wheel <= v.WheelEnd { |
|
|
|
|
resp.Recharge = v.Recharge |
|
|
|
|
resp.Bet = v.Bet |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if util.IsSameDayTimeStamp(now.Unix(), data.SignTime) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if resp.Day > 7 { |
|
|
|
|
if len(call.GetConfigActivitySignByWheel(data.Wheel+1)) > 0 { |
|
|
|
|
if err := db.Mysql().Update(&common.ActivitySignData{UID: data.UID}, map[string]interface{}{"sign": 0, "wheel": gorm.Expr("wheel + ?", 1)}); err != nil { |
|
|
|
|
log.Error("err:%v", err) |
|
|
|
|
resp.CanSign = false |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
resp.Sign = 7 * (data.Wheel) |
|
|
|
|
resp.Day = 1 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
resp.CanSign = true |
|
|
|
|
if !data.Finish { |
|
|
|
|
for _, v := range resp.List { |
|
|
|
|
if v.Day == resp.Day && data.Wheel >= v.WheelStart && data.Wheel <= v.WheelEnd { |
|
|
|
|
if re.DayRecharge < v.Recharge || playerData.DayBet < v.Bet { |
|
|
|
|
resp.CanSign = false |
|
|
|
|
} else { |
|
|
|
|
// 更新状态
|
|
|
|
|
if err := db.Mysql().Update(&common.ActivitySignData{UID: data.UID}, map[string]interface{}{"finish": true}); err != nil { |
|
|
|
|
log.Error("err:%v", err) |
|
|
|
|
resp.CanSign = false |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func ActivitySignNewInfo(c *gin.Context) { |
|
|
|
|
a := app.NewApp(c) |
|
|
|
|
defer func() { |
|
|
|
|
a.Response() |
|
|
|
|
}() |
|
|
|
|
if !a.CheckActivityExpire(common.ActivityIDSign) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
a.GetUID() |
|
|
|
|
resp := GetSignNewInfo(a.UID) |
|
|
|
|
if resp == nil { |
|
|
|
|
a.Code = values.CodeRetry |
|
|
|
|
a.Msg = "पात्रता को पूरा न करें" |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
a.Data = resp |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func ActivitySignNewDraw(c *gin.Context) { |
|
|
|
|
a := app.NewApp(c) |
|
|
|
|
defer func() { |
|
|
|
|
a.Response() |
|
|
|
|
}() |
|
|
|
|
if !a.CheckActivityExpire(common.ActivityIDSign) { |
|
|
|
|
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 |
|
|
|
|
} |
|
|
|
|
list := call.GetConfigActivitySignByWheel(data.Wheel) |
|
|
|
|
if len(list) == 0 { |
|
|
|
|
a.Code = values.CodeRetry |
|
|
|
|
a.Msg = "शर्तों को पूरा नहीं किया जाता है" |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
now := time.Now() |
|
|
|
|
if util.IsSameDayTimeStamp(now.Unix(), data.SignTime) { |
|
|
|
|
// 已经签到
|
|
|
|
|
a.Code = values.CodeParam |
|
|
|
|
a.Msg = "आज में हस्ताक्षर किए" |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 获取签到了几天
|
|
|
|
|
day := GetSignDay(data.Sign) + 1 |
|
|
|
|
var reward int64 |
|
|
|
|
for _, v := range list { |
|
|
|
|
if v.Day == day { |
|
|
|
|
reward = v.Reward |
|
|
|
|
re := call.GetRechargeInfo(a.UID) |
|
|
|
|
playerData := call.GetPlayerData(a.UID) |
|
|
|
|
if re.DayRecharge < v.Recharge || playerData.DayBet < v.Bet { |
|
|
|
|
a.Code = values.CodeParam |
|
|
|
|
a.Msg = "शर्तों को पूरा नहीं किया जाता है" |
|
|
|
|
log.Error("uid:%v,conf:%v", a.UID, v) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if reward == 0 { |
|
|
|
|
a.Code = values.CodeRetry |
|
|
|
|
log.Error("reward == 0") |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ok
|
|
|
|
|
newSign := Sign(day) |
|
|
|
|
updates := map[string]interface{}{"sign": newSign, "finish": false, "reward": gorm.Expr("reward + ?", reward)} |
|
|
|
|
if config.GetBase().Release { |
|
|
|
|
updates["sign_time"] = now.Unix() |
|
|
|
|
} |
|
|
|
|
rows, err := db.Mysql().UpdateRes(&common.ActivitySignData{UID: a.UID, Sign: data.Sign}, updates) |
|
|
|
|
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.CurrencyINR, |
|
|
|
|
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) |
|
|
|
|
@ -992,7 +1185,6 @@ func ActivityBreakGiftInfo(c *gin.Context) { |
|
|
|
|
if call.GetUserCurrency(a.UID, common.CurrencyINR) > limit { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
payData := call.GetPlayerPayData(a.UID) |
|
|
|
|
re := call.GetRechargeInfo(a.UID) |
|
|
|
|
con := call.GetConfigActivityBreakGiftByRecharge(re.TotalRecharge, payData) |
|
|
|
|
@ -1000,7 +1192,6 @@ func ActivityBreakGiftInfo(c *gin.Context) { |
|
|
|
|
if con == nil { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if util.SliceContain(payData.SubBreakGift, con.Level) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
@ -1566,3 +1757,113 @@ func ActivitySuperDraw(c *gin.Context) { |
|
|
|
|
}, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func ActivityBetDrawInfo(c *gin.Context) { |
|
|
|
|
a := app.NewApp(c) |
|
|
|
|
defer func() { |
|
|
|
|
a.Response() |
|
|
|
|
}() |
|
|
|
|
if !a.CheckActivityExpire(common.ActivityIDBetDraw) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
a.GetUID() |
|
|
|
|
drawInfo := &common.ActivityBetDrawData{UID: a.UID} |
|
|
|
|
if a.UID > 0 { |
|
|
|
|
db.Mysql().Get(drawInfo) |
|
|
|
|
if drawInfo.ID == 0 { |
|
|
|
|
db.Mysql().Create(drawInfo) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
a.Data = &values.ActivityBetDrawInfoResp{ |
|
|
|
|
List: call.GetConfigBetDraw(), |
|
|
|
|
Lucky: drawInfo.Lucky, |
|
|
|
|
} |
|
|
|
|
call.UploadActivityData(a.UID, common.ActivityIDBetDraw, common.ActivityDataClick, 0) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func ActivityBetDrawDraw(c *gin.Context) { |
|
|
|
|
a := app.NewApp(c) |
|
|
|
|
defer func() { |
|
|
|
|
a.Response() |
|
|
|
|
}() |
|
|
|
|
req := values.ActivityBetDrawDrawReq{} |
|
|
|
|
if !a.S(&req) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if !a.CheckActivityExpire(common.ActivityIDBetDraw) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
configList, weightList := call.GetConfigBetDrawByType(req.WheelType) |
|
|
|
|
if len(configList) == 0 { |
|
|
|
|
a.Code = values.CodeRetry |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
conf := configList[0] |
|
|
|
|
drawInfo := common.ActivityBetDrawData{UID: a.UID} |
|
|
|
|
db.Mysql().Get(&drawInfo) |
|
|
|
|
if drawInfo.Lucky < conf.Cost { |
|
|
|
|
a.Code = values.CodeRetry |
|
|
|
|
a.Msg = "lucky not enough" |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
// 计算权重
|
|
|
|
|
idx := util.RandWeight(weightList) |
|
|
|
|
if idx < 0 { |
|
|
|
|
a.Code = values.CodeRetry |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
rewardConf := configList[idx] |
|
|
|
|
reward := rewardConf.Reward |
|
|
|
|
err := db.Mysql().Update(&drawInfo, map[string]interface{}{ |
|
|
|
|
"lucky": gorm.Expr("lucky - ?", conf.Cost), |
|
|
|
|
}) |
|
|
|
|
if err != nil { |
|
|
|
|
a.Code = values.CodeRetry |
|
|
|
|
log.Error("ActivityBetDrawDraw err:%v", err) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if reward > 0 { |
|
|
|
|
_, _ = call.UpdateCurrencyPro(&common.UpdateCurrency{ |
|
|
|
|
CurrencyBalance: &common.CurrencyBalance{ |
|
|
|
|
UID: a.UID, |
|
|
|
|
Event: common.CurrencyEventActivityAppSpin, |
|
|
|
|
Type: common.CurrencyINR, |
|
|
|
|
Value: reward, |
|
|
|
|
NeedBet: call.GetConfigCurrencyResourceNeedBet(common.CurrencyResourceBonus, reward), |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
call.UploadActivityData(a.UID, common.ActivityIDBetDraw, common.ActivityDataJoin, reward) |
|
|
|
|
db.ES().InsertToESGO(common.ESIndexBackBetDraw, common.ESActivityBetDraw{ |
|
|
|
|
UID: a.UID, |
|
|
|
|
Time: time.Now().Unix(), |
|
|
|
|
Reward: reward, |
|
|
|
|
Type: req.WheelType, |
|
|
|
|
}) |
|
|
|
|
a.Data = &values.ActivityBetDrawDrawResp{ |
|
|
|
|
Reward: reward, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func ActivityBetDrawHistory(c *gin.Context) { |
|
|
|
|
a := app.NewApp(c) |
|
|
|
|
defer func() { |
|
|
|
|
a.Response() |
|
|
|
|
}() |
|
|
|
|
a.GetUID() |
|
|
|
|
req := values.ActivityBetDrawRecordReq{} |
|
|
|
|
if !a.S(&req) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
resp := new(values.ActivityBetDrawRecordResp) |
|
|
|
|
if !a.CheckActivityExpire(common.ActivityIDBetDraw) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
q := elastic.NewBoolQuery() |
|
|
|
|
q.Filter(elastic.NewTermQuery("Type", req.WheelType)) |
|
|
|
|
_, _ = db.ES().QueryList(common.ESIndexBackBetDraw, req.Page-1, req.Num, q, &resp.RecordList, "Time", false) |
|
|
|
|
q.Filter(elastic.NewTermQuery("UID", a.UID)) |
|
|
|
|
_, _ = db.ES().QueryList(common.ESIndexBackBetDraw, 0, 5000, q, &resp.SelfList, "Time", false) |
|
|
|
|
a.Data = resp |
|
|
|
|
} |
|
|
|
|
|