作者 李宇航

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

Lyh server



查看合并请求 !1429
... ... @@ -17,6 +17,7 @@ use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Column;
use App\Models\Product\Detail;
use App\Models\Product\ExtendInfo;
use App\Models\Product\Product;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
... ... @@ -140,71 +141,148 @@ class LyhImportTest extends Command
$productModel = new Product();
$detailModel = new Detail();
$columnModel = new Column();
$extentInfoModel = new ExtendInfo();
foreach ($line_of_text as $k => $val){
if($k < 2){
if($k < 1){
continue;
}
$saveData = [];
if($val[1] ?? ''){
$saveData['title'] = $val[1];
if(!empty($val[0])){
$saveData['title'] = $val[0];
}else{
continue;
}
if($val[0] ?? ''){
$cateInfo = $cateModel->read(['seo_title'=>trim($val[0])]);
if(!empty($val[1])){
$cateInfo = $cateModel->read(['seo_title'=>trim($val[1])]);
if($cateInfo !== false){
$saveData['category_id'] = ','.$cateInfo['id'].',';
}
}
$saveData['intro'] = $val[2];
$saveData['content'] = $val[3];
$seo = ['seo_title'=>$val[5]];
$saveData['intro'] = $val[6] ?? '';
$seo = ['seo_title'=>$val[0]];
$saveData['seo_mate'] = json_encode($seo,true);
$thumb = ['alt'=>'主图','url'=>str_replace('/public','/upload/p/3283',$val[6])];
$gallery = [['alt'=>'主图','url'=>str_replace('/public','/upload/p/3283',$val[6])]];
$thumb = ['alt'=>'主图','url'=>str_replace('/public','/upload/p/3283',$val[11])];
$gallery = [['alt'=>'主图','url'=>str_replace('/public','/upload/p/3283',$val[11])]];
$saveData['thumb'] = json_encode($thumb,true);
$saveData['gallery'] = json_encode($gallery,true);
$id = $productModel->addReturnId($saveData);
echo date('Y-m-d H:i:s') . '新增产品id:'.$id . PHP_EOL;
//设置关联关系
if($cateInfo !== false){
CategoryRelated::saveRelated($id,[$cateInfo['id']]);
}
//设置路由
$route = RouteMap::setRoute($val[1],RouteMap::SOURCE_PRODUCT,$id,$project_id);
$route = RouteMap::setRoute($val[0],RouteMap::SOURCE_PRODUCT,$id,$project_id);
$productModel->edit(['route'=>$route],['id'=>$id]);
//设置产品描述
$detail = [
'product_id'=>$id,
'column_id'=>1,
'text_type'=>1,
'content'=>json_encode(['content'=>$val[3]])
];
$detailModel->addReturnId($detail);
//扩展描述设置
$detailFaq = [
'column_name'=>'FAQs',
'product_id'=>$id
];
$faqId = $columnModel->addReturnId($detailFaq);
$faqsDetail = json_decode($val[4],true);
if(!empty($faqsDetail) && is_array($faqsDetail)){
$faqContent = '<div>';
foreach ($faqsDetail as $faq_Val){
$faqContent .= "<span>question:".$faq_Val['question'] . "</span><br /><span>" . "answer:".$faq_Val['answer']. "</span><br />";
}
$faqContent .= '</div>';
$detailFaqInfo = [
echo date('Y-m-d H:i:s') . '新增产品id:'.$id . PHP_EOL;
if(!empty($val[2])){
$extent = [
'key'=>'pd_extended_field_4',
'product_id'=>$id,
'project_id'=>$project_id,
'values'=>$val[2],
];
$extentInfoModel->addReturnId($extent);
}
if(!empty($val[3])){
$extent = [
'key'=>'pd_extended_field_1',
'product_id'=>$id,
'project_id'=>$project_id,
'values'=>$val[3],
];
$extentInfoModel->addReturnId($extent);
}
if(!empty($val[4])){
$extent = [
'key'=>'pd_extended_field_2',
'product_id'=>$id,
'project_id'=>$project_id,
'values'=>$val[4],
];
$extentInfoModel->addReturnId($extent);
}
if(!empty($val[5])){
$extent = [
'key'=>'pd_extended_field_3',
'product_id'=>$id,
'project_id'=>$project_id,
'values'=>$val[5],
];
$extentInfoModel->addReturnId($extent);
}
//产品描述
if(!empty($val[7])){
//设置产品描述
$detail = [
'title'=>'SEODescription',
'product_id'=>$id,
'column_id'=>$faqId,
'column_id'=>1,
'text_type'=>1,
'content'=>json_encode(['content'=>$faqContent])
'content'=>json_encode(['content'=>$val[7]])
];
$detailModel->addReturnId($detailFaqInfo);
}else{
@file_put_contents(storage_path('logs/lyh_error.log'), var_export('产品标题:'. $val[1] . PHP_EOL .'faqs数据有问题:' . $val[4], true) . PHP_EOL, FILE_APPEND);
echo date('Y-m-d H:i:s') . '产品标题:'. $val[1] . PHP_EOL .'faqs数据有问题:' . $val[4];
$detailModel->addReturnId($detail);
}
//产品描述
if(!empty($val[8])){
//设置产品描述
$detail = [
'title'=>'SEOSpecification',
'product_id'=>$id,
'column_id'=>1,
'text_type'=>1,
'content'=>json_encode(['content'=>$val[8]])
];
$detailModel->addReturnId($detail);
}
if(!empty($val[9])){
try {
$faqsDetail = json_decode($val[9],true);
if(!empty($faqsDetail) && is_array($faqsDetail)){
$faqContent = '<div>';
foreach ($faqsDetail as $faq_Val){
$faqContent .= "<span>question:".$faq_Val['question'] . "</span><br /><span>" . "answer:".$faq_Val['answer']. "</span><br />";
}
$faqContent .= '</div>';
$detailFaqInfo = [
'title'=>'SEOQandA',
'product_id'=>$id,
'column_id'=>1,
'text_type'=>1,
'content'=>json_encode(['content'=>$faqContent])
];
$detailModel->addReturnId($detailFaqInfo);
}else{
@file_put_contents(storage_path('logs/lyh_error.log'), var_export('产品标题:'. $val[0] . PHP_EOL .'faqs数据有问题:' . $val[9], true) . PHP_EOL, FILE_APPEND);
echo date('Y-m-d H:i:s') . '产品标题:'. $val[0] . PHP_EOL .'faqs数据有问题:' . $val[9];
}
}catch(\Exception $e){
echo 'fqs';
}
}
if(!empty($val[10])){
try {
$faqsDetail = json_decode($val[10],true);
if(!empty($faqsDetail) && is_array($faqsDetail)){
$faqContent = '<div>';
foreach ($faqsDetail as $faq_Val){
$faqContent .= "<span>question:".$faq_Val['question'] . "</span><br /><span>" . "answer:".$faq_Val['answer']. "</span><br />";
}
$faqContent .= '</div>';
$detailFaqInfo = [
'title'=>'SEOQandA_Product',
'product_id'=>$id,
'column_id'=>1,
'text_type'=>1,
'content'=>json_encode(['content'=>$faqContent])
];
$detailModel->addReturnId($detailFaqInfo);
}else{
@file_put_contents(storage_path('logs/lyh_error.log'), var_export('产品标题:'. $val[0] . PHP_EOL .'faqs数据有问题:' . $val[10], true) . PHP_EOL, FILE_APPEND);
echo date('Y-m-d H:i:s') . '产品标题:'. $val[0] . PHP_EOL .'SEOQandA_Product数据有问题:' . $val[10];
}
}catch(\Exception $e){
continue;
}
}
}
return true;
... ...
... ... @@ -163,7 +163,7 @@ class ProjectLogic extends BaseLogic
$this->setTypeSevenEdit($this->param);
}else{
//初始化项目
$this->createProjectData($this->param);
$this->param = $this->createProjectData($this->param);
//双向绑定服务器,需放到保存项目的上方
$this->setServers($this->param['serve_id'],$this->param['id']);
//ai_blog
... ... @@ -196,32 +196,6 @@ class ProjectLogic extends BaseLogic
}
/**
* @remark :开启推荐供应商设置
* @name :isPurchaser
* @author :lyh
* @method :post
* @time :2025/3/10 15:33
*/
public function isPurchaser($project_id){
if($this->param['type'] == Project::TYPE_TWO){
if(empty($this->param['uptime'])){
$this->param['deploy_build']['is_supplier'] = 1;
}else{
//获取项目的上线时间
$projectInfo = $this->model->read(['id'=>$project_id],['uptime']);
//查看上线时间是否大于3天
$threeDaysAgo = date('Y-m-d H:i:s', strtotime('-3 days'));
if($projectInfo['uptime'] > $threeDaysAgo){
//上线时间大于当前时间的3天钱,默认不允许关闭推荐供应商
$this->param['deploy_build']['is_supplier'] = 1;
}
}
return true;
}
}
/**
* @remark :开启AI博客后
* @name :setAiBlog
* @author :lyh
... ... @@ -350,8 +324,19 @@ class ProjectLogic extends BaseLogic
* @time :2023/8/30 12:14
*/
public function saveProject($param){
if((($param['type'] == Project::TYPE_TWO) || ($param['type'] == Project::TYPE_THREE)) && empty($param['uptime'])){
$param['uptime'] = date('Y-m-d H:i:s');
if((($param['type'] == Project::TYPE_TWO) || ($param['type'] == Project::TYPE_THREE))){
//自动开启推荐供应商
if(empty($param['uptime'])){
$this->param['deploy_build']['is_supplier'] = 1;
$param['uptime'] = date('Y-m-d H:i:s');
}else{
//查看上线时间是否大于3天
$threeDaysAgo = date('Y-m-d H:i:s', strtotime('-3 days'));
if($param['uptime'] > $threeDaysAgo){
//上线时间大于当前时间的3天钱,默认不允许关闭推荐供应商
$this->param['deploy_build']['is_supplier'] = 1;
}
}
}
if($param['type'] == Project::TYPE_FIVE){
$param['extend_type'] = Project::TYPE_FIVE;
... ... @@ -603,7 +588,7 @@ class ProjectLogic extends BaseLogic
//改为异步
NoticeLog::createLog(NoticeLog::TYPE_INIT_PROJECT, ['project_id' => $param['id']]);
}
return $this->success();
return $this->success($param);
}
/**
... ...