瀏覽代碼

user property debug

zz 6 年之前
父節點
當前提交
c97badf5bf

+ 11 - 3
app/Http/Controllers/Wap/Web/WelcomeController.php

@@ -106,7 +106,7 @@ class WelcomeController extends BaseController
         }
         //设置用户是否充值
         $this->setIsPaid();
-        $this->setProperty($user->openid);
+        $this->setProperty($user->openid,$user->created_at);
         $channel_activities_flag = $this->judgeChannelActivity($user);
         //最近阅读页面 推荐
         if(isset($user->sex)){
@@ -2226,9 +2226,17 @@ class WelcomeController extends BaseController
         }
     }
 
-    private function setProperty($openid){
+    private function setProperty($openid,$register){
         $property = UserDivisionCpcPropertyService::userLevelV2($openid);
-        $this->property = $property;
+        if($property == 'none'){
+            if(time() - strtotime($register) > 3*86400){
+                $this->property = $property;
+            }else{
+                $this->property = 'unknown';
+            }
+        }else{
+            $this->property = $property;
+        }
     }
 
     //统计ua

+ 16 - 2
app/Modules/User/Services/UserDivisionCpcPropertyService.php

@@ -268,7 +268,14 @@ WHERE openid in (SELECT openid FROM users WHERE id = $uid)";
         $result =  UserDivisionCpcPropertyV2::where('openid',$openid)->where('is_enable',1)->select('property')->first();
         if($result)
             return $result->property;
-        return 'none';
+        $sql_format = 'select id,created_at from users WHERE  openid="%s" ORDER by created_at limit 1';
+        $info = DB::select(sprintf($sql_format,$openid));
+        if(!$info) return 'unknown';
+        foreach ($info as $item){
+            if( time()-strtotime($item->created_at) > 3*86400 )
+                return 'none';
+        }
+        return 'unknown';
     }
 
     public static function getUserPropertyV2($uid){
@@ -277,7 +284,14 @@ WHERE openid in (SELECT openid FROM users WHERE id = $uid)";
             ->select('user_division_cpc_property_v2.property')->first();
         if($result)
             return $result->property;
-        return 'none';
+        $sql_format = 'select id,created_at from users WHERE  openid = (select openid FROM users WHERE id=%s) ORDER by created_at limit 1';
+        $info = DB::select(sprintf($sql_format,$uid));
+        if(!$info) return 'unknown';
+        foreach ($info as $item){
+            if( time()-strtotime($item->created_at) > 3*86400 )
+                return 'none';
+        }
+        return 'unknown';
     }
 
     public static function updateV2($openid,$property=''){