|
@@ -636,10 +636,9 @@ class UserController
|
|
|
// UserSingleAward::where('uid', $item['uid'])->dec('grant', $item['number'])->update();
|
|
|
// }
|
|
|
// halt(111);
|
|
|
- $start = strtotime('yesterday');
|
|
|
- $end = strtotime('today');
|
|
|
+ $start = strtotime('today');
|
|
|
+ $end = strtotime('tomorrow');
|
|
|
$money = StoreOrder::where('paid', 1)->whereBetweenTime('add_time', $start, $end)->where('is_explosion_order', 1)->sum('pay_price'); // 全网业绩
|
|
|
-
|
|
|
$userUid = User::where('level', 1)->column('uid');//当前是会员的用户
|
|
|
$userOrder = StoreOrder::where('paid', 1)->where('is_explosion_order', 1)->sum('total_num');
|
|
|
$partnerCount = User::where('level', '>=',2)->count();//合伙人总数
|
|
@@ -705,32 +704,70 @@ class UserController
|
|
|
$award = $model->where('uid', $vo['uid'])->where('status', 0)->select()->toArray();
|
|
|
if ($award) {
|
|
|
$bdjl = 0; // 爆单剩余奖励
|
|
|
+ $moneyjl = 0;//余额奖励
|
|
|
foreach ($award as &$item) {
|
|
|
+ $bs = $item['money'] /7000;
|
|
|
+ $brokerage = $bs * 4000;//该订单应改获得的佣金
|
|
|
$surplus = $item['money'] - $item['grant'];
|
|
|
- if ($jl > 0){
|
|
|
- if ($surplus < $jl) {
|
|
|
- $bdjl += $surplus;
|
|
|
- $jl -= $surplus;
|
|
|
- $item['status'] = 1;
|
|
|
- $item['grant'] = $item['money'];
|
|
|
- } else {
|
|
|
- $bdjl += $jl;
|
|
|
- $item['grant'] += $jl;
|
|
|
- $jl = 0;
|
|
|
+ if($jl > 0){
|
|
|
+ if ($item['grant'] < $brokerage){
|
|
|
+ if ($item['grant'] + $jl > $brokerage){
|
|
|
+ $bdjl += $brokerage - $item['grant'];//能够发放的佣金
|
|
|
+ $moneyjl += $jl - $bdjl;// 能够发放的余额
|
|
|
+ $item['grant'] += $jl;
|
|
|
+ $jl = 0;
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $bdjl = $jl;//能够发放的佣金
|
|
|
+ $item['grant'] += $jl;
|
|
|
+ $jl = 0;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if ($surplus < $jl){
|
|
|
+ $moneyjl += $surplus;
|
|
|
+ $jl -= $surplus;
|
|
|
+ $item['status'] = 1;
|
|
|
+ $item['grant'] = $item['money'];
|
|
|
+ }else{
|
|
|
+ $moneyjl += $jl;
|
|
|
+ $item['grant'] += $jl;
|
|
|
+ $jl = 0;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
+// $surplus = $item['money'] - $item['grant'];
|
|
|
+// if ($jl > 0){
|
|
|
+// if ($surplus < $jl) {
|
|
|
+// $bdjl += $surplus;
|
|
|
+// $jl -= $surplus;
|
|
|
+// $item['status'] = 1;
|
|
|
+// $item['grant'] = $item['money'];
|
|
|
+// } else {
|
|
|
+// $bdjl += $jl;
|
|
|
+// $item['grant'] += $jl;
|
|
|
+// $jl = 0;
|
|
|
+// }
|
|
|
+// }
|
|
|
$model->saveAll($award);
|
|
|
- UserBill::income('佣金', $vo['uid'], 'now_money', 'brokerage', $userjl, '', $vo['brokerage_price'] + $userjl, '会员分红');
|
|
|
- if ($vo['level'] == 3){
|
|
|
-// UserBill::income('佣金', $vo['uid'], 'now_money', 'brokerage', $partnerjl, '', $vo['brokerage_price'] + $bdjl, '合伙人分红');
|
|
|
- UserBill::income('佣金', $vo['uid'], 'now_money', 'brokerage', $shareholderjl, '', $vo['brokerage_price'] + $userjl+ $shareholderjl, '股东分红');
|
|
|
- }elseif ($vo['level'] == 4){
|
|
|
-// UserBill::income('佣金', $vo['uid'], 'now_money', 'brokerage', $partnerjl, '', $vo['brokerage_price'] + $bdjl, '合伙人分红');
|
|
|
- UserBill::income('佣金', $vo['uid'], 'now_money', 'brokerage', $shareholderjl, '', $vo['brokerage_price'] + $userjl + $shareholderjl, '股东分红');
|
|
|
- UserBill::income('佣金', $vo['uid'], 'now_money', 'brokerage', $directorjl, '', $vo['brokerage_price'] + $userjl + $shareholderjl + $directorjl, '董事分红');
|
|
|
+ $nowUser = User::where('uid', $vo['uid'])->find();
|
|
|
+ if ($bdjl > 0){
|
|
|
+ UserBill::income('佣金', $vo['uid'], 'now_money', 'brokerage', $userjl, '', $nowUser['brokerage_price'] + $bdjl, '会员分红');
|
|
|
+ if ($vo['level'] == 3){
|
|
|
+ UserBill::income('佣金', $vo['uid'], 'now_money', 'brokerage', $shareholderjl, '', $nowUser['brokerage_price'] + $bdjl, '股东分红');
|
|
|
+ }elseif ($vo['level'] == 4){
|
|
|
+ UserBill::income('佣金', $vo['uid'], 'now_money', 'brokerage', $shareholderjl, '', $nowUser['brokerage_price'] + $bdjl, '股东分红');
|
|
|
+ UserBill::income('佣金', $vo['uid'], 'now_money', 'brokerage', $directorjl, '', $nowUser['brokerage_price'] + $bdjl, '董事分红');
|
|
|
+ }
|
|
|
+ User::where('uid', $vo['uid'])->inc('brokerage_price', $bdjl)->update();
|
|
|
}
|
|
|
- User::where('uid', $vo['uid'])->inc('brokerage_price', $bdjl)->update();
|
|
|
+ if ($moneyjl > 0){
|
|
|
+ UserBill::income('余额', $vo['uid'], 'now_money', 'fhjl', $moneyjl, '', $nowUser['now_money']+$moneyjl, '分红余额奖励');
|
|
|
+ User::where('uid', $vo['uid'])->inc('now_money', $moneyjl)->update();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// if ($vo['level'] == 1){
|
|
|
// 如果是会员
|
|
@@ -741,24 +778,61 @@ class UserController
|
|
|
$award = $model->where('uid', $spread['uid'])->where('status', 0)->select()->toArray();
|
|
|
if ($award){
|
|
|
$bdjl = 0; // 爆单剩余奖励
|
|
|
+ $moneyjl = 0;//余额奖励
|
|
|
foreach ($award as &$item){
|
|
|
+ $bs = $item['money'] /7000;
|
|
|
+ $brokerage = $bs * 4000;//该订单应改获得的佣金
|
|
|
$surplus = $item['money'] - $item['grant'];
|
|
|
- if ($sp_jl > 0){
|
|
|
- if ($surplus < $sp_jl){
|
|
|
- $bdjl += $surplus;
|
|
|
- $sp_jl -= $surplus;
|
|
|
- $item['status'] = 1;
|
|
|
- $item['grant'] = $item['money'];
|
|
|
+ if($sp_jl > 0){
|
|
|
+ if ($item['grant'] < $brokerage){
|
|
|
+ if ($item['grant'] + $sp_jl > $brokerage){
|
|
|
+ $bdjl += $brokerage - $item['grant'];//能够发放的佣金
|
|
|
+ $moneyjl += $sp_jl - $bdjl;// 能够发放的余额
|
|
|
+ $item['grant'] += $sp_jl;
|
|
|
+ $sp_jl = 0;
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $bdjl = $sp_jl;//能够发放的佣金
|
|
|
+ $item['grant'] += $sp_jl;
|
|
|
+ $sp_jl = 0;
|
|
|
+ }
|
|
|
}else{
|
|
|
- $bdjl += $sp_jl;
|
|
|
- $item['grant'] += $sp_jl;
|
|
|
- $sp_jl = 0;
|
|
|
+ if ($surplus < $sp_jl){
|
|
|
+ $moneyjl += $surplus;
|
|
|
+ $sp_jl -= $surplus;
|
|
|
+ $item['status'] = 1;
|
|
|
+ $item['grant'] = $item['money'];
|
|
|
+ }else{
|
|
|
+ $moneyjl += $sp_jl;
|
|
|
+ $item['grant'] += $sp_jl;
|
|
|
+ $sp_jl = 0;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
+// if ($sp_jl > 0){
|
|
|
+// if ($surplus < $sp_jl){
|
|
|
+// $bdjl += $surplus;
|
|
|
+// $sp_jl -= $surplus;
|
|
|
+// $item['status'] = 1;
|
|
|
+// $item['grant'] = $item['money'];
|
|
|
+// }else{
|
|
|
+// $bdjl += $sp_jl;
|
|
|
+// $item['grant'] += $sp_jl;
|
|
|
+// $sp_jl = 0;
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
$model->saveAll($award);
|
|
|
- UserBill::income('佣金', $spread['uid'], 'now_money', 'brokerage', $userjl, '', $spread['brokerage_price']+$userjl, '合伙人分红');
|
|
|
- User::where('uid', $spread['uid'])->inc('brokerage_price', $bdjl)->update();
|
|
|
+ if ($bdjl > 0){
|
|
|
+ UserBill::income('佣金', $spread['uid'], 'now_money', 'brokerage', $bdjl, '', $spread['brokerage_price']+$bdjl, '合伙人分红');
|
|
|
+ User::where('uid', $spread['uid'])->inc('brokerage_price', $bdjl)->update();
|
|
|
+ }
|
|
|
+ if ($moneyjl > 0){
|
|
|
+ UserBill::income('余额', $spread['uid'], 'now_money', 'fhjl', $moneyjl, '', $spread['now_money']+$moneyjl, '合伙人余额奖励');
|
|
|
+ User::where('uid', $spread['uid'])->inc('now_money', $moneyjl)->update();
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
// }
|