Compare commits
No commits in common. "d0f388e46ba7874248974b73d3107a9c9d4ceffe" and "b5aba457a0e4c44a70b791641e1de2b0fba64fab" have entirely different histories.
d0f388e46b
...
b5aba457a0
|
@ -49,15 +49,14 @@ 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 int64
|
||||
var costN int64
|
||||
var swapN, matchN int64
|
||||
var costN, gainN int64
|
||||
type m struct {
|
||||
Count int64 `bson:"count"`
|
||||
}
|
||||
|
@ -73,10 +72,22 @@ 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, "typeid": common.GainWay_Exchange}},
|
||||
{"$match": bson.M{"snid": snid, "logtype": 1, "itemid": id}},
|
||||
{"$group": bson.M{"_id": nil, "count": bson.M{"$sum": "$count"}}},
|
||||
}).AllowDiskUse().One(tc)
|
||||
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
|
||||
|
||||
// 获得总数量
|
||||
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
|
||||
}
|
||||
if count < 0 {
|
||||
count = 0
|
||||
// 消耗数量 = 消耗总数量 - 兑换返还 - 比赛返回
|
||||
count = costN - swapN - matchN
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
|
|
@ -322,8 +322,9 @@ func (this *BagMgr) AddItems(p *Player, addItems []*Item, add int64, gainWay int
|
|||
if v.ItemId == common.ItemIDPetSkill && v.ItemNum > 0 {
|
||||
PetMgrSington.CheckShowRed(p)
|
||||
}
|
||||
// 统计 v卡兑换消耗数量
|
||||
if v.ItemId == common.ItemIDVCard && gainWay == common.GainWay_Exchange {
|
||||
if v.ItemId == common.ItemIDVCard && (v.ItemNum <= 0 ||
|
||||
gainWay == common.GainWay_MatchSignup || 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.ConsumeTypeNum)
|
||||
this.MoneyTotal += int64(info.ConsumeNum)
|
||||
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.ConsumeTypeNum)
|
||||
player.MoneyTotal += int64(info.ConsumeNum)
|
||||
player.dirty = true
|
||||
player.SendDiffData()
|
||||
info.Amount[2] = player.GetVIPExpByPay(info.ConsumeNum)
|
||||
|
|
Loading…
Reference in New Issue