作者 lyh

gx

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :UpdateProductCategory.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/12/6 16:07
  8 + */
  9 +
  10 +namespace App\Console\Commands;
  11 +
  12 +use App\Models\Product\Category;
  13 +use App\Models\Product\CategoryRelated;
  14 +use App\Models\Product\Product;
  15 +use App\Models\Project\Project;
  16 +use App\Services\ProjectServer;
  17 +use Illuminate\Console\Command;
  18 +use Illuminate\Support\Facades\DB;
  19 +
  20 +/**
  21 + * @remark :更新分类
  22 + * @name :UpdateProductCategory
  23 + * @author :lyh
  24 + * @method :post
  25 + * @time :2023/12/6 16:07
  26 + */
  27 +class UpdateProductCategory extends Command
  28 +{
  29 + /**
  30 + * The name and signature of the console command.
  31 + *
  32 + * @var string
  33 + */
  34 + protected $signature = 'update_product_cate';
  35 +
  36 + /**
  37 + * The console command description.
  38 + *
  39 + * @var string
  40 + */
  41 + protected $description = '更新产品分类';
  42 +
  43 + /**
  44 + * @remark :执行方法
  45 + * @name :handle
  46 + * @author :lyh
  47 + * @method :post
  48 + * @time :2023/12/6 16:09
  49 + */
  50 + public function handle(){
  51 + //获取所有项目
  52 + $projectModel = new Project();
  53 + $list = $projectModel->list(['type'=>['in',[1,2,3,4],'project_id'=>1]]);
  54 + try {
  55 + foreach ($list as $v) {
  56 + echo date('Y-m-d H:i:s') . ' start: ' . $v['id'] . PHP_EOL;
  57 + ProjectServer::useProject($v['id']);
  58 + $this->getUpdateProductCategory($v['id']);
  59 + DB::disconnect('custom_mysql');
  60 + }
  61 + }catch (\Exception $e){
  62 + echo date('Y-m-d H:i:s') . ' error: ->' . $e->getMessage() . PHP_EOL;
  63 + }
  64 + echo date('Y-m-d H:i:s') . ' end: ' . PHP_EOL;
  65 + }
  66 +
  67 + /**
  68 + * @remark :更新
  69 + * @name :getUpdateProductCategory
  70 + * @author :lyh
  71 + * @method :post
  72 + * @time :2023/12/6 16:12
  73 + */
  74 + public function getUpdateProductCategory(){
  75 + $productModel = new Product();
  76 + $lists = $productModel->list(['status'=>1],'id',['id','category_id']);
  77 + foreach ($lists as $k => $v){
  78 + if(!empty($v['category_id'])){
  79 + $this->handleCategory($v['id'],$v['category_id']);
  80 + }
  81 + }
  82 + return true;
  83 + }
  84 +
  85 + /**
  86 + * @remark :处理分类
  87 + * @name :handleCategory
  88 + * @author :lyh
  89 + * @method :post
  90 + * @time :2023/12/6 16:20
  91 + */
  92 + public function handleCategory($id,$category){
  93 + $category = trim($category,',');
  94 + $cate_arr = explode(',',$category);
  95 + if(!empty($cate_arr) && is_array($cate_arr)){
  96 + foreach ($cate_arr as $v){
  97 + $categoryModel = new Category();
  98 + $info = $categoryModel->read(['pid'=>$v],['id']);
  99 + if($info === false){
  100 + //有下级时,跳过
  101 + continue;
  102 + }else{
  103 + //更新关联表
  104 + $cateRelatedModel = new CategoryRelated();
  105 + $relateInfo = $cateRelatedModel->read(['product_id'=>$id,'cate_id'=>$v]);
  106 + if($relateInfo === false){
  107 + $cateRelatedModel->add(['product_id'=>$id, 'cate_id'=>$v]);
  108 + }
  109 + }
  110 + }
  111 + }
  112 + }
  113 +}
@@ -138,6 +138,14 @@ class OnlineController extends BaseController @@ -138,6 +138,14 @@ class OnlineController extends BaseController
138 $query->where('gl_project.title', 'like', '%' . $this->map['search'] . '%'); 138 $query->where('gl_project.title', 'like', '%' . $this->map['search'] . '%');
139 } 139 }
140 } 140 }
  141 + if(isset($this->map['qa_status']) && !empty($this->map['qa_status'])){
  142 + // 搜索状态
  143 + $query->where('gl_project_online_check.qa_status',$this->map['qa_status']);
  144 + }
  145 + if(isset($this->map['optimist_status']) && !empty($this->map['optimist_status'])){
  146 + // 搜索状态
  147 + $query->where('gl_project_online_check.optimist_status',$this->map['optimist_status']);
  148 + }
141 $query = $query->where('gl_project.status',1);//TODO::已提交审核 149 $query = $query->where('gl_project.status',1);//TODO::已提交审核
142 return $query; 150 return $query;
143 } 151 }
@@ -391,7 +391,6 @@ class BTemplateLogic extends BaseLogic @@ -391,7 +391,6 @@ class BTemplateLogic extends BaseLogic
391 */ 391 */
392 public function templateSaveParam($param){ 392 public function templateSaveParam($param){
393 $param['project_id'] = $this->user['project_id']; 393 $param['project_id'] = $this->user['project_id'];
394 - $param['html'] = $param['main_html'];  
395 unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']); 394 unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']);
396 return $this->success($param); 395 return $this->success($param);
397 } 396 }