|
|
@@ -1370,11 +1370,11 @@ class User extends BaseController
|
|
1370
|
1370
|
|
|
1371
|
1371
|
|
|
1372
|
1372
|
if($teamid == 592){
|
|
1373
|
|
- $teamid = 593;//593
|
|
|
1373
|
+ $teamid = 17;//593
|
|
1374
|
1374
|
|
|
1375
|
1375
|
|
|
1376
|
1376
|
|
|
1377
|
|
- $team_userinfo_old_jbp1 = $this->getPerformance($teamid);
|
|
|
1377
|
+ $team_userinfo_old_jbp1 = $this->getPerformance22($teamid);
|
|
1378
|
1378
|
|
|
1379
|
1379
|
|
|
1380
|
1380
|
var_dump($team_userinfo_old_jbp1);return;
|
|
|
@@ -3526,45 +3526,37 @@ public function getNewTeamPv($common_nums) {
|
|
3526
|
3526
|
public function getteampv($common_nums) {
|
|
3527
|
3527
|
|
|
3528
|
3528
|
|
|
3529
|
|
- // 查询当前用户及其子级的所有订单
|
|
3530
|
|
- $orders = Db::name("store_order")
|
|
3531
|
|
- ->whereIn('status', [0, 1, 2, 3])
|
|
3532
|
|
- ->whereIn("uid", $common_nums)
|
|
3533
|
|
- ->whereIn("total_price", [1180, 11800, 10620, 2360, 9440])
|
|
3534
|
|
- ->select();
|
|
3535
|
|
-
|
|
3536
|
|
- // 计算总业绩
|
|
3537
|
|
- $totalPv = 0;
|
|
3538
|
|
- foreach ($orders as $order) {
|
|
3539
|
|
-
|
|
3540
|
|
- // var_dump($order['uid']."订单:".$order['total_price']);
|
|
3541
|
|
- if ($order['total_price'] == 1180) {
|
|
3542
|
|
- $totalPv += 700;
|
|
3543
|
|
- } else if ($order['total_price'] == 11800) {
|
|
3544
|
|
- $totalPv += 7000;
|
|
3545
|
|
- } else if ($order['total_price'] == 10620) {
|
|
3546
|
|
- $totalPv += 6300;
|
|
3547
|
|
- } else if ($order['total_price'] == 2360) {
|
|
3548
|
|
- $totalPv += 1400;
|
|
3549
|
|
- } else if ($order['total_price'] == 9440) {
|
|
3550
|
|
- $totalPv += 5600;
|
|
3551
|
|
- }
|
|
3552
|
|
- }
|
|
3553
|
|
-
|
|
3554
|
|
- //除了会员专区的其他区所有订单产生的业绩汇总在user表中的pv中
|
|
3555
|
|
- // $user_datas = Db::name("user")
|
|
3556
|
|
-
|
|
3557
|
|
- // ->whereIn("uid", $common_nums)
|
|
3558
|
|
-
|
|
3559
|
|
- // ->select();
|
|
|
3529
|
+ // 查询当前用户及其子级的所有订单
|
|
|
3530
|
+ $orders = Db::name("store_order")
|
|
|
3531
|
+ ->whereIn('status', [0, 1, 2, 3])
|
|
|
3532
|
+ ->whereIn("uid", $common_nums)
|
|
|
3533
|
+ ->whereIn("total_price", [1180, 11800, 10620, 2360, 9440])
|
|
|
3534
|
+ ->select();
|
|
3560
|
3535
|
|
|
3561
|
|
- // foreach ($user_datas as $v) {
|
|
3562
|
|
- // $totalPv += $v['pv'];
|
|
3563
|
|
- // }
|
|
|
3536
|
+ // 初始化业绩和人数
|
|
|
3537
|
+ $totalPv = 0;
|
|
|
3538
|
+ $totalUsers = count($common_nums); // 初始化人数为子级总数
|
|
3564
|
3539
|
|
|
3565
|
|
-
|
|
|
3540
|
+ // 遍历订单计算业绩
|
|
|
3541
|
+ foreach ($orders as $order) {
|
|
|
3542
|
+ if ($order['total_price'] == 1180) {
|
|
|
3543
|
+ $totalPv += 700;
|
|
|
3544
|
+ } else if ($order['total_price'] == 11800) {
|
|
|
3545
|
+ $totalPv += 7000;
|
|
|
3546
|
+ } else if ($order['total_price'] == 10620) {
|
|
|
3547
|
+ $totalPv += 6300;
|
|
|
3548
|
+ } else if ($order['total_price'] == 2360) {
|
|
|
3549
|
+ $totalPv += 1400;
|
|
|
3550
|
+ } else if ($order['total_price'] == 9440) {
|
|
|
3551
|
+ $totalPv += 5600;
|
|
|
3552
|
+ }
|
|
|
3553
|
+ }
|
|
3566
|
3554
|
|
|
3567
|
|
- return $totalPv;
|
|
|
3555
|
+ // 返回业绩和人数
|
|
|
3556
|
+ return [
|
|
|
3557
|
+ 'totalPv' => $totalPv,
|
|
|
3558
|
+ 'totalUsers' => $totalUsers
|
|
|
3559
|
+ ];
|
|
3568
|
3560
|
}
|
|
3569
|
3561
|
|
|
3570
|
3562
|
// 递归获取所有子级 UID 的业绩
|
|
|
@@ -3698,6 +3690,406 @@ public function processArray($array) {
|
|
3698
|
3690
|
return $result;
|
|
3699
|
3691
|
}
|
|
3700
|
3692
|
|
|
|
3693
|
+
|
|
|
3694
|
+//获取当前uesr_id下面在2.0中是否还有直接下级,并计算她的大部门和小部门
|
|
|
3695
|
+public function getparents_child_pv($user_id){
|
|
|
3696
|
+ // 获取直接下级的 UID 列表
|
|
|
3697
|
+ $get_childs = Db::name("user")
|
|
|
3698
|
+ ->where("spread_uid", $user_id)
|
|
|
3699
|
+ ->column("uid");
|
|
|
3700
|
+
|
|
|
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;
|
|
|
3727
|
+ }
|
|
|
3728
|
+}
|
|
|
3729
|
+
|
|
|
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
|
+];
|
|
|
3741
|
+
|
|
|
3742
|
+
|
|
|
3743
|
+}
|
|
|
3744
|
+
|
|
|
3745
|
+//根据父级IDS获取伞下的所有子级ID
|
|
|
3746
|
+function getRecursiveChildren_s($parentUid) {
|
|
|
3747
|
+ $result = []; // 用于存储所有子级的 uid
|
|
|
3748
|
+
|
|
|
3749
|
+ // 定义递归函数
|
|
|
3750
|
+ $recursion = function ($currentUid) use (&$result, &$recursion) {
|
|
|
3751
|
+ // 查询当前父级的所有直接子级
|
|
|
3752
|
+ $children = Db::name("user")
|
|
|
3753
|
+ ->where("spread_uid", $currentUid)
|
|
|
3754
|
+ ->column("uid"); // 获取子级的 uid 列表
|
|
|
3755
|
+
|
|
|
3756
|
+ // 如果没有子级,直接返回
|
|
|
3757
|
+ if (empty($children)) {
|
|
|
3758
|
+ return;
|
|
|
3759
|
+ }
|
|
|
3760
|
+
|
|
|
3761
|
+ // 遍历每个子级
|
|
|
3762
|
+ foreach ($children as $childUid) {
|
|
|
3763
|
+ $result[] = $childUid; // 将子级的 uid 添加到结果数组
|
|
|
3764
|
+ $recursion($childUid); // 递归查询子级的子级
|
|
|
3765
|
+ }
|
|
|
3766
|
+ };
|
|
|
3767
|
+
|
|
|
3768
|
+ // 从初始父级开始递归查询
|
|
|
3769
|
+ $recursion($parentUid);
|
|
|
3770
|
+
|
|
|
3771
|
+ return array_unique($result); // 返回结果数组,并去重
|
|
|
3772
|
+}
|
|
|
3773
|
+
|
|
|
3774
|
+ /**
|
|
|
3775
|
+ * 获取当前用户业绩
|
|
|
3776
|
+ */
|
|
|
3777
|
+ public function getPerformance22($user_id) {
|
|
|
3778
|
+ $team_amount = 0;
|
|
|
3779
|
+ $person_amount = 0;
|
|
|
3780
|
+ //$user_id = 17;
|
|
|
3781
|
+
|
|
|
3782
|
+ $result_big_team_arr = [];
|
|
|
3783
|
+ $get_teams_comm_datas = [];//在2.0中获取父级下面的所有团队数据
|
|
|
3784
|
+ //共建联盟业绩 个人联盟业绩 共建联盟总pv 个人联盟业绩pv
|
|
|
3785
|
+ $common_nums = $this->getCommonNums($user_id);
|
|
|
3786
|
+
|
|
|
3787
|
+ //var_dump($common_nums);
|
|
|
3788
|
+ $get_teams_comm_num = 0;
|
|
|
3789
|
+ $get_teams_comm_pv = 0;
|
|
|
3790
|
+
|
|
|
3791
|
+ $get_teams_per_num = 0;//小部门人数
|
|
|
3792
|
+ //1.0系统中有下级,需要在2.0中再加下级数据
|
|
|
3793
|
+ if($user_id < 611){
|
|
|
3794
|
+ //梅红在2.0中的ID是780
|
|
|
3795
|
+
|
|
|
3796
|
+
|
|
|
3797
|
+ //用户三峡所有在2.0系统下面的业绩和人数 start
|
|
|
3798
|
+ $child_nums = [];
|
|
|
3799
|
+
|
|
|
3800
|
+ //获取当前用户
|
|
|
3801
|
+ foreach($common_nums as $v){
|
|
|
3802
|
+ $child_nums[] = $this->getRecursiveChildren($v);
|
|
|
3803
|
+ }
|
|
|
3804
|
+
|
|
|
3805
|
+
|
|
|
3806
|
+
|
|
|
3807
|
+ //去除空数组,并重新组合有数据的数组
|
|
|
3808
|
+ $filteredData = array_filter($child_nums, function($array) {
|
|
|
3809
|
+ return !empty($array); // 如果数组不为空,则保留
|
|
|
3810
|
+ });
|
|
|
3811
|
+
|
|
|
3812
|
+ // 合并所有非空数组
|
|
|
3813
|
+
|
|
|
3814
|
+ foreach ($filteredData as $array) {
|
|
|
3815
|
+ $result_big_team_arr = array_merge($result_big_team_arr, $array);
|
|
|
3816
|
+ }
|
|
|
3817
|
+ //var_dump($result_big_team_arr);
|
|
|
3818
|
+ //获取当前用户下面在2.0中的下级所有PV
|
|
|
3819
|
+ //$get_teams_comm_pv = $this->getteampv($result_big_team_arr);
|
|
|
3820
|
+ $t_pv = $this->getteampv($result_big_team_arr);
|
|
|
3821
|
+ $get_teams_comm_pv =$t_pv['totalPv'];
|
|
|
3822
|
+ //var_dump($get_teams_comm_pv);
|
|
|
3823
|
+
|
|
|
3824
|
+ //获取当前用户下面在2.0中的下级所有人数
|
|
|
3825
|
+ $get_teams_comm_num = count($result_big_team_arr);
|
|
|
3826
|
+
|
|
|
3827
|
+ //用户伞下小部门所有在2.0系统下面的业绩和人数 end
|
|
|
3828
|
+ }else{
|
|
|
3829
|
+
|
|
|
3830
|
+ //当前用户在1.0没有下级,那直接在新系统2.0找下级获取数据,并区分大小部门
|
|
|
3831
|
+ $child_nums = $this->getChildren($user_id);
|
|
|
3832
|
+
|
|
|
3833
|
+ //获取父级子级下面的个人
|
|
|
3834
|
+ $num_teams = $this->getTeamSize($child_nums);
|
|
|
3835
|
+
|
|
|
3836
|
+
|
|
|
3837
|
+ foreach($child_nums as $v){
|
|
|
3838
|
+
|
|
|
3839
|
+ $get_teams_comm_datas[] = $this->getTeamPv11($v);//如果有多个父级ID,需要获取他们伞下的子级,所有的业绩进行
|
|
|
3840
|
+ }
|
|
|
3841
|
+
|
|
|
3842
|
+ //$s = $this->getparents_child_pv($user_id);
|
|
|
3843
|
+
|
|
|
3844
|
+ //var_dump($get_teams_comm_datas);
|
|
|
3845
|
+ //如果只有一个部门,就是默认大部门
|
|
|
3846
|
+ if( count($get_teams_comm_datas) ==1 ){
|
|
|
3847
|
+
|
|
|
3848
|
+ $get_teams_comm_pv =$get_teams_comm_datas[0];
|
|
|
3849
|
+ $get_teams_comm_num = $num_teams[0]['total_count'];
|
|
|
3850
|
+
|
|
|
3851
|
+ }else if(count($get_teams_comm_datas) >1){
|
|
|
3852
|
+
|
|
|
3853
|
+ // var_dump( $get_teams_comm_datas);
|
|
|
3854
|
+ //获取一个最大值,设为大部门,其他的加载一块是小部门
|
|
|
3855
|
+ $getss = $this->processArray($get_teams_comm_datas);
|
|
|
3856
|
+
|
|
|
3857
|
+ $max_value_count = $num_teams[$getss['max_index']]['total_count'];
|
|
|
3858
|
+
|
|
|
3859
|
+ unset($num_teams[$getss['max_index']]);
|
|
|
3860
|
+
|
|
|
3861
|
+ //获取小部门的人数
|
|
|
3862
|
+ $per_num = 0;
|
|
|
3863
|
+ foreach($num_teams as $k=>$v){
|
|
|
3864
|
+ $per_num +=$v['total_count'];
|
|
|
3865
|
+ }
|
|
|
3866
|
+
|
|
|
3867
|
+ //找到最大值的(大部门)
|
|
|
3868
|
+ $get_teams_comm_num = $max_value_count;
|
|
|
3869
|
+ //小部门的数量
|
|
|
3870
|
+ $get_teams_per_num = $per_num;
|
|
|
3871
|
+ //var_dump($getss['max_value']);
|
|
|
3872
|
+ $person_amount = $getss['remaining_sum'];
|
|
|
3873
|
+ $get_teams_comm_pv = $getss['max_value'];
|
|
|
3874
|
+ }
|
|
|
3875
|
+
|
|
|
3876
|
+
|
|
|
3877
|
+ }
|
|
|
3878
|
+
|
|
|
3879
|
+ //合并业绩和人数
|
|
|
3880
|
+ $team_amount += $get_teams_comm_pv;
|
|
|
3881
|
+
|
|
|
3882
|
+ //var_dump($team_amount);
|
|
|
3883
|
+ //1.0获取小区业绩
|
|
|
3884
|
+ $person_nums = $this->getPersonageNums($user_id);
|
|
|
3885
|
+ // var_dump($person_nums);
|
|
|
3886
|
+ $result_small_team_arr = [];
|
|
|
3887
|
+ //1.0系统中有下级,需要在2.0中再加下级数据
|
|
|
3888
|
+
|
|
|
3889
|
+
|
|
|
3890
|
+
|
|
|
3891
|
+ //用户三峡所有在2.0系统下面的业绩和人数 start
|
|
|
3892
|
+ $child_nums_mix = [];
|
|
|
3893
|
+
|
|
|
3894
|
+ //获取当前用户
|
|
|
3895
|
+ foreach($person_nums as $v){
|
|
|
3896
|
+ $child_nums_mix[] = $this->getRecursiveChildren($v);
|
|
|
3897
|
+ }
|
|
|
3898
|
+
|
|
|
3899
|
+ //去除空数组,并重新组合有数据的数组
|
|
|
3900
|
+ $filteredData_1 = array_filter($child_nums_mix, function($array) {
|
|
|
3901
|
+ return !empty($array); // 如果数组不为空,则保留
|
|
|
3902
|
+ });
|
|
|
3903
|
+
|
|
|
3904
|
+ // 合并所有非空数组
|
|
|
3905
|
+ $result_small_team_arr = [];
|
|
|
3906
|
+ foreach ($filteredData_1 as $array) {
|
|
|
3907
|
+ $result_small_team_arr = array_merge($result_small_team_arr, $array);
|
|
|
3908
|
+ }
|
|
|
3909
|
+
|
|
|
3910
|
+
|
|
|
3911
|
+ //var_dump($result_small_team_arr);
|
|
|
3912
|
+ //获取当前用户下面在2.0中的下级所有PV
|
|
|
3913
|
+ // $get_teams_per_pv = $this->getteampv($result_small_team_arr);
|
|
|
3914
|
+ $t_pv = $this->getteampv($result_small_team_arr);
|
|
|
3915
|
+ $get_teams_per_pv =$t_pv['totalPv'];
|
|
|
3916
|
+ //var_dump( $get_teams_per_pv);
|
|
|
3917
|
+
|
|
|
3918
|
+
|
|
|
3919
|
+
|
|
|
3920
|
+
|
|
|
3921
|
+ //获取当前用户下面在2.0中的下级所有人数
|
|
|
3922
|
+ $get_teams_per_num += count($result_small_team_arr);
|
|
|
3923
|
+ //合并业绩和人数
|
|
|
3924
|
+ $person_amount += $get_teams_per_pv;
|
|
|
3925
|
+
|
|
|
3926
|
+
|
|
|
3927
|
+ // if($user_id == 593){
|
|
|
3928
|
+ // $person_amount = 2800;
|
|
|
3929
|
+
|
|
|
3930
|
+ // }
|
|
|
3931
|
+
|
|
|
3932
|
+ //var_dump($person_amount);
|
|
|
3933
|
+ //用户小部门所有在2.0系统下面的业绩和人数 end
|
|
|
3934
|
+
|
|
|
3935
|
+
|
|
|
3936
|
+ // $common_nums[] = $user_id;
|
|
|
3937
|
+ foreach ($common_nums as $key => $value) {
|
|
|
3938
|
+ # code...
|
|
|
3939
|
+ $amount = $this->getPerformance1($value);
|
|
|
3940
|
+ $team_amount += $amount;
|
|
|
3941
|
+ }
|
|
|
3942
|
+ foreach ($person_nums as $key => $value) {
|
|
|
3943
|
+ # code...
|
|
|
3944
|
+ $amount = $this->getPerformance1($value);
|
|
|
3945
|
+ $person_amount += $amount;
|
|
|
3946
|
+ }
|
|
|
3947
|
+ //var_dump($team_amount);
|
|
|
3948
|
+
|
|
|
3949
|
+ //
|
|
|
3950
|
+
|
|
|
3951
|
+ if($user_id < 611){
|
|
|
3952
|
+
|
|
|
3953
|
+ //获取当前用户直属下级(查询在2.0中直接推荐人和伞下的业绩。并比对大小部门)
|
|
|
3954
|
+ //例子:17所有下面uid是speard_uid都是17的,和所有伞下的业绩。分出大小部门,加到1.0的大小部门中
|
|
|
3955
|
+ $b_s = $this->getparents_child_pv($user_id);
|
|
|
3956
|
+
|
|
|
3957
|
+ //var_dump( $b_s);echo "yyyyyyyyyyyyy";
|
|
|
3958
|
+ $team_amount += $b_s['team_pv'];
|
|
|
3959
|
+ $get_teams_comm_num += $b_s['team_num'];
|
|
|
3960
|
+
|
|
|
3961
|
+
|
|
|
3962
|
+ $person_amount += $b_s['per_pv'];
|
|
|
3963
|
+
|
|
|
3964
|
+ $get_teams_per_num += $b_s['per_num'];//小部门人数
|
|
|
3965
|
+ //var_dump( $b_s['team_num'],$b_s['per_num']);
|
|
|
3966
|
+ }
|
|
|
3967
|
+
|
|
|
3968
|
+
|
|
|
3969
|
+
|
|
|
3970
|
+ $user_team_amount = Db::name("old_user_of_goods")->whereIn("user_id",$common_nums)->where("node_id",$user_id)->where('money', 1180)->select();
|
|
|
3971
|
+
|
|
|
3972
|
+ //$money1180Records = $this->old_user_of_goods->where('status', 1)->where('money', 1180)->select();
|
|
|
3973
|
+// 计算 status 为 1 且 money 为 1180 的记录总和(减去相应值后)
|
|
|
3974
|
+ $money1180Sum = 0;
|
|
|
3975
|
+ foreach ($user_team_amount as $record) {
|
|
|
3976
|
+ $money1180Sum += $record['money'] - 300 - 180;
|
|
|
3977
|
+ }
|
|
|
3978
|
+
|
|
|
3979
|
+// 获取 status 为 1 且 money 为 11800 的记录集合
|
|
|
3980
|
+
|
|
|
3981
|
+ $money11800Records = Db::name("old_user_of_goods")->whereIn("user_id",$common_nums)->where("node_id",$user_id)->where('money', 11800)->select();
|
|
|
3982
|
+
|
|
|
3983
|
+// 计算 status 为 1 且 money 为 11800 的记录总和(减去相应值后)
|
|
|
3984
|
+ $money11800Sum = 0;
|
|
|
3985
|
+ foreach ($money11800Records as $record) {
|
|
|
3986
|
+ $money11800Sum += $record['money'] - 3000 - 1800;
|
|
|
3987
|
+ }
|
|
|
3988
|
+
|
|
|
3989
|
+ $money10620Records = Db::name("old_user_of_goods")->whereIn("user_id",$common_nums)->where("node_id",$user_id)->where('money', 10620)->select();
|
|
|
3990
|
+
|
|
|
3991
|
+// 计算 status 为 1 且 money 为 11800 的记录总和(减去相应值后)
|
|
|
3992
|
+ $money10620Sum = 0;
|
|
|
3993
|
+ foreach ($money10620Records as $record) {
|
|
|
3994
|
+ $money10620Sum += $record['money'] - 2700 - 1620;
|
|
|
3995
|
+ }
|
|
|
3996
|
+
|
|
|
3997
|
+// 计算除去特定值后的总和
|
|
|
3998
|
+//$otherMoneyRecords = $this->old_user_of_goods->where('status', 1)->whereNotIn('money', [1180, 11800])->select();
|
|
|
3999
|
+ $otherMoneyRecords = Db::name("old_user_of_goods")->whereIn("user_id",$common_nums)->where("node_id",$user_id)->whereNotIn('money', [1180, 11800 ,10620])->select();
|
|
|
4000
|
+ $otherMoneySum = 0;
|
|
|
4001
|
+ foreach ($otherMoneyRecords as $record) {
|
|
|
4002
|
+ $otherMoneySum += $record['money'];
|
|
|
4003
|
+ }
|
|
|
4004
|
+
|
|
|
4005
|
+
|
|
|
4006
|
+// 分别处理特定值的情况并加上其他值的总和
|
|
|
4007
|
+ $all_record_nums = $money1180Sum + $money11800Sum + $money10620Sum + round($otherMoneySum * 0.7,2);
|
|
|
4008
|
+ // var_dump($all_record_nums);
|
|
|
4009
|
+ $team_amount += $all_record_nums;
|
|
|
4010
|
+ // var_dump($user_team_amount);
|
|
|
4011
|
+ //计算自己的个人联盟总流水
|
|
|
4012
|
+
|
|
|
4013
|
+ // // //计算自己的个人联盟总流水
|
|
|
4014
|
+ // $user_person_amount = Db::name("old_user_of_goods")->whereIn("user_id",$person_nums)->where("node_id",$user_id)->where('status',1)->sum("money");
|
|
|
4015
|
+ // $user_person_amount = empty($user_person_amount) ? 0 : round($user_person_amount * 0.7,2);
|
|
|
4016
|
+ // $person_amount += $user_person_amount;
|
|
|
4017
|
+ //计算个人的1180单价的业绩 集合
|
|
|
4018
|
+ $money1180Records = Db::name("old_user_of_goods")->whereIn("user_id",$person_nums)->where("node_id",$user_id)->where("money",1180)->select();
|
|
|
4019
|
+
|
|
|
4020
|
+ $money1180Sum = 0;
|
|
|
4021
|
+
|
|
|
4022
|
+ foreach ($money1180Records as $record) {
|
|
|
4023
|
+ $money1180Sum += $record['money'] - 300 - 180;
|
|
|
4024
|
+ }
|
|
|
4025
|
+
|
|
|
4026
|
+ $money11800Records = Db::name("old_user_of_goods")->whereIn("user_id",$person_nums)->where("node_id",$user_id)->where("money",11800)->select();
|
|
|
4027
|
+
|
|
|
4028
|
+ //var_dump($person_nums);
|
|
|
4029
|
+ //计算个人的11800单价的业绩 集合
|
|
|
4030
|
+ $money11800Sum = 0;
|
|
|
4031
|
+
|
|
|
4032
|
+ foreach ($money11800Records as $record) {
|
|
|
4033
|
+ $money11800Sum += $record['money'] - 3000 - 1800;
|
|
|
4034
|
+ }
|
|
|
4035
|
+
|
|
|
4036
|
+
|
|
|
4037
|
+ $money10620Records = Db::name("old_user_of_goods")->whereIn("user_id",$person_nums)->where("node_id",$user_id)->where("money",10620)->select();
|
|
|
4038
|
+
|
|
|
4039
|
+ //var_dump($person_nums);
|
|
|
4040
|
+ //计算个人的10620单价的业绩 集合
|
|
|
4041
|
+ $money10620Sum = 0;
|
|
|
4042
|
+
|
|
|
4043
|
+ foreach ($money10620Records as $record) {
|
|
|
4044
|
+ $money10620Sum += $record['money'] - 2700 - 1620;
|
|
|
4045
|
+ }
|
|
|
4046
|
+
|
|
|
4047
|
+
|
|
|
4048
|
+ // 计算除去特定值后的总和
|
|
|
4049
|
+ $otherMoneyRecords = Db::name("old_user_of_goods")->whereIn("user_id",$person_nums)->where("node_id",$user_id)->whereNotIn('money', [1180, 11800 ,10620])->select();
|
|
|
4050
|
+ $otherMoneySum = 0;
|
|
|
4051
|
+ foreach ($otherMoneyRecords as $record) {
|
|
|
4052
|
+ $otherMoneySum += $record['money'];
|
|
|
4053
|
+ }
|
|
|
4054
|
+
|
|
|
4055
|
+ // 分别处理特定值的情况并加上其他值的总和
|
|
|
4056
|
+ $user_person_amount = $money1180Sum + $money11800Sum +$money10620Sum + round($otherMoneySum * 0.7,2);
|
|
|
4057
|
+
|
|
|
4058
|
+
|
|
|
4059
|
+ $person_amount += $user_person_amount;
|
|
|
4060
|
+
|
|
|
4061
|
+
|
|
|
4062
|
+ //级别信息
|
|
|
4063
|
+ $userInfo = Db::name("user")->find($user_id);//
|
|
|
4064
|
+ $zk_level = 4;
|
|
|
4065
|
+ $is_zk = false;
|
|
|
4066
|
+ if($userInfo['user_level_id_old'] == $zk_level) {
|
|
|
4067
|
+ $is_zk = true;
|
|
|
4068
|
+ $sales_incentive_info = $this->getStarLevel($user_id,$team_amount,$person_amount);
|
|
|
4069
|
+ $sales_incentive = isset($sales_incentive_info['title']) ? $sales_incentive_info['title'] : '';
|
|
|
4070
|
+ } else{
|
|
|
4071
|
+ $sales_incentive = 0;
|
|
|
4072
|
+ }
|
|
|
4073
|
+
|
|
|
4074
|
+
|
|
|
4075
|
+ $return_data = [
|
|
|
4076
|
+ 'common_nums'=>count($common_nums) + $get_teams_comm_num,
|
|
|
4077
|
+ 'person_nums'=>count($person_nums) + $get_teams_per_num,
|
|
|
4078
|
+ 'common_nums_pv'=> $team_amount,
|
|
|
4079
|
+ 'person_nums_pv'=> $person_amount,
|
|
|
4080
|
+ 'sum_nums_pv' =>$team_amount + $person_amount,
|
|
|
4081
|
+ 'sales_incentive' => $sales_incentive,
|
|
|
4082
|
+ "is_zk"=>$is_zk
|
|
|
4083
|
+ ];
|
|
|
4084
|
+ return $return_data;
|
|
|
4085
|
+
|
|
|
4086
|
+
|
|
|
4087
|
+
|
|
|
4088
|
+
|
|
|
4089
|
+
|
|
|
4090
|
+ }
|
|
|
4091
|
+
|
|
|
4092
|
+
|
|
3701
|
4093
|
/**
|
|
3702
|
4094
|
* 获取当前用户业绩
|
|
3703
|
4095
|
*/
|
|
|
@@ -3714,13 +4106,15 @@ public function processArray($array) {
|
|
3714
|
4106
|
//var_dump($user_id);
|
|
3715
|
4107
|
$get_teams_comm_num = 0;
|
|
3716
|
4108
|
$get_teams_comm_pv = 0;
|
|
|
4109
|
+
|
|
|
4110
|
+ $get_teams_per_num = 0;//小部门人数
|
|
3717
|
4111
|
//1.0系统中有下级,需要在2.0中再加下级数据
|
|
3718
|
4112
|
if($user_id < 611){
|
|
3719
|
4113
|
//梅红在2.0中的ID是780
|
|
3720
|
|
- if($user_id == 593){
|
|
3721
|
|
- $common_nums[] = 780;
|
|
3722
|
|
- unset($common_nums[0]);
|
|
3723
|
|
- }
|
|
|
4114
|
+ // if($user_id == 593){
|
|
|
4115
|
+ // $common_nums[] = 780;
|
|
|
4116
|
+ // unset($common_nums[0]);
|
|
|
4117
|
+ // }
|
|
3724
|
4118
|
//var_dump($common_nums);
|
|
3725
|
4119
|
//用户三峡所有在2.0系统下面的业绩和人数 start
|
|
3726
|
4120
|
$child_nums = [];
|
|
|
@@ -3729,15 +4123,15 @@ public function processArray($array) {
|
|
3729
|
4123
|
$common_ns[] = $user_id;
|
|
3730
|
4124
|
//var_dump($common_ns);return;
|
|
3731
|
4125
|
//获取当前用户
|
|
3732
|
|
- foreach($common_ns as $v){
|
|
|
4126
|
+ foreach($common_nums as $v){
|
|
3733
|
4127
|
$child_nums[] = $this->getRecursiveChildren($v);
|
|
3734
|
4128
|
}
|
|
3735
|
4129
|
|
|
3736
|
4130
|
//梅红在2.0中的ID是780
|
|
3737
|
|
- if($user_id == 593){
|
|
3738
|
|
- $child_nums[0][] = 780;
|
|
|
4131
|
+ // if($user_id == 593){
|
|
|
4132
|
+ // $child_nums[0][] = 780;
|
|
3739
|
4133
|
|
|
3740
|
|
- }
|
|
|
4134
|
+ // }
|
|
3741
|
4135
|
|
|
3742
|
4136
|
|
|
3743
|
4137
|
//去除空数组,并重新组合有数据的数组
|
|
|
@@ -3753,7 +4147,14 @@ public function processArray($array) {
|
|
3753
|
4147
|
|
|
3754
|
4148
|
//var_dump($result_big_team_arr);echo "ppppppppppppppppp";
|
|
3755
|
4149
|
//获取当前用户下面在2.0中的下级所有PV
|
|
3756
|
|
- $get_teams_comm_pv = $this->getteampv($result_big_team_arr);
|
|
|
4150
|
+ $t_pv = $this->getteampv($result_big_team_arr);
|
|
|
4151
|
+ $get_teams_comm_pv =$t_pv['totalPv'];
|
|
|
4152
|
+
|
|
|
4153
|
+ // if($user_id == 593){
|
|
|
4154
|
+ // $get_teams_comm_pv = 7000;
|
|
|
4155
|
+
|
|
|
4156
|
+ // }
|
|
|
4157
|
+
|
|
3757
|
4158
|
//var_dump($get_teams_comm_pv);
|
|
3758
|
4159
|
//获取当前用户下面在2.0中的下级所有人数
|
|
3759
|
4160
|
$get_teams_comm_num = count($result_big_team_arr);
|
|
|
@@ -3778,9 +4179,31 @@ public function processArray($array) {
|
|
3778
|
4179
|
$get_teams_comm_num = $num_teams[0]['total_count'];
|
|
3779
|
4180
|
|
|
3780
|
4181
|
}else if(count($get_teams_comm_datas) >1){
|
|
|
4182
|
+ // $getss = $this->processArray($get_teams_comm_datas);
|
|
|
4183
|
+
|
|
|
4184
|
+ // $team_datas = $num_teams[$getss['max_index']];
|
|
|
4185
|
+
|
|
|
4186
|
+ // var_dump( $get_teams_comm_datas);
|
|
|
4187
|
+ //获取一个最大值,设为大部门,其他的加载一块是小部门
|
|
3781
|
4188
|
$getss = $this->processArray($get_teams_comm_datas);
|
|
3782
|
|
- //var_dump($getss);
|
|
3783
|
|
- $team_datas = $num_teams[$getss['max_index']];
|
|
|
4189
|
+
|
|
|
4190
|
+ $max_value_count = $num_teams[$getss['max_index']]['total_count'];
|
|
|
4191
|
+
|
|
|
4192
|
+ unset($num_teams[$getss['max_index']]);
|
|
|
4193
|
+
|
|
|
4194
|
+ //获取小部门的人数
|
|
|
4195
|
+ $per_num = 0;
|
|
|
4196
|
+ foreach($num_teams as $k=>$v){
|
|
|
4197
|
+ $per_num +=$v['total_count'];
|
|
|
4198
|
+ }
|
|
|
4199
|
+
|
|
|
4200
|
+ //找到最大值的(大部门)
|
|
|
4201
|
+ $get_teams_comm_num = $max_value_count;
|
|
|
4202
|
+ //小部门的数量
|
|
|
4203
|
+ $get_teams_per_num = $per_num;
|
|
|
4204
|
+ //var_dump($getss['max_value']);
|
|
|
4205
|
+ $person_amount = $getss['remaining_sum'];
|
|
|
4206
|
+ $get_teams_comm_pv = $getss['max_value'];
|
|
3784
|
4207
|
}
|
|
3785
|
4208
|
|
|
3786
|
4209
|
|
|
|
@@ -3822,16 +4245,24 @@ public function processArray($array) {
|
|
3822
|
4245
|
}
|
|
3823
|
4246
|
|
|
3824
|
4247
|
//获取当前用户下面在2.0中的下级所有PV
|
|
3825
|
|
- $get_teams_per_pv = $this->getteampv($result_small_team_arr);
|
|
3826
|
|
-
|
|
|
4248
|
+ // $get_teams_per_pv = $this->getteampv($result_small_team_arr);
|
|
|
4249
|
+ $t_pv = $this->getteampv($result_small_team_arr);
|
|
|
4250
|
+ $get_teams_per_pv =$t_pv['totalPv'];
|
|
3827
|
4251
|
|
|
3828
|
4252
|
|
|
3829
|
4253
|
|
|
3830
|
4254
|
|
|
3831
|
4255
|
//获取当前用户下面在2.0中的下级所有人数
|
|
3832
|
|
- $get_teams_per_num = count($result_small_team_arr);
|
|
|
4256
|
+ $get_teams_per_num += count($result_small_team_arr);
|
|
3833
|
4257
|
//合并业绩和人数
|
|
3834
|
4258
|
$person_amount += $get_teams_per_pv;
|
|
|
4259
|
+
|
|
|
4260
|
+
|
|
|
4261
|
+ // if($user_id == 593){
|
|
|
4262
|
+ // $person_amount = 2800;
|
|
|
4263
|
+
|
|
|
4264
|
+ // }
|
|
|
4265
|
+
|
|
3835
|
4266
|
//var_dump($person_amount);
|
|
3836
|
4267
|
//用户小部门所有在2.0系统下面的业绩和人数 end
|
|
3837
|
4268
|
|
|
|
@@ -3849,6 +4280,27 @@ public function processArray($array) {
|
|
3849
|
4280
|
}
|
|
3850
|
4281
|
//var_dump($team_amount);
|
|
3851
|
4282
|
|
|
|
4283
|
+
|
|
|
4284
|
+ if($user_id < 611){
|
|
|
4285
|
+
|
|
|
4286
|
+ //获取当前用户直属下级(查询在2.0中直接推荐人和伞下的业绩。并比对大小部门)
|
|
|
4287
|
+ //例子:17所有下面uid是speard_uid都是17的,和所有伞下的业绩。分出大小部门,加到1.0的大小部门中
|
|
|
4288
|
+ $b_s = $this->getparents_child_pv($user_id);
|
|
|
4289
|
+
|
|
|
4290
|
+ //var_dump( $b_s);echo "yyyyyyyyyyyyy";
|
|
|
4291
|
+ $team_amount += $b_s['team_pv'];
|
|
|
4292
|
+ $get_teams_comm_num += $b_s['team_num'];
|
|
|
4293
|
+
|
|
|
4294
|
+
|
|
|
4295
|
+ $person_amount += $b_s['per_pv'];
|
|
|
4296
|
+
|
|
|
4297
|
+ $get_teams_per_num += $b_s['per_num'];//小部门人数
|
|
|
4298
|
+
|
|
|
4299
|
+
|
|
|
4300
|
+
|
|
|
4301
|
+ //var_dump($team_amount,$person_amount );
|
|
|
4302
|
+ }
|
|
|
4303
|
+
|
|
3852
|
4304
|
|
|
3853
|
4305
|
|
|
3854
|
4306
|
$user_team_amount = Db::name("old_user_of_goods")->whereIn("user_id",$common_nums)->where("node_id",$user_id)->where('money', 1180)->select();
|
|
|
@@ -3860,6 +4312,13 @@ public function processArray($array) {
|
|
3860
|
4312
|
$money1180Sum += $record['money'] - 300 - 180;
|
|
3861
|
4313
|
}
|
|
3862
|
4314
|
|
|
|
4315
|
+
|
|
|
4316
|
+ if($user_id == 593){
|
|
|
4317
|
+ $money1180Sum -= 700;
|
|
|
4318
|
+
|
|
|
4319
|
+ }
|
|
|
4320
|
+
|
|
|
4321
|
+
|
|
3863
|
4322
|
// 获取 status 为 1 且 money 为 11800 的记录集合
|
|
3864
|
4323
|
|
|
3865
|
4324
|
$money11800Records = Db::name("old_user_of_goods")->whereIn("user_id",$common_nums)->where("node_id",$user_id)->where('money', 11800)->select();
|