Compare commits
2 Commits
b5aba457a0
...
d0f388e46b
Author | SHA1 | Date |
---|---|---|
|
d0f388e46b | |
|
c21dd8e565 |
|
@ -49,14 +49,15 @@ func (svc *ItemLogSvc) InsertItemLog(log *model.ItemLog, ret *bool) (err error)
|
|||
return
|
||||
}
|
||||
|
||||
// GetItemCount 获取v卡兑换消耗数量
|
||||
func GetItemCount(platform string, snid, id int32, tp int) (count int64) {
|
||||
c := ItemLogsCollection(platform)
|
||||
if c == nil {
|
||||
return 0
|
||||
}
|
||||
var err error
|
||||
var swapN, matchN int64
|
||||
var costN, gainN int64
|
||||
var swapN int64
|
||||
var costN int64
|
||||
type m struct {
|
||||
Count int64 `bson:"count"`
|
||||
}
|
||||
|
@ -72,22 +73,10 @@ func GetItemCount(platform string, snid, id int32, tp int) (count int64) {
|
|||
}
|
||||
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)
|
||||
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"}}},
|
||||
}).AllowDiskUse().One(tc)
|
||||
if err != nil && !errors.Is(err, mgo.ErrNotFound) {
|
||||
|
@ -96,24 +85,14 @@ func GetItemCount(platform string, snid, id int32, tp int) (count int64) {
|
|||
}
|
||||
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 {
|
||||
// 获得数量 = 获得总数量 - 兑换返还 - 比赛返回
|
||||
count = gainN - swapN - matchN
|
||||
} else {
|
||||
// 消耗数量 = 消耗总数量 - 兑换返还 - 比赛返回
|
||||
count = costN - swapN - matchN
|
||||
// 消耗数量 = 消耗总数量 - 兑换返还
|
||||
count = costN - swapN
|
||||
}
|
||||
if count < 0 {
|
||||
count = 0
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
|
|
@ -322,9 +322,8 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int
|
|||
if v.ItemId == common.ItemIDPetSkill && v.ItemNum > 0 {
|
||||
PetMgrSington.CheckShowRed(p)
|
||||
}
|
||||
if v.ItemId == common.ItemIDVCard && (v.ItemNum <= 0 ||
|
||||
gainWay == common.GainWay_MatchSignup || gainWay == common.GainWay_Exchange) {
|
||||
// 比赛报名返还,兑换返还
|
||||
// 统计 v卡兑换消耗数量
|
||||
if v.ItemId == common.ItemIDVCard && gainWay == common.GainWay_Exchange {
|
||||
p.VCardCost += -v.ItemNum
|
||||
if p.VCardCost < 0 {
|
||||
p.VCardCost = 0
|
||||
|
|
|
@ -3928,7 +3928,7 @@ func (this *Player) GetPayGoodsInfo() {
|
|||
this.AddDiamond(int64(info.Amount[1]), 0, info.GainWay, "Callback_login", info.Remark)
|
||||
}
|
||||
this.AddMoneyPayTotal(int64(info.ConsumeNum))
|
||||
this.MoneyTotal += int64(info.ConsumeNum)
|
||||
this.MoneyTotal += int64(info.ConsumeTypeNum)
|
||||
if info.ItemInfo != nil {
|
||||
for _, v := range info.ItemInfo {
|
||||
items = append(items, &Item{ItemId: v.ItemId, ItemNum: v.ItemNum})
|
||||
|
|
|
@ -3444,7 +3444,7 @@ func init() {
|
|||
player.AddDiamond(int64(info.Amount[1]), 0, info.GainWay, "Callback", info.Remark)
|
||||
}
|
||||
player.AddMoneyPayTotal(int64(info.ConsumeNum))
|
||||
player.MoneyTotal += int64(info.ConsumeNum)
|
||||
player.MoneyTotal += int64(info.ConsumeTypeNum)
|
||||
player.dirty = true
|
||||
player.SendDiffData()
|
||||
info.Amount[2] = player.GetVIPExpByPay(info.ConsumeNum)
|
||||
|
|
Loading…
Reference in New Issue