...
|
...
|
@@ -32,21 +32,25 @@ class Finish |
|
|
if($first_user){
|
|
|
// 一级佣金
|
|
|
$share = json_decode(Config::where(['name' => 'share'])->value('value'), true);
|
|
|
$first_commission = $order['pay_fee'] * $share['order_first'] / 100;
|
|
|
$first_commission = ($share['order_first'] > 0) ? ($order['pay_fee'] * $share['order_first'] / 100) : 0;
|
|
|
if($first_commission > 0){
|
|
|
$first_user->commission = Db::raw('commission + ' . $first_commission);
|
|
|
$first_user->save();
|
|
|
// 记录 UserCommissionLog
|
|
|
\app\api\model\UserCommissionLog::doAdd($first_user, $first_commission, 'order_commssion', $order['id'], 1);
|
|
|
|
|
|
// 二级佣金
|
|
|
$second_user = User::get($first_user['pid']);
|
|
|
if($second_user){
|
|
|
$second_commission = $order['pay_fee'] * $share['order_second'] / 100;
|
|
|
$second_user->commission = Db::raw('commission + ' . $second_commission);
|
|
|
$second_user->save();
|
|
|
// 记录 UserCommissionLog
|
|
|
\app\api\model\UserCommissionLog::doAdd($second_user, $second_commission, 'order_commssion', $order['id'], 1);
|
|
|
}
|
|
|
|
|
|
// // 二级佣金
|
|
|
// $second_user = User::get($first_user['pid']);
|
|
|
// if($second_user){
|
|
|
// $second_commission = ($share['order_second'] > 0) ? ($order['pay_fee'] * $share['order_second'] / 100) : 0;
|
|
|
// if($second_commission > 0){
|
|
|
// $second_user->commission = Db::raw('commission + ' . $second_commission);
|
|
|
// $second_user->save();
|
|
|
// // 记录 UserCommissionLog
|
|
|
// \app\api\model\UserCommissionLog::doAdd($second_user, $second_commission, 'order_commssion', $order['id'], 1);
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
return $order;
|
...
|
...
|
|