作者 Your Name
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :SendProduct.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/30 14:41
  8 + */
  9 +
  10 +namespace App\Console\Commands\Product;
  11 +
  12 +use App\Models\Blog\Blog;
  13 +use App\Models\Domain\DomainInfo;
  14 +use App\Models\News\News;
  15 +use App\Models\Product\Product;
  16 +use App\Models\Project\Project;
  17 +use App\Services\ProjectServer;
  18 +use Illuminate\Console\Command;
  19 +use Illuminate\Support\Facades\DB;
  20 +
  21 +class SendProduct extends Command
  22 +{
  23 + /**
  24 + * The name and signature of the console command.
  25 + *
  26 + * @var string
  27 + */
  28 + protected $signature = 'send_product';
  29 +
  30 + /**
  31 + * The console command description.
  32 + *
  33 + * @var string
  34 + */
  35 + protected $description = '根据发布时间发布产品';
  36 +
  37 + /**
  38 + * @remark :发布
  39 + * @name :handle
  40 + * @author :lyh
  41 + * @method :post
  42 + * @time :2024/8/30 14:42
  43 + */
  44 + public function handle(){
  45 + $projectModel = new Project();
  46 + $list = $projectModel->list(['deleted_status'=>0]);
  47 + $data = [];
  48 + foreach ($list as $v){
  49 + echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
  50 + ProjectServer::useProject($v['id']);
  51 + $domainModel = new DomainInfo();
  52 + $domain = $domainModel->getProjectIdDomain($v['id']);
  53 + if(empty($domain)){
  54 + continue;
  55 + }
  56 + $arr1 = $this->sendProduct();
  57 + $arr2 = $this->sendBlog();
  58 + $arr3 = $this->sendNews();
  59 + $c_url = $domain.'api/update_page/';
  60 + $param = [
  61 + 'project_id' => $this->user['project_id'],
  62 + 'type' => 1,
  63 + 'route' => 3,
  64 + 'url' => array_merge($arr1,$arr2,$arr3),
  65 + 'language'=> [],
  66 + 'is_sitemap' => 0
  67 + ];
  68 + http_post($c_url, json_encode($param));
  69 + //TODO::通知C端生成界面
  70 + DB::disconnect('custom_mysql');
  71 + }
  72 + echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
  73 + }
  74 +
  75 + /**
  76 + * @remark :发布产品
  77 + * @name :sendProduct
  78 + * @author :lyh
  79 + * @method :post
  80 + * @time :2024/8/30 14:44
  81 + */
  82 + public function sendProduct(){
  83 + $start_date = date('Y-m-d H:i:s');
  84 + $end_date = date('Y-m-d 23:59:59');
  85 + $productModel = new Product();
  86 + $arr = $productModel->formatQuery(['send_time'=>['between',[$start_date,$end_date]],'status'=>3])->pluck('route');
  87 + $productModel->edit(['status'=>1],['send_time'=>['between',[$start_date,$end_date]],'status'=>3]);
  88 + return $arr;
  89 + }
  90 +
  91 + /**
  92 + * @remark :定时发布博客
  93 + * @name :sendBlog
  94 + * @author :lyh
  95 + * @method :post
  96 + * @time :2024/8/30 15:19
  97 + */
  98 + public function sendBlog(){
  99 + $start_date = date('Y-m-d H:i:s');
  100 + $end_date = date('Y-m-d 23:59:59');
  101 + $blogModel = new Blog();
  102 + $arr = $blogModel->formatQuery(['send_time'=>['between',[$start_date,$end_date]],'status'=>3])->pluck('url');
  103 + $blogModel->edit(['status'=>1],['release_at'=>['between',[$start_date,$end_date]],'status'=>3]);
  104 + return $arr;
  105 + }
  106 +
  107 + /**
  108 + * @remark :定时发布新闻
  109 + * @name :sendNews
  110 + * @author :lyh
  111 + * @method :post
  112 + * @time :2024/8/30 15:19
  113 + */
  114 + public function sendNews(){
  115 + $start_date = date('Y-m-d H:i:s');
  116 + $end_date = date('Y-m-d 23:59:59');
  117 + $newsModel = new News();
  118 + $arr = $newsModel->formatQuery(['send_time'=>['between',[$start_date,$end_date]],'status'=>3])->pluck('url');
  119 + $newsModel->edit(['status'=>1],['release_at'=>['between',[$start_date,$end_date]],'status'=>3]);
  120 + return $arr;
  121 + }
  122 +}
@@ -383,20 +383,12 @@ class ProjectUpdate extends Command @@ -383,20 +383,12 @@ class ProjectUpdate extends Command
383 'sort' => $item['sort'] ?? 0, 383 'sort' => $item['sort'] ?? 0,
384 'files' => $files, 384 'files' => $files,
385 ], ['id' => $id]); 385 ], ['id' => $id]);
386 - } else {  
387 - //按6.0展示只更新分类  
388 - $model->edit([  
389 - 'category_id' => $category_id  
390 - ], ['id' => $id]);  
391 } 386 }
392 } 387 }
393 388
394 - //关联分类  
395 - if ($category_arr) {  
396 - CategoryRelated::saveRelated($id, array_column($category_arr, 'id'));  
397 - }  
398 -  
399 if ($six_read) { 389 if ($six_read) {
  390 + //关联分类
  391 + CategoryRelated::saveRelated($id, array_column($category_arr, 'id'));
400 //扩展字段 392 //扩展字段
401 if ($item['extend'] ?? []) { 393 if ($item['extend'] ?? []) {
402 foreach (array_reverse($item['extend']) as $ke => $ve) { 394 foreach (array_reverse($item['extend']) as $ke => $ve) {
@@ -508,9 +500,7 @@ class ProjectUpdate extends Command @@ -508,9 +500,7 @@ class ProjectUpdate extends Command
508 500
509 CollectTask::_insert($item['url'], $project_id, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $domain_arr['host'], $link_type, $language_list, $page_list); 501 CollectTask::_insert($item['url'], $project_id, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $domain_arr['host'], $link_type, $language_list, $page_list);
510 } else { 502 } else {
511 - $id = $news['id'];  
512 - $six_read = $news['six_read'];  
513 - if ($six_read) { 503 + if ($news['six_read']) {
514 //按5.0展示才需要更新数据 504 //按5.0展示才需要更新数据
515 $model->edit([ 505 $model->edit([
516 'name' => $item['ttile'], 506 'name' => $item['ttile'],
@@ -522,7 +512,7 @@ class ProjectUpdate extends Command @@ -522,7 +512,7 @@ class ProjectUpdate extends Command
522 'image' => $new_img, 512 'image' => $new_img,
523 'release_at' => $item['post_date'] ?? date('Y-m-d H:i:s'), 513 'release_at' => $item['post_date'] ?? date('Y-m-d H:i:s'),
524 'sort' => $item['sort'] ?? 0, 514 'sort' => $item['sort'] ?? 0,
525 - ], ['id' => $id]); 515 + ], ['id' => $news['id']]);
526 } 516 }
527 } 517 }
528 } catch (\Exception $e) { 518 } catch (\Exception $e) {
@@ -164,7 +164,11 @@ class ProductController extends BaseController @@ -164,7 +164,11 @@ class ProductController extends BaseController
164 $query = $query->where('title','like','%'.$this->map['title'].'%'); 164 $query = $query->where('title','like','%'.$this->map['title'].'%');
165 } 165 }
166 if(isset($this->map['status'])){ 166 if(isset($this->map['status'])){
167 - $query = $query->where('status',$this->map['status']); 167 + if($this->map['status'] == 0){
  168 + $query = $query->whereIn('status',[0,3]);
  169 + }else{
  170 + $query = $query->where('status',$this->map['status']);
  171 + }
168 } 172 }
169 if(isset($this->map['created_uid'])){ 173 if(isset($this->map['created_uid'])){
170 $query = $query->where('created_uid',$this->map['created_uid']); 174 $query = $query->where('created_uid',$this->map['created_uid']);
@@ -721,4 +725,20 @@ class ProductController extends BaseController @@ -721,4 +725,20 @@ class ProductController extends BaseController
721 $typeModel->del(['project_id'=>$this->user['project_id'],'name'=>$this->param['name']]); 725 $typeModel->del(['project_id'=>$this->user['project_id'],'name'=>$this->param['name']]);
722 $this->response('success'); 726 $this->response('success');
723 } 727 }
  728 +
  729 + /**
  730 + * @remark :获取按钮
  731 + * @name :getButton
  732 + * @author :lyh
  733 + * @method :post
  734 + * @time :2024/8/30 16:29
  735 + */
  736 + public function getButton(){
  737 + return [
  738 + '0'=>'草稿',
  739 + '1'=>'发布',
  740 + '2'=>'回收站',
  741 + '3'=>'待发布'
  742 + ];
  743 + }
724 } 744 }
@@ -260,6 +260,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -260,6 +260,7 @@ Route::middleware(['bloginauth'])->group(function () {
260 Route::any('/getProductType', [\App\Http\Controllers\Bside\Product\ProductController::class, 'getProductType'])->name('product_getProductType'); 260 Route::any('/getProductType', [\App\Http\Controllers\Bside\Product\ProductController::class, 'getProductType'])->name('product_getProductType');
261 Route::any('/saveType', [\App\Http\Controllers\Bside\Product\ProductController::class, 'saveType'])->name('product_saveType'); 261 Route::any('/saveType', [\App\Http\Controllers\Bside\Product\ProductController::class, 'saveType'])->name('product_saveType');
262 Route::any('/delProductType', [\App\Http\Controllers\Bside\Product\ProductController::class, 'delProductType'])->name('product_delProductType'); 262 Route::any('/delProductType', [\App\Http\Controllers\Bside\Product\ProductController::class, 'delProductType'])->name('product_delProductType');
  263 + Route::any('/getButton', [\App\Http\Controllers\Bside\Product\ProductController::class, 'getButton'])->name('product_getButton');
263 //产品分类 264 //产品分类
264 Route::get('category', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'index'])->name('product_category'); 265 Route::get('category', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'index'])->name('product_category');
265 Route::get('category/info', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'info'])->name('product_category_info'); 266 Route::get('category/info', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'info'])->name('product_category_info');