作者 赵彬吉
@@ -32,7 +32,7 @@ class SyncTimeFiles extends Command @@ -32,7 +32,7 @@ class SyncTimeFiles extends Command
32 public function handle() 32 public function handle()
33 { 33 {
34 $fileModel = new File(); 34 $fileModel = new File();
35 - $start = '2024-08-10 00:00:00'; 35 + $start = '2024-08-26 00:00:00';
36 $end = date('Y-m-d H:i:s'); 36 $end = date('Y-m-d H:i:s');
37 $lists = $fileModel->list(['created_at'=>['between',[$start,$end]]]); 37 $lists = $fileModel->list(['created_at'=>['between',[$start,$end]]]);
38 foreach ($lists as $v){ 38 foreach ($lists as $v){
@@ -55,13 +55,13 @@ class UpdateRoute extends Command @@ -55,13 +55,13 @@ class UpdateRoute extends Command
55 */ 55 */
56 public function handle(){ 56 public function handle(){
57 $projectModel = new Project(); 57 $projectModel = new Project();
58 - $list = $projectModel->list(['id'=>['in',[1535]]]); 58 + $list = $projectModel->list(['id'=>['in',[1155]]]);
59 $data = []; 59 $data = [];
60 foreach ($list as $v){ 60 foreach ($list as $v){
61 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 61 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
62 ProjectServer::useProject($v['id']); 62 ProjectServer::useProject($v['id']);
63 -// $this->getProduct();  
64 - $this->setProductKeyword(); 63 + $this->getProduct();
  64 +// $this->setProductKeyword();
65 // $this->getBlog(); 65 // $this->getBlog();
66 DB::disconnect('custom_mysql'); 66 DB::disconnect('custom_mysql');
67 } 67 }
@@ -386,6 +386,18 @@ class HtmlCollect extends Command @@ -386,6 +386,18 @@ class HtmlCollect extends Command
386 } 386 }
387 } 387 }
388 388
  389 + //特殊项目
  390 + if ($project_id == 2226) {
  391 + preg_match_all('/data-parallax-image=[\'"](.*?)[\'"]>/i', $html, $result_s);
  392 + $special = $result_s[1] ?? [];
  393 + foreach ($special as $v_s) {
  394 + $check_v_s = $this->url_check($v_s, $project_id, $domain, $web_url_domain, $home_url);
  395 + if ($check_v_s && (!in_array($check_v_s, $source))) {
  396 + $source[] = $check_v_s;
  397 + }
  398 + }
  399 + }
  400 +
389 return $source; 401 return $source;
390 } 402 }
391 403
@@ -29,6 +29,7 @@ use App\Models\WebSetting\WebSettingReceiving; @@ -29,6 +29,7 @@ use App\Models\WebSetting\WebSettingReceiving;
29 use App\Services\CosService; 29 use App\Services\CosService;
30 use App\Services\ProjectServer; 30 use App\Services\ProjectServer;
31 use Illuminate\Console\Command; 31 use Illuminate\Console\Command;
  32 +use Illuminate\Support\Facades\Cache;
32 use Illuminate\Support\Facades\DB; 33 use Illuminate\Support\Facades\DB;
33 use Illuminate\Support\Facades\Redis; 34 use Illuminate\Support\Facades\Redis;
34 35
@@ -67,9 +68,14 @@ class ProjectUpdate extends Command @@ -67,9 +68,14 @@ class ProjectUpdate extends Command
67 protected function start_update() 68 protected function start_update()
68 { 69 {
69 $task_id = $this->get_task(); 70 $task_id = $this->get_task();
70 - if (!$task_id) { 71 + if ($task_id === false) {
  72 + //所有任务执行完成
71 sleep(60); 73 sleep(60);
72 return true; 74 return true;
  75 + } elseif ($task_id === 0) {
  76 + //队列任务已处理完,有进程正在查询数据库,等待5秒后执行
  77 + sleep(5);
  78 + return true;
73 } 79 }
74 80
75 $task = UpdateLog::where('id', $task_id)->where('status', UpdateLog::STATUS_UN)->first(); 81 $task = UpdateLog::where('id', $task_id)->where('status', UpdateLog::STATUS_UN)->first();
@@ -711,6 +717,7 @@ class ProjectUpdate extends Command @@ -711,6 +717,7 @@ class ProjectUpdate extends Command
711 $extend = $extend_model->read(['title' => $ke]); 717 $extend = $extend_model->read(['title' => $ke]);
712 if ($extend) { 718 if ($extend) {
713 if ($extend['type'] == 3) { 719 if ($extend['type'] == 3) {
  720 + //图片
714 $gallery = []; 721 $gallery = [];
715 if (is_array($ve)) { 722 if (is_array($ve)) {
716 foreach ($ve as $ve_img) { 723 foreach ($ve as $ve_img) {
@@ -721,8 +728,24 @@ class ProjectUpdate extends Command @@ -721,8 +728,24 @@ class ProjectUpdate extends Command
721 } 728 }
722 $value = Arr::a2s($gallery); 729 $value = Arr::a2s($gallery);
723 } elseif ($extend['type'] == 4) { 730 } elseif ($extend['type'] == 4) {
724 - $value = Arr::a2s([$this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)]); 731 + //文件
  732 + if (is_array($ve)) {
  733 + if (isset($ve['title']) || isset($ve['url'])) {
  734 + $file = [
  735 + [
  736 + 'name' => isset($ve['title']) ? $ve['title'] : '',
  737 + 'url' => isset($ve['url']) ? $this->source_download($ve['url'], $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1) : ''
  738 + ]
  739 + ];
  740 + } else {
  741 + $file = [];
  742 + }
  743 + $value = Arr::a2s($file);
  744 + } else {
  745 + $value = Arr::a2s([$this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)]);
  746 + }
725 } else { 747 } else {
  748 + //文本
726 $value = $ve; 749 $value = $ve;
727 } 750 }
728 751
@@ -777,6 +800,11 @@ class ProjectUpdate extends Command @@ -777,6 +800,11 @@ class ProjectUpdate extends Command
777 return $task_id; 800 return $task_id;
778 } 801 }
779 802
  803 + if (!Cache::add('console_update_task_select_mysql', true, 5)) {
  804 + //如果存在数据锁,表示有其他进程已往下执行,当前进程直接返回
  805 + return 0;
  806 + }
  807 +
780 $task_list = UpdateLog::where('status', UpdateLog::STATUS_UN)->orderBy('sort', 'asc')->orderBy('updated_at', 'asc')->limit(20)->get(); 808 $task_list = UpdateLog::where('status', UpdateLog::STATUS_UN)->orderBy('sort', 'asc')->orderBy('updated_at', 'asc')->limit(20)->get();
781 if ($task_list->count() == 0) { 809 if ($task_list->count() == 0) {
782 return false; 810 return false;
@@ -793,7 +821,7 @@ class ProjectUpdate extends Command @@ -793,7 +821,7 @@ class ProjectUpdate extends Command
793 //获取地址路由 821 //获取地址路由
794 protected function get_url_route($url) 822 protected function get_url_route($url)
795 { 823 {
796 - if (strpos($url, '%3A') !== false || strpos($url, '%2F') !== false) { 824 + if (strpos($url, '%') !== false) {
797 $url = urldecode($url); 825 $url = urldecode($url);
798 } 826 }
799 $arr = parse_url($url); 827 $arr = parse_url($url);
@@ -926,6 +926,28 @@ function base62_encode($num) { @@ -926,6 +926,28 @@ function base62_encode($num) {
926 return $result; 926 return $result;
927 } 927 }
928 928
  929 +/**
  930 + * @remark :腾讯云安全的base64
  931 + * @name :urlSafeBase64Encode
  932 + * @author :lyh
  933 + * @method :post
  934 + * @time :2024/8/19 14:21
  935 + */
  936 +function urlSafeBase64Encode($data = '') {
  937 + if(empty($data)){
  938 + return $data;
  939 + }
  940 + // 1. 使用标准的 BASE64 编码
  941 + $base64 = base64_encode($data);
  942 + // 2. 将加号(+)替换成连接号(-)
  943 + $base64 = str_replace('+', '-', $base64);
  944 + // 3. 将正斜线(/)替换成下划线(_)
  945 + $base64 = str_replace('/', '_', $base64);
  946 + // 4. 去掉末尾的等号(=)
  947 + $base64 = rtrim($base64, '=');
  948 + return $base64;
  949 +}
  950 +
929 951
930 952
931 953
@@ -30,7 +30,7 @@ class ProductController extends BaseController @@ -30,7 +30,7 @@ class ProductController extends BaseController
30 public function getImages(Request $request) 30 public function getImages(Request $request)
31 { 31 {
32 $project_id = $request->input('project_id'); 32 $project_id = $request->input('project_id');
33 - $project = ProjectServer::useProject($project_id); 33 + $project = ProjectServer::useProject($project_id); $project = ProjectServer::useProject($project_id);
34 if (!$project) { 34 if (!$project) {
35 $this->response('项目不存在', Code::SYSTEM_ERROR); 35 $this->response('项目不存在', Code::SYSTEM_ERROR);
36 } 36 }
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Aside\AutoPull;
  4 +
  5 +use App\Enums\Common\Code;
  6 +use App\Helper\Arr;
  7 +use App\Http\Controllers\Aside\BaseController;
  8 +use App\Models\AutoPull\AutoPullNotify;
  9 +use App\Models\Manage\Manage;
  10 +
  11 +class AutoPullController extends BaseController
  12 +{
  13 + /**
  14 + * 获取自动拉取代码任务列表
  15 + * @author Akun
  16 + * @date 2024/08/26 15:49
  17 + */
  18 + public function getTaskLists()
  19 + {
  20 + $autoModule = new AutoPullNotify();
  21 + $lists = $autoModule->lists($this->map, $this->page, $this->row);
  22 + if (!empty($lists)) {
  23 + $manage_model = new Manage();
  24 + foreach ($lists['list'] as $k => $v) {
  25 + $lists['list'][$k]['operator_name'] = $manage_model->getName($v['user_id']);
  26 + $lists['list'][$k]['server_name'] = AutoPullNotify::serversMap()[$v['server_id']];
  27 +
  28 + $process = Arr::s2a($v['process']);
  29 + $process_name = [];
  30 + if ($process) {
  31 + foreach ($process as $kp => $vp) {
  32 + $process_name[$kp] = AutoPullNotify::processMap()[$vp];
  33 + }
  34 + }
  35 +
  36 + $lists['list'][$k]['process_name'] = $process_name;
  37 + }
  38 + }
  39 +
  40 + $this->response('success', Code::SUCCESS, $lists);
  41 + }
  42 +
  43 + /**
  44 + * 添加自动拉取代码任务
  45 + * @author Akun
  46 + * @date 2024/08/26 16:31
  47 + */
  48 + public function saveTask()
  49 + {
  50 + $this->request->validate([
  51 + 'server_id' => 'required',
  52 + ], [
  53 + 'server_id.required' => '服务器不能为空'
  54 + ]);
  55 +
  56 + $model = new AutoPullNotify();
  57 +
  58 + foreach ($this->param['server_id'] as $v) {
  59 + $model->add([
  60 + 'user_id' => $this->uid,
  61 + 'server_id' => $v,
  62 + 'process' => Arr::a2s($this->param['process'] ?? []),
  63 + 'status' => 0
  64 + ]);
  65 + }
  66 +
  67 + $this->response('success');
  68 + }
  69 +
  70 + /**
  71 + * 获取服务器及进程配置
  72 + * @author Akun
  73 + * @date 2024/08/26 16:07
  74 + */
  75 + public function taskMap()
  76 + {
  77 + $servers = AutoPullNotify::serversMap();
  78 + $process = AutoPullNotify::processMap();
  79 +
  80 + $lists = [
  81 + 'servers' => $servers,
  82 + 'process' => $process
  83 + ];
  84 +
  85 + $this->response('success', Code::SUCCESS, $lists);
  86 + }
  87 +}
@@ -47,7 +47,8 @@ class ExtensionModuleController extends BaseController @@ -47,7 +47,8 @@ class ExtensionModuleController extends BaseController
47 '3'=>'图片框', 47 '3'=>'图片框',
48 '4'=>'文件框', 48 '4'=>'文件框',
49 '5'=>'下拉框', 49 '5'=>'下拉框',
50 - '6'=>'自动生成订单框' 50 + '6'=>'自动生成订单框',
  51 + '7'=>'创建时间'
51 ]; 52 ];
52 $this->response('success',Code::SUCCESS,$data); 53 $this->response('success',Code::SUCCESS,$data);
53 } 54 }
@@ -66,7 +67,7 @@ class ExtensionModuleController extends BaseController @@ -66,7 +67,7 @@ class ExtensionModuleController extends BaseController
66 'module_id.required' => '模块id不能为空', 67 'module_id.required' => '模块id不能为空',
67 ]); 68 ]);
68 $moduleFieldModel = new ExtensionModuleField(); 69 $moduleFieldModel = new ExtensionModuleField();
69 - $list = $moduleFieldModel->list(['module_id'=>$this->param['module_id']]); 70 + $list = $moduleFieldModel->list(['module_id'=>$this->param['module_id']],'sort',['*'],'desc');
70 $moduleValueModel = new ExtensionModuleValue(); 71 $moduleValueModel = new ExtensionModuleValue();
71 foreach ($list as $k => $v){ 72 foreach ($list as $k => $v){
72 $v['is_use'] = 0; 73 $v['is_use'] = 0;
@@ -76,6 +77,9 @@ class ExtensionModuleController extends BaseController @@ -76,6 +77,9 @@ class ExtensionModuleController extends BaseController
76 $v['is_use'] = 1; 77 $v['is_use'] = 1;
77 } 78 }
78 $list[$k] = $v; 79 $list[$k] = $v;
  80 + if(!empty($v['data'])){
  81 + $v['data'] = json_decode($v['data'],true);
  82 + }
79 } 83 }
80 $this->response('success',Code::SUCCESS,$list); 84 $this->response('success',Code::SUCCESS,$list);
81 } 85 }
@@ -133,12 +137,25 @@ class ExtensionModuleController extends BaseController @@ -133,12 +137,25 @@ class ExtensionModuleController extends BaseController
133 ],[ 137 ],[
134 'module_id.required' => '模块id不能为空', 138 'module_id.required' => '模块id不能为空',
135 ]); 139 ]);
  140 + $searchParam = [
  141 + 'module_id'=>$this->param['module_id'],
  142 + ];
136 $data = []; 143 $data = [];
137 $moduleValueModel = new ExtensionModuleValue(); 144 $moduleValueModel = new ExtensionModuleValue();
138 - $lists = $moduleValueModel->list(['module_id'=>$this->param['module_id']]); 145 + if(isset($this->param['field_id']) && ($this->param['field_id'] != 0) && isset($this->param['value'])){
  146 + $uuidArr = $moduleValueModel->formatQuery(['field_id'=>$this->param['field_id'],'value'=>$this->param['value'],'module_id'=>$this->param['module_id']])->distinct()->pluck('uuid')->toArray();
  147 + if(!empty($uuidArr)){
  148 + $searchParam['uuid'] = ['in',$uuidArr];
  149 + }
  150 + }
  151 + if(isset($this->param['start_time']) && !empty($this->param['start_time']) && isset($this->param['end_time']) && !empty($this->param['end_time'])){
  152 + $searchParam['created_at'] = ['between',[$this->param['start_time'],$this->param['end_time']]];
  153 + }
  154 + $lists = $moduleValueModel->list($searchParam);
139 if(!empty($lists)){ 155 if(!empty($lists)){
140 foreach ($lists as $k => $v){ 156 foreach ($lists as $k => $v){
141 $data[$v['uuid']][$v['field_id']] = $v['value']; 157 $data[$v['uuid']][$v['field_id']] = $v['value'];
  158 + $data[$v['uuid']]['created_at'] = $v['created_at'];
142 } 159 }
143 } 160 }
144 $resultData = []; 161 $resultData = [];
@@ -224,7 +241,112 @@ class ExtensionModuleController extends BaseController @@ -224,7 +241,112 @@ class ExtensionModuleController extends BaseController
224 * @time :2024/8/20 10:31 241 * @time :2024/8/20 10:31
225 */ 242 */
226 public function sendUniqueStr(){ 243 public function sendUniqueStr(){
227 - $uniqueString = md5(time() . rand(1000, 9999)); 244 + $this->request->validate([
  245 + 'id'=>'required',
  246 + ],[
  247 + 'id.required' => '字段id不能为空',
  248 + ]);
  249 + $uniqueString = '';
  250 + //查看当前字段id的data
  251 + $moduleFieldModel = new ExtensionModuleField();
  252 + $info = $moduleFieldModel->read(['id'=>$this->param['id']]);
  253 + if(empty($info['data'])){
  254 + $uniqueString = md5(time() . rand(1000, 9999));
  255 + }else{
  256 + $data = json_decode($info['data']);
  257 + foreach ($data as $v){
  258 + foreach ($v as $k => $sonV){
  259 + if($k == 1){
  260 + $uniqueString .= $sonV;
  261 + }elseif ($k == 2){
  262 + $uniqueString .= date('YmdHis');
  263 + }elseif ($k == 3){
  264 + $uniqueString .= uniqid();
  265 + }else{
  266 + $randomString = md5(uniqid(mt_rand(), true));
  267 + $uniqueString .= substr($randomString, 0, (int)$sonV);
  268 + }
  269 + }
  270 + }
  271 + }
228 $this->response('success',Code::SUCCESS,['str'=>$uniqueString]); 272 $this->response('success',Code::SUCCESS,['str'=>$uniqueString]);
229 } 273 }
  274 +
  275 + /**
  276 + * @remark :获取类型
  277 + * @name :getFieldType
  278 + * @author :lyh
  279 + * @method :post
  280 + * @time :2024/8/22 11:22
  281 + */
  282 + public function getFieldType(){
  283 + $data = [
  284 + 1=>'文本框',
  285 + 2=>'多文本框',
  286 + 3=>'图片框',
  287 + 4=>'文件框',
  288 + 5=>'下拉框',
  289 + 6=>'自动订单'
  290 + ];
  291 + $this->response('success',Code::SUCCESS,$data);
  292 + }
  293 +
  294 + /**
  295 + * @remark :设置排序
  296 + * @name :setSort
  297 + * @author :lyh
  298 + * @method :post
  299 + * @time :2024/8/22 17:27
  300 + */
  301 + public function setSort(){
  302 + $moduleFieldModel = new ExtensionModuleField();
  303 + $num = 100;
  304 + foreach ($this->param['id'] as $id){
  305 + $moduleFieldModel->edit(['sort'=>$num],['id'=>$id]);
  306 + $num--;
  307 + }
  308 + $this->response('success');
  309 + }
  310 +
  311 + /**
  312 + * @remark :设置搜索参数
  313 + * @name :setSearchParam
  314 + * @author :lyh
  315 + * @method :post
  316 + * @time :2024/8/23 16:24
  317 + */
  318 + public function setSearchParam(){
  319 + $this->request->validate([
  320 + 'module_id'=>'required',
  321 + 'id'=>'required|array'
  322 + ],[
  323 + 'module_id.required' => '模块id不能为空',
  324 + 'id.required'=>'id不能为空',
  325 + 'id.array'=>'id是一个数组'
  326 + ]);
  327 + $moduleFieldModel = new ExtensionModuleField();
  328 + $moduleFieldModel->edit(['is_search'=>0],['module_id'=>$this->param['module_id']]);
  329 + $moduleFieldModel->edit(['is_search'=>1],['id'=>['in',$this->param['id']]]);
  330 + $this->response('success');
  331 + }
  332 +
  333 + /**
  334 + * @remark :删除数据
  335 + * @name :delExtensionValue
  336 + * @author :lyh
  337 + * @method :post
  338 + * @time :2024/8/26 14:25
  339 + */
  340 + public function delExtensionValue(){
  341 + $this->request->validate([
  342 + 'module_id'=>'required',
  343 + 'uuid'=>'required',
  344 + ],[
  345 + 'module_id.required' => '模块id不能为空',
  346 + 'uuid.required' => '字段id不能为空',
  347 + ]);
  348 + $moduleValueModel = new ExtensionModuleValue();
  349 + $moduleValueModel->del(['module_id'=>$this->param['module_id'],'uuid'=>$this->param['uuid']]);
  350 + $this->response('success');
  351 + }
230 } 352 }
@@ -134,6 +134,9 @@ class InquiryController extends BaseController @@ -134,6 +134,9 @@ class InquiryController extends BaseController
134 } 134 }
135 135
136 foreach ($map as $field => $name) { 136 foreach ($map as $field => $name) {
  137 + if(is_array($item[$field])){
  138 + $item[$field] = implode(',',$item[$field]);
  139 + }
137 if (Str::startsWith($item[$field], '=')) { 140 if (Str::startsWith($item[$field], '=')) {
138 $item[$field] = "'" . $item[$field]; 141 $item[$field] = "'" . $item[$field];
139 } 142 }
@@ -17,6 +17,7 @@ use App\Models\Product\ExtendInfo; @@ -17,6 +17,7 @@ use App\Models\Product\ExtendInfo;
17 use App\Models\Product\Keyword; 17 use App\Models\Product\Keyword;
18 use App\Models\Product\KeywordRelated; 18 use App\Models\Product\KeywordRelated;
19 use App\Models\Product\Product; 19 use App\Models\Product\Product;
  20 +use App\Models\Product\ProductType;
20 use App\Models\RouteMap\RouteMap; 21 use App\Models\RouteMap\RouteMap;
21 use App\Models\Template\Setting; 22 use App\Models\Template\Setting;
22 use App\Models\Template\BTemplate; 23 use App\Models\Template\BTemplate;
@@ -665,4 +666,41 @@ class ProductController extends BaseController @@ -665,4 +666,41 @@ class ProductController extends BaseController
665 $logic->delProductKeyword(); 666 $logic->delProductKeyword();
666 $this->response('success'); 667 $this->response('success');
667 } 668 }
  669 +
  670 + /**
  671 + * @remark :获取产品类型
  672 + * @name :getProductType
  673 + * @author :lyh
  674 + * @method :post
  675 + * @time :2024/8/21 17:18
  676 + */
  677 + public function getProductType(){
  678 + $typeModel = new ProductType();
  679 + $data = $typeModel->list(['project_id'=>['in',[0,$this->user['project_id']]]]);
  680 + $this->response('success',Code::SUCCESS,$data);
  681 + }
  682 +
  683 + /**
  684 + * @remark :保存数据
  685 + * @name :saveType
  686 + * @author :lyh
  687 + * @method :post
  688 + * @time :2024/8/21 17:52
  689 + */
  690 + public function saveType(){
  691 + $this->request->validate([
  692 + 'name'=>'required',
  693 + ],[
  694 + 'name.required' => 'id不为空',
  695 + ]);
  696 + $typeModel = new ProductType();
  697 + if(isset($this->param['id']) && !empty($this->param['id'])){
  698 + $id = $this->param['id'];
  699 + $typeModel->edit($this->param,['id'=>$this->param['id']]);
  700 + }else{
  701 + $this->param['project_id'] = $this->user['project_id'];
  702 + $id = $typeModel->addReturnId($this->param);
  703 + }
  704 + $this->response('success',Code::SUCCESS,['id'=>$id]);
  705 + }
668 } 706 }
@@ -147,7 +147,14 @@ class FileController @@ -147,7 +147,14 @@ class FileController
147 */ 147 */
148 public function synchronizationFile($fileName,$location){ 148 public function synchronizationFile($fileName,$location){
149 //同步到大文件 149 //同步到大文件
150 - SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName,'location'=>$location]); 150 + $file_path = $this->getUrl($this->path.'/'.$fileName, 0,$location);
  151 + $headers = get_headers($file_path, 1);
  152 + if (strpos($headers[0], '200') === false) {
  153 + $errorFileModel = new ErrorFile();
  154 + $errorFileModel->add(['path'=>$this->param['path'].'/'.$this->param['name']]);
  155 + }else{
  156 + SyncImageFileJob::dispatch(['path'=>$this->path,'name'=>$fileName,'location'=>$location]);
  157 + }
151 return true; 158 return true;
152 } 159 }
153 160
@@ -10,10 +10,13 @@ use App\Jobs\CopyProjectJob; @@ -10,10 +10,13 @@ use App\Jobs\CopyProjectJob;
10 use App\Jobs\SyncImageFileJob; 10 use App\Jobs\SyncImageFileJob;
11 use App\Models\File\ErrorFile; 11 use App\Models\File\ErrorFile;
12 use App\Models\File\Image as ImageModel; 12 use App\Models\File\Image as ImageModel;
  13 +use App\Models\File\ImageSetting;
  14 +use App\Models\File\WatermarkImage;
13 use App\Models\Project\Project; 15 use App\Models\Project\Project;
14 use App\Services\AmazonS3Service; 16 use App\Services\AmazonS3Service;
15 use App\Services\CosService; 17 use App\Services\CosService;
16 use App\Services\TencentCosService; 18 use App\Services\TencentCosService;
  19 +use App\Services\UpyunService;
17 use Illuminate\Http\Exceptions\HttpResponseException; 20 use Illuminate\Http\Exceptions\HttpResponseException;
18 use Illuminate\Http\JsonResponse; 21 use Illuminate\Http\JsonResponse;
19 use Illuminate\Support\Facades\Cache; 22 use Illuminate\Support\Facades\Cache;
@@ -204,8 +207,9 @@ class ImageController extends Controller @@ -204,8 +207,9 @@ class ImageController extends Controller
204 $fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0); 207 $fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0);
205 //上传到cos 208 //上传到cos
206 if($this->upload_location == 0){ 209 if($this->upload_location == 0){
  210 + $watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0);
207 $cosService = new CosService(); 211 $cosService = new CosService();
208 - $cosService->uploadFile($files,$this->path,$fileName); 212 + $cosService->uploadFile($files,$this->path,$fileName,false,$watermarkOptions);
209 }else{ 213 }else{
210 //TODO::上传亚马逊 214 //TODO::上传亚马逊
211 $amazonS3Service = new AmazonS3Service(); 215 $amazonS3Service = new AmazonS3Service();
@@ -337,8 +341,9 @@ class ImageController extends Controller @@ -337,8 +341,9 @@ class ImageController extends Controller
337 $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name); 341 $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
338 //同步数据到cos 342 //同步数据到cos
339 if($this->upload_location == 0){ 343 if($this->upload_location == 0){
  344 + $watermarkOptions = $this->getProjectConfig($this->cache['project_id'] ?? 0);
340 $cosService = new CosService(); 345 $cosService = new CosService();
341 - $cosService->uploadFile($file,$this->path,$fileName); 346 + $cosService->uploadFile($file,$this->path,$fileName,false,$watermarkOptions);
342 }else{ 347 }else{
343 //TODO::上传亚马逊 348 //TODO::上传亚马逊
344 $amazonS3Service = new AmazonS3Service(); 349 $amazonS3Service = new AmazonS3Service();
@@ -354,6 +359,54 @@ class ImageController extends Controller @@ -354,6 +359,54 @@ class ImageController extends Controller
354 } 359 }
355 360
356 /** 361 /**
  362 + * @remark :获取图片配置
  363 + * @name :getProjectConfig
  364 + * @author :lyh
  365 + * @method :post
  366 + * @time :2024/8/24 11:03
  367 + */
  368 + public function getProjectConfig($project_id = 0){
  369 + $str = '';
  370 + $imageSettingModel = new ImageSetting();
  371 + $settingInfo = $imageSettingModel->read(['project_id'=>$project_id]);
  372 + if($settingInfo !== false){
  373 + if($settingInfo['status'] == 1 && !empty($settingInfo['image_data'])){
  374 + $image_data = json_decode($settingInfo['image_data'],true);
  375 + foreach ($image_data as $k => $v){
  376 + if (str_starts_with($v, "image/")) {
  377 + $v = 'image/'.urlSafeBase64Encode(substr($v, strlen("image/")));
  378 + }
  379 + $image_data[$k] = $v;
  380 + }
  381 + $str = 'watermark/1/'.implode('/',$image_data);
  382 + return $str;
  383 + }
  384 + if($settingInfo['status'] == 2 && !empty($settingInfo['str_data'])){
  385 + $str_data = json_decode($settingInfo['str_data'],true);
  386 + foreach ($str_data as $k => $v){
  387 + $arr = explode('/',$v);
  388 + if ($arr[0] == 'text') {
  389 + $arr[1] = urlSafeBase64Encode($arr[1]);
  390 + $v = implode('/',$arr);
  391 + }
  392 + if ($arr[0] == 'font') {
  393 + $arr[1] = urlSafeBase64Encode($arr[1]);
  394 + $v = implode('/',$arr);
  395 + }
  396 + if ($arr[0] == 'fill') {
  397 + $arr[1] = urlSafeBase64Encode($arr[1]);
  398 + $v = implode('/',$arr);
  399 + }
  400 + $str_data[$k] = $v;
  401 + }
  402 + }
  403 + $str = 'watermark/2/'.implode('/',$str_data);
  404 + return $str;
  405 + }
  406 + return $str;
  407 + }
  408 +
  409 + /**
357 * @param $filename 410 * @param $filename
358 * @remark :下载 411 * @remark :下载
359 * @name :download 412 * @name :download
@@ -514,4 +567,203 @@ class ImageController extends Controller @@ -514,4 +567,203 @@ class ImageController extends Controller
514 $data = ['image_download'=>url('a/download_images?path='.$info['path']), 'name' => $info['name']]; 567 $data = ['image_download'=>url('a/download_images?path='.$info['path']), 'name' => $info['name']];
515 $this->response('success',Code::SUCCESS,$data); 568 $this->response('success',Code::SUCCESS,$data);
516 } 569 }
  570 +
  571 + /**
  572 + * @remark :覆盖原图
  573 + * @name :coverOriginalImage
  574 + * @author :lyh
  575 + * @method :post
  576 + * @time :2024/8/21 11:45
  577 + */
  578 + public function coverOriginalImage(){
  579 + $this->request->validate([
  580 + 'old_url'=>['required'],
  581 + 'url'=>['required'],
  582 + 'saveUrl'=>['required'],
  583 + ],[
  584 + 'old_url.required'=>'原图的相对路径',
  585 + 'url.required'=>'请填写预览的链接',
  586 + 'saveUrl.required'=>'保存的路径',
  587 + ]);
  588 + $cos = new CosService();
  589 + $url = $cos->coverOriginalImage($this->param['url'],$this->param['saveUrl']);
  590 + $this->saveWatermarkImage($this->param['saveUrl'],$this->param['old_url']);
  591 + if($this->param['saveUrl'] == $this->param['old_url']){
  592 + $upYun = new UpyunService();
  593 + $upYun->purgePush($url);
  594 + }
  595 + $this->response('success',Code::SUCCESS,['url'=>$url]);
  596 + }
  597 +
  598 + /**
  599 + * @remark :设置图片水印
  600 + * @name :setWatermark
  601 + * @author :lyh
  602 + * @method :post
  603 + * @time :2024/8/21 9:15
  604 + */
  605 + public function setWatermark(){
  606 + $this->request->validate([
  607 + 'url'=>['required'],
  608 + 'is_image'=>['required'],
  609 + ],[
  610 + 'url.required'=>'请填写需要处理图片的相对路径',
  611 + 'is_image.required'=>'请设置文本水印还是图片水印',
  612 + ]);
  613 + $cos = new CosService();
  614 + $url = $cos->setWatermark($this->param['url'], $this->param['data'],$this->param['is_image']);
  615 + $this->response('success',Code::SUCCESS,['url'=>$url]);
  616 + }
  617 +
  618 + /**
  619 + * @remark :获取字体
  620 + * @name :getFont
  621 + * @author :lyh
  622 + * @method :post
  623 + * @time :2024/8/21 9:47
  624 + */
  625 + public function getFont(){
  626 + $cos = new CosService();
  627 + $data = $cos->getFont();
  628 + $this->response('success',Code::SUCCESS,$data);
  629 + }
  630 +
  631 + /**
  632 + * @remark :处理9宫格数据
  633 + * @name :getPosition
  634 + * @author :lyh
  635 + * @method :post
  636 + * @time :2024/8/21 9:47
  637 + */
  638 + public function getPosition(){
  639 + $cos = new CosService();
  640 + $data = $cos->getPosition();
  641 + $this->response('success',Code::SUCCESS,$data);
  642 + }
  643 +
  644 + /**
  645 + * @remark :保存水印图片记录
  646 + * @name :saveWatermarkImage
  647 + * @author :lyh
  648 + * @method :post
  649 + * @time :2024/8/21 14:34
  650 + */
  651 + public function saveWatermarkImage($path,$old_path){
  652 + $watermarkImageModel = new WatermarkImage();
  653 + $data = [
  654 + 'path' => $path,
  655 + 'old_path'=>$old_path,
  656 + 'project_id' =>$this->cache['project_id'] ?? 0
  657 + ];
  658 + return $watermarkImageModel->addReturnId($data);
  659 + }
  660 +
  661 + /**
  662 + * @remark :设置请求参数
  663 + * @name :setInputParam
  664 + * @author :lyh
  665 + * @method :post
  666 + * @time :2024/8/24 10:31
  667 + */
  668 + public function saveInputParam(){
  669 + $this->request->validate([
  670 + 'data'=>['required'],
  671 + 'is_image'=>['required'],
  672 + ],[
  673 + 'data.required'=>'数据',
  674 + 'is_image.required'=>'请设置文本水印还是图片水印',
  675 + ]);
  676 + $data = $this->param['data'];
  677 + $is_image = $this->param['is_image'];
  678 + $imageSetting = new ImageSetting();
  679 + $info = $imageSetting->read(['project_id'=>$this->cache['project_id']]);
  680 + $domain = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';//cos域名
  681 + if($is_image){
  682 + $param = [
  683 + 'image/'.$domain.($data['image'] ?? ''),//图片
  684 + 'gravity/'.($data['gravity'] ?? 'SouthEast'),
  685 + 'dx/'.($data['dx'] ?? 0),
  686 + 'dy/'. ($data['dy'] ?? 0),
  687 + 'batch/'.($data['batch'] ?? 0),//平铺水印功能
  688 + 'dissolve/'.($data['dissolve'] ?? 50),//透明度
  689 + 'degree/'.($data['degree'] ?? 0),//旋转角度设置,取值范围为0 - 360,默认0
  690 + ];
  691 + if($info === false){
  692 + $imageSetting->add(['image_data'=>json_encode($param,true),'project_id'=>$this->cache['project_id']]);
  693 + }else{
  694 + $imageSetting->edit(['image_data'=>json_encode($param,true)],['project_id'=>$this->cache['project_id']]);
  695 + }
  696 + }else{
  697 + $param = [
  698 + 'text/'.($data['text'] ?? ''),//文字水印名称
  699 + 'gravity/'.($data['gravity'] ?? 'SouthEast'),
  700 + 'dx/'.($data['dx'] ?? 10),
  701 + 'dy/'. ($data['dy'] ?? 10),
  702 + 'font/'.($data['font'] ?? 'tahoma.ttf'),//默认宋体
  703 + 'fontsize/'.($data['fontsize'] ?? 24),//水印文字字体大小,单位为磅,缺省值13
  704 + 'fill/'.($data['fill'] ?? '#3D3D3D'),//颜色
  705 + 'dissolve/'.($data['dissolve'] ?? 50),//透明度
  706 + 'degree/'.($data['degree'] ?? 0),//文字水印的旋转角度设置,取值范围为0 - 360,默认0
  707 + 'batch/'.($data['batch'] ?? 0),//平铺水印功能
  708 + 'shadow/'.($data['shadow'] ?? 0),//文字阴影效果,有效值为[0,100],默认为0,表示无阴影
  709 + ];
  710 + if($info === false){
  711 + $imageSetting->add(['str_data'=>json_encode($param,true),'project_id'=>$this->cache['project_id']]);
  712 + }else{
  713 + $imageSetting->edit(['str_data'=>json_encode($param,true)],['project_id'=>$this->cache['project_id']]);
  714 + }
  715 + }
  716 + $this->response('success');
  717 + }
  718 +
  719 + /**
  720 + * @remark :修改水印配置状态
  721 + * @name :editStatus
  722 + * @author :lyh
  723 + * @method :post
  724 + * @time :2024/8/24 11:14
  725 + */
  726 + public function editStatus(){
  727 + $this->request->validate([
  728 + 'status'=>'required',
  729 + ],[
  730 + 'status.required'=>'状态',
  731 + ]);
  732 + $imageSetting = new ImageSetting();
  733 + $info = $imageSetting->read(['project_id'=>$this->cache['project_id']]);
  734 + if($info === false){
  735 + $this->response('请先设置水印',Code::SYSTEM_ERROR);
  736 + }
  737 + if($info['status'] == 1 && empty($info['image_data'])){
  738 + $this->response('请先设置水印',Code::SYSTEM_ERROR);
  739 + }
  740 + if($info['status'] == 2 && empty($info['str_data'])){
  741 + $this->response('请先设置水印',Code::SYSTEM_ERROR);
  742 + }
  743 + $imageSetting->edit(['status'=>$this->param['status']],['project_id'=>$this->cache['project_id']]);
  744 + $this->response('success');
  745 + }
  746 +
  747 + /**
  748 + * @remark :获取配置
  749 + * @name :getImageSetting
  750 + * @author :lyh
  751 + * @method :post
  752 + * @time :2024/8/24 11:41
  753 + */
  754 + public function getImageSetting(){
  755 + $imageSetting = new ImageSetting();
  756 + $info = $imageSetting->read(['project_id'=>$this->cache['project_id']]);
  757 + if($info !== false){
  758 + if(!empty($info['image_data'])){
  759 + $info['image_data'] = json_decode($info['image_data'],true);
  760 + }
  761 + if(!empty($info['str_data'])){
  762 + $info['str_data'] = json_decode($info['str_data'],true);
  763 + }
  764 + $info['domain'] = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';
  765 + }
  766 +
  767 + $this->response('success',Code::SUCCESS,$info);
  768 + }
517 } 769 }
@@ -114,7 +114,7 @@ class BTemplateLogic extends BaseLogic @@ -114,7 +114,7 @@ class BTemplateLogic extends BaseLogic
114 $condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>'','is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id]; 114 $condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>'','is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id];
115 $headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id); 115 $headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id);
116 $bTemplateComModel = new BTemplateCom(); 116 $bTemplateComModel = new BTemplateCom();
117 - $otherInfo = $bTemplateComModel->read(['source'=>$headComInfo['source'],'common_type'=>BTemplate::COMMON_OTHER,'is_list'=>$headComInfo['is_list'],'is_custom'=>$headComInfo['is_custom']]); 117 + $otherInfo = $bTemplateComModel->read(['source'=>$headComInfo['source'],'common_type'=>BTemplate::COMMON_OTHER,'is_list'=>$headComInfo['is_list'],'is_custom'=>$headComInfo['is_custom'],'template_id'=>$template_id]);
118 if($otherInfo === false){ 118 if($otherInfo === false){
119 $this->fail('获取失败,请联系管理员222'); 119 $this->fail('获取失败,请联系管理员222');
120 } 120 }
@@ -139,7 +139,7 @@ class BTemplateLogic extends BaseLogic @@ -139,7 +139,7 @@ class BTemplateLogic extends BaseLogic
139 $headComInfo = $bTemplateComModel->read($condition); 139 $headComInfo = $bTemplateComModel->read($condition);
140 if($headComInfo === false){ 140 if($headComInfo === false){
141 //取默认公共的 141 //取默认公共的
142 - $headComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_HEAD]); 142 + $headComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_HEAD,'template_id'=>$template_id]);
143 if($headComInfo === false){ 143 if($headComInfo === false){
144 $this->fail('获取失败,请联系管理员111'); 144 $this->fail('获取失败,请联系管理员111');
145 } 145 }
@@ -160,7 +160,7 @@ class BTemplateLogic extends BaseLogic @@ -160,7 +160,7 @@ class BTemplateLogic extends BaseLogic
160 $footerComInfo = $bTemplateComModel->read($condition); 160 $footerComInfo = $bTemplateComModel->read($condition);
161 if($footerComInfo === false){ 161 if($footerComInfo === false){
162 //取默认首页的 162 //取默认首页的
163 - $footerComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_FOOTER]); 163 + $footerComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_FOOTER,'template_id'=>$template_id]);
164 if($footerComInfo === false){ 164 if($footerComInfo === false){
165 $this->fail('获取失败,请联系管理员'); 165 $this->fail('获取失败,请联系管理员');
166 } 166 }
@@ -51,33 +51,50 @@ class CustomTemplateLogic extends BaseLogic @@ -51,33 +51,50 @@ class CustomTemplateLogic extends BaseLogic
51 $this->fail('当前数据不存在'); 51 $this->fail('当前数据不存在');
52 } 52 }
53 if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){ 53 if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){
54 - $html = $this->getTemplateComHtml($info['html'],$info['html_style']); 54 + $template_id = $this->getTemplateId();
  55 + $html = $this->getTemplateComHtml($info['html'],$info['html_style'],$template_id);
55 $info['html'] = $this->getHeadFooter($html); 56 $info['html'] = $this->getHeadFooter($html);
56 } 57 }
57 return $this->success($info); 58 return $this->success($info);
58 } 59 }
59 60
60 /** 61 /**
  62 + * @remark :获取模版id
  63 + * @name :getTemplateId
  64 + * @author :lyh
  65 + * @method :post
  66 + * @time :2023/12/27 10:51
  67 + */
  68 + public function getTemplateId(){
  69 + $bSettingModel = new Setting();
  70 + $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']],['id','template_id']);
  71 + if($bSettingInfo === false){
  72 + $this->fail('请先设置模板');
  73 + }
  74 + return $this->success($bSettingInfo['template_id']);
  75 + }
  76 + /**
61 * @remark :非定制获取头部+底部 77 * @remark :非定制获取头部+底部
62 * @name :getTemplateComHtml 78 * @name :getTemplateComHtml
63 * @author :lyh 79 * @author :lyh
64 * @method :post 80 * @method :post
65 * @time :2024/4/29 16:53 81 * @time :2024/4/29 16:53
66 */ 82 */
67 - public function getTemplateComHtml($html,$html_style){ 83 + public function getTemplateComHtml($html,$html_style,$template_id){
68 if(empty($html)){ 84 if(empty($html)){
69 $html = "<main></main>"; 85 $html = "<main></main>";
70 $html_style = "<style id='globalsojs-styles'></style>"; 86 $html_style = "<style id='globalsojs-styles'></style>";
71 } 87 }
72 - $headComInfo = $this->getHeadComHtml(['common_type'=>BTemplate::COMMON_HEAD]); 88 + $headComInfo = $this->getHeadComHtml(['common_type'=>BTemplate::COMMON_HEAD,'template_id'=>$template_id]);
73 $bTemplateComModel = new BTemplateCom(); 89 $bTemplateComModel = new BTemplateCom();
74 $condition['common_type'] = BTemplate::COMMON_OTHER; 90 $condition['common_type'] = BTemplate::COMMON_OTHER;
75 $condition['source'] = $headComInfo['source']; 91 $condition['source'] = $headComInfo['source'];
  92 + $condition['template_id'] = $template_id;
76 $otherInfo = $bTemplateComModel->read($condition); 93 $otherInfo = $bTemplateComModel->read($condition);
77 if($otherInfo === false){ 94 if($otherInfo === false){
78 $this->fail('获取失败,请联系管理员'); 95 $this->fail('获取失败,请联系管理员');
79 } 96 }
80 - $footerComInfo = $this->getFooterComHtml(); 97 + $footerComInfo = $this->getFooterComHtml($template_id);
81 $commonInfo = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '', 98 $commonInfo = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '',
82 'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? '']; 99 'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? ''];
83 $html = $commonInfo['head_style'].$html_style.$commonInfo['footer_style'].$commonInfo['other']. $commonInfo['head_html'].$html.$commonInfo['footer_html']; 100 $html = $commonInfo['head_style'].$html_style.$commonInfo['footer_style'].$commonInfo['other']. $commonInfo['head_html'].$html.$commonInfo['footer_html'];
@@ -98,6 +115,7 @@ class CustomTemplateLogic extends BaseLogic @@ -98,6 +115,7 @@ class CustomTemplateLogic extends BaseLogic
98 $headComInfo = $bTemplateComModel->read($condition); 115 $headComInfo = $bTemplateComModel->read($condition);
99 if($headComInfo === false){ 116 if($headComInfo === false){
100 //取默认公共的 117 //取默认公共的
  118 + $template_id = $this->getTemplateId();
101 $condition['source'] = BTemplate::SOURCE_COM; 119 $condition['source'] = BTemplate::SOURCE_COM;
102 $headComInfo = $bTemplateComModel->read($condition); 120 $headComInfo = $bTemplateComModel->read($condition);
103 if($headComInfo === false){ 121 if($headComInfo === false){
@@ -113,12 +131,14 @@ class CustomTemplateLogic extends BaseLogic @@ -113,12 +131,14 @@ class CustomTemplateLogic extends BaseLogic
113 * @method :post 131 * @method :post
114 * @time :2024/4/29 17:18 132 * @time :2024/4/29 17:18
115 */ 133 */
116 - public function getFooterComHtml(){ 134 + public function getFooterComHtml($template_id){
117 $bTemplateComModel = new BTemplateCom(); 135 $bTemplateComModel = new BTemplateCom();
  136 + $condition['template_id'] = $template_id;
118 $condition['common_type'] = BTemplate::COMMON_FOOTER; 137 $condition['common_type'] = BTemplate::COMMON_FOOTER;
119 $condition['source'] = $this->getType(BTemplate::COMMON_FOOTER); 138 $condition['source'] = $this->getType(BTemplate::COMMON_FOOTER);
120 $footerComInfo = $bTemplateComModel->read($condition); 139 $footerComInfo = $bTemplateComModel->read($condition);
121 if($footerComInfo === false){ 140 if($footerComInfo === false){
  141 + $template_id = $this->getTemplateId();
122 //取默认首页的 142 //取默认首页的
123 $condition['source'] = BTemplate::SOURCE_COM; 143 $condition['source'] = BTemplate::SOURCE_COM;
124 $footerComInfo = $bTemplateComModel->read($condition); 144 $footerComInfo = $bTemplateComModel->read($condition);
@@ -57,6 +57,7 @@ class InitHtmlLogic extends BaseLogic @@ -57,6 +57,7 @@ class InitHtmlLogic extends BaseLogic
57 $html = $commonInfo['head_style'].$main_style.$commonInfo['footer_style'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html']; 57 $html = $commonInfo['head_style'].$main_style.$commonInfo['footer_style'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
58 $html = $this->getHeadFooter($html);//组装数据 58 $html = $this->getHeadFooter($html);//组装数据
59 $data['html'] = $html; 59 $data['html'] = $html;
  60 + $data['template_id'] = $template_id;
60 return $this->success($data); 61 return $this->success($data);
61 } 62 }
62 63
@@ -71,7 +72,7 @@ class InitHtmlLogic extends BaseLogic @@ -71,7 +72,7 @@ class InitHtmlLogic extends BaseLogic
71 $condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id]; 72 $condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id];
72 $headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id); 73 $headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id);
73 $bTemplateComModel = new BTemplateCom(); 74 $bTemplateComModel = new BTemplateCom();
74 - $otherInfo = $bTemplateComModel->read(['source'=>$headComInfo['source'],'common_type'=>BTemplate::COMMON_OTHER,'is_list'=>$headComInfo['is_list'],'is_custom'=>$headComInfo['is_custom']]); 75 + $otherInfo = $bTemplateComModel->read(['template_id'=>$template_id,'source'=>$headComInfo['source'],'common_type'=>BTemplate::COMMON_OTHER,'is_list'=>$headComInfo['is_list'],'is_custom'=>$headComInfo['is_custom']]);
75 if($otherInfo === false){ 76 if($otherInfo === false){
76 $this->fail('获取失败,请联系管理员2'); 77 $this->fail('获取失败,请联系管理员2');
77 } 78 }
@@ -96,7 +97,7 @@ class InitHtmlLogic extends BaseLogic @@ -96,7 +97,7 @@ class InitHtmlLogic extends BaseLogic
96 $headComInfo = $bTemplateComModel->read($condition); 97 $headComInfo = $bTemplateComModel->read($condition);
97 if($headComInfo === false){ 98 if($headComInfo === false){
98 //取默认公共的 99 //取默认公共的
99 - $headComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_HEAD]); 100 + $headComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_HEAD,'template_id'=>$template_id]);
100 if($headComInfo === false){ 101 if($headComInfo === false){
101 $this->fail('获取失败,请联系管理员1'); 102 $this->fail('获取失败,请联系管理员1');
102 } 103 }
@@ -117,7 +118,7 @@ class InitHtmlLogic extends BaseLogic @@ -117,7 +118,7 @@ class InitHtmlLogic extends BaseLogic
117 $footerComInfo = $bTemplateComModel->read($condition); 118 $footerComInfo = $bTemplateComModel->read($condition);
118 if($footerComInfo === false){ 119 if($footerComInfo === false){
119 //取默认首页的 120 //取默认首页的
120 - $footerComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_FOOTER]); 121 + $footerComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_FOOTER,'template_id'=>$template_id]);
121 if($footerComInfo === false){ 122 if($footerComInfo === false){
122 $this->fail('获取失败,请联系管理员3'); 123 $this->fail('获取失败,请联系管理员3');
123 } 124 }
@@ -94,7 +94,8 @@ class CustomModuleContentLogic extends BaseLogic @@ -94,7 +94,8 @@ class CustomModuleContentLogic extends BaseLogic
94 }elseif($v['type'] == 4){ 94 }elseif($v['type'] == 4){
95 $arr1 = json_decode($info['values']); 95 $arr1 = json_decode($info['values']);
96 foreach ($arr1 as $k1=>$v1){ 96 foreach ($arr1 as $k1=>$v1){
97 - $v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location'],$this->user['file_cdn'] ?? 0); 97 + $v1 = (array)$v1;
  98 + $v1['url'] = getFileUrl($v1['url'] ?? $v1,$this->user['storage_type'],$this->user['project_location'],$this->user['file_cdn'] ?? 0);
98 $arr1[$k1] = $v1; 99 $arr1[$k1] = $v1;
99 } 100 }
100 $v['values'] = $arr1; 101 $v['values'] = $arr1;
@@ -149,6 +150,11 @@ class CustomModuleContentLogic extends BaseLogic @@ -149,6 +150,11 @@ class CustomModuleContentLogic extends BaseLogic
149 * @time :2023/12/7 15:04 150 * @time :2023/12/7 15:04
150 */ 151 */
151 public function contentAdd(){ 152 public function contentAdd(){
  153 + //验证当前name是否已添加
  154 + $info = $this->model->read(['name'=>$this->param['name'],'module_id'=>$this->param['module_id']]);
  155 + if($info !== false){
  156 + $this->fail('当前数据名称已存在');
  157 + }
152 try { 158 try {
153 $this->param['sort'] = $this->setNewsSort(); 159 $this->param['sort'] = $this->setNewsSort();
154 $id = $this->model->addReturnId($this->param); 160 $id = $this->model->addReturnId($this->param);
@@ -301,7 +307,7 @@ class CustomModuleContentLogic extends BaseLogic @@ -301,7 +307,7 @@ class CustomModuleContentLogic extends BaseLogic
301 $v['values'] = json_encode($v['values']); 307 $v['values'] = json_encode($v['values']);
302 }elseif ($v['type'] == 4){ 308 }elseif ($v['type'] == 4){
303 foreach ($v['values'] as $k1=>$v1){ 309 foreach ($v['values'] as $k1=>$v1){
304 - $v1 = str_replace_url($v1); 310 + $v1['url'] = str_replace_url($v1['url']);
305 $v['values'][$k1] = $v1; 311 $v['values'][$k1] = $v1;
306 } 312 }
307 $v['values'] = json_encode($v['values']); 313 $v['values'] = json_encode($v['values']);
@@ -39,6 +39,9 @@ class ExtensionModuleFieldLogic extends BaseLogic @@ -39,6 +39,9 @@ class ExtensionModuleFieldLogic extends BaseLogic
39 if($info !== false){ 39 if($info !== false){
40 $this->fail('当前字段名已存在'); 40 $this->fail('当前字段名已存在');
41 } 41 }
  42 + if(isset($this->param['data']) && !empty($this->param['data'])){
  43 + $this->param['data'] = json_encode($this->param['data']);
  44 + }
42 if(isset($this->param['id']) && !empty($this->param['id'])){ 45 if(isset($this->param['id']) && !empty($this->param['id'])){
43 $id = $this->param['id']; 46 $id = $this->param['id'];
44 $this->model->edit($this->param,['id'=>$id]); 47 $this->model->edit($this->param,['id'=>$id]);
@@ -59,11 +62,11 @@ class ExtensionModuleFieldLogic extends BaseLogic @@ -59,11 +62,11 @@ class ExtensionModuleFieldLogic extends BaseLogic
59 public function delModuleField(){ 62 public function delModuleField(){
60 //查看当前字段是否在使用 63 //查看当前字段是否在使用
61 $moduleValueModel = new ExtensionModuleValue(); 64 $moduleValueModel = new ExtensionModuleValue();
62 - $info = $moduleValueModel->read(['filed_id'=>$this->param['filed_id']]); 65 + $info = $moduleValueModel->read(['field_id'=>$this->param['field_id']]);
63 if($info !== false){ 66 if($info !== false){
64 $this->fail('当前字段正在使用中,不允许删除'); 67 $this->fail('当前字段正在使用中,不允许删除');
65 } 68 }
66 - $this->model->del(['id'=>$this->param['filed_id']]); 69 + $this->model->del(['id'=>$this->param['field_id']]);
67 return $this->success(); 70 return $this->success();
68 } 71 }
69 } 72 }
@@ -178,6 +178,7 @@ class UserLoginLogic @@ -178,6 +178,7 @@ class UserLoginLogic
178 $info['uptime'] = $project['uptime']; 178 $info['uptime'] = $project['uptime'];
179 $info['storage_type'] = $project['storage_type']; 179 $info['storage_type'] = $project['storage_type'];
180 $info['project_location'] = $project['project_location']; 180 $info['project_location'] = $project['project_location'];
  181 + $info['open_export_product'] = $project['open_export_product'];
181 $info['is_update_language'] = $project['is_update_language']; 182 $info['is_update_language'] = $project['is_update_language'];
182 $info['configuration'] = $project['deploy_build']['configuration']; 183 $info['configuration'] = $project['deploy_build']['configuration'];
183 $info['file_cdn'] = $project['deploy_build']['file_cdn']; 184 $info['file_cdn'] = $project['deploy_build']['file_cdn'];
@@ -286,6 +287,7 @@ class UserLoginLogic @@ -286,6 +287,7 @@ class UserLoginLogic
286 $info['configuration'] = $project['deploy_build']['configuration']; 287 $info['configuration'] = $project['deploy_build']['configuration'];
287 $info['project_type'] = $project['type']; 288 $info['project_type'] = $project['type'];
288 $info['storage_type'] = $project['storage_type']; 289 $info['storage_type'] = $project['storage_type'];
  290 + $info['open_export_product'] = $project['open_export_product'];
289 $info['project_location'] = $project['project_location']; 291 $info['project_location'] = $project['project_location'];
290 $info['file_cdn'] = $project['deploy_build']['file_cdn']; 292 $info['file_cdn'] = $project['deploy_build']['file_cdn'];
291 $info['service_duration'] = $project['deploy_build']['service_duration'] ?? 0; 293 $info['service_duration'] = $project['deploy_build']['service_duration'] ?? 0;
  1 +<?php
  2 +
  3 +namespace App\Models\AutoPull;
  4 +
  5 +use App\Models\Base;
  6 +
  7 +class AutoPullNotify extends Base
  8 +{
  9 + protected $table = 'gl_auto_pull_notify';
  10 +
  11 + public static function serversMap()
  12 + {
  13 + return [
  14 + 1 => '硅谷云服务器',
  15 + 9 => '硅谷IDC服务器01(6.0美服1)',
  16 + 3 => '硅谷IDC服务器02(6.0美服2)',
  17 + 2 => '俄罗斯服务器',
  18 + 4 => '阿里云深圳服务器',
  19 + 5 => '日本服务器',
  20 + 8 => '香港服务器',
  21 + ];
  22 + }
  23 +
  24 + public static function processMap()
  25 + {
  26 + return [
  27 + 'php artisan handle_html' => '拉取页面zip文件并解压',
  28 + 'php artisan create_update_page_route' => '创建主站路由',
  29 + 'php artisan create_update_page_master' => '生成主站页面',
  30 + 'php artisan create_update_page_minor' => '生成小语种页面',
  31 + 'php artisan create_update_page_now' => '实时生成主站页面',
  32 + 'php artisan create_update_page_sitemap' => '生成主站sitemap,robots',
  33 + 'php artisan create_update_amp_route' => '创建amp站路由',
  34 + 'php artisan create_update_page_amp' => '生成amp站页面',
  35 + 'php artisan create_update_amp_sitemap' => '生成amp站sitemap,robots',
  36 + ];
  37 + }
  38 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ImageSetting.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/24 10:07
  8 + */
  9 +
  10 +namespace App\Models\File;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class ImageSetting extends Base
  15 +{
  16 + protected $table = 'gl_image_setting';
  17 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :WatermarkImage.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/21 14:29
  8 + */
  9 +
  10 +namespace App\Models\File;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class WatermarkImage extends Base
  15 +{
  16 + protected $table = 'gl_watermark_image';
  17 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ProductType.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/8/21 16:46
  8 + */
  9 +
  10 +namespace App\Models\Product;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class ProductType extends Base
  15 +{
  16 + protected $table = 'gl_product_type';
  17 +}
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace App\Services; 3 namespace App\Services;
4 4
5 use App\Exceptions\InquiryFilterException; 5 use App\Exceptions\InquiryFilterException;
  6 +use App\Models\File\ImageSetting;
6 use App\Utils\LogUtils; 7 use App\Utils\LogUtils;
7 use Qcloud\Cos\Client; 8 use Qcloud\Cos\Client;
8 /** 9 /**
@@ -22,7 +23,7 @@ class CosService @@ -22,7 +23,7 @@ class CosService
22 * @method :post 23 * @method :post
23 * @time :2023/7/19 15:28 24 * @time :2023/7/19 15:28
24 */ 25 */
25 - public function uploadFile(&$files,$path,$filename, $binary = false,$watermarkOptions = null) 26 + public function uploadFile(&$files,$path,$filename, $binary = false,$watermarkOptions = '')
26 { 27 {
27 $cos = config('filesystems.disks.cos'); 28 $cos = config('filesystems.disks.cos');
28 $cosClient = new Client([ 29 $cosClient = new Client([
@@ -41,18 +42,18 @@ class CosService @@ -41,18 +42,18 @@ class CosService
41 ]; 42 ];
42 //水印 43 //水印
43 if ($watermarkOptions) { 44 if ($watermarkOptions) {
44 - $options['Pic-Operations'] = json_encode([ 45 + $options['PicOperations'] = json_encode([
45 'is_pic_info' => 1, 46 'is_pic_info' => 1,
46 'rules' => [ 47 'rules' => [
47 [ 48 [
48 - 'fileid' => $filename, // 使用相同的文件名保存 49 + 'fileid' => $key, // 使用相同的文件名保存
49 'rule' => $watermarkOptions, 50 'rule' => $watermarkOptions,
50 ] 51 ]
51 ] 52 ]
52 - ]); 53 + ], true);
53 } 54 }
54 - // 上传文件  
55 - $cosClient->putObject($options); 55 + $res = $cosClient->putObject($options);
  56 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($res, true) . PHP_EOL, FILE_APPEND);
56 return $key; 57 return $key;
57 } 58 }
58 59
@@ -182,29 +183,29 @@ class CosService @@ -182,29 +183,29 @@ class CosService
182 South:底部中间 183 South:底部中间
183 SouthEast:右下角 184 SouthEast:右下角
184 */ 185 */
185 - public function addFieldImage($cdnUrl = '',$data = [],$is_image = false){ 186 + public function setWatermark($cdnUrl = '',$data = [],$is_image = false){
186 $domain = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';//cos域名 187 $domain = 'http://globalso-v6-1309677403.cos.ap-hongkong.myqcloud.com';//cos域名
187 $url = $domain . $cdnUrl; 188 $url = $domain . $cdnUrl;
188 if($is_image){ 189 if($is_image){
189 $param = [ 190 $param = [
190 - 'image/'.$this->urlSafeBase64Encode($domain.$data['image'] ?? ''),//文字水印名称 191 + 'image/'.urlSafeBase64Encode($domain.$data['image'] ?? ''),//图片
191 'gravity/'.($data['gravity'] ?? 'SouthEast'), 192 'gravity/'.($data['gravity'] ?? 'SouthEast'),
192 'dx/'.($data['dx'] ?? 0), 193 'dx/'.($data['dx'] ?? 0),
193 'dy/'. ($data['dy'] ?? 0), 194 'dy/'. ($data['dy'] ?? 0),
194 'batch/'.($data['batch'] ?? 0),//平铺水印功能 195 'batch/'.($data['batch'] ?? 0),//平铺水印功能
195 'dissolve/'.($data['dissolve'] ?? 50),//透明度 196 'dissolve/'.($data['dissolve'] ?? 50),//透明度
196 - 'degree/'.($data['degree'] ?? 0),//文字水印的旋转角度设置,取值范围为0 - 360,默认0 197 + 'degree/'.($data['degree'] ?? 0),//旋转角度设置,取值范围为0 - 360,默认0
197 ]; 198 ];
198 $url = $url.'?watermark/1/'.implode('/',$param); 199 $url = $url.'?watermark/1/'.implode('/',$param);
199 }else{ 200 }else{
200 $param = [ 201 $param = [
201 - 'text/'.$this->urlSafeBase64Encode($data['text'] ?? ''),//文字水印名称 202 + 'text/'.urlSafeBase64Encode($data['text'] ?? ''),//文字水印名称
202 'gravity/'.($data['gravity'] ?? 'SouthEast'), 203 'gravity/'.($data['gravity'] ?? 'SouthEast'),
203 'dx/'.($data['dx'] ?? 10), 204 'dx/'.($data['dx'] ?? 10),
204 'dy/'. ($data['dy'] ?? 10), 205 'dy/'. ($data['dy'] ?? 10),
205 - 'font/'.$this->urlSafeBase64Encode($data['font'] ?? 'tahoma.ttf'),//默认宋体 206 + 'font/'.urlSafeBase64Encode($data['font'] ?? 'tahoma.ttf'),//默认宋体
206 'fontsize/'.($data['fontsize'] ?? 24),//水印文字字体大小,单位为磅,缺省值13 207 'fontsize/'.($data['fontsize'] ?? 24),//水印文字字体大小,单位为磅,缺省值13
207 - 'fill/'.$this->urlSafeBase64Encode($data['fill'] ?? '#3D3D3D'),//颜色 208 + 'fill/'.urlSafeBase64Encode($data['fill'] ?? '#3D3D3D'),//颜色
208 'dissolve/'.($data['dissolve'] ?? 50),//透明度 209 'dissolve/'.($data['dissolve'] ?? 50),//透明度
209 'degree/'.($data['degree'] ?? 0),//文字水印的旋转角度设置,取值范围为0 - 360,默认0 210 'degree/'.($data['degree'] ?? 0),//文字水印的旋转角度设置,取值范围为0 - 360,默认0
210 'batch/'.($data['batch'] ?? 0),//平铺水印功能 211 'batch/'.($data['batch'] ?? 0),//平铺水印功能
@@ -215,14 +216,16 @@ class CosService @@ -215,14 +216,16 @@ class CosService
215 return $url; 216 return $url;
216 } 217 }
217 218
  219 +
  220 +
218 /** 221 /**
219 - * @remark :添加水印后保存图片(覆盖) 222 + * @remark :添加水印后保存图片(覆盖/非覆盖的文件未存入数据库
220 * @name :uploadImages 223 * @name :uploadImages
221 * @author :lyh 224 * @author :lyh
222 * @method :post 225 * @method :post
223 * @time :2024/8/19 17:06 226 * @time :2024/8/19 17:06
224 */ 227 */
225 - public function uploadImages($url,$cdnUrl){ 228 + public function coverOriginalImage($url,$cdnUrl){
226 // 获取水印后的图片内容 229 // 获取水印后的图片内容
227 $imageContent = file_get_contents($url); 230 $imageContent = file_get_contents($url);
228 // 使用 COS SDK 将图片重新上传并覆盖原图 231 // 使用 COS SDK 将图片重新上传并覆盖原图
@@ -244,28 +247,6 @@ class CosService @@ -244,28 +247,6 @@ class CosService
244 } 247 }
245 248
246 /** 249 /**
247 - * @remark :腾讯云安全的base64  
248 - * @name :urlSafeBase64Encode  
249 - * @author :lyh  
250 - * @method :post  
251 - * @time :2024/8/19 14:21  
252 - */  
253 - public function urlSafeBase64Encode($data = '') {  
254 - if(empty($data)){  
255 - return $data;  
256 - }  
257 - // 1. 使用标准的 BASE64 编码  
258 - $base64 = base64_encode($data);  
259 - // 2. 将加号(+)替换成连接号(-)  
260 - $base64 = str_replace('+', '-', $base64);  
261 - // 3. 将正斜线(/)替换成下划线(_)  
262 - $base64 = str_replace('/', '_', $base64);  
263 - // 4. 去掉末尾的等号(=)  
264 - $base64 = rtrim($base64, '=');  
265 - return $base64;  
266 - }  
267 -  
268 - /**  
269 * @remark :处理9宫格数据 250 * @remark :处理9宫格数据
270 * @name :getPosition 251 * @name :getPosition
271 * @author :lyh 252 * @author :lyh
@@ -274,15 +255,15 @@ class CosService @@ -274,15 +255,15 @@ class CosService
274 */ 255 */
275 public function getPosition(){ 256 public function getPosition(){
276 return [ 257 return [
277 - 1=>'gravity/northWest',  
278 - 2=>'gravity/north',  
279 - 3=>'gravity/northEast',  
280 - 4=>'gravity/west',  
281 - 5=>'gravity/center',  
282 - 6=>'gravity/east',  
283 - 7=>'gravity/southWest',  
284 - 8=>'gravity/south',  
285 - 9=>'gravity/southEast', 258 + 1=>'northWest',
  259 + 2=>'north',
  260 + 3=>'northEast',
  261 + 4=>'west',
  262 + 5=>'center',
  263 + 6=>'east',
  264 + 7=>'southWest',
  265 + 8=>'south',
  266 + 9=>'southEast',
286 ]; 267 ];
287 } 268 }
288 269
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: zhl
  5 + * Date: 2024/8/20
  6 + * Time: 11:01
  7 + */
  8 +namespace App\Services;
  9 +
  10 +class UpyunService
  11 +{
  12 + /**
  13 + * 刷新进度查询
  14 + * @param $task_id
  15 + * @return mixed
  16 + */
  17 + public function purgePull($task_id)
  18 + {
  19 + $action = '/purge';
  20 + if (FALSE == is_array($task_id))
  21 + $task_id = [$task_id];
  22 + $task_ids = implode(',', $task_id);
  23 + $param = [
  24 + 'task_ids' => $task_ids, // 需要查询进度的 task_id
  25 + ];
  26 + list($status, $result) = $this->curlRequest($action, $param, 'GET', $this->getHeader());
  27 + return $result;
  28 + }
  29 +
  30 + /**
  31 + * URL 刷新
  32 + * @param $url
  33 + * @return mixed
  34 + */
  35 + public function purgePush($url)
  36 + {
  37 + $action = '/purge';
  38 + if (FALSE == is_array($url))
  39 + $url = [$url];
  40 + $urls = implode(PHP_EOL, $url);
  41 + $param = [
  42 + 'bucket' => '',
  43 + 'urls' => $urls, // 需要批量刷新的文件 URL,多个 URL 通过换行符分隔
  44 + ];
  45 + list($status, $result) = $this->curlRequest($action, $param, 'POST', $this->getHeader());
  46 + return $result;
  47 + }
  48 +
  49 + /**
  50 + * URL 预热
  51 + * @param $url
  52 + * @return mixed
  53 + */
  54 + public function preheatPush($url)
  55 + {
  56 + $action = '/preheat';
  57 + if (FALSE == is_array($url))
  58 + $url = [$url];
  59 + $urls = implode(PHP_EOL, $url);
  60 + $param = [
  61 + 'bucket' => '',
  62 + 'urls' => $urls, // 需要批量刷新的文件 URL,多个 URL 通过换行符分隔
  63 + 'range_bytes' => ''
  64 + ];
  65 + list($status, $result) = $this->curlRequest($action, $param, 'POST', $this->getHeader());
  66 + return $result;
  67 + }
  68 +
  69 + /**
  70 + * 头信息需要携带授权token
  71 + * @return array
  72 + */
  73 + public function getHeader()
  74 + {
  75 + return [
  76 + 'Authorization: Bearer ' . config('custom.upyun.token'),
  77 + ];
  78 + }
  79 +
  80 + /**
  81 + * @param $url
  82 + * @param $data
  83 + * @param string $method
  84 + * @param array $header
  85 + * @param int $time_out
  86 + * @return array
  87 + */
  88 + public function curlRequest($url, $data, $method = 'POST', $header = [], $time_out = 60)
  89 + {
  90 + $url = config('custom.upyun.api_url') . $url;
  91 + $ch = curl_init();
  92 + curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);
  93 + curl_setopt($ch, CURLOPT_URL, $url);
  94 + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  95 + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  96 + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  97 + if ($data)
  98 + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  99 + curl_setopt($ch, CURLOPT_HTTPHEADER, array_merge([
  100 + 'Expect:',
  101 + 'Content-type: application/json',
  102 + 'Accept: application/json',
  103 + ], $header)
  104 + );
  105 + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
  106 + $response = curl_exec($ch);
  107 + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  108 + curl_close($ch);
  109 + return [$code, $response];
  110 + }
  111 +
  112 + /**
  113 + * 创建token
  114 + * 该功能请不要重复使用
  115 + * 注意:出于安全考虑,token 只有在调用该接口创建时返回一次,后续无法再通过其他接口查询token值,调用该接口后,请务必记录token值
  116 + * {"access_token":"fe64817b-1f32-46f3-9ac3-a2993725708a","name":"v6-66c4333f60644","scope":"global","services":[],"created_at":1724134209,"expired_at":9999999999}
  117 + * @return mixed
  118 + */
  119 + public function createToken()
  120 + {
  121 + $action = '/oauth/tokens';
  122 + $param = [
  123 + 'username' => '', // 用户名
  124 + 'password' => '', // 密码
  125 + 'code' => md5(uniqid()), // 20-32位随机字符串,每次请求不能重复。只能包含数字、字母和中划线
  126 + 'name' => 'v6-' . uniqid(), // token 备注名,长度 20 的字符串,不能和其他 token 重复
  127 + 'scope' => 'global', // 权限 Valid Values:'global''bucket''operator''domain''cache''log''stats''oauth''security''srs'
  128 +// 'expired_at' => '', // integer token 过期时间的秒级时间戳,当该参数不设置时,表示永不过期
  129 + ];
  130 + list($status, $result) = $this->curlRequest($action, $param);
  131 + return $result;
  132 + }
  133 +}
@@ -24,5 +24,10 @@ return [ @@ -24,5 +24,10 @@ return [
24 ["69.172.229.12","69.172.229.13","69.172.229.14","69.172.229.15","69.172.229.16","69.172.229.36","69.172.229.59","69.172.229.60","69.172.229.61","69.172.229.62","69.172.229.63","69.172.229.64","69.172.229.65"], 24 ["69.172.229.12","69.172.229.13","69.172.229.14","69.172.229.15","69.172.229.16","69.172.229.36","69.172.229.59","69.172.229.60","69.172.229.61","69.172.229.62","69.172.229.63","69.172.229.64","69.172.229.65"],
25 ["69.172.233.75","69.172.233.76","69.172.233.77","69.172.233.78","69.172.233.79","69.172.233.80","69.172.233.81","69.172.233.82","69.172.233.83","69.172.233.84","69.172.233.85","69.172.233.86","69.172.233.87"], 25 ["69.172.233.75","69.172.233.76","69.172.233.77","69.172.233.78","69.172.233.79","69.172.233.80","69.172.233.81","69.172.233.82","69.172.233.83","69.172.233.84","69.172.233.85","69.172.233.86","69.172.233.87"],
26 ["76.74.220.18","76.74.220.19","76.74.220.20","76.74.220.21","76.74.220.22","76.74.220.23","76.74.220.24","76.74.220.25","76.74.220.26","76.74.220.27","76.74.220.28","76.74.220.29","76.74.220.30"], 26 ["76.74.220.18","76.74.220.19","76.74.220.20","76.74.220.21","76.74.220.22","76.74.220.23","76.74.220.24","76.74.220.25","76.74.220.26","76.74.220.27","76.74.220.28","76.74.220.29","76.74.220.30"],
27 - ["64.34.205.152","64.34.205.170","64.34.205.171","64.34.205.172","64.34.205.173","64.34.205.174","64.34.205.210","64.34.205.211","64.34.205.212","64.34.205.213","64.34.205.214","64.34.205.215","64.34.205.216"]] 27 + ["64.34.205.152","64.34.205.170","64.34.205.171","64.34.205.172","64.34.205.173","64.34.205.174","64.34.205.210","64.34.205.211","64.34.205.212","64.34.205.213","64.34.205.214","64.34.205.215","64.34.205.216"]],
  28 +
  29 + 'upyun' => [
  30 + 'api_url' => 'https://api.upyun.com',
  31 + 'token' => 'fe64817b-1f32-46f3-9ac3-a2993725708a',
  32 + ],
28 ]; 33 ];
@@ -253,6 +253,8 @@ Route::middleware(['aloginauth'])->group(function () { @@ -253,6 +253,8 @@ Route::middleware(['aloginauth'])->group(function () {
253 //图片操作 253 //图片操作
254 Route::prefix('images')->group(function () { 254 Route::prefix('images')->group(function () {
255 Route::post('/upload', [\App\Http\Controllers\File\ImageController::class, 'upload'])->name('images_upload'); 255 Route::post('/upload', [\App\Http\Controllers\File\ImageController::class, 'upload'])->name('images_upload');
  256 + Route::post('/getFont', [\App\Http\Controllers\File\ImageController::class, 'getFont'])->name('images_getFont');
  257 + Route::post('/getPosition', [\App\Http\Controllers\File\ImageController::class, 'getPosition'])->name('images_getPosition');
256 Route::post('/getDownloadUrl', [\App\Http\Controllers\File\ImageController::class, 'getDownloadUrl'])->name('images_getDownloadUrl'); 258 Route::post('/getDownloadUrl', [\App\Http\Controllers\File\ImageController::class, 'getDownloadUrl'])->name('images_getDownloadUrl');
257 }); 259 });
258 //文件操作 260 //文件操作
@@ -463,6 +465,14 @@ Route::middleware(['aloginauth'])->group(function () { @@ -463,6 +465,14 @@ Route::middleware(['aloginauth'])->group(function () {
463 Route::any('/saveModule', [Aside\ExtentModule\ExtensionModuleController::class, 'saveModule'])->name('admin.extension_module_saveModule'); 465 Route::any('/saveModule', [Aside\ExtentModule\ExtensionModuleController::class, 'saveModule'])->name('admin.extension_module_saveModule');
464 Route::any('/delModule', [Aside\ExtentModule\ExtensionModuleController::class, 'delModule'])->name('admin.extension_module_delModule'); 466 Route::any('/delModule', [Aside\ExtentModule\ExtensionModuleController::class, 'delModule'])->name('admin.extension_module_delModule');
465 }); 467 });
  468 + /**
  469 + * C端代码自动拉取模块
  470 + */
  471 + Route::prefix('auto_pull')->group(function () {
  472 + Route::any('/', [Aside\AutoPull\AutoPullController::class, 'getTaskLists'])->name('admin.auto_pull_getTaskLists');
  473 + Route::any('/saveTask', [Aside\AutoPull\AutoPullController::class, 'saveTask'])->name('admin.auto_pull_saveTask');
  474 + Route::any('/taskMap', [Aside\AutoPull\AutoPullController::class, 'taskMap'])->name('admin.auto_pull_taskMap');
  475 + });
466 }); 476 });
467 477
468 //无需登录验证的路由组 478 //无需登录验证的路由组
@@ -257,6 +257,8 @@ Route::middleware(['bloginauth'])->group(function () { @@ -257,6 +257,8 @@ Route::middleware(['bloginauth'])->group(function () {
257 Route::any('/sendAiProduct', [\App\Http\Controllers\Bside\Product\ProductController::class, 'sendAiProduct'])->name('product_sendAiProduct'); 257 Route::any('/sendAiProduct', [\App\Http\Controllers\Bside\Product\ProductController::class, 'sendAiProduct'])->name('product_sendAiProduct');
258 Route::any('/getSearchCategoryList', [\App\Http\Controllers\Bside\Product\ProductController::class, 'getSearchCategoryList'])->name('product_getSearchCategoryList'); 258 Route::any('/getSearchCategoryList', [\App\Http\Controllers\Bside\Product\ProductController::class, 'getSearchCategoryList'])->name('product_getSearchCategoryList');
259 Route::any('/delProductKeyword', [\App\Http\Controllers\Bside\Product\ProductController::class, 'delProductKeyword'])->name('product_delProductKeyword'); 259 Route::any('/delProductKeyword', [\App\Http\Controllers\Bside\Product\ProductController::class, 'delProductKeyword'])->name('product_delProductKeyword');
  260 + Route::any('/getProductType', [\App\Http\Controllers\Bside\Product\ProductController::class, 'getProductType'])->name('product_getProductType');
  261 + Route::any('/saveType', [\App\Http\Controllers\Bside\Product\ProductController::class, 'saveType'])->name('product_saveType');
260 //产品分类 262 //产品分类
261 Route::get('category', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'index'])->name('product_category'); 263 Route::get('category', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'index'])->name('product_category');
262 Route::get('category/info', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'info'])->name('product_category_info'); 264 Route::get('category/info', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'info'])->name('product_category_info');
@@ -316,7 +318,14 @@ Route::middleware(['bloginauth'])->group(function () { @@ -316,7 +318,14 @@ Route::middleware(['bloginauth'])->group(function () {
316 //图片操作 318 //图片操作
317 Route::prefix('images')->group(function () { 319 Route::prefix('images')->group(function () {
318 Route::post('/upload', [\App\Http\Controllers\File\ImageController::class, 'upload'])->name('image_upload'); 320 Route::post('/upload', [\App\Http\Controllers\File\ImageController::class, 'upload'])->name('image_upload');
  321 + Route::post('/getFont', [\App\Http\Controllers\File\ImageController::class, 'getFont'])->name('images_getFont');
  322 + Route::post('/getPosition', [\App\Http\Controllers\File\ImageController::class, 'getPosition'])->name('images_getPosition');
  323 + Route::post('/setWatermark', [\App\Http\Controllers\File\ImageController::class, 'setWatermark'])->name('images_setWatermark');
  324 + Route::post('/coverOriginalImage', [\App\Http\Controllers\File\ImageController::class, 'coverOriginalImage'])->name('images_coverOriginalImage');
319 Route::any('/getImageList', [\App\Http\Controllers\File\ImageController::class, 'getImageList'])->name('image_getImageList'); 325 Route::any('/getImageList', [\App\Http\Controllers\File\ImageController::class, 'getImageList'])->name('image_getImageList');
  326 + Route::any('/saveInputParam', [\App\Http\Controllers\File\ImageController::class, 'saveInputParam'])->name('image_saveInputParam');
  327 + Route::any('/editStatus', [\App\Http\Controllers\File\ImageController::class, 'editStatus'])->name('image_editStatus');
  328 + Route::any('/getImageSetting', [\App\Http\Controllers\File\ImageController::class, 'getImageSetting'])->name('image_getImageSetting');
320 }); 329 });
321 //文件操作 330 //文件操作
322 Route::prefix('files')->group(function () { 331 Route::prefix('files')->group(function () {
@@ -578,6 +587,10 @@ Route::middleware(['bloginauth'])->group(function () { @@ -578,6 +587,10 @@ Route::middleware(['bloginauth'])->group(function () {
578 Route::any('/addModuleValue', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'addModuleValue'])->name('extension_module_addModuleValue'); 587 Route::any('/addModuleValue', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'addModuleValue'])->name('extension_module_addModuleValue');
579 Route::any('/editModuleValue', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'editModuleValue'])->name('extension_module_editModuleValue'); 588 Route::any('/editModuleValue', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'editModuleValue'])->name('extension_module_editModuleValue');
580 Route::any('/sendUniqueStr', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'sendUniqueStr'])->name('extension_module_sendUniqueStr'); 589 Route::any('/sendUniqueStr', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'sendUniqueStr'])->name('extension_module_sendUniqueStr');
  590 + Route::any('/getFieldType', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'getFieldType'])->name('extension_module_getFieldType');
  591 + Route::any('/setSort', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'setSort'])->name('extension_module_setSort');
  592 + Route::any('/setSearchParam', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'setSearchParam'])->name('extension_module_setSearchParam');
  593 + Route::any('/delExtensionValue', [\App\Http\Controllers\Bside\ExtensionModule\ExtensionModuleController::class, 'delExtensionValue'])->name('extension_module_delExtensionValue');
581 }); 594 });
582 595
583 //自定义小语种文本信息 596 //自定义小语种文本信息