|
|
@ -838,7 +838,7 @@ class ApiController extends \yii\web\Controller |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 短信验证码 |
|
|
|
* 短信验证码 接口已关闭 |
|
|
|
* @return array |
|
|
|
* @return array |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function actionSmsVerifyCode(){ |
|
|
|
public function actionSmsVerifyCode(){ |
|
|
@ -846,6 +846,7 @@ class ApiController extends \yii\web\Controller |
|
|
|
header("Access-Control-Allow-Methods: POST"); |
|
|
|
header("Access-Control-Allow-Methods: POST"); |
|
|
|
header("Access-Control-Allow-Headers: Content-Type, X-Requested-With, Cache-Control,Authorization,Beeba-Sign,Beeba-Timestamp"); |
|
|
|
header("Access-Control-Allow-Headers: Content-Type, X-Requested-With, Cache-Control,Authorization,Beeba-Sign,Beeba-Timestamp"); |
|
|
|
Yii::$app->response->format = Response::FORMAT_JSON; |
|
|
|
Yii::$app->response->format = Response::FORMAT_JSON; |
|
|
|
|
|
|
|
return ['success' => false, 'msg' => '接口已关闭']; |
|
|
|
$params = Yii::$app->request->post(); |
|
|
|
$params = Yii::$app->request->post(); |
|
|
|
$cache = Yii::$app->cache; |
|
|
|
$cache = Yii::$app->cache; |
|
|
|
$now = time(); |
|
|
|
$now = time(); |
|
|
@ -891,12 +892,23 @@ class ApiController extends \yii\web\Controller |
|
|
|
header("Access-Control-Allow-Headers: Content-Type, X-Requested-With, Cache-Control,Authorization,Beeba-Sign,Beeba-Timestamp"); |
|
|
|
header("Access-Control-Allow-Headers: Content-Type, X-Requested-With, Cache-Control,Authorization,Beeba-Sign,Beeba-Timestamp"); |
|
|
|
Yii::$app->response->format = Response::FORMAT_JSON; |
|
|
|
Yii::$app->response->format = Response::FORMAT_JSON; |
|
|
|
$request = Yii::$app->request; |
|
|
|
$request = Yii::$app->request; |
|
|
|
|
|
|
|
$cache = Yii::$app->cache; |
|
|
|
$result = array( |
|
|
|
$result = array( |
|
|
|
'code' => 0, |
|
|
|
'code' => 0, |
|
|
|
'msg' => '请求成功', |
|
|
|
'msg' => '请求成功', |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
$now = time(); |
|
|
|
|
|
|
|
$last_visited_name = 'hy_last_visit_ip_' . Yii::$app->request->getUserIP(); |
|
|
|
|
|
|
|
$last_visited_time = $cache->get($last_visited_name); |
|
|
|
|
|
|
|
if ($last_visited_time && $now - $last_visited_time < 90) { |
|
|
|
|
|
|
|
$result['code'] = -1; |
|
|
|
|
|
|
|
$result['msg'] = '接口调用过于频繁'; |
|
|
|
|
|
|
|
$result['data'] = $now - $last_visited_time; |
|
|
|
|
|
|
|
return $result; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$cache->set($last_visited_name, $now); |
|
|
|
|
|
|
|
} |
|
|
|
$name = trim($request->post('name','')); |
|
|
|
$name = trim($request->post('name','')); |
|
|
|
$code = trim($request->post('code','')); |
|
|
|
|
|
|
|
$mobile = trim($request->post('mobile','')); |
|
|
|
$mobile = trim($request->post('mobile','')); |
|
|
|
$user = UserT::findOne(['name' => $name, 'phone' => $mobile]); |
|
|
|
$user = UserT::findOne(['name' => $name, 'phone' => $mobile]); |
|
|
|
if($name == '' || !preg_match('/^1[345789]\d{9}$/', $mobile)){ |
|
|
|
if($name == '' || !preg_match('/^1[345789]\d{9}$/', $mobile)){ |
|
|
@ -904,11 +916,6 @@ class ApiController extends \yii\web\Controller |
|
|
|
$result['msg'] = '参数错误'; |
|
|
|
$result['msg'] = '参数错误'; |
|
|
|
return $result; |
|
|
|
return $result; |
|
|
|
} |
|
|
|
} |
|
|
|
if($code == '' || Yii::$app->cache->get('hy_vcode_'.$mobile) != $code){ |
|
|
|
|
|
|
|
$result['code'] = -1; |
|
|
|
|
|
|
|
$result['msg'] = '验证码错误'; |
|
|
|
|
|
|
|
return $result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if($user) { |
|
|
|
if($user) { |
|
|
|
$user->password = MyLib::hashPwd('123456',$user->salt); |
|
|
|
$user->password = MyLib::hashPwd('123456',$user->salt); |
|
|
|
if(!$user->save()){ |
|
|
|
if(!$user->save()){ |
|
|
@ -968,7 +975,19 @@ class ApiController extends \yii\web\Controller |
|
|
|
$result['code'] = -1; |
|
|
|
$result['code'] = -1; |
|
|
|
$result['msg'] = $e->getMessage(); |
|
|
|
$result['msg'] = $e->getMessage(); |
|
|
|
} |
|
|
|
} |
|
|
|
Yii::$app->cache->delete('hy_vcode_'.$mobile); |
|
|
|
} |
|
|
|
|
|
|
|
// 发送账号密码至短信 |
|
|
|
|
|
|
|
$url = 'http://user.banmacar.com/api/sms/single-send'; |
|
|
|
|
|
|
|
$params['token'] = 'b0909511a91119876a0957ab95fe8c7c'; |
|
|
|
|
|
|
|
$params['content'] = "【汇盈帮手】您好,您在汇盈帮手车险业务系统的体验账号为{$result['data']['username']},初始密码为{$result['data']['password']},系统地址:http://demo.huiybs.cn/"; |
|
|
|
|
|
|
|
$ret = MyLib::Post(http_build_query($params), $url); |
|
|
|
|
|
|
|
$ret = json_decode($ret, true); |
|
|
|
|
|
|
|
if (isset($ret['code']) && $ret['code'] == 200) { |
|
|
|
|
|
|
|
$result['code'] = 0; |
|
|
|
|
|
|
|
$result['msg'] = '账号密码已通过短信下发至您手机,请注意查收'; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$result['success'] = false; |
|
|
|
|
|
|
|
$result['msg'] = $ret['msg']; |
|
|
|
} |
|
|
|
} |
|
|
|
return $result; |
|
|
|
return $result; |
|
|
|
} |
|
|
|
} |
|
|
|