上传物品叠加-1 的bug
This commit is contained in:
parent
e08860bcb2
commit
5755b8101a
@ -236,7 +236,7 @@ func (this *ModelItemsComp) AddItemToUserPackByGrid(uId string, gridid string, i
|
|||||||
if num < 0 {
|
if num < 0 {
|
||||||
err = ItemNotEnoughError
|
err = ItemNotEnoughError
|
||||||
} else {
|
} else {
|
||||||
if num > int64(conf.UpperLimit) {
|
if conf.UpperLimit > 0 && num > int64(conf.UpperLimit) {
|
||||||
err = GirdAmountUpper
|
err = GirdAmountUpper
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
@ -261,6 +261,10 @@ func (this *ModelItemsComp) addItemToUserPack(uid string, items []*pb.DB_UserIte
|
|||||||
if conf, err = this.module.configure.GetItemConfigure(itemId); err != nil {
|
if conf, err = this.module.configure.GetItemConfigure(itemId); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if conf.UpperLimit == 0 {
|
||||||
|
err = fmt.Errorf("item UpperLimit is 0")
|
||||||
|
return
|
||||||
|
}
|
||||||
isNew = true
|
isNew = true
|
||||||
leftnum = int64(addnum)
|
leftnum = int64(addnum)
|
||||||
add = make([]*pb.DB_UserItemData, 0)
|
add = make([]*pb.DB_UserItemData, 0)
|
||||||
@ -281,17 +285,23 @@ func (this *ModelItemsComp) addItemToUserPack(uid string, items []*pb.DB_UserIte
|
|||||||
update = append(update, v)
|
update = append(update, v)
|
||||||
break
|
break
|
||||||
} else if num > 0 && num > int64(v.Amount) {
|
} else if num > 0 && num > int64(v.Amount) {
|
||||||
if num <= int64(conf.UpperLimit) {
|
if conf.UpperLimit > 0 {
|
||||||
|
if num <= int64(conf.UpperLimit) {
|
||||||
|
leftnum = 0
|
||||||
|
v.Amount = uint32(num)
|
||||||
|
update = append(update, v)
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
if v.Amount < uint32(conf.UpperLimit) {
|
||||||
|
leftnum = int64(num - int64(conf.UpperLimit))
|
||||||
|
v.Amount = uint32(conf.UpperLimit)
|
||||||
|
update = append(update, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
leftnum = 0
|
leftnum = 0
|
||||||
v.Amount = uint32(num)
|
v.Amount = uint32(num)
|
||||||
update = append(update, v)
|
update = append(update, v)
|
||||||
break
|
|
||||||
} else {
|
|
||||||
if v.Amount < uint32(conf.UpperLimit) {
|
|
||||||
leftnum = int64(num - int64(conf.UpperLimit))
|
|
||||||
v.Amount = uint32(conf.UpperLimit)
|
|
||||||
update = append(update, v)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if num == 0 {
|
} else if num == 0 {
|
||||||
leftnum = 0
|
leftnum = 0
|
||||||
@ -306,7 +316,7 @@ func (this *ModelItemsComp) addItemToUserPack(uid string, items []*pb.DB_UserIte
|
|||||||
if leftnum > 0 { //还没有放完 寻找空的格子填充
|
if leftnum > 0 { //还没有放完 寻找空的格子填充
|
||||||
index := int32(len(items))
|
index := int32(len(items))
|
||||||
for leftnum > 0 { //需要补充格子
|
for leftnum > 0 { //需要补充格子
|
||||||
if leftnum <= int64(conf.UpperLimit) {
|
if conf.UpperLimit < 0 || (conf.UpperLimit > 0 && leftnum <= int64(conf.UpperLimit)) {
|
||||||
grid := &pb.DB_UserItemData{
|
grid := &pb.DB_UserItemData{
|
||||||
GridId: primitive.NewObjectID().Hex(),
|
GridId: primitive.NewObjectID().Hex(),
|
||||||
UId: uid,
|
UId: uid,
|
||||||
|
Loading…
Reference in New Issue
Block a user