进一步完成
This commit is contained in:
72
app/command/QuerySmsTempStatus.php
Normal file
72
app/command/QuerySmsTempStatus.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace app\command;
|
||||
|
||||
use app\model\AlibabaSms;
|
||||
use support\Log;
|
||||
use support\think\Db;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use ZipArchive;
|
||||
|
||||
|
||||
// 查询短信模版审核状态
|
||||
class QuerySmsTempStatus extends Command
|
||||
{
|
||||
protected static $defaultName = 'querysmstempstatus';
|
||||
protected static $defaultDescription = 'querysmstempstatus';
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->addArgument('name', InputArgument::OPTIONAL, 'Name description');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询模版审核状态 1小时执行一次
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
* @return int
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$list = Db::table('sms_shop_template')->where(['status' => 1])->select()->toArray();
|
||||
Log::info('短信模版审核查询开始->' . json_encode($list));
|
||||
if($list) {
|
||||
foreach ($list as $k => $value) {
|
||||
$data = [
|
||||
'TemplateCode' => $value['template_code']
|
||||
];
|
||||
$res = AlibabaSms::GetSmsTemplate($data);
|
||||
if($res['Code'] == 'OK') {
|
||||
$msg = '';
|
||||
if($res['TemplateStatus'] == 0) {
|
||||
$status = 1;
|
||||
}elseif ($res['TemplateStatus'] == 1) {
|
||||
$status = 2;
|
||||
}elseif ($res['TemplateStatus'] == 2) {
|
||||
$status = -1;
|
||||
$msg = $res['AuditInfo']['RejectInfo'];
|
||||
}elseif ($res['TemplateStatus'] == 10) {
|
||||
$status = -1;
|
||||
$msg = '取消审核';
|
||||
}
|
||||
$update_data = [
|
||||
'status' => $status,
|
||||
'fail_msg' => $msg?:$msg,
|
||||
];
|
||||
$update_status = Db::table('sms_shop_template')->where(['id' => $value['id']])->update($update_data);
|
||||
Log::info('模版查询完毕数据库更新结果---》[ID]' . $value['id'] . '更新结果-->' . $update_status . '-->更新数据 . ' . json_encode($update_data));
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user