fix:修复出售限制未生效的问题 (#1038)

-  修改更新购买限制逻辑的位置
- `checkCanSalesFor` & `selectCanSalesFishFor`俩个函数一个是检测出售鱼竿上限,一个是检测出售鱼上限。
  暂时解决俩个函数对于buff状态更新冲突的问题;下个版本打算重构一下这部分,把俩个函数合并一下。用一个函数就够了
This commit is contained in:
vatebur
2024-10-15 22:39:01 +08:00
committed by GitHub
parent 23c0949388
commit e653475e08
2 changed files with 19 additions and 14 deletions

View File

@@ -194,13 +194,6 @@ func init() {
}
}
// 更新交易鱼类数量
if checkIsFish(thingName) {
err := dbdata.updateCanSalesFishFor(uid, number)
if err != nil {
ctx.SendChain(message.Text("[ERROR,记录鱼类交易数量失败,此次交易不记录]:", err))
}
}
records, err := dbdata.getUserThingInfo(uid, "唱片")
if err != nil {
ctx.SendChain(message.Text("[ERROR at store.go.9.1]:", err))
@@ -321,6 +314,14 @@ func init() {
logrus.Warnln(err)
}
}
// 更新交易鱼类数量
if checkIsFish(thingName) {
err := dbdata.updateCanSalesFishFor(uid, number)
if err != nil {
ctx.SendChain(message.Text("[ERROR,记录鱼类交易数量失败,此次交易不记录]:", err))
}
}
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("成功出售", thingName, "", number, "个", ",你赚到了", pice*number, msg)))
})
engine.OnRegex(`^出售所有垃圾`, getdb, refreshFish).SetBlock(true).Limit(limitSet).Handle(func(ctx *zero.Ctx) {
@@ -532,13 +533,6 @@ func init() {
}
}
// 更新交易鱼类数量
if checkIsFish(thingName) {
err := dbdata.updateCanSalesFishFor(uid, number)
if err != nil {
ctx.SendChain(message.Text("[ERROR,更新鱼类交易数量失败,此次交易不记录]:", err))
}
}
thing := thingInfos[index]
if thing.Number < number {
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("商店数量不足")))
@@ -656,6 +650,13 @@ func init() {
logrus.Warnln(err)
}
}
// 更新交易鱼类数量
if checkIsFish(thingName) {
err := dbdata.updateCanSalesFishFor(uid, number)
if err != nil {
ctx.SendChain(message.Text("[ERROR,更新鱼类交易数量失败,此次交易不记录]:", err))
}
}
ctx.Send(message.ReplyWithMessage(ctx.Event.MessageID, message.Text("你用", price, "购买了", number, thingName)))
})
}