hrjy il y a 2 ans
Parent
commit
b4ed2c3b0d
2 fichiers modifiés avec 16 ajouts et 5 suppressions
  1. 6 1
      app/api/controller/user/UserController.php
  2. 10 4
      app/common.php

+ 6 - 1
app/api/controller/user/UserController.php

@@ -639,7 +639,12 @@ class UserController
      */
     public function team(Request $request)
     {
-        $data['list'] = get_downlines(User::select(), $request->uid());
+        $time = UtilService::getMore([
+            ['start_time'],
+            ['end_time']
+        ]);
+
+        $data['list'] = get_downlines(User::select(), $request->uid(), $time);
         $data['team_count'] = count($data['list']);
         $data['zt_count'] = User::where('spread_uid', $request->uid())->count();
 

+ 10 - 4
app/common.php

@@ -623,18 +623,24 @@ if (!function_exists('do_request')) {
 
     if (!function_exists('get_downlines')){
         //所有下级
-        function get_downlines($members,$id){
+        function get_downlines($members,$id,$time = ''){
             $arr=array();
+            $where = [];
+            if ($time['start_time'] and $time['end_time']){
+                $where[] = ['add_time', '>', strtotime($time['start_time'])];
+                $where[] = ['add_time', '<', strtotime($time['end_time'])];
+            }
+
             foreach ($members as $key => $v) {
                 if($v['spread_uid']==$id){  //pid为0的是顶级分类
                     $arr[]= [
                         'nickname' => $v['nickname'],
                         'avatar' => $v['avatar'],
                         'uid' => $v['uid'],
-                        'price' => \app\models\store\StoreOrder::where('uid', $v['uid'])->where('paid', 1)->sum('pay_price'),
-                        'count' => \app\models\store\StoreOrder::where('uid', $v['uid'])->where('paid', 1)->sum('total_num')
+                        'price' => \app\models\store\StoreOrder::where('uid', $v['uid'])->where('paid', 1)->where($where)->sum('pay_price'),
+                        'count' => \app\models\store\StoreOrder::where('uid', $v['uid'])->where('paid', 1)->where($where)->sum('total_num')
                     ];
-                    $arr = array_merge($arr,get_downlines($members,$v['uid']));
+                    $arr = array_merge($arr,get_downlines($members,$v['uid'], $time));
                 }
             }
             return $arr;