作者 赵彬吉
@@ -75,6 +75,7 @@ class CopyProject extends Command @@ -75,6 +75,7 @@ class CopyProject extends Command
75 $this->output('CopyProjectJob end, old project_id: ' . $old_project_id . ', new project_id: ' . $project_id); 75 $this->output('CopyProjectJob end, old project_id: ' . $old_project_id . ', new project_id: ' . $project_id);
76 }catch (\Exception $e){ 76 }catch (\Exception $e){
77 echo '复制数据库失败:'.$old_project_id . '<->'.$project_id; 77 echo '复制数据库失败:'.$old_project_id . '<->'.$project_id;
  78 + echo $e->getMessage().PHP_EOL;
78 } 79 }
79 //修改项目状态 80 //修改项目状态
80 $projectModel->edit(['delete_status'=>0],['id'=>$project_id]); 81 $projectModel->edit(['delete_status'=>0],['id'=>$project_id]);
@@ -62,7 +62,11 @@ class RecommendedSuppliers extends Command @@ -62,7 +62,11 @@ class RecommendedSuppliers extends Command
62 if($result !== false){ 62 if($result !== false){
63 ProjectServer::useProject($v['project_id']); 63 ProjectServer::useProject($v['project_id']);
64 $title = $this->getKeywords($v['project_id']); 64 $title = $this->getKeywords($v['project_id']);
65 - $this->savePurchaser($v['project_id'],$title); 65 + if(!empty($title)){
  66 + $this->savePurchaser($v['project_id'],$title);
  67 + }else{
  68 + echo '关键词已取完'.PHP_EOL;
  69 + }
66 DB::disconnect('custom_mysql'); 70 DB::disconnect('custom_mysql');
67 } 71 }
68 } 72 }
@@ -84,7 +88,9 @@ class RecommendedSuppliers extends Command @@ -84,7 +88,9 @@ class RecommendedSuppliers extends Command
84 $count = $purchaserInfoModel->counts(['project_id'=>$v['project_id']]); 88 $count = $purchaserInfoModel->counts(['project_id'=>$v['project_id']]);
85 //获取项目版本 89 //获取项目版本
86 $plan = ['专业版'=>300, '标准版'=>500, '商务版'=>800, '旗舰版'=>1200]; 90 $plan = ['专业版'=>300, '标准版'=>500, '商务版'=>800, '旗舰版'=>1200];
87 - $total_number = $plan[Project::planMap()[$v['plan']]] ?? 300; 91 + $typePlan = Project::planMap();
  92 + $version = $typePlan[$v['plan']] ?? '专业版';
  93 + $total_number = $plan[$version] ?? 300;
88 if($count > $total_number){ 94 if($count > $total_number){
89 echo date('Y-m-d H:i:s') . '达到数量上线关闭的项目:'.$v['project_id'] . PHP_EOL; 95 echo date('Y-m-d H:i:s') . '达到数量上线关闭的项目:'.$v['project_id'] . PHP_EOL;
90 //更新数量上限字段,并关闭推荐供应商 96 //更新数量上限字段,并关闭推荐供应商
@@ -95,12 +101,31 @@ class RecommendedSuppliers extends Command @@ -95,12 +101,31 @@ class RecommendedSuppliers extends Command
95 return true; 101 return true;
96 } 102 }
97 103
  104 + /**
  105 + * @remark :获取关键词数据
  106 + * @name :getPurchaser
  107 + * @author :lyh
  108 + * @method :post
  109 + * @time :2025/4/15 17:55
  110 + */
98 public function getPurchaser($keyword,$project_id){ 111 public function getPurchaser($keyword,$project_id){
99 $purchaserModel = new Purchaser(); 112 $purchaserModel = new Purchaser();
100 return $purchaserModel->read(['keyword'=>$keyword,'project_id'=>$project_id]); 113 return $purchaserModel->read(['keyword'=>$keyword,'project_id'=>$project_id]);
101 } 114 }
102 115
103 /** 116 /**
  117 + * @remark :获取已经处理过的关键词
  118 + * @name :getPurchaserList
  119 + * @author :lyh
  120 + * @method :post
  121 + * @time :2025/4/15 17:55
  122 + */
  123 + public function getPurchaserList($project_id){
  124 + $purchaserModel = new Purchaser();
  125 + return $purchaserModel->selectField(['project_id'=>$project_id],'keyword');
  126 + }
  127 +
  128 + /**
104 * @remark :保存供应商 129 * @remark :保存供应商
105 * @name :getPurchaser 130 * @name :getPurchaser
106 * @author :lyh 131 * @author :lyh
@@ -110,6 +135,7 @@ class RecommendedSuppliers extends Command @@ -110,6 +135,7 @@ class RecommendedSuppliers extends Command
110 public function savePurchaser($project_id,$keyword,$row = 10){ 135 public function savePurchaser($project_id,$keyword,$row = 10){
111 //项目还没有关键词 136 //项目还没有关键词
112 if(!$keyword){ 137 if(!$keyword){
  138 + echo '项目还没有关键词'.PHP_EOL;
113 return true; 139 return true;
114 } 140 }
115 $url = 'https://fob.ai.cc/api/company_list'; 141 $url = 'https://fob.ai.cc/api/company_list';
@@ -126,6 +152,7 @@ class RecommendedSuppliers extends Command @@ -126,6 +152,7 @@ class RecommendedSuppliers extends Command
126 'total'=>$this->param['row'] ?? 10, 152 'total'=>$this->param['row'] ?? 10,
127 ]; 153 ];
128 $res = http_post($url,json_encode($param)); 154 $res = http_post($url,json_encode($param));
  155 + echo '请求返回状态'. $res['code']?? ''.PHP_EOL;
129 // echo date('Y-m-d H:i:s') . json_encode($res) . PHP_EOL; 156 // echo date('Y-m-d H:i:s') . json_encode($res) . PHP_EOL;
130 if(!empty($res) && isset($res['code']) && $res['code'] == 200 && !empty($res['data'])){ 157 if(!empty($res) && isset($res['code']) && $res['code'] == 200 && !empty($res['data'])){
131 //保存多条数据 158 //保存多条数据
@@ -152,15 +179,13 @@ class RecommendedSuppliers extends Command @@ -152,15 +179,13 @@ class RecommendedSuppliers extends Command
152 * @time :2024/7/1 18:07 179 * @time :2024/7/1 18:07
153 */ 180 */
154 public function getKeywords($project_id){ 181 public function getKeywords($project_id){
155 - $info = Keyword::inRandomOrder()->first();  
156 - if(!$info){ 182 + $keywordModel = new Keyword();
  183 + $keyword_array = $this->getPurchaserList($project_id);
  184 + $info = $keywordModel->read(['title'=>['not in',$keyword_array]],'title');
  185 + if($info === false){
157 return ''; 186 return '';
158 } 187 }
159 - $keywordInfo = $this->getPurchaser($info->title,$project_id);  
160 - if($keywordInfo !== false){  
161 - $this->getKeywords($project_id);  
162 - }  
163 - return $info->title; 188 + return $info['title'] ?? '';
164 } 189 }
165 190
166 /** 191 /**