Compare commits

..

No commits in common. "d0f388e46ba7874248974b73d3107a9c9d4ceffe" and "b5aba457a0e4c44a70b791641e1de2b0fba64fab" have entirely different histories.

4 changed files with 35 additions and 13 deletions

View File

@ -49,15 +49,14 @@ 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 int64 var swapN, matchN int64
var costN int64 var costN, gainN int64
type m struct { type m struct {
Count int64 `bson:"count"` Count int64 `bson:"count"`
} }
@ -73,10 +72,22 @@ func GetItemCount(platform string, snid, id int32, tp int) (count int64) {
} }
swapN = tc.Count swapN = tc.Count
// 比赛返回
tc = new(m)
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 && !errors.Is(err, mgo.ErrNotFound) {
logger.Logger.Warn("GetItemCount matchN error:", err)
return 0
}
matchN = tc.Count
// 消耗总数量 // 消耗总数量
tc = new(m) tc = new(m)
err = c.Pipe([]bson.M{ err = c.Pipe([]bson.M{
{"$match": bson.M{"snid": snid, "logtype": 1, "itemid": id, "typeid": common.GainWay_Exchange}}, {"$match": bson.M{"snid": snid, "logtype": 1, "itemid": id}},
{"$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 && !errors.Is(err, mgo.ErrNotFound) { if err != nil && !errors.Is(err, mgo.ErrNotFound) {
@ -85,14 +96,24 @@ func GetItemCount(platform string, snid, id int32, tp int) (count int64) {
} }
costN = tc.Count costN = tc.Count
// 获得总数量
tc = new(m)
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 && !errors.Is(err, mgo.ErrNotFound) {
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 count = costN - swapN - matchN
}
if count < 0 {
count = 0
} }
return count return count
} }

View File

@ -322,8 +322,9 @@ 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)
} }
// 统计 v卡兑换消耗数量 if v.ItemId == common.ItemIDVCard && (v.ItemNum <= 0 ||
if v.ItemId == common.ItemIDVCard && gainWay == common.GainWay_Exchange { gainWay == common.GainWay_MatchSignup || 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

@ -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.ConsumeTypeNum) this.MoneyTotal += int64(info.ConsumeNum)
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.ConsumeTypeNum) player.MoneyTotal += int64(info.ConsumeNum)
player.dirty = true player.dirty = true
player.SendDiffData() player.SendDiffData()
info.Amount[2] = player.GetVIPExpByPay(info.ConsumeNum) info.Amount[2] = player.GetVIPExpByPay(info.ConsumeNum)