diff --git a/command.py b/command.py index 5cd3886..01c077e 100644 --- a/command.py +++ b/command.py @@ -95,7 +95,7 @@ diuse_farm = on_alconna( Subcommand("sign-in", help_text="农场签到"), Subcommand("admin-up", Args["num?", int], help_text="农场下阶段"), Subcommand("point-to-vipPoint", Args["num?", int], help_text="农场币换点券"), - Subcommand("my-vipPoint", help_text="我的点券") + Subcommand("my-vipPoint", help_text="我的点券"), ), priority=5, block=True, @@ -693,5 +693,3 @@ async def _(session: Uninfo): await MessageUtils.build_message( g_sTranslation["basic"]["vipPoint"].format(vipPoint=vipPoint) ).send(reply_to=True) - - diff --git a/config.py b/config.py index 19f837c..091c386 100644 --- a/config.py +++ b/config.py @@ -46,7 +46,9 @@ g_sTranslation = { "notNum": "❗️ 请输入购买数量!", "noLevel": "🔒 你的等级不够哦,努努力吧 💪", "noPoint": "💰 你的农场币不够哦~ 快速速氪金吧!💸", + "noVipPoint": "💰 你的点券不够哦~ 快速速氪金吧!💸", "success": "✅ 成功购买{name},花费{total}农场币,剩余{point}农场币 🌾", + "vipSuccess": "✅ 成功购买{name},花费{total}点券,剩余{point}点券 🌾", "errorSql": "❌ 购买失败,执行数据库错误!🛑", "error": "❌ 购买出错!请检查需购买的种子名称!🔍", }, diff --git a/farm/shop.py b/farm/shop.py index 812b1e2..e1a8b00 100644 --- a/farm/shop.py +++ b/farm/shop.py @@ -1,6 +1,5 @@ import math -from zhenxun.services.log import logger from zhenxun.utils.image_utils import ImageTemplate from ..config import g_sResourcePath, g_sTranslation @@ -33,7 +32,8 @@ class CShopManager: columnName = [ "-", "种子名称", - "种子单价", + "农场币", + "点券", "解锁等级", "果实单价", "收获经验", @@ -77,7 +77,8 @@ class CShopManager: [ icon, plant["name"], # 种子名称 - plant["buy"], # 种子单价 + plant["buy"], # 农场币种子单价 + plant["vipBuy"], # 点券种子单价 plant["level"], # 解锁等级 plant["price"], # 果实单价 plant["experience"], # 收获经验 @@ -125,21 +126,32 @@ class CShopManager: if level[0] < int(plantInfo["level"]): return g_sTranslation["buySeed"]["noLevel"] - point = await g_pDBService.user.getUserPointByUid(uid) - total = int(plantInfo["buy"]) * num - + """ logger.debug( f"用户:{uid}购买{name},数量为{num}。用户农场币为{point},购买需要{total}" ) - - if point < total: - return g_sTranslation["buySeed"]["noPoint"] + """ + if plantInfo["isVip"] == 1: + vipPoint = await g_pDBService.user.getUserVipPointByUid(uid) + total = int(plantInfo["vipBuy"]) * num + if vipPoint < total: + return g_sTranslation["buySeed"]["noVipPoint"] + await g_pDBService.user.updateUserVipPointByUid(uid, vipPoint - total) else: + point = await g_pDBService.user.getUserPointByUid(uid) + total = int(plantInfo["buy"]) * num + if point < total: + return g_sTranslation["buySeed"]["noPoint"] await g_pDBService.user.updateUserPointByUid(uid, point - total) - if not await g_pDBService.userSeed.addUserSeedByUid(uid, name, num): - return g_sTranslation["buySeed"]["errorSql"] + if not await g_pDBService.userSeed.addUserSeedByUid(uid, name, num): + return g_sTranslation["buySeed"]["errorSql"] + if plantInfo["isVip"] == 1: + return g_sTranslation["buySeed"]["vipSuccess"].format( + name=name, total=total, point=vipPoint - total + ) + else: return g_sTranslation["buySeed"]["success"].format( name=name, total=total, point=point - total ) diff --git a/resource/db/plant.db b/resource/db/plant.db index a198f31..7597ade 100644 Binary files a/resource/db/plant.db and b/resource/db/plant.db differ