Merge remote-tracking branch 'origin/master' into akun
正在显示
6 个修改的文件
包含
169 行增加
和
87 行删除
| @@ -60,6 +60,8 @@ class RemainDay extends Command | @@ -60,6 +60,8 @@ class RemainDay extends Command | ||
| 60 | */ | 60 | */ |
| 61 | public function __construct() | 61 | public function __construct() |
| 62 | { | 62 | { |
| 63 | + $this->project = new Project(); | ||
| 64 | + $this->deployBuild = new DeployBuild(); | ||
| 63 | parent::__construct(); | 65 | parent::__construct(); |
| 64 | } | 66 | } |
| 65 | 67 | ||
| @@ -68,67 +70,94 @@ class RemainDay extends Command | @@ -68,67 +70,94 @@ class RemainDay extends Command | ||
| 68 | */ | 70 | */ |
| 69 | public function handle() | 71 | public function handle() |
| 70 | { | 72 | { |
| 71 | - $this->getSeoList();//按上线时间统计的项目 | ||
| 72 | - $list = Project::whereIn('type', [Project::TYPE_TWO,Project::TYPE_THREE,Project::TYPE_FOUR])->get(); | 73 | + $this->saveSeoRemainDay();//单独白帽系统剩余服务时常 |
| 74 | + $this->saveRemainDay(); | ||
| 75 | + return true; | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * @remark :白帽系统剩余服务时常 | ||
| 80 | + * @name :getSeoList | ||
| 81 | + * @author :lyh | ||
| 82 | + * @method :post | ||
| 83 | + * @time :2025/4/1 16:44 | ||
| 84 | + */ | ||
| 85 | + public function saveSeoRemainDay(){ | ||
| 86 | + $projectArr = $this->deployBuild->selectField(['seo_plan'=>1,'project_id'=>['not in',$this->ceaseProjectId]],'project_id'); | ||
| 87 | + $data = $this->project->list(['id'=>['in',$projectArr]],'id',['id','uptime','finish_remain_day']); | ||
| 88 | + foreach ($data as $item){ | ||
| 89 | + $deploy_build = $this->deployBuild->read(['project_id'=>$item['id']],['seo_service_duration']); | ||
| 90 | + if($item['uptime']){ | ||
| 91 | + $diff = time() - strtotime($item['uptime']); | ||
| 92 | + $item['finish_remain_day'] = floor($diff / (60 * 60 * 24)); | ||
| 93 | + $seo_remain_day = $deploy_build['seo_service_duration'] - floor($diff / (60 * 60 * 24)); | ||
| 94 | + }else{ | ||
| 95 | + $seo_remain_day = $deploy_build['seo_service_duration']; | ||
| 96 | + } | ||
| 97 | + $extend_type = 0; | ||
| 98 | + if($seo_remain_day < 0){ | ||
| 99 | + $seo_remain_day = 0; | ||
| 100 | + $extend_type = Project::TYPE_FIVE; | ||
| 101 | + } | ||
| 102 | +// $this->project->edit(['seo_service_duration'=>$seo_remain_day,'extend_type'=>$extend_type],['id'=>$item['id']]); | ||
| 103 | + } | ||
| 104 | + return $projectArr; | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + /** | ||
| 108 | + * @remark :普通项目剩余服务时常 | ||
| 109 | + * @name :saveRemainDay | ||
| 110 | + * @author :lyh | ||
| 111 | + * @method :post | ||
| 112 | + * @time :2025/4/2 10:48 | ||
| 113 | + */ | ||
| 114 | + public function saveRemainDay(){ | ||
| 115 | + $list = $this->project->list(['type'=>['in',[Project::TYPE_TWO,Project::TYPE_THREE,Project::TYPE_FOUR]]],'id',['id','uptime','remain_day','is_remain_today','pause_days','finish_remain_day']); | ||
| 73 | foreach ($list as $item){ | 116 | foreach ($list as $item){ |
| 74 | - echo '项目id:' . $item['id'] . '执行时间:'. date('Y-m-d H:i:s') . PHP_EOL; | ||
| 75 | - if(in_array($item->id,$this->ceaseProjectId)){//暂停的项目 | ||
| 76 | - if(($item['type'] == Project::TYPE_TWO) && ($item->is_remain_today == 1)){ | ||
| 77 | - $item->pause_days = $item->pause_days + 1; | 117 | + $deploy_build = $this->deployBuild->read(['project_id'=>$item['id']],['service_duration']); |
| 118 | + echo 'start->项目id:' . $item['id'] . '执行时间:'. date('Y-m-d H:i:s') . PHP_EOL; | ||
| 119 | + if(in_array($item['id'],$this->ceaseProjectId)){//暂停的项目 | ||
| 120 | + if(($item['type'] == Project::TYPE_TWO) && ($item['is_remain_today'] == 1)){ | ||
| 121 | + $pause_days = $item['pause_days'] + 1; | ||
| 78 | } | 122 | } |
| 79 | if($item['type'] != Project::TYPE_THREE){ | 123 | if($item['type'] != Project::TYPE_THREE){ |
| 80 | - $item->pause_days = $item->pause_days + 1; | 124 | + $pause_days = $item['pause_days'] + 1; |
| 81 | } | 125 | } |
| 82 | - }else{ | ||
| 83 | - if(in_array($item->id,$this->projectId)){//已开始优化的时间结算 | 126 | + $this->project->edit(['pause_days'=>$pause_days],['id'=>$item['id']]); |
| 127 | + return true; | ||
| 128 | + } | ||
| 129 | + //未暂停的项目 | ||
| 130 | + if($item['type'] == Project::TYPE_TWO || $item['type'] == Project::TYPE_FOUR){ | ||
| 131 | + if(in_array($item['id'],$this->projectId)){//已开始优化的时间结算 | ||
| 84 | $optimizeModel = new DeployOptimize(); | 132 | $optimizeModel = new DeployOptimize(); |
| 85 | - $opInfo = $optimizeModel->read(['project_id'=>$item->id],['start_date']); | 133 | + $opInfo = $optimizeModel->read(['project_id'=>$item['id']],['start_date']); |
| 86 | if($opInfo === false){ | 134 | if($opInfo === false){ |
| 87 | continue; | 135 | continue; |
| 88 | } | 136 | } |
| 89 | - $diff = time() - strtotime($opInfo['start_date'] ?? $item->uptime); | ||
| 90 | - $remain_day = $item['deploy_build']['service_duration'] - floor($diff / (60 * 60 * 24)); | 137 | + $diff = time() - strtotime($opInfo['start_date'] ?? $item['uptime']); |
| 138 | + $remain_day = $deploy_build['service_duration'] - floor($diff / (60 * 60 * 24)); | ||
| 91 | }else{ | 139 | }else{ |
| 92 | - if($item['type'] == Project::TYPE_TWO){ | ||
| 93 | - $compliance_day = ($item->finish_remain_day ?? 0); | ||
| 94 | - $remain_day = $item['deploy_build']['service_duration'] - $compliance_day; | ||
| 95 | - }else{ | ||
| 96 | - if($item->uptime){ | ||
| 97 | - $diff = time() - strtotime($item->uptime); | ||
| 98 | - $item->finish_remain_day = floor($diff / (60 * 60 * 24)); | ||
| 99 | - $remain_day = $item['deploy_build']['service_duration'] - floor($diff / (60 * 60 * 24)); | ||
| 100 | - }else{ | ||
| 101 | - $remain_day = $item['deploy_build']['service_duration']; | ||
| 102 | - } | ||
| 103 | - } | 140 | + $compliance_day = ($item['finish_remain_day'] ?? 0); |
| 141 | + $remain_day = $deploy_build['service_duration'] - $compliance_day; | ||
| 142 | + } | ||
| 143 | + }else{ | ||
| 144 | + //普通建站项目 | ||
| 145 | + if($item['uptime']){ | ||
| 146 | + $diff = time() - strtotime($item['uptime']); | ||
| 147 | + $item['finish_remain_day'] = floor($diff / (60 * 60 * 24)); | ||
| 148 | + $remain_day = $deploy_build['service_duration'] - floor($diff / (60 * 60 * 24)); | ||
| 149 | + }else{ | ||
| 150 | + $remain_day = $deploy_build['service_duration']; | ||
| 104 | } | 151 | } |
| 105 | - $item->remain_day = ($remain_day > 0 ? $remain_day : 0); | ||
| 106 | } | 152 | } |
| 107 | - $item->save(); | ||
| 108 | - if($item->remain_day == 0){ | ||
| 109 | - $item->extend_type = Project::TYPE_FIVE; | ||
| 110 | -// $item->site_status = Project::TYPE_ONE;//关闭站点 | ||
| 111 | - //TODO::未续费网站禁止登录及通知C端禁止网站 | ||
| 112 | -// $domainModel = new DomainInfoModel(); | ||
| 113 | -// $domainInfos = $domainModel->read(['project_id'=>$item->id]); | ||
| 114 | -// if($domainInfos !== false){ | ||
| 115 | -// curl_get('https://'.$domainInfos['domain'].'/api/stop_or_start_website/'); | ||
| 116 | -// } | 153 | + $extend_type = 0; |
| 154 | + if($remain_day < 0){ | ||
| 155 | + $remain_day = 0; | ||
| 156 | + $extend_type = Project::TYPE_FIVE; | ||
| 117 | } | 157 | } |
| 158 | +// $this->project->edit(['remain_day'=>$remain_day,'extend_type'=>$extend_type],['id'=>$item['id']]); | ||
| 159 | + echo 'end->项目id:' . $item['id'] . '执行时间:'. date('Y-m-d H:i:s') . PHP_EOL; | ||
| 160 | + return true; | ||
| 118 | } | 161 | } |
| 119 | } | 162 | } |
| 120 | - | ||
| 121 | - /** | ||
| 122 | - * @remark :获取白帽系统id | ||
| 123 | - * @name :getSeoList | ||
| 124 | - * @author :lyh | ||
| 125 | - * @method :post | ||
| 126 | - * @time :2025/4/1 16:44 | ||
| 127 | - */ | ||
| 128 | - public function getSeoList(){ | ||
| 129 | - $deployBuildModel = new DeployBuild(); | ||
| 130 | - $data = $deployBuildModel->selectField(['seo_plan'=>1],'project_id'); | ||
| 131 | - $this->projectId = array_merge($this->projectId, $data); | ||
| 132 | - return true; | ||
| 133 | - } | ||
| 134 | } | 163 | } |
| @@ -64,15 +64,7 @@ class UpdateRoute extends Command | @@ -64,15 +64,7 @@ class UpdateRoute extends Command | ||
| 64 | */ | 64 | */ |
| 65 | public function handle() | 65 | public function handle() |
| 66 | { | 66 | { |
| 67 | - $projectModel = new Project(); | ||
| 68 | - $lists = $projectModel->list(['delete_status' => 0], 'id', ['id']); | ||
| 69 | - echo date('Y-m-d H:i:s') . '开始--------------' . PHP_EOL; | ||
| 70 | - foreach ($lists as $v) { | ||
| 71 | - ProjectServer::useProject($v['id']); | ||
| 72 | - $this->getAiBlog($v['id']); | ||
| 73 | - DB::disconnect('custom_mysql'); | ||
| 74 | - } | ||
| 75 | - echo date('Y-m-d H:i:s') . '--------------结束' . PHP_EOL; | 67 | + $this->updateProjectOp(); |
| 76 | } | 68 | } |
| 77 | /** | 69 | /** |
| 78 | * @remark : | 70 | * @remark : |
| @@ -531,7 +523,7 @@ class UpdateRoute extends Command | @@ -531,7 +523,7 @@ class UpdateRoute extends Command | ||
| 531 | public function updateProjectOp(){ | 523 | public function updateProjectOp(){ |
| 532 | //查询优化中台数据 | 524 | //查询优化中台数据 |
| 533 | $projectModel = new Project(); | 525 | $projectModel = new Project(); |
| 534 | - $list = $projectModel->list(['type'=>2],['id']); | 526 | + $list = $projectModel->list(['type'=>['in',[2,4]]],['id']); |
| 535 | $rankDataModel = new RankDataLog(); | 527 | $rankDataModel = new RankDataLog(); |
| 536 | $opModel = new DeployOptimize(); | 528 | $opModel = new DeployOptimize(); |
| 537 | foreach ($list as $v){ | 529 | foreach ($list as $v){ |
| @@ -215,6 +215,9 @@ class CNoticeController extends BaseController | @@ -215,6 +215,9 @@ class CNoticeController extends BaseController | ||
| 215 | $project_id = $this->user['project_id']; | 215 | $project_id = $this->user['project_id']; |
| 216 | $type = intval($request->input('type', 1)); | 216 | $type = intval($request->input('type', 1)); |
| 217 | $route = intval($request->input('page', 1)); | 217 | $route = intval($request->input('page', 1)); |
| 218 | + if(in_array($route,[4,6])){ | ||
| 219 | + $this->fail('聚合页翻译请联系管理员'); | ||
| 220 | + } | ||
| 218 | $url = $request->input('url', []); | 221 | $url = $request->input('url', []); |
| 219 | $language = $request->input('language', []); | 222 | $language = $request->input('language', []); |
| 220 | $is_sitemap = intval($request->input('is_sitemap', 0)); | 223 | $is_sitemap = intval($request->input('is_sitemap', 0)); |
| @@ -9,7 +9,9 @@ | @@ -9,7 +9,9 @@ | ||
| 9 | 9 | ||
| 10 | namespace App\Http\Controllers\Bside\Gpt; | 10 | namespace App\Http\Controllers\Bside\Gpt; |
| 11 | 11 | ||
| 12 | +use App\Enums\Common\Code; | ||
| 12 | use App\Http\Controllers\Bside\BaseController; | 13 | use App\Http\Controllers\Bside\BaseController; |
| 14 | +use App\Http\Logic\Bside\Gpt\ChatLogic; | ||
| 13 | 15 | ||
| 14 | class ChatController extends BaseController | 16 | class ChatController extends BaseController |
| 15 | { | 17 | { |
| @@ -20,8 +22,13 @@ class ChatController extends BaseController | @@ -20,8 +22,13 @@ class ChatController extends BaseController | ||
| 20 | * @method :post | 22 | * @method :post |
| 21 | * @time :2025/4/1 14:35 | 23 | * @time :2025/4/1 14:35 |
| 22 | */ | 24 | */ |
| 23 | - public function sendMessage(){ | ||
| 24 | - if(isset($this->param['task_id'])){ | ||
| 25 | - } | 25 | + public function sendMessage(ChatLogic $logic){ |
| 26 | + $this->request->validate([ | ||
| 27 | + 'message'=>['required'], | ||
| 28 | + ],[ | ||
| 29 | + 'message.required' => '消息内容不能为空', | ||
| 30 | + ]); | ||
| 31 | + $data = $logic->sendMessage(); | ||
| 32 | + $this->response('success',Code::SUCCESS,$data); | ||
| 26 | } | 33 | } |
| 27 | } | 34 | } |
| @@ -20,24 +20,41 @@ class ChatLogic extends BaseLogic | @@ -20,24 +20,41 @@ class ChatLogic extends BaseLogic | ||
| 20 | $this->model = new Chat(); | 20 | $this->model = new Chat(); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | + /** | ||
| 24 | + * @remark :发送消息 | ||
| 25 | + * @name :sendMessage | ||
| 26 | + * @author :lyh | ||
| 27 | + * @method :post | ||
| 28 | + * @time :2025/4/2 10:01 | ||
| 29 | + */ | ||
| 23 | public function sendMessage(){ | 30 | public function sendMessage(){ |
| 24 | - if(isset($this->param['task_id'])){ | ||
| 25 | - $chatInfo = $this->model->read(['id'=>$this->param['task_id']]); | 31 | + if(isset($this->param['chat_id'])){ |
| 32 | + $chatInfo = $this->model->read(['id'=>$this->param['chat_id']]); | ||
| 26 | if($chatInfo === false){ | 33 | if($chatInfo === false){ |
| 27 | - $this->fail('会话不存在'); | 34 | + $id = $this->saveChat($this->param['message']); |
| 35 | + }else{ | ||
| 36 | + $id = $chatInfo['id']; | ||
| 28 | } | 37 | } |
| 29 | }else{ | 38 | }else{ |
| 30 | - //创建一个会话 | ||
| 31 | - $saveData = [ | ||
| 32 | - 'user_id'=>$this->user['id'], | ||
| 33 | - 'input_content'=>$this->param['input_content'], | ||
| 34 | - ]; | ||
| 35 | - $id = $this->model->addReturnId(); | ||
| 36 | - $saveData = [ | ||
| 37 | - 'user_id'=>$this->user['id'], | ||
| 38 | - 'is_reply'=>1, | ||
| 39 | - 'input_content'=>$this->param['input_content'], | ||
| 40 | - ]; | 39 | + $id = $this->saveChat($this->param['message']); |
| 41 | } | 40 | } |
| 41 | + | ||
| 42 | + | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * @remark :创建一条新会话 | ||
| 47 | + * @name :saveChat | ||
| 48 | + * @author :lyh | ||
| 49 | + * @method :post | ||
| 50 | + * @time :2025/4/2 10:06 | ||
| 51 | + */ | ||
| 52 | + public function saveChat($message){ | ||
| 53 | + //创建一个会话 | ||
| 54 | + $saveData = [ | ||
| 55 | + 'user_id'=>$this->user['id'], | ||
| 56 | + 'input_content'=>$message, | ||
| 57 | + ]; | ||
| 58 | + return $this->model->addReturnId($saveData); | ||
| 42 | } | 59 | } |
| 43 | } | 60 | } |
| @@ -9,17 +9,51 @@ | @@ -9,17 +9,51 @@ | ||
| 9 | 9 | ||
| 10 | namespace App\Services; | 10 | namespace App\Services; |
| 11 | 11 | ||
| 12 | +use Hbb\CmerLlmChat\CmerClient; | ||
| 13 | +use Hbb\CmerLlmChat\models\ChatModel; | ||
| 14 | +use Illuminate\Support\Facades\Log; | ||
| 15 | + | ||
| 12 | class GptService | 16 | class GptService |
| 13 | { | 17 | { |
| 14 | - | ||
| 15 | - protected $header = [ | ||
| 16 | - 'apikey' => 'UkzZljFv83Z2qBi5YR1o3f2otAVWtug6', | ||
| 17 | - 'X-CmerApi-Host' => 'bizopenai.p.cmer.com', | ||
| 18 | - ]; | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - protected $api = 'https://api.cmer.com'; | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - protected $api_test = 'http://test.waimaoq.com'; | 18 | + /** |
| 19 | + * @remark :大模型会话 | ||
| 20 | + * @name :get_ai_chat | ||
| 21 | + * @author :lyh | ||
| 22 | + * @method :post | ||
| 23 | + * @time :2025/4/2 9:38 | ||
| 24 | + * | ||
| 25 | + */ | ||
| 26 | + public function get_ai_chat($data,$type = 1){ | ||
| 27 | + // 组装请求体参数 | ||
| 28 | + // $data['message'] = [ | ||
| 29 | + // ['role' => 'system', 'content' => "You are now the marketing customer service of 深圳创贸集团"], | ||
| 30 | + // ['role' => 'user', 'content' => '创贸集团有多少技术?'], | ||
| 31 | + // ['role' => 'assistant', 'content' => '创贸集团有200+技术。'], | ||
| 32 | + // ['role' => 'user', 'content' => '今天天气怎么样'] | ||
| 33 | + // ]; | ||
| 34 | + $apikey = env('AI_CREATE_KEY')??'7yn!We6$&NnVA38bpGy*A@4TQ5iYLJcW'; | ||
| 35 | + $client = new CmerClient($apikey); | ||
| 36 | + // 修改超时时间,默认60秒 | ||
| 37 | + $client->timeout=300; | ||
| 38 | + $payload = new ChatModel($data['messages']); | ||
| 39 | + // 修改模型名称,豆包,Gpt,Claude | ||
| 40 | + $payload->model = env('CHAT_GTP_MODEL','gpt-4o-mini');; | ||
| 41 | + $payload->supplier = isset($data['supplier'])?$data['supplier']:"openai"; | ||
| 42 | + //发送请求 | ||
| 43 | + if($type == 1){//返回数据 | ||
| 44 | + $response = $client->chat($payload); | ||
| 45 | + $result=$response->getBody()->getContents(); | ||
| 46 | + if(!$result){ | ||
| 47 | + Log::info('ai接口返回错误信息:'.$result. PHP_EOL); | ||
| 48 | + return false; | ||
| 49 | + } | ||
| 50 | + return json_decode($result,true); | ||
| 51 | + }else { | ||
| 52 | + //发送流式请求 | ||
| 53 | + $payload->stream = true; | ||
| 54 | + $response = $client->chat($payload); | ||
| 55 | + $body = $response->getBody(); | ||
| 56 | + return $body; | ||
| 57 | + } | ||
| 58 | + } | ||
| 25 | } | 59 | } |
-
请 注册 或 登录 后发表评论