添加老配额分红统计
parent
aafd381dcf
commit
f3ce94002c
|
|
@ -33,6 +33,26 @@ class QuotaV1SendLogTable extends Grid
|
||||||
if ($jobId) {
|
if ($jobId) {
|
||||||
$grid->model()->where('job_id', $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 "<div style='padding: 10px;'>已领取:".bcdiv($receivedAmount, 100, 2).' 元 | 未领取:'.bcdiv($failedAmount, 100, 2).' 元 | 共计:'.bcdiv($totalAmount, 100, 2).' 元</div>';
|
||||||
|
});
|
||||||
return $grid;
|
return $grid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,25 +41,25 @@ class QuotaV1SendCommand extends Command
|
||||||
$walletService = new WalletService();
|
$walletService = new WalletService();
|
||||||
//依次分红
|
//依次分红
|
||||||
foreach ($userInfos as $userInfo) {
|
foreach ($userInfos as $userInfo) {
|
||||||
if ($userInfo->bonusable) {//只针对享受分红的人发放
|
// if ($userInfo->bonusable) {//只针对享受分红的人发放
|
||||||
$quotaV1amount = round(bcmul(bcdiv($job->amount, $totalQuotaV1, 5), $userInfo->quota_v1, 3));
|
$quotaV1amount = round(bcmul(bcdiv($job->amount, $totalQuotaV1, 5), $userInfo->quota_v1, 3));
|
||||||
if ($quotaV1amount >0) {
|
if ($quotaV1amount >0) {
|
||||||
$log = new QuotaV1SendLog();
|
$log = new QuotaV1SendLog();
|
||||||
$log->user_id = $userInfo->user_id;
|
$log->user_id = $userInfo->user_id;
|
||||||
$log->job_id = $job->id;
|
$log->job_id = $job->id;
|
||||||
$log->amount = $quotaV1amount;
|
$log->amount = $quotaV1amount;
|
||||||
$log->save();
|
$log->save();
|
||||||
try {
|
// try {
|
||||||
DB::beginTransaction();
|
// DB::beginTransaction();
|
||||||
$log->update(['status'=>1]);
|
// $log->update(['status'=>1]);
|
||||||
$walletService->changeBalance($userInfo->user, $log->amount, WalletLog::ACTION_QUOTA_V1, '老配额分红', $log);
|
// $walletService->changeBalance($userInfo->user, $log->amount, WalletLog::ACTION_QUOTA_V1, '老配额分红', $log);
|
||||||
DB::commit();
|
// DB::commit();
|
||||||
} catch (Throwable $th) {
|
// } catch (Throwable $th) {
|
||||||
DB::rollBack();
|
// DB::rollBack();
|
||||||
report($th);
|
// report($th);
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ class QuotaV1SendLog extends Model
|
||||||
];
|
];
|
||||||
|
|
||||||
public static $statusText = [
|
public static $statusText = [
|
||||||
self::STATUS_FAILED=>'失败',
|
self::STATUS_FAILED=>'未领取',
|
||||||
self::STATUS_SUCCESS=>'成功',
|
self::STATUS_SUCCESS=>'已领取',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue