作者 李宇航

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

Lyh server



查看合并请求 !1429
@@ -17,6 +17,7 @@ use App\Models\Product\Category; @@ -17,6 +17,7 @@ use App\Models\Product\Category;
17 use App\Models\Product\CategoryRelated; 17 use App\Models\Product\CategoryRelated;
18 use App\Models\Product\Column; 18 use App\Models\Product\Column;
19 use App\Models\Product\Detail; 19 use App\Models\Product\Detail;
  20 +use App\Models\Product\ExtendInfo;
20 use App\Models\Product\Product; 21 use App\Models\Product\Product;
21 use App\Models\RouteMap\RouteMap; 22 use App\Models\RouteMap\RouteMap;
22 use App\Models\Template\BTemplate; 23 use App\Models\Template\BTemplate;
@@ -140,71 +141,148 @@ class LyhImportTest extends Command @@ -140,71 +141,148 @@ class LyhImportTest extends Command
140 $productModel = new Product(); 141 $productModel = new Product();
141 $detailModel = new Detail(); 142 $detailModel = new Detail();
142 $columnModel = new Column(); 143 $columnModel = new Column();
  144 + $extentInfoModel = new ExtendInfo();
143 foreach ($line_of_text as $k => $val){ 145 foreach ($line_of_text as $k => $val){
144 - if($k < 2){ 146 + if($k < 1){
145 continue; 147 continue;
146 } 148 }
147 $saveData = []; 149 $saveData = [];
148 - if($val[1] ?? ''){  
149 - $saveData['title'] = $val[1]; 150 + if(!empty($val[0])){
  151 + $saveData['title'] = $val[0];
150 }else{ 152 }else{
151 continue; 153 continue;
152 } 154 }
153 - if($val[0] ?? ''){  
154 - $cateInfo = $cateModel->read(['seo_title'=>trim($val[0])]); 155 + if(!empty($val[1])){
  156 + $cateInfo = $cateModel->read(['seo_title'=>trim($val[1])]);
155 if($cateInfo !== false){ 157 if($cateInfo !== false){
156 $saveData['category_id'] = ','.$cateInfo['id'].','; 158 $saveData['category_id'] = ','.$cateInfo['id'].',';
157 } 159 }
158 } 160 }
159 - $saveData['intro'] = $val[2];  
160 - $saveData['content'] = $val[3];  
161 - $seo = ['seo_title'=>$val[5]]; 161 + $saveData['intro'] = $val[6] ?? '';
  162 + $seo = ['seo_title'=>$val[0]];
162 $saveData['seo_mate'] = json_encode($seo,true); 163 $saveData['seo_mate'] = json_encode($seo,true);
163 - $thumb = ['alt'=>'主图','url'=>str_replace('/public','/upload/p/3283',$val[6])];  
164 - $gallery = [['alt'=>'主图','url'=>str_replace('/public','/upload/p/3283',$val[6])]]; 164 + $thumb = ['alt'=>'主图','url'=>str_replace('/public','/upload/p/3283',$val[11])];
  165 + $gallery = [['alt'=>'主图','url'=>str_replace('/public','/upload/p/3283',$val[11])]];
165 $saveData['thumb'] = json_encode($thumb,true); 166 $saveData['thumb'] = json_encode($thumb,true);
166 $saveData['gallery'] = json_encode($gallery,true); 167 $saveData['gallery'] = json_encode($gallery,true);
167 $id = $productModel->addReturnId($saveData); 168 $id = $productModel->addReturnId($saveData);
168 - echo date('Y-m-d H:i:s') . '新增产品id:'.$id . PHP_EOL;  
169 //设置关联关系 169 //设置关联关系
170 if($cateInfo !== false){ 170 if($cateInfo !== false){
171 CategoryRelated::saveRelated($id,[$cateInfo['id']]); 171 CategoryRelated::saveRelated($id,[$cateInfo['id']]);
172 } 172 }
173 //设置路由 173 //设置路由
174 - $route = RouteMap::setRoute($val[1],RouteMap::SOURCE_PRODUCT,$id,$project_id); 174 + $route = RouteMap::setRoute($val[0],RouteMap::SOURCE_PRODUCT,$id,$project_id);
175 $productModel->edit(['route'=>$route],['id'=>$id]); 175 $productModel->edit(['route'=>$route],['id'=>$id]);
176 - //设置产品描述  
177 - $detail = [  
178 - 'product_id'=>$id,  
179 - 'column_id'=>1,  
180 - 'text_type'=>1,  
181 - 'content'=>json_encode(['content'=>$val[3]])  
182 - ];  
183 - $detailModel->addReturnId($detail);  
184 - //扩展描述设置  
185 - $detailFaq = [  
186 - 'column_name'=>'FAQs',  
187 - 'product_id'=>$id  
188 - ];  
189 - $faqId = $columnModel->addReturnId($detailFaq);  
190 -  
191 - $faqsDetail = json_decode($val[4],true);  
192 - if(!empty($faqsDetail) && is_array($faqsDetail)){  
193 - $faqContent = '<div>';  
194 - foreach ($faqsDetail as $faq_Val){  
195 - $faqContent .= "<span>question:".$faq_Val['question'] . "</span><br /><span>" . "answer:".$faq_Val['answer']. "</span><br />";  
196 - }  
197 - $faqContent .= '</div>';  
198 - $detailFaqInfo = [ 176 + echo date('Y-m-d H:i:s') . '新增产品id:'.$id . PHP_EOL;
  177 + if(!empty($val[2])){
  178 + $extent = [
  179 + 'key'=>'pd_extended_field_4',
  180 + 'product_id'=>$id,
  181 + 'project_id'=>$project_id,
  182 + 'values'=>$val[2],
  183 + ];
  184 + $extentInfoModel->addReturnId($extent);
  185 + }
  186 + if(!empty($val[3])){
  187 + $extent = [
  188 + 'key'=>'pd_extended_field_1',
  189 + 'product_id'=>$id,
  190 + 'project_id'=>$project_id,
  191 + 'values'=>$val[3],
  192 + ];
  193 + $extentInfoModel->addReturnId($extent);
  194 + }
  195 + if(!empty($val[4])){
  196 + $extent = [
  197 + 'key'=>'pd_extended_field_2',
  198 + 'product_id'=>$id,
  199 + 'project_id'=>$project_id,
  200 + 'values'=>$val[4],
  201 + ];
  202 + $extentInfoModel->addReturnId($extent);
  203 + }
  204 + if(!empty($val[5])){
  205 + $extent = [
  206 + 'key'=>'pd_extended_field_3',
  207 + 'product_id'=>$id,
  208 + 'project_id'=>$project_id,
  209 + 'values'=>$val[5],
  210 + ];
  211 + $extentInfoModel->addReturnId($extent);
  212 + }
  213 + //产品描述
  214 + if(!empty($val[7])){
  215 + //设置产品描述
  216 + $detail = [
  217 + 'title'=>'SEODescription',
199 'product_id'=>$id, 218 'product_id'=>$id,
200 - 'column_id'=>$faqId, 219 + 'column_id'=>1,
201 'text_type'=>1, 220 'text_type'=>1,
202 - 'content'=>json_encode(['content'=>$faqContent]) 221 + 'content'=>json_encode(['content'=>$val[7]])
203 ]; 222 ];
204 - $detailModel->addReturnId($detailFaqInfo);  
205 - }else{  
206 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export('产品标题:'. $val[1] . PHP_EOL .'faqs数据有问题:' . $val[4], true) . PHP_EOL, FILE_APPEND);  
207 - echo date('Y-m-d H:i:s') . '产品标题:'. $val[1] . PHP_EOL .'faqs数据有问题:' . $val[4]; 223 + $detailModel->addReturnId($detail);
  224 + }
  225 + //产品描述
  226 + if(!empty($val[8])){
  227 + //设置产品描述
  228 + $detail = [
  229 + 'title'=>'SEOSpecification',
  230 + 'product_id'=>$id,
  231 + 'column_id'=>1,
  232 + 'text_type'=>1,
  233 + 'content'=>json_encode(['content'=>$val[8]])
  234 + ];
  235 + $detailModel->addReturnId($detail);
  236 + }
  237 + if(!empty($val[9])){
  238 + try {
  239 + $faqsDetail = json_decode($val[9],true);
  240 + if(!empty($faqsDetail) && is_array($faqsDetail)){
  241 + $faqContent = '<div>';
  242 + foreach ($faqsDetail as $faq_Val){
  243 + $faqContent .= "<span>question:".$faq_Val['question'] . "</span><br /><span>" . "answer:".$faq_Val['answer']. "</span><br />";
  244 + }
  245 + $faqContent .= '</div>';
  246 + $detailFaqInfo = [
  247 + 'title'=>'SEOQandA',
  248 + 'product_id'=>$id,
  249 + 'column_id'=>1,
  250 + 'text_type'=>1,
  251 + 'content'=>json_encode(['content'=>$faqContent])
  252 + ];
  253 + $detailModel->addReturnId($detailFaqInfo);
  254 + }else{
  255 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export('产品标题:'. $val[0] . PHP_EOL .'faqs数据有问题:' . $val[9], true) . PHP_EOL, FILE_APPEND);
  256 + echo date('Y-m-d H:i:s') . '产品标题:'. $val[0] . PHP_EOL .'faqs数据有问题:' . $val[9];
  257 + }
  258 + }catch(\Exception $e){
  259 + echo 'fqs';
  260 + }
  261 + }
  262 + if(!empty($val[10])){
  263 + try {
  264 + $faqsDetail = json_decode($val[10],true);
  265 + if(!empty($faqsDetail) && is_array($faqsDetail)){
  266 + $faqContent = '<div>';
  267 + foreach ($faqsDetail as $faq_Val){
  268 + $faqContent .= "<span>question:".$faq_Val['question'] . "</span><br /><span>" . "answer:".$faq_Val['answer']. "</span><br />";
  269 + }
  270 + $faqContent .= '</div>';
  271 + $detailFaqInfo = [
  272 + 'title'=>'SEOQandA_Product',
  273 + 'product_id'=>$id,
  274 + 'column_id'=>1,
  275 + 'text_type'=>1,
  276 + 'content'=>json_encode(['content'=>$faqContent])
  277 + ];
  278 + $detailModel->addReturnId($detailFaqInfo);
  279 + }else{
  280 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export('产品标题:'. $val[0] . PHP_EOL .'faqs数据有问题:' . $val[10], true) . PHP_EOL, FILE_APPEND);
  281 + echo date('Y-m-d H:i:s') . '产品标题:'. $val[0] . PHP_EOL .'SEOQandA_Product数据有问题:' . $val[10];
  282 + }
  283 + }catch(\Exception $e){
  284 + continue;
  285 + }
208 } 286 }
209 } 287 }
210 return true; 288 return true;
@@ -163,7 +163,7 @@ class ProjectLogic extends BaseLogic @@ -163,7 +163,7 @@ class ProjectLogic extends BaseLogic
163 $this->setTypeSevenEdit($this->param); 163 $this->setTypeSevenEdit($this->param);
164 }else{ 164 }else{
165 //初始化项目 165 //初始化项目
166 - $this->createProjectData($this->param); 166 + $this->param = $this->createProjectData($this->param);
167 //双向绑定服务器,需放到保存项目的上方 167 //双向绑定服务器,需放到保存项目的上方
168 $this->setServers($this->param['serve_id'],$this->param['id']); 168 $this->setServers($this->param['serve_id'],$this->param['id']);
169 //ai_blog 169 //ai_blog
@@ -196,32 +196,6 @@ class ProjectLogic extends BaseLogic @@ -196,32 +196,6 @@ class ProjectLogic extends BaseLogic
196 } 196 }
197 197
198 /** 198 /**
199 - * @remark :开启推荐供应商设置  
200 - * @name :isPurchaser  
201 - * @author :lyh  
202 - * @method :post  
203 - * @time :2025/3/10 15:33  
204 - */  
205 - public function isPurchaser($project_id){  
206 - if($this->param['type'] == Project::TYPE_TWO){  
207 - if(empty($this->param['uptime'])){  
208 - $this->param['deploy_build']['is_supplier'] = 1;  
209 - }else{  
210 - //获取项目的上线时间  
211 - $projectInfo = $this->model->read(['id'=>$project_id],['uptime']);  
212 - //查看上线时间是否大于3天  
213 - $threeDaysAgo = date('Y-m-d H:i:s', strtotime('-3 days'));  
214 - if($projectInfo['uptime'] > $threeDaysAgo){  
215 - //上线时间大于当前时间的3天钱,默认不允许关闭推荐供应商  
216 - $this->param['deploy_build']['is_supplier'] = 1;  
217 - }  
218 - }  
219 - return true;  
220 - }  
221 -  
222 - }  
223 -  
224 - /**  
225 * @remark :开启AI博客后 199 * @remark :开启AI博客后
226 * @name :setAiBlog 200 * @name :setAiBlog
227 * @author :lyh 201 * @author :lyh
@@ -350,8 +324,19 @@ class ProjectLogic extends BaseLogic @@ -350,8 +324,19 @@ class ProjectLogic extends BaseLogic
350 * @time :2023/8/30 12:14 324 * @time :2023/8/30 12:14
351 */ 325 */
352 public function saveProject($param){ 326 public function saveProject($param){
353 - if((($param['type'] == Project::TYPE_TWO) || ($param['type'] == Project::TYPE_THREE)) && empty($param['uptime'])){  
354 - $param['uptime'] = date('Y-m-d H:i:s'); 327 + if((($param['type'] == Project::TYPE_TWO) || ($param['type'] == Project::TYPE_THREE))){
  328 + //自动开启推荐供应商
  329 + if(empty($param['uptime'])){
  330 + $this->param['deploy_build']['is_supplier'] = 1;
  331 + $param['uptime'] = date('Y-m-d H:i:s');
  332 + }else{
  333 + //查看上线时间是否大于3天
  334 + $threeDaysAgo = date('Y-m-d H:i:s', strtotime('-3 days'));
  335 + if($param['uptime'] > $threeDaysAgo){
  336 + //上线时间大于当前时间的3天钱,默认不允许关闭推荐供应商
  337 + $this->param['deploy_build']['is_supplier'] = 1;
  338 + }
  339 + }
355 } 340 }
356 if($param['type'] == Project::TYPE_FIVE){ 341 if($param['type'] == Project::TYPE_FIVE){
357 $param['extend_type'] = Project::TYPE_FIVE; 342 $param['extend_type'] = Project::TYPE_FIVE;
@@ -603,7 +588,7 @@ class ProjectLogic extends BaseLogic @@ -603,7 +588,7 @@ class ProjectLogic extends BaseLogic
603 //改为异步 588 //改为异步
604 NoticeLog::createLog(NoticeLog::TYPE_INIT_PROJECT, ['project_id' => $param['id']]); 589 NoticeLog::createLog(NoticeLog::TYPE_INIT_PROJECT, ['project_id' => $param['id']]);
605 } 590 }
606 - return $this->success(); 591 + return $this->success($param);
607 } 592 }
608 593
609 /** 594 /**