update: optimize commission calculation

This commit is contained in:
tokumeikoi 2022-02-07 15:05:56 +08:00
parent 8a18bdf9c3
commit 9dc44c0e1d
3 changed files with 7 additions and 5 deletions

View File

@ -93,7 +93,6 @@ class CheckCommission extends Command
0 => 100
];
}
$actualPayCommissionAmount = 0;
for ($l = 0; $l < $level; $l++) {
$inviter = User::find($inviteUserId);
if (!$inviter) continue;
@ -119,10 +118,9 @@ class CheckCommission extends Command
return false;
}
$inviteUserId = $inviter->invite_user_id;
$actualPayCommissionAmount = $actualPayCommissionAmount + $commissionBalance;
// update order actual commission balance
$order->actual_commission_balance = $order->actual_commission_balance + $commissionBalance;
}
// update order commission balance
$order->commission_balance = $actualPayCommissionAmount;
return true;
}

View File

@ -128,6 +128,7 @@ CREATE TABLE `v2_order` (
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0待支付1开通中2已取消3已完成4已折抵',
`commission_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0待确认1发放中2有效3无效',
`commission_balance` int(11) NOT NULL DEFAULT '0',
`actual_commission_balance` int(11) DEFAULT NULL COMMENT '实际支付佣金',
`paid_at` int(11) DEFAULT NULL,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
@ -371,4 +372,4 @@ CREATE TABLE `v2_user` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 2022-01-21 18:20:29
-- 2022-02-07 07:04:34

View File

@ -483,3 +483,6 @@ ALTER TABLE `v2_coupon`
ALTER TABLE `v2_notice`
ADD `show` tinyint(1) NOT NULL DEFAULT '0' AFTER `content`;
ALTER TABLE `v2_order`
ADD `actual_commission_balance` int(11) NULL COMMENT '实际支付佣金' AFTER `commission_balance`;