作者 lyh

gx

@@ -5,6 +5,7 @@ namespace App\Helper; @@ -5,6 +5,7 @@ namespace App\Helper;
5 use App\Models\Ai\AiCommand as AiCommandModel; 5 use App\Models\Ai\AiCommand as AiCommandModel;
6 use App\Models\User\UserLog as UserLogModel; 6 use App\Models\User\UserLog as UserLogModel;
7 use App\Models\User\UserLogin as UserLoginModel; 7 use App\Models\User\UserLogin as UserLoginModel;
  8 +use Illuminate\Encryption\Encrypter;
8 use Illuminate\Support\Facades\Cache; 9 use Illuminate\Support\Facades\Cache;
9 10
10 /** 11 /**
@@ -12,6 +13,8 @@ use Illuminate\Support\Facades\Cache; @@ -12,6 +13,8 @@ use Illuminate\Support\Facades\Cache;
12 */ 13 */
13 class Common 14 class Common
14 { 15 {
  16 + public $key = '66537a12d4fff992f6d8b67fdda6192f';
  17 + public $method = 'AES-256-CBC';
15 /** 18 /**
16 * @name :生成用户操作日志 19 * @name :生成用户操作日志
17 * @return void 20 * @return void
@@ -165,4 +168,19 @@ class Common @@ -165,4 +168,19 @@ class Common
165 $days = floor(($currentTimestamp - $targetTimestamp) / (60 * 60 * 24)); 168 $days = floor(($currentTimestamp - $targetTimestamp) / (60 * 60 * 24));
166 return (int)$days; 169 return (int)$days;
167 } 170 }
  171 +
  172 + // 生成授授权码
  173 + public function encrypt($data)
  174 + {
  175 + $crypt = new Encrypter($this->key, $this->method);
  176 + return $crypt->encrypt($data);
  177 + }
  178 +
  179 + // 解密授权码
  180 + public function decrypt($string)
  181 + {
  182 + $crypt = new Encrypter($this->key, $this->method);
  183 + return $crypt->decrypt($string);
  184 + }
  185 +
168 } 186 }
@@ -15,7 +15,7 @@ class socket @@ -15,7 +15,7 @@ class socket
15 // 创建一个Socket 15 // 创建一个Socket
16 $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); 16 $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
17 // 绑定IP地址和端口 17 // 绑定IP地址和端口
18 - socket_bind($socket, '127.0.0.1', 8080); 18 + socket_bind($socket, '127.0.0.1', 1213);
19 // 开始监听连接请求 19 // 开始监听连接请求
20 socket_listen($socket); 20 socket_listen($socket);
21 // 接受客户端连接 21 // 接受客户端连接
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 namespace App\Http\Controllers\Bside; 10 namespace App\Http\Controllers\Bside;
11 11
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
  13 +use App\Helper\Common;
13 use App\Helper\Translate; 14 use App\Helper\Translate;
14 use App\Helper\Wechat; 15 use App\Helper\Wechat;
15 use App\Http\Logic\Bside\User\UserLoginLogic; 16 use App\Http\Logic\Bside\User\UserLoginLogic;
@@ -144,4 +145,35 @@ class LoginController extends BaseController @@ -144,4 +145,35 @@ class LoginController extends BaseController
144 @file_put_contents(storage_path('logs/lyh_error.log'), $message . PHP_EOL, FILE_APPEND); 145 @file_put_contents(storage_path('logs/lyh_error.log'), $message . PHP_EOL, FILE_APPEND);
145 $this->response('success'); 146 $this->response('success');
146 } 147 }
  148 +
  149 + /**
  150 + * @remark :生成token
  151 + * @name :generateToken
  152 + * @author :lyh
  153 + * @method :post
  154 + * @time :2023/8/24 17:27
  155 + */
  156 + public function generateToken(){
  157 + $data = [
  158 + 'phone' => $this->param['phone'],
  159 + 'from_order_id' => $this->param['from_order_id'], // 提单系统 同步到个项目的唯一凭证(数字或者字符串)
  160 + 'timestamp' => time(), // 接收到字符串解密出来以后需要 验证时间不超过30秒 超过时间视为无效授权
  161 + ];
  162 + $common = new Common();
  163 + $str = $common->encrypt($data);
  164 + $this->response('success',Code::SUCCESS,['str'=>$str]);
  165 + }
  166 +
  167 + /**
  168 + * @remark :解token
  169 + * @name :globalSo_v6_login
  170 + * @author :lyh
  171 + * @method :post
  172 + * @time :2023/8/24 17:37
  173 + */
  174 + public function globalSo_v6_login(){
  175 + $common = new Common();
  176 + $arr = $common->decrypt($this->param['token']);
  177 + $this->response('success',Code::SUCCESS,$arr);
  178 + }
147 } 179 }
@@ -339,4 +339,6 @@ Route::group([], function () { @@ -339,4 +339,6 @@ Route::group([], function () {
339 Route::any('/sendLoginSms', [\App\Http\Controllers\Bside\LoginController::class, 'sendLoginSms'])->name('sendLoginSms'); 339 Route::any('/sendLoginSms', [\App\Http\Controllers\Bside\LoginController::class, 'sendLoginSms'])->name('sendLoginSms');
340 Route::any('/autologin', [\App\Http\Controllers\Bside\LoginController::class, 'autologin'])->name('autologin'); 340 Route::any('/autologin', [\App\Http\Controllers\Bside\LoginController::class, 'autologin'])->name('autologin');
341 Route::any('/qrcode', [\App\Http\Controllers\Bside\LoginController::class, 'qrcode'])->name('qrcode'); 341 Route::any('/qrcode', [\App\Http\Controllers\Bside\LoginController::class, 'qrcode'])->name('qrcode');
  342 + Route::any('/generateToken', [\App\Http\Controllers\Bside\LoginController::class, 'generateToken'])->name('generateToken');
  343 + Route::any('/globalSo_v6_login', [\App\Http\Controllers\Bside\LoginController::class, 'globalSo_v6_login'])->name('globalSo_v6_login');
342 }); 344 });
@@ -9,3 +9,4 @@ use Illuminate\Support\Facades\Route; @@ -9,3 +9,4 @@ use Illuminate\Support\Facades\Route;
9 * @time :2023/8/24 10:14 9 * @time :2023/8/24 10:14
10 */ 10 */
11 Route::any('/eventmessage', [\App\Http\Controllers\Bside\LoginController::class, 'eventMessage'])->name('eventMessage'); 11 Route::any('/eventmessage', [\App\Http\Controllers\Bside\LoginController::class, 'eventMessage'])->name('eventMessage');
  12 +