|
@@ -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');
|
|
|
|
|
|
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();
|
|
|
}
|
|
|
|
|
|
- $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) {
|