Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions plugin/mcfish/main.go
Original file line number Diff line number Diff line change
@@ -791,6 +791,7 @@ func (sql *fishdb) checkCanSalesFor(uid int64, sales bool) (int, error) {
userInfo.Duration = time.Now().Unix()
userInfo.SalesPole = 0
userInfo.BuyTing = 0
userInfo.SalesFish = 0
}
if sales && userInfo.SalesPole < 5 {
residue = 5 - userInfo.SalesPole
@@ -825,6 +826,9 @@ func (sql *fishdb) selectCanSalesFishFor(uid int64, sales int) int {
_ = sql.db.Find("buff", &userInfo, "where ID = "+strconv.FormatInt(uid, 10))
if time.Now().Day() != time.Unix(userInfo.Duration, 0).Day() {
userInfo.Duration = time.Now().Unix()
// 在 checkCanSalesFor 也有更新buff时间,TODO:重构 *CanSalesFishFor 俩个函数
userInfo.SalesPole = 0
userInfo.BuyTing = 0
userInfo.SalesFish = 0
err := sql.db.Insert("buff", &userInfo)
if err != nil {
29 changes: 15 additions & 14 deletions plugin/mcfish/store.go
Original file line number Diff line number Diff line change
@@ -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)))
})
}