From 0845bca268dddbb6947f5359b8e95aa9d19cdfb6 Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Sun, 29 Jan 2023 20:00:58 +0800 Subject: [PATCH] medal add gift_fee_factor and user_medal add priority --- .../Resources/System/MedalResource.php | 7 ++ app/Models/BonusLogs.php | 2 + app/Models/Medal.php | 18 ++++ app/Models/User.php | 4 +- app/Repositories/BonusRepository.php | 76 +++++++++++++--- app/Repositories/MedalRepository.php | 30 ++++++- ...31_add_gift_fee_factor_to_medals_table.php | 32 +++++++ ...0836_add_priority_to_user_medals_table.php | 32 +++++++ include/constants.php | 2 +- include/functions.php | 26 ++++-- public/ajax.php | 23 +++++ public/medal.php | 90 +++++++++++++------ public/userdetails.php | 12 +-- resources/lang/en/bonus.php | 1 + resources/lang/en/label.php | 1 + resources/lang/en/medal.php | 7 ++ resources/lang/en/message.php | 4 + resources/lang/zh_CN/bonus.php | 1 + resources/lang/zh_CN/label.php | 1 + resources/lang/zh_CN/medal.php | 4 + resources/lang/zh_CN/message.php | 4 + resources/lang/zh_TW/bonus.php | 1 + resources/lang/zh_TW/label.php | 1 + resources/lang/zh_TW/medal.php | 7 ++ resources/lang/zh_TW/message.php | 4 + 25 files changed, 335 insertions(+), 55 deletions(-) create mode 100644 database/migrations/2023_01_27_143831_add_gift_fee_factor_to_medals_table.php create mode 100644 database/migrations/2023_01_28_170836_add_priority_to_user_medals_table.php diff --git a/app/Filament/Resources/System/MedalResource.php b/app/Filament/Resources/System/MedalResource.php index 73a316e4..a621ef9a 100644 --- a/app/Filament/Resources/System/MedalResource.php +++ b/app/Filament/Resources/System/MedalResource.php @@ -76,6 +76,12 @@ class MedalResource extends Resource ->numeric() ->default(0) , + Forms\Components\TextInput::make('gift_fee_factor') + ->label(__('medal.fields.gift_fee_factor')) + ->helperText(__('medal.fields.gift_fee_factor_help')) + ->numeric() + ->default(0) + , Forms\Components\Textarea::make('description') ->label(__('label.description')) , @@ -96,6 +102,7 @@ class MedalResource extends Resource ->formatStateUsing(fn ($record) => new HtmlString(sprintf('%s ~
%s', $record->sale_begin_time ?? '--', $record->sale_end_time ?? '--'))) , Tables\Columns\TextColumn::make('bonus_addition_factor')->label(__('medal.fields.bonus_addition_factor')), + Tables\Columns\TextColumn::make('gift_fee_factor')->label(__('medal.fields.gift_fee_factor')), Tables\Columns\TextColumn::make('price')->label(__('label.price')), Tables\Columns\TextColumn::make('duration')->label(__('label.medal.duration')), diff --git a/app/Models/BonusLogs.php b/app/Models/BonusLogs.php index 588b09f1..37109ce4 100644 --- a/app/Models/BonusLogs.php +++ b/app/Models/BonusLogs.php @@ -32,6 +32,7 @@ class BonusLogs extends NexusModel const BUSINESS_TYPE_BUY_TEMPORARY_INVITE = 15; const BUSINESS_TYPE_BUY_RAINBOW_ID = 16; const BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD = 17; + const BUSINESS_TYPE_GIFT_MEDAL = 18; public static array $businessTypes = [ self::BUSINESS_TYPE_CANCEL_HIT_AND_RUN => ['text' => 'Cancel H&R'], @@ -51,6 +52,7 @@ class BonusLogs extends NexusModel self::BUSINESS_TYPE_BUY_TEMPORARY_INVITE => ['text' => 'Buy temporary invite'], self::BUSINESS_TYPE_BUY_RAINBOW_ID => ['text' => 'Buy rainbow ID'], self::BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD => ['text' => 'Buy change username card'], + self::BUSINESS_TYPE_GIFT_MEDAL => ['text' => 'Gift medal to someone'], ]; public static function getBonusForCancelHitAndRun() diff --git a/app/Models/Medal.php b/app/Models/Medal.php index a76dfca7..c72faa33 100644 --- a/app/Models/Medal.php +++ b/app/Models/Medal.php @@ -18,6 +18,7 @@ class Medal extends NexusModel protected $fillable = [ 'name', 'description', 'image_large', 'image_small', 'price', 'duration', 'get_type', 'display_on_medal_page', 'sale_begin_time', 'sale_end_time', 'inventory', 'bonus_addition_factor', + 'gift_fee_factor', ]; public $timestamps = true; @@ -55,6 +56,23 @@ class Medal extends NexusModel return nexus_trans("label.permanent"); } + public function checkCanBeBuy() + { + if ($this->get_type == self::GET_TYPE_GRANT) { + throw new \RuntimeException(nexus_trans('medal.grant_only')); + } + $now = now(); + if ($this->sale_begin_time && $this->sale_begin_time->gt($now)) { + throw new \RuntimeException(nexus_trans('medal.before_sale_begin_time')); + } + if ($this->sale_end_time && $this->sale_end_time->lt($now)) { + throw new \RuntimeException(nexus_trans('medal.after_sale_end_time')); + } + if ($this->inventory !== null && $this->inventory <= 0) { + throw new \RuntimeException(nexus_trans('medal.inventory_empty')); + } + } + public function users(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { return $this->belongsToMany(User::class, 'user_medals', 'medal_id', 'uid')->withTimestamps(); diff --git a/app/Models/User.php b/app/Models/User.php index a660d641..be4685e5 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -459,9 +459,9 @@ class User extends Authenticatable implements FilamentUser, HasName public function medals(): \Illuminate\Database\Eloquent\Relations\BelongsToMany { return $this->belongsToMany(Medal::class, 'user_medals', 'uid', 'medal_id') - ->withPivot(['id', 'expire_at', 'status']) + ->withPivot(['id', 'expire_at', 'status', 'priority']) ->withTimestamps() - ->orderByPivot('id', 'desc') + ->orderByPivot('priority', 'desc') ; } diff --git a/app/Repositories/BonusRepository.php b/app/Repositories/BonusRepository.php index 1945a0a0..93391652 100644 --- a/app/Repositories/BonusRepository.php +++ b/app/Repositories/BonusRepository.php @@ -6,6 +6,7 @@ use App\Models\BonusLogs; use App\Models\HitAndRun; use App\Models\Invite; use App\Models\Medal; +use App\Models\Message; use App\Models\Setting; use App\Models\User; use App\Models\UserMedal; @@ -58,19 +59,7 @@ class BonusRepository extends BaseRepository if ($exists) { throw new \LogicException("user: $uid already own this medal: $medalId."); } - if ($medal->get_type != Medal::GET_TYPE_EXCHANGE) { - throw new \LogicException("This medal can not be buy."); - } - if ($medal->inventory !== null && $medal->inventory <= 0) { - throw new \LogicException("Inventory empty."); - } - $now = now(); - if ($medal->sale_begin_time && $medal->sale_begin_time->gt($now)) { - throw new \LogicException("Before sale begin time."); - } - if ($medal->sale_end_time && $medal->sale_end_time->lt($now)) { - throw new \LogicException("After sale end time."); - } + $medal->checkCanBeBuy(); $requireBonus = $medal->price; NexusDB::transaction(function () use ($user, $medal, $requireBonus) { $comment = nexus_trans('bonus.comment_buy_medal', [ @@ -101,6 +90,67 @@ class BonusRepository extends BaseRepository } + public function consumeToGiftMedal($uid, $medalId, $toUid): bool + { + $user = User::query()->findOrFail($uid); + $toUser = User::query()->findOrFail($toUid); + $medal = Medal::query()->findOrFail($medalId); + $exists = $toUser->valid_medals()->where('medal_id', $medalId)->exists(); + do_log(last_query()); + if ($exists) { + throw new \LogicException("user: $toUid already own this medal: $medalId."); + } + $medal->checkCanBeBuy(); + $giftFee = $medal->price * ($medal->gift_fee_factor ?? 0); + $requireBonus = $medal->price + $giftFee; + NexusDB::transaction(function () use ($user, $toUser, $medal, $requireBonus, $giftFee) { + $comment = nexus_trans('bonus.comment_gift_medal', [ + 'bonus' => $requireBonus, + 'medal_name' => $medal->name, + 'to_username' => $toUser->username, + ], $user->locale); + do_log("comment: $comment"); + $this->consumeUserBonus($user, $requireBonus, BonusLogs::BUSINESS_TYPE_GIFT_MEDAL, "$comment(medal ID: {$medal->id})"); + + $expireAt = null; + if ($medal->duration > 0) { + $expireAt = Carbon::now()->addDays($medal->duration)->toDateTimeString(); + } + $msg = [ + 'sender' => 0, + 'receiver' => $toUser->id, + 'subject' => nexus_trans('message.receive_medal.subject', [], $toUser->locale), + 'msg' => nexus_trans('message.receive_medal.body', [ + 'username' => $user->username, + 'cost_bonus' => $requireBonus, + 'medal_name' => $medal->name, + 'price' => $medal->price, + 'gift_fee_total' => $giftFee, + 'gift_fee_factor' => $medal->gift_fee_factor ?? 0, + 'expire_at' => $expireAt ?? nexus_trans('label.permanent'), + 'bonus_addition_factor' => $medal->bonus_addition_factor ?? 0, + ], $toUser->locale), + 'added' => now() + ]; + Message::add($msg); + $toUser->medals()->attach([$medal->id => ['expire_at' => $expireAt, 'status' => UserMedal::STATUS_NOT_WEARING]]); + if ($medal->inventory !== null) { + $affectedRows = NexusDB::table('medals') + ->where('id', $medal->id) + ->where('inventory', $medal->inventory) + ->decrement('inventory') + ; + if ($affectedRows != 1) { + throw new \RuntimeException("Decrement medal({$medal->id}) inventory affected rows != 1($affectedRows)"); + } + } + + }); + + return true; + + } + public function consumeToBuyAttendanceCard($uid): bool { $user = User::query()->findOrFail($uid); diff --git a/app/Repositories/MedalRepository.php b/app/Repositories/MedalRepository.php index 45050372..ea2641fb 100644 --- a/app/Repositories/MedalRepository.php +++ b/app/Repositories/MedalRepository.php @@ -74,7 +74,7 @@ class MedalRepository extends BaseRepository return $user->medals()->attach([$medal->id => ['expire_at' => $expireAt, 'status' => UserMedal::STATUS_NOT_WEARING]]); } - function toggleUserMedalStatus($id, $userId) + public function toggleUserMedalStatus($id, $userId) { $userMedal = UserMedal::query()->findOrFail($id); if ($userMedal->uid != $userId) { @@ -91,4 +91,32 @@ class MedalRepository extends BaseRepository return $userMedal; } + public function saveUserMedal(int $userId, array $userMedalData) + { + $user = User::query()->findOrFail($userId); + $validMedals = $user->valid_medals; + if ($validMedals->isEmpty()) { + return true; + } + $statusCaseWhens = $priorityCaseWhens = $idArr = []; + foreach ($validMedals as $medal) { + $id = $medal->pivot->id; + $idArr[] = $id; + if (isset($userMedalData[$id]['status'])) { + $status = UserMedal::STATUS_WEARING; + } else { + $status = UserMedal::STATUS_NOT_WEARING; + } + $statusCaseWhens[] = sprintf('when `id` = %s then %s', $id, $status); + $priorityCaseWhens[] = sprintf('when `id` = %s then %s', $id, $userMedalData[$id]['priority'] ?? 0); + } + $sql = sprintf( + 'update user_medals set `status` = case %s end, `priority` = case %s end where id in (%s)', + implode(' ', $statusCaseWhens), implode(' ', $priorityCaseWhens), implode(',', $idArr) + ); + do_log("sql: $sql"); + clear_user_cache($userId); + return NexusDB::statement($sql); + } + } diff --git a/database/migrations/2023_01_27_143831_add_gift_fee_factor_to_medals_table.php b/database/migrations/2023_01_27_143831_add_gift_fee_factor_to_medals_table.php new file mode 100644 index 00000000..85f52f34 --- /dev/null +++ b/database/migrations/2023_01_27_143831_add_gift_fee_factor_to_medals_table.php @@ -0,0 +1,32 @@ +float('gift_fee_factor', 10, 6)->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('medals', function (Blueprint $table) { + $table->dropColumn(['gift_fee_factor']); + }); + } +}; diff --git a/database/migrations/2023_01_28_170836_add_priority_to_user_medals_table.php b/database/migrations/2023_01_28_170836_add_priority_to_user_medals_table.php new file mode 100644 index 00000000..9dd0a2f2 --- /dev/null +++ b/database/migrations/2023_01_28_170836_add_priority_to_user_medals_table.php @@ -0,0 +1,32 @@ +integer('priority')->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('user_medals', function (Blueprint $table) { + $table->dropColumn(['priority']); + }); + } +}; diff --git a/include/constants.php b/include/constants.php index 261c281c..1c598408 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ '; - $wrapAfter = ''; + $wrapBefore = '
'; + $wrapAfter = '
'; foreach ($medals as $medal) { - $html = sprintf('
', $medal->image_large, $medal->name, $maxHeight); + $html = sprintf('
', $medal->image_large, $medal->name, $maxHeight, $maxHeight); if ($withActions) { + $html .= sprintf( + '
%s: %s%s: %s', + nexus_trans('label.expire_at'), + $medal->pivot->expire_at ? format_datetime($medal->pivot->expire_at) : nexus_trans('label.permanent'), + nexus_trans('medal.fields.bonus_addition_factor'), + $medal->bonus_addition_factor ?? 0, + nexus_trans('label.priority'), + $medal->pivot->id, + $medal->pivot->priority ?? 0, + nexus_trans('label.priority_help') + ); $checked = ''; if ($medal->pivot->status == \App\Models\UserMedal::STATUS_WEARING) { $checked = ' checked'; } - $html .= sprintf('', nexus_trans('medal.action_wearing'), $medal->pivot->id, $checked); + $html .= sprintf('', nexus_trans('medal.action_wearing'), $medal->pivot->id, $checked); + $html .= '
'; } $html .= '
'; $medalImages[] = $html; } + $medalImages[] = sprintf('
', nexus_trans('label.save')); return $wrapBefore . implode('', $medalImages) . $wrapAfter; } @@ -5962,6 +5975,7 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array $valuetwo = $bzero_bonus * ( 2 / $pi); $valuethree = $logofpointone / ($nzero_bonus - 1); $timenow = time(); + $nowStr = date('Y-m-d H:i:s'); $sectoweek = 7*24*60*60; $A = $official_a = $size = $official_size = 0; @@ -5989,8 +6003,8 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array $officialAdditionalFactor = \App\Models\Setting::get('bonus.official_addition'); $zeroBonusTag = \App\Models\Setting::get('bonus.zero_bonus_tag'); $zeroBonusFactor = \App\Models\Setting::get('bonus.zero_bonus_factor'); - $userMedalResult = \Nexus\Database\NexusDB::select("select sum(bonus_addition_factor) as factor from medals where id in (select medal_id from user_medals where uid = $uid)"); - $medalAdditionalFactor = $userMedalResult[0]['factor'] ?? 0; + $userMedalResult = \Nexus\Database\NexusDB::select("select sum(bonus_addition_factor) as factor from medals where id in (select medal_id from user_medals where uid = $uid and (expire_at is null or expire_at > '$nowStr'))"); + $medalAdditionalFactor = floatval($userMedalResult[0]['factor'] ?? 0); do_log("$logPrefix, sql: $sql, count: " . count($torrentResult) . ", officialTag: $officialTag, officialAdditionalFactor: $officialAdditionalFactor, zeroBonusTag: $zeroBonusTag, zeroBonusFactor: $zeroBonusFactor, medalAdditionalFactor: $medalAdditionalFactor"); $last_action = ""; foreach ($torrentResult as $torrent) diff --git a/public/ajax.php b/public/ajax.php index c9d9a0cc..c376fa62 100644 --- a/public/ajax.php +++ b/public/ajax.php @@ -138,3 +138,26 @@ function buyMedal($params) $rep = new \App\Repositories\BonusRepository(); return $rep->consumeToBuyMedal($CURUSER['id'], $params['medal_id']); } + +function giftMedal($params) +{ + global $CURUSER; + $rep = new \App\Repositories\BonusRepository(); + return $rep->consumeToGiftMedal($CURUSER['id'], $params['medal_id'], $params['uid']); +} + +function saveUserMedal($params) +{ + global $CURUSER; + $data = []; + foreach ($params as $param) { + $fieldAndId = explode('_', $param['name']); + $field = $fieldAndId[0]; + $id = $fieldAndId[1]; + $value = $param['value']; + $data[$id][$field] = $value; + } +// dd($params, $data); + $rep = new \App\Repositories\MedalRepository(); + return $rep->saveUserMedal($CURUSER['id'], $data); +} diff --git a/public/medal.php b/public/medal.php index 6db9489c..d9a801e3 100644 --- a/public/medal.php +++ b/public/medal.php @@ -18,10 +18,12 @@ $columnImageLargeLabel = nexus_trans('medal.fields.image_large'); $columnPriceLabel = nexus_trans('medal.fields.price'); $columnDurationLabel = nexus_trans('medal.fields.duration'); $columnDescriptionLabel = nexus_trans('medal.fields.description'); -$columnActionLabel = nexus_trans('nexus.action'); +$columnBuyLabel = nexus_trans('medal.buy_btn'); $columnSaleBeginEndTimeLabel = nexus_trans('medal.fields.sale_begin_end_time'); $columnInventoryLabel = nexus_trans('medal.fields.inventory'); $columnBonusAdditionFactorLabel = nexus_trans('medal.fields.bonus_addition_factor'); +$columnGiftLabel = nexus_trans('medal.gift_btn'); +$columnGiftFeeFactorLabel = nexus_trans('medal.fields.gift_fee_factor'); $header = '

'.$title.'

'; $filterForm = <<
@@ -41,13 +43,15 @@ $table = <<ID - + + - + + TABLE; @@ -59,42 +63,51 @@ $userMedals = \App\Models\UserMedal::query()->where('uid', $CURUSER['id']) ->keyBy('medal_id') ; foreach ($rows as $row) { - $disabled = ' disabled'; - $class = ''; - if ($userMedals->has($row->id)) { - $btnText = nexus_trans('medal.buy_already'); - } elseif ($row->get_type == \App\Models\Medal::GET_TYPE_GRANT) { - $btnText = nexus_trans('medal.grant_only'); - } elseif ($row->sale_begin_time && $row->sale_begin_time->gt($now)) { - $btnText = nexus_trans('medal.before_sale_begin_time'); - } elseif ($row->sale_end_time && $row->sale_end_time->lt($now)) { - $btnText = nexus_trans('medal.after_sale_end_time'); - } elseif ($row->inventory !== null && $row->inventory <= 0) { - $btnText = nexus_trans('medal.inventory_empty'); - } elseif ($CURUSER['seedbonus'] < $row->price) { - $btnText = nexus_trans('medal.require_more_bonus'); - } else { - $btnText = nexus_trans('medal.buy_btn'); - $disabled = ''; - $class = 'buy'; + $buyDisabled = $giftDisabled = ' disabled'; + $buyClass = $giftClass = ''; + try { + $row->checkCanBeBuy(); + if ($userMedals->has($row->id)) { + $buyBtnText = nexus_trans('medal.buy_already'); + } elseif ($CURUSER['seedbonus'] < $row->price) { + $buyBtnText = nexus_trans('medal.require_more_bonus'); + } else { + $buyBtnText = nexus_trans('medal.buy_btn'); + $buyDisabled = ''; + $buyClass = 'buy'; + } + if ($CURUSER['seedbonus'] < $row->price * (1 + ($row->gift_fee_factor ?? 0))) { + $giftBtnText = nexus_trans('medal.require_more_bonus'); + } else { + $giftBtnText = nexus_trans('medal.gift_btn'); + $giftDisabled = ''; + $giftClass = 'gift'; + } + } catch (\Exception $exception) { + $buyBtnText = $giftBtnText = $exception->getMessage(); } - $action = sprintf( + $buyAction = sprintf( '', - $class, $row->id, $btnText, $disabled + $buyClass, $row->id, $buyBtnText, $buyDisabled + ); + $giftAction = sprintf( + '', + $giftDisabled, $giftClass, $row->id, $giftBtnText, $giftDisabled ); $table .= sprintf( - '', - $row->id, $row->name, $row->image_large, $row->sale_begin_time ?? '--', $row->sale_end_time ?? '--', $row->bonus_addition_factor, number_format($row->price), $row->durationText, $row->inventory ?? nexus_trans('label.infinite'), $row->description, $action + '', + $row->id, $row->name, $row->image_large, $row->sale_begin_time ?? '--', $row->sale_end_time ?? '--', $row->bonus_addition_factor, $row->gift_fee_factor ?? 0, number_format($row->price), $row->durationText, $row->inventory ?? nexus_trans('label.infinite'), $row->description, $buyAction, $giftAction ); } $table .= '
$columnNameLabel $columnImageLargeLabel$columnSaleBeginEndTimeLabel$columnSaleBeginEndTimeLabel $columnBonusAdditionFactorLabel$columnGiftFeeFactorLabel $columnPriceLabel $columnDurationLabel $columnInventoryLabel $columnDescriptionLabel$columnActionLabel$columnBuyLabel$columnGiftLabel
%s%s%s ~
%s
%s%s%s%s%s%s
%s%s%s ~
%s
%s%s%s%s%s%s%s%s
'; echo $header . $table . $paginationBottom; end_main_frame(); -$confirmMsg = nexus_trans('medal.confirm_to_buy'); +$confirmBuyMsg = nexus_trans('medal.confirm_to_buy'); +$confirmGiftMsg = nexus_trans('medal.confirm_to_gift'); $js = <<" . get_username($user['id'], true,false) . $count if ($userInfo->valid_medals->isNotEmpty()) { print build_medal_image($userInfo->{$medalType}, 120, $CURUSER['id'] == $user['id']); $warnMedalJs = << 'Spend :bonus bonus buy :count temporary invite', 'comment_buy_rainbow_id' => 'Spend :bonus bonus buy :duration days rainbow ID', 'comment_buy_change_username_card' => 'Spend :bonus bonus buy change username card', + 'comment_gift_medal' => 'Spend :bonus bonus buy :medal_name and gift to :to_username', 'table_thead' => [ 'reward_type' => 'Reward type', 'count' => 'Count', diff --git a/resources/lang/en/label.php b/resources/lang/en/label.php index 6ed46bc6..4a9021ec 100644 --- a/resources/lang/en/label.php +++ b/resources/lang/en/label.php @@ -35,6 +35,7 @@ return [ 'reset' => 'Reset', 'anonymous' => 'Anonymous', 'infinite' => 'Infinite', + 'save' => 'Save', 'setting' => [ 'nav_text' => 'Setting', 'backup' => [ diff --git a/resources/lang/en/medal.php b/resources/lang/en/medal.php index efbce88f..50fccded 100644 --- a/resources/lang/en/medal.php +++ b/resources/lang/en/medal.php @@ -28,10 +28,17 @@ return [ 'users_count' => 'Sold counts', 'bonus_addition_factor' => 'Bonus addition factor', 'bonus_addition_factor_help' => 'For example: 0.01 means 1% addition, leave blank no addition', + 'gift_fee_factor' => 'Gift fee factor', + 'gift_fee_factor_help' => 'The additional fee charged for gifts to other users is equal to the price multiplied by this factor', ], 'buy_already' => 'Already buy', 'buy_btn' => 'Buy', 'confirm_to_buy' => 'Sure you want to buy?', 'require_more_bonus' => 'Require more bonus', 'grant_only' => 'Grant only', + 'before_sale_begin_time' => 'Before sale begin time', + 'after_sale_end_time' => 'After sale end time', + 'inventory_empty' => 'Inventory empty', + 'gift_btn' => 'Gift', + 'confirm_to_gift' => 'Confirm to gift to user ', ]; diff --git a/resources/lang/en/message.php b/resources/lang/en/message.php index d1de2137..6ad20a50 100644 --- a/resources/lang/en/message.php +++ b/resources/lang/en/message.php @@ -27,4 +27,8 @@ return [ 'subject' => 'Temporary invite :change_type', 'body' => 'Your temporary invite count had :change_type :count by :operator, reason: :reason.', ], + 'receive_medal' => [ + 'subject' => 'Receive gift medal', + 'body' => "User :username purchased a medal [:medal_name] at a cost of :cost_bonus and gave it to you. The medal is worth :price, the fee is :gift_fee_total(factor: :gift_fee_factor), you will have this medal until: :expire_at, and the medal's bonus addition factor is: :bonus_addition_factor.", + ], ]; diff --git a/resources/lang/zh_CN/bonus.php b/resources/lang/zh_CN/bonus.php index ce1db493..769dfa4a 100644 --- a/resources/lang/zh_CN/bonus.php +++ b/resources/lang/zh_CN/bonus.php @@ -6,6 +6,7 @@ return [ 'comment_buy_temporary_invite' => '花费 :bonus 魔力购买了 :count 个临时邀请', 'comment_buy_rainbow_id' => '花费 :bonus 魔力购买了 :duration 天的彩虹 ID', 'comment_buy_change_username_card' => '花费 :bonus 魔力购买了改名卡', + 'comment_gift_medal' => '花费 :bonus 魔力购买了 :medal_name 并赠送给 :to_username', 'table_thead' => [ 'reward_type' => '奖励类型', 'count' => '数量', diff --git a/resources/lang/zh_CN/label.php b/resources/lang/zh_CN/label.php index c024f511..f48a4617 100644 --- a/resources/lang/zh_CN/label.php +++ b/resources/lang/zh_CN/label.php @@ -35,6 +35,7 @@ return [ 'reset' => '重置', 'anonymous' => '匿名', 'infinite' => '无限', + 'save' => '保存', 'setting' => [ 'nav_text' => '设置', 'backup' => [ diff --git a/resources/lang/zh_CN/medal.php b/resources/lang/zh_CN/medal.php index 6c657670..3ec6cd16 100644 --- a/resources/lang/zh_CN/medal.php +++ b/resources/lang/zh_CN/medal.php @@ -28,6 +28,8 @@ return [ 'users_count' => '已售数量', 'bonus_addition_factor' => '魔力加成系数', 'bonus_addition_factor_help' => '如:0.01 表示 1% 的加成,留空无加成', + 'gift_fee_factor' => '赠送手续费系数', + 'gift_fee_factor_help' => '赠送给其他用户时额外收取手续费等于价格乘以此系数', ], 'buy_already' => '已经购买', 'buy_btn' => '购买', @@ -37,4 +39,6 @@ return [ 'before_sale_begin_time' => '未到可购买时间', 'after_sale_end_time' => '已过可购买时间', 'inventory_empty' => '库存不足', + 'gift_btn' => '赠送', + 'confirm_to_gift' => '确定要赠送给用户 ', ]; diff --git a/resources/lang/zh_CN/message.php b/resources/lang/zh_CN/message.php index e47f47c2..63629fdf 100644 --- a/resources/lang/zh_CN/message.php +++ b/resources/lang/zh_CN/message.php @@ -27,4 +27,8 @@ return [ 'subject' => '临时邀请:change_type', 'body' => '你的临时邀请被管理员 :operator :change_type :count 个,理由::reason。', ], + 'receive_medal' => [ + 'subject' => '收到赠送勋章', + 'body' => '用户 :username 花费魔力 :cost_bonus 购买了勋章[:medal_name]并赠送与你。此勋章价值 :price,手续费 :gift_fee_total(系数::gift_fee_factor),你将拥有此勋章有效期至: :expire_at,勋章的魔力加成系数为: :bonus_addition_factor。', + ], ]; diff --git a/resources/lang/zh_TW/bonus.php b/resources/lang/zh_TW/bonus.php index 66c9a058..11bf6c25 100644 --- a/resources/lang/zh_TW/bonus.php +++ b/resources/lang/zh_TW/bonus.php @@ -6,6 +6,7 @@ return [ 'comment_buy_temporary_invite' => '花費 :bonus 魔力購買了 :count 個臨時邀請', 'comment_buy_rainbow_id' => '花費 :bonus 魔力購買了 :duration 天的彩虹 ID', 'comment_buy_change_username_card' => '花費 :bonus 魔力購買了改名卡', + 'comment_gift_medal' => '花費 :bonus 魔力購買了 :medal_name 並贈送給 :to_username', 'table_thead' => [ 'reward_type' => '獎勵類型', 'count' => '數量', diff --git a/resources/lang/zh_TW/label.php b/resources/lang/zh_TW/label.php index b48812e9..66dd2a1b 100644 --- a/resources/lang/zh_TW/label.php +++ b/resources/lang/zh_TW/label.php @@ -35,6 +35,7 @@ return [ 'reset' => '重置', 'anonymous' => '匿名', 'infinite' => '無限', + 'save' => '保存', 'setting' => [ 'nav_text' => '設置', 'backup' => [ diff --git a/resources/lang/zh_TW/medal.php b/resources/lang/zh_TW/medal.php index 6c8bdf51..710684e5 100644 --- a/resources/lang/zh_TW/medal.php +++ b/resources/lang/zh_TW/medal.php @@ -28,10 +28,17 @@ return [ 'users_count' => '已售數量', 'bonus_addition_factor' => '魔力加成系數', 'bonus_addition_factor_help' => '如:0.01 表示 1% 的加成,留空無加成', + 'gift_fee_factor' => '贈送手續費系數', + 'gift_fee_factor_help' => '贈送給其他用戶時額外收取手續費等於價格乘以此系數', ], 'buy_already' => '已經購買', 'buy_btn' => '購買', 'confirm_to_buy' => '確定要購買嗎?', 'require_more_bonus' => '需要更多魔力值', 'grant_only' => '僅授予', + 'before_sale_begin_time' => '未到可購買時間', + 'after_sale_end_time' => '已過可購買時間', + 'inventory_empty' => '庫存不足', + 'gift_btn' => '贈送', + 'confirm_to_gift' => '確定要贈送給用戶 ', ]; diff --git a/resources/lang/zh_TW/message.php b/resources/lang/zh_TW/message.php index bac6d977..5e681cf3 100644 --- a/resources/lang/zh_TW/message.php +++ b/resources/lang/zh_TW/message.php @@ -26,4 +26,8 @@ return [ 'subject' => '臨時邀請:change_type', 'body' => '你的臨時邀請被管理員 :operator :change_type :count 個,理由::reason。', ], + 'receive_medal' => [ + 'subject' => '收到贈送勛章', + 'body' => '用戶 :username 花費魔力 :cost_bonus 購買了勛章[:medal_name]並贈送與你。此勛章價值 :price,手續費 :gift_fee_total(系數::gift_fee_factor),你將擁有此勛章有效期至: :expire_at,勛章的魔力加成系數為: :bonus_addition_factor。', + ], ];