12345678910111213141516171819202122232425262728293031323334 |
- <?php
- namespace ln\listens;
- use app\common\repositories\system\sms\SmsRecordRepository;
- use ln\interfaces\ListenerInterface;
- use ln\services\TimerService;
- use ln\services\YunxinSmsService;
- use Swoole\Timer;
- class SyncSmsResultCodeListen extends TimerService implements ListenerInterface
- {
- public function handle($event): void
- {
- $this->tick(1000 * 60 * 5, function () {
- $smsRecordRepository = app()->make(SmsRecordRepository::class);
- $time = date('Y-m-d H:i:s', strtotime("- 10 minutes"));
- $ids = $smsRecordRepository->getTimeOutIds($time);
- if (count($ids)) return;
- $list = (array)YunxinSmsService::create()->getStatus($ids);
- foreach ($list as $item) {
- if (isset($item['id'])) {
- if ($item['resultcode'] == '' || $item['resultcode'] == null) $item['resultcode'] = 134;
- $smsRecordRepository->updateRecordStatus($item['id'], $item['resultcode']);
- }
- }
- });
- }
- }
|