Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
8 个修改的文件
包含
245 行增加
和
7 行删除
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands\Domain; | ||
| 4 | + | ||
| 5 | +use App\Models\Devops\ServersIp; | ||
| 6 | +use App\Services\AlibabaCloudService; | ||
| 7 | +use Illuminate\Console\Command; | ||
| 8 | + | ||
| 9 | +class EmergencyRecords extends Command | ||
| 10 | +{ | ||
| 11 | + protected $signature = 'emergency_records {server_id} {type}'; | ||
| 12 | + protected $description = '紧急修改域名解析'; | ||
| 13 | + | ||
| 14 | + public function handle() | ||
| 15 | + { | ||
| 16 | + //服务器id | ||
| 17 | + $server_id = $this->argument('server_id'); | ||
| 18 | + //类型,1受灾,2恢复 | ||
| 19 | + $type = $this->argument('type'); | ||
| 20 | + | ||
| 21 | + try { | ||
| 22 | + //获取服务器的所有可用ip | ||
| 23 | + $server_ip_model = new ServersIp(); | ||
| 24 | + $server_ip_list = $server_ip_model->where('servers_id', $server_id)->where('status', 0)->get(); | ||
| 25 | + if ($server_ip_list->count() > 0) { | ||
| 26 | + foreach ($server_ip_list as $value) { | ||
| 27 | + if (empty($value->ip) || empty($value->domain)) { | ||
| 28 | + $this->output('ID ' . $value->id . ' 数据错误'); | ||
| 29 | + continue; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + //获取解析记录 | ||
| 33 | + $domain_array = explode('.', $value->domain); | ||
| 34 | + $domain_rr = $domain_array[0]; | ||
| 35 | + $record = AlibabaCloudService::describeDomainRecords('globalso.com', $domain_rr); | ||
| 36 | + $record_status_code = $record['statusCode'] ?? 0; | ||
| 37 | + if ($record_status_code != 200) { | ||
| 38 | + $this->output('获取主机记录 ' . $domain_rr . ' 解析数据失败'); | ||
| 39 | + continue; | ||
| 40 | + } | ||
| 41 | + $record_detail = $record['body']['DomainRecords']['Record'][0] ?? []; | ||
| 42 | + if (!$record_detail) { | ||
| 43 | + $this->output('主机记录 ' . $domain_rr . ' 解析数据不存在'); | ||
| 44 | + continue; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + //目标ip跟解析记录当前ip一样的数据,不用修改 | ||
| 48 | + $target_ip = $type == 1 ? '43.153.1.240' : $value->ip; | ||
| 49 | + if ($target_ip == $record_detail['Value']) { | ||
| 50 | + $this->output('主机记录 ' . $domain_rr . ' 的值已为 ' . $target_ip); | ||
| 51 | + continue; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + //修改解析记录 | ||
| 55 | + $record_id = $record_detail['RecordId']; | ||
| 56 | + $record_rr = $record_detail['RR']; | ||
| 57 | + $record_type = $record_detail['Type']; | ||
| 58 | + | ||
| 59 | + $record_edit = AlibabaCloudService::updateDomainRecord($record_id, $record_rr, $record_type, $target_ip); | ||
| 60 | + $record_edit_status_code = $record_edit['statusCode'] ?? 0; | ||
| 61 | + if ($record_edit_status_code == 200) { | ||
| 62 | + $this->output('修改主机记录 ' . $record_rr . ' 的值为 ' . $target_ip . ' 成功'); | ||
| 63 | + } else { | ||
| 64 | + $this->output('修改主机记录 ' . $record_rr . ' 的值为 ' . $target_ip . ' 失败'); | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + } catch (\Exception $e) { | ||
| 69 | + $this->output($e->getMessage()); | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * 输出处理日志 | ||
| 75 | + * @param $message | ||
| 76 | + */ | ||
| 77 | + public function output($message) | ||
| 78 | + { | ||
| 79 | + echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL; | ||
| 80 | + } | ||
| 81 | +} |
| @@ -275,7 +275,11 @@ class VideoTask extends Command | @@ -275,7 +275,11 @@ class VideoTask extends Command | ||
| 275 | } | 275 | } |
| 276 | }else{ | 276 | }else{ |
| 277 | $product_all_id = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20)->pluck('id')->toArray(); | 277 | $product_all_id = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->inRandomOrder()->take(20)->pluck('id')->toArray(); |
| 278 | - $products = Product::whereIn("id", $product_all_id)->orderByRaw(DB::raw("FIELD(id, " . implode(',', $product_all_id) . ")"))->get(); | 278 | + if(empty($product_all_id)){ |
| 279 | + $products = []; | ||
| 280 | + }else{ | ||
| 281 | + $products = Product::whereIn("id", $product_all_id)->orderByRaw(DB::raw("FIELD(id, " . implode(',', $product_all_id) . ")"))->get(); | ||
| 282 | + } | ||
| 279 | } | 283 | } |
| 280 | $data = []; | 284 | $data = []; |
| 281 | if (!empty($products)){ | 285 | if (!empty($products)){ |
| @@ -72,7 +72,7 @@ class RankData extends BaseCommands | @@ -72,7 +72,7 @@ class RankData extends BaseCommands | ||
| 72 | } | 72 | } |
| 73 | } | 73 | } |
| 74 | return !$error; | 74 | return !$error; |
| 75 | - } catch (\Exception $e) { | 75 | + } catch (\Exception|\Throwable $e) { |
| 76 | Log::channel('rank_data')->error('排名数据任务失败 ' . $e->getMessage()); | 76 | Log::channel('rank_data')->error('排名数据任务失败 ' . $e->getMessage()); |
| 77 | throw new \Exception($e->getMessage()); | 77 | throw new \Exception($e->getMessage()); |
| 78 | } | 78 | } |
| @@ -12,6 +12,8 @@ namespace App\Http\Controllers\Bside\BCom; | @@ -12,6 +12,8 @@ namespace App\Http\Controllers\Bside\BCom; | ||
| 12 | use App\Enums\Common\Code; | 12 | use App\Enums\Common\Code; |
| 13 | use App\Http\Controllers\Bside\BaseController; | 13 | use App\Http\Controllers\Bside\BaseController; |
| 14 | use App\Models\Log\OperationHeartbeat; | 14 | use App\Models\Log\OperationHeartbeat; |
| 15 | +use App\Models\Manage\Manage; | ||
| 16 | +use App\Models\User\User; | ||
| 15 | 17 | ||
| 16 | class OperationHeartbeatController extends BaseController | 18 | class OperationHeartbeatController extends BaseController |
| 17 | { | 19 | { |
| @@ -36,6 +38,7 @@ class OperationHeartbeatController extends BaseController | @@ -36,6 +38,7 @@ class OperationHeartbeatController extends BaseController | ||
| 36 | 'is_custom.required' => '是否为扩展模版', | 38 | 'is_custom.required' => '是否为扩展模版', |
| 37 | 'is_template.required' => '详情页/可视化', | 39 | 'is_template.required' => '详情页/可视化', |
| 38 | ]); | 40 | ]); |
| 41 | + | ||
| 39 | $condition = ['project_id'=>$this->user['project_id'],'source'=>$this->param['source'],'source_id'=>$this->param['source_id'], | 42 | $condition = ['project_id'=>$this->user['project_id'],'source'=>$this->param['source'],'source_id'=>$this->param['source_id'], |
| 40 | 'is_list'=>$this->param['is_list'],'is_custom'=>$this->param['is_custom'],'is_template'=>$this->param['is_template']]; | 43 | 'is_list'=>$this->param['is_list'],'is_custom'=>$this->param['is_custom'],'is_template'=>$this->param['is_template']]; |
| 41 | $operationHeartbeatModel = new OperationHeartbeat(); | 44 | $operationHeartbeatModel = new OperationHeartbeat(); |
| @@ -44,9 +47,11 @@ class OperationHeartbeatController extends BaseController | @@ -44,9 +47,11 @@ class OperationHeartbeatController extends BaseController | ||
| 44 | if($info === false){ | 47 | if($info === false){ |
| 45 | $condition['operator_id'] = $this->user['id']; | 48 | $condition['operator_id'] = $this->user['id']; |
| 46 | $condition['project_id'] = $this->user['project_id']; | 49 | $condition['project_id'] = $this->user['project_id']; |
| 50 | + $condition['ip'] = $this->request->ip(); | ||
| 51 | + $condition['manager_id'] = $this->user['manager_id'] ?? 0; | ||
| 47 | $operationHeartbeatModel->addReturnId($condition); | 52 | $operationHeartbeatModel->addReturnId($condition); |
| 48 | }else{ | 53 | }else{ |
| 49 | - $operationHeartbeatModel->edit(['status'=>$condition['status'] ?? 0],['id'=>$info['id']]); | 54 | + $operationHeartbeatModel->edit(['status'=>$condition['status'] ?? 0,'ip'=>$this->request->ip(),'manager_id'=> $this->user['manager_id'] ?? 0],['id'=>$info['id']]); |
| 50 | } | 55 | } |
| 51 | $this->response('success'); | 56 | $this->response('success'); |
| 52 | } | 57 | } |
| @@ -81,10 +86,28 @@ class OperationHeartbeatController extends BaseController | @@ -81,10 +86,28 @@ class OperationHeartbeatController extends BaseController | ||
| 81 | }else{ | 86 | }else{ |
| 82 | $date_time = strtotime($info['updated_at']) + 7200; | 87 | $date_time = strtotime($info['updated_at']) + 7200; |
| 83 | if($date_time < time()){ | 88 | if($date_time < time()){ |
| 84 | - $operationHeartbeatModel->edit(['status'=>0],$condition); | 89 | + $operationHeartbeatModel->edit(['status'=>0,'ip'=>'127.0.0.1'],$condition); |
| 85 | $info['status'] = 0; | 90 | $info['status'] = 0; |
| 86 | } | 91 | } |
| 87 | } | 92 | } |
| 93 | + if($info['status'] == 1){ | ||
| 94 | + //当前登录为切入登录 | ||
| 95 | + if(isset($this->user['manager_id']) && !empty($this->user['manager_id'])){ | ||
| 96 | + //上一次验证也是切入登录 | ||
| 97 | + if($info['manager_id'] != 0){ | ||
| 98 | + $managerModel = new Manage(); | ||
| 99 | + $managerInfo = $managerModel->read(['id'=>$info['manager_id']],['name']); | ||
| 100 | + $info['message'] = '此页面数据已有人在编辑,请勿重复操作!操作人ip:'.$info['ip'].'操作的管理员为:'.$managerInfo['name']; | ||
| 101 | + }else{ | ||
| 102 | + //账号密码登录 | ||
| 103 | + $userModel = new User(); | ||
| 104 | + $userInfo = $userModel->read(['id'=>$info['operator_id']],['name']); | ||
| 105 | + $info['message'] = '此页面数据已有人在编辑,请勿重复操作!'.$userInfo['name'].'用户登录在操作。'; | ||
| 106 | + } | ||
| 107 | + }else{ | ||
| 108 | + $info['message'] = '此页面数据已有人在编辑,请勿重复操作!'; | ||
| 109 | + } | ||
| 110 | + } | ||
| 88 | $this->response('success',Code::SUCCESS,$info); | 111 | $this->response('success',Code::SUCCESS,$info); |
| 89 | } | 112 | } |
| 90 | } | 113 | } |
| @@ -186,8 +186,8 @@ class InquiryLogic extends BaseLogic | @@ -186,8 +186,8 @@ class InquiryLogic extends BaseLogic | ||
| 186 | public function sendMobileVerifyData($phone){ | 186 | public function sendMobileVerifyData($phone){ |
| 187 | $phoneDataModel = new PhoneData(); | 187 | $phoneDataModel = new PhoneData(); |
| 188 | $num_phone = preg_replace('/\D/', '',$phone) ?? ''; // \D 匹配所有非数字字符 | 188 | $num_phone = preg_replace('/\D/', '',$phone) ?? ''; // \D 匹配所有非数字字符 |
| 189 | - $info = $phoneDataModel->read(['phone'=>$num_phone]); | ||
| 190 | - if($info === false){ | 189 | + $data = $phoneDataModel->read(['phone'=>$num_phone]); |
| 190 | + if($data === false){ | ||
| 191 | $url = 'https://fob.ai.cc/api/mobile_verify_data/'.$phone; | 191 | $url = 'https://fob.ai.cc/api/mobile_verify_data/'.$phone; |
| 192 | $data = http_get($url); | 192 | $data = http_get($url); |
| 193 | if(!empty($data)){ | 193 | if(!empty($data)){ |
app/Services/AlibabaCloudService.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Services; | ||
| 4 | + | ||
| 5 | +use AlibabaCloud\SDK\Alidns\V20150109\Alidns; | ||
| 6 | +use AlibabaCloud\SDK\Alidns\V20150109\Models\AddDomainRecordRequest; | ||
| 7 | +use AlibabaCloud\SDK\Alidns\V20150109\Models\DescribeDomainRecordsRequest; | ||
| 8 | +use AlibabaCloud\SDK\Alidns\V20150109\Models\UpdateDomainRecordRemarkRequest; | ||
| 9 | +use AlibabaCloud\SDK\Alidns\V20150109\Models\UpdateDomainRecordRequest; | ||
| 10 | +use AlibabaCloud\Tea\Utils\Utils; | ||
| 11 | +use Darabonba\OpenApi\Models\Config; | ||
| 12 | + | ||
| 13 | +class AlibabaCloudService | ||
| 14 | +{ | ||
| 15 | + /** | ||
| 16 | + * 创建客户端 | ||
| 17 | + * @return Alidns | ||
| 18 | + * @author Akun | ||
| 19 | + * @date 2024/09/21 16:16 | ||
| 20 | + */ | ||
| 21 | + public static function createClient() | ||
| 22 | + { | ||
| 23 | + $config = new Config([ | ||
| 24 | + 'accessKeyId' => env('ALIBABA_CLOUD_KEY'), | ||
| 25 | + 'accessKeySecret' => env('ALIBABA_CLOUD_SECRET'), | ||
| 26 | + ]); | ||
| 27 | + | ||
| 28 | + return new Alidns($config); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 获取域名解析记录列表 | ||
| 33 | + * @param $domain | ||
| 34 | + * @param $keyword | ||
| 35 | + * @param $status | ||
| 36 | + * @return array | ||
| 37 | + * @author Akun | ||
| 38 | + * @date 2024/09/21 17:19 | ||
| 39 | + */ | ||
| 40 | + public static function describeDomainRecords($domain, $keyword, $status = 'Enable') | ||
| 41 | + { | ||
| 42 | + $client = self::createClient(); | ||
| 43 | + | ||
| 44 | + $request = new DescribeDomainRecordsRequest([ | ||
| 45 | + 'domainName' => $domain, | ||
| 46 | + 'RRKeyWord' => $keyword, | ||
| 47 | + 'status' => $status, | ||
| 48 | + ]); | ||
| 49 | + | ||
| 50 | + $response = $client->DescribeDomainRecords($request); | ||
| 51 | + | ||
| 52 | + return Utils::toArray($response); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * 添加解析记录 | ||
| 57 | + * @param $domain | ||
| 58 | + * @param $rr | ||
| 59 | + * @param $type | ||
| 60 | + * @param $value | ||
| 61 | + * @return array | ||
| 62 | + * @author Akun | ||
| 63 | + * @date 2024/09/21 17:33 | ||
| 64 | + */ | ||
| 65 | + public static function addDomainRecord($domain, $rr, $type, $value) | ||
| 66 | + { | ||
| 67 | + $client = self::createClient(); | ||
| 68 | + | ||
| 69 | + $request = new AddDomainRecordRequest([ | ||
| 70 | + 'domainName' => $domain, | ||
| 71 | + 'RR' => $rr, | ||
| 72 | + 'type' => $type, | ||
| 73 | + 'value' => $value | ||
| 74 | + ]); | ||
| 75 | + | ||
| 76 | + $response = $client->AddDomainRecord($request); | ||
| 77 | + | ||
| 78 | + return Utils::toArray($response); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + /** | ||
| 82 | + * 修改解析记录备注 | ||
| 83 | + * @param $record_id | ||
| 84 | + * @param $remark | ||
| 85 | + * @return array | ||
| 86 | + * @author Akun | ||
| 87 | + * @date 2024/09/21 17:38 | ||
| 88 | + */ | ||
| 89 | + public static function updateDomainRecordRemark($record_id, $remark) | ||
| 90 | + { | ||
| 91 | + $client = self::createClient(); | ||
| 92 | + | ||
| 93 | + $request = new UpdateDomainRecordRemarkRequest([ | ||
| 94 | + 'recordId' => $record_id, | ||
| 95 | + 'remark' => $remark, | ||
| 96 | + ]); | ||
| 97 | + | ||
| 98 | + $response = $client->UpdateDomainRecordRemark($request); | ||
| 99 | + | ||
| 100 | + return Utils::toArray($response); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + /** | ||
| 104 | + * 修改解析记录详情 | ||
| 105 | + * @param $record_id | ||
| 106 | + * @param $rr | ||
| 107 | + * @param $type | ||
| 108 | + * @param $value | ||
| 109 | + * @return array | ||
| 110 | + * @author Akun | ||
| 111 | + * @date 2024/09/23 10:55 | ||
| 112 | + */ | ||
| 113 | + public static function updateDomainRecord($record_id, $rr, $type, $value) | ||
| 114 | + { | ||
| 115 | + $client = self::createClient(); | ||
| 116 | + | ||
| 117 | + $request = new UpdateDomainRecordRequest([ | ||
| 118 | + 'recordId' => $record_id, | ||
| 119 | + 'RR' => $rr, | ||
| 120 | + 'type' => $type, | ||
| 121 | + 'value' => $value, | ||
| 122 | + ]); | ||
| 123 | + | ||
| 124 | + $response = $client->UpdateDomainRecord($request); | ||
| 125 | + | ||
| 126 | + return Utils::toArray($response); | ||
| 127 | + } | ||
| 128 | +} |
| @@ -111,7 +111,7 @@ class SyncSubmitTaskService | @@ -111,7 +111,7 @@ class SyncSubmitTaskService | ||
| 111 | * @date 2024/8/27 | 111 | * @date 2024/8/27 |
| 112 | */ | 112 | */ |
| 113 | public function subscribe($data, $date){ | 113 | public function subscribe($data, $date){ |
| 114 | - $email = $data['data']['data']['email']; | 114 | + $email = $data['data']['email']; |
| 115 | if (filter_var($email, FILTER_VALIDATE_EMAIL)) { | 115 | if (filter_var($email, FILTER_VALIDATE_EMAIL)) { |
| 116 | $model = new Email(); | 116 | $model = new Email(); |
| 117 | $model->email = $email; | 117 | $model->email = $email; |
| @@ -5,6 +5,8 @@ | @@ -5,6 +5,8 @@ | ||
| 5 | "keywords": ["framework", "laravel"], | 5 | "keywords": ["framework", "laravel"], |
| 6 | "license": "MIT", | 6 | "license": "MIT", |
| 7 | "require": { | 7 | "require": { |
| 8 | + "alibabacloud/alidns-20150109": "*", | ||
| 9 | + "alibabacloud/darabonba-openapi": "^0.2.12", | ||
| 8 | "barryvdh/laravel-dompdf": "^2.0", | 10 | "barryvdh/laravel-dompdf": "^2.0", |
| 9 | "bensampo/laravel-enum": "^4.2", | 11 | "bensampo/laravel-enum": "^4.2", |
| 10 | "beyondcode/laravel-websockets": "^1.14", | 12 | "beyondcode/laravel-websockets": "^1.14", |
-
请 注册 或 登录 后发表评论