作者 赵彬吉
... ... @@ -297,13 +297,16 @@ class VideoTask extends Command
break;
}
$keyword_ids = implode(',',$item->keyword_id);
$keyword_video_ids = implode(',',$item->keyword_video_id);
if (strpos(','.$keyword_ids.',', ','.$keyword_id.',') === false) {
if(strpos(','.$keyword_video_ids.',', ','.$keyword_id.',') === false){
//不包含
$productModel = new Product();
$keyword_ids = !empty($keyword_ids) ? ','.$keyword_ids.',' : ',' ;
$keyword_id_str = $keyword_ids . $keyword_id.',';
KeywordRelated::saveRelated($item->id,explode(',',trim($keyword_id_str,',')));
$productModel->edit(['keyword_id'=>$keyword_id_str],['id'=>$item->id]);
$keyword_video_ids = !empty($keyword_video_ids) ? ','.$keyword_video_ids.',' : ',' ;
$keyword_video_id_str = $keyword_video_ids . $keyword_id.',';
$productModel->edit(['keyword_video_id'=>$keyword_video_id_str],['id'=>$item->id]);
KeywordRelated::saveRelated($item->id,$keyword_video_ids,2);
}
}
$data[] = ['url'=>getImageUrl($item->thumb['url']),'title'=>$item->title];
}
... ...
... ... @@ -26,6 +26,7 @@ use App\Models\File\Image as ImageModel;
use App\Models\News\News;
use App\Models\News\NewsCategory;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\Project\DeployOptimize;
use App\Models\Project\MinorLanguages;
... ... @@ -61,31 +62,51 @@ class Demo extends Command
protected $description = 'demo';
public function handle(){
// $projectModel = new Project();
// $list = $projectModel->list(['id'=>1659]);
// foreach ($list as $v){
// echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
// ProjectServer::useProject($v['id']);
$projectModel = new Project();
$list = $projectModel->list(['is_upgrade'=>0,'delete_status'=>0]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
// $this->getProduct();
// DB::disconnect('custom_mysql');
// }
return $this->savePurchaserInfo();
$this->copyProduct();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
public function getProduct(){
$productModel = new Product();
$lists = $productModel->list(['status'=>['!=',2]]);
$lists = $productModel->list(['status'=>['!=',3]]);
if(!empty($lists)){
foreach ($lists as $v){
if(!empty($v['route'])){
if(!empty($v['keyword_id'])){
echo date('Y-m-d H:i:s') . 'id :'.$v['id'] . PHP_EOL;
$route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT, $v['id'], $v['project_id']);
$productModel->edit(['route'=>$route],['id'=>$v['id']]);
$keyword_arr = [];
$count = count($v['keyword_id']);
if($count > 7){
foreach ($v['keyword_id'] as $key => $val){
if($key > 6){
break;
}
$keyword_arr[] = $val;
}
$keyword_str = explode(',',$keyword_arr);
$productModel->edit(['keyword_id'=>$keyword_str],['id'=>$v['id']]);
$keywordRelatedModel = new KeywordRelated();
$keywordRelatedModel->edit(['type'=>2],['keyword_id'=>$val,'product_id'=>$v['id']]);
}
}
}
}
}
public function copyProduct(){
$tableName = 'gl_product';
$copyTableName = $tableName . '_c';
// 创建新表并复制数据
DB::connection('custom_mysql')->statement("CREATE TABLE {$copyTableName} LIKE {$tableName}");
DB::connection('custom_mysql')->statement("INSERT INTO {$copyTableName} SELECT * FROM {$tableName}");
}
/**
* @remark :保存供应商详情
... ...
... ... @@ -12,6 +12,7 @@ namespace App\Console\Commands\Update;
use App\Models\Domain\DomainInfo;
use App\Models\Product\Keyword;
use App\Models\Product\KeywordPage;
use App\Models\Product\Product;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
... ... @@ -106,4 +107,19 @@ class UpdateKeyword extends Command
shell_exec('curl -k "'.$url.'"');
return true;
}
/**
* @remark :更新产品关键词
* @name :updatedProductKeyword
* @author :lyh
* @method :post
* @time :2024/11/27 14:26
*/
public function updatedProductKeyword(){
$productModel = new Product();
$lists = $productModel->list();
foreach ($lists as $k => $v){
}
}
}
... ...
... ... @@ -110,7 +110,7 @@ class DetailController extends BaseController
'product_id.required' => '产品id不能为空',
'data.required' => 'data不能为空',
]);
$data = $logic->saveDetail();
$data = $logic->saveDetail($this->param['product_id'],$this->param['data']);
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -94,7 +94,7 @@ class TranslateController extends BaseController
$resData['route'] = $values['url'];
$resData['page'] = $values['page'];
$resData['data'] = [];
$keyInfo = $keyModel->read(['route'=>$values['route'],'page'=>$values['page']],['id','proof_key']);
$keyInfo = $keyModel->read(['url'=>$values['url'],'page'=>$values['page']],['id','proof_key']);
if($keyInfo !== false){
$result_id_data[] = $keyInfo['id'];
$translate_data = json_decode($values['translate_data']['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
... ... @@ -106,7 +106,7 @@ class TranslateController extends BaseController
}
}
}
$resData['data'] = $translate_data;
$resData['data'] = $translate_data ?? [];
$res_data[] = $resData;
}
$keyList = $keyModel->list(['id'=>['not in',$result_id_data]],'id',['id','proof_key','url','page']);
... ... @@ -391,17 +391,6 @@ class TranslateController extends BaseController
}
/**
* @remark :获取默认数据
* @name :getDefaultData
* @author :lyh
* @method :post
* @time :2024/7/16 15:28
*/
public function getDefaultData(){
}
/**
* @remark :
* @name :pageList
* @author :lyh
... ...
... ... @@ -29,7 +29,7 @@ class ImportLogic extends BaseLogic
$this->fail('导入文件格式必须为csv');
}
$domain = $this->param['domain'];
if (strpos($domain, 'https') === false && strpos($domain, 'http') == false) {
if (strpos($domain, 'https') === false && strpos($domain, 'http') === false) {
$this->fail('请输入完整的采集页面地址');
}
$domain_arr = parse_url($domain);
... ...
... ... @@ -50,15 +50,15 @@ class DetailLogic extends BaseLogic
* @method :post
* @time :2024/11/13 9:30
*/
public function saveDetail(){
if(!empty($this->param['data'])){
public function saveDetail($product_id,$data){
if(!empty($data)){
try {
foreach ($this->param['data'] as $data){
foreach ($data as $v){
foreach ($data as $val){
foreach ($val as $v){
$save_data = [
'sort'=>$v['sort'],
'column_id'=>$v['column_id'],
'product_id'=>$this->param['product_id'],
'product_id'=>$product_id,
'text_type'=>$v['text_type'],
'title'=>$v['title'] ?? '',
'content'=>json_encode($v['content'] ?? [],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
... ... @@ -75,6 +75,6 @@ class DetailLogic extends BaseLogic
$this->fail('保存失败,请联系管理员.错误:'.$e->getMessage());
}
}
return $this->success(['product_id'=>$this->param['product_id']]);
return $this->success(['product_id'=>$product_id]);
}
}
... ...
... ... @@ -67,6 +67,9 @@ class ProductLogic extends BaseLogic
//产品分类关联
CategoryRelated::saveRelated($id, $category_ids);
KeywordRelated::saveRelated($id,$category_ids);
//更新产品新描述
$detailLogic = new DetailLogic();
$detailLogic->saveDetail($id,$this->param['data'] ?? []);
//保存扩展字段
$this->saveExtendInfo($id,$extend);
}catch (\Exception $e){
... ...
... ... @@ -294,10 +294,8 @@ class TranslateLogic extends BaseLogic
$id = $this->model->addReturnId($param);
TranslateData::insert(['trans_id'=>$id,'data'=>json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)]);
}else{
if(!empty($data)){
TranslateData::where(['trans_id'=>$info['id']])->update(['data'=>json_encode($data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)]);
}
}
//写日志
$userLogModel = new UserLog();
$userLogModel->add(['model'=>'translate/save','remark'=>json_encode($this->param,true),'type'=>0,'operator_id'=>$this->user['id'],'project_id'=>$this->user['project_id']]);
... ...
... ... @@ -24,19 +24,20 @@ class KeywordRelated extends Base
* @author zbj
* @date 2023/5/4
*/
public static function saveRelated($product_id, $keyword_ids)
public static function saveRelated($product_id, $keyword_ids,$type = 1)
{
if(!is_array($keyword_ids)){
$keyword_ids = array_filter(Arr::splitFilterToArray($keyword_ids), 'intval');
}
//先删除
self::where('product_id', $product_id)->delete();
self::where('product_id', $product_id)->where('type',$type)->delete();
//批量保存
$data = [];
if(!empty($keyword_ids)){
foreach ($keyword_ids as $keyword_id){
$data[] = [
'type' => $type,
'product_id' => $product_id,
'keyword_id' => $keyword_id,
'created_at'=>date('Y-m-d H:i:s'),
... ...
... ... @@ -196,7 +196,9 @@ class Product extends Base
public function getKeywordIdAttribute($value){
return Arr::setToArr(trim($value,','));
}
public function getKeywordVideoIdAttribute($value){
return Arr::setToArr(trim($value,','));
}
public function getRelatedProductIdAttribute($value){
return Arr::setToArr($value);
}
... ...