作者 赵彬吉
... ... @@ -28,7 +28,7 @@ class RemainDay extends Command
* @var 按上线时间统计
*/
protected $projectId = [
1434,1812,276,596
1434,1812,276
];//需要单独处理的项目
/**
... ...
... ... @@ -14,11 +14,8 @@ use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Mail;
/**
*
* Class WorkchatMessageSend
* @package App\Console\Commands
* @author zbj
* @date 2023/11/28
* @package App\Console\Commands\Task
*/
class WorkchatMessageSend extends Command
{
... ...
... ... @@ -56,20 +56,38 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>['in',[1646]]]);
$list = $projectModel->list(['id'=>['in',[1799]]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$this->getProduct();
// $this->getProduct();
// $this->setProductKeyword();
// $this->getBlog();
// $this->setCustomRoute($v['id']);
$this->editProductAlt();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
}
public function editProductAlt(){
$productModel = new Product();
$lists = $productModel->list(['status'=>1],'id',['id','route','thumb','gallery']);
foreach ($lists as $k => $v){
$v['thumb']['alt'] = $v['route'];
if(!empty($v['gallery'])){
foreach ($v['gallery'] as $keys => $values){
$values = (array)$values;
$values['alt'] = $v['route'];
$v['gallery'][$keys] = $values;
}
}
$productModel->edit(['thumb'=>json_encode($v['thumb'],true),'gallery'=>json_encode($v['gallery'],true)],['id'=>$v['id']]);
}
return true;
}
public function setCustomRoute($project_id){
$customModel = new CustomModuleContent();
$list = $customModel->list();
... ...
... ... @@ -12,6 +12,7 @@ namespace App\Http\Controllers\Bside\BCom;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Http\Controllers\Bside\BaseController;
use App\Jobs\UpdatePageJob;
use App\Models\Com\Notify;
use App\Models\Com\UpdateLog;
use App\Models\Com\UpdateNotify;
... ... @@ -107,7 +108,7 @@ class CNoticeController extends BaseController
}else{
//其他服务器:请求对应C端接口
$c_url = $this->user['domain'].'api/update_page/';
$param = [
$c_param = [
'project_id' => $this->user['project_id'],
'type' => $type,
'route' => $route,
... ... @@ -115,10 +116,10 @@ class CNoticeController extends BaseController
'language'=> $language,
'is_sitemap' => $is_sitemap
];
http_post($c_url, json_encode($param));
// $shell = 'curl -X POST ' . escapeshellarg($c_url) . ' -H "Content-Type: application/json"' .
// ' -d ' . escapeshellarg(json_encode($param)) . ' > /dev/null 2>&1 &';
// shell_exec($shell);
// http_post($c_url, json_encode($c_param));
//2024-10-11:改为异步请求
UpdatePageJob::dispatch(['c_url'=>$c_url,'c_params'=>json_encode($c_param)]);
}
$this->response('更新中请稍后, 更新完成将会发送站内信通知更新结果!');
}
... ...
... ... @@ -252,7 +252,7 @@ class CustomTemplateLogic extends BaseLogic
$this->setTemplateLog($bSettingInfo['template_id'] ?? 0,$html,$this->param['id']);
//通知
$this->addUpdateNotify(RouteMap::SOURCE_PAGE,$info['url']);
$this->curlDelRoute(['route'=>$info['url'],'new_route'=>$info['url']]);
$this->curlDelRoute(['old_route'=>$info['url'],'new_route'=>$info['url']]);
return $this->success();
}
... ... @@ -391,7 +391,7 @@ class CustomTemplateLogic extends BaseLogic
}
}
$this->addUpdateNotify(RouteMap::SOURCE_PAGE,$route);
$this->curlDelRoute(['route'=>$info['url'],'new_route'=>$route]);
$this->curlDelRoute(['old_route'=>$info['url'],'new_route'=>$route]);
return true;
}
... ... @@ -436,7 +436,7 @@ class CustomTemplateLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_PAGE, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id' => $id], ['id', 'url']);
$this->curlDelRoute(['route'=>$info['url']]);
$this->curlDelRoute(['old_route'=>$info['url']]);
return $this->success();
}
... ...
... ... @@ -186,7 +186,7 @@ class InitHtmlLogic extends BaseLogic
}
$this->saveTemplateCom($this->param['html'],$template_id,$this->param['type'],$is_list,$is_custom);
$route = RouteMap::getRoute('all',0,$this->user['project_id']);
$this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
$this->curlDelRoute(['old_route'=>$route,'new_route'=>$route]);
return $this->success();
}
... ...
... ... @@ -204,7 +204,7 @@ class BlogCategoryLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','alias']);
$this->curlDelRoute(['route'=>$info['alias']]);
$this->curlDelRoute(['old_route'=>$info['alias']]);
return $this->success();
}
... ...
... ... @@ -159,7 +159,7 @@ class BlogLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_BLOG, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','url']);
$this->curlDelRoute(['route'=>$info['url']]);
$this->curlDelRoute(['old_route'=>$info['url']]);
return $this->success();
}
... ...
... ... @@ -180,7 +180,7 @@ class CustomModuleCategoryLogic extends BaseLogic
$info = $this->model->read(['id' => $id], ['id', 'route']);
if ($info['route'] != $route) {
$this->addUpdateNotify(RouteMap::SOURCE_MODULE_CATE,$route);
$this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]);
$this->curlDelRoute(['old_route'=>$info['route'],'new_route'=>$route]);
}
return true;
}
... ... @@ -223,7 +223,7 @@ class CustomModuleCategoryLogic extends BaseLogic
}
RouteMap::delRoute(RouteMap::SOURCE_MODULE_CATE, $id, $this->user['project_id']);
//通知
$this->curlDelRoute(['route'=>$info['route']]);
$this->curlDelRoute(['old_route'=>$info['route']]);
return $this->success();
}
... ...
... ... @@ -247,7 +247,7 @@ class CustomModuleContentLogic extends BaseLogic
//生成一条删除路由记录
$info = $this->model->read(['id' => $id], ['id', 'route']);
$this->addUpdateNotify(RouteMap::SOURCE_MODULE,$route);
$this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]);
$this->curlDelRoute(['old_route'=>$info['route'],'new_route'=>$route]);
return true;
}
... ... @@ -354,7 +354,7 @@ class CustomModuleContentLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_MODULE, $id, $this->user['project_id']);
//通知
$info = $this->model->read(['id' => $id], ['id', 'route']);
$this->curlDelRoute(['route'=>$info['route']]);
$this->curlDelRoute(['old_route'=>$info['route']]);
return $this->success();
}
... ...
... ... @@ -218,7 +218,7 @@ class NewsCategoryLogic extends BaseLogic
//删除路由映射
RouteMap::delRoute(RouteMap::SOURCE_NEWS_CATE, $id, $this->user['project_id']);
$info = $this->model->read(['id'=>$id],['id','alias']);
$this->curlDelRoute(['route'=>$info['alias']]);
$this->curlDelRoute(['old_route'=>$info['alias']]);
return $this->success();
}
... ...
... ... @@ -290,7 +290,7 @@ class NewsLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_NEWS, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id' => $id], ['id', 'url']);
$this->curlDelRoute(['route'=>$info['url']]);
$this->curlDelRoute(['old_route'=>$info['url']]);
return $this->success();
}
... ...
... ... @@ -194,7 +194,7 @@ class CategoryLogic extends BaseLogic
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
if($info !== false){
$this->curlDelRoute(['route'=>$info['route']]);
$this->curlDelRoute(['old_route'=>$info['route']]);
}
return $this->success();
}
... ...
... ... @@ -205,7 +205,7 @@ class KeywordLogic extends BaseLogic
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
if($info !== false){
$this->curlDelRoute(['route'=>$info['route']]);
$this->curlDelRoute(['old_route'=>$info['route']]);
}
return $this->success();
}
... ...
... ... @@ -387,7 +387,7 @@ class ProductLogic extends BaseLogic
RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
//生成一条删除路由记录
$info = $this->model->read(['id'=>$id],['id','route']);
$this->curlDelRoute(['route'=>$info['route']]);
$this->curlDelRoute(['old_route'=>$info['route']]);
return $this->success();
}
... ...
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class UpdatePageJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $tries = 3; // 可配置任务重试次数
protected $param;
/**
* Create a new job instance.
*
* @param $data
* @return void
*/
public function __construct($data)
{
$this->param = $data;
}
/**
* Execute the job.
* B端更新页面异步请求
* @return bool
*/
public function handle()
{
$c_url = $this->param['c_url'];
$c_params = $this->param['c_params'];
try {
$re = http_post($c_url, $c_params, [], true);
if (isset($re['status']) && $re['status'] == 200) {
$this->output($c_url . ' | 请求成功');
} else {
$this->output($c_url . ' | ' . ($re['message'] ?? '未返回失败原因'));
}
} catch (\Exception $e) {
$this->output($c_url . ' | 请求异常:' . $e->getMessage());
}
return true;
}
/**
* 输出处理日志
* @param $message
*/
public function output($message)
{
echo date('Y-m-d H:i:s') . ' | ' . $message . PHP_EOL;
}
}
... ...
... ... @@ -33,7 +33,15 @@ class MessagePush extends Base
protected $table = 'gl_workchat_message_push';
public static function addInquiryMessage($id, $project_id, $country, $submit_at){
/**
* @param $id
* @param $project_id
* @param $country
* @param $name
* @param $submit_at
* @return bool
*/
public static function addInquiryMessage($id, $project_id, $country, $name, $submit_at){
if(!ProjectServer::useProject($project_id)){
return false;
}
... ... @@ -56,7 +64,7 @@ class MessagePush extends Base
$model->friend_id = $friend_id;
$model->type = self::TYPE_INQUIRY;
$model->ref_ids = $id;
$model->content = '[' . date('H:i', strtotime($submit_at)) . '] 您的全球搜网站收到来自【' . $country . '】的询盘信息,请登录后台或APP进行查看!';
$model->content = '[' . date('H:i', strtotime($submit_at)) . '] 您的全球搜网站收到来自【' . $country . $name . '】的询盘信息,请登录后台或APP进行查看!';
}else{
//定时发送时间
$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
$model->type = self::TYPE_INQUIRY;
$model->ref_ids = $id;
$model->send_time = $send_time;
$model->content = '[09:00] 您的全球搜网站收到来自【' . $country . '】的询盘信息,请登录后台或APP进行查看!';
$model->content = '[09:00] 您的全球搜网站收到来自【' . $country . $name . '】的询盘信息,请登录后台或APP进行查看!';
}else{
$ref_ids = explode(',', $model->ref_ids);
$ref_ids[] = $id;
... ...
... ... @@ -160,7 +160,8 @@ class SyncSubmitTaskService
//推送企微消息
try {
MessagePush::addInquiryMessage($id, $data['project_id'], $data['country'], $data['submit_at']);
$name = empty($data['data']['name']) ? '' : ' ' . $data['data']['name'];
MessagePush::addInquiryMessage($id, $data['project_id'], $data['country'], $name, $data['submit_at']);
}catch (\Exception $e){
LogUtils::error('询盘消息'.$id.'写入企微消息队列失败' . $e->getMessage());
}
... ...