Selaa lähdekoodia

test

tags/v1.1.3
huangjiajun 1 vuosi sitten
vanhempi
commit
d59e1fffed
1 muutettua tiedostoa jossa 7 lisäystä ja 16 poistoa
  1. +7
    -16
      svc/svc_day_luck_draw_reward.go

+ 7
- 16
svc/svc_day_luck_draw_reward.go Näytä tiedosto

@@ -24,20 +24,8 @@ func InitForDayLuckDraw(redisAddr string) (err error) {
}

//随机几个用户
func RandUser(sess *xorm.Session) []string {
func RandUser(sess *xorm.Session, setting *model.DayLuckDrawSetting) []string {
var newOid = make([]string, 0)

setting := db.GetDayLuckDrawSettingSess(sess)
if setting == nil {
return newOid
}
now := time.Now().Unix()
if setting.IsUse == 0 || setting.StartTime.IsZero() || setting.EndTime.IsZero() {
return newOid
}
if now < setting.StartTime.Unix() || now > setting.EndTime.Unix() {
return newOid
}
count := 0
var rewardData = make([]md.RewardData, 0)
err := json.Unmarshal([]byte(setting.RewardData), &rewardData)
@@ -156,11 +144,14 @@ func GetUserReward(eg *xorm.Engine, mid string, isTask bool) error {
for _, v := range rewardData {
rewardDataMap[zhios_day_luck_draw_utils.StrToInt64(v.Key)] = zhios_day_luck_draw_utils.StrToInt(v.Num)
}
uids := RandUser(sess)
uids := RandUser(sess, setting)
var award = make(map[string]int64)
var awardIdMap = make(map[int64]int)
for _, v := range uids {
for i := 0; i < 10; i++ {
if award[v] > 0 {
continue
}
key := AwardRandomNumberFor100000()
awardId := int64(0)
for _, awardProbabilityMap := range probabilityMap {
@@ -177,11 +168,11 @@ func GetUserReward(eg *xorm.Engine, mid string, isTask bool) error {
//查下已产生用户数量
awardCount, ok := awardIdMap[awardId]
//查下总数量
rewardDataCount, ok := rewardDataMap[awardId]
rewardDataCount, ok1 := rewardDataMap[awardId]
if ok == false {
continue
}
if ok {
if ok1 {
if awardCount+1 > rewardDataCount {
continue
}


Ladataan…
Peruuta
Tallenna