update: commission stat

This commit is contained in:
tokumeikoi 2022-10-29 14:23:51 +08:00
parent 44b2d56db9
commit 37f1f64442
2 changed files with 11 additions and 10 deletions

View File

@ -80,15 +80,14 @@ class CheckCommission extends Command
public function payHandle($inviteUserId, Order $order) public function payHandle($inviteUserId, Order $order)
{ {
$level = 3;
if ((int)config('v2board.commission_distribution_enable', 0)) { if ((int)config('v2board.commission_distribution_enable', 0)) {
$level = 3;
$commissionShareLevels = [ $commissionShareLevels = [
0 => (int)config('v2board.commission_distribution_l1'), 0 => (int)config('v2board.commission_distribution_l1'),
1 => (int)config('v2board.commission_distribution_l2'), 1 => (int)config('v2board.commission_distribution_l2'),
2 => (int)config('v2board.commission_distribution_l3') 2 => (int)config('v2board.commission_distribution_l3')
]; ];
} else { } else {
$level = 3;
$commissionShareLevels = [ $commissionShareLevels = [
0 => 100 0 => 100
]; ];

View File

@ -58,19 +58,21 @@ class InviteController extends Controller
if ($user->commission_rate) { if ($user->commission_rate) {
$commission_rate = $user->commission_rate; $commission_rate = $user->commission_rate;
} }
$uncheck_commission_balance = (int)Order::where('status', 3)
->where('commission_status', 0)
->where('invite_user_id', $request->user['id'])
->sum('commission_balance');
if (config('v2board.commission_distribution_enable', 0)) {
$uncheck_commission_balance = $uncheck_commission_balance * (config('v2board.commission_distribution_l1') / 100);
}
$stat = [ $stat = [
//已注册用户数 //已注册用户数
(int)User::where('invite_user_id', $request->user['id'])->count(), (int)User::where('invite_user_id', $request->user['id'])->count(),
//有效的佣金 //有效的佣金
(int)Order::where('status', 3) (int)CommissionLog::where('invite_user_id', $request->user['id'])
->where('commission_status', 2) ->sum('get_amount'),
->where('invite_user_id', $request->user['id'])
->sum('commission_balance'),
//确认中的佣金 //确认中的佣金
(int)Order::where('status', 3) $uncheck_commission_balance,
->where('commission_status', 0)
->where('invite_user_id', $request->user['id'])
->sum('commission_balance'),
//佣金比例 //佣金比例
(int)$commission_rate, (int)$commission_rate,
//可用佣金 //可用佣金