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.
62 lines
1.7 KiB
62 lines
1.7 KiB
package es |
|
|
|
// UpsertMatchData 刷新玩家战绩 |
|
// func (ES *EsClient) UpsertMatchData(uid int, game string, one *common.OneGameData, md *common.PlayerMatchData) error { |
|
// one.LastRecord = time.Now().Unix() |
|
// if md.UID == 0 { // 记录不存在 |
|
// one.DayMatch = 1 |
|
// one.WeekMatch = 1 |
|
// one.MonthMatch = 1 |
|
// if one.WinMatch > 0 { |
|
// one.DayWin = 1 |
|
// } |
|
// field := reflect.ValueOf(md).Elem().FieldByName(game) |
|
// if field.CanSet() { |
|
// field.Set(reflect.ValueOf(one).Elem()) |
|
// } |
|
// md.UID = uid |
|
// return ES.InsertToESByID(common.ESIndexMatchData, strconv.Itoa(uid), md) |
|
// } |
|
// field := reflect.ValueOf(md).Elem().FieldByName(game) |
|
// if !field.IsValid() { |
|
// return errors.New("unknow game") |
|
// } |
|
// mdo := field.Interface().(common.OneGameData) |
|
// if mdo.BestWin < one.BestWin { |
|
// mdo.BestWin = one.BestWin |
|
// } |
|
// mdo.TotalMatch += one.TotalMatch |
|
// mdo.WinMatch += one.WinMatch |
|
// now := time.Now().Unix() |
|
// if util.IsSameDayTimeStamp(mdo.LastRecord, now) { |
|
// mdo.DayMatch += 1 |
|
// mdo.DayMatchTime += one.DayMatchTime |
|
// if one.WinMatch > 0 { |
|
// mdo.DayMatch += 1 |
|
// } |
|
// } else { |
|
// mdo.DayMatch = 1 |
|
// mdo.DayMatchTime = one.DayMatchTime |
|
// if one.WinMatch > 0 { |
|
// mdo.DayMatch = 1 |
|
// } |
|
// } |
|
// if util.IsSameWeek(mdo.LastRecord, now) { |
|
// mdo.WeekMatch += 1 |
|
// } else { |
|
// mdo.WeekMatch = 1 |
|
// } |
|
// if util.IsSameMonth(mdo.LastRecord, now) { |
|
// mdo.MonthMatch += 1 |
|
// } else { |
|
// mdo.MonthMatch = 1 |
|
// } |
|
// mdo.LastRecord = now |
|
// field.Set(reflect.ValueOf(mdo)) |
|
// _, err := ES.Update(common.ESIndexMatchData, strconv.Itoa(uid), md) |
|
// if err != nil { |
|
// log.Error("err:%v", err) |
|
// return err |
|
// } |
|
// return nil |
|
// }
|
|
|