作者 lyh

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6

  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]]],'id',['id']);
  54 + echo date('Y-m-d H:i:s') . ' start: ' . json_encode($list) . PHP_EOL;
  55 + try {
  56 + foreach ($list as $v) {
  57 + echo date('Y-m-d H:i:s') . ' start: ' . $v['id'] . PHP_EOL;
  58 + ProjectServer::useProject($v['id']);
  59 + $this->getUpdateProductCategory();
  60 + DB::disconnect('custom_mysql');
  61 + }
  62 + }catch (\Exception $e){
  63 + echo date('Y-m-d H:i:s') . ' error: ->' . $e->getMessage() . PHP_EOL;
  64 + }
  65 + echo date('Y-m-d H:i:s') . ' end: ' . PHP_EOL;
  66 + }
  67 +
  68 + /**
  69 + * @remark :更新
  70 + * @name :getUpdateProductCategory
  71 + * @author :lyh
  72 + * @method :post
  73 + * @time :2023/12/6 16:12
  74 + */
  75 + public function getUpdateProductCategory(){
  76 + $productModel = new Product();
  77 + $lists = $productModel->list(['status'=>1],'id',['id','category_id']);
  78 + foreach ($lists as $k => $v){
  79 + if(!empty($v['category_id'])){
  80 + $this->handleCategory($v['id'],$v['category_id']);
  81 + }
  82 + }
  83 + return true;
  84 + }
  85 +
  86 + /**
  87 + * @remark :处理分类
  88 + * @name :handleCategory
  89 + * @author :lyh
  90 + * @method :post
  91 + * @time :2023/12/6 16:20
  92 + */
  93 + public function handleCategory($id,$cate_arr){
  94 + if(!empty($cate_arr) && is_array($cate_arr)){
  95 + foreach ($cate_arr as $v){
  96 + $categoryModel = new Category();
  97 + $info = $categoryModel->read(['pid'=>$v],['id']);
  98 + if($info !== false){
  99 + //有下级时,跳过
  100 + continue;
  101 + }else{
  102 + //更新关联表
  103 + $cateRelatedModel = new CategoryRelated();
  104 + $relateInfo = $cateRelatedModel->read(['product_id'=>$id,'cate_id'=>$v]);
  105 + if($relateInfo === false){
  106 + $cateRelatedModel->add(['product_id'=>$id, 'cate_id'=>$v]);
  107 + }
  108 + }
  109 + }
  110 + }
  111 + }
  112 +}
@@ -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 }
@@ -298,6 +298,21 @@ class ProductController extends BaseController @@ -298,6 +298,21 @@ class ProductController extends BaseController
298 $v['values'] = ''; 298 $v['values'] = '';
299 } 299 }
300 }else{ 300 }else{
  301 + $v = $this->setTypValues($v,$info);
  302 + }
  303 + $list[$k] = $v;
  304 + }
  305 + return $list;
  306 + }
  307 +
  308 + /**
  309 + * @remark :扩展字段根据type返回类型
  310 + * @name :setTypValues
  311 + * @author :lyh
  312 + * @method :post
  313 + * @time :2023/12/6 14:43
  314 + */
  315 + public function setTypValues($v,$info){
301 if($v['type'] == 3){ 316 if($v['type'] == 3){
302 $arr = json_decode($info['values']); 317 $arr = json_decode($info['values']);
303 foreach ($arr as $k1=>$v1){ 318 foreach ($arr as $k1=>$v1){
@@ -316,10 +331,7 @@ class ProductController extends BaseController @@ -316,10 +331,7 @@ class ProductController extends BaseController
316 }else{ 331 }else{
317 $v['values'] = $info['values']; 332 $v['values'] = $info['values'];
318 } 333 }
319 - }  
320 - $list[$k] = $v;  
321 - }  
322 - return $list; 334 + return $this->success($v);
323 } 335 }
324 336
325 /** 337 /**
@@ -75,6 +75,9 @@ class OnlineCheckLogic extends BaseLogic @@ -75,6 +75,9 @@ class OnlineCheckLogic extends BaseLogic
75 if(($this->param['optimist_mid'] == 0) || ($this->param['qa_mid'] == 0)){ 75 if(($this->param['optimist_mid'] == 0) || ($this->param['qa_mid'] == 0)){
76 $this->fail('请先选择优化师和品控,在提交审核'); 76 $this->fail('请先选择优化师和品控,在提交审核');
77 } 77 }
  78 + $projectModel = new Project();
  79 + //提交审核修改状态为审核中
  80 + $projectModel->edit(['status'=>1],['id'=>$this->param['id']]);
78 //组装数据 81 //组装数据
79 $data = [ 82 $data = [
80 'project_id' => $this->param['id'], 83 'project_id' => $this->param['id'],
@@ -88,9 +91,6 @@ class OnlineCheckLogic extends BaseLogic @@ -88,9 +91,6 @@ class OnlineCheckLogic extends BaseLogic
88 $this->fail('error'); 91 $this->fail('error');
89 } 92 }
90 } 93 }
91 - $projectModel = new Project();  
92 - //提交审核修改状态为审核中  
93 - $projectModel->edit(['status'=>1],['id'=>$this->param['id']]);  
94 return $this->success(); 94 return $this->success();
95 } 95 }
96 } 96 }
@@ -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 }
@@ -11,6 +11,7 @@ namespace App\Http\Logic\Bside\CustomModule; @@ -11,6 +11,7 @@ namespace App\Http\Logic\Bside\CustomModule;
11 11
12 use App\Http\Logic\Bside\BaseLogic; 12 use App\Http\Logic\Bside\BaseLogic;
13 use App\Models\CustomModule\CustomModuleCategory; 13 use App\Models\CustomModule\CustomModuleCategory;
  14 +use App\Models\CustomModule\CustomModuleContent;
14 use App\Models\RouteMap\RouteMap; 15 use App\Models\RouteMap\RouteMap;
15 16
16 class CustomModuleCategoryLogic extends BaseLogic 17 class CustomModuleCategoryLogic extends BaseLogic
@@ -41,7 +42,7 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -41,7 +42,7 @@ class CustomModuleCategoryLogic extends BaseLogic
41 $menu = array(); 42 $menu = array();
42 $list = $this->model->list($this->param); 43 $list = $this->model->list($this->param);
43 if(!empty($list)){ 44 if(!empty($list)){
44 - foreach ($list as $k => $v){ 45 + foreach ($list as $v){
45 if($v['pid'] == 0){ 46 if($v['pid'] == 0){
46 $v['sub'] = _get_child($v['id'],$list); 47 $v['sub'] = _get_child($v['id'],$list);
47 $menu[] = $v; 48 $menu[] = $v;
@@ -110,7 +111,9 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -110,7 +111,9 @@ class CustomModuleCategoryLogic extends BaseLogic
110 public function categoryAdd(){ 111 public function categoryAdd(){
111 try { 112 try {
112 $id = $this->model->addReturnId($this->param); 113 $id = $this->model->addReturnId($this->param);
113 - $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $id, $this->user['project_id']); 114 + $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],
  115 + $id, $this->user['project_id']);
  116 + $this->handleAddSon($id);
114 $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route); 117 $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],$route);
115 $this->edit(['url' => $route], ['id' => $id]); 118 $this->edit(['url' => $route], ['id' => $id]);
116 }catch (\Exception $e){ 119 }catch (\Exception $e){
@@ -127,7 +130,8 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -127,7 +130,8 @@ class CustomModuleCategoryLogic extends BaseLogic
127 * @time :2023/12/5 10:55 130 * @time :2023/12/5 10:55
128 */ 131 */
129 public function categoryEdit(){ 132 public function categoryEdit(){
130 - $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $this->param['id'], $this->user['project_id']); 133 + $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'],
  134 + $this->param['id'], $this->user['project_id']);
131 $this->editNewsRoute($this->param['id'],$route); 135 $this->editNewsRoute($this->param['id'],$route);
132 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 136 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
133 if($rs === false){ 137 if($rs === false){
@@ -160,24 +164,23 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -160,24 +164,23 @@ class CustomModuleCategoryLogic extends BaseLogic
160 * @method :post 164 * @method :post
161 * @time :2023/6/13 11:34 165 * @time :2023/6/13 11:34
162 */ 166 */
163 - public function addProcessingSon($cate_id){ 167 + public function handleAddSon($cate_id){
164 if(isset($this->param['pid']) && !empty($this->param['pid'])) { 168 if(isset($this->param['pid']) && !empty($this->param['pid'])) {
165 $this->param['pid'] = 0; 169 $this->param['pid'] = 0;
166 } 170 }
167 //判断为子分类时 171 //判断为子分类时
168 if($this->param['pid'] != 0) { 172 if($this->param['pid'] != 0) {
169 //查看当前上级分类下是否有其他分类 173 //查看当前上级分类下是否有其他分类
170 - $cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]]); 174 + $cate_info = $this->model->read(['pid' => $this->param['pid'], 'id' => ['!=', $cate_id]],['id']);
171 if ($cate_info === false) { 175 if ($cate_info === false) {
172 //查看当前上一级分类下是否有关联模块内容 176 //查看当前上一级分类下是否有关联模块内容
173 - $newsModel = new NewsModel();  
174 - $news_count = $newsModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count(); 177 + $contentModel = new CustomModuleContent();
  178 + $news_count = $contentModel->where('category_id','like', '%,' . $this->param['pid'] . ',%')->count();
175 if ($news_count > 0) { 179 if ($news_count > 0) {
176 - $replacement = ',' . $cate_id . ',';  
177 - $old = ',' . $this->param['pid'] . ','; 180 + $replacement = $this->handleStr($cate_id);
  181 + $old = $this->handleStr($this->param['pid']);
178 //更新所有商品到当前分类 182 //更新所有商品到当前分类
179 - $newsModel->where('category_id', 'like', '%' . $old . '%')  
180 - ->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]); 183 + $contentModel->where('category_id', 'like', '%' . $old . '%')->update(['category_id' => DB::raw("REPLACE(category_id, '$old', '$replacement')")]);
181 } 184 }
182 } 185 }
183 } 186 }
@@ -185,6 +188,17 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -185,6 +188,17 @@ class CustomModuleCategoryLogic extends BaseLogic
185 } 188 }
186 189
187 /** 190 /**
  191 + * @remark :处理字符串
  192 + * @name :handleStr
  193 + * @author :lyh
  194 + * @method :post
  195 + * @time :2023/12/5 18:03
  196 + */
  197 + public function handleStr($str){
  198 + return ',' . $str . ',';
  199 + }
  200 +
  201 + /**
188 * @remark :删除数据 202 * @remark :删除数据
189 * @name :ModuleDel 203 * @name :ModuleDel
190 * @author :lyh 204 * @author :lyh
@@ -62,6 +62,7 @@ class CustomModuleLogic extends BaseLogic @@ -62,6 +62,7 @@ class CustomModuleLogic extends BaseLogic
62 * @time :2023/12/5 9:39 62 * @time :2023/12/5 9:39
63 */ 63 */
64 public function moduleAdd(){ 64 public function moduleAdd(){
  65 + $this->param['project_id'] = $this->user['project_id'];
65 $rs = $this->model->add($this->param); 66 $rs = $this->model->add($this->param);
66 if($rs === false){ 67 if($rs === false){
67 $this->fail('系统错误,请联系管理员'); 68 $this->fail('系统错误,请联系管理员');
@@ -38,21 +38,12 @@ class ProductLogic extends BaseLogic @@ -38,21 +38,12 @@ class ProductLogic extends BaseLogic
38 * @time :2023/8/21 18:35 38 * @time :2023/8/21 18:35
39 */ 39 */
40 public function productSave(){ 40 public function productSave(){
41 - //扩展字段  
42 - $extend = [];  
43 - if(!empty($this->param['extend'])){  
44 - $extend = $this->param['extend'];  
45 - unset($this->param['extend']);  
46 - }  
47 - $this->param = $this->handleSaveParam($this->param); 41 + //处理扩展字段
  42 + $extend = $this->handleExtent();
48 //单独处理分类 43 //单独处理分类
49 - $category_ids = [];  
50 - if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {  
51 - $category_ids = $this->getLastCategoryArr($this->param['category_id']);  
52 - $this->param['category_id'] = ','.implode(',',$category_ids).',';  
53 - }else{  
54 - $this->param['category_id'] = '';  
55 - } 44 + $category_ids = $this->handleCategory();
  45 + //处理其他字段
  46 + $this->param = $this->handleSaveParam($this->param);
56 DB::connection('custom_mysql')->beginTransaction(); 47 DB::connection('custom_mysql')->beginTransaction();
57 try { 48 try {
58 if(isset($this->param['id']) && !empty($this->param['id'])){ 49 if(isset($this->param['id']) && !empty($this->param['id'])){
@@ -81,6 +72,40 @@ class ProductLogic extends BaseLogic @@ -81,6 +72,40 @@ class ProductLogic extends BaseLogic
81 } 72 }
82 73
83 /** 74 /**
  75 + * @remark :处理扩展字段
  76 + * @name :handleExtent
  77 + * @author :lyh
  78 + * @method :post
  79 + * @time :2023/12/6 15:06
  80 + */
  81 + public function handleExtent(){
  82 + //扩展字段
  83 + $extend = [];
  84 + if(!empty($this->param['extend'])){
  85 + $extend = $this->param['extend'];
  86 + unset($this->param['extend']);
  87 + }
  88 + return $extend;
  89 + }
  90 +
  91 + /**
  92 + * @remark :处理分类数据
  93 + * @name :handleCategory
  94 + * @author :lyh
  95 + * @method :post
  96 + * @time :2023/12/6 15:01
  97 + */
  98 + public function handleCategory(){
  99 + $category_ids = [];
  100 + if(isset($this->param['category_id']) && !empty($this->param['category_id'])) {
  101 + $category_ids = $this->getLastCategoryArr($this->param['category_id']);
  102 + $this->param['category_id'] = ','.implode(',',$category_ids).',';
  103 + }else{
  104 + $this->param['category_id'] = '';
  105 + }
  106 + return $category_ids;
  107 + }
  108 + /**
84 * @remark :新增时处理字段 109 * @remark :新增时处理字段
85 * @name :addHandleParam 110 * @name :addHandleParam
86 * @author :lyh 111 * @author :lyh
@@ -112,6 +137,20 @@ class ProductLogic extends BaseLogic @@ -112,6 +137,20 @@ class ProductLogic extends BaseLogic
112 if(empty($v['values'])){ 137 if(empty($v['values'])){
113 continue; 138 continue;
114 } 139 }
  140 + $v = $this->saveHandleExtend($v,$product_id);
  141 + $extendInfoModel->add($v);
  142 + }
  143 + return $this->success();
  144 + }
  145 +
  146 + /**
  147 + * @remark :保存扩展字段时处理数据
  148 + * @name :saveHandleExtend
  149 + * @author :lyh
  150 + * @method :post
  151 + * @time :2023/12/6 15:11
  152 + */
  153 + public function saveHandleExtend(&$v,$product_id){
115 unset($v['title']); 154 unset($v['title']);
116 if($v['type'] == 3){ 155 if($v['type'] == 3){
117 foreach ($v['values'] as $k1=>$v1){ 156 foreach ($v['values'] as $k1=>$v1){
@@ -128,11 +167,8 @@ class ProductLogic extends BaseLogic @@ -128,11 +167,8 @@ class ProductLogic extends BaseLogic
128 } 167 }
129 $v['project_id'] = $this->user['project_id']; 168 $v['project_id'] = $this->user['project_id'];
130 $v['product_id'] = $product_id; 169 $v['product_id'] = $product_id;
131 - $extendInfoModel->add($v); 170 + return $this->success($v);
132 } 171 }
133 - return $this->success();  
134 - }  
135 -  
136 172
137 /** 173 /**
138 * @remark :编辑列表数据 174 * @remark :编辑列表数据
@@ -38,7 +38,9 @@ class CategoryRelated extends Base @@ -38,7 +38,9 @@ class CategoryRelated extends Base
38 foreach ($cate_ids as $cate_id){ 38 foreach ($cate_ids as $cate_id){
39 $data[] = [ 39 $data[] = [
40 'product_id' => $product_id, 40 'product_id' => $product_id,
41 - 'cate_id' => $cate_id 41 + 'cate_id' => $cate_id,
  42 + 'created_at'=>date('Y-m-d H:i:s'),
  43 + 'updated_at'=>date('Y-m-d H:i:s')
42 ]; 44 ];
43 } 45 }
44 self::insert($data); 46 self::insert($data);