作者 刘锟

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

@@ -257,4 +257,23 @@ class KeywordController extends BaseController @@ -257,4 +257,23 @@ class KeywordController extends BaseController
257 $id = $keywordPageModel->addReturnId($this->param); 257 $id = $keywordPageModel->addReturnId($this->param);
258 $this->response('success',Code::SUCCESS,['id'=>$id]); 258 $this->response('success',Code::SUCCESS,['id'=>$id]);
259 } 259 }
  260 +
  261 + /**
  262 + * @remark :删除关联关系
  263 + * @name :delRelated
  264 + * @author :lyh
  265 + * @method :post
  266 + * @time :2024/11/28 10:30
  267 + */
  268 + public function delRelated(KeywordLogic $logic){
  269 + $this->request->validate([
  270 + 'keyword_id'=>'required',
  271 + 'product_id'=>'required',
  272 + ],[
  273 + 'keyword_id.required' => '关键词id不能为空',
  274 + 'product_id.required' => '产品id不为空',
  275 + ]);
  276 + $logic->delRelated($this->param['keyword'],$this->param['product_id']);
  277 + $this->response('success');
  278 + }
260 } 279 }
@@ -69,13 +69,11 @@ class EmailController extends BaseController @@ -69,13 +69,11 @@ class EmailController extends BaseController
69 public function set_smtp(Smtp $smtp) 69 public function set_smtp(Smtp $smtp)
70 { 70 {
71 $this->request->validate([ 71 $this->request->validate([
72 - 'project_id' => ['required'],  
73 'email' => ['required', 'email', 'max:200'], 72 'email' => ['required', 'email', 'max:200'],
74 'password' => ['required', 'max:200'], 73 'password' => ['required', 'max:200'],
75 'host' => ['required', 'max:200', 'regex:/[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?/'], 74 'host' => ['required', 'max:200', 'regex:/[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?/'],
76 'from_name' => ['required', 'max:200'], 75 'from_name' => ['required', 'max:200'],
77 ], [ 76 ], [
78 - 'project_id.required' => '参数异常',  
79 'email.required' => '邮箱必须', 77 'email.required' => '邮箱必须',
80 'email.email' => '邮箱格式错误', 78 'email.email' => '邮箱格式错误',
81 'password.required' => '授权码/密码必须', 79 'password.required' => '授权码/密码必须',
@@ -83,7 +81,7 @@ class EmailController extends BaseController @@ -83,7 +81,7 @@ class EmailController extends BaseController
83 'host.regex' => 'smtp格式错误', 81 'host.regex' => 'smtp格式错误',
84 'from_name.required' => '发信人昵称必须', 82 'from_name.required' => '发信人昵称必须',
85 ]); 83 ]);
86 - $info = $smtp->read(['project_id' => $this->param['project_id']]); 84 + $info = $smtp->read(['project_id' => $this->project['id']]);
87 if (!$info) { 85 if (!$info) {
88 $smtp->add($this->param); 86 $smtp->add($this->param);
89 } else { 87 } else {
@@ -92,6 +90,11 @@ class EmailController extends BaseController @@ -92,6 +90,11 @@ class EmailController extends BaseController
92 $this->response('success'); 90 $this->response('success');
93 } 91 }
94 92
  93 + public function get_smtp(Smtp $smtp){
  94 + $info = $smtp->read(['project_id' => $this->project['id']]);
  95 + $this->response($info);
  96 + }
  97 +
95 public function group_send(GroupSendTask $groupSendTask) 98 public function group_send(GroupSendTask $groupSendTask)
96 { 99 {
97 $this->request->validate([ 100 $this->request->validate([
@@ -42,6 +42,7 @@ class KeywordLogic extends BaseLogic @@ -42,6 +42,7 @@ class KeywordLogic extends BaseLogic
42 if($info !== false){ 42 if($info !== false){
43 $info['url'] = $this->user['domain'] . $info['route']; 43 $info['url'] = $this->user['domain'] . $info['route'];
44 $info['related_news_info'] = News::whereIn('id', $info['related_news_ids'])->select(['id', 'name'])->get(); 44 $info['related_news_info'] = News::whereIn('id', $info['related_news_ids'])->select(['id', 'name'])->get();
  45 + $info['product_list'] = $this->getProduct($info['id']);
45 } 46 }
46 return $this->success($info); 47 return $this->success($info);
47 } 48 }
@@ -298,4 +299,41 @@ class KeywordLogic extends BaseLogic @@ -298,4 +299,41 @@ class KeywordLogic extends BaseLogic
298 } 299 }
299 return $this->success(); 300 return $this->success();
300 } 301 }
  302 +
  303 + /**
  304 + * @remark :根据关键字获取产品
  305 + * @name :getProduct
  306 + * @author :lyh
  307 + * @method :post
  308 + * @time :2024/11/28 9:26
  309 + */
  310 + public function getProduct($keyword_id){
  311 + $productList = [];
  312 + $keywordRelatedModel = new KeywordRelated();
  313 + $productIdArr = $keywordRelatedModel->selectField(['keyword_id'=>$keyword_id],'product_id');
  314 + if(!empty($productIdArr)){
  315 + $productModel = new Product();
  316 + $productList = $productModel->list(['id'=>['in',$productIdArr]],['id','title']);
  317 + }
  318 + return $this->success($productList);
  319 + }
  320 +
  321 + /**
  322 + * @remark :对应删除关联关系
  323 + * @name :delRelated
  324 + * @author :lyh
  325 + * @method :post
  326 + * @time :2024/11/28 9:46
  327 + */
  328 + public function delRelated($keyword_id,$product_id){
  329 + $productModel = new Product();
  330 + $productModel->where('id', $product_id)
  331 + ->update(['keyword_id' => DB::raw("REPLACE(keyword_id, ',$keyword_id,' , ',')"),'keyword_video_id' => DB::raw("REPLACE(keyword_video_id, ',$keyword_id,' , ',')")]);
  332 + $productModel->where('id', $product_id)->where('keyword_id',',')->orWhere('keyword_video_id',',')
  333 + ->update(['keyword_id' => DB::raw("REPLACE(keyword_id, ',' , '')"),'keyword_video_id' => DB::raw("REPLACE(keyword_video_id, ',' , '')")]);
  334 + $keywordRelatedModel = new KeywordRelated();
  335 + $keywordRelatedModel->del(['product_id'=>$product_id,'keyword_id'=>$keyword_id]);
  336 + return $this->success();
  337 + }
  338 +
301 } 339 }
@@ -43,6 +43,7 @@ class ProductLogic extends BaseLogic @@ -43,6 +43,7 @@ class ProductLogic extends BaseLogic
43 $extend = $this->handleExtent(); 43 $extend = $this->handleExtent();
44 //单独处理分类 44 //单独处理分类
45 $category_ids = $this->handleCategory(); 45 $category_ids = $this->handleCategory();
  46 + $keyword_arr = $this->param['keyword_id'] ?? [];
46 //处理其他字段 47 //处理其他字段
47 $this->param = $this->handleSaveParam($this->param); 48 $this->param = $this->handleSaveParam($this->param);
48 try { 49 try {
@@ -66,7 +67,7 @@ class ProductLogic extends BaseLogic @@ -66,7 +67,7 @@ class ProductLogic extends BaseLogic
66 } 67 }
67 //产品分类关联 68 //产品分类关联
68 CategoryRelated::saveRelated($id, $category_ids); 69 CategoryRelated::saveRelated($id, $category_ids);
69 - KeywordRelated::saveRelated($id,$category_ids); 70 + KeywordRelated::saveRelated($id,$keyword_arr);
70 //更新产品新描述 71 //更新产品新描述
71 $detailLogic = new DetailLogic(); 72 $detailLogic = new DetailLogic();
72 $detailLogic->saveDetail($id,$this->param['data'] ?? []); 73 $detailLogic->saveDetail($id,$this->param['data'] ?? []);
@@ -53,33 +53,6 @@ class QueryListener @@ -53,33 +53,6 @@ class QueryListener
53 $log = $log.' [ RunTime:'.$event->time.'ms ] '; 53 $log = $log.' [ RunTime:'.$event->time.'ms ] ';
54 Log::debug($log); 54 Log::debug($log);
55 } 55 }
56 - //监听api_no是TM咋个被改的  
57 - if (Str::contains($event->sql, 'update') && Str::contains($event->sql, '`api_no` =')) {  
58 - //记录debug 根据这个溯源  
59 - $trace = debug_backtrace();  
60 - $traces = [];  
61 - foreach ($trace as $index => $caller) {  
62 - if ($index === 0) {  
63 - continue; // 跳过当前方法的调用信息  
64 - }  
65 - $file = $caller['file'];  
66 - $line = $caller['line'];  
67 - $class = $caller['class'];  
68 - $method = $caller['function'];  
69 - $traces[] = "Method $method called from $class in file $file at line $line\n";  
70 - }  
71 - //用户信息 哪个改的 还是脚本跑的  
72 - $token = request()->header('token');  
73 - Log::channel('test')->info('api_no updated', [  
74 - 'sql' => $event->sql,  
75 - 'bindings' => $event->bindings,  
76 - 'route' => Route::current(),  
77 - 'request' => request()->all(),  
78 - 'a_info' => Cache::get(Common::MANAGE_TOKEN . $token),  
79 - 'b_info' => Cache::get($token),  
80 - 'trace' => $traces  
81 - ]);  
82 - }  
83 }catch (\Exception $exception){ 56 }catch (\Exception $exception){
84 Log::error('log sql error:'.$exception->getMessage()); 57 Log::error('log sql error:'.$exception->getMessage());
85 } 58 }
@@ -296,4 +296,5 @@ class Base extends Model @@ -296,4 +296,5 @@ class Base extends Model
296 $data = $this->filterRequestData($data); 296 $data = $this->filterRequestData($data);
297 return $this->formatQuery($data)->pluck($filed)->toArray(); 297 return $this->formatQuery($data)->pluck($filed)->toArray();
298 } 298 }
  299 +
299 } 300 }
@@ -281,6 +281,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -281,6 +281,7 @@ Route::middleware(['bloginauth'])->group(function () {
281 Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd'); 281 Route::post('keyword/batchAdd', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchAdd'])->name('product_keyword_batchAdd');
282 Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel'); 282 Route::post('keyword/batchDel', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchDel'])->name('product_keyword_batchDel');
283 Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete'); 283 Route::any('keyword/delete', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delete'])->name('product_keyword_delete');
  284 + Route::any('keyword/delRelated', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'delRelated'])->name('product_keyword_delRelated');
284 Route::any('keyword/batchUpdateKeyword', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchUpdateKeyword'])->name('product_keyword_batchUpdateKeyword'); 285 Route::any('keyword/batchUpdateKeyword', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchUpdateKeyword'])->name('product_keyword_batchUpdateKeyword');
285 Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo'); 286 Route::any('keyword/batchKeywordIsVideo', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordIsVideo'])->name('product_keyword_batchKeywordIsVideo');
286 Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled'); 287 Route::any('keyword/batchKeywordFiled', [\App\Http\Controllers\Bside\Product\KeywordController::class, 'batchKeywordFiled'])->name('product_keyword_batchKeywordFiled');
@@ -632,6 +633,7 @@ Route::middleware(['bloginauth'])->group(function () { @@ -632,6 +633,7 @@ Route::middleware(['bloginauth'])->group(function () {
632 Route::any('/del', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'delete'])->name('subscribe_email_del'); 633 Route::any('/del', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'delete'])->name('subscribe_email_del');
633 Route::any('/export', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'export'])->name('subscribe_email_export'); 634 Route::any('/export', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'export'])->name('subscribe_email_export');
634 Route::any('/set_smtp', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'set_smtp'])->name('subscribe_email_set_smtp'); 635 Route::any('/set_smtp', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'set_smtp'])->name('subscribe_email_set_smtp');
  636 + Route::any('/get_smtp', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'get_smtp'])->name('subscribe_email_get_smtp');
635 Route::any('/group_send', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'group_send'])->name('subscribe_email_group_send'); 637 Route::any('/group_send', [\App\Http\Controllers\Bside\Subscribe\EmailController::class, 'group_send'])->name('subscribe_email_group_send');
636 }); 638 });
637 639