作者 李宇航

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

修改生成报告错误问题



查看合并请求 !551
<?php
/**
* @remark :
* @name :DeleteProductCategory.php
* @author :lyh
* @method :post
* @time :2024/5/16 14:59
*/
namespace App\Console\Commands\DeleteCategory;
use App\Models\Com\NoticeLog;
use Illuminate\Console\Command;
/**
* @remark :删除分类
* @name :DeleteProductCategory
* @author :lyh
* @method :post
* @time :2024/5/16 15:00
*/
class DeleteProductCategory extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'delete_product_category';
/**
* The console command description.
*
* @var string
*/
protected $description = '删除产品关键字';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* @remark :批量处理
* @name :handle
* @author :lyh
* @method :post
* @time :2024/5/16 15:02
*/
public function handle(){
while (true){
$noticeLogModel = new NoticeLog();
$list = $noticeLogModel->list(['status'=>NoticeLog::STATUS_PENDING,'type'=>NoticeLog::DELETE_PRODUCT_CATEGORY],'id',['*'],'asc','100');
if(empty($list)){
sleep(100);
}
foreach ($list as $v){
}
}
}
}
... ...
... ... @@ -26,6 +26,11 @@ class ATemplateController extends BaseController
* @time :2023/6/28 16:34
*/
public function lists(ATemplateLogic $aTemplateLogic,TemplateLabel $templateLabel){
if(isset($this->map['label_name']) && !empty($this->map['label_name'])){
$id_arr = $templateLabel->formatQuery(['name'=>['like','%'.$this->map['label_name'].'%']])->pluck('template_id')->toArray();
$this->map['id'] = ['in',$id_arr];
unset($this->map['label_name']);
}
$filed = ['id','name','image','url','status','sort','deleted_status','test_model','created_at','project_id'];
$lists = $aTemplateLogic->aTemplateList($this->map,$this->page,$this->row,$this->order,$filed);
if(!empty($lists) && !empty($lists['list'])){
... ...
... ... @@ -81,9 +81,9 @@ class MonthReportController extends BaseController
['status'=>1,'created_at'=>['between',[now()->subDays(30)->startOfDay()->toDateString(),now()->startOfDay()->toDateString()]]
])->count();
$newsModel = new News();
$info['news_num'] = $newsModel->formatQuery(['status'=>0])->count();
$info['news_num'] = $newsModel->formatQuery(['status'=>1])->count();
$info['news_num_last_7'] = $newsModel->formatQuery(
['status'=>0,'created_at'=>['between',[now()->subDays(7)->startOfDay()->toDateString(),now()->startOfDay()->toDateString()]]
['status'=>1,'created_at'=>['between',[now()->subDays(7)->startOfDay()->toDateString(),now()->startOfDay()->toDateString()]]
])->count();
$info['service_duration'] = $this->user['service_duration'];//服务天数
$info['ip_total'] = (new Visit())->count();//ip总数
... ...
... ... @@ -148,7 +148,6 @@ class BlogCategoryController extends BaseController
'id.array' => 'ID为数组',
]);
$blogCategoryLogic->delBlogCategory();
//TODO::写入操作日志
$this->response('success');
}
... ...
... ... @@ -73,8 +73,8 @@ class BlogController extends BaseController
if(isset($this->map['name']) && !empty($this->map['name'])){
$query = $query->where('name',$this->map['name'][0],'%'.$this->map['name'][1].'%');
}
if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){
$query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]);
if(!empty($this->param['start_at']) && !empty($this->param['end_at'])){
$query->whereBetween('created_at', [$this->param['start_at'],$this->param['end_at']]);
}
return $query;
}
... ...
... ... @@ -77,8 +77,8 @@ class NewsController extends BaseController
if(isset($this->map['name']) && !empty($this->map['name'])){
$query = $query->where('name',$this->map['name'][0],'%'.$this->map['name'][1].'%');
}
if(!empty($this->map['start_at']) && !empty($this->map['end_at'])){
$query->whereBetween('created_at', [$this->map['start_at'],$this->map['end_at']]);
if(!empty($this->param['start_at']) && !empty($this->param['end_at'])){
$query->whereBetween('created_at', [$this->param['start_at'],$this->param['end_at']]);
}
return $query;
}
... ...
... ... @@ -8,6 +8,7 @@ use App\Models\Blog\Blog;
use App\Models\Blog\Blog as BlogModel;
use App\Models\Blog\BlogCategory;
use App\Models\Blog\BlogCategory as BlogCategoryModel;
use App\Models\Com\NoticeLog;
use App\Models\News\NewsCategory as NewsCategoryModel;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplate;
... ... @@ -94,15 +95,18 @@ class BlogCategoryLogic extends BaseLogic
* @method
*/
public function delBlogCategory(){
foreach ($this->param['id'] as $id){
//删除路由
$this->delRoute($id);
$this->model->del(['id'=>$id]);
//同步删除产品字段category_id
$blogModel = new Blog();
$blogModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]);
$blogModel->edit(['category_id'=>null],['category_id'=>',']);
$ids = $this->param['id'];
foreach ($ids as $id){
$str = [];
$this->getAllSub($id,$str);
$str[] = $id;
foreach ($str as $value){
//删除路由
$this->delRoute($value);
$this->model->del(['id'=>$value]);
}
}
NoticeLog::createLog(NoticeLog::DELETE_BLOG_CATEGORY, ['project_id' => $this->user['project_id']]);
return $this->success();
}
... ...
... ... @@ -4,6 +4,7 @@ namespace App\Http\Logic\Bside\News;
use App\Helper\Translate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Com\NoticeLog;
use App\Models\News\News;
use App\Models\News\News as NewsModel;
use App\Models\News\NewsCategory as NewsCategoryModel;
... ... @@ -83,22 +84,27 @@ class NewsCategoryLogic extends BaseLogic
$this->edit($this->param,['id'=>$this->param['id']]);
return $this->success();
}
/**
* @name :删除新闻分类
* @return array
* @throws \App\Exceptions\BsideGlobalException
* @author :liyuhang
* @method
* @remark :删除分类
* @name :del_news_category
* @author :lyh
* @method :post
* @time :2024/5/16 14:58
*/
public function del_news_category(){
foreach ($this->param['id'] as $id){
$this->delRoute($id);
$this->model->del(['id'=>$id]);
//同步删除产品字段category_id
$newsModel = new NewsModel();
$newsModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]);
$newsModel->edit(['category_id'=>null],['category_id'=>',']);
$ids = $this->param['id'];
foreach ($ids as $id){
$str = [];
$this->getAllSub($id,$str);
$str[] = $id;
foreach ($str as $value){
//删除路由
$this->delRoute($value);
$this->model->del(['id'=>$value]);
}
}
NoticeLog::createLog(NoticeLog::DELETE_NEWS_CATEGORY, ['project_id' => $this->user['project_id']]);
return $this->success();
}
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Http\Logic\Bside\Product;
use App\Helper\Arr;
use App\Helper\Common;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Com\NoticeLog;
use App\Models\Product\Category;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Product;
... ... @@ -163,17 +164,16 @@ class CategoryLogic extends BaseLogic
public function categoryDelete(){
$ids = $this->param['ids'];
foreach ($ids as $id){
//删除路由
$this->delRoute($id);
$this->model->del(['id'=>$id]);
//同步删除关联表
$categoryRelatedModel = new CategoryRelated();
$categoryRelatedModel->del(['cate_id'=>$id]);
//同步删除产品字段category_id
$productModel = new Product();
$productModel->edit(['category_id'=>DB::raw("REPLACE(category_id, ',$id,' , ',')")],['category_id'=>['like','%,'.$id.',%']]);
$productModel->edit(['category_id'=>null],['category_id'=>',']);
$str = [];
$this->getAllSub($id,$str);
$str[] = $id;
foreach ($str as $value){
//删除路由
$this->delRoute($value);
$this->model->del(['id'=>$value]);
}
}
NoticeLog::createLog(NoticeLog::DELETE_PRODUCT_CATEGORY, ['project_id' => $this->user['project_id']]);
//清除缓存
Common::del_user_cache('product_category',$this->user['project_id']);
return $this->success();
... ...
... ... @@ -2,9 +2,10 @@
namespace App\Models\Com;
use App\Helper\Arr;
use App\Models\Base;
use Illuminate\Database\Eloquent\Model;
class NoticeLog extends Model
class NoticeLog extends Base
{
//设置关联表名
protected $table = 'gl_notice_log';
... ... @@ -13,6 +14,9 @@ class NoticeLog extends Model
const TYPE_RANK_DATA = 'rank_data';
const TYPE_INIT_PROJECT = 'init_project';
const TYPE_INIT_KEYWORD = 'init_keyword';
const DELETE_PRODUCT_CATEGORY = 'delete_product_category';
const DELETE_BLOG_CATEGORY = 'delete_blog_category';
const DELETE_NEWS_CATEGORY = 'delete_news_category';
const STATUS_PENDING = 0;
const STATUS_SUCCESS = 1;
const STATUS_FAIL = 2;
... ...