作者 李宇航

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

修改生成报告错误问题



查看合并请求 !551
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :DeleteProductCategory.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/5/16 14:59
  8 + */
  9 +
  10 +namespace App\Console\Commands\DeleteCategory;
  11 +
  12 +use App\Models\Com\NoticeLog;
  13 +use Illuminate\Console\Command;
  14 +
  15 +/**
  16 + * @remark :删除分类
  17 + * @name :DeleteProductCategory
  18 + * @author :lyh
  19 + * @method :post
  20 + * @time :2024/5/16 15:00
  21 + */
  22 +class DeleteProductCategory extends Command
  23 +{
  24 + /**
  25 + * The name and signature of the console command.
  26 + *
  27 + * @var string
  28 + */
  29 + protected $signature = 'delete_product_category';
  30 +
  31 + /**
  32 + * The console command description.
  33 + *
  34 + * @var string
  35 + */
  36 + protected $description = '删除产品关键字';
  37 +
  38 + /**
  39 + * Create a new command instance.
  40 + *
  41 + * @return void
  42 + */
  43 + public function __construct()
  44 + {
  45 + parent::__construct();
  46 + }
  47 +
  48 + /**
  49 + * @remark :批量处理
  50 + * @name :handle
  51 + * @author :lyh
  52 + * @method :post
  53 + * @time :2024/5/16 15:02
  54 + */
  55 + public function handle(){
  56 + while (true){
  57 + $noticeLogModel = new NoticeLog();
  58 + $list = $noticeLogModel->list(['status'=>NoticeLog::STATUS_PENDING,'type'=>NoticeLog::DELETE_PRODUCT_CATEGORY],'id',['*'],'asc','100');
  59 + if(empty($list)){
  60 + sleep(100);
  61 + }
  62 + foreach ($list as $v){
  63 +
  64 + }
  65 + }
  66 + }
  67 +}
@@ -26,6 +26,11 @@ class ATemplateController extends BaseController @@ -26,6 +26,11 @@ class ATemplateController extends BaseController
26 * @time :2023/6/28 16:34 26 * @time :2023/6/28 16:34
27 */ 27 */
28 public function lists(ATemplateLogic $aTemplateLogic,TemplateLabel $templateLabel){ 28 public function lists(ATemplateLogic $aTemplateLogic,TemplateLabel $templateLabel){
  29 + if(isset($this->map['label_name']) && !empty($this->map['label_name'])){
  30 + $id_arr = $templateLabel->formatQuery(['name'=>['like','%'.$this->map['label_name'].'%']])->pluck('template_id')->toArray();
  31 + $this->map['id'] = ['in',$id_arr];
  32 + unset($this->map['label_name']);
  33 + }
29 $filed = ['id','name','image','url','status','sort','deleted_status','test_model','created_at','project_id']; 34 $filed = ['id','name','image','url','status','sort','deleted_status','test_model','created_at','project_id'];
30 $lists = $aTemplateLogic->aTemplateList($this->map,$this->page,$this->row,$this->order,$filed); 35 $lists = $aTemplateLogic->aTemplateList($this->map,$this->page,$this->row,$this->order,$filed);
31 if(!empty($lists) && !empty($lists['list'])){ 36 if(!empty($lists) && !empty($lists['list'])){
@@ -81,9 +81,9 @@ class MonthReportController extends BaseController @@ -81,9 +81,9 @@ class MonthReportController extends BaseController
81 ['status'=>1,'created_at'=>['between',[now()->subDays(30)->startOfDay()->toDateString(),now()->startOfDay()->toDateString()]] 81 ['status'=>1,'created_at'=>['between',[now()->subDays(30)->startOfDay()->toDateString(),now()->startOfDay()->toDateString()]]
82 ])->count(); 82 ])->count();
83 $newsModel = new News(); 83 $newsModel = new News();
84 - $info['news_num'] = $newsModel->formatQuery(['status'=>0])->count(); 84 + $info['news_num'] = $newsModel->formatQuery(['status'=>1])->count();
85 $info['news_num_last_7'] = $newsModel->formatQuery( 85 $info['news_num_last_7'] = $newsModel->formatQuery(
86 - ['status'=>0,'created_at'=>['between',[now()->subDays(7)->startOfDay()->toDateString(),now()->startOfDay()->toDateString()]] 86 + ['status'=>1,'created_at'=>['between',[now()->subDays(7)->startOfDay()->toDateString(),now()->startOfDay()->toDateString()]]
87 ])->count(); 87 ])->count();
88 $info['service_duration'] = $this->user['service_duration'];//服务天数 88 $info['service_duration'] = $this->user['service_duration'];//服务天数
89 $info['ip_total'] = (new Visit())->count();//ip总数 89 $info['ip_total'] = (new Visit())->count();//ip总数
@@ -148,7 +148,6 @@ class BlogCategoryController extends BaseController @@ -148,7 +148,6 @@ class BlogCategoryController extends BaseController
148 'id.array' => 'ID为数组', 148 'id.array' => 'ID为数组',
149 ]); 149 ]);
150 $blogCategoryLogic->delBlogCategory(); 150 $blogCategoryLogic->delBlogCategory();
151 - //TODO::写入操作日志  
152 $this->response('success'); 151 $this->response('success');
153 } 152 }
154 153
@@ -73,8 +73,8 @@ class BlogController extends BaseController @@ -73,8 +73,8 @@ class BlogController extends BaseController
73 if(isset($this->map['name']) && !empty($this->map['name'])){ 73 if(isset($this->map['name']) && !empty($this->map['name'])){
74 $query = $query->where('name',$this->map['name'][0],'%'.$this->map['name'][1].'%'); 74 $query = $query->where('name',$this->map['name'][0],'%'.$this->map['name'][1].'%');
75 } 75 }
76 - if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){  
77 - $query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]); 76 + if(!empty($this->param['start_at']) && !empty($this->param['end_at'])){
  77 + $query->whereBetween('created_at', [$this->param['start_at'],$this->param['end_at']]);
78 } 78 }
79 return $query; 79 return $query;
80 } 80 }
@@ -77,8 +77,8 @@ class NewsController extends BaseController @@ -77,8 +77,8 @@ class NewsController extends BaseController
77 if(isset($this->map['name']) && !empty($this->map['name'])){ 77 if(isset($this->map['name']) && !empty($this->map['name'])){
78 $query = $query->where('name',$this->map['name'][0],'%'.$this->map['name'][1].'%'); 78 $query = $query->where('name',$this->map['name'][0],'%'.$this->map['name'][1].'%');
79 } 79 }
80 - if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){  
81 - $query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]); 80 + if(!empty($this->param['start_at']) && !empty($this->param['end_at'])){
  81 + $query->whereBetween('created_at', [$this->param['start_at'],$this->param['end_at']]);
82 } 82 }
83 return $query; 83 return $query;
84 } 84 }
@@ -8,6 +8,7 @@ use App\Models\Blog\Blog; @@ -8,6 +8,7 @@ use App\Models\Blog\Blog;
8 use App\Models\Blog\Blog as BlogModel; 8 use App\Models\Blog\Blog as BlogModel;
9 use App\Models\Blog\BlogCategory; 9 use App\Models\Blog\BlogCategory;
10 use App\Models\Blog\BlogCategory as BlogCategoryModel; 10 use App\Models\Blog\BlogCategory as BlogCategoryModel;
  11 +use App\Models\Com\NoticeLog;
11 use App\Models\News\NewsCategory as NewsCategoryModel; 12 use App\Models\News\NewsCategory as NewsCategoryModel;
12 use App\Models\RouteMap\RouteMap; 13 use App\Models\RouteMap\RouteMap;
13 use App\Models\Template\BTemplate; 14 use App\Models\Template\BTemplate;
@@ -94,15 +95,18 @@ class BlogCategoryLogic extends BaseLogic @@ -94,15 +95,18 @@ class BlogCategoryLogic extends BaseLogic
94 * @method 95 * @method
95 */ 96 */
96 public function delBlogCategory(){ 97 public function delBlogCategory(){
97 - foreach ($this->param['id'] as $id){  
98 - //删除路由  
99 - $this->delRoute($id);  
100 - $this->model->del(['id'=>$id]);  
101 - //同步删除产品字段category_id  
102 - $blogModel = new Blog();  
103 - $blogModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]);  
104 - $blogModel->edit(['category_id'=>null],['category_id'=>',']); 98 + $ids = $this->param['id'];
  99 + foreach ($ids as $id){
  100 + $str = [];
  101 + $this->getAllSub($id,$str);
  102 + $str[] = $id;
  103 + foreach ($str as $value){
  104 + //删除路由
  105 + $this->delRoute($value);
  106 + $this->model->del(['id'=>$value]);
  107 + }
105 } 108 }
  109 + NoticeLog::createLog(NoticeLog::DELETE_BLOG_CATEGORY, ['project_id' => $this->user['project_id']]);
106 return $this->success(); 110 return $this->success();
107 } 111 }
108 112
@@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\News; @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\News;
4 4
5 use App\Helper\Translate; 5 use App\Helper\Translate;
6 use App\Http\Logic\Bside\BaseLogic; 6 use App\Http\Logic\Bside\BaseLogic;
  7 +use App\Models\Com\NoticeLog;
7 use App\Models\News\News; 8 use App\Models\News\News;
8 use App\Models\News\News as NewsModel; 9 use App\Models\News\News as NewsModel;
9 use App\Models\News\NewsCategory as NewsCategoryModel; 10 use App\Models\News\NewsCategory as NewsCategoryModel;
@@ -83,22 +84,27 @@ class NewsCategoryLogic extends BaseLogic @@ -83,22 +84,27 @@ class NewsCategoryLogic extends BaseLogic
83 $this->edit($this->param,['id'=>$this->param['id']]); 84 $this->edit($this->param,['id'=>$this->param['id']]);
84 return $this->success(); 85 return $this->success();
85 } 86 }
  87 +
86 /** 88 /**
87 - * @name :删除新闻分类  
88 - * @return array  
89 - * @throws \App\Exceptions\BsideGlobalException  
90 - * @author :liyuhang  
91 - * @method 89 + * @remark :删除分类
  90 + * @name :del_news_category
  91 + * @author :lyh
  92 + * @method :post
  93 + * @time :2024/5/16 14:58
92 */ 94 */
93 public function del_news_category(){ 95 public function del_news_category(){
94 - foreach ($this->param['id'] as $id){  
95 - $this->delRoute($id);  
96 - $this->model->del(['id'=>$id]);  
97 - //同步删除产品字段category_id  
98 - $newsModel = new NewsModel();  
99 - $newsModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]);  
100 - $newsModel->edit(['category_id'=>null],['category_id'=>',']); 96 + $ids = $this->param['id'];
  97 + foreach ($ids as $id){
  98 + $str = [];
  99 + $this->getAllSub($id,$str);
  100 + $str[] = $id;
  101 + foreach ($str as $value){
  102 + //删除路由
  103 + $this->delRoute($value);
  104 + $this->model->del(['id'=>$value]);
  105 + }
101 } 106 }
  107 + NoticeLog::createLog(NoticeLog::DELETE_NEWS_CATEGORY, ['project_id' => $this->user['project_id']]);
102 return $this->success(); 108 return $this->success();
103 } 109 }
104 110
@@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\Product; @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\Product;
5 use App\Helper\Arr; 5 use App\Helper\Arr;
6 use App\Helper\Common; 6 use App\Helper\Common;
7 use App\Http\Logic\Bside\BaseLogic; 7 use App\Http\Logic\Bside\BaseLogic;
  8 +use App\Models\Com\NoticeLog;
8 use App\Models\Product\Category; 9 use App\Models\Product\Category;
9 use App\Models\Product\CategoryRelated; 10 use App\Models\Product\CategoryRelated;
10 use App\Models\Product\Product; 11 use App\Models\Product\Product;
@@ -163,17 +164,16 @@ class CategoryLogic extends BaseLogic @@ -163,17 +164,16 @@ class CategoryLogic extends BaseLogic
163 public function categoryDelete(){ 164 public function categoryDelete(){
164 $ids = $this->param['ids']; 165 $ids = $this->param['ids'];
165 foreach ($ids as $id){ 166 foreach ($ids as $id){
166 - //删除路由  
167 - $this->delRoute($id);  
168 - $this->model->del(['id'=>$id]);  
169 - //同步删除关联表  
170 - $categoryRelatedModel = new CategoryRelated();  
171 - $categoryRelatedModel->del(['cate_id'=>$id]);  
172 - //同步删除产品字段category_id  
173 - $productModel = new Product();  
174 - $productModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]);  
175 - $productModel->edit(['category_id'=>null],['category_id'=>',']); 167 + $str = [];
  168 + $this->getAllSub($id,$str);
  169 + $str[] = $id;
  170 + foreach ($str as $value){
  171 + //删除路由
  172 + $this->delRoute($value);
  173 + $this->model->del(['id'=>$value]);
  174 + }
176 } 175 }
  176 + NoticeLog::createLog(NoticeLog::DELETE_PRODUCT_CATEGORY, ['project_id' => $this->user['project_id']]);
177 //清除缓存 177 //清除缓存
178 Common::del_user_cache('product_category',$this->user['project_id']); 178 Common::del_user_cache('product_category',$this->user['project_id']);
179 return $this->success(); 179 return $this->success();
@@ -2,9 +2,10 @@ @@ -2,9 +2,10 @@
2 namespace App\Models\Com; 2 namespace App\Models\Com;
3 3
4 use App\Helper\Arr; 4 use App\Helper\Arr;
  5 +use App\Models\Base;
5 use Illuminate\Database\Eloquent\Model; 6 use Illuminate\Database\Eloquent\Model;
6 7
7 -class NoticeLog extends Model 8 +class NoticeLog extends Base
8 { 9 {
9 //设置关联表名 10 //设置关联表名
10 protected $table = 'gl_notice_log'; 11 protected $table = 'gl_notice_log';
@@ -13,6 +14,9 @@ class NoticeLog extends Model @@ -13,6 +14,9 @@ class NoticeLog extends Model
13 const TYPE_RANK_DATA = 'rank_data'; 14 const TYPE_RANK_DATA = 'rank_data';
14 const TYPE_INIT_PROJECT = 'init_project'; 15 const TYPE_INIT_PROJECT = 'init_project';
15 const TYPE_INIT_KEYWORD = 'init_keyword'; 16 const TYPE_INIT_KEYWORD = 'init_keyword';
  17 + const DELETE_PRODUCT_CATEGORY = 'delete_product_category';
  18 + const DELETE_BLOG_CATEGORY = 'delete_blog_category';
  19 + const DELETE_NEWS_CATEGORY = 'delete_news_category';
16 const STATUS_PENDING = 0; 20 const STATUS_PENDING = 0;
17 const STATUS_SUCCESS = 1; 21 const STATUS_SUCCESS = 1;
18 const STATUS_FAIL = 2; 22 const STATUS_FAIL = 2;