reward torrent add bonus log

This commit is contained in:
xiaomlove
2025-09-08 11:57:33 +07:00
parent 6411cdc72e
commit 22a91a5851
5 changed files with 27 additions and 3 deletions

View File

@@ -19,6 +19,7 @@ class BonusLogs extends NexusModel
const DEFAULT_BONUS_BUY_RAINBOW_ID = 5000;
const DEFAULT_BONUS_BUY_CHANGE_USERNAME_CARD = 100000;
//扣除类1开始
const BUSINESS_TYPE_CANCEL_HIT_AND_RUN = 1;
const BUSINESS_TYPE_BUY_MEDAL = 2;
const BUSINESS_TYPE_BUY_ATTENDANCE_CARD = 3;
@@ -40,13 +41,17 @@ class BonusLogs extends NexusModel
const BUSINESS_TYPE_BUY_TORRENT = 19;
const BUSINESS_TYPE_TASK_NOT_PASS_DEDUCT = 20;
const BUSINESS_TYPE_TASK_PASS_REWARD = 21;
const BUSINESS_TYPE_REWARD_TORRENT = 22;
//获得类普通获得1000 起步
const BUSINESS_TYPE_ROLE_WORK_SALARY = 1000;
const BUSINESS_TYPE_TORRENT_BE_DOWNLOADED = 1001;
const BUSINESS_TYPE_RECEIVE_REWARD = 1002;
const BUSINESS_TYPE_RECEIVE_GIFT = 1003;
const BUSINESS_TYPE_UPLOAD_TORRENT = 1004;
const BUSINESS_TYPE_TORRENT_BE_REWARD = 1005;
//获得类做种获得10000 起
const BUSINESS_TYPE_SEEDING_BASIC = 10000;
const BUSINESS_TYPE_SEEDING_DONOR_ADDITION = 10001;
const BUSINESS_TYPE_SEEDING_OFFICIAL_ADDITION = 10002;
@@ -75,12 +80,15 @@ class BonusLogs extends NexusModel
self::BUSINESS_TYPE_BUY_TORRENT => ['text' => 'Buy torrent'],
self::BUSINESS_TYPE_TASK_NOT_PASS_DEDUCT => ['text' => 'Task failure penalty'],
self::BUSINESS_TYPE_TASK_PASS_REWARD => ['text' => 'Task success reward'],
self::BUSINESS_TYPE_REWARD_TORRENT => ['text' => 'Reward torrent'],
self::BUSINESS_TYPE_ROLE_WORK_SALARY => ['text' => 'Role work salary'],
self::BUSINESS_TYPE_TORRENT_BE_DOWNLOADED => ['text' => 'Torrent be downloaded'],
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_TORRENT_BE_REWARD => ['text' => 'Torrent be reward'],
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'],
@@ -135,7 +143,7 @@ class BonusLogs extends NexusModel
'old_total_value' => $old,
'value' => $delta,
'new_total_value' => $new,
'comment' => sprintf("[%s] %s", self::$businessTypes[$businessType]['text'], $comment),
'comment' => sprintf("[%s]%s", self::$businessTypes[$businessType]['text'], $comment ? " $comment" : ""),
'created_at' => $nowStr,
'updated_at' => $nowStr,
]);

View File

@@ -8,7 +8,9 @@ if (isset($_GET['id'])) stderr("Party is over!", "This trick doesn't work anymor
$userid = $CURUSER["id"];
$torrentid = (int) $_POST["id"];
$value = (int) abs($_POST['value']);
if (!in_array($value, \App\Models\Setting::getBonusRewardOptions())) {
stderr('Error', 'Invalid value.');
}
if($value <= 0) stderr('Error', 'Value must be positive.');
if($value > $CURUSER['seedbonus']) stderr('Error','You do not have such bonus!');
$tsql = sql_query("SELECT owner FROM torrents WHERE id = $torrentid") or sqlerr(__FILE__,__LINE__);
@@ -21,9 +23,14 @@ $tsql = sql_query("SELECT COUNT(*) FROM magic WHERE torrentid=$torrentid and use
$trows = mysql_fetch_assoc($tsql);
$t_ab = $trows[0];
if ($t_ab != 0) stderr("Error", "You already gave the magic value!");
$torrentOwnerInfo = \App\Models\User::query()->find($torrentowner, \App\Models\User::$commonFields);
if (!$torrentOwnerInfo) {
stderr('Error', 'Invalid torrent owner!');
}
if (isset($userid) && isset($torrentid)&& isset($value)) {
sql_query("INSERT INTO magic (torrentid, userid,value) VALUES ($torrentid, $userid, $value)") or sqlerr(__FILE__,__LINE__);
KPS("-",$value,$CURUSER['id']);//selete
\App\Models\BonusLogs::add($CURUSER['id'], $CURUSER['seedbonus'], $value, $CURUSER['seedbonus'] - $value, "", \App\Models\BonusLogs::BUSINESS_TYPE_REWARD_TORRENT);
KPS("+",$value,$torrentowner);//add to the owner
\App\Models\BonusLogs::add($torrentOwnerInfo['id'], $torrentOwnerInfo['seedbonus'], $value, $torrentOwnerInfo['seedbonus'] + $value, "", \App\Models\BonusLogs::BUSINESS_TYPE_TORRENT_BE_REWARD);
}

View File

@@ -21,12 +21,15 @@ return [
\App\Models\BonusLogs::BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD => 'Buy change username card',
\App\Models\BonusLogs::BUSINESS_TYPE_GIFT_MEDAL => 'Gift medal',
\App\Models\BonusLogs::BUSINESS_TYPE_BUY_TORRENT => 'Buy torrent',
\App\Models\BonusLogs::BUSINESS_TYPE_REWARD_TORRENT => 'Reward torrent',
\App\Models\BonusLogs::BUSINESS_TYPE_ROLE_WORK_SALARY => 'Role work salary',
\App\Models\BonusLogs::BUSINESS_TYPE_TORRENT_BE_DOWNLOADED => 'Torrent be downloaded',
\App\Models\BonusLogs::BUSINESS_TYPE_RECEIVE_REWARD => 'Receive reward',
\App\Models\BonusLogs::BUSINESS_TYPE_RECEIVE_GIFT => 'Receive gift',
\App\Models\BonusLogs::BUSINESS_TYPE_UPLOAD_TORRENT => 'Upload torrent',
\App\Models\BonusLogs::BUSINESS_TYPE_TORRENT_BE_REWARD => 'Torrent receive reward',
\App\Models\BonusLogs::BUSINESS_TYPE_SEEDING_BASIC => 'Seeding basic',
\App\Models\BonusLogs::BUSINESS_TYPE_SEEDING_DONOR_ADDITION => 'Seeding donor addition',
\App\Models\BonusLogs::BUSINESS_TYPE_SEEDING_OFFICIAL_ADDITION => 'Seeding official addition',

View File

@@ -23,12 +23,15 @@ return [
\App\Models\BonusLogs::BUSINESS_TYPE_BUY_TORRENT => '购买种子',
\App\Models\BonusLogs::BUSINESS_TYPE_TASK_PASS_REWARD => '任务完成奖励',
\App\Models\BonusLogs::BUSINESS_TYPE_TASK_NOT_PASS_DEDUCT => '任务未完成扣除',
\App\Models\BonusLogs::BUSINESS_TYPE_REWARD_TORRENT => '奖励种子',
\App\Models\BonusLogs::BUSINESS_TYPE_ROLE_WORK_SALARY => '工作组工资',
\App\Models\BonusLogs::BUSINESS_TYPE_TORRENT_BE_DOWNLOADED => '种子被下载',
\App\Models\BonusLogs::BUSINESS_TYPE_RECEIVE_REWARD => '收到奖励',
\App\Models\BonusLogs::BUSINESS_TYPE_RECEIVE_GIFT => '收到礼物',
\App\Models\BonusLogs::BUSINESS_TYPE_UPLOAD_TORRENT => '发布种子',
\App\Models\BonusLogs::BUSINESS_TYPE_TORRENT_BE_REWARD => '种子收到奖励',
\App\Models\BonusLogs::BUSINESS_TYPE_SEEDING_BASIC => '做种基础魔力',
\App\Models\BonusLogs::BUSINESS_TYPE_SEEDING_DONOR_ADDITION => '做种捐赠加成',
\App\Models\BonusLogs::BUSINESS_TYPE_SEEDING_OFFICIAL_ADDITION => '做种官种加成',

View File

@@ -21,12 +21,15 @@ return [
\App\Models\BonusLogs::BUSINESS_TYPE_BUY_CHANGE_USERNAME_CARD => '購買改名卡',
\App\Models\BonusLogs::BUSINESS_TYPE_GIFT_MEDAL => '贈送勛章',
\App\Models\BonusLogs::BUSINESS_TYPE_BUY_TORRENT => '購買種子',
\App\Models\BonusLogs::BUSINESS_TYPE_REWARD_TORRENT => '獎勵種子',
\App\Models\BonusLogs::BUSINESS_TYPE_ROLE_WORK_SALARY => '工作組工資',
\App\Models\BonusLogs::BUSINESS_TYPE_TORRENT_BE_DOWNLOADED => '種子被下載',
\App\Models\BonusLogs::BUSINESS_TYPE_RECEIVE_REWARD => '收到獎勵',
\App\Models\BonusLogs::BUSINESS_TYPE_RECEIVE_GIFT => '收到禮物',
\App\Models\BonusLogs::BUSINESS_TYPE_UPLOAD_TORRENT => '發布種子',
\App\Models\BonusLogs::BUSINESS_TYPE_TORRENT_BE_REWARD => '種子收到獎勵',
\App\Models\BonusLogs::BUSINESS_TYPE_SEEDING_BASIC => '做種基礎魔力',
\App\Models\BonusLogs::BUSINESS_TYPE_SEEDING_DONOR_ADDITION => '做種捐贈加成',
\App\Models\BonusLogs::BUSINESS_TYPE_SEEDING_OFFICIAL_ADDITION => '做種官種加成',