Browse Source

提现限制

Kirin 1 year ago
parent
commit
5bd4df7b66
1 changed files with 31 additions and 21 deletions
  1. 31 21
      app/models/store/StoreOrder.php

+ 31 - 21
app/models/store/StoreOrder.php

@@ -2579,37 +2579,39 @@ class StoreOrder extends BaseModel
                     $ratio = ($group_level['company_award'] > $award_level['company_award'] ? $group_level['company_award'] : $award_level['company_award']);
                     $spread_up = User::where('uid', $spread['spread_uid'])->find();
                     $group_levels = SystemGroupLevel::where('company_award', '>', 0)->column('id');
+                    $p_ratio = 0;
                     $award_levels = SystemAwardLevel::where('company_award', '>', 0)->column('id');
 //                    @file_put_contents('order.txt', '【8.8】' . time() . PHP_EOL, FILE_APPEND);
                     while ($spread_up) {
                         if (in_array($spread_up['group_level'], $group_levels) || in_array($spread_up['award_level'], $award_levels)) {
                             $ratio -= 1;
+                            $p_ratio = 1;
                             break;
                         }
                         $spread_up = User::where('uid', $spread_up['spread_uid'])->find();
                     }
 //                    @file_put_contents('order.txt', '【8.9】' . time() . PHP_EOL, FILE_APPEND);
-                    $c = [];
-                    $p = [$spread['uid']];
-                    while ($p) {
-                        $child = User::where('spread_uid', 'in', $p)->where(function ($query) use ($group_levels, $award_levels) {
-                            if (count($group_levels) && count($award_levels)) {
-                                $query->where('group_level', 'in', $group_levels)
-                                    ->whereOr('award_level', 'in', $award_levels);
-                            } else if (count($group_levels)) {
-                                $query->where('group_level', 'in', $group_levels);
-                            } else if (count($award_levels)) {
-                                $query->where('award_level', 'in', $award_levels);
-                            } else {
-                                $query->where('award_level', '100000000000');
-                            }
-                        })->column('uid');
-                        if (count($child)) {
-                            $c = array_merge($c, $child);
-                        }
-                        $p = User::where('spread_uid', 'in', $p)->where('uid', 'not in', $child)->column('uid');
-                    }
-                    $ratio += count(array_unique($c));
+//                    $c = [];
+//                    $p = [$spread['uid']];
+//                    while ($p) {
+//                        $child = User::where('spread_uid', 'in', $p)->where(function ($query) use ($group_levels, $award_levels) {
+//                            if (count($group_levels) && count($award_levels)) {
+//                                $query->where('group_level', 'in', $group_levels)
+//                                    ->whereOr('award_level', 'in', $award_levels);
+//                            } else if (count($group_levels)) {
+//                                $query->where('group_level', 'in', $group_levels);
+//                            } else if (count($award_levels)) {
+//                                $query->where('award_level', 'in', $award_levels);
+//                            } else {
+//                                $query->where('award_level', '100000000000');
+//                            }
+//                        })->column('uid');
+//                        if (count($child)) {
+//                            $c = array_merge($c, $child);
+//                        }
+//                        $p = User::where('spread_uid', 'in', $p)->where('uid', 'not in', $child)->column('uid');
+//                    }
+//                    $ratio += count(array_unique($c));
                     if ($ratio > 0) {
                         $op_award = bcmul($suit_price, bcdiv($ratio, 100, 4), 2);
                         if ($op_award > 0) {
@@ -2619,6 +2621,14 @@ class StoreOrder extends BaseModel
                             $balance = bcadd($balance, $op_award, 2);
                         }
                     }
+                    if ($p_ratio > 0) {
+                        $op_award = bcmul($suit_price, bcdiv($p_ratio, 100, 4), 2);
+                        if ($op_award > 0) {
+                            $mark = '用户' . $userInfo['nickname'] . '(' . $order['uid'] . ')' . '购买套装商品,获得分公司奖奖励' . $op_award;
+                            $res = $res && UserBill::income('分公司奖', $spread_up['uid'], 'now_money', 'brokerage', $op_award, $order['id'], bcadd($spread_up['brokerage_price'], $op_award, 2), $mark);
+                            $res = $res && User::where('uid', $spread_up['uid'])->inc('brokerage_price', $op_award)->update();
+                        }
+                    }
                     $company_award = true;
                 }
                 if (($group_level['operate_award'] > 0 || $award_level['operate_award'] > 0) && !$operate_award) {