Merge remote-tracking branch 'origin/main' into Beta
This commit is contained in:
+1
-1
@@ -654,7 +654,7 @@ async def _(session: Uninfo, num: Query[int] = AlconnaQuery("num", 0)):
|
||||
|
||||
|
||||
diuse_farm.shortcut(
|
||||
"农场币换点券(.*?)",
|
||||
"点券兑换(.*?)",
|
||||
command="我的农场",
|
||||
arguments=["point-to-vipPoint"],
|
||||
prefix=True,
|
||||
|
||||
@@ -46,7 +46,9 @@ g_sTranslation = {
|
||||
"notNum": "❗️ 请输入购买数量!",
|
||||
"noLevel": "🔒 你的等级不够哦,努努力吧 💪",
|
||||
"noPoint": "💰 你的农场币不够哦~ 快速速氪金吧!💸",
|
||||
"noVipPoint": "💰 你的点券不够哦~ 快速速氪金吧!💸",
|
||||
"success": "✅ 成功购买{name},花费{total}农场币,剩余{point}农场币 🌾",
|
||||
"vipSuccess": "✅ 成功购买{name},花费{total}点券,剩余{point}点券 🌾",
|
||||
"errorSql": "❌ 购买失败,执行数据库错误!🛑",
|
||||
"error": "❌ 购买出错!请检查需购买的种子名称!🔍",
|
||||
},
|
||||
|
||||
+32
-9
@@ -1150,12 +1150,25 @@ class CFarmManager:
|
||||
|
||||
@classmethod
|
||||
async def pointToVipPointByUid(cls, uid: str, num: int) -> str:
|
||||
"""农场币兑换点券
|
||||
"""点券兑换
|
||||
num:用户传参,即将兑换的点券
|
||||
pro:兑换倍数;兑换倍数乘以num即为需要消耗的农场币
|
||||
Args:
|
||||
uid (str): 用户Uid
|
||||
num (int): 兑换点券数量
|
||||
Returns:
|
||||
str: 返回结果
|
||||
兑换比例在配置文件中配置
|
||||
目前配置文件中默认是20倍
|
||||
100点券需要20000农场币
|
||||
赠送点券规则:
|
||||
小于2000点券:0
|
||||
2000-5000点券:100
|
||||
5000-50000点券:280
|
||||
大于50000点券:3000
|
||||
"""
|
||||
if num <= 0:
|
||||
return "点券兑换数量必须大于0"
|
||||
if num < 100:
|
||||
return "点券兑换数量必须大于等于100"
|
||||
|
||||
pro = int(Config.get_config("zhenxun_plugin_farm", "点券兑换倍数"))
|
||||
pro *= num
|
||||
@@ -1164,15 +1177,25 @@ class CFarmManager:
|
||||
if point < pro:
|
||||
return f"你的农场币不足,当前农场币为{point},兑换还需要{pro - point}农场币"
|
||||
|
||||
p = await g_pDBService.user.getUserVipPointByUid(uid)
|
||||
|
||||
giftPoints: int
|
||||
if num < 2000:
|
||||
giftPoints = 0
|
||||
elif num < 5000:
|
||||
giftPoints = 100
|
||||
elif num < 50000:
|
||||
giftPoints = 280
|
||||
else:
|
||||
giftPoints = 3000
|
||||
|
||||
number = num + p + giftPoints
|
||||
await g_pDBService.user.updateUserVipPointByUid(uid, int(number))
|
||||
|
||||
point -= pro
|
||||
await g_pDBService.user.updateUserPointByUid(uid, int(point))
|
||||
|
||||
p = await g_pDBService.user.getUserVipPointByUid(uid)
|
||||
number = num + p
|
||||
|
||||
await g_pDBService.user.updateUserVipPointByUid(uid, int(number))
|
||||
|
||||
return f"兑换{num}点券成功,当前点券:{number},当前农场币:{point}"
|
||||
return f"兑换{num}点券成功,当前点券:{number},赠送点券:{giftPoints},当前农场币:{point}"
|
||||
|
||||
|
||||
g_pFarmManager = CFarmManager()
|
||||
|
||||
+23
-11
@@ -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
|
||||
)
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user