<?php

declare (strict_types = 1);
namespace library\utils;


use library\utils\Sms\AliSms;
use library\utils\Sms\TencentSms;

class Sms {

    /**
     * 发送模板短信【前台使用】
     * @param $tel
     * @param $code
     * @param $sassid
     * @param array $array
     * @return mixed
     */
   public function SmsCode($tel, $code,$sassid, $array = array()) {
        $data = $this->SmsSendTpl($tel, $code,$sassid, $array);
        if ($data['Code'] == 'OK') {
            $r['status'] = 1;
            $r['error'] = 'ok';
        } else {
            $r['status'] = -1;
            $r['error'] = $data['Message'];
        }
        return $r;
    }


    /**
     * 发送模板的数据
     * @param $tel 手机号码
     * @param $code code
     * @param $sassid
     * @param array $array
     * @return mixed|null
     */
    function SmsSendTpl($tel, $code,$sassid, $array = array()) {
       // $aliSms = new AliSms;
      //  $r = $aliSms->SmsSendTmplete($tel,$code,$sassid,$array);
        $tencent = new TencentSms();
        $r = $tencent->SmsSendTmplete($tel,$code,$sassid,$array);
        return $r;
    }




}
