作者 赵彬吉
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :EditPage.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/11/13 10:06
  8 + */
  9 +
  10 +namespace App\Console\Commands;
  11 +
  12 +use App\Models\Project\Project;
  13 +use App\Models\RouteMap\RouteMap;
  14 +use App\Models\Template\BCustomTemplate;
  15 +use App\Services\ProjectServer;
  16 +use Illuminate\Console\Command;
  17 +use Illuminate\Support\Facades\DB;
  18 +
  19 +class EditPage extends Command
  20 +{
  21 + /**
  22 + * The name and signature of the console command.
  23 + *
  24 + * @var string
  25 + */
  26 + protected $signature = 'edit_page';
  27 +
  28 + /**
  29 + * The console command description.
  30 + *
  31 + * @var string
  32 + */
  33 + protected $description = '修复单页面路由数据';
  34 +
  35 + /**
  36 + * Create a new command instance.
  37 + *
  38 + * @return void
  39 + */
  40 + public function __construct()
  41 + {
  42 + parent::__construct();
  43 + }
  44 +
  45 + /**
  46 + * @return bool
  47 + */
  48 + public function handle()
  49 + {
  50 + //获取所有项目
  51 + $projectModel = new Project();
  52 + $list = $projectModel->list(['type'=>['in',[1,2,3,4]]]);
  53 + try {
  54 + foreach ($list as $v){
  55 + echo date('Y-m-d H:i:s') . ' start: '. $v['id'] . PHP_EOL;
  56 + ProjectServer::useProject($v['id']);
  57 + BCustomTemplate::where('url', 'like', '%-tag%')
  58 + ->update(['url' => DB::raw("REPLACE(url, '-tag', '')")]);
  59 + RouteMap::where('route', 'like', '%-tag%')->where('source','page')
  60 + ->update(['route' => DB::raw("REPLACE(route, '-tag', '')")]);
  61 + DB::disconnect('custom_mysql');
  62 + }
  63 + }catch (\Exception $e){
  64 + echo date('Y-m-d H:i:s') . ' error: ->' . $e->getMessage() . PHP_EOL;
  65 + }
  66 + echo date('Y-m-d H:i:s') . ' end: down' . PHP_EOL;
  67 + return true;
  68 + }
  69 +}
@@ -225,13 +225,10 @@ class SyncProject extends Command @@ -225,13 +225,10 @@ class SyncProject extends Command
225 225
226 if($is_update == 1){ 226 if($is_update == 1){
227 //4.0或5.0更新到6.0 227 //4.0或5.0更新到6.0
228 -  
229 //初始化数据库 228 //初始化数据库
230 $this->initializationMysql($id); 229 $this->initializationMysql($id);
231 -  
232 //初始账号 230 //初始账号
233 $this->createUser($data['project']['mobile'],$id,$data['project']['lead_name']); 231 $this->createUser($data['project']['mobile'],$id,$data['project']['lead_name']);
234 -  
235 //新增数据抓取任务 232 //新增数据抓取任务
236 $task_list = []; 233 $task_list = [];
237 foreach ($param['api_type'] as $v_type){ 234 foreach ($param['api_type'] as $v_type){
@@ -245,7 +242,6 @@ class SyncProject extends Command @@ -245,7 +242,6 @@ class SyncProject extends Command
245 UpdateLog::createLog($id,$task,$param['get_data_url']); 242 UpdateLog::createLog($id,$task,$param['get_data_url']);
246 } 243 }
247 } 244 }
248 -  
249 DB::commit(); 245 DB::commit();
250 }catch (\Exception $e){ 246 }catch (\Exception $e){
251 DB::rollBack(); 247 DB::rollBack();
@@ -278,9 +274,11 @@ class SyncProject extends Command @@ -278,9 +274,11 @@ class SyncProject extends Command
278 * @time :2023/8/30 15:53 274 * @time :2023/8/30 15:53
279 */ 275 */
280 public function saveProject($param){ 276 public function saveProject($param){
281 -// if(isset($param['channel']) && !empty($param['channel'])){ 277 + if(isset($param['channel']) && !empty($param['channel'])){
282 $param['channel'] = Arr::a2s($param['channel']); 278 $param['channel'] = Arr::a2s($param['channel']);
283 -// } 279 + }else{
  280 + $param['channel'] = Arr::a2s(["user_id"=>"", "zone_id"=>"", "channel_id"=>""]);
  281 + }
284 $projectModel = new Project(); 282 $projectModel = new Project();
285 $info = $projectModel->read(['from_order_id'=>$param['from_order_id'],'delete_status'=>0]); 283 $info = $projectModel->read(['from_order_id'=>$param['from_order_id'],'delete_status'=>0]);
286 if($info !== false){ 284 if($info !== false){
@@ -319,12 +317,11 @@ class SyncProject extends Command @@ -319,12 +317,11 @@ class SyncProject extends Command
319 protected function savePayment($param,$id){ 317 protected function savePayment($param,$id){
320 $param['project_id'] = $id; 318 $param['project_id'] = $id;
321 $paymentModel= new Payment(); 319 $paymentModel= new Payment();
322 -// if(isset($param['contract']) && !empty($param['contract'])){  
323 - $param['contract'] = Arr::a2s($param['contract']);  
324 -// }  
325 -// if(isset($param['bill']) && !empty($param['bill'])){  
326 - $param['bill'] = Arr::a2s($param['bill']);  
327 -// } 320 + $param['contract'] = Arr::a2s($param['contract']);
  321 + $param['bill'] = Arr::a2s($param['bill']);
  322 + if(!isset($param['renewal_record'])){
  323 + $param['renewal_record'] = [["amount"=> null, "remark"=> null, "expire_at"=> null]];
  324 + }
328 $info = $paymentModel->read(['project_id'=>$id]); 325 $info = $paymentModel->read(['project_id'=>$id]);
329 if($info !== false){ 326 if($info !== false){
330 $paymentModel->edit($param,['id'=>$info['id']]); 327 $paymentModel->edit($param,['id'=>$info['id']]);
@@ -10,6 +10,7 @@ @@ -10,6 +10,7 @@
10 namespace App\Console\Commands; 10 namespace App\Console\Commands;
11 11
12 use App\Models\Mail\Mail; 12 use App\Models\Mail\Mail;
  13 +use App\Models\Project\Project;
13 use App\Models\User\User; 14 use App\Models\User\User;
14 use App\Services\ProjectServer; 15 use App\Services\ProjectServer;
15 use Illuminate\Console\Command; 16 use Illuminate\Console\Command;
@@ -40,16 +41,20 @@ class UpdateProgress extends Command @@ -40,16 +41,20 @@ class UpdateProgress extends Command
40 */ 41 */
41 public function handle() 42 public function handle()
42 { 43 {
43 - $project_id = Redis::rpop('updateProgress');  
44 - echo date('Y-m-d H:i:s') . ' start: ' . $project_id . PHP_EOL; 44 + //获取所有项目
  45 + $projectModel = new Project();
  46 + $list = $projectModel->list(['type'=>['in',[1,2,3,4]]]);
45 try { 47 try {
46 - ProjectServer::useProject($project_id);  
47 - $this->getUpdateProgress($project_id);  
48 - DB::disconnect('custom_mysql'); 48 + foreach ($list as $v) {
  49 + echo date('Y-m-d H:i:s') . ' start: ' . $v['id'] . PHP_EOL;
  50 + ProjectServer::useProject($v['id']);
  51 + $this->getUpdateProgress($v['id']);
  52 + DB::disconnect('custom_mysql');
  53 + }
49 }catch (\Exception $e){ 54 }catch (\Exception $e){
50 - echo date('Y-m-d H:i:s') . ' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL; 55 + echo date('Y-m-d H:i:s') . ' error: ->' . $e->getMessage() . PHP_EOL;
51 } 56 }
52 - echo date('Y-m-d H:i:s') . ' end: ' . $project_id . PHP_EOL; 57 + echo date('Y-m-d H:i:s') . ' end: ' . PHP_EOL;
53 } 58 }
54 59
55 /** 60 /**
@@ -62,6 +67,7 @@ class UpdateProgress extends Command @@ -62,6 +67,7 @@ class UpdateProgress extends Command
62 public function getUpdateProgress($project_id){ 67 public function getUpdateProgress($project_id){
63 $info = DB::connection('custom_mysql')->table('gl_update_progress')->whereRaw('total_num > current_num')->first(); 68 $info = DB::connection('custom_mysql')->table('gl_update_progress')->whereRaw('total_num > current_num')->first();
64 if(!empty($info)){ 69 if(!empty($info)){
  70 + //超时时间
65 $time = date("Y-m-d H:i:s",strtotime($info['created_at']) + $info['total_num'] * 60); 71 $time = date("Y-m-d H:i:s",strtotime($info['created_at']) + $info['total_num'] * 60);
66 if($time > date("Y-m-d H:i:s")){ 72 if($time > date("Y-m-d H:i:s")){
67 DB::connection('custom_mysql')->table('gl_update_progress')->where('id',$info['id'])->update(['current_num'=>$info['total_num']]); 73 DB::connection('custom_mysql')->table('gl_update_progress')->where('id',$info['id'])->update(['current_num'=>$info['total_num']]);
@@ -74,10 +80,9 @@ class UpdateProgress extends Command @@ -74,10 +80,9 @@ class UpdateProgress extends Command
74 $data["content"] = "部分页面更新超时,请重新更新,或联系管理员"; 80 $data["content"] = "部分页面更新超时,请重新更新,或联系管理员";
75 $mail = new Mail(); 81 $mail = new Mail();
76 $mail->add($data); 82 $mail->add($data);
77 - }else{  
78 - Redis::lpush('updateProgress', $project_id);  
79 } 83 }
80 } 84 }
  85 + echo date('Y-m-d H:i:s') . ' end: ' . $project_id . PHP_EOL;
81 return true; 86 return true;
82 } 87 }
83 } 88 }
@@ -196,13 +196,9 @@ class DomainInfoController extends BaseController @@ -196,13 +196,9 @@ class DomainInfoController extends BaseController
196 $this->request->validate([ 196 $this->request->validate([
197 'id'=>'required', 197 'id'=>'required',
198 'type' => 'required', 198 'type' => 'required',
199 - 'other_domain'=>'required',  
200 - 'extend_config'=>'required'  
201 ],[ 199 ],[
202 'id.required' => 'id不能为空', 200 'id.required' => 'id不能为空',
203 'type.required' => '类型不能为空', 201 'type.required' => '类型不能为空',
204 - 'other_domain.required' => '其他域名不能为空',  
205 - 'extend_config.required' => '301配置不能为空',  
206 ]); 202 ]);
207 $domainInfoLogic->sslSave(); 203 $domainInfoLogic->sslSave();
208 $this->response('success'); 204 $this->response('success');
@@ -90,6 +90,8 @@ class ProjectController extends BaseController @@ -90,6 +90,8 @@ class ProjectController extends BaseController
90 $query = $this->searchContent($query); 90 $query = $this->searchContent($query);
91 //搜索升级项目 91 //搜索升级项目
92 $query = $this->searchUpgrade($query); 92 $query = $this->searchUpgrade($query);
  93 + //搜索战队
  94 + $query = $this->searchChannel($query);
93 return $query; 95 return $query;
94 } 96 }
95 97
@@ -189,6 +191,23 @@ class ProjectController extends BaseController @@ -189,6 +191,23 @@ class ProjectController extends BaseController
189 } 191 }
190 192
191 /** 193 /**
  194 + * @remark :搜索战队
  195 + * @name :searchChannel
  196 + * @author :lyh
  197 + * @method :post
  198 + * @time :2023/11/9 10:16
  199 + */
  200 + public function searchChannel(&$query){
  201 + if(isset($this->map['zone_id']) && !empty($this->map['zone_id'])){
  202 + $query->where('gl_project.channel','like','%"zone_id": "'.$this->map['channel_id'].'"%');
  203 + }
  204 + if(isset($this->map['channel_id']) && !empty($this->map['channel_id'])){
  205 + $query->where('gl_project.channel','like','%"channel_id": "'.$this->map['channel_id'].'"%');
  206 + }
  207 + return $query;
  208 + }
  209 +
  210 + /**
192 * @remark :搜索技术组 211 * @remark :搜索技术组
193 * @name :searchDept 212 * @name :searchDept
194 * @author :lyh 213 * @author :lyh
@@ -141,7 +141,6 @@ class CNoticeController extends BaseController @@ -141,7 +141,6 @@ class CNoticeController extends BaseController
141 ]; 141 ];
142 $updateProgressModel = new UpdateProgress(); 142 $updateProgressModel = new UpdateProgress();
143 $updateProgressModel->insert($data); 143 $updateProgressModel->insert($data);
144 - Redis::lpush('updateProgress', $this->user['project_id']);  
145 return true; 144 return true;
146 } 145 }
147 146
@@ -56,9 +56,6 @@ class BaseController extends Controller @@ -56,9 +56,6 @@ class BaseController extends Controller
56 if(is_array($v)){ 56 if(is_array($v)){
57 $this->map[$k] = $v; 57 $this->map[$k] = $v;
58 }else{ 58 }else{
59 - if(empty($v) && ($v == null)){  
60 - unset($this->param[$k]);  
61 - }  
62 $this->getMap($k,$v); 59 $this->getMap($k,$v);
63 } 60 }
64 } 61 }
@@ -138,6 +138,11 @@ class LoginController extends BaseController @@ -138,6 +138,11 @@ class LoginController extends BaseController
138 * @time :2023/6/28 16:13 138 * @time :2023/6/28 16:13
139 */ 139 */
140 public function stringTranslation(){ 140 public function stringTranslation(){
  141 + $this->request->validate([
  142 + 'str'=>'required',
  143 + ],[
  144 + 'str.required' => '翻译字符串不能为空',
  145 + ]);
141 $str = Translate::tran($this->param['str'], 'en'); 146 $str = Translate::tran($this->param['str'], 'en');
142 $this->response('success',Code::SUCCESS,strtolower($str)); 147 $this->response('success',Code::SUCCESS,strtolower($str));
143 } 148 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ExtendController.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/11/9 14:22
  8 + */
  9 +
  10 +namespace App\Http\Controllers\Bside\Product;
  11 +
  12 +use App\Enums\Common\Code;
  13 +use App\Http\Controllers\Bside\BaseController;
  14 +use App\Http\Logic\Bside\Product\ExtendLogic;
  15 +use App\Models\Product\Extend;
  16 +
  17 +/**
  18 + * @remark :添加扩展字段
  19 + * @name :ExtendController
  20 + * @author :lyh
  21 + * @method :post
  22 + * @time :2023/11/9 14:22
  23 + */
  24 +class ExtendController extends BaseController
  25 +{
  26 + /**
  27 + * @remark :获取所有扩展字段
  28 + * @name :lists
  29 + * @author :lyh
  30 + * @method :post
  31 + * @time :2023/11/9 14:23
  32 + */
  33 + public function lists(Extend $extend){
  34 + $lists = $extend->list($this->map);
  35 + $this->response('success',Code::SUCCESS,$lists);
  36 + }
  37 +
  38 + /**
  39 + * @remark :保存数据
  40 + * @name :save
  41 + * @author :lyh
  42 + * @method :post
  43 + * @time :2023/11/9 14:26
  44 + */
  45 + public function save(ExtendLogic $extendLogic){
  46 + $this->request->validate([
  47 + 'title'=>'required',
  48 + 'type'=>'required',
  49 + ],[
  50 + 'title.required' => '字段名称不能为空',
  51 + 'type.required' => '字段类型不能为空',
  52 + ]);
  53 + $info = $extendLogic->extendSave();
  54 + $this->response('success',Code::SUCCESS,$info);
  55 + }
  56 +
  57 + /**
  58 + * @remark :删除扩展字段
  59 + * @name :del
  60 + * @author :lyh
  61 + * @method :post
  62 + * @time :2023/11/9 16:00
  63 + */
  64 + public function del(ExtendLogic $extendLogic){
  65 + $this->request->validate([
  66 + 'id'=>'required',
  67 + ],[
  68 + 'id.required' => '主键不能为空',
  69 + ]);
  70 + $extendLogic->extendDel();
  71 + $this->response('success');
  72 + }
  73 +}
@@ -11,6 +11,7 @@ use App\Http\Logic\Bside\Product\ProductLogic; @@ -11,6 +11,7 @@ use App\Http\Logic\Bside\Product\ProductLogic;
11 use App\Http\Requests\Bside\Product\ProductRequest; 11 use App\Http\Requests\Bside\Product\ProductRequest;
12 use App\Models\Product\Category; 12 use App\Models\Product\Category;
13 use App\Models\Product\CategoryRelated; 13 use App\Models\Product\CategoryRelated;
  14 +use App\Models\Product\ExtendInfo;
14 use App\Models\Product\Keyword; 15 use App\Models\Product\Keyword;
15 use App\Models\Product\KeywordRelated; 16 use App\Models\Product\KeywordRelated;
16 use App\Models\Product\Product; 17 use App\Models\Product\Product;
@@ -268,6 +269,17 @@ class ProductController extends BaseController @@ -268,6 +269,17 @@ class ProductController extends BaseController
268 $templateInfo = $templateSettingModel->read(['project_id'=>$this->user['project_id']]); 269 $templateInfo = $templateSettingModel->read(['project_id'=>$this->user['project_id']]);
269 $v['is_renovation'] = $this->getProductIsRenovation($templateInfo,$v['id']); 270 $v['is_renovation'] = $this->getProductIsRenovation($templateInfo,$v['id']);
270 $v['url'] = $this->user['domain'].$v['route']; 271 $v['url'] = $this->user['domain'].$v['route'];
  272 + //获取当前数据扩展字段及值
  273 + $extendInfoModel = new ExtendInfo();
  274 + $v['extend'] = $extendInfoModel->list(['product_id'=>$v['id']],'created_at');
  275 + foreach ($v['extend'] as $k1=>$v1){
  276 + if($v1['type'] == 3){
  277 + $v1['values'] = getImageUrl($v1['values']);
  278 + }elseif ($v1['type'] == 4){
  279 + $v1['values'] = getFileUrl($v1['values']);
  280 + }
  281 + $v['extend'][$k1] = $v1;
  282 + }
271 return $v; 283 return $v;
272 } 284 }
273 285
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ExtendLogic.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/11/9 14:24
  8 + */
  9 +
  10 +namespace App\Http\Logic\Bside\Product;
  11 +
  12 +use App\Helper\Translate;
  13 +use App\Http\Logic\Bside\BaseLogic;
  14 +use App\Models\Product\Extend;
  15 +use App\Models\Product\ExtendInfo;
  16 +
  17 +class ExtendLogic extends BaseLogic
  18 +{
  19 + public function __construct()
  20 + {
  21 + parent::__construct();
  22 + $this->param = $this->requestAll;
  23 + $this->model = new Extend();
  24 + }
  25 +
  26 + /**
  27 + * @remark :保存数据
  28 + * @name :extendSave
  29 + * @author :lyh
  30 + * @method :post
  31 + * @time :2023/11/9 14:29
  32 + */
  33 + public function extendSave(){
  34 + if(isset($this->param['id']) && !empty($this->param['id'])){
  35 + $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
  36 + }else{
  37 + $info = $this->model->read(['title'=>$this->param['title']]);
  38 + if($info !== false){
  39 + $this->fail('当前扩展名称已存在');
  40 + }
  41 + $key = trim(strtolower(preg_replace('/[\W]+/', '-', trim(Translate::tran($this->param['title'], 'en')))), '-');
  42 + $this->param['key'] = $this->getKey($key);
  43 + $this->param['project_id'] = $this->user['project_id'];
  44 + $rs = $this->model->add($this->param);
  45 + }
  46 + if($rs === false){
  47 + $this->fail('error');
  48 + }
  49 + return $this->success($this->param);
  50 + }
  51 +
  52 + /**
  53 + * @remark :获取唯一key
  54 + * @name :getKey
  55 + * @author :lyh
  56 + * @method :post
  57 + * @time :2023/11/9 15:55
  58 + */
  59 + public function getKey($key){
  60 + $info = $this->model->read(['key'=>$key]);
  61 + if($info !== false){
  62 + $key .= '-'.rand(1, 100);
  63 + return $this->getKey($key);
  64 + }
  65 + return $key;
  66 + }
  67 +
  68 + /**
  69 + * @remark :删除自定义字段
  70 + * @name :extendDel
  71 + * @author :lyh
  72 + * @method :post
  73 + * @time :2023/11/9 16:07
  74 + */
  75 + public function extendDel(){
  76 + $info = $this->model->read(['id'=>$this->param['id']]);
  77 + //查看当前扩展字段是否设置了值
  78 + $extendInfoModel = new ExtendInfo();
  79 + $extendInfo = $extendInfoModel->read(['key'=>$info['key']]);
  80 + if($extendInfo !== false){
  81 + $this->fail('当前扩展字段已有产品在使用,不允许删除');
  82 + }
  83 + $this->model->del(['id'=>$this->param['id']]);
  84 + return $this->success();
  85 + }
  86 +}
@@ -53,13 +53,10 @@ class KeywordLogic extends BaseLogic @@ -53,13 +53,10 @@ class KeywordLogic extends BaseLogic
53 try { 53 try {
54 $this->param = $this->handleSaveParam($this->param); 54 $this->param = $this->handleSaveParam($this->param);
55 if(isset($this->param['id']) && !empty($this->param['id'])){ 55 if(isset($this->param['id']) && !empty($this->param['id'])){
56 - $info = $this->model->read(['id'=>$this->param['id']],['id','route']);  
57 - $route = $info['route'];  
58 - $this->model->edit($this->param,['id'=>$info['id']]); 56 + $this->model->edit($this->param,['id'=>$this->param['id']]);
59 }else{ 57 }else{
60 $this->param['project_id'] = $this->user['project_id']; 58 $this->param['project_id'] = $this->user['project_id'];
61 $this->param['created_at'] = date('Y-m-d H:i:s'); 59 $this->param['created_at'] = date('Y-m-d H:i:s');
62 - $this->param['title'] = $this->param['title'].'-tag';  
63 $this->param['updated_at'] = $this->param['created_at']; 60 $this->param['updated_at'] = $this->param['created_at'];
64 $id = $this->model->insertGetId($this->param); 61 $id = $this->model->insertGetId($this->param);
65 //路由映射 62 //路由映射
@@ -7,6 +7,7 @@ use App\Helper\Common; @@ -7,6 +7,7 @@ use App\Helper\Common;
7 use App\Http\Logic\Bside\BaseLogic; 7 use App\Http\Logic\Bside\BaseLogic;
8 use App\Models\Product\Category; 8 use App\Models\Product\Category;
9 use App\Models\Product\CategoryRelated; 9 use App\Models\Product\CategoryRelated;
  10 +use App\Models\Product\ExtendInfo;
10 use App\Models\Product\Keyword; 11 use App\Models\Product\Keyword;
11 use App\Models\Product\Product; 12 use App\Models\Product\Product;
12 use App\Models\RouteMap\RouteMap; 13 use App\Models\RouteMap\RouteMap;
@@ -37,6 +38,12 @@ class ProductLogic extends BaseLogic @@ -37,6 +38,12 @@ class ProductLogic extends BaseLogic
37 * @time :2023/8/21 18:35 38 * @time :2023/8/21 18:35
38 */ 39 */
39 public function productSave(){ 40 public function productSave(){
  41 + //扩展字段
  42 + $extend = [];
  43 + if(!empty($this->param['extend'])){
  44 + $extend = $this->param['extend'];
  45 + unset($this->param['extend']);
  46 + }
40 $this->param = $this->handleSaveParam($this->param); 47 $this->param = $this->handleSaveParam($this->param);
41 //单独处理分类 48 //单独处理分类
42 $category_ids = []; 49 $category_ids = [];
@@ -52,26 +59,67 @@ class ProductLogic extends BaseLogic @@ -52,26 +59,67 @@ class ProductLogic extends BaseLogic
52 $this->param['route'] = $this->editProductRoute($this->param['route']); 59 $this->param['route'] = $this->editProductRoute($this->param['route']);
53 $this->model->edit($this->param,['id'=>$this->param['id']]); 60 $this->model->edit($this->param,['id'=>$this->param['id']]);
54 }else{ 61 }else{
55 - $this->param['project_id'] = $this->user['project_id'];  
56 - $this->param['created_at'] = date('Y-m-d H:i:s');  
57 - $this->param['updated_at'] = $this->param['created_at'];  
58 - $this->param['route'] = $this->param['route'].'-'.RouteMap::SOURCE_PRODUCT; 62 + $this->param = $this->addHandleParam($this->param);
59 $id = $this->model->addReturnId($this->param); 63 $id = $this->model->addReturnId($this->param);
  64 + $this->param['route'] = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
60 } 65 }
61 - $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);  
62 - $this->model->edit(['route'=>$route],['id'=>$id]); 66 + $this->model->edit(['route'=> $this->param['route']],['id'=>$id]);
63 //产品分类关联 67 //产品分类关联
64 CategoryRelated::saveRelated($id, $category_ids); 68 CategoryRelated::saveRelated($id, $category_ids);
  69 + //保存扩展字段
  70 + $this->saveExtendInfo($id,$extend);
65 DB::connection('custom_mysql')->commit(); 71 DB::connection('custom_mysql')->commit();
66 }catch (\Exception $e){ 72 }catch (\Exception $e){
67 DB::connection('custom_mysql')->rollBack(); 73 DB::connection('custom_mysql')->rollBack();
68 $this->fail('系统错误请联系管理员'); 74 $this->fail('系统错误请联系管理员');
69 } 75 }
70 //通知更新 76 //通知更新
71 - $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT, 'route'=>$route]); 77 + $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_PRODUCT, 'route'=>$this->param['route']]);
  78 + return $this->success();
  79 + }
  80 +
  81 + /**
  82 + * @remark :新增时处理字段
  83 + * @name :addHandleParam
  84 + * @author :lyh
  85 + * @method :post
  86 + * @time :2023/11/9 14:48
  87 + */
  88 + public function addHandleParam($param){
  89 + $param['project_id'] = $this->user['project_id'];
  90 + $param['created_at'] = date('Y-m-d H:i:s');
  91 + $param['updated_at'] = $param['created_at'];
  92 + return $param;
  93 + }
  94 +
  95 + /**
  96 + * @remark :保存扩展字段
  97 + * @name :saveExtend
  98 + * @author :lyh
  99 + * @method :post
  100 + * @time :2023/11/9 15:02
  101 + */
  102 + public function saveExtendInfo($id,$extend){
  103 + //先删除以前的数据
  104 + $extendInfoModel = new ExtendInfo();
  105 + $extendInfoModel->del(['project_id'=>$id]);
  106 + if(!empty($extend)){
  107 + foreach ($extend as $v){
  108 + unset($v['title']);
  109 + if(!empty($v['values'])){
  110 + if($v['type'] == 3 || $v['type'] || 4){
  111 + $v['values'] = str_replace_url($v['values']);
  112 + }
  113 + $v['project_id'] = $this->user['project_id'];
  114 + $v['product_id'] = $id;
  115 + $extendInfoModel->add($v);
  116 + }
  117 + }
  118 + }
72 return $this->success(); 119 return $this->success();
73 } 120 }
74 121
  122 +
75 /** 123 /**
76 * @remark :编辑列表数据 124 * @remark :编辑列表数据
77 * @name :editList 125 * @name :editList
@@ -135,15 +183,15 @@ class ProductLogic extends BaseLogic @@ -135,15 +183,15 @@ class ProductLogic extends BaseLogic
135 $v['url'] = str_replace_url($v['url']); 183 $v['url'] = str_replace_url($v['url']);
136 $param['gallery'][$k] = $v; 184 $param['gallery'][$k] = $v;
137 } 185 }
138 - $param['thumb'] = Arr::a2s($param['gallery'][0] ?? '');  
139 - $param['gallery'] = Arr::a2s($param['gallery'] ?? ''); 186 + $param['thumb'] = Arr::a2s($param['gallery'][0] ?? []);
  187 + $param['gallery'] = Arr::a2s($param['gallery'] ?? []);
140 } 188 }
141 - $param['attrs'] = Arr::a2s($param['attrs'] ?? ''); 189 + $param['attrs'] = Arr::a2s($param['attrs'] ?? []);
142 $param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? ''); 190 $param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? '');
143 if(isset($param['keyword_id']) && !empty($param['keyword_id'])){ 191 if(isset($param['keyword_id']) && !empty($param['keyword_id'])){
144 $param['keyword_id'] = ','.Arr::arrToSet($param['keyword_id']).','; 192 $param['keyword_id'] = ','.Arr::arrToSet($param['keyword_id']).',';
145 } 193 }
146 - $param['describe'] = Arr::a2s($param['describe'] ?? ''); 194 + $param['describe'] = Arr::a2s($param['describe'] ?? []);
147 $param['describe_id'] = Arr::arrToSet($param['describe_id'] ?? ''); 195 $param['describe_id'] = Arr::arrToSet($param['describe_id'] ?? '');
148 $param['seo_mate'] = Arr::a2s($param['seo_mate'] ?? ''); 196 $param['seo_mate'] = Arr::a2s($param['seo_mate'] ?? '');
149 $param['related_product_id'] = Arr::arrToSet($param['related_product_id'] ?? ''); 197 $param['related_product_id'] = Arr::arrToSet($param['related_product_id'] ?? '');
@@ -151,7 +199,7 @@ class ProductLogic extends BaseLogic @@ -151,7 +199,7 @@ class ProductLogic extends BaseLogic
151 foreach ($param['icon'] as $k1 => $v1){ 199 foreach ($param['icon'] as $k1 => $v1){
152 $param['icon'][$k1] = str_replace_url($v1); 200 $param['icon'][$k1] = str_replace_url($v1);
153 } 201 }
154 - $param['icon'] = Arr::a2s($param['icon'] ?? ''); 202 + $param['icon'] = Arr::a2s($param['icon'] ?? []);
155 } 203 }
156 $param['created_uid'] = $this->user['id']; 204 $param['created_uid'] = $this->user['id'];
157 return $param; 205 return $param;
@@ -166,6 +166,7 @@ class UserLoginLogic @@ -166,6 +166,7 @@ class UserLoginLogic
166 $info['is_customized'] = $project['is_customized']; 166 $info['is_customized'] = $project['is_customized'];
167 $info['is_upload_manage'] = $project['is_upload_manage']; 167 $info['is_upload_manage'] = $project['is_upload_manage'];
168 $info['upload_config'] = $project['upload_config']; 168 $info['upload_config'] = $project['upload_config'];
  169 + $info['image_max'] = $project['image_max'];
169 $info['configuration'] = $project['deploy_build']['configuration']; 170 $info['configuration'] = $project['deploy_build']['configuration'];
170 //保存项目缓存 171 //保存项目缓存
171 Cache::put('user-'.$info['project_id'],$project,$minutes = null); 172 Cache::put('user-'.$info['project_id'],$project,$minutes = null);
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :Extend.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/11/9 14:18
  8 + */
  9 +
  10 +namespace App\Models\Product;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class Extend extends Base
  15 +{
  16 + //设置关联表名
  17 + protected $table = 'gl_product_extend';
  18 + //连接数据库
  19 + protected $connection = 'custom_mysql';
  20 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :ExtendInfo.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/11/9 14:19
  8 + */
  9 +
  10 +namespace App\Models\Product;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class ExtendInfo extends Base
  15 +{
  16 + //设置关联表名
  17 + protected $table = 'gl_product_extend_info';
  18 + //连接数据库
  19 + protected $connection = 'custom_mysql';
  20 +}
@@ -117,6 +117,10 @@ class RouteMap extends Base @@ -117,6 +117,10 @@ class RouteMap extends Base
117 $route_map->path = self::SOURCE_BLOG; 117 $route_map->path = self::SOURCE_BLOG;
118 }elseif ($source == self::SOURCE_BLOG_CATE){ 118 }elseif ($source == self::SOURCE_BLOG_CATE){
119 $route_map->path = self::PATH_BLOG_CATE; 119 $route_map->path = self::PATH_BLOG_CATE;
  120 + }elseif ($source == self::SOURCE_PRODUCT_KEYWORD){
  121 + $route = $route.'-tag';
  122 + }elseif ($source == self::SOURCE_PRODUCT){
  123 + $route = $route.'-product';
120 } 124 }
121 $route_map->source_id = $source_id; 125 $route_map->source_id = $source_id;
122 $route_map->project_id = $project_id; 126 $route_map->project_id = $project_id;
@@ -232,6 +232,9 @@ Route::middleware(['bloginauth'])->group(function () { @@ -232,6 +232,9 @@ Route::middleware(['bloginauth'])->group(function () {
232 Route::get('describe/info', [\App\Http\Controllers\Bside\Product\DescribeController::class, 'info'])->name('product_describe_info'); 232 Route::get('describe/info', [\App\Http\Controllers\Bside\Product\DescribeController::class, 'info'])->name('product_describe_info');
233 Route::post('describe/save', [\App\Http\Controllers\Bside\Product\DescribeController::class, 'save'])->name('product_describe_save'); 233 Route::post('describe/save', [\App\Http\Controllers\Bside\Product\DescribeController::class, 'save'])->name('product_describe_save');
234 Route::any('describe/delete', [\App\Http\Controllers\Bside\Product\DescribeController::class, 'delete'])->name('product_describe_delete'); 234 Route::any('describe/delete', [\App\Http\Controllers\Bside\Product\DescribeController::class, 'delete'])->name('product_describe_delete');
  235 + //扩展字段
  236 + Route::any('extend', [\App\Http\Controllers\Bside\Product\ExtendController::class, 'lists'])->name('product_extend');
  237 + Route::any('extend/save', [\App\Http\Controllers\Bside\Product\ExtendController::class, 'save'])->name('product_extend_save');
235 }); 238 });
236 239
237 240