xiaogang 4 роки тому
батько
коміт
d1a9191a61

+ 20 - 0
app/Helper/function.php

xqd xqd
@@ -1,4 +1,5 @@
 <?php
+use \Illuminate\Support\Facades\DB;
 //生成随机码
 function create_invite_code() {
     $code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
@@ -101,4 +102,23 @@ function birthday($birthday){
     return $year_diff;
 }
 
+/**
+ *  谁看了我
+ * @param $user_id  //操作人id
+ * @param $look_id  //被查看人的id
+ * @return bool
+ */
+function look_log($user_id,$look_id){
+    $ins['user_id'] = $user_id;
+    $ins['look_id'] = $look_id;
+    $ins['atime'] = date("Y-m-d H:i:s");
+    $last_look = DB::table('users_look')->where(['user_id'=>$user_id,'look_id'=>$look_id])->orderBy('atime','desc')->first();
+    if($last_look && date('d')==date('d',$last_look['atime'])){
+        return true;
+    }
+    DB::table('users_look')->insert($ins);
+    DB::table('users')->where('id','=',$look_id)->increment('look_num',1);
+    return true;
+}
+
 

+ 11 - 0
app/Http/Controllers/Api/HomeController.php

xqd
@@ -64,4 +64,15 @@ class HomeController extends Controller
         }
         return response()->json($res);
     }
+
+    public function user_detail(Request $request){
+        try {
+            $res = $this->homeService->user_detail($request->user_id);
+        }catch (\Exception $exception){
+            return $this->response->errorForbidden($exception->getMessage());
+        }
+        return response()->json($res);
+    }
+
+
 }

+ 19 - 0
app/Http/Controllers/Api/UserController.php

xqd
@@ -170,6 +170,25 @@ class UserController extends Controller
         }
     }
 
+    /**
+     * 上传照片或者视频
+     * @param Request $request
+     * @return \Illuminate\Http\JsonResponse|void
+     */
+    public function upload_file(Request $request){
+        try {
+            $res = VipModel::query()->orderBy('id','asc')->get();
+            foreach ($res as $k=>$v){
+                $res[$k]['rights'] = json_decode($v['rights'],true);
+            }
+        }catch (\Exception $exception){
+            return $this->response->errorForbidden($exception->getMessage());
+        }
+        return response()->json($res);
+    }
+
+
+
     /**
      * 获取VIP
      */

+ 1 - 1
app/Models/UserInfoModel.php

xqd
@@ -9,7 +9,7 @@ class UserInfoModel extends BaseModel
     protected $table = 'users_info';
     public $timestamps = false;
     protected $primaryKey="user_id";
-    protected $fillable = ['user_id', 'nickname','avatar','birthday','height','weight','work','info','figure','feeling','education','income','drink','hobby','photo','video'];
+    protected $fillable = ['user_id','weixin', 'nickname','avatar','birthday','height','weight','work','info','figure','feeling','education','income','drink','hobby','photo','video'];
 
     protected $appends = ['age'];
 

+ 12 - 0
app/Services/HomeService.php

xqd
@@ -45,4 +45,16 @@ class HomeService
         }
         return $query;
     }
+
+    //用户详情
+    public function user_detail($user_id){
+        $user = auth('api')->user();
+        if($user){
+            //登录状态  增加 谁看了我记录
+            look_log($user->id,$user_id);
+        }
+
+
+
+    }
 }

+ 1 - 1
app/Services/UserService.php

xqd
@@ -37,7 +37,7 @@ class UserService
             ->with(['user'=>function($query){
                 $query->select('id','sex','is_vip','tencent_im_user_id');
             },'user_info'])
-            ->where('user_id',$param['user_id'])
+            ->where('look_id',$param['user_id'])
             ->paginate(request('perPage',20));
         return $res;
     }