zilong преди 4 години
родител
ревизия
dad149b25d

+ 12 - 4
app/Helpers/functions.php

xqd
@@ -11,23 +11,31 @@ use App\Exceptions\ExitOutException;
 
 //统一输出格式话的json数据
 if (!function_exists('out')) {
-    function out($data = null, $code = 200, $message = 'success')
+    function out($data = null, $code = 200, $message = 'success', $exceptionData = false)
     {
         $out = ['code' => $code, 'message' => $message, 'data' => $data];
 
+        if ($exceptionData !== false) {
+            trace([$message => $exceptionData], 'error');
+        }
+
         return response()->json($out);
     }
 }
 
 //统一异常输出格式话的json数据
 if (!function_exists('exit_out')) {
-    function exit_out($data = null, $code = 500, $message = 'fail')
+    function exit_out($data = null, $code = 200, $message = 'success', $exceptionData = false)
     {
         $out = ['code' => $code, 'message' => $message, 'data' => $data];
 
-        $message = json_encode($out, JSON_UNESCAPED_UNICODE);
+        if ($exceptionData !== false) {
+            trace([$message => $exceptionData], 'error');
+        }
+
+        $json = json_encode($out, JSON_UNESCAPED_UNICODE);
 
-        throw new ExitOutException($message);
+        throw new ExitOutException($json);
     }
 }
 

+ 28 - 63
app/Http/Controllers/Api/V1/CommonController.php

xqd xqd
@@ -26,87 +26,56 @@ class CommonController extends Controller
 
         $data = $app->auth->session($req['wechat_code']);
 
-        if (!empty($data['openid'])){
-            $req['openid'] = $data['openid'];
-            $req['register_time'] = time();
-        }
-        else {
-            trace(['微信登录获取openid异常' => $data], 'error');
+        if (empty($data['openid'])){
             return out(null, 10001, '微信登录code错误');
         }
 
-        $user = User::select(['id', 'status', 'phone', 'nickname', 'avatar','realname','promoter_type'])->where('openid', $req['openid'])->first();
+        $session_key = !empty($data['session_key']) ? $data['session_key'] : '';
+        $user = User::select(['id', 'status', 'phone', 'nickname', 'avatar'])->where('openid', $data['openid'])->first();
         if (empty($user)){
-            $req['partner_id'] = 1;//默认总部
-            $req['province_id'] = 2;//默认总部
-            $req['city_id'] = 37;//默认总部
-            $res = User::create($req);
-            if ($res){
-                $user = User::select(['id', 'status', 'phone', 'nickname', 'avatar','realname','promoter_type'])->where('openid', $req['openid'])->first();
-                $token = aes_encrypt(['id' => $user['id'], 'time' => time()]);
-                return out(['token' => $token, 'is_auth' => 1, 'avatar' => $user['avatar'], 'nickname' => $user['nickname'],'realname' => $user['realname'],'promoter_type'=>$user['promoter_type']]);
-            }
-            return out(['token' => '', 'is_auth' => 0, 'avatar' => '', 'nickname' => '']);
+            $user = User::create([
+                'openid' => $data['openid'],
+                'nickname' => $req['nickname'] ?? '',
+                'avatar' => $req['avatar'] ?? '',
+                'session_key' => $session_key
+            ]);
         }
         else {
-            if ($user['status'] == 0){
-                return out(null, 10001, '账号已被冻结');
+            if ($user['status'] == 0) {
+                return out(null, 10002, '该账号已被冻结');
             }
-            if (!empty($data['session_key'])){
-                $req['session_key']=$data['session_key'];
-                $user->fill($req)->save();
-            }
-
-            $token = aes_encrypt(['id' => $user['id'], 'time' => time()]);
 
-            return out(['token' => $token, 'is_auth' => 1, 'avatar' => $user['avatar'], 'nickname' => $user['nickname'],'realname' => $user['realname'],'promoter_type'=>$user['promoter_type']]);
+            User::where('id', $user['id'])->update([
+                'nickname' => $req['nickname'] ?? '',
+                'avatar' => $req['avatar'] ?? '',
+                'session_key' => $session_key
+            ]);
         }
+
+        $token = aes_encrypt(['id' => $user['id'], 'time' => time()]);
+
+        return out(['token' => $token]);
     }
 
     public function uploadImg()
     {
         $file = request()->file('file');
-        if (!empty($file)) {
-            $path = $file->store('uploads');
-            $file_url = request()->getScheme().'://'.request()->getHost().'/'.$path;
-
-            return out(['file_url' => $file_url]);
+        if (empty($file)) {
+            return out(null, 10001, '文件不能为空');
         }
 
-        return out(null, 10001, '文件不能为空');
-    }
-
-    public function getPhoneNumber()
-    {
-        $req = request()->post();
-        $this->validate(request(), [
-            'iv' => 'required',
-            'encryptData' => 'required',
-        ]);
-
-        $user = User::getUserByToken();
-        $session_key = $user['session_key'];
-
-        $app = Factory::miniProgram(config('config.wechat_small_program'));
-
-        try {
-            $decryptedData = $app->encryptor->decryptData($session_key, $req['iv'], $req['encryptData']);
-        } catch (\Exception $e) {
-            return out(null, 10001, '获取手机失败');
-        }
+        $path = $file->store('uploads');
+        $url = request()->getScheme().'://'.request()->getHost().'/'.$path;
 
-        return out($decryptedData);
+        return out(['url' => $url]);
     }
 
     public function doc()
     {
-        $database = 'juyin';
-        $prefix = 'xcx_';
+        $database = env('DB_DATABASE');
+        $prefix = env('DB_PREFIX');
         $map1 = [
             'users' => 'user(用户表)',
-            'user_reports' => 'user_report(用户上传的报告表)',
-            'payments' => 'payment(支付表)',
-            'user_promotes' => 'user_promote(用户推广信息表)',
         ];
 
         $data1 = array();
@@ -117,11 +86,7 @@ class CommonController extends Controller
         }
 
         $map2 = [
-            'orders' => 'order(订单表)',
-            'order_projects' => 'order_project(订单项目表)',
-            'assessment_reports' => 'assessment_reports(评估报告表)',
-            'user_withdraw_records' => 'user_withdraw_record(用户提现记录表)',
-            'user_balance_logs' => 'user_balance_log(用户资金日志表)'
+            'docters' => 'docters(医生表)',
         ];
 
         $data2 = array();

+ 24 - 1
app/Http/Controllers/Api/V1/UserController.php

xqd
@@ -9,13 +9,36 @@
 namespace App\Http\Controllers\Api\V1;
 
 use App\Http\Controllers\Api\AuthController;
+use EasyWeChat\Factory;
 
 class UserController extends AuthController
 {
-    public function UserInfo()
+    public function userInfo()
     {
         $user = $this->user;
 
+        unset($user['session_key']);
+
         return out($user);
     }
+
+    public function getPhoneNumber()
+    {
+        $req = request()->post();
+        $this->validate(request(), [
+            'iv' => 'required',
+            'encryptData' => 'required',
+        ]);
+        $user = $this->user;
+
+        $app = Factory::miniProgram(config('config.wechat_small_program'));
+
+        try {
+            $decryptedData = $app->encryptor->decryptData($user['session_key'], $req['iv'], $req['encryptData']);
+        } catch (\Exception $e) {
+            return out(null, 10001, '获取手机号失败', $e->getMessage());
+        }
+
+        return out($decryptedData);
+    }
 }

+ 0 - 0
bootstrap/cache/.gitignore


+ 1 - 1
config/filesystems.php

xqd
@@ -45,7 +45,7 @@ return [
 
         'local' => [
             'driver' => 'local',
-            'root' => storage_path('app'),
+            'root' => public_path(),
         ],
 
         'public' => [

+ 2 - 0
public/uploads/.gitignore

xqd
@@ -0,0 +1,2 @@
+*
+!.gitignore

+ 80 - 0
resources/views/doc.blade.php

xqd
@@ -0,0 +1,80 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>部分数据表字典</title>
+    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet">
+</head>
+
+<body style="font-size: 15px; margin: 25px;">
+<div style="text-align: center"><h1>部分数据表字典</h1></div>
+<div class="row">
+    <div class="col-sm-6">
+        <?php foreach ($data1 as $k => $v){ ?>
+        <div class="ibox float-e-margins">
+            <div class="ibox-title">
+                <h2 style="margin-top: -5px;">{{$k}}</h2>
+            </div>
+            <div class="ibox-content">
+
+                <table class="table table-bordered">
+                    <thead>
+                    <tr>
+                        <th>字段名</th>
+                        <th>字段类型</th>
+                        <th>字段注释</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <?php foreach ($v as $vv){ ?>
+                    <tr>
+                        <td>{{$vv->name}}</td>
+                        <td>{{$vv->type}}</td>
+                        <td>{{$vv->comment}}</td>
+                    </tr>
+                    <?php }?>
+                    </tbody>
+                </table>
+
+            </div>
+        </div>
+        <?php }?>
+    </div>
+
+    <div class="col-sm-6">
+        <?php foreach ($data2 as $k => $v){ ?>
+        <div class="ibox float-e-margins">
+            <div class="ibox-title">
+                <h2 style="margin-top: -5px;">{{$k}}</h2>
+            </div>
+            <div class="ibox-content">
+
+                <table class="table table-bordered">
+                    <thead>
+                    <tr>
+                        <th>字段名</th>
+                        <th>字段类型</th>
+                        <th>字段注释</th>
+                    </tr>
+                    </thead>
+                    <tbody>
+                    <?php foreach ($v as $vv){ ?>
+                    <tr>
+                        <td>{{$vv->name}}</td>
+                        <td>{{$vv->type}}</td>
+                        <td>{{$vv->comment}}</td>
+                    </tr>
+                    <?php }?>
+                    </tbody>
+                </table>
+
+            </div>
+        </div>
+        <?php }?>
+    </div>
+</div>
+</body>
+
+</html>

+ 0 - 100
resources/views/welcome.blade.php

xqd
@@ -1,100 +0,0 @@
-<!DOCTYPE html>
-<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
-    <head>
-        <meta charset="utf-8">
-        <meta name="viewport" content="width=device-width, initial-scale=1">
-
-        <title>Laravel</title>
-
-        <!-- Fonts -->
-        <link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet">
-
-        <!-- Styles -->
-        <style>
-            html, body {
-                background-color: #fff;
-                color: #636b6f;
-                font-family: 'Nunito', sans-serif;
-                font-weight: 200;
-                height: 100vh;
-                margin: 0;
-            }
-
-            .full-height {
-                height: 100vh;
-            }
-
-            .flex-center {
-                align-items: center;
-                display: flex;
-                justify-content: center;
-            }
-
-            .position-ref {
-                position: relative;
-            }
-
-            .top-right {
-                position: absolute;
-                right: 10px;
-                top: 18px;
-            }
-
-            .content {
-                text-align: center;
-            }
-
-            .title {
-                font-size: 84px;
-            }
-
-            .links > a {
-                color: #636b6f;
-                padding: 0 25px;
-                font-size: 13px;
-                font-weight: 600;
-                letter-spacing: .1rem;
-                text-decoration: none;
-                text-transform: uppercase;
-            }
-
-            .m-b-md {
-                margin-bottom: 30px;
-            }
-        </style>
-    </head>
-    <body>
-        <div class="flex-center position-ref full-height">
-            @if (Route::has('login'))
-                <div class="top-right links">
-                    @auth
-                        <a href="{{ url('/home') }}">Home</a>
-                    @else
-                        <a href="{{ route('login') }}">Login</a>
-
-                        @if (Route::has('register'))
-                            <a href="{{ route('register') }}">Register</a>
-                        @endif
-                    @endauth
-                </div>
-            @endif
-
-            <div class="content">
-                <div class="title m-b-md">
-                    Laravel
-                </div>
-
-                <div class="links">
-                    <a href="https://laravel.com/docs">Docs</a>
-                    <a href="https://laracasts.com">Laracasts</a>
-                    <a href="https://laravel-news.com">News</a>
-                    <a href="https://blog.laravel.com">Blog</a>
-                    <a href="https://nova.laravel.com">Nova</a>
-                    <a href="https://forge.laravel.com">Forge</a>
-                    <a href="https://vapor.laravel.com">Vapor</a>
-                    <a href="https://github.com/laravel/laravel">GitHub</a>
-                </div>
-            </div>
-        </div>
-    </body>
-</html>

+ 0 - 0
storage/app/.gitignore


+ 0 - 0
storage/app/public/.gitignore


+ 0 - 0
storage/framework/.gitignore


+ 0 - 0
storage/framework/cache/.gitignore


+ 0 - 0
storage/framework/cache/data/.gitignore


+ 0 - 0
storage/framework/sessions/.gitignore


+ 0 - 0
storage/framework/testing/.gitignore


+ 0 - 0
storage/framework/views/.gitignore


+ 0 - 0
storage/logs/.gitignore