正在显示
11 个修改的文件
包含
274 行增加
和
24 行删除
app/Admin/Grids/Modal/User/TeamModal.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | ++----------------------------------------------------------------------------------------------------------------------- | ||
| 4 | + * grid 列表 modal 类:家庭-成员 modal 类 | ||
| 5 | ++----------------------------------------------------------------------------------------------------------------------- | ||
| 6 | + * | ||
| 7 | + * PHP version 7 | ||
| 8 | + * | ||
| 9 | + * @category App\Admin\Grids\Modal | ||
| 10 | + * @package App\Admin\Grids\Modal | ||
| 11 | + * @author Richer <yangzi1028@163.com> | ||
| 12 | + * @date 2022年11月1日16:03:27 | ||
| 13 | + * @copyright 2020-2022 Richer (http://www.Richer.com/) | ||
| 14 | + * @license http://www.Richer.com/ License | ||
| 15 | + * @link http://www.Richer.com/ | ||
| 16 | + */ | ||
| 17 | +namespace App\Admin\Grids\Modal\User; | ||
| 18 | + | ||
| 19 | +use App\Admin\Grids\Modal\BaseModal; | ||
| 20 | +use App\Models\User\TimesRecord; | ||
| 21 | +use App\Models\User\User; | ||
| 22 | +use App\Transformers\Activity\ActivityUserTransformer; | ||
| 23 | +use App\Transformers\User\TimesRecordTransformer; | ||
| 24 | +use App\Transformers\User\UserTransformer; | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * Class TeamModal | ||
| 28 | + * | ||
| 29 | + * @category App\Admin\Grids\User | ||
| 30 | + * @package App\Admin\Grids\User | ||
| 31 | + * @author Richer <yangzi1028@163.com> | ||
| 32 | + * @date 2022年3月15日09:22:19 | ||
| 33 | + * @copyright 2020-2022 Richer (http://www.Richer.com/) | ||
| 34 | + * @license http://www.Richer.com/ License | ||
| 35 | + * @link http://www.Richer.com/ | ||
| 36 | + */ | ||
| 37 | +class TeamModal extends BaseModal | ||
| 38 | +{ | ||
| 39 | + protected $type = ''; | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * TeamModal constructor. | ||
| 43 | + * @param $type | ||
| 44 | + */ | ||
| 45 | + public function __construct($type = '') | ||
| 46 | + { | ||
| 47 | + $this->type = $type; | ||
| 48 | + } | ||
| 49 | + public function render($key = null) | ||
| 50 | + { | ||
| 51 | +// dd($this->type ); | ||
| 52 | + $user = User::find($key); | ||
| 53 | + if ($user->partner == 1) { | ||
| 54 | + $list = User::where(function ($query) use($key) { | ||
| 55 | + $query->where('pid', $key)->orWhere('gid', $key); | ||
| 56 | + })->latest()->paginate(request('per_page', 10)); | ||
| 57 | + } else { | ||
| 58 | + $list = User::where('pid', $key)->latest()->paginate(request('per_page', 10)); | ||
| 59 | + } | ||
| 60 | + request()->offsetSet('user_id', $key); | ||
| 61 | + $paginator = $this->renderPaginator($key, $list, app(UserTransformer::class)); | ||
| 62 | + // 定义需要展示的字段 | ||
| 63 | + $columns = [ | ||
| 64 | + [ | ||
| 65 | + 'name' => __('avatar'), | ||
| 66 | + 'field' => 'avatar', | ||
| 67 | + 'type' => 'image', | ||
| 68 | + ], | ||
| 69 | + [ | ||
| 70 | + 'name' => __('nickname'), | ||
| 71 | + 'field' => 'nickname', | ||
| 72 | + ], | ||
| 73 | + [ | ||
| 74 | + 'name' => __('mobile'), | ||
| 75 | + 'field' => 'mobile', | ||
| 76 | + ], | ||
| 77 | + [ | ||
| 78 | + 'name' => __('关系'), | ||
| 79 | + 'field' => 'level_show', | ||
| 80 | + ], | ||
| 81 | + [ | ||
| 82 | + 'name' => __('加入时间'), | ||
| 83 | + 'field' => 'created_at', | ||
| 84 | + ], | ||
| 85 | + ]; | ||
| 86 | + | ||
| 87 | + $paginator['columns'] = $columns; | ||
| 88 | + | ||
| 89 | + return view( | ||
| 90 | + 'admin::grid.modal', | ||
| 91 | + $paginator | ||
| 92 | + ); | ||
| 93 | + } | ||
| 94 | +} |
| @@ -18,6 +18,7 @@ namespace App\Admin\Grids\User; | @@ -18,6 +18,7 @@ namespace App\Admin\Grids\User; | ||
| 18 | 18 | ||
| 19 | use App\Admin\Extensions\CustomActions; | 19 | use App\Admin\Extensions\CustomActions; |
| 20 | use App\Admin\Grids\Modal\User\IncomeRecordModal; | 20 | use App\Admin\Grids\Modal\User\IncomeRecordModal; |
| 21 | +use App\Admin\Grids\Modal\User\TeamModal; | ||
| 21 | use App\Admin\Grids\Modal\User\TimesRecordModal; | 22 | use App\Admin\Grids\Modal\User\TimesRecordModal; |
| 22 | use App\Admin\Grids\Modal\User\WithdrawnRecordModal; | 23 | use App\Admin\Grids\Modal\User\WithdrawnRecordModal; |
| 23 | use App\Models\User\User; | 24 | use App\Models\User\User; |
| @@ -91,7 +92,7 @@ trait UserGrid | @@ -91,7 +92,7 @@ trait UserGrid | ||
| 91 | { | 92 | { |
| 92 | parent::setGridQuery(); | 93 | parent::setGridQuery(); |
| 93 | 94 | ||
| 94 | - $this->grid->model()->with(['wallet']); | 95 | + $this->grid->model()->with(['wallet']);//->withCount(['allChildren']); |
| 95 | } | 96 | } |
| 96 | 97 | ||
| 97 | /** | 98 | /** |
| @@ -132,7 +133,6 @@ trait UserGrid | @@ -132,7 +133,6 @@ trait UserGrid | ||
| 132 | $url = $actions->getResource(); | 133 | $url = $actions->getResource(); |
| 133 | 134 | ||
| 134 | $actions->append(CustomActions::renderAddUserTimes($id, $url)); | 135 | $actions->append(CustomActions::renderAddUserTimes($id, $url)); |
| 135 | - | ||
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | /** | 138 | /** |
| @@ -142,16 +142,25 @@ trait UserGrid | @@ -142,16 +142,25 @@ trait UserGrid | ||
| 142 | */ | 142 | */ |
| 143 | public function renderGridFields() | 143 | public function renderGridFields() |
| 144 | { | 144 | { |
| 145 | + $this->grid->fixColumns(1, -1); | ||
| 145 | $this->gridRowNo(); | 146 | $this->gridRowNo(); |
| 146 | $this->gridUser(); | 147 | $this->gridUser(); |
| 148 | + | ||
| 147 | // $this->gridBoolField('partner'); | 149 | // $this->gridBoolField('partner'); |
| 148 | $this->gridSwitchField('partner', '', config('constants.STATUS1_STATE_OPTIONS')); | 150 | $this->gridSwitchField('partner', '', config('constants.STATUS1_STATE_OPTIONS')); |
| 151 | + $this->gridNumberField('children_count', '团队')->display(function () { | ||
| 152 | + if ($this->partner == 1) { | ||
| 153 | + return $this->children()->count() + $this->children1()->count(); | ||
| 154 | + } | ||
| 155 | + return $this->children()->count(); | ||
| 156 | + | ||
| 157 | + })->modal('团队明细记录', TeamModal::class);//->sortable(); | ||
| 149 | 158 | ||
| 150 | 159 | ||
| 151 | $this->gridTextField('wallet.income', '总收入')->modal('收入明细记录', IncomeRecordModal::class); | 160 | $this->gridTextField('wallet.income', '总收入')->modal('收入明细记录', IncomeRecordModal::class); |
| 152 | $this->gridTextField('wallet.balance', '余额'); | 161 | $this->gridTextField('wallet.balance', '余额'); |
| 153 | - $this->gridTextField('wallet.withdrawn', '提现')->modal('提现明细记录', WithdrawnRecordModal::class); | ||
| 154 | - $this->gridTextField('wallet.frozen', '冻结'); | 162 | +// $this->gridTextField('wallet.withdrawn', '提现')->modal('提现明细记录', WithdrawnRecordModal::class); |
| 163 | +// $this->gridTextField('wallet.frozen', '冻结'); | ||
| 155 | // $this->gridSingleImageField('avatar', __('wx_avatar')); | 164 | // $this->gridSingleImageField('avatar', __('wx_avatar')); |
| 156 | //// $this->gridTextField('username'); | 165 | //// $this->gridTextField('username'); |
| 157 | //// $this->gridTextField('name', __('truename')); | 166 | //// $this->gridTextField('name', __('truename')); |
| @@ -159,8 +168,8 @@ trait UserGrid | @@ -159,8 +168,8 @@ trait UserGrid | ||
| 159 | // $this->gridSingleSelectField('gender', __('gender'), User::GENDER_OPTIONS, User::GENDER_COLOR_OPTIONS); | 168 | // $this->gridSingleSelectField('gender', __('gender'), User::GENDER_OPTIONS, User::GENDER_COLOR_OPTIONS); |
| 160 | $this->gridNumberField('times')->modal('次数明细记录', TimesRecordModal::class)->sortable(); | 169 | $this->gridNumberField('times')->modal('次数明细记录', TimesRecordModal::class)->sortable(); |
| 161 | $this->gridTextField('login_times')->sortable(); | 170 | $this->gridTextField('login_times')->sortable(); |
| 162 | - $this->gridDateField('last_login_time'); | 171 | +// $this->gridDateField('last_login_time'); |
| 163 | $this->gridDateField('created_at', __('registered_at')); | 172 | $this->gridDateField('created_at', __('registered_at')); |
| 164 | - $this->gridSingleImageField('invite_qr_code', '小程序码'); | 173 | +// $this->gridSingleImageField('invite_qr_code', '小程序码'); |
| 165 | } | 174 | } |
| 166 | } | 175 | } |
| @@ -16,8 +16,12 @@ | @@ -16,8 +16,12 @@ | ||
| 16 | */ | 16 | */ |
| 17 | namespace App\Factories\Wechat; | 17 | namespace App\Factories\Wechat; |
| 18 | 18 | ||
| 19 | +use App\Models\User\User; | ||
| 19 | use EasyWeChat\Factory; | 20 | use EasyWeChat\Factory; |
| 20 | use Illuminate\Http\Request; | 21 | use Illuminate\Http\Request; |
| 22 | +use Illuminate\Support\Arr; | ||
| 23 | +use Illuminate\Support\Facades\Log; | ||
| 24 | +use Illuminate\Support\Str; | ||
| 21 | 25 | ||
| 22 | /** | 26 | /** |
| 23 | * Trait Official | 27 | * Trait Official |
| @@ -98,7 +102,7 @@ trait Official | @@ -98,7 +102,7 @@ trait Official | ||
| 98 | Log::info($message); | 102 | Log::info($message); |
| 99 | 103 | ||
| 100 | //按事件类型处理 | 104 | //按事件类型处理 |
| 101 | - $event = \Str::camel('event_'. $message['Event']); | 105 | + $event = Str::camel('event_'. $message['Event']); |
| 102 | 106 | ||
| 103 | if (method_exists($this, $event)) { | 107 | if (method_exists($this, $event)) { |
| 104 | return call_user_func_array([$this, $event], [$message]); | 108 | return call_user_func_array([$this, $event], [$message]); |
| @@ -116,8 +120,8 @@ trait Official | @@ -116,8 +120,8 @@ trait Official | ||
| 116 | protected function eventSubscribe($message) | 120 | protected function eventSubscribe($message) |
| 117 | { | 121 | { |
| 118 | // 设置了场景 | 122 | // 设置了场景 |
| 119 | - if (\Arr::get($message, 'EventKey')) { | ||
| 120 | - $message['EventKey'] = str_replace('qrscene_', '', \Arr::get($message, 'EventKey')); | 123 | + if (Arr::get($message, 'EventKey')) { |
| 124 | + $message['EventKey'] = str_replace('qrscene_', '', Arr::get($message, 'EventKey')); | ||
| 121 | $user_id = str_replace('INVITE', '', $message['EventKey']); | 125 | $user_id = str_replace('INVITE', '', $message['EventKey']); |
| 122 | $user = User::findOrFail($user_id); | 126 | $user = User::findOrFail($user_id); |
| 123 | if ($user) { | 127 | if ($user) { |
| @@ -139,8 +143,8 @@ trait Official | @@ -139,8 +143,8 @@ trait Official | ||
| 139 | */ | 143 | */ |
| 140 | protected function eventSCAN($message) | 144 | protected function eventSCAN($message) |
| 141 | { | 145 | { |
| 142 | - if (\Arr::get($message, 'EventKey')) { | ||
| 143 | - $message['EventKey'] = str_replace('qrscene_', '', \Arr::get($message, 'EventKey')); | 146 | + if (Arr::get($message, 'EventKey')) { |
| 147 | + $message['EventKey'] = str_replace('qrscene_', '', Arr::get($message, 'EventKey')); | ||
| 144 | $user_id = str_replace('INVITE', '', $message['EventKey']); | 148 | $user_id = str_replace('INVITE', '', $message['EventKey']); |
| 145 | $user = User::findOrFail($user_id); | 149 | $user = User::findOrFail($user_id); |
| 146 | if ($user) { | 150 | if ($user) { |
| @@ -96,14 +96,14 @@ class AuthController extends BaseController | @@ -96,14 +96,14 @@ class AuthController extends BaseController | ||
| 96 | /** | 96 | /** |
| 97 | * 用户登录:微信收取登录 | 97 | * 用户登录:微信收取登录 |
| 98 | * | 98 | * |
| 99 | - * @param LoginRequest $request | 99 | + * @param Request $request |
| 100 | * @return Response | 100 | * @return Response |
| 101 | */ | 101 | */ |
| 102 | - public function wechatAuth(LoginRequest $request) | 102 | + public function wechatAuth(Request $request) |
| 103 | { | 103 | { |
| 104 | $result = $this->service->wechatAuth($request); | 104 | $result = $this->service->wechatAuth($request); |
| 105 | if ($result) { | 105 | if ($result) { |
| 106 | - return $this->success($result, __('login') . ' ' . __('succeeded'), 0); | 106 | + return $this->success($result, __('login') . ' ' . __('succeeded'), 0, $result->token); |
| 107 | } else { | 107 | } else { |
| 108 | return $this->error($this->service->getMessage(), 2006); | 108 | return $this->error($this->service->getMessage(), 2006); |
| 109 | } | 109 | } |
| @@ -190,7 +190,7 @@ trait ChatTrait | @@ -190,7 +190,7 @@ trait ChatTrait | ||
| 190 | * @param string $type | 190 | * @param string $type |
| 191 | * @return string | 191 | * @return string |
| 192 | */ | 192 | */ |
| 193 | - public static function sendRequest($open_ai, $send_data, $type = 'chunked') | 193 | + public static function sendRequest($open_ai, $send_data, $type = 'stream') |
| 194 | { | 194 | { |
| 195 | $answer = ''; | 195 | $answer = ''; |
| 196 | if ($type === 'chunked') { | 196 | if ($type === 'chunked') { |
| @@ -245,9 +245,8 @@ trait ChatTrait | @@ -245,9 +245,8 @@ trait ChatTrait | ||
| 245 | header('Content-type: text/event-stream'); | 245 | header('Content-type: text/event-stream'); |
| 246 | header('Cache-Control: no-cache'); | 246 | header('Cache-Control: no-cache'); |
| 247 | ob_end_flush(); | 247 | ob_end_flush(); |
| 248 | - $answer = ""; | ||
| 249 | $complete = $open_ai->chat($send_data, function ($curl_info, $data) use (&$answer) { | 248 | $complete = $open_ai->chat($send_data, function ($curl_info, $data) use (&$answer) { |
| 250 | - record_log($this->log_channel, '开始请求' ); | 249 | +// record_log($this->log_channel, '开始请求' ); |
| 251 | 250 | ||
| 252 | $deltas = explode("\n", $data); | 251 | $deltas = explode("\n", $data); |
| 253 | $content = ''; | 252 | $content = ''; |
| @@ -266,11 +265,11 @@ trait ChatTrait | @@ -266,11 +265,11 @@ trait ChatTrait | ||
| 266 | } else { | 265 | } else { |
| 267 | $content = "对不起,我不知道怎么去回答。"; | 266 | $content = "对不起,我不知道怎么去回答。"; |
| 268 | } | 267 | } |
| 269 | - echo "data: " .str_replace("\n", "\\n", $content )."\n\n"; | 268 | + echo str_replace("\n", "\\n", $content )."\n\n"; |
| 270 | flush(); | 269 | flush(); |
| 271 | } | 270 | } |
| 272 | 271 | ||
| 273 | - record_log($this->log_channel, '内容: ' . $content ); | 272 | +// record_log($this->log_channel, '内容: ' . $content ); |
| 274 | 273 | ||
| 275 | if (connection_aborted()) { | 274 | if (connection_aborted()) { |
| 276 | return 0; | 275 | return 0; |
| @@ -87,10 +87,34 @@ trait UserTrait | @@ -87,10 +87,34 @@ trait UserTrait | ||
| 87 | */ | 87 | */ |
| 88 | public function children(): HasMany | 88 | public function children(): HasMany |
| 89 | { | 89 | { |
| 90 | + return $this->hasMany(get_class($this), 'pid', 'id'); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * @return HasMany | ||
| 96 | + */ | ||
| 97 | + public function children1(): HasMany | ||
| 98 | + { | ||
| 90 | return $this->hasMany(get_class($this), 'gid', 'id'); | 99 | return $this->hasMany(get_class($this), 'gid', 'id'); |
| 91 | } | 100 | } |
| 92 | 101 | ||
| 93 | /** | 102 | /** |
| 103 | + * @return hasMany | ||
| 104 | + */ | ||
| 105 | + public function allChildren() | ||
| 106 | + { | ||
| 107 | + if ($this->partner == 1) { | ||
| 108 | + return $this->children()->with('allChildren'); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + return $this->children(); | ||
| 112 | + | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | +// public function team | ||
| 116 | + | ||
| 117 | + /** | ||
| 94 | * 我的详情 | 118 | * 我的详情 |
| 95 | * | 119 | * |
| 96 | * @return hasOne | 120 | * @return hasOne |
| @@ -391,6 +391,75 @@ class WechatService extends BaseService | @@ -391,6 +391,75 @@ class WechatService extends BaseService | ||
| 391 | } | 391 | } |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | + public function authLoginWithOfficialAccount1($request) | ||
| 395 | + { | ||
| 396 | + $config = [ | ||
| 397 | + 'app_id' => config('wechat.official_account.app_id'), | ||
| 398 | + 'secret' => config('wechat.official_account.secret'), | ||
| 399 | + // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名 | ||
| 400 | + 'oauth' => [ | ||
| 401 | + 'scopes' => ['snsapi_userinfo'], | ||
| 402 | + 'callback' => '/oauth_callback', | ||
| 403 | + ], | ||
| 404 | + // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名 | ||
| 405 | + 'response_type' => 'array', | ||
| 406 | + ]; | ||
| 407 | + | ||
| 408 | + $app = Factory::officialAccount($config); | ||
| 409 | + $oauth = $app->oauth; | ||
| 410 | + | ||
| 411 | + $targetUrl = urldecode($request->input('target_url')); | ||
| 412 | + | ||
| 413 | + $response = [ | ||
| 414 | + 'errcode' => 0, | ||
| 415 | + 'errmsg' => '操作成功', | ||
| 416 | + 'result' => [], | ||
| 417 | + ]; | ||
| 418 | + | ||
| 419 | + if (empty($targetUrl)) { | ||
| 420 | + $this->message = '参数错误:target_url'; | ||
| 421 | + return false; | ||
| 422 | + } | ||
| 423 | + | ||
| 424 | + // 判断用户是否已经授权 | ||
| 425 | + if (empty(session('wechat.oauth_user'))) { | ||
| 426 | + // 用户未授权,则开始授权 | ||
| 427 | + session(['wechat.oauth_target_url' => $targetUrl]); | ||
| 428 | + return $oauth->redirect(); | ||
| 429 | + } else { | ||
| 430 | + // 用户已经授权 | ||
| 431 | + $user = session('wechat.oauth_user'); | ||
| 432 | + $response['result'] = $user; | ||
| 433 | + return $response; | ||
| 434 | + } | ||
| 435 | + } | ||
| 436 | + | ||
| 437 | + public function oauthCallback() | ||
| 438 | + { | ||
| 439 | + $config = [ | ||
| 440 | + 'app_id' => config('wechat.official_account.app_id'), | ||
| 441 | + 'secret' => config('wechat.official_account.secret'), | ||
| 442 | + // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名 | ||
| 443 | + 'oauth' => [ | ||
| 444 | + 'scopes' => ['snsapi_userinfo'], | ||
| 445 | + 'callback' => '/oauth_callback', | ||
| 446 | + ], | ||
| 447 | + // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名 | ||
| 448 | + 'response_type' => 'array', | ||
| 449 | + ]; | ||
| 450 | + | ||
| 451 | + $app = Factory::officialAccount($config); | ||
| 452 | + $oauth = $app->oauth; | ||
| 453 | + $user = $oauth->user()->getOriginal(); | ||
| 454 | + $targetUrl = session('wechat.oauth_target_url'); | ||
| 455 | + | ||
| 456 | + // 将用户信息保存到session中 | ||
| 457 | + session(['wechat.oauth_user' => $user->toArray()]); | ||
| 458 | + | ||
| 459 | + return redirect($targetUrl); | ||
| 460 | + } | ||
| 461 | + | ||
| 462 | + | ||
| 394 | /** | 463 | /** |
| 395 | * 登录:公众号收取登录 | 464 | * 登录:公众号收取登录 |
| 396 | * "openid" => "oemt65wMNi7XXo76PUIrsJuoJUeA" | 465 | * "openid" => "oemt65wMNi7XXo76PUIrsJuoJUeA" |
| @@ -411,9 +480,18 @@ class WechatService extends BaseService | @@ -411,9 +480,18 @@ class WechatService extends BaseService | ||
| 411 | */ | 480 | */ |
| 412 | public function authLoginWithOfficialAccount($request) | 481 | public function authLoginWithOfficialAccount($request) |
| 413 | { | 482 | { |
| 483 | + record_log('wechat-auth', '微信公众号授权登录' , 'begin'); | ||
| 484 | + record_log('wechat-auth', '请求信息:' .json_encode($request->all())); | ||
| 485 | + $code = $request->input('code'); | ||
| 486 | + if (!$code) { | ||
| 487 | + $this->message = '授权失败,code不能为空。'; | ||
| 488 | + record_log('wechat-auth', '微信公众号授权登录' , 'end'); | ||
| 489 | + return false; | ||
| 490 | + } | ||
| 491 | + | ||
| 414 | // 正在申请 | 492 | // 正在申请 |
| 415 | $user_info = session('wechat.oauth_user.default')->original; // 拿到授权用户资料 | 493 | $user_info = session('wechat.oauth_user.default')->original; // 拿到授权用户资料 |
| 416 | - | 494 | + record_log('wechat-auth', '授权用户信息:' .json_encode($user_info)); |
| 417 | 495 | ||
| 418 | // $factory = app(WechatFactory::class); | 496 | // $factory = app(WechatFactory::class); |
| 419 | // // 公众号好手气 | 497 | // // 公众号好手气 |
| @@ -440,18 +518,35 @@ class WechatService extends BaseService | @@ -440,18 +518,35 @@ class WechatService extends BaseService | ||
| 440 | } | 518 | } |
| 441 | 519 | ||
| 442 | if ($user_info) { | 520 | if ($user_info) { |
| 521 | + $pid = $request->inviter_id ? : 0; // 邀请人id | ||
| 522 | + $gid = 0; | ||
| 523 | + if ($pid) { | ||
| 524 | + $inviter = User::find($pid); | ||
| 525 | + $gid = optional($inviter)->pid; | ||
| 526 | + } | ||
| 443 | $user->avatar = Arr::get($user_info, 'avatarUrl'); | 527 | $user->avatar = Arr::get($user_info, 'avatarUrl'); |
| 444 | $user->nickname = Arr::get($user_info, 'nickName'); | 528 | $user->nickname = Arr::get($user_info, 'nickName'); |
| 445 | $user->gender = Arr::get($user_info, 'gender'); | 529 | $user->gender = Arr::get($user_info, 'gender'); |
| 446 | $user->country = Arr::get($user_info, 'country'); | 530 | $user->country = Arr::get($user_info, 'country'); |
| 447 | $user->province = Arr::get($user_info, 'province'); | 531 | $user->province = Arr::get($user_info, 'province'); |
| 448 | $user->city = Arr::get($user_info, 'city'); | 532 | $user->city = Arr::get($user_info, 'city'); |
| 533 | + $user->times = 10; // 新用户注册赠送 10 条 | ||
| 534 | + $user->invite_qr_code = 'mini_program_code/'.$user->id .'.png'; | ||
| 535 | + $user->pid = $pid; | ||
| 536 | + $user->gid = $gid; | ||
| 537 | + $user->openid = $openid; | ||
| 538 | + $user->password = bcrypt(config('constants.PASSWORD')); | ||
| 539 | + $user->role = Role::GENERAL; | ||
| 540 | + $user->password = bcrypt(config('constants.PASSWORD')); | ||
| 541 | + $user->registered_at = date('Y-m-d H:i:s'); | ||
| 542 | + $user->registered_ip = $request->ip(); | ||
| 449 | } | 543 | } |
| 450 | $user->token = JWTAuth::fromuser($user); | 544 | $user->token = JWTAuth::fromuser($user); |
| 451 | $user->save(); | 545 | $user->save(); |
| 452 | 546 | ||
| 453 | // 记录登陆日志 | 547 | // 记录登陆日志 |
| 454 | $this->recordLoginRecord($request, $user); | 548 | $this->recordLoginRecord($request, $user); |
| 549 | + record_log('wechat-auth', '微信公众号授权登录' , 'end'); | ||
| 455 | return $user; | 550 | return $user; |
| 456 | } | 551 | } |
| 457 | 552 |
| @@ -18,7 +18,9 @@ namespace App\Transformers\User; | @@ -18,7 +18,9 @@ namespace App\Transformers\User; | ||
| 18 | 18 | ||
| 19 | use App\Models\User\Role; | 19 | use App\Models\User\Role; |
| 20 | use App\Models\User\User; | 20 | use App\Models\User\User; |
| 21 | +use App\Models\User\WalletRecord; | ||
| 21 | use App\Transformers\BaseTransformer; | 22 | use App\Transformers\BaseTransformer; |
| 23 | +use Illuminate\Support\Arr; | ||
| 22 | 24 | ||
| 23 | /** | 25 | /** |
| 24 | * Class UserTransformer. | 26 | * Class UserTransformer. |
| @@ -42,10 +44,10 @@ class UserTransformer extends BaseTransformer | @@ -42,10 +44,10 @@ class UserTransformer extends BaseTransformer | ||
| 42 | */ | 44 | */ |
| 43 | public function transform(User $model) | 45 | public function transform(User $model) |
| 44 | { | 46 | { |
| 45 | - return [ | 47 | + $output = [ |
| 46 | 'id' => (int) $model->id, | 48 | 'id' => (int) $model->id, |
| 47 | - 'username' => (string)$model->username, | ||
| 48 | - 'name' => (string)$model->name, | 49 | +// 'username' => (string)$model->username, |
| 50 | +// 'name' => (string)$model->name, | ||
| 49 | 'nickname' => (string)$model->nickname, | 51 | 'nickname' => (string)$model->nickname, |
| 50 | 'avatar' => (string)$model->avatar, | 52 | 'avatar' => (string)$model->avatar, |
| 51 | 'mobile' => (string)$model->mobile, | 53 | 'mobile' => (string)$model->mobile, |
| @@ -62,5 +64,17 @@ class UserTransformer extends BaseTransformer | @@ -62,5 +64,17 @@ class UserTransformer extends BaseTransformer | ||
| 62 | 'created_at' => format_date($model->created_at), | 64 | 'created_at' => format_date($model->created_at), |
| 63 | 'updated_at' => format_date($model->updated_at), | 65 | 'updated_at' => format_date($model->updated_at), |
| 64 | ]; | 66 | ]; |
| 67 | + | ||
| 68 | + if (request('user_id')) { | ||
| 69 | + if ($model->pid == request('user_id')) { | ||
| 70 | + $output['level'] = 1; | ||
| 71 | + $output['level_show'] = __(Arr::get(WalletRecord::EVENT_OPTIONS, WalletRecord::DIRECT)); | ||
| 72 | + } elseif ($model->gid == request('user_id')) { | ||
| 73 | + $output['level'] = 2; | ||
| 74 | + $output['level_show'] = __(Arr::get(WalletRecord::EVENT_OPTIONS, WalletRecord::INDIRECT)); | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + return $output; | ||
| 65 | } | 79 | } |
| 66 | } | 80 | } |
| @@ -164,6 +164,14 @@ return [ | @@ -164,6 +164,14 @@ return [ | ||
| 164 | 'days' => 14, | 164 | 'days' => 14, |
| 165 | 'permission'=> 0777, | 165 | 'permission'=> 0777, |
| 166 | ], | 166 | ], |
| 167 | + // 微信支付回调日志 | ||
| 168 | + 'wechat-auth' => [ | ||
| 169 | + 'driver' => 'daily', | ||
| 170 | + 'path' => storage_path('logs/wechat-auth/wechat-auth.log'), | ||
| 171 | + 'level' => 'info', | ||
| 172 | + 'days' => 14, | ||
| 173 | + 'permission'=> 0777, | ||
| 174 | + ], | ||
| 167 | ], | 175 | ], |
| 168 | 176 | ||
| 169 | ]; | 177 | ]; |
resources/views/index.blade.php
0 → 100644
| 1 | +<!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>chatApp</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)')) | ||
| 2 | + document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=./static/index.b0707a6a.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=./static/js/chunk-vendors.fc0b6f42.js></script><script src=./static/js/index.293a48ba.js></script></body></html> |
| @@ -11,7 +11,8 @@ | @@ -11,7 +11,8 @@ | ||
| 11 | | | 11 | | |
| 12 | */ | 12 | */ |
| 13 | Route::get('/', function () { | 13 | Route::get('/', function () { |
| 14 | - return view('welcome'); | 14 | + |
| 15 | + return view('index'); | ||
| 15 | }); | 16 | }); |
| 16 | 17 | ||
| 17 | Route::group(['middleware' => ['cors']], function () { | 18 | Route::group(['middleware' => ['cors']], function () { |
-
请 注册 或 登录 后发表评论