diff --git a/app/Admin/Renderable/QuotaV1SendLogTable.php b/app/Admin/Renderable/QuotaV1SendLogTable.php index 06664802..5101f1b3 100644 --- a/app/Admin/Renderable/QuotaV1SendLogTable.php +++ b/app/Admin/Renderable/QuotaV1SendLogTable.php @@ -33,6 +33,26 @@ class QuotaV1SendLogTable extends Grid if ($jobId) { $grid->model()->where('job_id', $jobId); } + + $grid->header(function ($collection) use ($grid) { + $query = QuotaV1SendLog::query(); + + // 拿到表格筛选 where 条件数组进行遍历 + $grid->model()->getQueries()->unique()->each(function ($value) use (&$query) { + if (in_array($value['method'], ['paginate', 'get', 'orderBy', 'orderByDesc'], true)) { + return; + } + + $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []); + }); + + // 查出统计数据 + $receivedAmount = (clone $query)->where('status', QuotaV1SendLog::STATUS_SUCCESS)->sum('amount'); + $failedAmount = (clone $query)->where('status', QuotaV1SendLog::STATUS_FAILED)->sum('amount'); + $totalAmount = (clone $query)->sum('amount'); + // 自定义组件 + return "
已领取:".bcdiv($receivedAmount, 100, 2).' 元 | 未领取:'.bcdiv($failedAmount, 100, 2).' 元 | 共计:'.bcdiv($totalAmount, 100, 2).' 元
'; + }); return $grid; } } diff --git a/app/Console/Commands/QuotaV1SendCommand.php b/app/Console/Commands/QuotaV1SendCommand.php index 0378c3b8..af58be15 100644 --- a/app/Console/Commands/QuotaV1SendCommand.php +++ b/app/Console/Commands/QuotaV1SendCommand.php @@ -41,25 +41,25 @@ class QuotaV1SendCommand extends Command $walletService = new WalletService(); //依次分红 foreach ($userInfos as $userInfo) { - if ($userInfo->bonusable) {//只针对享受分红的人发放 - $quotaV1amount = round(bcmul(bcdiv($job->amount, $totalQuotaV1, 5), $userInfo->quota_v1, 3)); - if ($quotaV1amount >0) { - $log = new QuotaV1SendLog(); - $log->user_id = $userInfo->user_id; - $log->job_id = $job->id; - $log->amount = $quotaV1amount; - $log->save(); - try { - DB::beginTransaction(); - $log->update(['status'=>1]); - $walletService->changeBalance($userInfo->user, $log->amount, WalletLog::ACTION_QUOTA_V1, '老配额分红', $log); - DB::commit(); - } catch (Throwable $th) { - DB::rollBack(); - report($th); - } - } + // if ($userInfo->bonusable) {//只针对享受分红的人发放 + $quotaV1amount = round(bcmul(bcdiv($job->amount, $totalQuotaV1, 5), $userInfo->quota_v1, 3)); + if ($quotaV1amount >0) { + $log = new QuotaV1SendLog(); + $log->user_id = $userInfo->user_id; + $log->job_id = $job->id; + $log->amount = $quotaV1amount; + $log->save(); + // try { + // DB::beginTransaction(); + // $log->update(['status'=>1]); + // $walletService->changeBalance($userInfo->user, $log->amount, WalletLog::ACTION_QUOTA_V1, '老配额分红', $log); + // DB::commit(); + // } catch (Throwable $th) { + // DB::rollBack(); + // report($th); + // } } + // } } }); } diff --git a/app/Models/QuotaV1SendLog.php b/app/Models/QuotaV1SendLog.php index 163e0efc..1e3f5184 100644 --- a/app/Models/QuotaV1SendLog.php +++ b/app/Models/QuotaV1SendLog.php @@ -23,8 +23,8 @@ class QuotaV1SendLog extends Model ]; public static $statusText = [ - self::STATUS_FAILED=>'失败', - self::STATUS_SUCCESS=>'成功', + self::STATUS_FAILED=>'未领取', + self::STATUS_SUCCESS=>'已领取', ]; public function user()