作者 赵彬吉
@@ -28,7 +28,7 @@ class RemainDay extends Command @@ -28,7 +28,7 @@ class RemainDay extends Command
28 * @var 按上线时间统计 28 * @var 按上线时间统计
29 */ 29 */
30 protected $projectId = [ 30 protected $projectId = [
31 - 1434,1812,276,596 31 + 1434,1812,276
32 ];//需要单独处理的项目 32 ];//需要单独处理的项目
33 33
34 /** 34 /**
@@ -14,11 +14,8 @@ use Illuminate\Support\Facades\Config; @@ -14,11 +14,8 @@ use Illuminate\Support\Facades\Config;
14 use Illuminate\Support\Facades\Mail; 14 use Illuminate\Support\Facades\Mail;
15 15
16 /** 16 /**
17 - *  
18 * Class WorkchatMessageSend 17 * Class WorkchatMessageSend
19 - * @package App\Console\Commands  
20 - * @author zbj  
21 - * @date 2023/11/28 18 + * @package App\Console\Commands\Task
22 */ 19 */
23 class WorkchatMessageSend extends Command 20 class WorkchatMessageSend extends Command
24 { 21 {
@@ -56,20 +56,38 @@ class UpdateRoute extends Command @@ -56,20 +56,38 @@ class UpdateRoute extends Command
56 */ 56 */
57 public function handle(){ 57 public function handle(){
58 $projectModel = new Project(); 58 $projectModel = new Project();
59 - $list = $projectModel->list(['id'=>['in',[1646]]]); 59 + $list = $projectModel->list(['id'=>['in',[1799]]]);
60 $data = []; 60 $data = [];
61 foreach ($list as $v){ 61 foreach ($list as $v){
62 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 62 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
63 ProjectServer::useProject($v['id']); 63 ProjectServer::useProject($v['id']);
64 - $this->getProduct(); 64 +// $this->getProduct();
65 // $this->setProductKeyword(); 65 // $this->setProductKeyword();
66 // $this->getBlog(); 66 // $this->getBlog();
67 // $this->setCustomRoute($v['id']); 67 // $this->setCustomRoute($v['id']);
  68 + $this->editProductAlt();
68 DB::disconnect('custom_mysql'); 69 DB::disconnect('custom_mysql');
69 } 70 }
70 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 71 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
71 } 72 }
72 73
  74 + public function editProductAlt(){
  75 + $productModel = new Product();
  76 + $lists = $productModel->list(['status'=>1],'id',['id','route','thumb','gallery']);
  77 + foreach ($lists as $k => $v){
  78 + $v['thumb']['alt'] = $v['route'];
  79 + if(!empty($v['gallery'])){
  80 + foreach ($v['gallery'] as $keys => $values){
  81 + $values = (array)$values;
  82 + $values['alt'] = $v['route'];
  83 + $v['gallery'][$keys] = $values;
  84 + }
  85 + }
  86 + $productModel->edit(['thumb'=>json_encode($v['thumb'],true),'gallery'=>json_encode($v['gallery'],true)],['id'=>$v['id']]);
  87 + }
  88 + return true;
  89 + }
  90 +
73 public function setCustomRoute($project_id){ 91 public function setCustomRoute($project_id){
74 $customModel = new CustomModuleContent(); 92 $customModel = new CustomModuleContent();
75 $list = $customModel->list(); 93 $list = $customModel->list();
@@ -12,6 +12,7 @@ namespace App\Http\Controllers\Bside\BCom; @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Bside\BCom;
12 use App\Enums\Common\Code; 12 use App\Enums\Common\Code;
13 use App\Helper\Arr; 13 use App\Helper\Arr;
14 use App\Http\Controllers\Bside\BaseController; 14 use App\Http\Controllers\Bside\BaseController;
  15 +use App\Jobs\UpdatePageJob;
15 use App\Models\Com\Notify; 16 use App\Models\Com\Notify;
16 use App\Models\Com\UpdateLog; 17 use App\Models\Com\UpdateLog;
17 use App\Models\Com\UpdateNotify; 18 use App\Models\Com\UpdateNotify;
@@ -107,7 +108,7 @@ class CNoticeController extends BaseController @@ -107,7 +108,7 @@ class CNoticeController extends BaseController
107 }else{ 108 }else{
108 //其他服务器:请求对应C端接口 109 //其他服务器:请求对应C端接口
109 $c_url = $this->user['domain'].'api/update_page/'; 110 $c_url = $this->user['domain'].'api/update_page/';
110 - $param = [ 111 + $c_param = [
111 'project_id' => $this->user['project_id'], 112 'project_id' => $this->user['project_id'],
112 'type' => $type, 113 'type' => $type,
113 'route' => $route, 114 'route' => $route,
@@ -115,10 +116,10 @@ class CNoticeController extends BaseController @@ -115,10 +116,10 @@ class CNoticeController extends BaseController
115 'language'=> $language, 116 'language'=> $language,
116 'is_sitemap' => $is_sitemap 117 'is_sitemap' => $is_sitemap
117 ]; 118 ];
118 - http_post($c_url, json_encode($param));  
119 -// $shell = 'curl -X POST ' . escapeshellarg($c_url) . ' -H "Content-Type: application/json"' .  
120 -// ' -d ' . escapeshellarg(json_encode($param)) . ' > /dev/null 2>&1 &';  
121 -// shell_exec($shell); 119 +// http_post($c_url, json_encode($c_param));
  120 +
  121 + //2024-10-11:改为异步请求
  122 + UpdatePageJob::dispatch(['c_url'=>$c_url,'c_params'=>json_encode($c_param)]);
122 } 123 }
123 $this->response('更新中请稍后, 更新完成将会发送站内信通知更新结果!'); 124 $this->response('更新中请稍后, 更新完成将会发送站内信通知更新结果!');
124 } 125 }
@@ -252,7 +252,7 @@ class CustomTemplateLogic extends BaseLogic @@ -252,7 +252,7 @@ class CustomTemplateLogic extends BaseLogic
252 $this->setTemplateLog($bSettingInfo['template_id'] ?? 0,$html,$this->param['id']); 252 $this->setTemplateLog($bSettingInfo['template_id'] ?? 0,$html,$this->param['id']);
253 //通知 253 //通知
254 $this->addUpdateNotify(RouteMap::SOURCE_PAGE,$info['url']); 254 $this->addUpdateNotify(RouteMap::SOURCE_PAGE,$info['url']);
255 - $this->curlDelRoute(['route'=>$info['url'],'new_route'=>$info['url']]); 255 + $this->curlDelRoute(['old_route'=>$info['url'],'new_route'=>$info['url']]);
256 return $this->success(); 256 return $this->success();
257 } 257 }
258 258
@@ -391,7 +391,7 @@ class CustomTemplateLogic extends BaseLogic @@ -391,7 +391,7 @@ class CustomTemplateLogic extends BaseLogic
391 } 391 }
392 } 392 }
393 $this->addUpdateNotify(RouteMap::SOURCE_PAGE,$route); 393 $this->addUpdateNotify(RouteMap::SOURCE_PAGE,$route);
394 - $this->curlDelRoute(['route'=>$info['url'],'new_route'=>$route]); 394 + $this->curlDelRoute(['old_route'=>$info['url'],'new_route'=>$route]);
395 return true; 395 return true;
396 } 396 }
397 397
@@ -436,7 +436,7 @@ class CustomTemplateLogic extends BaseLogic @@ -436,7 +436,7 @@ class CustomTemplateLogic extends BaseLogic
436 RouteMap::delRoute(RouteMap::SOURCE_PAGE, $id, $this->user['project_id']); 436 RouteMap::delRoute(RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
437 //生成一条删除路由记录 437 //生成一条删除路由记录
438 $info = $this->model->read(['id' => $id], ['id', 'url']); 438 $info = $this->model->read(['id' => $id], ['id', 'url']);
439 - $this->curlDelRoute(['route'=>$info['url']]); 439 + $this->curlDelRoute(['old_route'=>$info['url']]);
440 return $this->success(); 440 return $this->success();
441 } 441 }
442 442
@@ -186,7 +186,7 @@ class InitHtmlLogic extends BaseLogic @@ -186,7 +186,7 @@ class InitHtmlLogic extends BaseLogic
186 } 186 }
187 $this->saveTemplateCom($this->param['html'],$template_id,$this->param['type'],$is_list,$is_custom); 187 $this->saveTemplateCom($this->param['html'],$template_id,$this->param['type'],$is_list,$is_custom);
188 $route = RouteMap::getRoute('all',0,$this->user['project_id']); 188 $route = RouteMap::getRoute('all',0,$this->user['project_id']);
189 - $this->curlDelRoute(['route'=>$route,'new_route'=>$route]); 189 + $this->curlDelRoute(['old_route'=>$route,'new_route'=>$route]);
190 return $this->success(); 190 return $this->success();
191 } 191 }
192 192
@@ -204,7 +204,7 @@ class BlogCategoryLogic extends BaseLogic @@ -204,7 +204,7 @@ class BlogCategoryLogic extends BaseLogic
204 RouteMap::delRoute(RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']); 204 RouteMap::delRoute(RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
205 //生成一条删除路由记录 205 //生成一条删除路由记录
206 $info = $this->model->read(['id'=>$id],['id','alias']); 206 $info = $this->model->read(['id'=>$id],['id','alias']);
207 - $this->curlDelRoute(['route'=>$info['alias']]); 207 + $this->curlDelRoute(['old_route'=>$info['alias']]);
208 return $this->success(); 208 return $this->success();
209 } 209 }
210 210
@@ -159,7 +159,7 @@ class BlogLogic extends BaseLogic @@ -159,7 +159,7 @@ class BlogLogic extends BaseLogic
159 RouteMap::delRoute(RouteMap::SOURCE_BLOG, $id, $this->user['project_id']); 159 RouteMap::delRoute(RouteMap::SOURCE_BLOG, $id, $this->user['project_id']);
160 //生成一条删除路由记录 160 //生成一条删除路由记录
161 $info = $this->model->read(['id'=>$id],['id','url']); 161 $info = $this->model->read(['id'=>$id],['id','url']);
162 - $this->curlDelRoute(['route'=>$info['url']]); 162 + $this->curlDelRoute(['old_route'=>$info['url']]);
163 return $this->success(); 163 return $this->success();
164 } 164 }
165 165
@@ -180,7 +180,7 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -180,7 +180,7 @@ class CustomModuleCategoryLogic extends BaseLogic
180 $info = $this->model->read(['id' => $id], ['id', 'route']); 180 $info = $this->model->read(['id' => $id], ['id', 'route']);
181 if ($info['route'] != $route) { 181 if ($info['route'] != $route) {
182 $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE,$route); 182 $this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE,$route);
183 - $this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]); 183 + $this->curlDelRoute(['old_route'=>$info['route'],'new_route'=>$route]);
184 } 184 }
185 return true; 185 return true;
186 } 186 }
@@ -223,7 +223,7 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -223,7 +223,7 @@ class CustomModuleCategoryLogic extends BaseLogic
223 } 223 }
224 RouteMap::delRoute(RouteMap::SOURCE_MODULE_CATE, $id, $this->user['project_id']); 224 RouteMap::delRoute(RouteMap::SOURCE_MODULE_CATE, $id, $this->user['project_id']);
225 //通知 225 //通知
226 - $this->curlDelRoute(['route'=>$info['route']]); 226 + $this->curlDelRoute(['old_route'=>$info['route']]);
227 return $this->success(); 227 return $this->success();
228 } 228 }
229 229
@@ -247,7 +247,7 @@ class CustomModuleContentLogic extends BaseLogic @@ -247,7 +247,7 @@ class CustomModuleContentLogic extends BaseLogic
247 //生成一条删除路由记录 247 //生成一条删除路由记录
248 $info = $this->model->read(['id' => $id], ['id', 'route']); 248 $info = $this->model->read(['id' => $id], ['id', 'route']);
249 $this->addUpdateNotify(RouteMap::SOURCE_MODULE,$route); 249 $this->addUpdateNotify(RouteMap::SOURCE_MODULE,$route);
250 - $this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]); 250 + $this->curlDelRoute(['old_route'=>$info['route'],'new_route'=>$route]);
251 return true; 251 return true;
252 } 252 }
253 253
@@ -354,7 +354,7 @@ class CustomModuleContentLogic extends BaseLogic @@ -354,7 +354,7 @@ class CustomModuleContentLogic extends BaseLogic
354 RouteMap::delRoute(RouteMap::SOURCE_MODULE, $id, $this->user['project_id']); 354 RouteMap::delRoute(RouteMap::SOURCE_MODULE, $id, $this->user['project_id']);
355 //通知 355 //通知
356 $info = $this->model->read(['id' => $id], ['id', 'route']); 356 $info = $this->model->read(['id' => $id], ['id', 'route']);
357 - $this->curlDelRoute(['route'=>$info['route']]); 357 + $this->curlDelRoute(['old_route'=>$info['route']]);
358 return $this->success(); 358 return $this->success();
359 } 359 }
360 360
@@ -218,7 +218,7 @@ class NewsCategoryLogic extends BaseLogic @@ -218,7 +218,7 @@ class NewsCategoryLogic extends BaseLogic
218 //删除路由映射 218 //删除路由映射
219 RouteMap::delRoute(RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']); 219 RouteMap::delRoute(RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
220 $info = $this->model->read(['id'=>$id],['id','alias']); 220 $info = $this->model->read(['id'=>$id],['id','alias']);
221 - $this->curlDelRoute(['route'=>$info['alias']]); 221 + $this->curlDelRoute(['old_route'=>$info['alias']]);
222 return $this->success(); 222 return $this->success();
223 } 223 }
224 224
@@ -290,7 +290,7 @@ class NewsLogic extends BaseLogic @@ -290,7 +290,7 @@ class NewsLogic extends BaseLogic
290 RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']); 290 RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
291 //生成一条删除路由记录 291 //生成一条删除路由记录
292 $info = $this->model->read(['id' => $id], ['id', 'url']); 292 $info = $this->model->read(['id' => $id], ['id', 'url']);
293 - $this->curlDelRoute(['route'=>$info['url']]); 293 + $this->curlDelRoute(['old_route'=>$info['url']]);
294 return $this->success(); 294 return $this->success();
295 } 295 }
296 296
@@ -194,7 +194,7 @@ class CategoryLogic extends BaseLogic @@ -194,7 +194,7 @@ class CategoryLogic extends BaseLogic
194 //生成一条删除路由记录 194 //生成一条删除路由记录
195 $info = $this->model->read(['id'=>$id],['id','route']); 195 $info = $this->model->read(['id'=>$id],['id','route']);
196 if($info !== false){ 196 if($info !== false){
197 - $this->curlDelRoute(['route'=>$info['route']]); 197 + $this->curlDelRoute(['old_route'=>$info['route']]);
198 } 198 }
199 return $this->success(); 199 return $this->success();
200 } 200 }
@@ -205,7 +205,7 @@ class KeywordLogic extends BaseLogic @@ -205,7 +205,7 @@ class KeywordLogic extends BaseLogic
205 //生成一条删除路由记录 205 //生成一条删除路由记录
206 $info = $this->model->read(['id'=>$id],['id','route']); 206 $info = $this->model->read(['id'=>$id],['id','route']);
207 if($info !== false){ 207 if($info !== false){
208 - $this->curlDelRoute(['route'=>$info['route']]); 208 + $this->curlDelRoute(['old_route'=>$info['route']]);
209 } 209 }
210 return $this->success(); 210 return $this->success();
211 } 211 }
@@ -387,7 +387,7 @@ class ProductLogic extends BaseLogic @@ -387,7 +387,7 @@ class ProductLogic extends BaseLogic
387 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); 387 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
388 //生成一条删除路由记录 388 //生成一条删除路由记录
389 $info = $this->model->read(['id'=>$id],['id','route']); 389 $info = $this->model->read(['id'=>$id],['id','route']);
390 - $this->curlDelRoute(['route'=>$info['route']]); 390 + $this->curlDelRoute(['old_route'=>$info['route']]);
391 return $this->success(); 391 return $this->success();
392 } 392 }
393 393
  1 +<?php
  2 +
  3 +namespace App\Jobs;
  4 +
  5 +use Illuminate\Bus\Queueable;
  6 +use Illuminate\Contracts\Queue\ShouldQueue;
  7 +use Illuminate\Foundation\Bus\Dispatchable;
  8 +use Illuminate\Queue\InteractsWithQueue;
  9 +use Illuminate\Queue\SerializesModels;
  10 +
  11 +class UpdatePageJob implements ShouldQueue
  12 +{
  13 + use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  14 +
  15 + public $tries = 3; // 可配置任务重试次数
  16 +
  17 + protected $param;
  18 +
  19 + /**
  20 + * Create a new job instance.
  21 + *
  22 + * @param $data
  23 + * @return void
  24 + */
  25 + public function __construct($data)
  26 + {
  27 + $this->param = $data;
  28 + }
  29 +
  30 + /**
  31 + * Execute the job.
  32 + * B端更新页面异步请求
  33 + * @return bool
  34 + */
  35 + public function handle()
  36 + {
  37 + $c_url = $this->param['c_url'];
  38 + $c_params = $this->param['c_params'];
  39 +
  40 + try {
  41 + $re = http_post($c_url, $c_params, [], true);
  42 + if (isset($re['status']) && $re['status'] == 200) {
  43 + $this->output($c_url . ' | 请求成功');
  44 + } else {
  45 + $this->output($c_url . ' | ' . ($re['message'] ?? '未返回失败原因'));
  46 + }
  47 + } catch (\Exception $e) {
  48 + $this->output($c_url . ' | 请求异常:' . $e->getMessage());
  49 + }
  50 +
  51 +
  52 + return true;
  53 + }
  54 +
  55 + /**
  56 + * 输出处理日志
  57 + * @param $message
  58 + */
  59 + public function output($message)
  60 + {
  61 + echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL;
  62 + }
  63 +}
@@ -33,7 +33,15 @@ class MessagePush extends Base @@ -33,7 +33,15 @@ class MessagePush extends Base
33 protected $table = 'gl_workchat_message_push'; 33 protected $table = 'gl_workchat_message_push';
34 34
35 35
36 - public static function addInquiryMessage($id, $project_id, $country, $submit_at){ 36 + /**
  37 + * @param $id
  38 + * @param $project_id
  39 + * @param $country
  40 + * @param $name
  41 + * @param $submit_at
  42 + * @return bool
  43 + */
  44 + public static function addInquiryMessage($id, $project_id, $country, $name, $submit_at){
37 if(!ProjectServer::useProject($project_id)){ 45 if(!ProjectServer::useProject($project_id)){
38 return false; 46 return false;
39 } 47 }
@@ -56,7 +64,7 @@ class MessagePush extends Base @@ -56,7 +64,7 @@ class MessagePush extends Base
56 $model->friend_id = $friend_id; 64 $model->friend_id = $friend_id;
57 $model->type = self::TYPE_INQUIRY; 65 $model->type = self::TYPE_INQUIRY;
58 $model->ref_ids = $id; 66 $model->ref_ids = $id;
59 - $model->content = '[' . date('H:i', strtotime($submit_at)) . '] 您的全球搜网站收到来自【' . $country . '】的询盘信息,请登录后台或APP进行查看!'; 67 + $model->content = '[' . date('H:i', strtotime($submit_at)) . '] 您的全球搜网站收到来自【' . $country . $name . '】的询盘信息,请登录后台或APP进行查看!';
60 }else{ 68 }else{
61 //定时发送时间 69 //定时发送时间
62 $send_time = $hour >= 9 ? date('Y-m-d 09:00:00', strtotime('+1 day')) : date('Y-m-d 09:00:00'); 70 $send_time = $hour >= 9 ? date('Y-m-d 09:00:00', strtotime('+1 day')) : date('Y-m-d 09:00:00');
@@ -69,7 +77,7 @@ class MessagePush extends Base @@ -69,7 +77,7 @@ class MessagePush extends Base
69 $model->type = self::TYPE_INQUIRY; 77 $model->type = self::TYPE_INQUIRY;
70 $model->ref_ids = $id; 78 $model->ref_ids = $id;
71 $model->send_time = $send_time; 79 $model->send_time = $send_time;
72 - $model->content = '[09:00] 您的全球搜网站收到来自【' . $country . '】的询盘信息,请登录后台或APP进行查看!'; 80 + $model->content = '[09:00] 您的全球搜网站收到来自【' . $country . $name . '】的询盘信息,请登录后台或APP进行查看!';
73 }else{ 81 }else{
74 $ref_ids = explode(',', $model->ref_ids); 82 $ref_ids = explode(',', $model->ref_ids);
75 $ref_ids[] = $id; 83 $ref_ids[] = $id;
@@ -160,7 +160,8 @@ class SyncSubmitTaskService @@ -160,7 +160,8 @@ class SyncSubmitTaskService
160 160
161 //推送企微消息 161 //推送企微消息
162 try { 162 try {
163 - MessagePush::addInquiryMessage($id, $data['project_id'], $data['country'], $data['submit_at']); 163 + $name = empty($data['data']['name']) ? '' : ' ' . $data['data']['name'];
  164 + MessagePush::addInquiryMessage($id, $data['project_id'], $data['country'], $name, $data['submit_at']);
164 }catch (\Exception $e){ 165 }catch (\Exception $e){
165 LogUtils::error('询盘消息'.$id.'写入企微消息队列失败' . $e->getMessage()); 166 LogUtils::error('询盘消息'.$id.'写入企微消息队列失败' . $e->getMessage());
166 } 167 }