作者 刘锟

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

... ... @@ -36,16 +36,9 @@ class InitKeywordComment extends Command
public $number = 100;
public function handle(){
$projectModel = new Project();
$lists = $projectModel->list(['delete_status' => 0,'id'=>['<',1368],'project_type'=>0,'extend_type'=>0,'type'=>['in',[1,2,3,4,6]]], 'id', ['id']);
foreach ($lists as $val) {
echo date('Y-m-d H:i:s') . '开始--项目的id:' . $val['id'] . PHP_EOL;
$this->_action($val['id']);
}
return true;
$keywordCommentModel = new AggregateKeywordComment();
while (true){
$list = NoticeLog::where('type', NoticeLog::TYPE_INIT_KEYWORD_COMMON)->where('status', NoticeLog::STATUS_PENDING)->get();
$list = NoticeLog::where('type', NoticeLog::TYPE_INIT_KEYWORD_COMMENT)->where('status', NoticeLog::STATUS_PENDING)->get();
if(empty($list)){
sleep(200);
continue;
... ...
<?php
namespace App\Console\Commands\WorkOrder;
use App\Models\ProjectAssociation\ProjectAssociation;
use App\Models\Workchat\MessagePush;
use App\Models\WorkOrder\Tickets;
use Illuminate\Console\Command;
class PushNotify extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'workorder:push-notify';
/**
* The console command description.
*
* @var string
*/
protected $description = 'tickets push notify';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
while (true) {
try {
$tick = Tickets::where('ding', 0)
->where('submit_side', 2)
// ->where('project_id', 1)
->first();
if (!$tick) {
echo now() . " WARNING | 没有待推送的工单\n";
sleep(3);
continue;
}
$project = $tick->project;
if ($project->version != 6 || $project->is_del == 1) {
echo now() . " WARNING | 项目版本或状态异常 \n";
$tick->ding = 1;
$tick->save();
continue;
}
$message_push = new MessagePush();
$message_push->project_id = $project->table_id;
$message_push->friend_id = ProjectAssociation::where('project_id', $project->table_id)
->where('status', ProjectAssociation::STATUS_NORMAL)
->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT)
->value('friend_id');
if (empty($message_push->friend_id))
{
echo now() . " WARNING | 项目ID:{$project->table_id} 没有绑定企微群\n";
$tick->ding = 1;
$tick->save();
continue;
}
$message_push->content_type = 'Link';
$message_push->content = json_encode([
'title' => '工单查看 - ' . $project->company_name,
'desc' => $tick->title,
'size' => 0,
'thumbSize' => 0,
'thumbUrl' => 'https://www.cmer.com/uploads/logo1.png',
'url' => 'https://oa.quanqiusou.cn/tickets?project_id='.$project->uuid
], JSON_UNESCAPED_UNICODE);
$message_push->send_time = now();
$message_push->type = MessagePush::TYPE_TICKET;
$message_push->save();
$tick->ding = 1;
$tick->save();
echo now() . " INFO | 项目ID:{$project->table_id} 工单ID:{$tick->id} 推送成功\n";
}catch (\Exception $exception){
echo date('Y-m-d H:i:s')." ERROR | ".$exception->getMessage()."\n";
break;
}
}
}
}
... ...
... ... @@ -3,7 +3,6 @@
namespace App\Console\Commands\WorkOrder;
use App\Models\WorkOrder\TicketLog;
use App\Models\WorkOrder\WorkOrderLog;
use App\Services\DingTalkService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
... ...
... ... @@ -26,7 +26,7 @@ class AsideTicketController extends BaseController
'logs.engineer:id,name',
'project',
])
->when($validated['engineer_id'], function ($query) use ($validated) {
->when(!empty($validated['engineer_id']), function ($query) use ($validated) {
// 查 gl_tickets 表 submit_user_id 或 gl_ticket_logs 表 engineer_id
$engineerId = $validated['engineer_id'];
return $query->where(function ($q) use ($engineerId) {
... ...
... ... @@ -59,16 +59,23 @@ class EnterpriseProductLogic extends BaseLogic
ProjectServer::useProject($this->param['project_id']);
$linkModel = new LinkData();
$data = [];
$count = count($this->param['data']);
$error_num = 0;
foreach ($this->param['data'] as $v){
if(empty($v['send_time'])){
$error_num++;
continue;
}
$data[] = [
'url'=>$v['url'],
'da_values'=>$v['da_values'],
'send_time'=>$v['send_time'] ?? date('Y-m-d H:i:s')
];
}
if(!empty($data)){
$linkModel->insertAll($data);
}
DB::disconnect('custom_mysql');
return $this->success();
return $this->success(['success'=>'成功数量:'.$count-$error_num,'error'=>'失败数量:'.$error_num]);
}
}
... ...
... ... @@ -432,7 +432,7 @@ class ProjectLogic extends BaseLogic
$keywordCommentModel = new AggregateKeywordComment();
$commentNum = $keywordCommentModel->counts(['project_id'=>$param['id']]);
if(empty($commentNum)){
NoticeLog::createLog(NoticeLog::TYPE_INIT_KEYWORD_COMMON, ['project_id' => $param['id']]);
NoticeLog::createLog(NoticeLog::TYPE_INIT_KEYWORD_COMMENT, ['project_id' => $param['id']]);
}
}
if($param['type'] == Project::TYPE_FIVE){
... ...
... ... @@ -52,7 +52,12 @@ class CustomTemplateLogic extends BaseLogic
if(!empty($info['html'])){
$info['is_renovation'] = 1;
}else{
$info['html'] = $info['text'];
if(strpos($info['text'],"<main>") === false){
$info['html'] = "<main>".$info['text']."</main>";
}else{
$info['html'] = $info['text'];
}
$info['html_style'] = "<style id='globalsojs-styles'></style>";
$info['is_renovation'] = 0;
}
$info['image'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
... ...
... ... @@ -13,7 +13,7 @@ class NoticeLog extends Base
const TYPE_PROJECT = 'project';
const TYPE_RANK_DATA = 'rank_data';
const TYPE_INIT_PROJECT = 'init_project';
const TYPE_INIT_KEYWORD_COMMON = 'init_keyword_common';//聚合页关键词评论
const TYPE_INIT_KEYWORD_COMMENT = 'init_keyword_comment';//聚合页关键词评论
const TYPE_GENERATE_COUNT_CHARTS = 'generate_count_charts';//聚合页关键字图表生成
const TYPE_COPY_PROJECT = 'copy_project';
const TYPE_INIT_KEYWORD = 'init_keyword';
... ...
... ... @@ -27,6 +27,7 @@ class MessagePush extends Base
const TYPE_INQUIRY = 'inquiry';
const TYPE_WEEK = 'week';
const TYPE_TICKET = 'ticket';
//设置关联表名
/**
* @var mixed
... ...
... ... @@ -28,8 +28,10 @@ class AiVideoService
if($project_id){
$projectAiSettingModel = new ProjectAiSetting();
$aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$project_id]);
$this->mch_id = $aiSettingInfo['mch_id'];
$this->key = $aiSettingInfo['key'];
if($aiSettingInfo !== false){
$this->mch_id = $aiSettingInfo['mch_id'];
$this->key = $aiSettingInfo['key'];
}
}
}
... ...