This commit is contained in:
by 2024-07-10 16:34:40 +08:00
commit 351d5979ba
10 changed files with 844 additions and 834 deletions

View File

@ -1,6 +1,7 @@
package svc package svc
import ( import (
"errors"
"github.com/globalsign/mgo" "github.com/globalsign/mgo"
"github.com/globalsign/mgo/bson" "github.com/globalsign/mgo/bson"
"mongo.games.com/game/dbproxy/mongo" "mongo.games.com/game/dbproxy/mongo"
@ -113,10 +114,10 @@ func GetMoneyTotal(platform string, snid int32) int64 {
} }
tc := new(m) tc := new(m)
err = c.Pipe([]bson.M{ err = c.Pipe([]bson.M{
{"$match": bson.M{"snid": snid, "state": 1, "consumenum": bson.M{"$gt": 0}}}, {"$match": bson.M{"snid": snid, "state": 1, "consumetypenum": bson.M{"$gt": 0}}},
{"$group": bson.M{"_id": nil, "total": bson.M{"$sum": "$consumenum"}}}, {"$group": bson.M{"_id": nil, "total": bson.M{"$sum": "$consumetypenum"}}},
}).AllowDiskUse().One(tc) }).AllowDiskUse().One(tc)
if err != nil { if err != nil && !errors.Is(err, mgo.ErrNotFound) {
logger.Logger.Error("GetMoneyTotal error:", err) logger.Logger.Error("GetMoneyTotal error:", err)
return 0 return 0
} }

View File

@ -1,6 +1,7 @@
package svc package svc
import ( import (
"errors"
"net/rpc" "net/rpc"
"github.com/globalsign/mgo" "github.com/globalsign/mgo"
@ -48,14 +49,15 @@ func (svc *ItemLogSvc) InsertItemLog(log *model.ItemLog, ret *bool) (err error)
return return
} }
// GetItemCount 获取v卡兑换消耗数量
func GetItemCount(platform string, snid, id int32, tp int) (count int64) { func GetItemCount(platform string, snid, id int32, tp int) (count int64) {
c := ItemLogsCollection(platform) c := ItemLogsCollection(platform)
if c == nil { if c == nil {
return 0 return 0
} }
var err error var err error
var swapN, matchN int64 var swapN int64
var costN, gainN int64 var costN int64
type m struct { type m struct {
Count int64 `bson:"count"` Count int64 `bson:"count"`
} }
@ -65,51 +67,32 @@ func GetItemCount(platform string, snid, id int32, tp int) (count int64) {
{"$match": bson.M{"snid": snid, "logtype": 0, "itemid": id, "typeid": common.GainWay_Exchange}}, {"$match": bson.M{"snid": snid, "logtype": 0, "itemid": id, "typeid": common.GainWay_Exchange}},
{"$group": bson.M{"_id": nil, "count": bson.M{"$sum": "$count"}}}, {"$group": bson.M{"_id": nil, "count": bson.M{"$sum": "$count"}}},
}).AllowDiskUse().One(tc) }).AllowDiskUse().One(tc)
if err != nil { if err != nil && !errors.Is(err, mgo.ErrNotFound) {
logger.Logger.Warn("GetItemCount swapN error:", err) logger.Logger.Warn("GetItemCount swapN error:", err)
return 0 return 0
} }
swapN = tc.Count swapN = tc.Count
// 比赛返回
err = c.Pipe([]bson.M{
{"$match": bson.M{"snid": snid, "logtype": 0, "itemid": id, "typeid": common.GainWay_MatchSignup}},
{"$group": bson.M{"_id": nil, "count": bson.M{"$sum": "$count"}}},
}).AllowDiskUse().One(tc)
if err != nil {
logger.Logger.Warn("GetItemCount matchN error:", err)
return 0
}
matchN = tc.Count
// 消耗总数量 // 消耗总数量
tc = new(m)
err = c.Pipe([]bson.M{ err = c.Pipe([]bson.M{
{"$match": bson.M{"snid": snid, "logtype": 1, "itemid": id}}, {"$match": bson.M{"snid": snid, "logtype": 1, "itemid": id, "typeid": common.GainWay_Exchange}},
{"$group": bson.M{"_id": nil, "count": bson.M{"$sum": "$count"}}}, {"$group": bson.M{"_id": nil, "count": bson.M{"$sum": "$count"}}},
}).AllowDiskUse().One(tc) }).AllowDiskUse().One(tc)
if err != nil { if err != nil && !errors.Is(err, mgo.ErrNotFound) {
logger.Logger.Warn("GetItemCount costN error:", err) logger.Logger.Warn("GetItemCount costN error:", err)
return 0 return 0
} }
costN = tc.Count costN = tc.Count
// 获得总数量
err = c.Pipe([]bson.M{
{"$match": bson.M{"snid": snid, "logtype": 0, "itemid": id}},
{"$group": bson.M{"_id": nil, "count": bson.M{"$sum": "$count"}}},
}).AllowDiskUse().One(tc)
if err != nil {
logger.Logger.Warn("GetItemCount gainN error:", err)
return 0
}
gainN = tc.Count
if tp == 0 { if tp == 0 {
// 获得数量 = 获得总数量 - 兑换返还 - 比赛返回 // 获得数量 = 获得总数量 - 兑换返还 - 比赛返回
count = gainN - swapN - matchN
} else { } else {
// 消耗数量 = 消耗总数量 - 兑换返还 - 比赛返回 // 消耗数量 = 消耗总数量 - 兑换返还
count = costN - swapN - matchN count = costN - swapN
}
if count < 0 {
count = 0
} }
return count return count
} }

View File

@ -328,6 +328,10 @@ func (svc *PlayerDataSvc) GetPlayerDataBySnId(args *model.GetPlayerDataBySnIdArg
return nil return nil
} }
defer func() {
logger.Logger.Debugf("Player Data: snid:%v VCardCost:%v MoneyTotal:%v", ret.Pd.SnId, ret.Pd.VCardCost, ret.Pd.MoneyTotal)
}()
f := func(p *model.PlayerData) { f := func(p *model.PlayerData) {
// 更新一下绑定关系 // 更新一下绑定关系
if p.PSnId > 0 && p.PCode != "" { if p.PSnId > 0 && p.PCode != "" {
@ -410,7 +414,6 @@ func (svc *PlayerDataSvc) GetPlayerDataBySnId(args *model.GetPlayerDataBySnIdArg
if args.CorrectData && ret.Pd != nil { if args.CorrectData && ret.Pd != nil {
CorrectData(ret.Pd) CorrectData(ret.Pd)
} }
return nil return nil
} }

View File

@ -708,6 +708,8 @@ func ConvertPlayerDataToWebData(param *WebPlayerDataParam) *webapi.PlayerData {
pdfw.IsPermit = param.IsPermit pdfw.IsPermit = param.IsPermit
pdfw.PermitScore = param.PermitScore pdfw.PermitScore = param.PermitScore
pdfw.Long = param.Long pdfw.Long = param.Long
pdfw.VCardCost = param.VCardCost
pdfw.MoneyTotal = param.MoneyTotal
return pdfw return pdfw
} }
func (this *PlayerData) IsMarkFlag(flag int) bool { func (this *PlayerData) IsMarkFlag(flag int) bool {

File diff suppressed because it is too large Load Diff

View File

@ -205,6 +205,8 @@ message PlayerData{
bool IsPermit = 56; // bool IsPermit = 56; //
int64 Long = 57; // int64 Long = 57; //
int64 PermitScore = 58; // int64 PermitScore = 58; //
int64 VCardCost = 59; // v卡消耗
int64 MoneyTotal = 60; //
} }
message RoomInfo{ message RoomInfo{

2
public

@ -1 +1 @@
Subproject commit 1869e4641809a14e9e5d025e303bdb56350a801c Subproject commit b99c38049f5744e9eda2860329a72fef4324520e

View File

@ -322,9 +322,8 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int
if v.ItemId == common.ItemIDPetSkill && v.ItemNum > 0 { if v.ItemId == common.ItemIDPetSkill && v.ItemNum > 0 {
PetMgrSington.CheckShowRed(p) PetMgrSington.CheckShowRed(p)
} }
if v.ItemId == common.ItemIDVCard && (v.ItemNum <= 0 || // 统计 v卡兑换消耗数量
gainWay == common.GainWay_MatchSignup || gainWay == common.GainWay_Exchange) { if v.ItemId == common.ItemIDVCard && gainWay == common.GainWay_Exchange {
// 比赛报名返还,兑换返还
p.VCardCost += -v.ItemNum p.VCardCost += -v.ItemNum
if p.VCardCost < 0 { if p.VCardCost < 0 {
p.VCardCost = 0 p.VCardCost = 0

View File

@ -376,7 +376,6 @@ func (this *Player) OnLogined() {
this.SendToRepSrv(this.PlayerData) this.SendToRepSrv(this.PlayerData)
//红点检测 //红点检测
this.CheckShowRed() this.CheckShowRed()
this.SCItems()
TaskSubjectSingleton.Touch(common.TaskTypeLogin, &TaskData{SnId: this.SnId, Num: 1}) // 登录游戏 TaskSubjectSingleton.Touch(common.TaskTypeLogin, &TaskData{SnId: this.SnId, Num: 1}) // 登录游戏
@ -3076,6 +3075,7 @@ func (this *Player) SendPlayerInfo() {
if this.scene != nil && this.thrscene == 0 { if this.scene != nil && this.thrscene == 0 {
this.SendGameConfig(int32(this.scene.gameId), this.Platform, this.Channel) this.SendGameConfig(int32(this.scene.gameId), this.Platform, this.Channel)
} }
this.SCItems()
//this.SendJackpotInfo() //this.SendJackpotInfo()
} }
@ -3928,7 +3928,7 @@ func (this *Player) GetPayGoodsInfo() {
this.AddDiamond(int64(info.Amount[1]), 0, info.GainWay, "Callback_login", info.Remark) this.AddDiamond(int64(info.Amount[1]), 0, info.GainWay, "Callback_login", info.Remark)
} }
this.AddMoneyPayTotal(int64(info.ConsumeNum)) this.AddMoneyPayTotal(int64(info.ConsumeNum))
this.MoneyTotal += int64(info.ConsumeNum) this.MoneyTotal += int64(info.ConsumeTypeNum)
if info.ItemInfo != nil { if info.ItemInfo != nil {
for _, v := range info.ItemInfo { for _, v := range info.ItemInfo {
items = append(items, &Item{ItemId: v.ItemId, ItemNum: v.ItemNum}) items = append(items, &Item{ItemId: v.ItemId, ItemNum: v.ItemNum})

View File

@ -3444,7 +3444,7 @@ func init() {
player.AddDiamond(int64(info.Amount[1]), 0, info.GainWay, "Callback", info.Remark) player.AddDiamond(int64(info.Amount[1]), 0, info.GainWay, "Callback", info.Remark)
} }
player.AddMoneyPayTotal(int64(info.ConsumeNum)) player.AddMoneyPayTotal(int64(info.ConsumeNum))
player.MoneyTotal += int64(info.ConsumeNum) player.MoneyTotal += int64(info.ConsumeTypeNum)
player.dirty = true player.dirty = true
player.SendDiffData() player.SendDiffData()
info.Amount[2] = player.GetVIPExpByPay(info.ConsumeNum) info.Amount[2] = player.GetVIPExpByPay(info.ConsumeNum)