<?php
namespace app\common\listener;

use app\common\logic\ExternalPlatformLogic;
use think\facade\Log;

/**
 * 外部平台通知事件监听
 * Class ExternalPlatformListener
 * @package app\listener
 */
class ExternalPlatformListener
{
    public function handle($params)
    {
        try {
            // send_code 配置
            if (empty($params['send_code'])) {
                throw new \Exception('场景不能为空');
            }
            $result = ExternalPlatformLogic::handleByScene($params);
            if (false === $result) {
                throw new \Exception(ExternalPlatformLogic::getError());
            }
            return true;
        } catch (\Exception $e) {
            Log::write($params['send_code'].'：执行失败:'.$e->getMessage());
            return $e->getMessage();
        }
    }
}