76 lines
1.4 KiB
Go
76 lines
1.4 KiB
Go
package model
|
|
|
|
import (
|
|
"mongo.games.com/goserver/core/logger"
|
|
"time"
|
|
|
|
"github.com/globalsign/mgo"
|
|
)
|
|
|
|
type AwardLog struct {
|
|
AwardMap map[int32]map[int32]int64 //key1:1话费 2实物 key2 itemId value:数量
|
|
Ts int64
|
|
}
|
|
|
|
var (
|
|
AwardLogDBName = "log"
|
|
AwardLogCollName = "log_award"
|
|
)
|
|
|
|
type FetchAwardLogArgs struct {
|
|
Plt string
|
|
Data *AwardLog
|
|
}
|
|
type AwardLogRes struct {
|
|
Data *AwardLog
|
|
Ts int64
|
|
}
|
|
|
|
func FetchAwardLog(plt string) (recs AwardLog, err error) {
|
|
if rpcCli == nil {
|
|
return recs, ErrRPClientNoConn
|
|
}
|
|
args := &FetchAwardLogArgs{
|
|
Plt: plt,
|
|
}
|
|
err = rpcCli.CallWithTimeout("AwardLogSvc.FetchAwardLog", args, &recs, time.Second*30)
|
|
return
|
|
}
|
|
|
|
func UpsertAwardLog(platform string, data *AwardLog) {
|
|
if rpcCli == nil {
|
|
logger.Logger.Error("model.UpsertAwardLog rpcCli == nil")
|
|
return
|
|
}
|
|
|
|
args := &FetchAwardLogArgs{
|
|
Plt: platform,
|
|
Data: data,
|
|
}
|
|
|
|
ret := &AwardLogRes{}
|
|
err := rpcCli.CallWithTimeout("AwardLogSvc.UpsertAwardLog", args, ret, time.Second*30)
|
|
if err != nil {
|
|
logger.Logger.Warn("UpsertAwardLog error:", err)
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
type RemoveAwardLogArgs struct {
|
|
Plt string
|
|
Ts time.Time
|
|
}
|
|
|
|
func RemovAwardLog(plt string, ts time.Time) (ret *mgo.ChangeInfo, err error) {
|
|
if rpcCli == nil {
|
|
return nil, ErrRPClientNoConn
|
|
}
|
|
args := &RemoveMatchRecsArgs{
|
|
Plt: plt,
|
|
Ts: ts,
|
|
}
|
|
rpcCli.CallWithTimeout("AwardLogSvc.RemoveAwardLog", args, &ret, time.Second*30)
|
|
return
|
|
}
|