mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
seed bonus add log etc
This commit is contained in:
@@ -47,6 +47,12 @@ class BonusLogs extends NexusModel
|
||||
const BUSINESS_TYPE_RECEIVE_GIFT = 1003;
|
||||
const BUSINESS_TYPE_UPLOAD_TORRENT = 1004;
|
||||
|
||||
const BUSINESS_TYPE_SEEDING_BASIC = 10000;
|
||||
const BUSINESS_TYPE_SEEDING_DONOR_ADDITION = 10001;
|
||||
const BUSINESS_TYPE_SEEDING_OFFICIAL_ADDITION = 10002;
|
||||
const BUSINESS_TYPE_SEEDING_HAREM_ADDITION = 10003;
|
||||
const BUSINESS_TYPE_SEEDING_MEDAL_ADDITION = 10004;
|
||||
|
||||
public static array $businessTypes = [
|
||||
self::BUSINESS_TYPE_CANCEL_HIT_AND_RUN => ['text' => 'Cancel H&R'],
|
||||
self::BUSINESS_TYPE_BUY_MEDAL => ['text' => 'Buy medal'],
|
||||
@@ -75,6 +81,11 @@ class BonusLogs extends NexusModel
|
||||
self::BUSINESS_TYPE_RECEIVE_REWARD => ['text' => 'Receive reward'],
|
||||
self::BUSINESS_TYPE_RECEIVE_GIFT => ['text' => 'Receive gift'],
|
||||
self::BUSINESS_TYPE_UPLOAD_TORRENT => ['text' => 'Upload torrent'],
|
||||
self::BUSINESS_TYPE_SEEDING_BASIC => ['text' => 'Seeding basic'],
|
||||
self::BUSINESS_TYPE_SEEDING_DONOR_ADDITION => ['text' => 'Seeding donor addition'],
|
||||
self::BUSINESS_TYPE_SEEDING_OFFICIAL_ADDITION => ['text' => 'Seeding official addition'],
|
||||
self::BUSINESS_TYPE_SEEDING_HAREM_ADDITION => ['text' => 'Seeding harem addition'],
|
||||
self::BUSINESS_TYPE_SEEDING_MEDAL_ADDITION => ['text' => 'Seeding medal addition'],
|
||||
];
|
||||
|
||||
public function getBusinessTypeTextAttribute()
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class RequireSeedTorrent extends NexusModel
|
||||
{
|
||||
protected $fillable = ['torrent_id'];
|
||||
|
||||
public $timestamps = true;
|
||||
}
|
||||
@@ -263,5 +263,50 @@ class Setting extends NexusModel
|
||||
return self::get('security.record_announce_logs') == 'yes';
|
||||
}
|
||||
|
||||
public static function getIsRequireSeedSectionEnabled(): bool
|
||||
{
|
||||
return self::get("require_seed_section.enabled") == "yes";
|
||||
}
|
||||
|
||||
public static function getRequireSeedSectionSeederGte(): int
|
||||
{
|
||||
return (int)self::get("require_seed_section.seeder_gte");
|
||||
}
|
||||
|
||||
public static function getRequireSeedSectionSeederLte(): int
|
||||
{
|
||||
return (int)self::get("require_seed_section.seeder_lte");
|
||||
}
|
||||
|
||||
public static function getRequireSeedSectionMenuTitle(): string
|
||||
{
|
||||
return self::get("require_seed_section.menu_title", nexus_trans("torrent.require_seed_section_menu_title"));
|
||||
}
|
||||
|
||||
public static function getRequireSeedSectionPromotionState(): int
|
||||
{
|
||||
return self::get("require_seed_section.promotion_state", Torrent::REQUIRE_SEED_SECTION_DEFAULT_PROMOTION_STATE);
|
||||
}
|
||||
|
||||
public static function getRequireSeedSectionBonusAdditionFactor(): float
|
||||
{
|
||||
return self::get("require_seed_section.bonus_addition_factor", Torrent::REQUIRE_SEED_SECTION_DEFAULT_BONUS_ADDITION_FACTOR);
|
||||
}
|
||||
|
||||
public static function getRequireSeedSectionTags(): array
|
||||
{
|
||||
return self::get("require_seed_section.require_tags", []);
|
||||
}
|
||||
|
||||
public static function getRequireSeedSectionTorrentCountMax(): int
|
||||
{
|
||||
return self::get("require_seed_section.torrent_count_max", Torrent::REQUIRE_SEED_SECTION_DEFAULT_TORRENT_COUNT_MAX);
|
||||
}
|
||||
|
||||
public static function getBonusMinSize(): int
|
||||
{
|
||||
return (int)self::get("bonus.min_size");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -170,6 +170,12 @@ class Torrent extends NexusModel
|
||||
|
||||
const NFO_VIEW_STYLE_DOS = 'magic';
|
||||
const NFO_VIEW_STYLE_WINDOWS = 'latin-1';
|
||||
const REQUIRE_SEED_SECTION_DEFAULT_PROMOTION_STATE = self::PROMOTION_FREE;
|
||||
const REQUIRE_SEED_SECTION_DEFAULT_BONUS_ADDITION_FACTOR = 0;
|
||||
const REQUIRE_SEED_SECTION_DEFAULT_TORRENT_COUNT_MAX = 100;
|
||||
const REQUIRE_SEED_SECTION_PROMOTION_STATE_CACHE_KEY = "REQUIRE_SEED_SECTION_PROMOTION_STATE_CACHE";
|
||||
const REQUIRE_SEED_SECTION_TORRENT_ON_LIST_CACHE_KEY = "REQUIRE_SEED_SECTION_TORRENT_ON_LIST_CACHE";
|
||||
const REQUIRE_SEED_SECTION_TORRENT_USER_CACHE_KEY = "REQUIRE_SEED_SECTION_TORRENT_USER_CACHE";
|
||||
|
||||
public static array $nfoViewStyles = [
|
||||
self::NFO_VIEW_STYLE_DOS => ['text' => 'DOS-vy'],
|
||||
|
||||
+21
-16
@@ -19,22 +19,7 @@ class TrackerUrl extends NexusModel
|
||||
if ($model->is_default == 1) {
|
||||
self::query()->where("id", "!=", $model->id)->update(["is_default" => 0]);
|
||||
}
|
||||
//添加 id 与 URL 映射
|
||||
$redis = NexusDB::redis();
|
||||
$redis->del(self::TRACKER_URL_CACHE_KEY);
|
||||
$list = self::listAll();
|
||||
$first = $list->first();
|
||||
$hasDefault = false;
|
||||
foreach ($list as $item) {
|
||||
$redis->hset(self::TRACKER_URL_CACHE_KEY, $item->id, $item->url);
|
||||
if ($item->is_default == 1) {
|
||||
$hasDefault = true;
|
||||
$redis->set(self::TRACKER_URL_DEFAULT_CACHE_KEY, $item->url);
|
||||
}
|
||||
}
|
||||
if (!$hasDefault && $first) {
|
||||
$redis->set(self::TRACKER_URL_DEFAULT_CACHE_KEY, $first->url);
|
||||
}
|
||||
self::saveUrlCache();
|
||||
});
|
||||
static::saving(function (TrackerUrl $model) {
|
||||
if ($model->is_default == 1) {
|
||||
@@ -43,6 +28,26 @@ class TrackerUrl extends NexusModel
|
||||
});
|
||||
}
|
||||
|
||||
public static function saveUrlCache(): void
|
||||
{
|
||||
//添加 id 与 URL 映射
|
||||
$redis = NexusDB::redis();
|
||||
$redis->del(self::TRACKER_URL_CACHE_KEY);
|
||||
$list = self::listAll();
|
||||
$first = $list->first();
|
||||
$hasDefault = false;
|
||||
foreach ($list as $item) {
|
||||
$redis->hset(self::TRACKER_URL_CACHE_KEY, $item->id, $item->url);
|
||||
if ($item->is_default == 1) {
|
||||
$hasDefault = true;
|
||||
$redis->set(self::TRACKER_URL_DEFAULT_CACHE_KEY, $item->url);
|
||||
}
|
||||
}
|
||||
if (!$hasDefault && $first) {
|
||||
$redis->set(self::TRACKER_URL_DEFAULT_CACHE_KEY, $first->url);
|
||||
}
|
||||
}
|
||||
|
||||
public static function listAll()
|
||||
{
|
||||
return self::query()
|
||||
|
||||
+11
-4
@@ -66,7 +66,7 @@ class User extends Authenticatable implements FilamentUser, HasName
|
||||
self::CLASS_EXTREME_USER => ['text' => 'Extreme User', 'min_seed_points' => 600000],
|
||||
self::CLASS_ULTIMATE_USER => ['text' => 'Ultimate User', 'min_seed_points' => 800000],
|
||||
self::CLASS_NEXUS_MASTER => ['text' => 'Nexus Master', 'min_seed_points' => 1000000],
|
||||
self::CLASS_VIP => ['text' => 'Vip'],
|
||||
self::CLASS_VIP => ['text' => 'VIP'],
|
||||
self::CLASS_RETIREE => ['text' => 'Retiree'],
|
||||
self::CLASS_UPLOADER => ['text' => 'Uploader'],
|
||||
self::CLASS_MODERATOR => ['text' => 'Moderator'],
|
||||
@@ -105,6 +105,13 @@ class User extends Authenticatable implements FilamentUser, HasName
|
||||
|
||||
public static array $notificationOptions = ['topic_reply', 'hr_reached'];
|
||||
|
||||
private const USER_ENABLE_LATELY = "user_enable_lately:%s";
|
||||
|
||||
public static function getUserEnableLatelyCacheKey(int $userId): string
|
||||
{
|
||||
return sprintf(self::USER_ENABLE_LATELY, $userId);
|
||||
}
|
||||
|
||||
public function getClassTextAttribute(): string
|
||||
{
|
||||
return self::getClassText($this->class);
|
||||
@@ -115,12 +122,12 @@ class User extends Authenticatable implements FilamentUser, HasName
|
||||
if (!is_numeric($class)|| !isset(self::$classes[$class])) {
|
||||
return '';
|
||||
}
|
||||
$classText = self::$classes[$class]['text'];
|
||||
if ($class >= self::CLASS_VIP) {
|
||||
$classText = nexus_trans('user.class_names.' . $class);
|
||||
$alias = nexus_trans('user.class_names.' . $class);
|
||||
} else {
|
||||
$classText = self::$classes[$class]['text'];
|
||||
$alias = Setting::get("account.{$class}_alias");
|
||||
}
|
||||
$alias = Setting::get("account.{$class}_alias");
|
||||
if (!empty($alias)) {
|
||||
$classText .= "({$alias})";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
class UserRequireSeedTorrent extends NexusModel
|
||||
{
|
||||
protected $fillable = ['user_id', 'torrent_id', 'seed_time_begin', 'uploaded_begin', 'last_settlement_at'];
|
||||
|
||||
public $timestamps = true;
|
||||
}
|
||||
Reference in New Issue
Block a user