Smspop.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\monitor\controller;
  3. use think\Cache;
  4. use app\common\service\MailService;
  5. use app\common\service\HelperService;
  6. use app\common\service\JGSmsService;
  7. /**
  8. * 短信发送队列
  9. * Class Smspop
  10. */
  11. class Smspop extends Basepop
  12. {
  13. public $_listKey = 'sms_list';
  14. public $_Account = null;
  15. public function start(){
  16. $this->main($this->_listKey, 20, 'JGSMS发送队列');
  17. }
  18. public function mainFunc($requestArr){
  19. try{
  20. HelperService::$_startExecTime = microtime(true);
  21. HelperService::$_sysParams = $requestArr;
  22. $this->_Account = $this->getKey($requestArr['companyCode'],false);//不验证参数
  23. if(empty($this->_Account['JSMS_appKey']) || empty($this->_Account['JSMS_masterSecret'])){
  24. $returnData = [
  25. 'account'=>$this->_Account,
  26. 'return'=>'丢弃'
  27. ];
  28. HelperService::addLog($returnData,'redis-sms',"JGSMS");
  29. return true;
  30. }
  31. $smsService = new JGSmsService($this->_Account['JSMS_appKey'],$this->_Account['JSMS_masterSecret']);
  32. $res = $smsService->sendMessage($requestArr['mobile'],$requestArr['temp_id'],$requestArr['temp_para']);
  33. HelperService::addLog($res,'redis-sms',"JGSMS");
  34. return @json_decode($res,true);
  35. } catch (\Exception $ex){
  36. $mailService = new MailService();
  37. $mailService->send('leo',"JGSMS出队异常","",$ex->getMessage(),[['mail'=>'2990412861@qq.com','name'=>'leo.xie']]);
  38. }
  39. }
  40. public function stop(){
  41. Cache::rm($this->_listKey.'_pop_program');
  42. echo "restart success\n";
  43. }
  44. public function getCache(){
  45. $salesList = Cache::get($this->_listKey.'_pop_program');
  46. var_dump($salesList);
  47. }
  48. }