通知
This commit is contained in:
parent
6045d93716
commit
696919950d
|
|
@ -25,56 +25,54 @@ class NoticeLogic
|
|||
|
||||
public function callIt($log)
|
||||
{
|
||||
try {
|
||||
$dispatch = OrderDispatch::get($log->dispatch_id);
|
||||
//1=派单,2=提前通知,3=超时通知
|
||||
$ttsCode = null;
|
||||
$dispatch->tts_check_time = date('Y-m-d H:i:s',time()+5*60);
|
||||
if($log->type == 1)
|
||||
{
|
||||
$dispatch->tts_notice = 1;
|
||||
if($dispatch->type == 1){
|
||||
$ttsCode = self::TTS_DISPATCH1;
|
||||
$dispatch->save();
|
||||
}else{
|
||||
$ttsCode = self::TTS_DISPATCH2;
|
||||
}
|
||||
}elseif($log->type == 2)
|
||||
{
|
||||
$dispatch->tts_notice = 2;
|
||||
$ttsCode = self::TTS_GOGOGO;
|
||||
}elseif($log->type == 3){
|
||||
$dispatch->tts_notice = 3;
|
||||
$ttsCode = self::TTS_OVER_FINISHED;
|
||||
}
|
||||
if(empty($ttsCode)){
|
||||
$log->status = -1;
|
||||
$log->content = 'TTSID为空';
|
||||
$log->save();
|
||||
return;
|
||||
}
|
||||
|
||||
$status = config('alibaba_dyvms.status');
|
||||
|
||||
if($status){
|
||||
$reponse = DyvmsService::getInstance()->call($dispatch->worker_tel, $ttsCode, md5(time()));
|
||||
|
||||
if($reponse->statusCode == 200 && $reponse->body->code == 'OK'){
|
||||
$log->status = 1;
|
||||
$log->callId = $reponse->body->callId;
|
||||
$log->save();
|
||||
}else{
|
||||
$log->status = -1;
|
||||
$log->content = $reponse->body->message;
|
||||
$log->save();
|
||||
}
|
||||
$dispatch = OrderDispatch::get($log->dispatch_id);
|
||||
//1=派单,2=提前通知,3=超时通知
|
||||
$ttsCode = null;
|
||||
$dispatch->tts_check_time = date('Y-m-d H:i:s',time()+5*60);
|
||||
if($log->type == 1)
|
||||
{
|
||||
$dispatch->tts_notice = 1;
|
||||
if($dispatch->type == 1){
|
||||
$ttsCode = self::TTS_DISPATCH1;
|
||||
$dispatch->save();
|
||||
}else{
|
||||
throw new Exception('语音通知服务未开启');
|
||||
$ttsCode = self::TTS_DISPATCH2;
|
||||
}
|
||||
}catch (Exception $exception){
|
||||
}elseif($log->type == 2)
|
||||
{
|
||||
$dispatch->tts_notice = 2;
|
||||
$ttsCode = self::TTS_GOGOGO;
|
||||
}elseif($log->type == 3){
|
||||
$dispatch->tts_notice = 3;
|
||||
$ttsCode = self::TTS_OVER_FINISHED;
|
||||
}
|
||||
if(empty($ttsCode)){
|
||||
$log->status = -1;
|
||||
$log->content = $exception->getMessage();
|
||||
$log->content = 'TTSID为空';
|
||||
$log->save();
|
||||
return;
|
||||
}
|
||||
|
||||
$status = config('alibaba_dyvms.status');
|
||||
|
||||
if($status){
|
||||
$reponse = DyvmsService::getInstance()->call($dispatch->worker_tel, $ttsCode, md5(time()));
|
||||
|
||||
if($reponse->statusCode == 200 && $reponse->body->code == 'OK'){
|
||||
$log->status = 1;
|
||||
$log->callId = $reponse->body->callId;
|
||||
$log->save();
|
||||
}else{
|
||||
$log->status = -1;
|
||||
$log->content = $reponse->body->message;
|
||||
$log->save();
|
||||
}
|
||||
}else{
|
||||
$log->status = -1;
|
||||
$log->content = 'TTSID为空';
|
||||
$log->save();
|
||||
//throw new Exception('语音通知服务未开启');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,13 +11,16 @@ use app\common\Logic\NoticeLogic;
|
|||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class CheckOrdeRecordCommand extends Command
|
||||
{
|
||||
protected $title = 'dispatch跟进记录通知,每天9点1分执行';
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('check:dispatch-record-notice')
|
||||
->setDescription('dispatch跟进记录通知,每天9点1分执行');
|
||||
->setDescription($this->title);
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output){
|
||||
|
|
@ -29,32 +32,41 @@ class CheckOrdeRecordCommand extends Command
|
|||
->chunk(100, function ($list) {
|
||||
$ids = [];
|
||||
$dispatchIds = [];
|
||||
foreach ($list as $item) {
|
||||
$ids[] = $item->id;
|
||||
$dispatchIds[] = $item->dispatch_id;
|
||||
try {
|
||||
foreach ($list as $item) {
|
||||
$ids[] = $item->id;
|
||||
$dispatchIds[] = $item->dispatch_id;
|
||||
|
||||
$existDispatchIds = [];
|
||||
$existDispatchIds = [];
|
||||
|
||||
//修改状态
|
||||
if($item->need_notice == 1){ //需要通知
|
||||
if(in_array($item->dispatch_id,$existDispatchIds)){
|
||||
continue;
|
||||
//修改状态
|
||||
if($item->need_notice == 1){ //需要通知
|
||||
if(in_array($item->dispatch_id,$existDispatchIds)){
|
||||
continue;
|
||||
}
|
||||
$dispatch = OrderDispatch::get($item->dispatch_id,['orderb']);
|
||||
Message::create([
|
||||
'to_id' => $dispatch->admin_id,
|
||||
'type' => 1,
|
||||
'title' => '派单任务跟进提示',
|
||||
'content' => '【订单跟进提示】您有一条待跟进订单,订单编号:'.$dispatch->orderb->order_no.',请及时关注。'
|
||||
]);
|
||||
|
||||
$existDispatchIds[] = $item->dispatch_id;
|
||||
}
|
||||
$dispatch = OrderDispatch::get($item->dispatch_id,['orderb']);
|
||||
Message::create([
|
||||
'to_id' => $dispatch->admin_id,
|
||||
'type' => 1,
|
||||
'title' => '派单任务跟进提示',
|
||||
'content' => '【订单跟进提示】您有一条待跟进订单,订单编号:'.$dispatch->orderb->order_no.',请及时关注。'
|
||||
]);
|
||||
|
||||
$existDispatchIds[] = $item->dispatch_id;
|
||||
}
|
||||
OrderDispatchRecord::whereIn('id',$ids)->where('status',0)->update(['status'=>1]);
|
||||
$count = OrderDispatch::whereIn('id',$dispatchIds)->where('follow',1)->update(['follow'=>0]);
|
||||
echo 'count:'.$count.PHP_EOL;
|
||||
}catch (Exception $exception){
|
||||
Db::name('debug_log')->insert([
|
||||
'title' => $this->title,
|
||||
'content' => '错误内容:'.$exception->getMessage().',错误行:'. $exception->getLine().',错误文件:'. $exception->getFile(),
|
||||
'create_time' => date('Y-m-d H:i:s', time())
|
||||
]);
|
||||
}
|
||||
OrderDispatchRecord::whereIn('id',$ids)->where('status',0)->update(['status'=>1]);
|
||||
$count = OrderDispatch::whereIn('id',$dispatchIds)->where('follow',1)->update(['follow'=>0]);
|
||||
|
||||
echo 'count:'.$count.PHP_EOL;
|
||||
|
||||
});
|
||||
|
||||
$output->info('OVER');
|
||||
|
|
|
|||
|
|
@ -9,15 +9,17 @@ use app\common\Logic\OrderLogic;
|
|||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
use think\Hook;
|
||||
|
||||
class CheckOrderDispatchGotCommand extends Command
|
||||
{
|
||||
protected $title = '【自动派单未接单检测,五分钟未接单,重派派单】/【自动派单上门时间已到,未完成上门】,每分钟执行一次';
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('check:dispatch-toget')
|
||||
->setDescription('【自动派单未接单检测,五分钟未接单,重派派单】/【自动派单上门时间已到,未完成上门】,每分钟执行一次');
|
||||
->setDescription($this->title);
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output){
|
||||
|
|
@ -72,6 +74,11 @@ class CheckOrderDispatchGotCommand extends Command
|
|||
|
||||
echo 'arrive_count:'. $count. PHP_EOL;
|
||||
}catch (Exception $exception){
|
||||
Db::name('debug_log')->insert([
|
||||
'title' => $this->title,
|
||||
'content' => '错误内容:'.$exception->getMessage().',错误行:'. $exception->getLine().',错误文件:'. $exception->getFile(),
|
||||
'create_time' => date('Y-m-d H:i:s', time())
|
||||
]);
|
||||
echo $exception->getMessage(). PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,16 @@ use app\admin\model\OrderDispatch;
|
|||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class CheckSmsPlantCommand extends Command
|
||||
{
|
||||
protected $title = 'dispatch预约任务短信提醒,每5分钟执行一次';
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('check:dispatch-sms-plant')
|
||||
->setDescription('dispatch已预约任务短信提醒,每5分钟执行一次');
|
||||
->setDescription($this->title);
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output){
|
||||
|
|
@ -34,6 +36,12 @@ class CheckSmsPlantCommand extends Command
|
|||
}catch (Exception $exception){
|
||||
|
||||
echo '短信发送失败:'.$exception->getMessage().PHP_EOL;
|
||||
|
||||
Db::name('debug_log')->insert([
|
||||
'title' => $this->title,
|
||||
'content' => '错误内容:'.$exception->getMessage().',错误行:'. $exception->getLine().',错误文件:'. $exception->getFile(),
|
||||
'create_time' => date('Y-m-d H:i:s', time())
|
||||
]);
|
||||
}
|
||||
echo '短信发送完成:'.$item->id.PHP_EOL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,13 +11,18 @@ use app\common\Logic\NoticeLogic;
|
|||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class CheckTTSOverTimeCommand extends Command
|
||||
{
|
||||
|
||||
protected $title = 'dispatch超时未完成任务语音通知,每5分钟执行一次';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('check:dispatch-tts-overtime')
|
||||
->setDescription('dispatch超时未完成任务语音通知,每5分钟执行一次');
|
||||
->setDescription($this->title);
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output){
|
||||
|
|
@ -31,24 +36,34 @@ class CheckTTSOverTimeCommand extends Command
|
|||
->chunk(100, function ($list) {
|
||||
$ids = [];
|
||||
$logs = [];
|
||||
foreach ($list as $item) {
|
||||
$ids[] = $item->id;
|
||||
//修改状态
|
||||
$logs[] = [
|
||||
'dispatch_id' => $item->id,
|
||||
'order_id'=>$item->order_id,
|
||||
'type' => 3,
|
||||
'outid' => md5(time().rand(1000,9999).rand(1000,9999)),
|
||||
'create_time' => date('Y-m-d H:i:s'),
|
||||
'status' => 0,
|
||||
'update_time' => date('Y-m-d H:i:s')
|
||||
];
|
||||
(new TtsLog())->insertAll($logs);
|
||||
}
|
||||
if(!empty($ids)){
|
||||
$count = OrderDispatch::whereIn('id',$ids)->update(['follow'=>0,'tts_notice'=>3,'tts_check_time'=>date('Y-m-d H:i:s')]);
|
||||
echo $count.PHP_EOL;
|
||||
try {
|
||||
foreach ($list as $item) {
|
||||
$ids[] = $item->id;
|
||||
//修改状态
|
||||
$logs[] = [
|
||||
'dispatch_id' => $item->id,
|
||||
'order_id'=>$item->order_id,
|
||||
'type' => 3,
|
||||
'outid' => md5(time().rand(1000,9999).rand(1000,9999)),
|
||||
'create_time' => date('Y-m-d H:i:s'),
|
||||
'status' => 0,
|
||||
'update_time' => date('Y-m-d H:i:s')
|
||||
];
|
||||
(new TtsLog())->insertAll($logs);
|
||||
}
|
||||
if(!empty($ids)){
|
||||
$count = OrderDispatch::whereIn('id',$ids)->update(['follow'=>0,'tts_notice'=>3,'tts_check_time'=>date('Y-m-d H:i:s')]);
|
||||
echo $count.PHP_EOL;
|
||||
}
|
||||
|
||||
}catch (Exception $exception){
|
||||
Db::name('debug_log')->insert([
|
||||
'title' => $this->title,
|
||||
'content' => '错误内容:'.$exception->getMessage().',错误行:'. $exception->getLine().',错误文件:'. $exception->getFile(),
|
||||
'create_time' => date('Y-m-d H:i:s', time())
|
||||
]);
|
||||
}
|
||||
|
||||
});
|
||||
$output->info('OVER');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,13 +11,17 @@ use app\common\Logic\NoticeLogic;
|
|||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class CheckTTSPlantCommand extends Command
|
||||
{
|
||||
protected $title = 'dispatch预约任务语音提醒,每5分钟执行一次';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('check:dispatch-tts-plant')
|
||||
->setDescription('dispatch已预约任务语音提醒,每5分钟执行一次');
|
||||
->setDescription($this->title);
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output){
|
||||
|
|
@ -33,18 +37,27 @@ class CheckTTSPlantCommand extends Command
|
|||
$ids = [];
|
||||
$logs = [];
|
||||
foreach ($list as $item) {
|
||||
$ids[] = $item->id;
|
||||
//修改状态
|
||||
$logs[] = [
|
||||
'dispatch_id' => $item->id,
|
||||
'order_id'=>$item->order_id,
|
||||
'type' => 2,
|
||||
'outid' => md5(time().rand(1000,9999).rand(1000,9999)),
|
||||
'create_time' => date('Y-m-d H:i:s'),
|
||||
'status' => 0,
|
||||
'update_time' => date('Y-m-d H:i:s')
|
||||
];
|
||||
(new TtsLog())->insertAll($logs);
|
||||
|
||||
try {
|
||||
$ids[] = $item->id;
|
||||
//修改状态
|
||||
$logs[] = [
|
||||
'dispatch_id' => $item->id,
|
||||
'order_id'=>$item->order_id,
|
||||
'type' => 2,
|
||||
'outid' => md5(time().rand(1000,9999).rand(1000,9999)),
|
||||
'create_time' => date('Y-m-d H:i:s'),
|
||||
'status' => 0,
|
||||
'update_time' => date('Y-m-d H:i:s')
|
||||
];
|
||||
(new TtsLog())->insertAll($logs);
|
||||
}catch (Exception $exception){
|
||||
Db::name('debug_log')->insert([
|
||||
'title' => $this->title,
|
||||
'content' => '错误内容:'.$exception->getMessage().',错误行:'. $exception->getLine().',错误文件:'. $exception->getFile(),
|
||||
'create_time' => date('Y-m-d H:i:s', time())
|
||||
]);
|
||||
}
|
||||
}
|
||||
if(!empty($ids)){
|
||||
$count = OrderDispatch::whereIn('id',$ids)->update(['tts_notice'=>2,'tts_check_time'=>date('Y-m-d H:i:s')]);
|
||||
|
|
|
|||
|
|
@ -11,13 +11,17 @@ use app\common\Logic\NoticeLogic;
|
|||
use think\console\Command;
|
||||
use think\console\Input;
|
||||
use think\console\Output;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
|
||||
class CheckTTSTaskCommand extends Command
|
||||
{
|
||||
protected $title = 'dispatch语音发送任务,每1分钟执行一次';
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('check:dispatch-tts-task')
|
||||
->setDescription('语音发送任务,每1分钟执行一次');
|
||||
->setDescription($this->title);
|
||||
}
|
||||
|
||||
protected function execute(Input $input, Output $output){
|
||||
|
|
@ -26,7 +30,19 @@ class CheckTTSTaskCommand extends Command
|
|||
$Model->where('status','=',0)
|
||||
->chunk(100, function ($list)use($ttsService) {
|
||||
foreach ($list as $item) {
|
||||
$ttsService->callIt($item);
|
||||
try {
|
||||
$ttsService->callIt($item);
|
||||
}catch (Exception $exception){
|
||||
$item->status = -1;
|
||||
$item->content = $exception->getMessage();
|
||||
$item->save();
|
||||
|
||||
Db::name('debug_log')->insert([
|
||||
'title' => $this->title,
|
||||
'content' => '错误内容:'.$exception->getMessage().',错误行:'. $exception->getLine().',错误文件:'. $exception->getFile(),
|
||||
'create_time' => date('Y-m-d H:i:s', time())
|
||||
]);
|
||||
}
|
||||
echo $item->id.PHP_EOL;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user