作者 赵彬吉

update

  1 +<?php
  2 +
  3 +
  4 +namespace App\Http\Controllers\Aside;
  5 +
  6 +
  7 +use App\Services\Facades\Upload;
  8 +use Illuminate\Http\Request;
  9 +use Illuminate\Support\Facades\Storage;
  10 +
  11 +class FileController extends BaseController
  12 +{
  13 + /**
  14 + * 上传
  15 + * @param Request $request
  16 + * @return \Illuminate\Http\JsonResponse
  17 + * @throws \Psr\Container\ContainerExceptionInterface
  18 + * @throws \Psr\Container\NotFoundExceptionInterface
  19 + * @author zbj
  20 + * @date 2023/4/20
  21 + */
  22 + public function upload(Request $request){
  23 + // 上传文件
  24 + $files = Upload::puts('files', $this->param['config'] ?? 'default');
  25 + foreach ($files as &$file){
  26 + $file = Upload::path2url($file);
  27 + }
  28 + return $this->success($files);
  29 + }
  30 +
  31 + /**
  32 + * 下载
  33 + * @param Request $request
  34 + * @return \Symfony\Component\HttpFoundation\StreamedResponse
  35 + * @author zbj
  36 + * @date 2023/4/20
  37 + */
  38 + public function download(Request $request){
  39 + $path = Upload::url2path($this->param['url'] ?? '');
  40 + return Storage::disk('upload')->download($path);
  41 + }
  42 +
  43 +
  44 + /**
  45 + * 文件列表
  46 + * @author:dc
  47 + * @time 2023/5/29 11:42
  48 + */
  49 + public function lists(){
  50 + $type = \request()->get('type');
  51 +
  52 + switch ($type){
  53 + case 'video':{
  54 + $ext = ['mp4','avi'];
  55 + break;
  56 + }
  57 + default:{
  58 + $ext = ['png','jpg','jpeg','gif'];
  59 + break;
  60 + }
  61 + }
  62 +
  63 + $files = Upload::lists($this->param['config'] ?? 'default',$ext);
  64 + return $this->success($files);
  65 + }
  66 +
  67 +
  68 +
  69 +}
@@ -24,8 +24,11 @@ class ProjectController extends BaseController @@ -24,8 +24,11 @@ class ProjectController extends BaseController
24 public function list(ProjectLogic $logic) 24 public function list(ProjectLogic $logic)
25 { 25 {
26 $map = []; 26 $map = [];
  27 + if(!empty($this->param['type'])){
  28 + $map[] = ['type', $this->param['type']];
  29 + }
27 if(!empty($this->param['search'])){ 30 if(!empty($this->param['search'])){
28 - $map[] = ['title', 'like', "%{$this->param['search']}%"]; 31 + $map[] = ['title|company', $this->param['search']];
29 } 32 }
30 $sort = ['id' => 'desc']; 33 $sort = ['id' => 'desc'];
31 $data = $logic->getList($map, $sort); 34 $data = $logic->getList($map, $sort);
@@ -78,4 +81,19 @@ class ProjectController extends BaseController @@ -78,4 +81,19 @@ class ProjectController extends BaseController
78 $data = $logic->saveInquirySet($this->param); 81 $data = $logic->saveInquirySet($this->param);
79 return $this->success($data); 82 return $this->success($data);
80 } 83 }
  84 +
  85 +
  86 + /**
  87 + * 数据源
  88 + * @param ProjectLogic $logic
  89 + * @return \Illuminate\Http\JsonResponse
  90 + * @throws \Psr\Container\ContainerExceptionInterface
  91 + * @throws \Psr\Container\NotFoundExceptionInterface
  92 + * @author zbj
  93 + * @date 2023/6/20
  94 + */
  95 + public function data_source(ProjectLogic $logic){
  96 + $data = $logic->dataSource();
  97 + return $this->success($data);
  98 + }
81 } 99 }
@@ -28,4 +28,10 @@ class ManageLogic extends BaseLogic @@ -28,4 +28,10 @@ class ManageLogic extends BaseLogic
28 } 28 }
29 return parent::save($param); 29 return parent::save($param);
30 } 30 }
  31 +
  32 +
  33 + public static function getCacheName($id){
  34 + $info = (new self())->getCacheInfo($id);
  35 + return $info['name'] ?? '';
  36 + }
31 } 37 }
@@ -6,12 +6,16 @@ namespace App\Http\Logic\Aside\Project; @@ -6,12 +6,16 @@ namespace App\Http\Logic\Aside\Project;
6 use App\Helper\Arr; 6 use App\Helper\Arr;
7 use App\Helper\FormGlobalsoApi; 7 use App\Helper\FormGlobalsoApi;
8 use App\Http\Logic\Aside\BaseLogic; 8 use App\Http\Logic\Aside\BaseLogic;
  9 +use App\Http\Logic\Aside\Manage\ManageLogic;
  10 +use App\Models\City;
9 use App\Models\InquirySet; 11 use App\Models\InquirySet;
  12 +use App\Models\Manage\Manage;
10 use App\Models\Project\DeployBuild; 13 use App\Models\Project\DeployBuild;
11 use App\Models\Project\DeployOptimize; 14 use App\Models\Project\DeployOptimize;
12 use App\Models\Project\Payment; 15 use App\Models\Project\Payment;
13 use App\Models\Project\Project; 16 use App\Models\Project\Project;
14 use Illuminate\Database\Eloquent\Model; 17 use Illuminate\Database\Eloquent\Model;
  18 +use Illuminate\Support\Facades\Cache;
15 use Illuminate\Support\Facades\DB; 19 use Illuminate\Support\Facades\DB;
16 20
17 /** 21 /**
@@ -32,7 +36,30 @@ class ProjectLogic extends BaseLogic @@ -32,7 +36,30 @@ class ProjectLogic extends BaseLogic
32 public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20) 36 public function getList(array $map = [], array $sort = ['id' => 'desc'], array $columns = ['*'], int $limit = 20)
33 { 37 {
34 parent::setWith(['payment', 'deploy_build', 'deploy_optimize']); 38 parent::setWith(['payment', 'deploy_build', 'deploy_optimize']);
35 - return parent::getList($map, $sort, $columns, $limit); 39 + $list = parent::getList($map, $sort, ['id', 'title', 'channel', 'type', 'created_at'], $limit);
  40 + foreach ($list['list'] as &$item){
  41 + $item = [
  42 + 'id' => $item['id'],
  43 + 'title' => $item['title'],
  44 + 'channel' => $item['channel']['channel'] . ' - ' . $item['channel']['saler'],
  45 + 'key' => $item['deploy_build']['keyword_num'],
  46 + 'day' => $item['deploy_build']['service_duration'],
  47 + 'amount' => $item['payment']['amount'],
  48 + 'build_leader' => ManageLogic::getCacheName($item['deploy_build']['leader_mid']), //组长
  49 + 'build_manager' => ManageLogic::getCacheName($item['deploy_build']['manager_mid']), //项目经理
  50 + 'build_designer' => ManageLogic::getCacheName($item['deploy_build']['designer_mid']), //设计师
  51 + 'build_tech' => ManageLogic::getCacheName($item['deploy_build']['tech_mid']), //技术助理
  52 + 'optimize_manager' => ManageLogic::getCacheName($item['deploy_optimize']['manager_mid']), //优化服务经理
  53 + 'optimize_optimist' => ManageLogic::getCacheName($item['deploy_optimize']['optimist_mid']), //优化师
  54 + 'optimize_assist' => ManageLogic::getCacheName($item['deploy_optimize']['assist_mid']), //优化助理
  55 + 'optimize_tech' => ManageLogic::getCacheName($item['deploy_optimize']['tech_mid']), //售后技术
  56 + 'type' => $this->model::typeMap()[$item['type']] ?: '',
  57 + 'test_domain' => $item['deploy_build']['test_domain'],
  58 + 'domain' => $item['deploy_optimize']['domain'],
  59 + 'crated_at' => date('Y年m月d日', strtotime($item['created_at'])),
  60 + ];
  61 + }
  62 + return $list;
36 } 63 }
37 64
38 public function getInfo($id) 65 public function getInfo($id)
@@ -159,4 +186,15 @@ class ProjectLogic extends BaseLogic @@ -159,4 +186,15 @@ class ProjectLogic extends BaseLogic
159 $set->save(); 186 $set->save();
160 return $this->success(); 187 return $this->success();
161 } 188 }
  189 +
  190 + public function dataSource(){
  191 + $data = [];
  192 + $data['level'] = $this->model::levelMap();
  193 + $data['type'] = $this->model::typeMap();
  194 + $data['special'] = $this->model::specialMap();
  195 + $data['city'] = City::getTreeList();
  196 + return $data;
  197 + }
  198 +
  199 +
162 } 200 }
  1 +<?php
  2 +
  3 +namespace App\Models;
  4 +
  5 +
  6 +use App\Helper\Arr;
  7 +use Illuminate\Database\Eloquent\Model;
  8 +use Illuminate\Support\Facades\Cache;
  9 +
  10 +/**
  11 + * Class City
  12 + * @package App\Models
  13 + * @author zbj
  14 + * @date 2023/6/20
  15 + */
  16 +class City extends Model
  17 +{
  18 + //设置关联表名
  19 + protected $table = 'gl_system_city';
  20 +
  21 + public static function getTreeList(){
  22 + $cache_key = 'city_select_tree';
  23 + $data = Cache::get($cache_key);
  24 + if(!$data){
  25 + $list = self::select(['city_id', 'parent_id', 'name'])->whereIn('level', [0,1])->get()->toArray();
  26 + $data = Arr::listToTree($list, 'city_id', 'parent_id');
  27 + Cache::put($cache_key, $data, 24 * 3600);
  28 + }
  29 + return $data;
  30 + }
  31 +}
@@ -5,6 +5,7 @@ namespace App\Models\Project; @@ -5,6 +5,7 @@ namespace App\Models\Project;
5 use App\Helper\Arr; 5 use App\Helper\Arr;
6 use App\Models\Base; 6 use App\Models\Base;
7 use App\Models\Devops\ServerConfig; 7 use App\Models\Devops\ServerConfig;
  8 +use App\Services\Facades\Upload;
8 use Illuminate\Support\Facades\Cache; 9 use Illuminate\Support\Facades\Cache;
9 10
10 class Project extends Base 11 class Project extends Base
@@ -50,26 +51,39 @@ class Project extends Base @@ -50,26 +51,39 @@ class Project extends Base
50 ]; 51 ];
51 } 52 }
52 53
53 - public static function planMap(){ 54 + public static function planMap()
  55 + {
54 return [ 56 return [
55 - '营销大师-体验版',  
56 - '营销大师-标准版',  
57 - '营销大师-商务版',  
58 - '营销大师-旗舰版',  
59 - '数据大师-体验版',  
60 - '数据大师-智能版',  
61 - '数据大师-智慧版',  
62 - 'PLUS-尊享版',  
63 - 'PLUS-尊贵版',  
64 - 'PLUS-至尊版',  
65 - '防疫物质推广方案',  
66 - '疫情期间免费版',  
67 - '建站大师定制优化方案',  
68 - '星链网站(1年版)',  
69 - '星链网站(2年版)', 57 + 1 => '营销大师-体验版',
  58 + 2 => '营销大师-标准版',
  59 + 3 => '营销大师-商务版',
  60 + 4 => '营销大师-旗舰版',
  61 + 5 => '数据大师-体验版',
  62 + 6 => '数据大师-智能版',
  63 + 7 => '数据大师-智慧版',
  64 + 8 => 'PLUS-尊享版',
  65 + 9 => 'PLUS-尊贵版',
  66 + 10 => 'PLUS-至尊版',
  67 + 11 => '防疫物质推广方案',
  68 + 12 => '疫情期间免费版',
  69 + 13 => '建站大师定制优化方案',
  70 + 14 => '星链网站(1年版)',
  71 + 15 => '星链网站(2年版)',
70 ]; 72 ];
71 } 73 }
72 74
  75 + public static function specialMap()
  76 + {
  77 + return [
  78 + 1 => '自建站项目',
  79 + 2 => '重点跟进',
  80 + 3 => '推广案例',
  81 + 4 => '全球搜案例',
  82 + 5 => '设计师案例',
  83 + ];
  84 + }
  85 +
  86 +
73 /** 87 /**
74 * 项目部署服务器信息 88 * 项目部署服务器信息
75 * @return \Illuminate\Database\Eloquent\Relations\HasOne 89 * @return \Illuminate\Database\Eloquent\Relations\HasOne
@@ -141,28 +155,58 @@ class Project extends Base @@ -141,28 +155,58 @@ class Project extends Base
141 return self::hasOne(DeployOptimize::class, 'project_id', 'id'); 155 return self::hasOne(DeployOptimize::class, 'project_id', 'id');
142 } 156 }
143 157
144 - public function setLevelAttribute($value){ 158 + public function setLevelAttribute($value)
  159 + {
145 $this->attributes['level'] = Arr::arrToSet($value); 160 $this->attributes['level'] = Arr::arrToSet($value);
146 } 161 }
147 162
148 - public function getLevelAttribute($value){ 163 + public function getLevelAttribute($value)
  164 + {
149 return Arr::setToArr($value); 165 return Arr::setToArr($value);
150 } 166 }
151 167
152 - public function setChannelAttribute($value){ 168 + public function setChannelAttribute($value)
  169 + {
153 $this->attributes['channel'] = Arr::a2s($value); 170 $this->attributes['channel'] = Arr::a2s($value);
154 } 171 }
155 172
156 - public function getChannelAttribute($value){ 173 + public function getChannelAttribute($value)
  174 + {
157 return Arr::s2a($value); 175 return Arr::s2a($value);
158 } 176 }
159 177
160 - public function setNoticeAttribute($value){  
161 - $this->attributes['notice'] = Arr::a2s($value); 178 + public function setNoticeFileAttribute($value)
  179 + {
  180 + foreach ($value as &$v) {
  181 + $v = Upload::url2path($v);
  182 + }
  183 + $this->attributes['notice_file'] = Arr::a2s($value);
162 } 184 }
163 185
164 - public function getNoticeAttribute($value){  
165 - return Arr::s2a($value); 186 + public function getNoticeFileAttribute($value)
  187 + {
  188 + $value = Arr::s2a($value);
  189 + foreach ($value as &$v) {
  190 + $v = Upload::path2url($v);
  191 + }
  192 + return $value;
  193 + }
  194 +
  195 + public function setConfirmFileAttribute($value)
  196 + {
  197 + foreach ($value as &$v) {
  198 + $v = Upload::url2path($v);
  199 + }
  200 + $this->attributes['confirm_file'] = Arr::a2s($value);
  201 + }
  202 +
  203 + public function getConfirmFileAttribute($value)
  204 + {
  205 + $value = Arr::s2a($value);
  206 + foreach ($value as &$v) {
  207 + $v = Upload::path2url($v);
  208 + }
  209 + return $value;
166 } 210 }
167 211
168 /** 212 /**
@@ -170,21 +214,22 @@ class Project extends Base @@ -170,21 +214,22 @@ class Project extends Base
170 * @author zbj 214 * @author zbj
171 * @date 2023/5/5 215 * @date 2023/5/5
172 */ 216 */
173 - public static function getProjectByDomain($domain){  
174 - $cache_key = 'project_'.$domain; 217 + public static function getProjectByDomain($domain)
  218 + {
  219 + $cache_key = 'project_' . $domain;
175 $data = Cache::get($cache_key); 220 $data = Cache::get($cache_key);
176 - if(!$data){ 221 + if (!$data) {
177 //是否测试域名 222 //是否测试域名
178 $project_id = DeployBuild::where('test_domain', $domain)->value('project_id'); 223 $project_id = DeployBuild::where('test_domain', $domain)->value('project_id');
179 //是否正式域名 224 //是否正式域名
180 - if(!$project_id){ 225 + if (!$project_id) {
181 $project_id = DeployOptimize::where('domain', $domain)->value('project_id'); 226 $project_id = DeployOptimize::where('domain', $domain)->value('project_id');
182 } 227 }
183 - if(!$project_id){ 228 + if (!$project_id) {
184 return []; 229 return [];
185 } 230 }
186 $data = self::find($project_id); 231 $data = self::find($project_id);
187 - if($data){ 232 + if ($data) {
188 Cache::put($cache_key, $data); 233 Cache::put($cache_key, $data);
189 } 234 }
190 } 235 }
@@ -42,4 +42,11 @@ return [ @@ -42,4 +42,11 @@ return [
42 ], 42 ],
43 'path' => '/news' 43 'path' => '/news'
44 ], 44 ],
  45 + //项目相关
  46 + 'project' =>[
  47 + 'size' => [
  48 + 'max' => 1024*1024*1024, // 2M
  49 + ],
  50 + 'path' => '/project'
  51 + ],
45 ]; 52 ];
@@ -101,6 +101,7 @@ Route::middleware(['aloginauth'])->group(function () { @@ -101,6 +101,7 @@ Route::middleware(['aloginauth'])->group(function () {
101 Route::get('/info', [Aside\Project\ProjectController::class, 'info'])->name('admin.project_info'); 101 Route::get('/info', [Aside\Project\ProjectController::class, 'info'])->name('admin.project_info');
102 Route::post('/save', [Aside\Project\ProjectController::class, 'save'])->name('admin.project_save'); 102 Route::post('/save', [Aside\Project\ProjectController::class, 'save'])->name('admin.project_save');
103 Route::any('/inquiry_set', [Aside\Project\ProjectController::class, 'inquiry_set'])->name('admin.project_inquiry_set'); 103 Route::any('/inquiry_set', [Aside\Project\ProjectController::class, 'inquiry_set'])->name('admin.project_inquiry_set');
  104 + Route::any('/data_source', [Aside\Project\ProjectController::class, 'data_source'])->name('admin.project_data_source');
104 }); 105 });
105 106
106 //工单管理 107 //工单管理