|
|
@@ -1370,9 +1370,9 @@ class StoreOrderRepository extends BaseRepository
|
|
|
// if ($spread['spread_uid']>0){ //
|
|
|
// $this->getSpreadIntegral($order, $type,$spread);
|
|
|
// }
|
|
|
- if ($type == 5){
|
|
|
+ if ($type == 5) {
|
|
|
$this->team_rewards($order, 1); //分发节能油团队奖励
|
|
|
- }elseif ($type == 6){
|
|
|
+ } elseif ($type == 6) {
|
|
|
$this->team_rewards($order, 2); //分发礼包团队奖励
|
|
|
}
|
|
|
|
|
|
@@ -1446,12 +1446,12 @@ class StoreOrderRepository extends BaseRepository
|
|
|
try {
|
|
|
$user_spread_group = $this->get_spread_user($order['uid']); //获取所有上级id
|
|
|
$group_info = User::where('uid', 'in', $user_spread_group)->column('uid,nickname,brokerage_price,award_integral,award_range,oil_level,gift_level'); //获取所有上级信息
|
|
|
- if ($type == 1){
|
|
|
+ if ($type == 1) {
|
|
|
$model = new OilLevel();
|
|
|
$field = 'oil_level';
|
|
|
$product_type = 1;
|
|
|
$title = '节能油团队奖励';
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$model = new GiftLevel();
|
|
|
$field = 'gift_level';
|
|
|
$product_type = 2;
|
|
|
@@ -1471,13 +1471,13 @@ class StoreOrderRepository extends BaseRepository
|
|
|
// break;
|
|
|
|
|
|
$level = $model->where('award_ratio', '>', 0)->select();
|
|
|
- $price = bcmul($order['pay_price'],0.1,2); //分红金额
|
|
|
+ $price = bcmul($order['pay_price'], 0.1, 2); //分红金额
|
|
|
$integral_price = app()->make(AwardIntegralPriceRepository::class)->awardIntegralPrice(); //分红积分价格
|
|
|
foreach ($level as $k => $v) { //遍历等级
|
|
|
$all_performance = 0; //总业绩
|
|
|
$ratio = $v['award_ratio']; //奖励比例
|
|
|
$level_price = bcmul($price, $ratio, 2); //等级奖励金额
|
|
|
- @file_put_contents('quanju.txt', "------------------------------------------\r\n", 8);
|
|
|
+ @file_put_contents('quanju.txt', "------------------------------------------\r\n", 8);
|
|
|
@file_put_contents('quanju.txt', json_encode($v) . "-团队奖励等级信息\r\n", 8);
|
|
|
@file_put_contents('quanju.txt', $level_price . "-团队奖励等级奖励金额\r\n", 8);
|
|
|
foreach ($group_info as &$value) { //遍历上级统计总业绩
|
|
|
@@ -1486,8 +1486,8 @@ class StoreOrderRepository extends BaseRepository
|
|
|
$GiftLevel = app()->make(GiftLevel::class);
|
|
|
$group_users = $GiftLevel->get_group_user($value['uid']); //获取上级的用户和总业绩
|
|
|
|
|
|
- $achievement1 = StoreOrder::where('uid','in', $group_users)->where('paid', 1)->where('product_type',$product_type)->whereNotIn('status',-1)->sum('pay_price');
|
|
|
- $achievement2 = StoreOrder::where('uid', $value['uid'])->where('paid', 1)->where('product_type',$product_type)->whereNotIn('status',-1)->sum('pay_price');
|
|
|
+ $achievement1 = StoreOrder::where('uid', 'in', $group_users)->where('paid', 1)->where('product_type', $product_type)->whereNotIn('status', -1)->sum('pay_price');
|
|
|
+ $achievement2 = StoreOrder::where('uid', $value['uid'])->where('paid', 1)->where('product_type', $product_type)->whereNotIn('status', -1)->sum('pay_price');
|
|
|
$performance = bcadd($achievement1, $achievement2, 2);
|
|
|
$value['performance'] = $performance;
|
|
|
$all_performance = bcadd($all_performance, $performance, 2);
|
|
|
@@ -1495,24 +1495,26 @@ class StoreOrderRepository extends BaseRepository
|
|
|
}
|
|
|
@file_put_contents('quanju.txt', $all_performance . "-团队奖励所有人总业绩\r\n", 8);
|
|
|
foreach ($group_info as &$value) { //遍历上级分红
|
|
|
- $user_retio = bcdiv($value['performance'], $all_performance, 2); //用户奖励比例
|
|
|
- @file_put_contents('quanju.txt', $value['uid'] . "-团队奖励分红uid\r\n", 8);
|
|
|
- @file_put_contents('quanju.txt', $user_retio . "-团队奖励业绩分红比例\r\n", 8);
|
|
|
- @file_put_contents('quanju.txt', $value['performance'] . "-团队奖励个人业绩\r\n", 8);
|
|
|
- $user_reward = bcmul($level_price, $user_retio, 2); //用户奖励金额
|
|
|
- $user_integral = bcdiv($user_reward, $integral_price['price'], 2); //用户奖励积分
|
|
|
- $after = bcadd($value['award_integral'], $user_integral, 2); //更新用户奖励积分
|
|
|
- $make = app()->make(UserBillRepository::class);
|
|
|
- if ($user_integral>0){
|
|
|
- $make->incBill($value['uid'], 'award_integral', 'oil_integral', [
|
|
|
- 'number' => $user_integral,
|
|
|
- 'title' => $title,
|
|
|
- 'balance' => $after,
|
|
|
- 'status' => 1,
|
|
|
- 'link_id' => $order['order_id'],
|
|
|
- 'mark' => $value['nickname'] . '获得'.$v['name'].'等级的分红积分'.$user_integral ,
|
|
|
- ]);
|
|
|
- User::where('uid', $value['uid'])->update(['award_integral' => $after]);
|
|
|
+ if ($value[$field] >= $v['grade']) {
|
|
|
+ $user_retio = bcdiv($value['performance'], $all_performance, 2); //用户奖励比例
|
|
|
+ @file_put_contents('quanju.txt', $value['uid'] . "-团队奖励分红uid\r\n", 8);
|
|
|
+ @file_put_contents('quanju.txt', $user_retio . "-团队奖励业绩分红比例\r\n", 8);
|
|
|
+ @file_put_contents('quanju.txt', $value['performance'] . "-团队奖励个人业绩\r\n", 8);
|
|
|
+ $user_reward = bcmul($level_price, $user_retio, 2); //用户奖励金额
|
|
|
+ $user_integral = bcdiv($user_reward, $integral_price['price'], 2); //用户奖励积分
|
|
|
+ $after = bcadd($value['award_integral'], $user_integral, 2); //更新用户奖励积分
|
|
|
+ $make = app()->make(UserBillRepository::class);
|
|
|
+ if ($user_integral > 0) {
|
|
|
+ $make->incBill($value['uid'], 'award_integral', 'oil_integral', [
|
|
|
+ 'number' => $user_integral,
|
|
|
+ 'title' => $title,
|
|
|
+ 'balance' => $after,
|
|
|
+ 'status' => 1,
|
|
|
+ 'link_id' => $order['order_id'],
|
|
|
+ 'mark' => $value['nickname'] . '获得' . $v['name'] . '等级的分红积分' . $user_integral,
|
|
|
+ ]);
|
|
|
+ User::where('uid', $value['uid'])->update(['award_integral' => $after]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|