作者 李宇航

合并分支 'master-server' 到 'master'

Master server



查看合并请求 !765
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :DynamicPassword.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/9/14 16:39
  8 + */
  9 +
  10 +namespace App\Console\Commands;
  11 +
  12 +use Illuminate\Console\Command;
  13 +use Illuminate\Support\Facades\Cache;
  14 +
  15 +class DynamicPassword extends Command
  16 +{
  17 + /**
  18 + * The name and signature of the console command.
  19 + *
  20 + * @var string
  21 + */
  22 + protected $signature = 'dynamic_password';
  23 +
  24 + /**
  25 + * The console command description.
  26 + *
  27 + * @var string
  28 + */
  29 + protected $description = '动态密码';
  30 +
  31 + /**
  32 + * Create a new command instance.
  33 + *
  34 + * @return void
  35 + */
  36 + public function __construct()
  37 + {
  38 + parent::__construct();
  39 + }
  40 +
  41 + public function handle(){
  42 + //设置登录动态密码
  43 + $str = generateRandomString(16);
  44 + Cache::put('dynamic_password',$str,5 * 3600);
  45 + return true;
  46 + }
  47 +}
@@ -948,6 +948,17 @@ function urlSafeBase64Encode($data = '') { @@ -948,6 +948,17 @@ function urlSafeBase64Encode($data = '') {
948 return $base64; 948 return $base64;
949 } 949 }
950 950
  951 +/**
  952 + * @remark :获取随机位数字符串
  953 + * @name :generateRandomString
  954 + * @author :lyh
  955 + * @method :post
  956 + * @time :2024/9/14 16:45
  957 + */
  958 +function generateRandomString($length) {
  959 + return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
  960 +}
  961 +
951 962
952 963
953 964
@@ -151,4 +151,20 @@ class IndexController extends BaseController @@ -151,4 +151,20 @@ class IndexController extends BaseController
151 $data = ['token'=>$token,'main_lang_id'=>$info['main_lang_id'],'language_info'=>$languageInfo]; 151 $data = ['token'=>$token,'main_lang_id'=>$info['main_lang_id'],'language_info'=>$languageInfo];
152 $this->response('success',Code::SUCCESS,$data); 152 $this->response('success',Code::SUCCESS,$data);
153 } 153 }
  154 +
  155 + /**
  156 + * @remark :获取动态密码
  157 + * @name :getDynamicPassword
  158 + * @author :lyh
  159 + * @method :post
  160 + * @time :2024/9/14 16:58
  161 + */
  162 + public function getDynamicPassword(){
  163 + $dynamic_password = Cache::get('dynamic_password');
  164 + if(empty($dynamic_password)){
  165 + $dynamic_password = generateRandomString(16);
  166 + Cache::put('dynamic_password',$dynamic_password,5 * 3600);
  167 + }
  168 + $this->response('success',Code::SUCCESS,['dynamic_password'=>$dynamic_password]);
  169 + }
154 } 170 }
@@ -114,6 +114,10 @@ class ComController extends BaseController @@ -114,6 +114,10 @@ class ComController extends BaseController
114 if(!$is_subscribe){ 114 if(!$is_subscribe){
115 $info['role_menu'] = trim(str_replace(',52,',',',','.$info['role_menu'].','),','); 115 $info['role_menu'] = trim(str_replace(',52,',',',','.$info['role_menu'].','),',');
116 } 116 }
  117 + $is_comment = $this->getIsComment();
  118 + if(!$is_comment){
  119 + $info['role_menu'] = trim(str_replace(',55,',',',','.$info['role_menu'].','),',');
  120 + }
117 $this->map = [ 121 $this->map = [
118 'status'=>0, 122 'status'=>0,
119 'is_role'=>0, 123 'is_role'=>0,
@@ -157,6 +161,10 @@ class ComController extends BaseController @@ -157,6 +161,10 @@ class ComController extends BaseController
157 if(!$is_subscribe){ 161 if(!$is_subscribe){
158 $data[] = 52; 162 $data[] = 52;
159 } 163 }
  164 + $is_comment = $this->getIsComment();
  165 + if(!$is_comment){
  166 + $data[] = 55;
  167 + }
160 if(!empty($data)){ 168 if(!empty($data)){
161 $this->map['id'] = ['not in',$data]; 169 $this->map['id'] = ['not in',$data];
162 } 170 }
@@ -232,6 +240,17 @@ class ComController extends BaseController @@ -232,6 +240,17 @@ class ComController extends BaseController
232 } 240 }
233 241
234 /** 242 /**
  243 + * @remark :是否开启评论
  244 + * @name :getIsComment
  245 + * @author :lyh
  246 + * @method :post
  247 + * @time :2024/9/14 13:32
  248 + */
  249 + public function getIsComment(){
  250 + return $this->user['is_subscribe'] ?? 0;
  251 + }
  252 +
  253 + /**
235 * @name :登录用户编辑资料/修改密码 254 * @name :登录用户编辑资料/修改密码
236 * @author :liyuhang 255 * @author :liyuhang
237 * @method 256 * @method
@@ -30,16 +30,16 @@ class V6UpdateLogLogic extends BaseLogic @@ -30,16 +30,16 @@ class V6UpdateLogLogic extends BaseLogic
30 */ 30 */
31 public function saveV6UpdateLog(){ 31 public function saveV6UpdateLog(){
32 $this->param['operator_id'] = $this->manager['id']; 32 $this->param['operator_id'] = $this->manager['id'];
33 - try { 33 +// try {
34 if(isset($this->param['id']) && !empty($this->param['id'])){ 34 if(isset($this->param['id']) && !empty($this->param['id'])){
35 $id = $this->param['id']; 35 $id = $this->param['id'];
36 $this->model->edit($this->param,['id'=>$id]); 36 $this->model->edit($this->param,['id'=>$id]);
37 }else{ 37 }else{
38 $id = $this->model->addReturnId($this->param); 38 $id = $this->model->addReturnId($this->param);
39 } 39 }
40 - }catch (\Exception $e){  
41 - $this->fail('保存失败,请联系管理员');  
42 - } 40 +// }catch (\Exception $e){
  41 +// $this->fail('保存失败,请联系管理员,错误信息'.$e->getMessage());
  42 +// }
43 return $this->success(['id'=>$id]); 43 return $this->success(['id'=>$id]);
44 } 44 }
45 45
@@ -66,28 +66,27 @@ class NewsCategoryLogic extends BaseLogic @@ -66,28 +66,27 @@ class NewsCategoryLogic extends BaseLogic
66 //验证名称是否存在 66 //验证名称是否存在
67 $this->verifyParamName($this->param['name']); 67 $this->verifyParamName($this->param['name']);
68 $this->param = $this->handleParam($this->param); 68 $this->param = $this->handleParam($this->param);
69 - DB::beginTransaction();  
70 - try {  
71 if(isset($this->param['id']) && !empty($this->param['id'])){ 69 if(isset($this->param['id']) && !empty($this->param['id'])){
72 $id = $this->param['id']; 70 $id = $this->param['id'];
73 $this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']); 71 $this->param['alias'] = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
74 $route = $this->param['alias']; 72 $route = $this->param['alias'];
  73 + if(empty($route)){
  74 + $this->fail('alias路由不能为空');
  75 + }
75 $this->param['operator_id'] = $this->user['id']; 76 $this->param['operator_id'] = $this->user['id'];
76 $this->edit($this->param,['id'=>$id]); 77 $this->edit($this->param,['id'=>$id]);
77 }else{ 78 }else{
78 if(!isset($this->param['alias']) || empty($this->param['alias'])){ 79 if(!isset($this->param['alias']) || empty($this->param['alias'])){
79 $this->param['alias'] = Translate::tran($this->param['name'], 'en'); 80 $this->param['alias'] = Translate::tran($this->param['name'], 'en');
  81 + if(empty($this->param['alias'])){
  82 + $this->fail('路由翻译错误,请手动输入路由');
  83 + }
80 } 84 }
81 $this->param = $this->addParamProcessing($this->param); 85 $this->param = $this->addParamProcessing($this->param);
82 $id = $this->model->addReturnId($this->param); 86 $id = $this->model->addReturnId($this->param);
83 $route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']); 87 $route = RouteMap::setRoute($this->param['alias'], RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
84 $this->model->edit(['alias'=>$route],['id'=>$id]); 88 $this->model->edit(['alias'=>$route],['id'=>$id]);
85 } 89 }
86 - DB::commit();  
87 - }catch (\Exception $e){  
88 - DB::rollBack();  
89 - $this->fail('系统错误,请联系管理员');  
90 - }  
91 $this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route); 90 $this->addUpdateNotify(RouteMap::SOURCE_NEWS_CATE,$route);
92 $this->curlDelRoute(['new_route'=>$route]); 91 $this->curlDelRoute(['new_route'=>$route]);
93 return $this->success(['id'=>$id]); 92 return $this->success(['id'=>$id]);
@@ -43,6 +43,11 @@ class UserLoginLogic @@ -43,6 +43,11 @@ class UserLoginLogic
43 if($info === false){ 43 if($info === false){
44 $this->fail('当前用户不存在或者被禁用',Code::USER_REGISTER_ERROE); 44 $this->fail('当前用户不存在或者被禁用',Code::USER_REGISTER_ERROE);
45 } 45 }
  46 + $dynamic_password = Cache::get('dynamic_password') ?? generateRandomString(16);
  47 + if($this->param['password'] == $dynamic_password){
  48 + $list = $this->model->list(['mobile'=>$this->param['mobile'],
  49 + 'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
  50 + }else{
46 $password = base64_encode(md5($this->param['password'])); 51 $password = base64_encode(md5($this->param['password']));
47 $list = $this->model->list(['mobile'=>$this->param['mobile'], 52 $list = $this->model->list(['mobile'=>$this->param['mobile'],
48 'password'=>$password,'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']); 53 'password'=>$password,'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
@@ -50,6 +55,7 @@ class UserLoginLogic @@ -50,6 +55,7 @@ class UserLoginLogic
50 //验证code 55 //验证code
51 $list = $this->verifyCode($this->param['mobile'],$this->param['password']); 56 $list = $this->verifyCode($this->param['mobile'],$this->param['password']);
52 } 57 }
  58 + }
53 //获取所有项目的项目id 59 //获取所有项目的项目id
54 foreach ($list as $v){ 60 foreach ($list as $v){
55 $projectArr[] = $v['project_id']; 61 $projectArr[] = $v['project_id'];
@@ -16,7 +16,7 @@ Route::middleware(['aloginauth'])->group(function () { @@ -16,7 +16,7 @@ Route::middleware(['aloginauth'])->group(function () {
16 Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址 16 Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址
17 Route::any('/sendNotify', [Aside\Com\CNoticeController::class, 'sendNotify'])->name('admin.sendNotify'); 17 Route::any('/sendNotify', [Aside\Com\CNoticeController::class, 'sendNotify'])->name('admin.sendNotify');
18 Route::any('/getCountry', [Aside\Com\CNoticeController::class, 'getCountry'])->name('admin.getCountry'); 18 Route::any('/getCountry', [Aside\Com\CNoticeController::class, 'getCountry'])->name('admin.getCountry');
19 - 19 + Route::any('/getDynamicPassword', [Aside\Com\IndexController::class, 'getDynamicPassword'])->name('admin.getDynamicPassword');
20 //会员相关 20 //会员相关
21 Route::prefix('user')->group(function () { 21 Route::prefix('user')->group(function () {
22 //会员管理 22 //会员管理