作者 李宇航

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

Master server



查看合并请求 !633
@@ -89,9 +89,9 @@ class VideoTask extends Command @@ -89,9 +89,9 @@ class VideoTask extends Command
89 } 89 }
90 ProjectServer::useProject($task_project->project_id); 90 ProjectServer::useProject($task_project->project_id);
91 if(!empty($task_project->keywords)){ 91 if(!empty($task_project->keywords)){
92 - $task_project->keywords = explode(',',trim(',',$task_project->keywords)); 92 + $keywords = explode(',',trim(',',$task_project->keywords));
93 } 93 }
94 - $keyword = $this->getProjectKeyword($task_project->number,$task_project->keywords); 94 + $keyword = $this->getProjectKeyword($task_project->number,$keywords ?? []);
95 // 已经没有需要生成视频的关键词 95 // 已经没有需要生成视频的关键词
96 if (!$keyword) { 96 if (!$keyword) {
97 $task_project->status = KeywordVideoTask::STATUS_CLOSE; 97 $task_project->status = KeywordVideoTask::STATUS_CLOSE;
@@ -176,24 +176,15 @@ class VideoTask extends Command @@ -176,24 +176,15 @@ class VideoTask extends Command
176 */ 176 */
177 public function getProjectKeyword($number,$keywords = []) 177 public function getProjectKeyword($number,$keywords = [])
178 { 178 {
179 - if(!empty($keywords)){ 179 +
180 $keyword_id = Keyword::where('video', null)->whereIn("title", $keywords) 180 $keyword_id = Keyword::where('video', null)->whereIn("title", $keywords)
181 - ->where('route', 'not like', '%-tag')->whereNotNull('keyword_content')->pluck('id')->toArray();  
182 - if(count($keyword_id) == 0){ 181 + ->where('route', 'not like', '%-tag')->whereNotNull('keyword_content')->limit($number)->pluck('id')->toArray();
  182 + $need = $number - count($keyword_id);
  183 + if ($need > 0) {
183 $keyword_arr_id = Keyword::where('video', null)->where('route', 'not like', '%-tag') 184 $keyword_arr_id = Keyword::where('video', null)->where('route', 'not like', '%-tag')
184 - ->whereNotNull('keyword_content')->orderBy('id','asc')->limit($number)->pluck('id')->toArray();  
185 - }else{  
186 - $keyword_arr_id = Keyword::where('video', null)->whereNotIn("title", $keywords)->where('route', 'not like', '%-tag')  
187 - ->whereNotNull('keyword_content')->orderBy('id','asc')->limit($number - count($keyword_id))->pluck('id')->toArray();  
188 - $keyword_arr_id = array_merge($keyword_id,$keyword_arr_id);  
189 - }  
190 - }else{  
191 - $keyword_arr_id = Keyword::where('video', null)->where('route', 'not like', '%-tag')  
192 - ->whereNotNull('keyword_content')->orderBy('id','asc')->limit($number)->pluck('id')->toArray();  
193 - }  
194 - if(count($keyword_arr_id) == 0){  
195 - return []; 185 + ->whereNotNull('keyword_content')->whereNotIn('id', $keyword_id)->orderBy('id','asc')->limit($need)->pluck('id')->toArray();
196 } 186 }
  187 + $keyword_arr_id = array_merge($keyword_id, $keyword_arr_id);
197 $keyword = Keyword::whereIn("id", $keyword_arr_id)->get(); 188 $keyword = Keyword::whereIn("id", $keyword_arr_id)->get();
198 return $keyword; 189 return $keyword;
199 } 190 }
@@ -235,7 +226,7 @@ class VideoTask extends Command @@ -235,7 +226,7 @@ class VideoTask extends Command
235 } 226 }
236 } 227 }
237 //TODO::所有产品 228 //TODO::所有产品
238 - $thumb = $this->getRecommendAndHotProducts($keywordInfo['route'],$project_id); 229 + $thumb = $this->getRecommendAndHotProducts($keyword_id,$project_id);
239 $keyword_arr = Keyword::where("project_id",$project_id)->where("status",1)->inRandomOrder()->take(10)->pluck('title')->toArray(); 230 $keyword_arr = Keyword::where("project_id",$project_id)->where("status",1)->inRandomOrder()->take(10)->pluck('title')->toArray();
240 $data = [ 231 $data = [
241 'url'=> 'https://' . $domain.'/'.$keywordInfo['route'], 232 'url'=> 'https://' . $domain.'/'.$keywordInfo['route'],
@@ -251,37 +242,43 @@ class VideoTask extends Command @@ -251,37 +242,43 @@ class VideoTask extends Command
251 /** 242 /**
252 * 关键词聚合页-推荐&热门产品 243 * 关键词聚合页-推荐&热门产品
253 */ 244 */
254 - public function getRecommendAndHotProducts($route,$project_id): ?array 245 + public function getRecommendAndHotProducts($keyword_id,$project_id): ?array
255 { 246 {
256 $productIds = []; 247 $productIds = [];
257 - $productKeyword = Keyword::where("project_id",$project_id)->where("route",$route)->first();  
258 - if (!empty($productKeyword)){  
259 - $productsQuery = Product::where("project_id", $project_id)->where("status",1)->where("keyword_id","like","%,".$productKeyword->id.",%")->limit(7)->get(); 248 + $productKeyword = Keyword::where("id",$keyword_id)->first();
  249 + $productsQuery = Product::where("status",1)->where("keyword_id","like","%,".$keyword_id.",%")->limit(7)->get();
260 if (!empty($productsQuery)){ 250 if (!empty($productsQuery)){
261 foreach ($productsQuery as $item){ 251 foreach ($productsQuery as $item){
262 $productIds[] = $item->id; 252 $productIds[] = $item->id;
263 } 253 }
264 if (count($productIds)<7){ 254 if (count($productIds)<7){
265 - $product_all_id = Product::where("project_id", $project_id)->where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray(); 255 + $product_all_id = Product::where('thumb','!=',null)->whereNotIn('id', $productIds)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
266 $number = 40; 256 $number = 40;
267 $array_count = count($product_all_id); 257 $array_count = count($product_all_id);
268 if ($array_count > 0) { 258 if ($array_count > 0) {
269 - $product_id = array_rand($product_all_id, min($array_count, $number - count($productIds)));  
270 - $randomData = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); 259 + $product_id_key = array_rand($product_all_id, min($array_count, $number - count($productIds)));
  260 + foreach ($product_id_key as $value_key){
  261 + $project_id_arr = $product_all_id[$value_key];
  262 + }
  263 + $randomData = Product::whereIn("id", $project_id_arr)->get();
271 $products = $productsQuery->merge($randomData); 264 $products = $productsQuery->merge($randomData);
272 } 265 }
273 }else{ 266 }else{
274 $products = $productsQuery; 267 $products = $productsQuery;
275 } 268 }
276 }else{ 269 }else{
277 - $product_all_id = Product::where("project_id", $project_id)->where('thumb','!=',null)->where("status",Product::STATUS_ON)->pluck('id')->toArray(); 270 + $product_all_id = Product::where('thumb','!=',null)->where("status",Product::STATUS_ON)->pluck('id')->toArray();
  271 + shuffle($product_all_id);
278 $number = 40; 272 $number = 40;
279 $array_count = count($product_all_id); 273 $array_count = count($product_all_id);
280 if ($array_count > 0) 274 if ($array_count > 0)
281 { 275 {
282 - $product_id = array_rand($product_all_id, min($array_count, $number-count($productIds)));  
283 - $products = Product::where("project_id", $project_id)->whereIn("id", $product_id)->get(); 276 + $project_id_arr = [];
  277 + $product_id_key = array_rand($product_all_id, min($array_count, $number-count($productIds)));
  278 + foreach ($product_id_key as $value_key){
  279 + $project_id_arr = $product_all_id[$value_key];
284 } 280 }
  281 + $products = Product::where("project_id", $project_id)->whereIn("id", $project_id_arr)->get();
285 } 282 }
286 } 283 }
287 $data = []; 284 $data = [];
@@ -293,11 +290,11 @@ class VideoTask extends Command @@ -293,11 +290,11 @@ class VideoTask extends Command
293 if(count($data) > 13){ 290 if(count($data) > 13){
294 break; 291 break;
295 } 292 }
296 - $keyword_id = implode(',',$item->keyword_id);  
297 - if (strpos(','.$keyword_id.',', ','.$productKeyword->id.',') === false) { 293 + $keyword_ids = implode(',',$item->keyword_id);
  294 + if (strpos(','.$keyword_ids.',', ','.$keyword_id.',') === false) {
298 //不包含 295 //不包含
299 $productModel = new Product(); 296 $productModel = new Product();
300 - $keyword_id = ','.$keyword_id.',' . $productKeyword->id.','; 297 + $keyword_id = ','.$keyword_ids.',' . $keyword_id.',';
301 $productModel->edit(['keyword_id'=>$keyword_id],['id'=>$item->id]); 298 $productModel->edit(['keyword_id'=>$keyword_id],['id'=>$item->id]);
302 } 299 }
303 $data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title]; 300 $data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];
@@ -874,3 +874,37 @@ function textareaToArr($content, $separator = ','){ @@ -874,3 +874,37 @@ function textareaToArr($content, $separator = ','){
874 return trim($v); 874 return trim($v);
875 },explode($separator, $content))))); 875 },explode($separator, $content)))));
876 } 876 }
  877 +
  878 +/**
  879 + * @remark :字符串
  880 + * @name :base62_encode
  881 + * @author :lyh
  882 + * @method :post
  883 + * @time :2024/6/26 10:46
  884 + */
  885 +function ip_to_unique_string($ip) {
  886 + // 将IP地址转换为数值表示
  887 + $ip_number = ip2long($ip);
  888 + // 使用哈希函数生成唯一数值
  889 + $hash = hash('sha256', $ip_number, false);
  890 + $hash_number = hexdec(substr($hash, 0, 15)); // 取前15位作为大整数
  891 + // 将哈希值转换为Base62编码
  892 + $unique_string = base62_encode($hash_number);
  893 + // 确保唯一字符串为6位,如果不足则补齐,超出则截取前6位
  894 + $unique_string = str_pad($unique_string, 6, '0', STR_PAD_LEFT);
  895 + $unique_string = substr($unique_string, 0, 6);
  896 + return $unique_string;
  897 +}
  898 +
  899 +function base62_encode($num) {
  900 + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  901 + $base = strlen($characters);
  902 + $result = '';
  903 + while ($num > 0) {
  904 + $result = $characters[$num % $base] . $result;
  905 + $num = intval($num / $base);
  906 + }
  907 + return $result;
  908 +}
  909 +
  910 +
@@ -30,6 +30,11 @@ class ServersController extends BaseController @@ -30,6 +30,11 @@ class ServersController extends BaseController
30 } 30 }
31 $serversModel = new ServersModel(); 31 $serversModel = new ServersModel();
32 $lists = $serversModel->list($this->map); 32 $lists = $serversModel->list($this->map);
  33 + foreach ($lists as $k => $v){
  34 + if($v['being_number'] >= $v['total']){
  35 + unset($lists[$k]);
  36 + }
  37 + }
33 $this->response('success',Code::SUCCESS,$lists); 38 $this->response('success',Code::SUCCESS,$lists);
34 } 39 }
35 40
@@ -82,14 +87,18 @@ class ServersController extends BaseController @@ -82,14 +87,18 @@ class ServersController extends BaseController
82 'total'=>'required', 87 'total'=>'required',
83 'account'=>'required', 88 'account'=>'required',
84 'password'=>'required', 89 'password'=>'required',
85 - 'port'=>'required' 90 + 'port'=>'required',
  91 + 'ip_total'=>'required',
  92 + 'domain'=>'required'
86 ],[ 93 ],[
87 'server_name.required' => '服务器名称server_name不能为空', 94 'server_name.required' => '服务器名称server_name不能为空',
88 'service_type.required' => '服务器类型不能为空', 95 'service_type.required' => '服务器类型不能为空',
89 'total.required' => '总数不能为空', 96 'total.required' => '总数不能为空',
90 'account.required' => '账号不能为空', 97 'account.required' => '账号不能为空',
91 'password.required' => '密码不能为空', 98 'password.required' => '密码不能为空',
92 - 'port.required' => '端口不能为空' 99 + 'port.required' => '端口不能为空',
  100 + 'ip_total.required' => 'ip使用數量不能为空',
  101 + 'domain.required' => '初始域名不能为空',
93 ]); 102 ]);
94 $data = $serversLogic->saveServers(); 103 $data = $serversLogic->saveServers();
95 $this->response('success',Code::SUCCESS,$data); 104 $this->response('success',Code::SUCCESS,$data);
@@ -12,7 +12,9 @@ namespace App\Http\Controllers\Aside\Devops; @@ -12,7 +12,9 @@ namespace App\Http\Controllers\Aside\Devops;
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
13 use App\Http\Controllers\Aside\BaseController; 13 use App\Http\Controllers\Aside\BaseController;
14 use App\Http\Logic\Aside\Devops\ServersIpLogic; 14 use App\Http\Logic\Aside\Devops\ServersIpLogic;
  15 +use App\Models\Devops\Servers;
15 use App\Models\Devops\ServersIp as ServersIpModel; 16 use App\Models\Devops\ServersIp as ServersIpModel;
  17 +use App\Models\Project\Project;
16 18
17 class ServersIpController extends BaseController 19 class ServersIpController extends BaseController
18 { 20 {
@@ -30,7 +32,13 @@ class ServersIpController extends BaseController @@ -30,7 +32,13 @@ class ServersIpController extends BaseController
30 ],[ 32 ],[
31 'servers_id.required' => '服务器servers_id不能为空' 33 'servers_id.required' => '服务器servers_id不能为空'
32 ]); 34 ]);
  35 + $serverModel = new Servers();
  36 + $info = $serverModel->read(['id'=>$this->param['servers_id']]);
  37 + if($info === false){
  38 + $this->response('當前服務器不存在',Code::SERVER_ERROR);
  39 + }
33 $serversIpModel = new ServersIpModel(); 40 $serversIpModel = new ServersIpModel();
  41 + $this->map['total'] = ['<',$info['ip_total']];
34 $data = $serversIpModel->list($this->map); 42 $data = $serversIpModel->list($this->map);
35 $this->response('success',Code::SUCCESS,$data); 43 $this->response('success',Code::SUCCESS,$data);
36 } 44 }
@@ -101,10 +109,10 @@ class ServersIpController extends BaseController @@ -101,10 +109,10 @@ class ServersIpController extends BaseController
101 */ 109 */
102 public function batchSave(ServersIpLogic $serversIpLogic){ 110 public function batchSave(ServersIpLogic $serversIpLogic){
103 $this->request->validate([ 111 $this->request->validate([
104 - 'data'=>'required', 112 + 'ip'=>'required|array',
105 'servers_id'=>'required', 113 'servers_id'=>'required',
106 ],[ 114 ],[
107 - 'data.required' => 'data集合不能为空', 115 + 'ip.required' => 'ip集合不能为空',
108 'servers_id.required' => '服务器servers_id不能为空', 116 'servers_id.required' => '服务器servers_id不能为空',
109 ]); 117 ]);
110 $data = $serversIpLogic->batchSaveServersIp(); 118 $data = $serversIpLogic->batchSaveServersIp();
@@ -422,7 +422,6 @@ class OptimizeController extends BaseController @@ -422,7 +422,6 @@ class OptimizeController extends BaseController
422 if($info === false){ 422 if($info === false){
423 $this->response('请先创建视频任务,才能开启',Code::SYSTEM_ERROR); 423 $this->response('请先创建视频任务,才能开启',Code::SYSTEM_ERROR);
424 } 424 }
425 - $keywordVideoModel->edit(['status'=>$this->param['status']],['project_id'=>$this->param['project_id']]);  
426 $optimizeModel = new DeployOptimize(); 425 $optimizeModel = new DeployOptimize();
427 $optimizeModel->edit(['ai_video'=>$this->param['status']],['project_id'=>$this->param['project_id']]); 426 $optimizeModel->edit(['ai_video'=>$this->param['status']],['project_id'=>$this->param['project_id']]);
428 $this->response('success'); 427 $this->response('success');
@@ -31,7 +31,6 @@ class ProjectKeywordController extends BaseController @@ -31,7 +31,6 @@ class ProjectKeywordController extends BaseController
31 $data['search_keywords'] = $info['search_keywords']; 31 $data['search_keywords'] = $info['search_keywords'];
32 $data['customer_keywords'] = $info['customer_keywords']; 32 $data['customer_keywords'] = $info['customer_keywords'];
33 $data['brand_keyword'] = $info['brand_keyword']; 33 $data['brand_keyword'] = $info['brand_keyword'];
34 - $data['minor_keywords'] = $info['minor_keywords'];  
35 $this->response('success',Code::SUCCESS,$data); 34 $this->response('success',Code::SUCCESS,$data);
36 } 35 }
37 36
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 namespace App\Http\Logic\Aside\Devops; 10 namespace App\Http\Logic\Aside\Devops;
11 11
12 use App\Http\Logic\Aside\BaseLogic; 12 use App\Http\Logic\Aside\BaseLogic;
  13 +use App\Models\Devops\Servers;
13 use App\Models\Devops\ServersIp; 14 use App\Models\Devops\ServersIp;
14 15
15 class ServersIpLogic extends BaseLogic 16 class ServersIpLogic extends BaseLogic
@@ -32,6 +33,11 @@ class ServersIpLogic extends BaseLogic @@ -32,6 +33,11 @@ class ServersIpLogic extends BaseLogic
32 * @time :2024/6/24 17:28 33 * @time :2024/6/24 17:28
33 */ 34 */
34 public function saveServersIp(){ 35 public function saveServersIp(){
  36 + //验证域名是否唯一
  37 + $info = $this->model->read(['domain'=>$this->param['domain']]);
  38 + if($info !== false){
  39 + $this->fail('当前初始域名已存在');
  40 + }
35 if(isset($this->param['id']) && !empty($this->param['id'])){ 41 if(isset($this->param['id']) && !empty($this->param['id'])){
36 $id = $this->param['id']; 42 $id = $this->param['id'];
37 $this->model->edit($this->param,['id'=>$this->param['id']]); 43 $this->model->edit($this->param,['id'=>$this->param['id']]);
@@ -49,17 +55,23 @@ class ServersIpLogic extends BaseLogic @@ -49,17 +55,23 @@ class ServersIpLogic extends BaseLogic
49 * @time :2024/6/24 17:25 55 * @time :2024/6/24 17:25
50 */ 56 */
51 public function batchSaveServersIp(){ 57 public function batchSaveServersIp(){
52 - $data = [];  
53 - foreach ($this->param['data'] as $v){  
54 - if(empty($v['ip']) || empty($v['domain'])){ 58 + //獲取初始域名
  59 + $serverModel = new Servers();
  60 + $info = $serverModel->read(['id'=>$this->param['servers_id']]);
  61 + if($info === false){
  62 + $this->fail('當前服務器數據不存在');
  63 + }
  64 + foreach ($this->param['ip'] as $v){
  65 + if(empty($v)){
55 continue; 66 continue;
56 } 67 }
57 - $data[] = [  
58 - 'ip'=>$v['ip'],  
59 - 'domain'=>$v['domain'], 68 + $param = [
  69 + 'ip'=>$v,
  70 + 'domain'=>ip_to_unique_string($v).'.'.$info['domain'],
60 'servers_id'=>$this->param['servers_id'] 71 'servers_id'=>$this->param['servers_id']
61 ]; 72 ];
  73 + $this->model->addReturnId($param);
62 } 74 }
63 - return $this->addReturnId($data); 75 + return $this->success();
64 } 76 }
65 } 77 }
@@ -165,10 +165,12 @@ class HrLogic extends BaseLogic @@ -165,10 +165,12 @@ class HrLogic extends BaseLogic
165 if(($this->manager['gid'] != ManageHr::GID_ZERO) && isset($this->param['id'])){ 165 if(($this->manager['gid'] != ManageHr::GID_ZERO) && isset($this->param['id'])){
166 $groupModel = new Group(); 166 $groupModel = new Group();
167 $groupInfo = $groupModel->read(['id'=>$this->manager['gid']]); 167 $groupInfo = $groupModel->read(['id'=>$this->manager['gid']]);
168 - if (!in_array(20,$groupInfo['rights']) && ($data['manage_id'] != $this->manager['id'])) { 168 + if ((!in_array(20,$groupInfo['rights'])) && ($data['manage_id'] != $this->manager['id'])) {
  169 + if(strpos($this->manager['rules'],'20') == false){
169 $this->fail('无权限查看其他用户信息'); 170 $this->fail('无权限查看其他用户信息');
170 } 171 }
171 } 172 }
  173 + }
172 foreach ($this->model::specieField() as $v){ 174 foreach ($this->model::specieField() as $v){
173 $data[$v] = json_decode($data[$v],true); 175 $data[$v] = json_decode($data[$v],true);
174 } 176 }
@@ -19,6 +19,8 @@ use App\Models\Channel\Zone; @@ -19,6 +19,8 @@ use App\Models\Channel\Zone;
19 use App\Models\Com\NoticeLog; 19 use App\Models\Com\NoticeLog;
20 use App\Models\Com\UpdateLog; 20 use App\Models\Com\UpdateLog;
21 use App\Models\Devops\ServerConfig; 21 use App\Models\Devops\ServerConfig;
  22 +use App\Models\Devops\Servers;
  23 +use App\Models\Devops\ServersIp;
22 use App\Models\Domain\DomainInfo; 24 use App\Models\Domain\DomainInfo;
23 use App\Models\Inquiry\InquiryIP; 25 use App\Models\Inquiry\InquiryIP;
24 use App\Models\Inquiry\InquirySet; 26 use App\Models\Inquiry\InquirySet;
@@ -145,8 +147,6 @@ class ProjectLogic extends BaseLogic @@ -145,8 +147,6 @@ class ProjectLogic extends BaseLogic
145 * @time :2023/8/30 11:57 147 * @time :2023/8/30 11:57
146 */ 148 */
147 public function projectSave(){ 149 public function projectSave(){
148 - DB::beginTransaction();  
149 - try {  
150 if($this->param['type'] == Project::TYPE_SEVEN){ 150 if($this->param['type'] == Project::TYPE_SEVEN){
151 //错误单直接返回,单独处理 151 //错误单直接返回,单独处理
152 $this->setTypeSevenEdit($this->param); 152 $this->setTypeSevenEdit($this->param);
@@ -169,11 +169,52 @@ class ProjectLogic extends BaseLogic @@ -169,11 +169,52 @@ class ProjectLogic extends BaseLogic
169 $this->syncImageFile($this->param['project_location'],$this->param['id']); 169 $this->syncImageFile($this->param['project_location'],$this->param['id']);
170 //同步信息表 170 //同步信息表
171 (new SyncService())->projectAcceptAddress($this->param['id']); 171 (new SyncService())->projectAcceptAddress($this->param['id']);
  172 + //双向绑定服务器
  173 +// $this->setServers($this->param['server_id'],$this->param['id']);
172 } 174 }
173 - DB::commit();  
174 - }catch (\Exception $e){  
175 - DB::rollBack();  
176 - $this->fail('保存失败,请联系管理员'); 175 + return $this->success();
  176 + }
  177 +
  178 + /**
  179 + * @remark :选择服务器后双向绑定
  180 + * @name :setServers
  181 + * @author :lyh
  182 + * @method :post
  183 + * @time :2024/6/25 15:34
  184 + */
  185 + public function setServers($servers_id,$project_id){
  186 + //查看當前項目服務器是否有更改
  187 + $projectModel = new Project();
  188 + $projectInfo = $projectModel->read(['id'=>$project_id],['serve_id']);
  189 + if(!empty($projectInfo['serve_id'])){
  190 + if($projectInfo['serve_id'] == $servers_id){
  191 + return $this->success();
  192 + }
  193 + }
  194 + $serversIpModel = new ServersIp();
  195 + $serversIpInfo = $serversIpModel->read(['project_arr'=>['like','%,'.$project_id.',%']]);
  196 + if($serversIpInfo !== false){
  197 + $string = str_replace(','.$project_id.',',',',$serversIpInfo['project_arr']);
  198 + if($string == ','){
  199 + $string = '';
  200 + }
  201 + $serversIpModel->edit(['project_arr'=>$string],['id'=>$serversIpInfo['id']]);
  202 + }
  203 + $info = $serversIpModel->read(['id'=>$servers_id]);
  204 + $serversModel = new Servers();
  205 + $serversInfo = $serversModel->read(['id'=>$info['servers_id']]);
  206 + if($serversInfo['being_number'] >= $serversInfo['total']){
  207 + $this->fail('请选择其他服务器,当前服务器已满');
  208 + }
  209 + $project_arr = explode(',',trim($info['project_arr'],','));
  210 + if(count($project_arr) >= $serversInfo['ip_total']){
  211 + $this->fail('请选择其他服务器,当前ip已满');
  212 + }
  213 + if(!in_array($project_id,$project_arr)){
  214 + array_push($project_id);
  215 + $project_str = ','.implode(',',$project_arr).',';
  216 + $serversIpModel->edit(['project_arr'=>$project_str,'total'=>count($project_arr)],['id'=>$servers_id]);
  217 + $serversModel->where(['id'=>$info['servers_id']])->increment('being_number');
177 } 218 }
178 return $this->success(); 219 return $this->success();
179 } 220 }
@@ -17,7 +17,6 @@ class Project extends Base @@ -17,7 +17,6 @@ class Project extends Base
17 protected $table = 'gl_project'; 17 protected $table = 'gl_project';
18 18
19 const DATABASE_NAME_FIX = 'gl_data_'; 19 const DATABASE_NAME_FIX = 'gl_data_';
20 -  
21 const CUSTOMIZED_ONE = 1;//定制项目 20 const CUSTOMIZED_ONE = 1;//定制项目
22 const DEMO_PROJECT_ID = 1; 21 const DEMO_PROJECT_ID = 1;
23 22