dggzichahu/application/api/logic/SmsLogic.php

33 lines
998 B
PHP
Executable File

<?php
// +----------------------------------------------------------------------
// | 宏驰云科技开发团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | Author: HcyShop-kiki
// +----------------------------------------------------------------------
namespace app\api\logic;
use app\common\model\NoticeSetting;
use think\facade\Hook;
class SmsLogic{
public static function send($mobile,$key, $user_id = 0){
try{
$code = create_sms_code(4);
$send_data = [
'key' => NoticeSetting::SMS_SCENE[$key],
'mobile' => $mobile,
'params' => ['code'=>$code]
];
if (!empty($user_id)) {
$send_data['user_id'] = $user_id;
}
Hook::listen('sms_send',$send_data);
return true;
} catch (\Exception $e) {
return $e->getMessage();
}
}
}