hrjy %!s(int64=2) %!d(string=hai) anos
pai
achega
8380645c95
Modificáronse 2 ficheiros con 32 adicións e 15 borrados
  1. 28 13
      app/common.php
  2. 4 2
      app/models/many/ManyOrder.php

+ 28 - 13
app/common.php

@@ -662,22 +662,37 @@ if (!function_exists('do_request')) {
         }
     }
 
-    if (!function_exists('getParent')){
-        //查找所有上级
-        function getParent($uid){
-            //当前用户
-            static $arr=[];
-            //当前用户
-            $member = getDataFind('user',array('uid'=>$uid));
-            if ($member['spread_uid'] > 0){
-                $parent = getDataFind('user',array('uid'=>$member['spread_uid']));
+//    if (!function_exists('getParent')){
+//        //查找所有上级
+//        function getParent($uid){
+//            //当前用户
+//            static $arr=[];
+//            //当前用户
+//            $member = getDataFind('user',array('uid'=>$uid));
+//            if ($member['spread_uid'] > 0){
+//                $parent = getDataFind('user',array('uid'=>$member['spread_uid']));
+//
+//                $arr[]= $parent['uid'];
+//
+//                getParent($parent['uid']);
+//            }
+//            return $arr;
+//
+//        }
+//    }
 
-                $arr[]= $parent['uid'];
+    if (!function_exists('getParent')){
+        //获取指定级别的所有上级
+        function getParent($p_id,$array) {
+            $subs=array();
+            foreach($array as $item){
+                if($item['uid'] == $p_id){
+                    $subs[]=$item['uid'];//这里自己看着办,我是获取用户名
+                    $subs=array_merge($subs,getParent($item['spread_uid'],$array));
+                }
 
-                getParent($parent['uid']);
             }
-            return $arr;
-
+            return $subs;
         }
     }
 

+ 4 - 2
app/models/many/ManyOrder.php

@@ -126,13 +126,13 @@ class ManyOrder extends BaseModel
      */
     public static function push()
     {
-        if (!Push::where('add_time', strtotime('today'))->find()){
+        if (!Push::where('add_time', strtotime('today'))->where('type', 1)->find()){
             $user = User::select();
             foreach ($user as $item)
             {
                 $price = ManyOrder::whereBetweenTime('return_time', strtotime('yesterday'), strtotime('today'))->where('status', 1)->where('uid', $item['uid'])->sum('price');// 昨天众筹成功返还的金额流水
                 if ($item['spread_uid'] > 0 and $price > 0){
-                    $spread = getParent($item['uid']);// 找到所有上级
+                    $spread = getParent($item['spread_uid'], $user->toArray());// 找到所有上级
                     $v1 = 0;
                     $v2 = 0;
                     $v3 = 0;
@@ -235,6 +235,8 @@ class ManyOrder extends BaseModel
                     }
                 }
             }
+            Push::create(['add_time' => strtotime('today'), 'type' => 1]); //存入数据库信息
+
         }
     }