正在显示
1 个修改的文件
包含
73 行增加
和
13 行删除
| @@ -21,8 +21,11 @@ use App\Models\Project\Payment; | @@ -21,8 +21,11 @@ use App\Models\Project\Payment; | ||
| 21 | use App\Models\Project\Project; | 21 | use App\Models\Project\Project; |
| 22 | use App\Models\Project\ProjectAiSetting; | 22 | use App\Models\Project\ProjectAiSetting; |
| 23 | use App\Models\Project\ProjectWhiteHatAffix; | 23 | use App\Models\Project\ProjectWhiteHatAffix; |
| 24 | +use App\Models\RouteMap\RouteMap; | ||
| 24 | use App\Models\Template\BTemplateMain; | 25 | use App\Models\Template\BTemplateMain; |
| 25 | use App\Models\Template\TemplateTypeMain; | 26 | use App\Models\Template\TemplateTypeMain; |
| 27 | +use App\Models\WebSetting\Translate; | ||
| 28 | +use App\Models\WebSetting\TranslateData; | ||
| 26 | use App\Models\WebSetting\WebSetting; | 29 | use App\Models\WebSetting\WebSetting; |
| 27 | use App\Models\WorkOrder\TicketLog; | 30 | use App\Models\WorkOrder\TicketLog; |
| 28 | use App\Models\WorkOrder\Tickets; | 31 | use App\Models\WorkOrder\Tickets; |
| @@ -51,18 +54,7 @@ class lyhDemo extends Command | @@ -51,18 +54,7 @@ class lyhDemo extends Command | ||
| 51 | protected $description = '更新路由'; | 54 | protected $description = '更新路由'; |
| 52 | 55 | ||
| 53 | public function handle(){ | 56 | public function handle(){ |
| 54 | - $projectModel = new Payment(); | ||
| 55 | - $lists = $projectModel->list(['renewal_record'=>['not like','"expire_at": null']]); | ||
| 56 | - foreach ($lists as $item){ | ||
| 57 | - foreach ($item['renewal_record'] as $key => $val){ | ||
| 58 | - if(!isset($val['end_time']) && !empty($val['expire_at'])){ | ||
| 59 | - $val['end_time'] = $val['expire_at']; | ||
| 60 | - } | ||
| 61 | - $item['renewal_record'][$key] = $val; | ||
| 62 | - } | ||
| 63 | - $projectModel->edit(['renewal_record'=>json_encode($item['renewal_record'],true)],['id'=>$item['id']]); | ||
| 64 | - } | ||
| 65 | - return true; | 57 | + return $this->translate_action(); |
| 66 | } | 58 | } |
| 67 | 59 | ||
| 68 | /** | 60 | /** |
| @@ -245,9 +237,77 @@ class lyhDemo extends Command | @@ -245,9 +237,77 @@ class lyhDemo extends Command | ||
| 245 | echo "字段 $field 小写替换出错:" . $e->getMessage() . PHP_EOL; | 237 | echo "字段 $field 小写替换出错:" . $e->getMessage() . PHP_EOL; |
| 246 | } | 238 | } |
| 247 | } | 239 | } |
| 248 | - | ||
| 249 | echo '执行结束' . PHP_EOL; | 240 | echo '执行结束' . PHP_EOL; |
| 241 | + DB::disconnect('custom_mysql'); | ||
| 242 | + } | ||
| 250 | 243 | ||
| 244 | + public function translate_action() | ||
| 245 | + { | ||
| 246 | + ProjectServer::useProject(655); | ||
| 247 | + $this->model = new Translate(); | ||
| 248 | + $lists = DB::connection('custom_mysql')->table('gl_translate_copy1')->where('url','!=','All')->get(); | ||
| 249 | + foreach ($lists as $item) { | ||
| 250 | + $sourceInfo = $this->getRouteSource($item['url']); | ||
| 251 | + $info = $this->model->read(['language_id'=>$item['language_id'],'source_id'=>$sourceInfo['source_id'],'url'=>$item['url'],'project_id'=>655,'type'=>$item['type']]); | ||
| 252 | + if($info === false){ | ||
| 253 | + $param = [ | ||
| 254 | + 'type'=>$item['type'] ?? 1, | ||
| 255 | + 'project_id'=>655, | ||
| 256 | + 'url'=>$item['url'], | ||
| 257 | + 'language_id'=>$item['language_id'], | ||
| 258 | + 'alias'=>$item['alias'], | ||
| 259 | + 'source'=>$sourceInfo['source'], | ||
| 260 | + 'source_id'=>$sourceInfo['source_id'], | ||
| 261 | + 'is_list'=>$sourceInfo['is_list'], | ||
| 262 | + 'is_custom'=>$sourceInfo['is_custom'], | ||
| 263 | + 'page'=>$sendData['page'] ?? 0 | ||
| 264 | + ]; | ||
| 265 | + $id = $this->model->addReturnId($param); | ||
| 266 | + TranslateData::insert(['trans_id'=>$id,'data'=>$item['data']]); | ||
| 267 | + }else{ | ||
| 268 | + TranslateData::where(['trans_id'=>$info['id']])->update(['data'=>$item['data']]); | ||
| 269 | + } | ||
| 270 | + } | ||
| 251 | DB::disconnect('custom_mysql'); | 271 | DB::disconnect('custom_mysql'); |
| 252 | } | 272 | } |
| 273 | + | ||
| 274 | + public function getRouteSource($route){ | ||
| 275 | + $routes = $route; | ||
| 276 | + $data = ['source'=>0,'source_id'=>0,'is_list'=>0,'is_custom'=>0,'page'=>0]; | ||
| 277 | + if(strtolower($route) == 'all'){ | ||
| 278 | + return $this->success($data); | ||
| 279 | + } | ||
| 280 | + if($route == 'index' || $route == '/'){ | ||
| 281 | + $data['source'] = 1; | ||
| 282 | + return $this->success($data); | ||
| 283 | + } | ||
| 284 | + $route = basename($route); | ||
| 285 | + $page = 0; | ||
| 286 | + if (is_numeric($route)) { | ||
| 287 | + $arr = explode('/',$routes); | ||
| 288 | + $page = $route; | ||
| 289 | + $route = $arr[0]; | ||
| 290 | + } | ||
| 291 | + $routeModel = new RouteMap(); | ||
| 292 | + $routeInfo = $routeModel->read(['route'=>$route]); | ||
| 293 | + if($routeInfo === false){ | ||
| 294 | + if(in_array($route,['products','news','blog'])){ | ||
| 295 | + //固定路由 | ||
| 296 | + $data['page'] = $page; | ||
| 297 | + $data['is_list'] = 1; | ||
| 298 | + if($route == 'products'){ | ||
| 299 | + $data['source'] = 2; | ||
| 300 | + }elseif ($route == 'news'){ | ||
| 301 | + $data['source'] = 4; | ||
| 302 | + }else{ | ||
| 303 | + $data['source'] = 3; | ||
| 304 | + } | ||
| 305 | + return $this->success($data); | ||
| 306 | + } | ||
| 307 | + return $data; | ||
| 308 | + } | ||
| 309 | + $data = $this->resultData($routeInfo,$data); | ||
| 310 | + $data['page'] = $page; | ||
| 311 | + return $data; | ||
| 312 | + } | ||
| 253 | } | 313 | } |
-
请 注册 或 登录 后发表评论