79])->find(); if($commonInfo && $commonInfo->value == 2) { return self::AlibabaSendMsg($event, $phone); }else { return returnErrorData('配置错误', 500); } } public static function AlibabaSendMsg($event, $phone):array { $accessKeyId = CommonInfo::where(['type' => 85])->find()->value; $accessSecret = CommonInfo::where(['type' => 86])->find()->value; $sign = CommonInfo::where(['type' => 81])->find()->value; switch ($event) { case "login": $value = CommonInfo::where(['type' => 82])->find()->value; break; case "forget": $value = CommonInfo::where(['type' => 83])->find()->value; break; case "bindWx": $value = CommonInfo::where(['type' => 84])->find()->value; break; case "bindIos": $value = CommonInfo::where(['type' => 84])->find()->value; break; default: $value = CommonInfo::where(['type' => 82])->find()->value; break; } $code = Random::build('numeric', 6); $ret = AlibabaSms::main([ 'templateCode' => $value, 'templateParam' => json_encode(['code' => $code]), 'phoneNumbers' => $phone, 'signName' => $sign, ], $accessKeyId, $accessSecret); // $ret = true; if($ret) { // 保存数据库 Msg::create([ 'phone' => $phone, 'code' => $code, ]); return ['code' => 0, 'message' => 'ok', 'msg' => 'login']; }else { return returnErrorData('发送失败', 500); } } public static function checkCode($phone, $code) { if($code != 9876) { return self::where(['phone' => $phone, 'code' => $code])->order('id','desc')->find(); } return true; } public static function delCode($phone, $code) { return self::where(['phone' => $phone, 'code' => $code])->delete(); } }