add user meta check deadline

This commit is contained in:
xiaomlove
2023-01-06 20:19:21 +08:00
parent 8d8e3b7768
commit ad6e66ce56
9 changed files with 22 additions and 1 deletions

View File

@@ -504,6 +504,9 @@ class UserRepository extends BaseRepository
$log .= ", meta exists";
$keyExistsUpdates['updated_at'] = now();
if (!empty($keyExistsUpdates['duration'])) {
if ($metaExists->deadline === null) {
throw new \RuntimeException(nexus_trans('user.metas.already_valid_forever', ['meta_key_text' => $metaExists->metaKeyText]));
}
$log .= ", has duration: {$keyExistsUpdates['duration']}";
if ($metaExists->deadline && $metaExists->deadline->gte(now())) {
$log .= ", not expire";

View File

@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-01-05');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-01-06');
defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");

View File

@@ -166,6 +166,7 @@ $lang_mybonus = array
'text_buy_change_username_card_note' => '修改用户名一次,永久有效。',
'text_success_buy_change_username_card' => "祝贺你,成功购买了<b>改名卡</b>",
'text_change_username_card_already_has' => '已经拥有改名卡',
'text_rainbow_id_already_valid_forever' => '已永久拥有彩虹 ID',
);
?>

View File

@@ -166,6 +166,7 @@ $lang_mybonus = array
'text_buy_change_username_card_note' => '修改用戶名一次,永久有效。',
'text_success_buy_change_username_card' => "祝賀你,成功購買了<b>改名卡</b>",
'text_change_username_card_already_has' => '已經擁有改名卡',
'text_rainbow_id_already_valid_forever' => '已永久擁有彩虹 ID',
);
?>

View File

@@ -166,6 +166,7 @@ where<ul><li><b>A</b> is an intermediate variable</li><li><b>Ti</b> is the <b>i<
'text_buy_change_username_card_note' => 'Change your username once and it will be valid forever.',
'text_success_buy_change_username_card' => "Congratulations on your successful purchase of a <b>change username card</b>!",
'text_change_username_card_already_has' => 'Already have a change username card',
'text_rainbow_id_already_valid_forever' => 'Already have a permanent Rainbow ID',
);
?>

View File

@@ -436,6 +436,12 @@ for ($i=0; $i < count($allBonus); $i++)
} else {
print("<td class=\"rowfollow\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"".$lang_mybonus['submit_exchange']."\" /></td>");
}
} elseif ($bonusarray['art'] == 'rainbow_id') {
if (\App\Models\UserMeta::query()->where('uid', $CURUSER['id'])->where('meta_key', \App\Models\UserMeta::META_KEY_PERSONALIZED_USERNAME)->whereNull('deadline')->exists()) {
print("<td class=\"rowfollow\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"".$lang_mybonus['text_rainbow_id_already_valid_forever']."\" disabled=\"disabled\"/></td>");
} else {
print("<td class=\"rowfollow\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"".$lang_mybonus['submit_exchange']."\" /></td>");
}
} else {
print("<td class=\"rowfollow\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"".$lang_mybonus['submit_exchange']."\" /></td>");
}

View File

@@ -38,4 +38,7 @@ return [
'subject' => 'Get Props:name',
'body' => ':operator Grant you :name, Validity period: :duration.',
],
'metas' => [
'already_valid_forever' => ':meta_key_text 已經永久有效',
],
];

View File

@@ -38,4 +38,7 @@ return [
'subject' => '获得道具::name',
'body' => ':operator 授予你 :name 有效期::duration。',
],
'metas' => [
'already_valid_forever' => ':meta_key_text already valid forever',
],
];

View File

@@ -38,4 +38,7 @@ return [
'subject' => '獲得道具::name',
'body' => ':operator 授予你 :name 有效期::duration。',
],
'metas' => [
'already_valid_forever' => ':meta_key_text 已經永久有效',
],
];