|
@@ -829,93 +829,96 @@ class User extends BaseModel
|
|
|
$user = User::where('uid', $order['uid'])->find();
|
|
|
$info = StoreOrderCartInfo::where('oid', $order['id'])->where('product_id', '<=', 2)->select();
|
|
|
foreach ($info as $item){
|
|
|
- $product = StoreProduct::where('id', $item['product_id'])->find();
|
|
|
- if ($user['spread_uid']){
|
|
|
- // 当前用户是否有上级
|
|
|
- $spread = User::where('uid', $user['spread_uid'])->find();
|
|
|
- if ($spread['level'] == 2){
|
|
|
- // 如果用户是黄金会员
|
|
|
- $push = $product['price'] * 0.2; //获得价格百分之20的佣金
|
|
|
- if ($spread['brokerage_price']+$push > 6000){
|
|
|
- $max = 6000 - $spread['brokerage_price'];
|
|
|
- $spread['brokerage_price'] += 6000 - $spread['brokerage_price'];
|
|
|
- UserBill::income('佣金', $spread['uid'], 'now_money', 'brokerage', $max, $spread['spread_uid'], $spread['brokerage_price'], '直推礼包销售额20%分红,已达到上限');
|
|
|
- }else{
|
|
|
- $spread['brokerage_price'] += $push;
|
|
|
- UserBill::income('佣金', $spread['uid'], 'now_money', 'brokerage', $push, $spread['spread_uid'], $spread['brokerage_price'], '直推礼包销售额20%分红');
|
|
|
- }
|
|
|
- $spread->save();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- if ($product['id'] == 1){
|
|
|
- $divide = $silver == 0 ? 0 :($product['price'] * 0.1)/$silver; // 200礼包的百分之十白银会员平分
|
|
|
- $diamonds_divide = $silver == 0 ? 0:($product['price'] * 0.03)/$diamonds;//钻石会员200礼包的百分之3
|
|
|
- if ($silver_user){
|
|
|
- foreach ($silver_user as &$value){
|
|
|
- if ($value['brokerage_price']+$divide > 200){
|
|
|
- $max = 200 - $value['brokerage_price'];
|
|
|
- $value['brokerage_price'] += 200 - $value['brokerage_price'];
|
|
|
- UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $max, $value['spread_uid'], $value['brokerage_price'], '白银会员200礼包销售额分红,已达到上限');
|
|
|
+ $cart_info = $item['cart_info'];
|
|
|
+ for ($i = 0;$i < $cart_info['cart_num']; $i++){
|
|
|
+ $product = StoreProduct::where('id', $item['product_id'])->find();
|
|
|
+ if ($user['spread_uid']){
|
|
|
+ // 当前用户是否有上级
|
|
|
+ $spread = User::where('uid', $user['spread_uid'])->find();
|
|
|
+ if ($spread['level'] == 2){
|
|
|
+ // 如果用户是黄金会员
|
|
|
+ $push = $product['price'] * 0.2; //获得价格百分之20的佣金
|
|
|
+ if ($spread['brokerage_price']+$push > 6000){
|
|
|
+ $max = 6000 - $spread['brokerage_price'];
|
|
|
+ $spread['brokerage_price'] += 6000 - $spread['brokerage_price'];
|
|
|
+ UserBill::income('佣金', $spread['uid'], 'now_money', 'brokerage', $max, $spread['spread_uid'], $spread['brokerage_price'], '直推礼包销售额20%分红,已达到上限');
|
|
|
}else{
|
|
|
- $value['brokerage_price'] += $divide;
|
|
|
- UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $divide, $value['spread_uid'], $value['brokerage_price'], '白银会员200礼包销售额分红');
|
|
|
+ $spread['brokerage_price'] += $push;
|
|
|
+ UserBill::income('佣金', $spread['uid'], 'now_money', 'brokerage', $push, $spread['spread_uid'], $spread['brokerage_price'], '直推礼包销售额20%分红');
|
|
|
}
|
|
|
+ $spread->save();
|
|
|
}
|
|
|
- $model->saveAll($silver_user);
|
|
|
- }
|
|
|
- if ($diamonds_user){
|
|
|
- // 钻石会员
|
|
|
- foreach ($diamonds_user as &$value){
|
|
|
- $value['brokerage_price'] += $diamonds_divide;
|
|
|
- UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $diamonds_divide, $value['spread_uid'], $value['brokerage_price'], '钻石会员200礼包提成');
|
|
|
- }
|
|
|
- $model->saveAll($diamonds_user);
|
|
|
- }
|
|
|
- }elseif ($product['id'] == 2){
|
|
|
- //1991礼包 白银会员和黄金会员分百分之十的金额
|
|
|
- $divide = $silver+$gold == 0? 0 : ($product['price'] * 0.1)/($silver+$gold);
|
|
|
- $user = array_merge($silver_user, $gold_user);
|
|
|
|
|
|
- $top_user = getParent($order['uid']); // 获取到上级所有钻石用户
|
|
|
- $count = count($top_user);
|
|
|
- if ($count > 0){
|
|
|
- $top_divide = ($product['price'] * 0.2)/$count;//1991礼包百分之二十上级所有钻石会员平分
|
|
|
- foreach ($top_user as $v){
|
|
|
- $details = self::where('uid', $v)->find();
|
|
|
- $details['brokerage_price'] += $top_divide;
|
|
|
- $details->save();
|
|
|
- UserBill::income('佣金', $details['uid'], 'now_money', 'brokerage', $top_divide, $details['spread_uid'], $details['brokerage_price'], '钻石会员1991礼包销售额20%分红');
|
|
|
-
|
|
|
- }
|
|
|
}
|
|
|
- if ($user){
|
|
|
- // 黄金会员和白银会员
|
|
|
- foreach ($user as &$value){
|
|
|
- if ($value['level'] == 1){
|
|
|
+ if ($product['id'] == 1){
|
|
|
+ $divide = $silver == 0 ? 0 :($product['price'] * 0.1)/$silver; // 200礼包的百分之十白银会员平分
|
|
|
+ $diamonds_divide = $silver == 0 ? 0:($product['price'] * 0.03)/$diamonds;//钻石会员200礼包的百分之3
|
|
|
+ if ($silver_user){
|
|
|
+ foreach ($silver_user as &$value){
|
|
|
if ($value['brokerage_price']+$divide > 200){
|
|
|
$max = 200 - $value['brokerage_price'];
|
|
|
$value['brokerage_price'] += 200 - $value['brokerage_price'];
|
|
|
- UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $max, $value['spread_uid'], $value['brokerage_price'], '白银会员1991礼包销售额分红,已达到上限');
|
|
|
+ UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $max, $value['spread_uid'], $value['brokerage_price'], '白银会员200礼包销售额分红,已达到上限');
|
|
|
}else{
|
|
|
$value['brokerage_price'] += $divide;
|
|
|
- UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $divide, $value['spread_uid'], $value['brokerage_price'], '白银会员1991礼包销售额分红');
|
|
|
+ UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $divide, $value['spread_uid'], $value['brokerage_price'], '白银会员200礼包销售额分红');
|
|
|
}
|
|
|
+ }
|
|
|
+ $model->saveAll($silver_user);
|
|
|
+ }
|
|
|
+ if ($diamonds_user){
|
|
|
+ // 钻石会员
|
|
|
+ foreach ($diamonds_user as &$value){
|
|
|
+ $value['brokerage_price'] += $diamonds_divide;
|
|
|
+ UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $diamonds_divide, $value['spread_uid'], $value['brokerage_price'], '钻石会员200礼包提成');
|
|
|
+ }
|
|
|
+ $model->saveAll($diamonds_user);
|
|
|
+ }
|
|
|
+ }elseif ($product['id'] == 2){
|
|
|
+ //1991礼包 白银会员和黄金会员分百分之十的金额
|
|
|
+ $divide = $silver+$gold == 0? 0 : ($product['price'] * 0.1)/($silver+$gold);
|
|
|
+ $user = array_merge($silver_user, $gold_user);
|
|
|
+
|
|
|
+ $top_user = getParent($order['uid']); // 获取到上级所有钻石用户
|
|
|
+ $count = count($top_user);
|
|
|
+ if ($count > 0){
|
|
|
+ $top_divide = ($product['price'] * 0.2)/$count;//1991礼包百分之二十上级所有钻石会员平分
|
|
|
+ foreach ($top_user as $v){
|
|
|
+ $details = self::where('uid', $v)->find();
|
|
|
+ $details['brokerage_price'] += $top_divide;
|
|
|
+ $details->save();
|
|
|
+ UserBill::income('佣金', $details['uid'], 'now_money', 'brokerage', $top_divide, $details['spread_uid'], $details['brokerage_price'], '钻石会员1991礼包销售额20%分红');
|
|
|
|
|
|
- }elseif ($value['level'] == 2){
|
|
|
- if ($value['brokerage_price']+$divide > 6000){
|
|
|
- $max = 6000 - $value['brokerage_price']; // 到达上限
|
|
|
- $value['brokerage_price'] += 6000 - $value['brokerage_price'];
|
|
|
- UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $max, $value['spread_uid'], $value['brokerage_price'], '黄金会员1991礼包销售额分红,已达到上限');
|
|
|
- }else{
|
|
|
- $value['brokerage_price'] += $divide;
|
|
|
- UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $divide, $value['spread_uid'], $value['brokerage_price'], '黄金会员1991礼包销售额分红');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($user){
|
|
|
+ // 黄金会员和白银会员
|
|
|
+ foreach ($user as &$value){
|
|
|
+ if ($value['level'] == 1){
|
|
|
+ if ($value['brokerage_price']+$divide > 200){
|
|
|
+ $max = 200 - $value['brokerage_price'];
|
|
|
+ $value['brokerage_price'] += 200 - $value['brokerage_price'];
|
|
|
+ UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $max, $value['spread_uid'], $value['brokerage_price'], '白银会员1991礼包销售额分红,已达到上限');
|
|
|
+ }else{
|
|
|
+ $value['brokerage_price'] += $divide;
|
|
|
+ UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $divide, $value['spread_uid'], $value['brokerage_price'], '白银会员1991礼包销售额分红');
|
|
|
+ }
|
|
|
+
|
|
|
+ }elseif ($value['level'] == 2){
|
|
|
+ if ($value['brokerage_price']+$divide > 6000){
|
|
|
+ $max = 6000 - $value['brokerage_price']; // 到达上限
|
|
|
+ $value['brokerage_price'] += 6000 - $value['brokerage_price'];
|
|
|
+ UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $max, $value['spread_uid'], $value['brokerage_price'], '黄金会员1991礼包销售额分红,已达到上限');
|
|
|
+ }else{
|
|
|
+ $value['brokerage_price'] += $divide;
|
|
|
+ UserBill::income('佣金', $value['uid'], 'now_money', 'brokerage', $divide, $value['spread_uid'], $value['brokerage_price'], '黄金会员1991礼包销售额分红');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ $model->saveAll($user);
|
|
|
}
|
|
|
- $model->saveAll($user);
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -940,7 +943,9 @@ class User extends BaseModel
|
|
|
$s_user = getParents($uid);// 获取到上级所有黄金白银用户
|
|
|
$s_count = count($s_user);
|
|
|
foreach ($info as $item){
|
|
|
+ $cart_info = $item['cart_info'];
|
|
|
$product = StoreProduct::where('id', $item['product_id'])->find();
|
|
|
+ $product['price'] = $product['price'] * $cart_info['cart_num'];
|
|
|
if ($s_count > 0){
|
|
|
// 黄金白银会员分红
|
|
|
$divide = ($product['price'] * 0.1 )/ $s_count; // 普通商品百分之十的价格黄金和白银会员平分
|
|
@@ -1036,4 +1041,15 @@ class User extends BaseModel
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取ID
|
|
|
+ * @param $key
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public static function getkeytoid($key)
|
|
|
+ {
|
|
|
+ $rs = self::order('uid DESC')->find();
|
|
|
+ return $rs['uid']+1;
|
|
|
+ }
|
|
|
+
|
|
|
}
|