mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
add medal bonus addition
This commit is contained in:
@@ -70,6 +70,12 @@ class MedalResource extends Resource
|
||||
->label(__('medal.fields.sale_end_time'))
|
||||
->helperText(__('medal.fields.sale_end_time_help'))
|
||||
,
|
||||
Forms\Components\TextInput::make('bonus_addition_factor')
|
||||
->label(__('medal.fields.bonus_addition_factor'))
|
||||
->helperText(__('medal.fields.bonus_addition_factor_help'))
|
||||
->numeric()
|
||||
->default(0)
|
||||
,
|
||||
Forms\Components\Textarea::make('description')
|
||||
->label(__('label.description'))
|
||||
,
|
||||
@@ -89,6 +95,7 @@ class MedalResource extends Resource
|
||||
->label(__('medal.fields.sale_begin_end_time'))
|
||||
->formatStateUsing(fn ($record) => new HtmlString(sprintf('%s ~<br/>%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('price')->label(__('label.price')),
|
||||
|
||||
Tables\Columns\TextColumn::make('duration')->label(__('label.medal.duration')),
|
||||
|
||||
@@ -91,6 +91,11 @@ class CalculateUserSeedBonus implements ShouldQueue
|
||||
$all_bonus += $haremAddition;
|
||||
$bonusLog .= ", haremAdditionFactor: $haremAdditionFactor, haremBonus: $haremBonus, haremAddition: $haremAddition, all_bonus: $all_bonus";
|
||||
}
|
||||
if ($seedBonusResult['medal_additional_factor'] > 0) {
|
||||
$medalAddition = $seedBonusResult['medal_bonus'] * $seedBonusResult['medal_additional_factor'];
|
||||
$all_bonus += $medalAddition;
|
||||
$bonusLog .= ", medalAdditionFactor: {$seedBonusResult['medal_additional_factor']}, medalBonus: {$seedBonusResult['medal_bonus']}, medalAddition: $medalAddition, all_bonus: $all_bonus";
|
||||
}
|
||||
$dividend = 3600 / $autoclean_interval_one;
|
||||
$all_bonus = $all_bonus / $dividend;
|
||||
$seed_points = $seedBonusResult['seed_points'] / $dividend;
|
||||
|
||||
@@ -17,7 +17,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',
|
||||
'display_on_medal_page', 'sale_begin_time', 'sale_end_time', 'inventory', 'bonus_addition_factor',
|
||||
];
|
||||
|
||||
public $timestamps = true;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('medals', function (Blueprint $table) {
|
||||
$table->float('bonus_addition_factor')->default(0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('medals', function (Blueprint $table) {
|
||||
$table->dropColumn(['bonus_addition_factor']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-01-25');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-01-26');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -5989,7 +5989,9 @@ 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');
|
||||
do_log("$logPrefix, sql: $sql, count: " . count($torrentResult) . ", officialTag: $officialTag, officialAdditionalFactor: $officialAdditionalFactor, zeroBonusTag: $zeroBonusTag, zeroBonusFactor: $zeroBonusFactor");
|
||||
$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;
|
||||
do_log("$logPrefix, sql: $sql, count: " . count($torrentResult) . ", officialTag: $officialTag, officialAdditionalFactor: $officialAdditionalFactor, zeroBonusTag: $zeroBonusTag, zeroBonusFactor: $zeroBonusFactor, medalAdditionalFactor: $medalAdditionalFactor");
|
||||
$last_action = "";
|
||||
foreach ($torrentResult as $torrent)
|
||||
{
|
||||
@@ -6023,12 +6025,14 @@ function calculate_seed_bonus($uid, $torrentIdArr = null): array
|
||||
$seed_bonus = $seed_points = $valuetwo * atan($A / $l_bonus) + ($perseeding_bonus * $count);
|
||||
//Official addition don't think about the minimum value
|
||||
$official_bonus = $valuetwo * atan($official_a / $l_bonus);
|
||||
$medal_bonus = $valuetwo * atan($A / $l_bonus);
|
||||
$result = compact(
|
||||
'seed_points','seed_bonus', 'A', 'count', 'torrent_peer_count', 'size', 'last_action',
|
||||
'official_bonus', 'official_a', 'official_torrent_peer_count', 'official_size'
|
||||
'official_bonus', 'official_a', 'official_torrent_peer_count', 'official_size', 'medal_bonus'
|
||||
);
|
||||
$result['donor_times'] = $donortimes_bonus;
|
||||
$result['official_additional_factor'] = $officialAdditionalFactor;
|
||||
$result['medal_additional_factor'] = $medalAdditionalFactor;
|
||||
do_log("$logPrefix, result: " . json_encode($result));
|
||||
return $result;
|
||||
}
|
||||
@@ -6248,10 +6252,16 @@ function build_bonus_table(array $user, array $bonusResult = [], array $options
|
||||
$baseBonusFactor = $donortimes_bonus;
|
||||
}
|
||||
$baseBonus = $bonusResult['seed_bonus'] * $baseBonusFactor;
|
||||
$totalBonus = number_format( $baseBonus + $haremAddition * $haremFactor + $bonusResult['official_bonus'] * $officialAdditionalFactor, 3);
|
||||
$totalBonus = number_format(
|
||||
$baseBonus
|
||||
+ $haremAddition * $haremFactor
|
||||
+ $bonusResult['official_bonus'] * $officialAdditionalFactor
|
||||
+ $bonusResult['medal_bonus'] * $bonusResult['medal_additional_factor']
|
||||
, 3
|
||||
);
|
||||
|
||||
$rowSpan = 1;
|
||||
$hasHaremAddition = $hasOfficialAddition = false;
|
||||
$hasHaremAddition = $hasOfficialAddition = $hasMedalAddition = false;
|
||||
if ($haremFactor > 0) {
|
||||
$rowSpan++;
|
||||
$hasHaremAddition = true;
|
||||
@@ -6260,6 +6270,10 @@ function build_bonus_table(array $user, array $bonusResult = [], array $options
|
||||
$rowSpan++;
|
||||
$hasOfficialAddition = true;
|
||||
}
|
||||
if ($bonusResult['medal_additional_factor'] > 0) {
|
||||
$rowSpan++;
|
||||
$hasMedalAddition = true;
|
||||
}
|
||||
|
||||
$table = sprintf('<table cellpadding="5" style="%s">', $options['table_style'] ?? '');
|
||||
$table .= '<tr>';
|
||||
@@ -6285,6 +6299,18 @@ function build_bonus_table(array $user, array $bonusResult = [], array $options
|
||||
$rowSpan,
|
||||
$totalBonus
|
||||
);
|
||||
if ($hasMedalAddition) {
|
||||
$table .= sprintf(
|
||||
'<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>',
|
||||
nexus_trans('bonus.reward_types.medal_addition'),
|
||||
$bonusResult['torrent_peer_count'],
|
||||
mksize($bonusResult['size']),
|
||||
number_format($bonusResult['A'], 3),
|
||||
number_format($bonusResult['medal_bonus'], 3),
|
||||
$bonusResult['medal_additional_factor'],
|
||||
number_format($bonusResult['medal_bonus'] * $bonusResult['medal_additional_factor'], 3)
|
||||
);
|
||||
}
|
||||
|
||||
if ($hasOfficialAddition) {
|
||||
$table .= sprintf(
|
||||
@@ -6311,6 +6337,7 @@ function build_bonus_table(array $user, array $bonusResult = [], array $options
|
||||
number_format($haremAddition * $haremFactor, 3)
|
||||
);
|
||||
}
|
||||
|
||||
$table .= '</table>';
|
||||
|
||||
return [
|
||||
@@ -6319,6 +6346,8 @@ function build_bonus_table(array $user, array $bonusResult = [], array $options
|
||||
'harem_addition_factor' => $haremFactor,
|
||||
'has_official_addition' => $hasOfficialAddition,
|
||||
'official_addition_factor' => $officialAdditionalFactor,
|
||||
'has_medal_addition' => $hasMedalAddition,
|
||||
'medal_addition_factor' => $bonusResult['medal_additional_factor'],
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
@@ -167,6 +167,9 @@ $lang_mybonus = array
|
||||
'text_success_buy_change_username_card' => "祝贺你,成功购买了<b>改名卡</b>!",
|
||||
'text_change_username_card_already_has' => '已经拥有改名卡',
|
||||
'text_rainbow_id_already_valid_forever' => '已永久拥有彩虹 ID',
|
||||
'text_get_by_medal' => '勋章加成每小时将额外得到如下的魔力值',
|
||||
'medal_additional_desc' => '勋章奖励计算公式同上,不考虑低保',
|
||||
'medal_additional_factor' => '最终奖励为计算所得勋章奖励乘以勋章加成系数,当前勋章加成系数为: ',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -21,6 +21,7 @@ $columnDescriptionLabel = nexus_trans('medal.fields.description');
|
||||
$columnActionLabel = nexus_trans('nexus.action');
|
||||
$columnSaleBeginEndTimeLabel = nexus_trans('medal.fields.sale_begin_end_time');
|
||||
$columnInventoryLabel = nexus_trans('medal.fields.inventory');
|
||||
$columnBonusAdditionFactorLabel = nexus_trans('medal.fields.bonus_addition_factor');
|
||||
$header = '<h1 style="text-align: center">'.$title.'</h1>';
|
||||
$filterForm = <<<FORM
|
||||
<div>
|
||||
@@ -41,6 +42,7 @@ $table = <<<TABLE
|
||||
<td class="colhead">$columnNameLabel</td>
|
||||
<td class="colhead">$columnImageLargeLabel</td>
|
||||
<td class="colhead">$columnSaleBeginEndTimeLabel</td>
|
||||
<td class="colhead">$columnBonusAdditionFactorLabel</td>
|
||||
<td class="colhead">$columnPriceLabel</td>
|
||||
<td class="colhead">$columnDurationLabel</td>
|
||||
<td class="colhead">$columnInventoryLabel</td>
|
||||
@@ -81,8 +83,8 @@ foreach ($rows as $row) {
|
||||
$class, $row->id, $btnText, $disabled
|
||||
);
|
||||
$table .= sprintf(
|
||||
'<tr><td>%s</td><td>%s</td><td><img src="%s" style="max-width: 60px;max-height: 60px;" class="preview" /></td><td>%s ~<br>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>',
|
||||
$row->id, $row->name, $row->image_large, $row->sale_begin_time ?? '--', $row->sale_end_time ?? '--', number_format($row->price), $row->durationText, $row->inventory ?? nexus_trans('label.infinite'), $row->description, $action
|
||||
'<tr><td>%s</td><td>%s</td><td><img src="%s" style="max-width: 60px;max-height: 60px;" class="preview" /></td><td>%s ~<br>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>',
|
||||
$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
|
||||
);
|
||||
}
|
||||
$table .= '</tbody></table>';
|
||||
|
||||
@@ -489,6 +489,13 @@ else $loadpic = "loadbargreen";
|
||||
$width = $percent * 4;
|
||||
print("<img class=\"".$loadpic."\" src=\"pic/trans.gif\" style=\"width: ".$width."px;\" alt=\"".$percent."%\" /></td></tr></table>");
|
||||
|
||||
if ($bonusTableResult['has_medal_addition']) {
|
||||
print("<h1>".$lang_mybonus['text_get_by_medal']."</h1>");
|
||||
print("<ul>");
|
||||
print("<li>".sprintf($lang_mybonus['medal_additional_desc'], $CURUSER['id'])."</li>");
|
||||
print("<li>".$lang_mybonus['medal_additional_factor'].$bonusTableResult['medal_addition_factor']."</li>");
|
||||
print("</ul>");
|
||||
}
|
||||
if ($bonusTableResult['has_official_addition']) {
|
||||
print("<h1>".$lang_mybonus['text_get_by_seeding_official']."</h1>");
|
||||
print("<ul>");
|
||||
@@ -757,12 +764,12 @@ if ($action == "exchange") {
|
||||
}
|
||||
$bonusRep->consumeToCancelHitAndRun($userid, $_POST['hr_id']);
|
||||
nexus_redirect("" . get_protocol_prefix() . "$BASEURL/mybonus.php?do=cancel_hr");
|
||||
} elseif ($art == 'buy_medal') {
|
||||
if (empty($_POST['medal_id'])) {
|
||||
stderr("Error","Invalid Medal ID: " . ($_POST['medal_id'] ?? ''), false, false);
|
||||
}
|
||||
$bonusRep->consumeToBuyMedal($userid, $_POST['medal_id']);
|
||||
nexus_redirect("" . get_protocol_prefix() . "$BASEURL/mybonus.php?do=buy_medal");
|
||||
// } elseif ($art == 'buy_medal') {
|
||||
// if (empty($_POST['medal_id'])) {
|
||||
// stderr("Error","Invalid Medal ID: " . ($_POST['medal_id'] ?? ''), false, false);
|
||||
// }
|
||||
// $bonusRep->consumeToBuyMedal($userid, $_POST['medal_id']);
|
||||
// nexus_redirect("" . get_protocol_prefix() . "$BASEURL/mybonus.php?do=buy_medal");
|
||||
} elseif ($art == 'attendance_card') {
|
||||
$bonusRep->consumeToBuyAttendanceCard($userid);
|
||||
nexus_redirect("" . get_protocol_prefix() . "$BASEURL/mybonus.php?do=attendance_card");
|
||||
|
||||
@@ -20,5 +20,6 @@ return [
|
||||
'basic' => 'Basic reward',
|
||||
'harem_addition' => 'Harem addition',
|
||||
'official_addition' => 'Official addition',
|
||||
'medal_addition' => 'Medal addition',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -26,6 +26,8 @@ return [
|
||||
'inventory_help' => 'Leave blank without restriction',
|
||||
'sale_begin_end_time' => 'Available for sale',
|
||||
'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',
|
||||
],
|
||||
'buy_already' => 'Already buy',
|
||||
'buy_btn' => 'Buy',
|
||||
|
||||
@@ -20,5 +20,6 @@ return [
|
||||
'basic' => '基本奖励',
|
||||
'harem_addition' => '后宫加成',
|
||||
'official_addition' => '官种加成',
|
||||
'medal_addition' => '勋章加成',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -26,6 +26,8 @@ return [
|
||||
'inventory_help' => '留空表示无限',
|
||||
'sale_begin_end_time' => '可购买时间',
|
||||
'users_count' => '已售数量',
|
||||
'bonus_addition_factor' => '魔力加成系数',
|
||||
'bonus_addition_factor_help' => '如:0.01 表示 1% 的加成,留空无加成',
|
||||
],
|
||||
'buy_already' => '已经购买',
|
||||
'buy_btn' => '购买',
|
||||
|
||||
@@ -20,5 +20,6 @@ return [
|
||||
'basic' => '基本獎勵',
|
||||
'harem_addition' => '後宮加成',
|
||||
'official_addition' => '官種加成',
|
||||
'medal_addition' => '勛章加成',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -26,6 +26,8 @@ return [
|
||||
'inventory_help' => '留空表示無限',
|
||||
'sale_begin_end_time' => '可購買時間',
|
||||
'users_count' => '已售數量',
|
||||
'bonus_addition_factor' => '魔力加成系數',
|
||||
'bonus_addition_factor_help' => '如:0.01 表示 1% 的加成,留空無加成',
|
||||
],
|
||||
'buy_already' => '已經購買',
|
||||
'buy_btn' => '購買',
|
||||
|
||||
Reference in New Issue
Block a user