✨ 添加数据库字段(是否为点券作物,点券作物单价);实现点券购买种子;我的种子查询页面添加点券单价。
This commit is contained in:
parent
4ab21b7f7b
commit
34d4f698dd
@ -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)
|
||||
|
||||
|
||||
|
||||
@ -46,7 +46,9 @@ g_sTranslation = {
|
||||
"notNum": "❗️ 请输入购买数量!",
|
||||
"noLevel": "🔒 你的等级不够哦,努努力吧 💪",
|
||||
"noPoint": "💰 你的农场币不够哦~ 快速速氪金吧!💸",
|
||||
"noVipPoint": "💰 你的点券不够哦~ 快速速氪金吧!💸",
|
||||
"success": "✅ 成功购买{name},花费{total}农场币,剩余{point}农场币 🌾",
|
||||
"vipSuccess": "✅ 成功购买{name},花费{total}点券,剩余{point}点券 🌾",
|
||||
"errorSql": "❌ 购买失败,执行数据库错误!🛑",
|
||||
"error": "❌ 购买出错!请检查需购买的种子名称!🔍",
|
||||
},
|
||||
|
||||
28
farm/shop.py
28
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 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"]
|
||||
else:
|
||||
await g_pDBService.user.updateUserPointByUid(uid, point - total)
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user