作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

@@ -2,21 +2,10 @@ @@ -2,21 +2,10 @@
2 2
3 namespace App\Console\Commands; 3 namespace App\Console\Commands;
4 4
5 -use App\Helper\Arr;  
6 -use App\Helper\Common;  
7 -use App\Helper\Gpt;  
8 -use App\Helper\Translate;  
9 -use App\Http\Logic\Aside\Project\ProjectLogic;  
10 -use App\Models\Ai\AiCommand;  
11 -use App\Models\Mail\Mail;  
12 -use App\Models\Project\DeployOptimize;  
13 -use App\Models\Project\ProjectUpdateTdk;  
14 -use App\Models\User\User; 5 +
15 use App\Services\ProjectServer; 6 use App\Services\ProjectServer;
16 use Illuminate\Console\Command; 7 use Illuminate\Console\Command;
17 -use Illuminate\Support\Facades\Cache;  
18 use Illuminate\Support\Facades\DB; 8 use Illuminate\Support\Facades\DB;
19 -use Illuminate\Support\Facades\Redis;  
20 9
21 /** 10 /**
22 * 清除项目sdk 11 * 清除项目sdk
@@ -33,7 +33,7 @@ class UpgradeProjectCount extends Command @@ -33,7 +33,7 @@ class UpgradeProjectCount extends Command
33 protected $description = '升级项目统计'; 33 protected $description = '升级项目统计';
34 34
35 public function handle(){ 35 public function handle(){
36 - $project_id = 528; 36 + $project_id = 769;
37 ProjectServer::useProject($project_id); 37 ProjectServer::useProject($project_id);
38 $this->count($project_id); 38 $this->count($project_id);
39 DB::disconnect('custom_mysql'); 39 DB::disconnect('custom_mysql');
@@ -36,7 +36,7 @@ class UpgradeProjectCount extends Command @@ -36,7 +36,7 @@ class UpgradeProjectCount extends Command
36 protected $description = '升级项目统计'; 36 protected $description = '升级项目统计';
37 37
38 public function handle(){ 38 public function handle(){
39 - $project_id = 528; 39 + $project_id = 769;
40 $oldModel = new UpdateOldInfo(); 40 $oldModel = new UpdateOldInfo();
41 $info = $oldModel->read(['project_id'=>$project_id]); 41 $info = $oldModel->read(['project_id'=>$project_id]);
42 $url = $info['old_domain_online']; 42 $url = $info['old_domain_online'];
@@ -30,7 +30,7 @@ class SyncMobile extends Command @@ -30,7 +30,7 @@ class SyncMobile extends Command
30 protected $description = '同步手机号码库'; 30 protected $description = '同步手机号码库';
31 31
32 /** 32 /**
33 - * @remark :统一更新路由 33 + * @remark :统一更新
34 * @name :handle 34 * @name :handle
35 * @author :lyh 35 * @author :lyh
36 * @method :post 36 * @method :post
@@ -2,21 +2,10 @@ @@ -2,21 +2,10 @@
2 2
3 namespace App\Console\Commands; 3 namespace App\Console\Commands;
4 4
5 -use App\Helper\Arr;  
6 -use App\Helper\Common;  
7 -use App\Helper\Gpt;  
8 -use App\Helper\Translate;  
9 -use App\Models\Ai\AiCommand;  
10 -use App\Models\Mail\Mail;  
11 -use App\Models\Project\DeployOptimize;  
12 use App\Models\Project\Project; 5 use App\Models\Project\Project;
13 -use App\Models\Project\ProjectUpdateTdk;  
14 -use App\Models\User\User;  
15 use App\Services\ProjectServer; 6 use App\Services\ProjectServer;
16 use Illuminate\Console\Command; 7 use Illuminate\Console\Command;
17 -use Illuminate\Support\Facades\Cache;  
18 use Illuminate\Support\Facades\DB; 8 use Illuminate\Support\Facades\DB;
19 -use Illuminate\Support\Facades\Redis;  
20 9
21 /** 10 /**
22 * 初始化项目 11 * 初始化项目
@@ -2,21 +2,9 @@ @@ -2,21 +2,9 @@
2 2
3 namespace App\Console\Commands; 3 namespace App\Console\Commands;
4 4
5 -use App\Helper\Arr;  
6 -use App\Helper\Common;  
7 -use App\Helper\Gpt;  
8 -use App\Helper\Translate;  
9 -use App\Models\Ai\AiCommand;  
10 -use App\Models\Mail\Mail;  
11 -use App\Models\Project\DeployOptimize;  
12 use App\Models\Project\Project; 5 use App\Models\Project\Project;
13 use App\Models\Project\ProjectUpdateTdk; 6 use App\Models\Project\ProjectUpdateTdk;
14 -use App\Models\User\User;  
15 -use App\Services\ProjectServer;  
16 use Illuminate\Console\Command; 7 use Illuminate\Console\Command;
17 -use Illuminate\Support\Facades\Cache;  
18 -use Illuminate\Support\Facades\DB;  
19 -use Illuminate\Support\Facades\Redis;  
20 8
21 /** 9 /**
22 * 初始化项目 10 * 初始化项目
  1 +<?php
  2 +
  3 +namespace App\Http\Controllers\Api;
  4 +
  5 +use App\Exceptions\InquiryFilterException;
  6 +use App\Models\SyncSubmitTask\SyncSubmitTask;
  7 +use App\Services\CosService;
  8 +use Illuminate\Http\Request;
  9 +
  10 +/**
  11 + * Class InquiryController
  12 + * @package App\Http\Controllers\Api
  13 + * @author zbj
  14 + * @date 2024/2/2
  15 + */
  16 +class InquiryController extends BaseController
  17 +{
  18 + /**
  19 + * 提交询盘
  20 + * C端部署自己服务器的
  21 + * @param Request $request
  22 + * @return false|string
  23 + * @author zbj
  24 + * @date 2024/2/2
  25 + */
  26 + public function submit(Request $request){
  27 + $data = $request->post();
  28 + @file_put_contents(storage_path('logs/form_submit_' . date('Y-m-d') . '.log'), var_export(date('Y-m-d H:i:s') . "-询盘表单提交数据:" . json_encode($data), true) . PHP_EOL, FILE_APPEND);
  29 +
  30 + try {
  31 + $files = $request->allFiles()['data'] ?? [];
  32 + foreach ($files as $key => $file) {
  33 + $cos = new CosService();
  34 + $fileinfo = $cos->checkInquiryFile($file);
  35 + $fileName = uniqid().rand(10000,99999).'.'.$file->getClientOriginalExtension();
  36 + $path = $cos->uploadFile($file, '/inquiry/'. date('Ymd'), $fileName);
  37 + $data['data'][$key] = [
  38 + 'path' => $path,
  39 + 'original_name' => $fileinfo['name'],
  40 + ];
  41 + }
  42 + }catch (InquiryFilterException $e){
  43 + return $this->error($e->getMessage());
  44 + }catch (\Exception $e){
  45 + return $this->error('File upload fail');
  46 + }
  47 +
  48 + //异步处理
  49 + if(!SyncSubmitTask::addTask(SyncSubmitTask::TYPE_INQUIRY, $data)){
  50 + return $this->error();
  51 + }
  52 + return $this->success();
  53 + }
  54 +}
@@ -32,14 +32,15 @@ class ProductController extends BaseController @@ -32,14 +32,15 @@ class ProductController extends BaseController
32 } 32 }
33 33
34 try { 34 try {
35 - $gallery = Product::where('status', Product::STATUS_ON)->whereNotNull('gallery')->inRandomOrder()->value('gallery');  
36 - $gallery = array_map(function ($item) use ($project) {  
37 - return getImageUrl($item, $project['storage_type'], $project['project_location']);  
38 - }, Arr::pluck($gallery, 'url')); 35 + $info = Product::where('status', Product::STATUS_ON)->whereNotNull('gallery')->inRandomOrder()->select(['title', 'seo_mate', 'gallery'])->first();
  36 + $info['gallery'] = array_map(function ($item) use ($project) {
  37 + $item['url'] = getImageUrl($item['url'], $project['storage_type'], $project['project_location']);
  38 + return $item;
  39 + }, $info['gallery']);
39 } catch (\Exception $e) { 40 } catch (\Exception $e) {
40 LogUtils::error('Project Id: ' . $project_id . ' getProductImages error:' . $e->getMessage()); 41 LogUtils::error('Project Id: ' . $project_id . ' getProductImages error:' . $e->getMessage());
41 - $gallery = []; 42 + $info = [];
42 } 43 }
43 - $this->response('success', Code::SUCCESS, $gallery); 44 + $this->response('success', Code::SUCCESS, $info);
44 } 45 }
45 } 46 }
@@ -64,7 +64,7 @@ class NavController extends BaseController @@ -64,7 +64,7 @@ class NavController extends BaseController
64 $param['image'] = getImageUrl($param['image'],$this->user['storage_type'],$this->user['project_location']); 64 $param['image'] = getImageUrl($param['image'],$this->user['storage_type'],$this->user['project_location']);
65 } 65 }
66 if(isset($param['remark_image']) && !empty($param['remark_image'])){ 66 if(isset($param['remark_image']) && !empty($param['remark_image'])){
67 - $param['remark_image'] = getImageUrl($param['image'],$this->user['storage_type'],$this->user['project_location']); 67 + $param['remark_image'] = getImageUrl($param['remark_image'],$this->user['storage_type'],$this->user['project_location']);
68 } 68 }
69 return $this->success($param); 69 return $this->success($param);
70 } 70 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :UpdateHtml.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/2/2 10:11
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Html;
  11 +
  12 +use App\Http\Controllers\Controller;
  13 +use App\Models\Com\NoticeLog;
  14 +use App\Models\Project\Project;
  15 +use App\Models\RouteMap\RouteMap;
  16 +use App\Models\Service\Service as ServiceSettingModel;
  17 +use App\Models\Template\BTemplate;
  18 +use App\Services\ProjectServer;
  19 +use Illuminate\Support\Facades\DB;
  20 +
  21 +class UpdateHtml extends Controller
  22 +{
  23 + protected $param;
  24 + protected $project_id;
  25 + public function __construct($data){
  26 + $this->param = $data;//Todo::传递的参数
  27 + $this->project_id = $data['project_id'];
  28 + }
  29 +
  30 + /**
  31 + * @remark :更新界面
  32 + * @name :updateHtml
  33 + * @author :lyh
  34 + * @method :post
  35 + * @time :2024/2/2 10:12
  36 + */
  37 + public function updateHtml(){
  38 + ProjectServer::useProject($this->project_id);
  39 + if(isset($this->param['route']) && $this->param['route'] == 'all'){
  40 + //TODO::更新所有界面
  41 + }else{
  42 + //TODO::更新单页
  43 + $routeMapModel = new RouteMap();
  44 + }
  45 + DB::disconnect('custom_mysql');
  46 + }
  47 +
  48 + /**
  49 + * @remark :获取页面是否为 定制/非定制 页面
  50 + * @name :getPageHtmlIsCustomized
  51 + * @param :source:类型;is_list:是否为列表页 1:列表页面
  52 + * @author :lyh
  53 + * @method :post
  54 + * @time :2024/2/2 11:03
  55 + */
  56 + public function getPageHtmlIsCustomized($source,$is_list){
  57 + $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
  58 + //查看当前页面是否定制,是否开启可视化
  59 + $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
  60 + if (in_array($type, $page_array)) {//是定制界面
  61 + return BTemplate::IS_VISUALIZATION;
  62 + }
  63 + return BTemplate::IS_NO_VISUALIZATION;
  64 + }
  65 +
  66 + /**
  67 + * @remark :获取头部底部公共部分代码
  68 + * @name :getTemplateCommon
  69 + * @author :lyh
  70 + * @method :post
  71 + * @time :2024/2/2 11:02
  72 + */
  73 + public function getTemplateCommon(){
  74 +
  75 + }
  76 +
  77 + /**
  78 + * @remark :获取装修中间内容
  79 + * @name :getTemplateMainHtml
  80 + * @author :lyh
  81 + * @method :post
  82 + * @time :2024/2/2 11:01
  83 + */
  84 + public function getTemplateMainHtml(){
  85 +
  86 + }
  87 +
  88 + /**
  89 + * @remark :获取项目详情
  90 + * @name :getProjectInfo
  91 + * @author :lyh
  92 + * @method :post
  93 + * @time :2024/2/2 10:50
  94 + */
  95 + public function getProjectInfo($project_id){
  96 + $projectModel = new Project();
  97 + $info = $projectModel->read(['id'=>$project_id],['id','is_customized']);
  98 + return $info;
  99 + }
  100 +
  101 + /**
  102 + * @remark :拼接获取公共头部底部
  103 + * @name :getHeadFooter
  104 + * @author :lyh
  105 + * @method :post
  106 + * @time :2023/7/21 17:22
  107 + */
  108 + public function getHeadFooter($html){
  109 + //获取公共主题头部底部
  110 + $serviceSettingModel = new ServiceSettingModel();
  111 + $list = $serviceSettingModel->list(['type'=>2],'created_at');
  112 + //拼接html
  113 + foreach ($list as $v){
  114 + if($v['key'] == 'head'){
  115 + $html = $v['values'].$html;
  116 + }
  117 + if($v['key'] == 'footer'){
  118 + $html = $html.$v['values'];
  119 + }
  120 + }
  121 + return $html;
  122 + }
  123 +}
@@ -55,9 +55,9 @@ class LoginLogic extends BaseLogic @@ -55,9 +55,9 @@ class LoginLogic extends BaseLogic
55 $this->verifyCode($this->param['mobile'],$this->param['password']); 55 $this->verifyCode($this->param['mobile'],$this->param['password']);
56 $type = 2;//验证码登录 56 $type = 2;//验证码登录
57 } 57 }
58 - if(!empty($manage['token'])){  
59 - Cache::pull(Common::MANAGE_TOKEN . $manage['token']);  
60 - } 58 +// if(!empty($manage['token'])){
  59 +// Cache::pull(Common::MANAGE_TOKEN . $manage['token']);
  60 +// }
61 //生成新token 61 //生成新token
62 $token = md5(uniqid().$manage['id']); 62 $token = md5(uniqid().$manage['id']);
63 unset($manage['password']); 63 unset($manage['password']);
@@ -142,7 +142,11 @@ class BTemplateLogic extends BaseLogic @@ -142,7 +142,11 @@ class BTemplateLogic extends BaseLogic
142 $this->fail('当前扩展模块不存在或已被删除'); 142 $this->fail('当前扩展模块不存在或已被删除');
143 } 143 }
144 //扩展模块定制 144 //扩展模块定制
145 - if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION){ 145 + if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){
  146 + $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
  147 + return $this->success(['html'=>$html,'template_id'=>$template_id]);
  148 + }
  149 + if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){
146 $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom); 150 $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
147 return $this->success(['html'=>$html,'template_id'=>$template_id]); 151 return $this->success(['html'=>$html,'template_id'=>$template_id]);
148 } 152 }
@@ -327,7 +331,10 @@ class BTemplateLogic extends BaseLogic @@ -327,7 +331,10 @@ class BTemplateLogic extends BaseLogic
327 if($info === false){ 331 if($info === false){
328 $this->fail('当前扩展模块不存在或已被删除'); 332 $this->fail('当前扩展模块不存在或已被删除');
329 } 333 }
330 - if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION){ 334 + if($info['list_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_LIST){
  335 + return $this->success($template_id);
  336 + }
  337 + if($info['detail_customized'] == BTemplate::IS_VISUALIZATION && $is_list == BTemplate::IS_DETAIL){
331 return $this->success($template_id); 338 return $this->success($template_id);
332 } 339 }
333 }else{ 340 }else{
@@ -28,4 +28,42 @@ class SyncSubmitTask extends Model @@ -28,4 +28,42 @@ class SyncSubmitTask extends Model
28 protected $casts = [ 28 protected $casts = [
29 'data' => 'array', 29 'data' => 'array',
30 ]; 30 ];
  31 +
  32 + /**
  33 + * @param $type
  34 + * @param $data
  35 + * @return bool
  36 + * @author zbj
  37 + * @date 2023/11/28
  38 + */
  39 + public static function addTask($type, $data): bool
  40 + {
  41 + if (empty($data)) {
  42 + return false;
  43 + }
  44 + try {
  45 + $data = [
  46 + 'data' => $data['data'],
  47 + 'domain' => !empty($data['domain']) ? $data['domain'] : request()->getHost(),
  48 + 'ip' => !empty($data['ip']) ? $data['ip'] : request()->getClientIp(),
  49 + 'referer' => !empty($data['referer']) ? $data['referer'] : request()->header('Referer'),
  50 + 'user_agent' => !empty($data['user_agent']) ? $data['user_agent'] : request()->header('user_agent'),
  51 + ];
  52 +
  53 + if(empty($data['referer']) || empty($data['user_agent']) || empty($data['data'])){
  54 + return false;
  55 + }
  56 +
  57 + $model = new self();
  58 + $model->type = $type;
  59 + $model->data = $data;
  60 + !empty($data['submit_time']) && $model->created_at = $data['submit_time'];
  61 + $model->save();
  62 +
  63 + } catch (\Exception $e) {
  64 + Log::error('SyncSubmitTask addTask error', ['msg' => $e->getMessage(), 'data' => $data]);
  65 + return false;
  66 + }
  67 + return true;
  68 + }
31 } 69 }
@@ -51,6 +51,8 @@ class BTemplate extends Base @@ -51,6 +51,8 @@ class BTemplate extends Base
51 const IS_CUSTOM = 1;//为扩展模块 51 const IS_CUSTOM = 1;//为扩展模块
52 const IS_NO_CUSTOM = 0;//为默认模块 52 const IS_NO_CUSTOM = 0;//为默认模块
53 const IS_VISUALIZATION = 1;//定制项目 53 const IS_VISUALIZATION = 1;//定制项目
  54 +
  55 + const IS_NO_VISUALIZATION = 1;//定制项目
54 const STATUS = 0; 56 const STATUS = 0;
55 57
56 /** 58 /**
@@ -2,14 +2,11 @@ @@ -2,14 +2,11 @@
2 2
3 namespace App\Models\User; 3 namespace App\Models\User;
4 4
5 -//use Illuminate\Contracts\Auth\MustVerifyEmail;  
6 use App\Models\Base; 5 use App\Models\Base;
7 6
8 -//use Illuminate\Foundation\Auth\User as Authenticatable;  
9 7
10 class User extends Base 8 class User extends Base
11 { 9 {
12 -// use HasApiTokens, HasFactory, Notifiable;  
13 const ROLE_MANAGER = 0;//超级管理员 10 const ROLE_MANAGER = 0;//超级管理员
14 const TYPE_ONE = 1; 11 const TYPE_ONE = 1;
15 12
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace App\Services; 3 namespace App\Services;
4 4
  5 +use App\Exceptions\InquiryFilterException;
5 use App\Utils\LogUtils; 6 use App\Utils\LogUtils;
6 use Qcloud\Cos\Client; 7 use Qcloud\Cos\Client;
7 /** 8 /**
@@ -116,4 +117,28 @@ class CosService @@ -116,4 +117,28 @@ class CosService
116 } 117 }
117 } 118 }
118 119
  120 + /**
  121 + * @param $file
  122 + * @return array
  123 + * @throws \Exception
  124 + * @author zbj
  125 + * @date 2023/12/12
  126 + */
  127 + public function checkInquiryFile($file){
  128 + $size = $file->getSize();
  129 + if($size/1024/1024 > 20){
  130 + throw new InquiryFilterException('Your file size exceeds the limit. Please upload a file no larger than 20MB.');
  131 + }
  132 + $extension = $file->getClientOriginalExtension();
  133 +// JPEG (JPG) PDF DWG STEP(STP)IGS word xlsx
  134 + if(!in_array(strtolower($extension), ['png','jpg','jpeg', 'pdf', 'dwg', 'step', 'stp', 'igs','doc','docx','xls','xlsx'])){
  135 + throw new InquiryFilterException('Please upload file in png, jpg, jpeg, pdf, dwg, step, stp, igs, doc, docx, xls or xlsx format.');
  136 + }
  137 + return [
  138 + 'size' => $size,
  139 + 'extension' => $extension,
  140 + 'name' => $file->getClientOriginalName(),
  141 + 'mime' => $file->getMimeType(),
  142 + ];
  143 + }
119 } 144 }
@@ -22,4 +22,5 @@ Route::any('traffic_visit', [\App\Http\Controllers\Api\NoticeController::class, @@ -22,4 +22,5 @@ Route::any('traffic_visit', [\App\Http\Controllers\Api\NoticeController::class,
22 Route::get('optimize_project_list', [\App\Http\Controllers\Api\PrivateController::class, 'optimizeProjectList'])->name('api.optimize_project_list'); 22 Route::get('optimize_project_list', [\App\Http\Controllers\Api\PrivateController::class, 'optimizeProjectList'])->name('api.optimize_project_list');
23 Route::get('get_project_route', [\App\Http\Controllers\Api\PrivateController::class, 'getProjectRoute'])->name('api.get_project_route'); 23 Route::get('get_project_route', [\App\Http\Controllers\Api\PrivateController::class, 'getProjectRoute'])->name('api.get_project_route');
24 Route::any('get_product_images', [\App\Http\Controllers\Api\ProductController::class, 'getImages'])->name('api.get_product_images'); 24 Route::any('get_product_images', [\App\Http\Controllers\Api\ProductController::class, 'getImages'])->name('api.get_product_images');
  25 +Route::post('inquiry_submit', [\App\Http\Controllers\Api\InquiryController::class, 'submit'])->name('api.inquiry_submit');
25 26