作者 lyh

gx

@@ -55,77 +55,6 @@ class TaskController extends BaseController @@ -55,77 +55,6 @@ class TaskController extends BaseController
55 } 55 }
56 56
57 /** 57 /**
58 - * @remark :获取任务列表  
59 - * @name :getTaskList  
60 - * @author :lyh  
61 - * @method :post  
62 - * @time :2023/8/23 15:44  
63 - */  
64 - public function getTaskList(&$task,$ids){  
65 - $lists = $task->list(['id'=>['in',$ids]]);  
66 - foreach ($lists as $k => $v){  
67 - $v = $this->getFileUrl($v);  
68 - $lists[$k] = $v;  
69 - }  
70 - return $lists;  
71 - }  
72 -  
73 - /**  
74 - * @remark :处理文件  
75 - * @name :getFileUrl  
76 - * @author :lyh  
77 - * @method :post  
78 - * @time :2023/8/23 16:15  
79 - */  
80 - public function getFileUrl(&$v){  
81 - $fileModel = new File();  
82 - $file_info = $fileModel->read(['hash'=>$v['attachment']]);  
83 - if($file_info !== false){  
84 - $v['attachment_name'] = basename($file_info['path']);  
85 - if($file_info['is_cos'] == 1){  
86 - $cos = config('filesystems.disks.cos');  
87 - $cosCdn = $cos['cdn'];  
88 - $v['attachment'] = $cosCdn.$file_info['path'];  
89 - }else{  
90 - $v['attachment'] = url('a/download_files?hash='.$v['attachment']);  
91 - }  
92 - }  
93 - return $v;  
94 - }  
95 -  
96 - public function items(Request $request, TaskLogic $logic)  
97 - {  
98 - $request->validate([  
99 - 'own_manage_id'=>'required'  
100 - ],[  
101 - 'own_manage_id.required' => '所属人ID不能为空'  
102 - ]);  
103 - $map[] = ['id', 'in', TaskOwner::where('manage_id', $this->param['own_manage_id'])->pluck('id')->toArray()];  
104 - if(!empty($this->param['search']) && !empty($this->param['search_type'])){  
105 - if($this->param['search_type'] == 'project'){  
106 - $map[] = ['project_id', 'in', Project::where('title', 'like', "%{$this->param['search']}%")->pluck('id')->toarray()];  
107 - }else{  
108 - $map[] = [$this->param['search_type'], 'like', "%{$this->param['search']}%"];  
109 - }  
110 - }  
111 - if(!empty($this->param['dep_id'])){  
112 - $manage_ids = Manage::where('dept_id', $this->param['dep_id'])->pluck('id')->toArray();  
113 - $map[] = ['id', 'in', TaskOwner::whereIn('manage_id',$manage_ids)->pluck('task_id')->toArray()];  
114 - }  
115 - if(!empty($this->param['manage_id']) && !empty($this->param['type'])){  
116 - if($this->param['type'] == 1){  
117 - $map[] = ['created_manage_id', $this->param['manage_id']];  
118 - }else{  
119 - $map[] = ['id', 'in', TaskOwner::where('manage_id', $this->param['manage_id'])->pluck('task_id')->toArray()];  
120 - }  
121 - }  
122 - $sort = ['id' => 'desc'];  
123 - $data = $logic->getList($map, $sort, ['id', 'project_id', 'workload', 'priority', 'content', 'attachment', 'status', 'end_at', 'created_manage_id']);  
124 -  
125 - return $this->success($data);  
126 - }  
127 -  
128 - /**  
129 * @remark :获取详情 58 * @remark :获取详情
130 * @name :info 59 * @name :info
131 * @author :lyh 60 * @author :lyh
@@ -138,7 +67,7 @@ class TaskController extends BaseController @@ -138,7 +67,7 @@ class TaskController extends BaseController
138 ],[ 67 ],[
139 'id.required' => 'ID不能为空' 68 'id.required' => 'ID不能为空'
140 ]); 69 ]);
141 - $data = $logic->getTaskInfo($this->param['id']); 70 + $data = $logic->getTaskInfo();
142 return $this->response('success',Code::SUCCESS,$data); 71 return $this->response('success',Code::SUCCESS,$data);
143 } 72 }
144 73
@@ -157,7 +86,7 @@ class TaskController extends BaseController @@ -157,7 +86,7 @@ class TaskController extends BaseController
157 * @date 2023/4/27 86 * @date 2023/4/27
158 */ 87 */
159 public function status(Request $request, TaskLogic $logic){ 88 public function status(Request $request, TaskLogic $logic){
160 - $request->validate([ 89 + $this->request->validate([
161 'id'=>'required', 90 'id'=>'required',
162 'status' => ['required', Rule::in(array_keys(Task::statusMap()))] 91 'status' => ['required', Rule::in(array_keys(Task::statusMap()))]
163 ],[ 92 ],[
@@ -181,4 +110,43 @@ class TaskController extends BaseController @@ -181,4 +110,43 @@ class TaskController extends BaseController
181 $data = $logic->save($this->param); 110 $data = $logic->save($this->param);
182 return $this->success($data); 111 return $this->success($data);
183 } 112 }
  113 +
  114 + /**
  115 + * @remark :获取任务列表
  116 + * @name :getTaskList
  117 + * @author :lyh
  118 + * @method :post
  119 + * @time :2023/8/23 15:44
  120 + */
  121 + public function getTaskList(&$task,$ids){
  122 + $lists = $task->list(['id'=>['in',$ids]]);
  123 + foreach ($lists as $k => $v){
  124 + $v = $this->getFileUrl($v);
  125 + $lists[$k] = $v;
  126 + }
  127 + return $lists;
  128 + }
  129 +
  130 + /**
  131 + * @remark :处理文件
  132 + * @name :getFileUrl
  133 + * @author :lyh
  134 + * @method :post
  135 + * @time :2023/8/23 16:15
  136 + */
  137 + public function getFileUrl(&$v){
  138 + $fileModel = new File();
  139 + $file_info = $fileModel->read(['hash'=>$v['attachment']]);
  140 + if($file_info !== false){
  141 + $v['attachment_name'] = basename($file_info['path']);
  142 + if($file_info['is_cos'] == 1){
  143 + $cos = config('filesystems.disks.cos');
  144 + $cosCdn = $cos['cdn'];
  145 + $v['attachment'] = $cosCdn.$file_info['path'];
  146 + }else{
  147 + $v['attachment'] = url('a/download_files?hash='.$v['attachment']);
  148 + }
  149 + }
  150 + return $v;
  151 + }
184 } 152 }
@@ -7,6 +7,7 @@ use App\Helper\Arr; @@ -7,6 +7,7 @@ use App\Helper\Arr;
7 use App\Http\Logic\Aside\BaseLogic; 7 use App\Http\Logic\Aside\BaseLogic;
8 use App\Http\Logic\Aside\LoginLogic; 8 use App\Http\Logic\Aside\LoginLogic;
9 use App\Http\Logic\Aside\Manage\ManageLogic; 9 use App\Http\Logic\Aside\Manage\ManageLogic;
  10 +use App\Models\File\File;
10 use App\Models\Task\Task; 11 use App\Models\Task\Task;
11 use App\Models\Task\TaskOwner; 12 use App\Models\Task\TaskOwner;
12 use Illuminate\Support\Facades\DB; 13 use Illuminate\Support\Facades\DB;
@@ -23,49 +24,45 @@ class TaskLogic extends BaseLogic @@ -23,49 +24,45 @@ class TaskLogic extends BaseLogic
23 public function __construct() 24 public function __construct()
24 { 25 {
25 parent::__construct(); 26 parent::__construct();
26 - 27 + $this->param = $this->requestAll;
27 $this->model = new Task(); 28 $this->model = new Task();
28 } 29 }
29 30
30 -  
31 - public function getUserlist(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20){  
32 - $where = array_map(function ($v) {  
33 - if(!Str::startsWith($v[0], 'gto.')) {  
34 - $v[0] = 'gl_task.' . $v[0];  
35 - }  
36 - return $v;  
37 - }, $map);  
38 - $data = $this->formatQuery($where)->leftJoin('gl_task_owner as gto', 'gl_task.id', '=', 'gto.task_id')  
39 - ->select('gto.manage_id', DB::raw('COUNT(*) as count'))  
40 - ->groupBy('gto.manage_id')  
41 - ->paginate($limit)->toArray();  
42 - $list = [];  
43 - $map = array_map(function ($v) {  
44 - if(!Str::startsWith($v[0], 'gto.')) {  
45 - return $v;  
46 - }  
47 - return [];  
48 - }, $map);  
49 - $map = array_filter($map);  
50 - foreach ($data['list'] as $v){  
51 - $ids = TaskOwner::where('manage_id', $v['manage_id'])->pluck('task_id')->toArray();  
52 - $list[] = [  
53 - "manage_id" => $v['manage_id'],  
54 - "manage_id_text" => (new ManageLogic)->getCacheName($v['manage_id']),  
55 - "count" => $v['count'],  
56 - "task_list" => $this->model->list(['id'=>['in',$ids]]),  
57 - ];  
58 - }  
59 - return $this->success($list);  
60 - }  
61 -  
62 -  
63 - public function getTaskInfo($id) 31 + /**
  32 + * @remark :获取数据详情
  33 + * @name :getTaskInfo
  34 + * @author :lyh
  35 + * @method :post
  36 + * @time :2023/8/23 16:42
  37 + */
  38 + public function getTaskInfo()
64 { 39 {
65 - $info = $this->model->where(['id'=>$id])->with('owner')->with('follow')->first(); 40 + $info = $this->model->where(['id'=>$this->param['id']])->with('owner')->with('follow')->first();
66 return $this->success($info); 41 return $this->success($info);
67 } 42 }
68 43
  44 + /**
  45 + * @remark :处理文件
  46 + * @name :getFileUrl
  47 + * @author :lyh
  48 + * @method :post
  49 + * @time :2023/8/23 16:15
  50 + */
  51 + public function getFileUrl(&$v){
  52 + $fileModel = new File();
  53 + $file_info = $fileModel->read(['hash'=>$v['attachment']]);
  54 + if($file_info !== false){
  55 + $v['attachment_name'] = basename($file_info['path']);
  56 + if($file_info['is_cos'] == 1){
  57 + $cos = config('filesystems.disks.cos');
  58 + $cosCdn = $cos['cdn'];
  59 + $v['attachment'] = $cosCdn.$file_info['path'];
  60 + }else{
  61 + $v['attachment'] = url('a/download_files?hash='.$v['attachment']);
  62 + }
  63 + }
  64 + return $v;
  65 + }
69 public function save($param){ 66 public function save($param){
70 67
71 DB::beginTransaction(); 68 DB::beginTransaction();
@@ -31,7 +31,7 @@ class CategoryLogic extends BaseLogic @@ -31,7 +31,7 @@ class CategoryLogic extends BaseLogic
31 $data = parent::getList($map, $sort, $columns, $limit); 31 $data = parent::getList($map, $sort, $columns, $limit);
32 foreach ($data as &$v){ 32 foreach ($data as &$v){
33 $v['url'] = $this->user['domain'] . $v['route'] ; 33 $v['url'] = $this->user['domain'] . $v['route'] ;
34 - $v['product_num'] = $this->getProductNum($v['id']); 34 + $v['product_num'] = Product::where('category_id','like' ,'%,'.$v['category_id'].',%')->count();;
35 $v['image_link'] = getImageUrl($v['image']); 35 $v['image_link'] = getImageUrl($v['image']);
36 } 36 }
37 if(!$map){ 37 if(!$map){
@@ -129,14 +129,6 @@ class CategoryLogic extends BaseLogic @@ -129,14 +129,6 @@ class CategoryLogic extends BaseLogic
129 if(!$info){ 129 if(!$info){
130 continue; 130 continue;
131 } 131 }
132 - //是否有子分类  
133 - if(Category::where('project_id', $this->user['project_id'])->where('pid', $id)->count()){  
134 - $this->fail("分类{$info['title']}存在子分类,不能删除");  
135 - }  
136 - //是否有对应商品  
137 - if(CategoryRelated::where('cate_id', $id)->count()){  
138 - $this->fail("分类{$info['title']}存在产品,不能删除");  
139 - }  
140 //删除路由映射 132 //删除路由映射
141 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']); 133 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_CATE, $id, $this->user['project_id']);
142 } 134 }
@@ -153,15 +145,4 @@ class CategoryLogic extends BaseLogic @@ -153,15 +145,4 @@ class CategoryLogic extends BaseLogic
153 return $this->success(); 145 return $this->success();
154 } 146 }
155 147
156 - /**  
157 - * 关联产品数量  
158 - * @param $cate_id  
159 - * @return mixed  
160 - * @author zbj  
161 - * @date 2023/4/28  
162 - */  
163 - public function getProductNum($cate_id){  
164 - $cate_ids = $this->model->getChildIdsArr($cate_id);  
165 - return CategoryRelated::whereIn('cate_id', $cate_ids)->distinct()->count('product_id');  
166 - }  
167 } 148 }
@@ -7,6 +7,7 @@ use App\Helper\Arr; @@ -7,6 +7,7 @@ use App\Helper\Arr;
7 use App\Http\Logic\Bside\BaseLogic; 7 use App\Http\Logic\Bside\BaseLogic;
8 use App\Models\Product\Keyword; 8 use App\Models\Product\Keyword;
9 use App\Models\Product\KeywordRelated; 9 use App\Models\Product\KeywordRelated;
  10 +use App\Models\Product\Product;
10 use App\Models\RouteMap\RouteMap; 11 use App\Models\RouteMap\RouteMap;
11 use Illuminate\Support\Facades\DB; 12 use Illuminate\Support\Facades\DB;
12 13
@@ -29,13 +30,20 @@ class KeywordLogic extends BaseLogic @@ -29,13 +30,20 @@ class KeywordLogic extends BaseLogic
29 { 30 {
30 $data = parent::getList($map, $sort, $columns, $limit); 31 $data = parent::getList($map, $sort, $columns, $limit);
31 foreach ($data['list'] as &$v){ 32 foreach ($data['list'] as &$v){
32 - $v['product_num'] = $this->getProductNum($v['id']); 33 + $v['product_num'] = Product::where('keyword_id','like' ,'%,'.$v['keyword_id'].',%')->count();
33 $v['tdk'] = boolval($v['seo_title']) * boolval($v['seo_keywords']) * boolval($v['seo_description']); 34 $v['tdk'] = boolval($v['seo_title']) * boolval($v['seo_keywords']) * boolval($v['seo_description']);
34 $v['url'] = $this->user['domain'] . $v['route']; 35 $v['url'] = $this->user['domain'] . $v['route'];
35 } 36 }
36 return $this->success($data); 37 return $this->success($data);
37 } 38 }
38 39
  40 + /**
  41 + * @remark :获取数据详情
  42 + * @name :getInfo
  43 + * @author :lyh
  44 + * @method :post
  45 + * @time :2023/8/23 16:50
  46 + */
39 public function getInfo($id) 47 public function getInfo($id)
40 { 48 {
41 $info = parent::getInfo($id); 49 $info = parent::getInfo($id);
@@ -43,6 +51,13 @@ class KeywordLogic extends BaseLogic @@ -43,6 +51,13 @@ class KeywordLogic extends BaseLogic
43 return $this->success($info); 51 return $this->success($info);
44 } 52 }
45 53
  54 + /**
  55 + * @remark :保存
  56 + * @name :keywordSave
  57 + * @author :lyh
  58 + * @method :post
  59 + * @time :2023/8/23 16:50
  60 + */
46 public function keywordSave(){ 61 public function keywordSave(){
47 DB::beginTransaction(); 62 DB::beginTransaction();
48 try { 63 try {
@@ -77,17 +92,10 @@ class KeywordLogic extends BaseLogic @@ -77,17 +92,10 @@ class KeywordLogic extends BaseLogic
77 if(!$info){ 92 if(!$info){
78 continue; 93 continue;
79 } 94 }
80 -  
81 - //是否有对应商品  
82 - if(KeywordRelated::where('keyword_id', $id)->count()){  
83 - $this->fail("关键词{$info['title']}存在产品,不能删除");  
84 - }  
85 -  
86 //删除路由映射 95 //删除路由映射
87 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); 96 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']);
88 } 97 }
89 parent::delete($ids); 98 parent::delete($ids);
90 -  
91 DB::commit(); 99 DB::commit();
92 } catch (BsideGlobalException $e){ 100 } catch (BsideGlobalException $e){
93 DB::rollBack(); 101 DB::rollBack();
@@ -96,11 +104,7 @@ class KeywordLogic extends BaseLogic @@ -96,11 +104,7 @@ class KeywordLogic extends BaseLogic
96 DB::rollBack(); 104 DB::rollBack();
97 $this->fail('删除失败'); 105 $this->fail('删除失败');
98 } 106 }
99 -  
100 return $this->success(); 107 return $this->success();
101 } 108 }
102 109
103 - public function getProductNum($keyword_id){  
104 - return KeywordRelated::where('keyword_id', $keyword_id)->distinct()->count('product_id');  
105 - }  
106 } 110 }
@@ -293,12 +293,6 @@ class ProductLogic extends BaseLogic @@ -293,12 +293,6 @@ class ProductLogic extends BaseLogic
293 'status'=>$this->param['status'] 293 'status'=>$this->param['status']
294 ]; 294 ];
295 $this->model->edit($param,['id'=>['in',$this->param['id']]]); 295 $this->model->edit($param,['id'=>['in',$this->param['id']]]);
296 - //新增关联分类  
297 - foreach ($this->param['id'] as $v1){  
298 - foreach ($this->param['category_id'] as $v2){  
299 - CategoryRelated::saveRelated($v1,$v2);  
300 - }  
301 - }  
302 DB::commit(); 296 DB::commit();
303 //对应添加关联表 297 //对应添加关联表
304 }catch (\Exception $e){ 298 }catch (\Exception $e){
@@ -21,41 +21,4 @@ class Category extends Base @@ -21,41 +21,4 @@ class Category extends Base
21 21
22 const STATUS_ACTIVE = 1; 22 const STATUS_ACTIVE = 1;
23 23
24 - /**  
25 - * 子分类  
26 - * @var array  
27 - */  
28 - protected $child_ids_arr = [];  
29 -  
30 - /**  
31 - * 获取指定分类的所有子分类IDS(包括自己)  
32 - * @param $id  
33 - * @return array  
34 - * @author zbj  
35 - * @date 2023/4/28  
36 - */  
37 - public function getChildIdsArr($id)  
38 - {  
39 - $this->child_ids_arr = [$id];  
40 - return $this->getChildrenIdArr($id);  
41 - }  
42 -  
43 - /**  
44 - * 递归获取指定分类的所有子孙  
45 - * @param $id  
46 - * @return array  
47 - * @author zbj  
48 - * @date 2023/4/28  
49 - */  
50 - protected function getChildrenIdArr($id)  
51 - {  
52 - $list = parent::where("pid", $id)->pluck('pid', 'id');  
53 - if ($list) {  
54 - foreach ($list as $id => $pid) {  
55 - $this->child_ids_arr[] = $id;  
56 - $this->getChildrenIdArr($id);  
57 - }  
58 - }  
59 - return $this->child_ids_arr;  
60 - }  
61 } 24 }
@@ -168,7 +168,6 @@ Route::middleware(['aloginauth'])->group(function () { @@ -168,7 +168,6 @@ Route::middleware(['aloginauth'])->group(function () {
168 //工单管理 168 //工单管理
169 Route::prefix('task')->group(function () { 169 Route::prefix('task')->group(function () {
170 Route::get('/', [Aside\Task\TaskController::class, 'list'])->name('admin.task'); 170 Route::get('/', [Aside\Task\TaskController::class, 'list'])->name('admin.task');
171 - Route::get('/items', [Aside\Task\TaskController::class, 'items'])->name('admin.task_items');  
172 Route::get('/info', [Aside\Task\TaskController::class, 'info'])->name('admin.task_info'); 171 Route::get('/info', [Aside\Task\TaskController::class, 'info'])->name('admin.task_info');
173 Route::post('/save', [Aside\Task\TaskController::class, 'save'])->name('admin.task_save'); 172 Route::post('/save', [Aside\Task\TaskController::class, 'save'])->name('admin.task_save');
174 Route::post('/status', [Aside\Task\TaskController::class, 'status'])->name('admin.task_status'); 173 Route::post('/status', [Aside\Task\TaskController::class, 'status'])->name('admin.task_status');