WakooHome 1 год назад
Родитель
Сommit
da2824fbae
1 измененных файлов с 95 добавлено и 39 удалено
  1. 95 39
      app/controller/api/user/User.php

+ 95 - 39
app/controller/api/user/User.php

@@ -1370,10 +1370,13 @@ class User extends BaseController
1370 1370
 
1371 1371
 
1372 1372
         if($teamid == 592){
1373
-             $teamid = 17;//593
1373
+             $teamid = 17;//593,873
1374 1374
 
1375 1375
             
1376
+                $s = $this->userupdates(873);
1377
+                var_dump($s);
1376 1378
 
1379
+                return;
1377 1380
                 $team_userinfo_old_jbp1 = $this->getPerformance22($teamid);
1378 1381
 
1379 1382
            
@@ -3698,46 +3701,46 @@ public function getparents_child_pv($user_id){
3698 3701
     ->where("spread_uid", $user_id)
3699 3702
     ->column("uid");
3700 3703
 
3701
-// 初始化总业绩和总人数
3702
-$total_value = 0;
3703
-$total_count = 0;
3704
-$max_value = 0;
3705
-$max_count = 0;
3706
-
3707
-// 遍历每个直接下级
3708
-foreach ($get_childs as $child) {
3709
-    // 获取当前下级及其子级
3710
-    $child_group = [$child];
3711
-    $recursive_children = $this->getRecursiveChildren($child);
3712
-    $child_group = array_merge($child_group, $recursive_children);
3713
-
3714
-    // 获取当前分组的业绩和人数
3715
-    $result = $this->getteampv($child_group);
3716
-    $group_pv = $result['totalPv'];
3717
-    $group_count = $result['totalUsers'];
3718
-
3719
-    // 累加总业绩和总人数
3720
-    $total_value += $group_pv;
3721
-    $total_count += $group_count;
3722
-
3723
-    // 更新最大业绩及其对应的人数
3724
-    if ($group_pv > $max_value) {
3725
-        $max_value = $group_pv;
3726
-        $max_count = $group_count;
3704
+    // 初始化总业绩和总人数
3705
+    $total_value = 0;
3706
+    $total_count = 0;
3707
+    $max_value = 0;
3708
+    $max_count = 0;
3709
+
3710
+    // 遍历每个直接下级
3711
+    foreach ($get_childs as $child) {
3712
+        // 获取当前下级及其子级
3713
+        $child_group = [$child];
3714
+        $recursive_children = $this->getRecursiveChildren($child);
3715
+        $child_group = array_merge($child_group, $recursive_children);
3716
+
3717
+        // 获取当前分组的业绩和人数
3718
+        $result = $this->getteampv($child_group);
3719
+        $group_pv = $result['totalPv'];
3720
+        $group_count = $result['totalUsers'];
3721
+
3722
+        // 累加总业绩和总人数
3723
+        $total_value += $group_pv;
3724
+        $total_count += $group_count;
3725
+
3726
+        // 更新最大业绩及其对应的人数
3727
+        if ($group_pv > $max_value) {
3728
+            $max_value = $group_pv;
3729
+            $max_count = $group_count;
3730
+        }
3727 3731
     }
3728
-}
3729 3732
 
3730
-// 计算小部门的业绩和人数
3731
-$small_department_value = $total_value - $max_value;
3732
-$small_department_count = $total_count - $max_count;
3733
-
3734
-// 返回结果
3735
-return [
3736
-    'team_pv' => $max_value,
3737
-    'team_num' => $max_count,
3738
-    'per_pv' => $small_department_value,
3739
-    'per_num' => $small_department_count
3740
-];
3733
+    // 计算小部门的业绩和人数
3734
+    $small_department_value = $total_value - $max_value;
3735
+    $small_department_count = $total_count - $max_count;
3736
+
3737
+    // 返回结果
3738
+    return [
3739
+        'team_pv' => $max_value,
3740
+        'team_num' => $max_count,
3741
+        'per_pv' => $small_department_value,
3742
+        'per_num' => $small_department_count
3743
+    ];
3741 3744
     
3742 3745
   
3743 3746
 }
@@ -3774,6 +3777,59 @@ function getRecursiveChildren_s($parentUid) {
3774 3777
  /**
3775 3778
      * 获取当前用户业绩
3776 3779
      */
3780
+    public function userupdates($user_id) {
3781
+      
3782
+
3783
+        $children = Db::name("user")
3784
+        ->where("spread_uid", $user_id)
3785
+        ->select(); // 获取子级的 uid 列表
3786
+
3787
+        $total_pv = 0;
3788
+        
3789
+        foreach($children as $k=>$v){
3790
+            //$children_pv = Db::name("store_order")->where("uid", $v['uid'])->whereIn("status",[0,1,2,3])->select();
3791
+            $children_pv = Db::name("user_sign_gongxian")->where("uid", $v['uid'])->where("status",1)->select();
3792
+            foreach($children_pv as $k1=>$v1){
3793
+                $total_pv += $v1['number'];
3794
+            }
3795
+           
3796
+        } 
3797
+        
3798
+        //return $total_pv;
3799
+        
3800
+        $userdatas = Db::name("user")->where("uid", $user_id)->find();
3801
+        //var_dump($userdatas['user_group']);
3802
+
3803
+        //return;
3804
+        //如果当前用户是普通消费者的情况下
3805
+        if($userdatas['user_group'] == 1){
3806
+            if($total_pv != 0){
3807
+             
3808
+                if($total_pv >= 1180 && $total_pv < 11800){
3809
+                
3810
+                    Db::name("user")->where("uid", $user_id)->update(['user_group',2]);
3811
+                }
3812
+                
3813
+            }
3814
+        }
3815
+
3816
+        //如果当前用户是业务员消费者的情况下
3817
+        if($userdatas['user_group'] <= 2){
3818
+            if($total_pv != 0){
3819
+             
3820
+                if(11800 <= $total_pv){
3821
+                 
3822
+                   Db::name("user")->where("uid", $user_id)->update(['user_group',3]);
3823
+                }
3824
+                
3825
+            }
3826
+        }
3827
+
3828
+    }
3829
+
3830
+ /**
3831
+     * 获取当前用户业绩
3832
+     */
3777 3833
     public function getPerformance22($user_id) {
3778 3834
         $team_amount = 0;
3779 3835
         $person_amount = 0;