mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-03 14:10:57 +08:00
claim settle add bonus log
This commit is contained in:
@@ -42,6 +42,7 @@ class BonusLogs extends NexusModel
|
||||
const BUSINESS_TYPE_TASK_NOT_PASS_DEDUCT = 20;
|
||||
const BUSINESS_TYPE_TASK_PASS_REWARD = 21;
|
||||
const BUSINESS_TYPE_REWARD_TORRENT = 22;
|
||||
const BUSINESS_TYPE_CLAIMED_UNREACHED = 23;
|
||||
|
||||
//获得类,普通获得,1000 起步
|
||||
const BUSINESS_TYPE_ROLE_WORK_SALARY = 1000;
|
||||
@@ -50,6 +51,7 @@ class BonusLogs extends NexusModel
|
||||
const BUSINESS_TYPE_RECEIVE_GIFT = 1003;
|
||||
const BUSINESS_TYPE_UPLOAD_TORRENT = 1004;
|
||||
const BUSINESS_TYPE_TORRENT_BE_REWARD = 1005;
|
||||
const BUSINESS_TYPE_CLAIMED_REACHED = 1006;
|
||||
|
||||
//获得类,做种获得,10000 起
|
||||
const BUSINESS_TYPE_SEEDING_BASIC = 10000;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Jobs\SettleClaim;
|
||||
use App\Models\BonusLogs;
|
||||
use App\Models\Claim;
|
||||
use App\Models\Message;
|
||||
use App\Models\Snatch;
|
||||
@@ -260,16 +261,24 @@ class ClaimRepository extends BaseRepository
|
||||
|
||||
//Wrap with transaction
|
||||
DB::transaction(function () use ($uid, $unReachedIdArr, $toUpdateIdArr, $bonusFinal, $totalDeduct, $uploadedCaseWhen, $seedTimeCaseWhen, $message, $now) {
|
||||
//get latest
|
||||
$oldBonus = User::query()->find($uid, ['seedbonus'])->seedbonus;
|
||||
$delta = 0;
|
||||
//Increase user bonus
|
||||
User::query()->where('id', $uid)->increment('seedbonus', $bonusFinal);
|
||||
do_log("Increase user bonus: $bonusFinal", 'alert');
|
||||
$delta += $bonusFinal;
|
||||
do_log("Increase user: $uid bonus: $bonusFinal", 'alert');
|
||||
BonusLogs::add($uid, $oldBonus, $bonusFinal, $oldBonus + $bonusFinal, "", BonusLogs::BUSINESS_TYPE_CLAIMED_REACHED);
|
||||
$oldBonus += $bonusFinal;
|
||||
|
||||
//Handle unreached
|
||||
if (!empty($unReachedIdArr)) {
|
||||
Claim::query()->whereIn('id', $unReachedIdArr)->delete();
|
||||
User::query()->where('id', $uid)->decrement('seedbonus', $totalDeduct);
|
||||
do_log("Deduct user bonus: $totalDeduct", 'alert');
|
||||
$delta -= $totalDeduct;
|
||||
do_log("Deduct user: $uid bonus: $totalDeduct", 'alert');
|
||||
BonusLogs::add($uid, $oldBonus, $totalDeduct, $oldBonus - $totalDeduct, "", BonusLogs::BUSINESS_TYPE_CLAIMED_UNREACHED);
|
||||
$oldBonus -= $totalDeduct;
|
||||
}
|
||||
User::query()->where('id', $uid)->increment('seedbonus', $delta);
|
||||
|
||||
//Update claim `last_settle_at` and init `seed_time_begin` & `uploaded_begin`
|
||||
if (!empty($toUpdateIdArr)) {
|
||||
|
||||
Reference in New Issue
Block a user