12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\monitor\controller;
- use think\Cache;
- use app\common\service\MailService;
- use app\common\service\HelperService;
- use app\common\service\JGSmsService;
- /**
- * 短信发送队列
- * Class Smspop
- */
- class Smspop extends Basepop
- {
- public $_listKey = 'sms_list';
- public $_Account = null;
- public function start(){
- $this->main($this->_listKey, 20, 'JGSMS发送队列');
- }
- public function mainFunc($requestArr){
- try{
-
- HelperService::$_startExecTime = microtime(true);
- HelperService::$_sysParams = $requestArr;
-
- $this->_Account = $this->getKey($requestArr['companyCode'],false);//不验证参数
-
- if(empty($this->_Account['JSMS_appKey']) || empty($this->_Account['JSMS_masterSecret'])){
-
- $returnData = [
- 'account'=>$this->_Account,
- 'return'=>'丢弃'
- ];
- HelperService::addLog($returnData,'redis-sms',"JGSMS");
- return true;
- }
-
- $smsService = new JGSmsService($this->_Account['JSMS_appKey'],$this->_Account['JSMS_masterSecret']);
- $res = $smsService->sendMessage($requestArr['mobile'],$requestArr['temp_id'],$requestArr['temp_para']);
-
- HelperService::addLog($res,'redis-sms',"JGSMS");
-
- return @json_decode($res,true);
-
- } catch (\Exception $ex){
- $mailService = new MailService();
- $mailService->send('leo',"JGSMS出队异常","",$ex->getMessage(),[['mail'=>'2990412861@qq.com','name'=>'leo.xie']]);
- }
- }
-
- public function stop(){
- Cache::rm($this->_listKey.'_pop_program');
- echo "restart success\n";
- }
-
- public function getCache(){
- $salesList = Cache::get($this->_listKey.'_pop_program');
- var_dump($salesList);
- }
- }
|