Merge remote-tracking branch 'origin/master' into zhl
正在显示
23 个修改的文件
包含
345 行增加
和
177 行删除
| @@ -50,6 +50,18 @@ class ProjectImport extends Command | @@ -50,6 +50,18 @@ class ProjectImport extends Command | ||
| 50 | 50 | ||
| 51 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', import start' . PHP_EOL; | 51 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', import start' . PHP_EOL; |
| 52 | 52 | ||
| 53 | + $is_gbk = 0; | ||
| 54 | + $file_code_type = $this->get_code_type($task->file_url); | ||
| 55 | + if ($file_code_type === false) { | ||
| 56 | + echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', import fail, error: 文件编码格式错误' . PHP_EOL; | ||
| 57 | + $task->status = ImportTask::STATUS_COM;//导入完成 | ||
| 58 | + $task->save(); | ||
| 59 | + return true; | ||
| 60 | + } elseif ($file_code_type === 'GBK') { | ||
| 61 | + $is_gbk = 1; | ||
| 62 | + setlocale(LC_ALL, 'zh_CN'); | ||
| 63 | + } | ||
| 64 | + | ||
| 53 | //读取csv文件 | 65 | //读取csv文件 |
| 54 | $line_of_text = []; | 66 | $line_of_text = []; |
| 55 | try { | 67 | try { |
| @@ -76,19 +88,30 @@ class ProjectImport extends Command | @@ -76,19 +88,30 @@ class ProjectImport extends Command | ||
| 76 | if ($project) { | 88 | if ($project) { |
| 77 | foreach ($line_of_text as $k => $v) { | 89 | foreach ($line_of_text as $k => $v) { |
| 78 | if ($k > 0 && isset($v[0]) && $v[0]) { | 90 | if ($k > 0 && isset($v[0]) && $v[0]) { |
| 79 | - $total_count += 1; | ||
| 80 | - if ($task->type == ImportTask::TYPE_NEWS) { | ||
| 81 | - if ((new NewsLogic())->importNews($task->project_id, $task->user_id, $v)) { | ||
| 82 | - $success_count += 1; | ||
| 83 | - } | ||
| 84 | - } elseif ($task->type == ImportTask::TYPE_BLOG) { | ||
| 85 | - if ((new BlogLogic())->importBlog($task->project_id, $task->user_id, $v)) { | ||
| 86 | - $success_count += 1; | 91 | + |
| 92 | + if ($is_gbk) { | ||
| 93 | + foreach ($v as $kk => $vv) { | ||
| 94 | + $v[$kk] = mb_convert_encoding($vv, 'utf-8', 'gbk'); | ||
| 87 | } | 95 | } |
| 88 | - } else { | ||
| 89 | - if ((new ProductLogic())->importProduct($task->project_id, $task->user_id, $v)) { | ||
| 90 | - $success_count += 1; | 96 | + } |
| 97 | + | ||
| 98 | + $total_count += 1; | ||
| 99 | + try { | ||
| 100 | + if ($task->type == ImportTask::TYPE_NEWS) { | ||
| 101 | + if ((new NewsLogic())->importNews($task->project_id, $task->user_id, $v)) { | ||
| 102 | + $success_count += 1; | ||
| 103 | + } | ||
| 104 | + } elseif ($task->type == ImportTask::TYPE_BLOG) { | ||
| 105 | + if ((new BlogLogic())->importBlog($task->project_id, $task->user_id, $v)) { | ||
| 106 | + $success_count += 1; | ||
| 107 | + } | ||
| 108 | + } else { | ||
| 109 | + if ((new ProductLogic())->importProduct($task->project_id, $task->user_id, $v)) { | ||
| 110 | + $success_count += 1; | ||
| 111 | + } | ||
| 91 | } | 112 | } |
| 113 | + } catch (\Exception $e) { | ||
| 114 | + echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', title: ' . $v[0] . ', import fail, error: ' . $e->getMessage() . PHP_EOL; | ||
| 92 | } | 115 | } |
| 93 | } | 116 | } |
| 94 | } | 117 | } |
| @@ -99,11 +122,25 @@ class ProjectImport extends Command | @@ -99,11 +122,25 @@ class ProjectImport extends Command | ||
| 99 | 122 | ||
| 100 | $task->status = ImportTask::STATUS_COM;//导入完成 | 123 | $task->status = ImportTask::STATUS_COM;//导入完成 |
| 101 | $task->total_count = $total_count; | 124 | $task->total_count = $total_count; |
| 102 | - $task->success_count = $success_count; | 125 | + $task->success_count += $success_count; |
| 103 | $task->save(); | 126 | $task->save(); |
| 104 | 127 | ||
| 105 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', import end, total count: ' . $total_count . ', success count: ' . $success_count . PHP_EOL; | 128 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', import end, total count: ' . $total_count . ', success count: ' . $success_count . PHP_EOL; |
| 106 | 129 | ||
| 107 | sleep(2); | 130 | sleep(2); |
| 108 | } | 131 | } |
| 132 | + | ||
| 133 | + //判断编码格式 | ||
| 134 | + function get_code_type($file) | ||
| 135 | + { | ||
| 136 | + $list = array('GBK', 'UTF-8'); | ||
| 137 | + $str = file_get_contents($file); | ||
| 138 | + foreach ($list as $item) { | ||
| 139 | + $tmp = mb_convert_encoding($str, $item, $item); | ||
| 140 | + if (md5($tmp) == md5($str)) { | ||
| 141 | + return $item; | ||
| 142 | + } | ||
| 143 | + } | ||
| 144 | + return false; | ||
| 145 | + } | ||
| 109 | } | 146 | } |
| @@ -509,15 +509,16 @@ if (!function_exists('str_replace_url')) { | @@ -509,15 +509,16 @@ if (!function_exists('str_replace_url')) { | ||
| 509 | */ | 509 | */ |
| 510 | function str_replace_url($url) | 510 | function str_replace_url($url) |
| 511 | { | 511 | { |
| 512 | - // 使用 parse_url 函数来解析 URL | ||
| 513 | - $urlParts = parse_url($url); | ||
| 514 | - // 检查是否存在 host(域名)部分 | ||
| 515 | - if (isset($urlParts['path'])) { | ||
| 516 | - $urlWithoutDomain = $urlParts['path']; | ||
| 517 | - return $urlWithoutDomain; | ||
| 518 | - } else { | ||
| 519 | - return $url; | 512 | + if(!empty($url)){ |
| 513 | + // 使用 parse_url 函数来解析 URL | ||
| 514 | + $urlParts = parse_url($url); | ||
| 515 | + // 检查是否存在 host(域名)部分 | ||
| 516 | + if (isset($urlParts['path'])) { | ||
| 517 | + $urlWithoutDomain = $urlParts['path']; | ||
| 518 | + return $urlWithoutDomain; | ||
| 519 | + } | ||
| 520 | } | 520 | } |
| 521 | + return $url; | ||
| 521 | } | 522 | } |
| 522 | } | 523 | } |
| 523 | 524 |
| @@ -145,10 +145,8 @@ class OnlineController extends BaseController | @@ -145,10 +145,8 @@ class OnlineController extends BaseController | ||
| 145 | public function setQuestion(){ | 145 | public function setQuestion(){ |
| 146 | $this->request->validate([ | 146 | $this->request->validate([ |
| 147 | 'id'=>'required', | 147 | 'id'=>'required', |
| 148 | - 'question'=>'required' | ||
| 149 | ],[ | 148 | ],[ |
| 150 | 'id.required' => 'ID不能为空', | 149 | 'id.required' => 'ID不能为空', |
| 151 | - 'question.required' => 'question不能为空' | ||
| 152 | ]); | 150 | ]); |
| 153 | $onlineCheckModel = new OnlineCheck(); | 151 | $onlineCheckModel = new OnlineCheck(); |
| 154 | $rs = $onlineCheckModel->edit($this->param,['id'=>$this->param['id']]); | 152 | $rs = $onlineCheckModel->edit($this->param,['id'=>$this->param['id']]); |
| @@ -9,6 +9,7 @@ use App\Models\ASide\APublicModel; | @@ -9,6 +9,7 @@ use App\Models\ASide\APublicModel; | ||
| 9 | use App\Models\Channel\Channel; | 9 | use App\Models\Channel\Channel; |
| 10 | use App\Models\Domain\DomainInfo; | 10 | use App\Models\Domain\DomainInfo; |
| 11 | use App\Models\Manage\Manage; | 11 | use App\Models\Manage\Manage; |
| 12 | +use App\Models\Project\OnlineCheck; | ||
| 12 | use App\Models\Project\Project; | 13 | use App\Models\Project\Project; |
| 13 | use App\Models\Task\Task; | 14 | use App\Models\Task\Task; |
| 14 | use Illuminate\Support\Facades\DB; | 15 | use Illuminate\Support\Facades\DB; |
| @@ -31,7 +32,8 @@ class OptimizeController extends BaseController | @@ -31,7 +32,8 @@ class OptimizeController extends BaseController | ||
| 31 | public function lists(Project $project){ | 32 | public function lists(Project $project){ |
| 32 | $query = $project->leftJoin('gl_project_payment', 'gl_project.id', '=', 'gl_project_payment.project_id') | 33 | $query = $project->leftJoin('gl_project_payment', 'gl_project.id', '=', 'gl_project_payment.project_id') |
| 33 | ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id') | 34 | ->leftJoin('gl_project_deploy_build', 'gl_project.id', '=', 'gl_project_deploy_build.project_id') |
| 34 | - ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id'); | 35 | + ->leftJoin('gl_project_deploy_optimize', 'gl_project.id', '=', 'gl_project_deploy_optimize.project_id') |
| 36 | + ->leftJoin('gl_project_online_check', 'gl_project.id', '=', 'gl_project_online_check.project_id'); | ||
| 35 | $query = $this->searchParam($query); | 37 | $query = $this->searchParam($query); |
| 36 | $lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray(); | 38 | $lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page)->toArray(); |
| 37 | if(!empty($lists['list'])){ | 39 | if(!empty($lists['list'])){ |
| @@ -72,9 +74,9 @@ class OptimizeController extends BaseController | @@ -72,9 +74,9 @@ class OptimizeController extends BaseController | ||
| 72 | $item['product_num'] = $data['product'] ?? 0; | 74 | $item['product_num'] = $data['product'] ?? 0; |
| 73 | $item['keyword_num'] = $item['key'] ?? 0; | 75 | $item['keyword_num'] = $item['key'] ?? 0; |
| 74 | $item['autologin_code'] = getAutoLoginCode($item['id']); | 76 | $item['autologin_code'] = getAutoLoginCode($item['id']); |
| 75 | - $item['article_num'] = ($data['blog'] ?? 0) + ($data['news'] ?? 0); | ||
| 76 | - $item['task_finish_num'] = Task::getNumByProjectId($item['id'], Task::STATUS_DOWN); | ||
| 77 | - $item['task_pending_num'] = Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]); | 77 | +// $item['article_num'] = ($data['blog'] ?? 0) + ($data['news'] ?? 0); |
| 78 | +// $item['task_finish_num'] = Task::getNumByProjectId($item['id'], Task::STATUS_DOWN); | ||
| 79 | +// $item['task_pending_num'] = Task::getNumByProjectId($item['id'], [Task::STATUS_DONGING, Task::STATUS_WAIT]); | ||
| 78 | return $item; | 80 | return $item; |
| 79 | } | 81 | } |
| 80 | /** | 82 | /** |
| @@ -93,6 +95,13 @@ class OptimizeController extends BaseController | @@ -93,6 +95,13 @@ class OptimizeController extends BaseController | ||
| 93 | 'gl_project.type AS type', | 95 | 'gl_project.type AS type', |
| 94 | 'gl_project.created_at AS created_at', | 96 | 'gl_project.created_at AS created_at', |
| 95 | 'gl_project.cooperate_date AS cooperate_date', | 97 | 'gl_project.cooperate_date AS cooperate_date', |
| 98 | + 'gl_project.finish_remain_day AS finish_remain_day', | ||
| 99 | + 'gl_project.remain_day AS remain_day', | ||
| 100 | + 'gl_project_online_check.id AS online_check_id', | ||
| 101 | + 'gl_project_online_check.question AS question', | ||
| 102 | + 'gl_project_online_check.go_question AS go_question', | ||
| 103 | + 'gl_project_online_check.optimist_status AS optimist_status', | ||
| 104 | + 'gl_project_online_check.qa_status AS qa_status', | ||
| 96 | 'gl_project_payment.amount AS amount', | 105 | 'gl_project_payment.amount AS amount', |
| 97 | 'gl_project_deploy_build.dept_id AS dept_id', | 106 | 'gl_project_deploy_build.dept_id AS dept_id', |
| 98 | 'gl_project_deploy_build.keyword_num AS key', | 107 | 'gl_project_deploy_build.keyword_num AS key', |
| @@ -113,7 +122,6 @@ class OptimizeController extends BaseController | @@ -113,7 +122,6 @@ class OptimizeController extends BaseController | ||
| 113 | 'gl_project_deploy_optimize.domain AS domain', | 122 | 'gl_project_deploy_optimize.domain AS domain', |
| 114 | 'gl_project_deploy_optimize.quality_mid AS quality_mid', | 123 | 'gl_project_deploy_optimize.quality_mid AS quality_mid', |
| 115 | 'gl_project_deploy_optimize.design_mid AS design_mid', | 124 | 'gl_project_deploy_optimize.design_mid AS design_mid', |
| 116 | - 'gl_project_payment.amount AS amount', | ||
| 117 | ]; | 125 | ]; |
| 118 | return $select; | 126 | return $select; |
| 119 | } | 127 | } |
| @@ -148,7 +148,6 @@ class ProjectController extends BaseController | @@ -148,7 +148,6 @@ class ProjectController extends BaseController | ||
| 148 | 'gl_project_deploy_optimize.domain AS domain', | 148 | 'gl_project_deploy_optimize.domain AS domain', |
| 149 | 'gl_project_deploy_optimize.quality_mid AS quality_mid', | 149 | 'gl_project_deploy_optimize.quality_mid AS quality_mid', |
| 150 | 'gl_project_deploy_optimize.design_mid AS design_mid', | 150 | 'gl_project_deploy_optimize.design_mid AS design_mid', |
| 151 | - 'gl_project_payment.amount AS amount', | ||
| 152 | ]; | 151 | ]; |
| 153 | return $select; | 152 | return $select; |
| 154 | } | 153 | } |
| @@ -462,7 +461,7 @@ class ProjectController extends BaseController | @@ -462,7 +461,7 @@ class ProjectController extends BaseController | ||
| 462 | 'status.required' => '请选择审核状态', | 461 | 'status.required' => '请选择审核状态', |
| 463 | 'status.in' => '审核状态值无效', | 462 | 'status.in' => '审核状态值无效', |
| 464 | ]); | 463 | ]); |
| 465 | - $logic->onlineCheck($this->param); | 464 | + $logic->onlineCheck(); |
| 466 | $this->response('success'); | 465 | $this->response('success'); |
| 467 | } | 466 | } |
| 468 | 467 | ||
| @@ -630,4 +629,5 @@ class ProjectController extends BaseController | @@ -630,4 +629,5 @@ class ProjectController extends BaseController | ||
| 630 | $data['list'] = $list; | 629 | $data['list'] = $list; |
| 631 | $this->response('success',Code::SUCCESS, $data); | 630 | $this->response('success',Code::SUCCESS, $data); |
| 632 | } | 631 | } |
| 632 | + | ||
| 633 | } | 633 | } |
| @@ -166,21 +166,15 @@ class ATemplateController extends BaseController | @@ -166,21 +166,15 @@ class ATemplateController extends BaseController | ||
| 166 | if (empty($referer) || false == in_array($referer, ['oa.cmer.com', 'quanqiusou.cn', 'zgjoa.globalso.com'])) { | 166 | if (empty($referer) || false == in_array($referer, ['oa.cmer.com', 'quanqiusou.cn', 'zgjoa.globalso.com'])) { |
| 167 | $this->response('非法请求',Code::SYSTEM_ERROR, []); | 167 | $this->response('非法请求',Code::SYSTEM_ERROR, []); |
| 168 | } | 168 | } |
| 169 | - | ||
| 170 | - $lists = $aTemplateLogic->aTemplateList($this->map,$this->page,$this->row,$this->order); | 169 | + $filed = ['id','name','status','image','created_at']; |
| 170 | + $lists = $aTemplateLogic->aTemplateList($this->map,$this->page,$this->row,$this->order,$filed); | ||
| 171 | $data = []; | 171 | $data = []; |
| 172 | if(!empty($lists) && !empty($lists['list'])){ | 172 | if(!empty($lists) && !empty($lists['list'])){ |
| 173 | foreach ($lists['list'] as $k => $v){ | 173 | foreach ($lists['list'] as $k => $v){ |
| 174 | - $data[] = [ | ||
| 175 | - 'id' => $v['id'], | ||
| 176 | - 'name' => $v['name'], | ||
| 177 | - 'status' => $v['status'], | ||
| 178 | - 'image_link' => getImageUrl($v['image']), | ||
| 179 | - 'created_at' => $v['created_at'] | ||
| 180 | - ]; | 174 | + $v['image_link'] = getImageUrl($v['image']); |
| 175 | + $data[] = $v; | ||
| 181 | } | 176 | } |
| 182 | } | 177 | } |
| 183 | - unset($lists['list']); | ||
| 184 | $lists['data'] = $data; | 178 | $lists['data'] = $data; |
| 185 | $this->response('success',Code::SUCCESS,$lists); | 179 | $this->response('success',Code::SUCCESS,$lists); |
| 186 | } | 180 | } |
| @@ -197,7 +191,6 @@ class ATemplateController extends BaseController | @@ -197,7 +191,6 @@ class ATemplateController extends BaseController | ||
| 197 | if (empty($referer) || false == in_array($referer, ['oa.cmer.com', 'quanqiusou.cn', 'zgjoa.globalso.com'])) { | 191 | if (empty($referer) || false == in_array($referer, ['oa.cmer.com', 'quanqiusou.cn', 'zgjoa.globalso.com'])) { |
| 198 | $this->response('非法请求',Code::SYSTEM_ERROR, []); | 192 | $this->response('非法请求',Code::SYSTEM_ERROR, []); |
| 199 | } | 193 | } |
| 200 | - | ||
| 201 | $this->request->validate([ | 194 | $this->request->validate([ |
| 202 | 'id'=>'required' | 195 | 'id'=>'required' |
| 203 | ],[ | 196 | ],[ |
| @@ -33,7 +33,7 @@ class ProjectUserController extends BaseController | @@ -33,7 +33,7 @@ class ProjectUserController extends BaseController | ||
| 33 | $query = $userModel->leftJoin('gl_project', 'gl_project_user.project_id', '=', 'gl_project.id') | 33 | $query = $userModel->leftJoin('gl_project', 'gl_project_user.project_id', '=', 'gl_project.id') |
| 34 | ->leftJoin('gl_project_role', 'gl_project_user.role_id', '=', 'gl_project_role.id'); | 34 | ->leftJoin('gl_project_role', 'gl_project_user.role_id', '=', 'gl_project_role.id'); |
| 35 | $query = $this->searchParam($query); | 35 | $query = $this->searchParam($query); |
| 36 | - $lists = $query->paginate($this->row, $this->selectParam(), 'page', $this->page); | 36 | + $lists = $query->orderBy('gl_project_user.id', 'desc')->paginate($this->row, $this->selectParam(), 'page', $this->page); |
| 37 | $this->response('列表',Code::SUCCESS,$lists); | 37 | $this->response('列表',Code::SUCCESS,$lists); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| @@ -64,12 +64,14 @@ class ProjectUserController extends BaseController | @@ -64,12 +64,14 @@ class ProjectUserController extends BaseController | ||
| 64 | $query = $query->where('gl_project.title','like','%'.$this->map['title'].'%'); | 64 | $query = $query->where('gl_project.title','like','%'.$this->map['title'].'%'); |
| 65 | } | 65 | } |
| 66 | if(isset($this->map['name'])){ | 66 | if(isset($this->map['name'])){ |
| 67 | - | ||
| 68 | $query = $query->where('gl_project_user.name',$this->map['name'][0],$this->map['name'][1]); | 67 | $query = $query->where('gl_project_user.name',$this->map['name'][0],$this->map['name'][1]); |
| 69 | } | 68 | } |
| 70 | if(isset($this->map['mobile'])){ | 69 | if(isset($this->map['mobile'])){ |
| 71 | $query = $query->where('gl_project_user.mobile','like','%'.$this->map['mobile'].'%'); | 70 | $query = $query->where('gl_project_user.mobile','like','%'.$this->map['mobile'].'%'); |
| 72 | } | 71 | } |
| 72 | + if(isset($this->map['project_id'])){ | ||
| 73 | + $query = $query->where('gl_project_user.project_id',$this->map['project_id']); | ||
| 74 | + } | ||
| 73 | return $query; | 75 | return $query; |
| 74 | } | 76 | } |
| 75 | 77 | ||
| @@ -175,4 +177,21 @@ class ProjectUserController extends BaseController | @@ -175,4 +177,21 @@ class ProjectUserController extends BaseController | ||
| 175 | $lists = $project->list(['type'=>['!=',$project::TYPE_ZERO]],'id',['id','title']); | 177 | $lists = $project->list(['type'=>['!=',$project::TYPE_ZERO]],'id',['id','title']); |
| 176 | $this->response('success',Code::SUCCESS,$lists); | 178 | $this->response('success',Code::SUCCESS,$lists); |
| 177 | } | 179 | } |
| 180 | + | ||
| 181 | + /** | ||
| 182 | + * @remark :设置超级管理员 | ||
| 183 | + * @name :setRole | ||
| 184 | + * @author :lyh | ||
| 185 | + * @method :post | ||
| 186 | + * @time :2023/9/22 14:53 | ||
| 187 | + */ | ||
| 188 | + public function setAdmin(UserLogic $userLogic){ | ||
| 189 | + $this->request->validate([ | ||
| 190 | + 'id'=>'required', | ||
| 191 | + ],[ | ||
| 192 | + 'id.required' => 'ID不能为空', | ||
| 193 | + ]); | ||
| 194 | + $userLogic->setRole(); | ||
| 195 | + $this->response('success'); | ||
| 196 | + } | ||
| 178 | } | 197 | } |
| @@ -23,7 +23,7 @@ class WebSettingImageController extends BaseController | @@ -23,7 +23,7 @@ class WebSettingImageController extends BaseController | ||
| 23 | * @time :2023/9/21 15:12 | 23 | * @time :2023/9/21 15:12 |
| 24 | */ | 24 | */ |
| 25 | public function lists(WebSettingImage $webSettingImage){ | 25 | public function lists(WebSettingImage $webSettingImage){ |
| 26 | - $list = $webSettingImage->list(); | 26 | + $list = $webSettingImage->list([],'id',['id','image','type']); |
| 27 | $this->response('success',Code::SUCCESS,$list); | 27 | $this->response('success',Code::SUCCESS,$list); |
| 28 | } | 28 | } |
| 29 | 29 |
| @@ -23,6 +23,7 @@ class UserController extends BaseController | @@ -23,6 +23,7 @@ class UserController extends BaseController | ||
| 23 | public function lists(UserModel $userModel){ | 23 | public function lists(UserModel $userModel){ |
| 24 | //TODO::搜索参数统一处理 | 24 | //TODO::搜索参数统一处理 |
| 25 | $this->map['project_id'] = $this->user['project_id']; | 25 | $this->map['project_id'] = $this->user['project_id']; |
| 26 | + $this->map['role_id'] = ['!=',0]; | ||
| 26 | $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at','wechat','status']); | 27 | $lists = $userModel->lists($this->map,$this->page,$this->row,$this->order,['id','name','mobile','created_at','wechat','status']); |
| 27 | $this->response('success',Code::SUCCESS,$lists); | 28 | $this->response('success',Code::SUCCESS,$lists); |
| 28 | } | 29 | } |
| @@ -17,32 +17,43 @@ class OnlineCheckLogic extends BaseLogic | @@ -17,32 +17,43 @@ class OnlineCheckLogic extends BaseLogic | ||
| 17 | $this->model = new OnlineCheck(); | 17 | $this->model = new OnlineCheck(); |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | - | ||
| 21 | - public function onlineCheck($param){ | ||
| 22 | - $info = $this->model->where('project_id', $param['id'])->first(); | ||
| 23 | - if(!$info){ | 20 | + /** |
| 21 | + * @remark :用户审核 | ||
| 22 | + * @name :onlineCheck | ||
| 23 | + * @author :lyh | ||
| 24 | + * @method :post | ||
| 25 | + * @time :2023/9/22 11:01 | ||
| 26 | + */ | ||
| 27 | + public function onlineCheck(){ | ||
| 28 | + $info = $this->model->read(['project_id'=>$this->param['id']]); | ||
| 29 | + if($info === false){ | ||
| 24 | $this->fail('项目未提交审核'); | 30 | $this->fail('项目未提交审核'); |
| 25 | } | 31 | } |
| 26 | //查看当前用户是否有权限审核 | 32 | //查看当前用户是否有权限审核 |
| 27 | - if($param['type'] == 'optimist'){ | 33 | + if($this->param['type'] == 'optimist'){ |
| 28 | if($info['optimist_mid'] != $this->manager['id']){ | 34 | if($info['optimist_mid'] != $this->manager['id']){ |
| 29 | $this->fail('你无权限提交审核'); | 35 | $this->fail('你无权限提交审核'); |
| 30 | } | 36 | } |
| 31 | }else{ | 37 | }else{ |
| 38 | + //查看当前优化师是否审核 | ||
| 39 | + if($info['optimist_status'] != 1){ | ||
| 40 | + $this->fail('请先优化师审核'); | ||
| 41 | + } | ||
| 32 | if($info['qa_mid'] != $this->manager['id']){ | 42 | if($info['qa_mid'] != $this->manager['id']){ |
| 33 | $this->fail('你无权限提交审核'); | 43 | $this->fail('你无权限提交审核'); |
| 34 | } | 44 | } |
| 45 | + if(isset($this->param['project_type']) && !empty($this->param['project_type'])){ | ||
| 46 | + $projectModel = new Project(); | ||
| 47 | + $projectModel->edit(['type'=>$this->param['project_type']],['id'=>$this->param['id']]); | ||
| 48 | + } | ||
| 35 | } | 49 | } |
| 36 | $data = [ | 50 | $data = [ |
| 37 | - 'project_id' => $param['id'], | ||
| 38 | - $param['type'] . '_mid' => $this->manager['id'], | ||
| 39 | - $param['type'] . '_check_time' => date('Y-m-d H:i:s'), | ||
| 40 | - $param['type'] . '_status' => $param['status'], | 51 | + $this->param['type'] . '_mid' => $this->manager['id'], |
| 52 | + $this->param['type'] . '_check_time' => date('Y-m-d H:i:s'), | ||
| 53 | + $this->param['type'] . '_status' => $this->param['status'], | ||
| 41 | 'remark' => $param['remark'] ??'', | 54 | 'remark' => $param['remark'] ??'', |
| 42 | ]; | 55 | ]; |
| 43 | - | ||
| 44 | - $data['id'] = $info['id']; | ||
| 45 | - return $this->save($data); | 56 | + return $this->model->edit($data,['id'=>$info['id']]); |
| 46 | } | 57 | } |
| 47 | 58 | ||
| 48 | /** | 59 | /** |
| @@ -56,7 +67,7 @@ class OnlineCheckLogic extends BaseLogic | @@ -56,7 +67,7 @@ class OnlineCheckLogic extends BaseLogic | ||
| 56 | $info = $this->model->read(['project_id'=>$this->param['id']]); | 67 | $info = $this->model->read(['project_id'=>$this->param['id']]); |
| 57 | $projectModel = new Project(); | 68 | $projectModel = new Project(); |
| 58 | if($info !== false){ | 69 | if($info !== false){ |
| 59 | - $this->model->edit($this->param,['id'=>$info['id']]); | 70 | + $this->fail('已提交,请勿重复提交'); |
| 60 | }else{ | 71 | }else{ |
| 61 | //组装数据 | 72 | //组装数据 |
| 62 | $data = [ | 73 | $data = [ |
| @@ -203,23 +203,16 @@ class ProjectLogic extends BaseLogic | @@ -203,23 +203,16 @@ class ProjectLogic extends BaseLogic | ||
| 203 | $deployOptimizeModel = new DeployOptimize(); | 203 | $deployOptimizeModel = new DeployOptimize(); |
| 204 | if(isset($deploy_optimize['domain']) && !empty($deploy_optimize['domain'])){ | 204 | if(isset($deploy_optimize['domain']) && !empty($deploy_optimize['domain'])){ |
| 205 | //更改域名 | 205 | //更改域名 |
| 206 | - if(isset($deploy_optimize['domain']) && !empty($deploy_optimize['domain'])){ | ||
| 207 | - $this->editDomainStatus($deploy_optimize['domain'],$deploy_optimize['project_id']); | ||
| 208 | - } | ||
| 209 | - } | ||
| 210 | - if(isset($deploy_optimize['minor_languages']) && !empty($deploy_optimize['minor_languages'])){ | ||
| 211 | - $deploy_optimize['minor_languages'] = Arr::a2s($deploy_optimize['minor_languages']); | ||
| 212 | - } | ||
| 213 | - if(isset($deploy_optimize['minor_keywords']) && !empty($deploy_optimize['minor_keywords'])){ | ||
| 214 | - $deploy_optimize['minor_keywords'] = Arr::a2s($deploy_optimize['minor_keywords']); | 206 | + $this->editDomainStatus($deploy_optimize['domain'],$deploy_optimize['project_id']); |
| 215 | } | 207 | } |
| 216 | - | 208 | + $deploy_optimize['minor_languages'] = Arr::a2s(!empty($deploy_optimize['minor_languages']) ? $deploy_optimize['minor_languages'] : []); |
| 209 | + $deploy_optimize['minor_keywords'] = Arr::a2s(!empty($deploy_optimize['minor_keywords']) ? $deploy_optimize['minor_keywords'] : []); | ||
| 210 | + $deploy_optimize['special'] = !empty($deploy_optimize['special']) ? ','.trim($deploy_optimize['special'],',').',' : ''; | ||
| 217 | //是否更新了api_no | 211 | //是否更新了api_no |
| 218 | $api_no = DeployOptimize::where('id', $deploy_optimize['id'])->value('api_no'); | 212 | $api_no = DeployOptimize::where('id', $deploy_optimize['id'])->value('api_no'); |
| 219 | if($api_no != $deploy_optimize['api_no']){ | 213 | if($api_no != $deploy_optimize['api_no']){ |
| 220 | NoticeLog::createLog(NoticeLog::TYPE_RANK_DATA, ['api_no' => $deploy_optimize['api_no']]); | 214 | NoticeLog::createLog(NoticeLog::TYPE_RANK_DATA, ['api_no' => $deploy_optimize['api_no']]); |
| 221 | } | 215 | } |
| 222 | - | ||
| 223 | $deployOptimizeModel->edit($deploy_optimize,['id'=>$deploy_optimize['id']]); | 216 | $deployOptimizeModel->edit($deploy_optimize,['id'=>$deploy_optimize['id']]); |
| 224 | return $this->success(); | 217 | return $this->success(); |
| 225 | } | 218 | } |
| @@ -7,8 +7,10 @@ use App\Http\Logic\Aside\BaseLogic; | @@ -7,8 +7,10 @@ use App\Http\Logic\Aside\BaseLogic; | ||
| 7 | use App\Models\Manage\Manage; | 7 | use App\Models\Manage\Manage; |
| 8 | use App\Models\Manage\MenuSpecial; | 8 | use App\Models\Manage\MenuSpecial; |
| 9 | use App\Models\Project\Project; | 9 | use App\Models\Project\Project; |
| 10 | +use App\Models\User\ProjectRole; | ||
| 10 | use App\Models\User\User; | 11 | use App\Models\User\User; |
| 11 | use App\Models\User\User as UserModel; | 12 | use App\Models\User\User as UserModel; |
| 13 | +use Illuminate\Support\Facades\DB; | ||
| 12 | 14 | ||
| 13 | class UserLogic extends BaseLogic | 15 | class UserLogic extends BaseLogic |
| 14 | { | 16 | { |
| @@ -40,10 +42,11 @@ class UserLogic extends BaseLogic | @@ -40,10 +42,11 @@ class UserLogic extends BaseLogic | ||
| 40 | } | 42 | } |
| 41 | 43 | ||
| 42 | /** | 44 | /** |
| 43 | - * @name :添加会员 | ||
| 44 | - * @return void | ||
| 45 | - * @author :liyuhang | ||
| 46 | - * @method | 45 | + * @remark :保存用户 |
| 46 | + * @name :projectUserSave | ||
| 47 | + * @author :lyh | ||
| 48 | + * @method :post | ||
| 49 | + * @time :2023/9/22 14:35 | ||
| 47 | */ | 50 | */ |
| 48 | public function projectUserSave() | 51 | public function projectUserSave() |
| 49 | { | 52 | { |
| @@ -150,13 +153,18 @@ class UserLogic extends BaseLogic | @@ -150,13 +153,18 @@ class UserLogic extends BaseLogic | ||
| 150 | */ | 153 | */ |
| 151 | public function user_del() | 154 | public function user_del() |
| 152 | { | 155 | { |
| 153 | - $ids = $this->param['id']; | ||
| 154 | - $this->param['id'] = ['in', $this->param['id']]; | ||
| 155 | - $rs = $this->model->del($this->param); | ||
| 156 | - if ($rs === false) { | ||
| 157 | - $this->fail('删除失败'); | 156 | + foreach ($this->param['id'] as $id){ |
| 157 | + $info = $this->model->read(['id'=>$id],['id','role_id']); | ||
| 158 | + if($info['role_id'] != 0){ | ||
| 159 | + $rs = $this->model->del(['id'=>$id]); | ||
| 160 | + if($rs === false){ | ||
| 161 | + $this->fail('系统错误,请联系管理员'); | ||
| 162 | + } | ||
| 163 | + Common::del_user_cache($this->model, $id, 'A'); | ||
| 164 | + }else{ | ||
| 165 | + $this->fail('超级管理员不允许删除'); | ||
| 166 | + } | ||
| 158 | } | 167 | } |
| 159 | - Common::del_user_cache($this->model, $ids, 'A'); | ||
| 160 | return $this->success(); | 168 | return $this->success(); |
| 161 | } | 169 | } |
| 162 | 170 | ||
| @@ -174,4 +182,32 @@ class UserLogic extends BaseLogic | @@ -174,4 +182,32 @@ class UserLogic extends BaseLogic | ||
| 174 | } | 182 | } |
| 175 | return $this->success(); | 183 | return $this->success(); |
| 176 | } | 184 | } |
| 185 | + | ||
| 186 | + /** | ||
| 187 | + * @remark :设置超级管理员 | ||
| 188 | + * @name :setRole | ||
| 189 | + * @author :lyh | ||
| 190 | + * @method :post | ||
| 191 | + * @time :2023/9/22 14:38 | ||
| 192 | + */ | ||
| 193 | + public function setRole(){ | ||
| 194 | + DB::beginTransaction(); | ||
| 195 | + //获取当前用户的觉得 | ||
| 196 | + $roleModel = new ProjectRole(); | ||
| 197 | + $roleInfo = $roleModel->where('project_id',$this->param['project_id'])->orderBy('id','asc')->first(); | ||
| 198 | + $info = $this->model->read(['role_id'=>0]); | ||
| 199 | + if(empty($info) || empty($roleInfo)){ | ||
| 200 | + $this->fail('系统错误,请联系管理员'); | ||
| 201 | + } | ||
| 202 | + try { | ||
| 203 | + $this->model->edit(['role_id'=>$roleInfo['id']],['id'=>$info['id']]); | ||
| 204 | + $this->model->edit(['role_id'=>0],['id'=>$this->param['id']]); | ||
| 205 | + DB::commit(); | ||
| 206 | + }catch (\Exception $e){ | ||
| 207 | + DB::rollBack(); | ||
| 208 | + $this->fail('系统错误,请联系管理员'); | ||
| 209 | + } | ||
| 210 | + Common::del_user_cache($this->model, [$this->param['id'],$info['id']], 'A'); | ||
| 211 | + return $this->success(); | ||
| 212 | + } | ||
| 177 | } | 213 | } |
| @@ -149,17 +149,21 @@ class BaseLogic extends Logic | @@ -149,17 +149,21 @@ class BaseLogic extends Logic | ||
| 149 | function updateNotify($data) | 149 | function updateNotify($data) |
| 150 | { | 150 | { |
| 151 | $updateNotifyModel = new UpdateNotify(); | 151 | $updateNotifyModel = new UpdateNotify(); |
| 152 | - $info = $updateNotifyModel->read(['project_id'=>$data['project_id'],'route'=>$data['route'],'status'=>1]); | ||
| 153 | - if($info === false){ | ||
| 154 | - $param = [ | ||
| 155 | - 'project_id'=>$data['project_id'], | ||
| 156 | - 'type'=>$data['type'], | ||
| 157 | - 'route'=>$data['route'], | ||
| 158 | - ]; | ||
| 159 | - $updateNotifyModel->add($param); | 152 | + if($data['route'] != 'all'){ |
| 153 | + $info = $updateNotifyModel->read(['project_id'=>$data['project_id'],'route'=>$data['route'],'status'=>1]); | ||
| 154 | + if($info === false){ | ||
| 155 | + $param = [ | ||
| 156 | + 'project_id'=>$data['project_id'], | ||
| 157 | + 'type'=>$data['type'], | ||
| 158 | + 'route'=>$data['route'], | ||
| 159 | + ]; | ||
| 160 | + $updateNotifyModel->add($param); | ||
| 161 | + } | ||
| 162 | + //单页面直接通知更新 | ||
| 163 | + $url = $this->user['domain'].'api/delHtml/?project_id='.$this->user['project_id'].'&route='.$data['route']; | ||
| 164 | + }else{ | ||
| 165 | + $url = $this->user['domain'].'api/webInfo/?type=clear_website'; | ||
| 160 | } | 166 | } |
| 161 | - //单页面直接通知更新 | ||
| 162 | - $url = $this->user['domain'].'api/delHtml/?project_id='.$this->user['project_id'].'&route='.$data['route']; | ||
| 163 | curlGet($url); | 167 | curlGet($url); |
| 164 | return $this->success(); | 168 | return $this->success(); |
| 165 | } | 169 | } |
| @@ -270,20 +270,34 @@ class BlogLogic extends BaseLogic | @@ -270,20 +270,34 @@ class BlogLogic extends BaseLogic | ||
| 270 | */ | 270 | */ |
| 271 | public function importBlog($project_id, $user_id, $data) | 271 | public function importBlog($project_id, $user_id, $data) |
| 272 | { | 272 | { |
| 273 | - $category_id = ''; | ||
| 274 | - if ($data[2]) { | ||
| 275 | - //处理分类 | ||
| 276 | - $blogCategoryLogic = new BlogCategoryLogic(); | ||
| 277 | - $category_id = $blogCategoryLogic->importBlogCategory($project_id, $user_id, $data[2]); | ||
| 278 | - } | ||
| 279 | - | ||
| 280 | $blog = $this->model->read(['name' => $data[0]]); | 273 | $blog = $this->model->read(['name' => $data[0]]); |
| 281 | if (!$blog) { | 274 | if (!$blog) { |
| 275 | + | ||
| 276 | + $category_id = ''; | ||
| 277 | + if ($data[2]) { | ||
| 278 | + //处理分类 | ||
| 279 | + $blogCategoryLogic = new BlogCategoryLogic(); | ||
| 280 | + $category_id = $blogCategoryLogic->importBlogCategory($project_id, $user_id, $data[2]); | ||
| 281 | + } | ||
| 282 | + | ||
| 283 | + $text = ''; | ||
| 284 | + if($data[4]){ | ||
| 285 | + //处理内容中的图片 | ||
| 286 | + $pattern = '<img src="(.*?)">'; | ||
| 287 | + preg_match_all($pattern, $data[4], $result); | ||
| 288 | + if($result[1]){ | ||
| 289 | + foreach ($result[1] as $img){ | ||
| 290 | + $data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]); | ||
| 291 | + } | ||
| 292 | + } | ||
| 293 | + $text = $data[4]; | ||
| 294 | + } | ||
| 295 | + | ||
| 282 | $id = $this->model->addReturnId( | 296 | $id = $this->model->addReturnId( |
| 283 | [ | 297 | [ |
| 284 | 'name' => $data[0], | 298 | 'name' => $data[0], |
| 285 | 'category_id' => $category_id, | 299 | 'category_id' => $category_id, |
| 286 | - 'text' => $data[4] ?? '', | 300 | + 'text' => $text, |
| 287 | 'remark' => $data[3] ?? '', | 301 | 'remark' => $data[3] ?? '', |
| 288 | 'image' => $data['5'] ? CosService::uploadRemote($project_id, 'image_blog', $data[5]) : '', | 302 | 'image' => $data['5'] ? CosService::uploadRemote($project_id, 'image_blog', $data[5]) : '', |
| 289 | 'seo_title' => $data[6] ?? '', | 303 | 'seo_title' => $data[6] ?? '', |
| @@ -25,6 +25,11 @@ class ImportLogic extends BaseLogic | @@ -25,6 +25,11 @@ class ImportLogic extends BaseLogic | ||
| 25 | */ | 25 | */ |
| 26 | public function addImportTask() | 26 | public function addImportTask() |
| 27 | { | 27 | { |
| 28 | + $ext = explode('.', $this->param['file_url']); | ||
| 29 | + if (end($ext) != 'csv') { | ||
| 30 | + $this->fail('导入文件格式必须为csv'); | ||
| 31 | + } | ||
| 32 | + | ||
| 28 | $this->param['project_id'] = $this->user['project_id']; | 33 | $this->param['project_id'] = $this->user['project_id']; |
| 29 | $this->param['user_id'] = $this->user['id']; | 34 | $this->param['user_id'] = $this->user['id']; |
| 30 | $rs = $this->model->add($this->param); | 35 | $rs = $this->model->add($this->param); |
| @@ -36,9 +36,8 @@ class NavLogic extends BaseLogic | @@ -36,9 +36,8 @@ class NavLogic extends BaseLogic | ||
| 36 | { | 36 | { |
| 37 | DB::beginTransaction(); | 37 | DB::beginTransaction(); |
| 38 | try { | 38 | try { |
| 39 | - if(isset($this->param['image']) && !empty($this->param['image'])){ | ||
| 40 | - $this->param['image'] = str_replace_url($this->param['image']); | ||
| 41 | - } | 39 | + $this->param['image'] = str_replace_url(isset($this->param['image']) ? $this->param['image'] : ''); |
| 40 | + $this->param['remark_image'] = str_replace_url(isset($this->param['remark_image']) ? $this->param['remark_image'] : ''); | ||
| 42 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 41 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 43 | $this->handleEditParam();//验证是否可编辑分类 | 42 | $this->handleEditParam();//验证是否可编辑分类 |
| 44 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 43 | $this->model->edit($this->param,['id'=>$this->param['id']]); |
| @@ -269,20 +269,34 @@ class NewsLogic extends BaseLogic | @@ -269,20 +269,34 @@ class NewsLogic extends BaseLogic | ||
| 269 | */ | 269 | */ |
| 270 | public function importNews($project_id, $user_id, $data) | 270 | public function importNews($project_id, $user_id, $data) |
| 271 | { | 271 | { |
| 272 | - $category_id = ''; | ||
| 273 | - if ($data[2]) { | ||
| 274 | - //处理分类 | ||
| 275 | - $newsCategoryLogic = new NewsCategoryLogic(); | ||
| 276 | - $category_id = $newsCategoryLogic->importNewsCategory($project_id, $user_id, $data[2]); | ||
| 277 | - } | ||
| 278 | - | ||
| 279 | $news = $this->model->read(['name' => $data[0]]); | 272 | $news = $this->model->read(['name' => $data[0]]); |
| 280 | if (!$news) { | 273 | if (!$news) { |
| 274 | + | ||
| 275 | + $category_id = ''; | ||
| 276 | + if ($data[2]) { | ||
| 277 | + //处理分类 | ||
| 278 | + $newsCategoryLogic = new NewsCategoryLogic(); | ||
| 279 | + $category_id = $newsCategoryLogic->importNewsCategory($project_id, $user_id, $data[2]); | ||
| 280 | + } | ||
| 281 | + | ||
| 282 | + $text = ''; | ||
| 283 | + if($data[4]){ | ||
| 284 | + //处理内容中的图片 | ||
| 285 | + $pattern = '<img src="(.*?)">'; | ||
| 286 | + preg_match_all($pattern, $data[4], $result); | ||
| 287 | + if($result[1]){ | ||
| 288 | + foreach ($result[1] as $img){ | ||
| 289 | + $data[4] = str_replace($img,getImageUrl(CosService::uploadRemote($project_id,'image_news',$img)),$data[4]); | ||
| 290 | + } | ||
| 291 | + } | ||
| 292 | + $text = $data[4]; | ||
| 293 | + } | ||
| 294 | + | ||
| 281 | $id = $this->model->addReturnId( | 295 | $id = $this->model->addReturnId( |
| 282 | [ | 296 | [ |
| 283 | 'name' => $data[0], | 297 | 'name' => $data[0], |
| 284 | 'category_id' => $category_id, | 298 | 'category_id' => $category_id, |
| 285 | - 'text' => $data[4] ?? '', | 299 | + 'text' => $text, |
| 286 | 'remark' => $data[3] ?? '', | 300 | 'remark' => $data[3] ?? '', |
| 287 | 'image' => $data['5'] ? CosService::uploadRemote($project_id, 'image_news', $data[5]) : '', | 301 | 'image' => $data['5'] ? CosService::uploadRemote($project_id, 'image_news', $data[5]) : '', |
| 288 | 'seo_title' => $data[6] ?? '', | 302 | 'seo_title' => $data[6] ?? '', |
| @@ -381,63 +381,91 @@ class ProductLogic extends BaseLogic | @@ -381,63 +381,91 @@ class ProductLogic extends BaseLogic | ||
| 381 | */ | 381 | */ |
| 382 | public function importProduct($project_id, $user_id, $data) | 382 | public function importProduct($project_id, $user_id, $data) |
| 383 | { | 383 | { |
| 384 | - $category_id = ''; | ||
| 385 | - if ($data[2]) { | ||
| 386 | - //处理分类 | ||
| 387 | - $categoryLogic = new CategoryLogic(); | ||
| 388 | - $category_id = $categoryLogic->importProductCategory($project_id, $data[2]); | ||
| 389 | - } | 384 | + $product = $this->model->read(['title' => $data[0]]); |
| 385 | + if (!$product) { | ||
| 390 | 386 | ||
| 391 | - $keyword_id = ''; | ||
| 392 | - if($data[3]){ | ||
| 393 | - //处理关键词 | ||
| 394 | - $keywordLogic = new KeywordLogic(); | ||
| 395 | - $keyword_id = $keywordLogic->importProductKeyword($project_id, $data[3]); | ||
| 396 | - } | 387 | + $category_id = ''; |
| 388 | + if ($data[2]) { | ||
| 389 | + //处理分类 | ||
| 390 | + $categoryLogic = new CategoryLogic(); | ||
| 391 | + $category_id = $categoryLogic->importProductCategory($project_id, $data[2]); | ||
| 392 | + } | ||
| 397 | 393 | ||
| 398 | - $gallery = []; | ||
| 399 | - $thumb = ''; | ||
| 400 | - if($data[7]){ | ||
| 401 | - //处理图片 | ||
| 402 | - $img_arr = explode(',',$data[7]); | ||
| 403 | - foreach ($img_arr as $v_img){ | ||
| 404 | - $one_img = CosService::uploadRemote($project_id,'image_product',$v_img); | ||
| 405 | - if($one_img){ | ||
| 406 | - $one_gallery = [ | ||
| 407 | - 'alt' => '这是一张产品图', | ||
| 408 | - 'url' => $one_img | ||
| 409 | - ]; | 394 | + $keyword_id = ''; |
| 395 | + if($data[3]){ | ||
| 396 | + //处理关键词 | ||
| 397 | + $keywordLogic = new KeywordLogic(); | ||
| 398 | + $keyword_id = $keywordLogic->importProductKeyword($project_id, $data[3]); | ||
| 399 | + } | ||
| 400 | + | ||
| 401 | + $gallery = []; | ||
| 402 | + $thumb = ''; | ||
| 403 | + if($data[7]){ | ||
| 404 | + //处理图片 | ||
| 405 | + $img_arr = explode(',',$data[7]); | ||
| 406 | + foreach ($img_arr as $v_img){ | ||
| 407 | + if($v_img){ | ||
| 408 | + $one_img = CosService::uploadRemote($project_id,'image_product',$v_img); | ||
| 409 | + if($one_img){ | ||
| 410 | + $one_gallery = [ | ||
| 411 | + 'alt' => '这是一张产品图', | ||
| 412 | + 'url' => $one_img | ||
| 413 | + ]; | ||
| 414 | + | ||
| 415 | + if(!$thumb){ | ||
| 416 | + $thumb = Arr::a2s($one_gallery); | ||
| 417 | + } | ||
| 410 | 418 | ||
| 411 | - if(!$thumb){ | ||
| 412 | - $thumb = Arr::a2s($one_gallery); | 419 | + $gallery[] = $one_gallery; |
| 420 | + } | ||
| 413 | } | 421 | } |
| 422 | + } | ||
| 423 | + } | ||
| 414 | 424 | ||
| 415 | - $gallery[] = $one_gallery; | 425 | + $intro = ''; |
| 426 | + if($data[5]){ | ||
| 427 | + //处理短描述中的图片 | ||
| 428 | + $pattern = '<img src="(.*?)">'; | ||
| 429 | + preg_match_all($pattern, $data[5], $result_intro); | ||
| 430 | + if($result_intro[1]){ | ||
| 431 | + foreach ($result_intro[1] as $vi_img){ | ||
| 432 | + $data[5] = str_replace($vi_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vi_img)),$data[5]); | ||
| 433 | + } | ||
| 416 | } | 434 | } |
| 435 | + $intro = $data[5]; | ||
| 417 | } | 436 | } |
| 418 | - } | ||
| 419 | 437 | ||
| 438 | + $content = ''; | ||
| 439 | + if($data[6]){ | ||
| 440 | + //处理内容中的图片 | ||
| 441 | + $pattern = '<img src="(.*?)">'; | ||
| 442 | + preg_match_all($pattern, $data[6], $result_content); | ||
| 443 | + if($result_content[1]){ | ||
| 444 | + foreach ($result_content[1] as $vc_img){ | ||
| 445 | + $data[6] = str_replace($vc_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vc_img)),$data[6]); | ||
| 446 | + } | ||
| 447 | + } | ||
| 448 | + $content = $data[6]; | ||
| 449 | + } | ||
| 420 | 450 | ||
| 421 | - //处理seo | ||
| 422 | - $seo_mate = [ | ||
| 423 | - 'title' => $data[8]??'', | ||
| 424 | - 'keyword' => $data[9]??'', | ||
| 425 | - 'description' => $data[10]??'' | ||
| 426 | - ]; | 451 | + //处理seo |
| 452 | + $seo_mate = [ | ||
| 453 | + 'title' => $data[8]??'', | ||
| 454 | + 'keyword' => $data[9]??'', | ||
| 455 | + 'description' => $data[10]??'' | ||
| 456 | + ]; | ||
| 427 | 457 | ||
| 428 | - $product = $this->model->read(['title' => $data[0]]); | ||
| 429 | - if (!$product) { | ||
| 430 | $id = $this->model->addReturnId( | 458 | $id = $this->model->addReturnId( |
| 431 | [ | 459 | [ |
| 432 | 'project_id' => $project_id, | 460 | 'project_id' => $project_id, |
| 433 | 'title' => $data[0], | 461 | 'title' => $data[0], |
| 434 | 'thumb' => $thumb, | 462 | 'thumb' => $thumb, |
| 435 | 'gallery' => Arr::a2s($gallery), | 463 | 'gallery' => Arr::a2s($gallery), |
| 436 | - 'attrs' => $data[4] ? $data[4] : Arr::a2s([]), | 464 | + 'attrs' => trim($data[4]) ? $data[4] : Arr::a2s([]), |
| 437 | 'category_id' => $category_id, | 465 | 'category_id' => $category_id, |
| 438 | 'keyword_id' => $keyword_id, | 466 | 'keyword_id' => $keyword_id, |
| 439 | - 'intro' => $data[5] ?? '', | ||
| 440 | - 'content' => $data[6] ?? '', | 467 | + 'intro' => $intro, |
| 468 | + 'content' => $content, | ||
| 441 | 'seo_mate' => Arr::a2s($seo_mate), | 469 | 'seo_mate' => Arr::a2s($seo_mate), |
| 442 | 'created_uid' => $user_id, | 470 | 'created_uid' => $user_id, |
| 443 | 'status' => Product::STATUS_ON | 471 | 'status' => Product::STATUS_ON |
| @@ -42,6 +42,9 @@ class UserLogic extends BaseLogic | @@ -42,6 +42,9 @@ class UserLogic extends BaseLogic | ||
| 42 | if($info !== false){ | 42 | if($info !== false){ |
| 43 | $this->fail('当前手机号码已注册'); | 43 | $this->fail('当前手机号码已注册'); |
| 44 | } | 44 | } |
| 45 | + if(!isset($this->param['role']) || empty($this->param['role'])){ | ||
| 46 | + $this->fail('一个账号只允许一个超级管理员,请先添加角色'); | ||
| 47 | + } | ||
| 45 | $this->param['create_id'] = $this->user['id']; | 48 | $this->param['create_id'] = $this->user['id']; |
| 46 | $this->param['operator_id'] = $this->user['id']; | 49 | $this->param['operator_id'] = $this->user['id']; |
| 47 | $this->param['project_id'] = $this->user['project_id']; | 50 | $this->param['project_id'] = $this->user['project_id']; |
| @@ -74,7 +77,13 @@ class UserLogic extends BaseLogic | @@ -74,7 +77,13 @@ class UserLogic extends BaseLogic | ||
| 74 | } | 77 | } |
| 75 | $this->param['type'] = 1; | 78 | $this->param['type'] = 1; |
| 76 | $this->param['operator_id'] = $this->user['id']; | 79 | $this->param['operator_id'] = $this->user['id']; |
| 77 | - $this->edits(); | 80 | + if(isset($this->param['password']) && empty($this->param['password'])){ |
| 81 | + $this->param['password'] = base64_encode(md5($this->param['password'])); | ||
| 82 | + } | ||
| 83 | + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 84 | + if($rs === false){ | ||
| 85 | + $this->fail('系统错误,请联系管理员'); | ||
| 86 | + } | ||
| 78 | return $this->success(); | 87 | return $this->success(); |
| 79 | } | 88 | } |
| 80 | 89 | ||
| @@ -107,33 +116,4 @@ class UserLogic extends BaseLogic | @@ -107,33 +116,4 @@ class UserLogic extends BaseLogic | ||
| 107 | //对应删除组织架构 | 116 | //对应删除组织架构 |
| 108 | return $this->success(); | 117 | return $this->success(); |
| 109 | } | 118 | } |
| 110 | - | ||
| 111 | - /** | ||
| 112 | - * @param $param | ||
| 113 | - * @remark :编辑用户 | ||
| 114 | - * @name :edits | ||
| 115 | - * @author :lyh | ||
| 116 | - * @method :post | ||
| 117 | - * @time :2023/6/17 16:41 | ||
| 118 | - */ | ||
| 119 | - public function edits(){ | ||
| 120 | - if(!isset($this->param['password']) || empty($this->param['password'])){ | ||
| 121 | - unset($this->param['password']); | ||
| 122 | - }else{ | ||
| 123 | - $this->param['password'] = base64_encode(md5($this->param['password'])); | ||
| 124 | - } | ||
| 125 | - $info = $this->model->read(['mobile'=>$this->param['mobile'], | ||
| 126 | - 'project_id'=>$this->user['project_id'],'id'=>['!=',$this->param['id']]]); | ||
| 127 | - if($info !== false){ | ||
| 128 | - $this->fail('当前手机号码已注册'); | ||
| 129 | - } | ||
| 130 | - //密码加密 | ||
| 131 | - $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 132 | - if($rs === false){ | ||
| 133 | - $this->fail('系统错误,请联系管理员'); | ||
| 134 | - } | ||
| 135 | - //清空当前用户登录缓存 | ||
| 136 | - Cache::pull($this->user['token']); | ||
| 137 | - return $this->success(); | ||
| 138 | - } | ||
| 139 | } | 119 | } |
| @@ -62,4 +62,16 @@ class BNav extends Base | @@ -62,4 +62,16 @@ class BNav extends Base | ||
| 62 | return $value; | 62 | return $value; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | + /** | ||
| 66 | + * @remark :获取图片 | ||
| 67 | + * @name :getImageAttribute | ||
| 68 | + * @author :lyh | ||
| 69 | + * @method :post | ||
| 70 | + * @time :2023/9/18 16:20 | ||
| 71 | + */ | ||
| 72 | + public function getRemarkImageAttribute($value) | ||
| 73 | + { | ||
| 74 | + $value = getImageUrl($value); | ||
| 75 | + return $value; | ||
| 76 | + } | ||
| 65 | } | 77 | } |
| @@ -25,4 +25,18 @@ class DeployOptimize extends Base | @@ -25,4 +25,18 @@ class DeployOptimize extends Base | ||
| 25 | Cache::forget($cache_key); | 25 | Cache::forget($cache_key); |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | + /** | ||
| 29 | + * @remark : | ||
| 30 | + * @name :getSpecialAttribute | ||
| 31 | + * @author :lyh | ||
| 32 | + * @method :post | ||
| 33 | + * @time :2023/9/25 9:58 | ||
| 34 | + */ | ||
| 35 | + public function getSpecialAttribute($value) | ||
| 36 | + { | ||
| 37 | + if(!empty($value)){ | ||
| 38 | + $value = trim($value,','); | ||
| 39 | + } | ||
| 40 | + return $value; | ||
| 41 | + } | ||
| 28 | } | 42 | } |
| @@ -95,11 +95,11 @@ class CosService | @@ -95,11 +95,11 @@ class CosService | ||
| 95 | 'Key' => $key, | 95 | 'Key' => $key, |
| 96 | 'Body' => fopen($file_url, 'r'), | 96 | 'Body' => fopen($file_url, 'r'), |
| 97 | ]); | 97 | ]); |
| 98 | + return $key; | ||
| 98 | }catch (\Exception $e){ | 99 | }catch (\Exception $e){ |
| 99 | LogUtils::error('uploadRemote error', $e->getMessage()); | 100 | LogUtils::error('uploadRemote error', $e->getMessage()); |
| 101 | + return ''; | ||
| 100 | } | 102 | } |
| 101 | - | ||
| 102 | - return $key; | ||
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | } | 105 | } |
| @@ -22,6 +22,7 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -22,6 +22,7 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 22 | Route::any('/del', [Aside\User\ProjectUserController::class, 'del'])->name('admin.user_del'); | 22 | Route::any('/del', [Aside\User\ProjectUserController::class, 'del'])->name('admin.user_del'); |
| 23 | Route::any('/getRole', [Aside\User\ProjectUserController::class, 'getRole'])->name('admin.user_getRole'); | 23 | Route::any('/getRole', [Aside\User\ProjectUserController::class, 'getRole'])->name('admin.user_getRole'); |
| 24 | Route::any('/sort', [Aside\User\ProjectUserController::class, 'sort'])->name('admin.user_sort'); | 24 | Route::any('/sort', [Aside\User\ProjectUserController::class, 'sort'])->name('admin.user_sort'); |
| 25 | + Route::any('/setAdmin', [Aside\User\ProjectUserController::class, 'setAdmin'])->name('admin.user_setAdmin'); | ||
| 25 | Route::any('/getProjectList', [Aside\User\ProjectUserController::class, 'getProjectList'])->name('admin.user_getProjectList'); | 26 | Route::any('/getProjectList', [Aside\User\ProjectUserController::class, 'getProjectList'])->name('admin.user_getProjectList'); |
| 26 | 27 | ||
| 27 | //角色管理 | 28 | //角色管理 |
-
请 注册 或 登录 后发表评论