colly
2017-08-01 64689425ccf235d8f971bba4dffab9f13f89045d
短信接口调整合并,忘记密码
6 files modified
84 ■■■■■ changed files
Config/app.php 3 ●●●● patch | view | raw | blame | history
Library/Alidayu/Config/app.php 3 ●●●● patch | view | raw | blame | history
Yfs/Api/Send.php 23 ●●●● patch | view | raw | blame | history
Yfs/Api/User.php 30 ●●●●● patch | view | raw | blame | history
Yfs/Domain/Data.php 2 ●●●●● patch | view | raw | blame | history
Yfs/Domain/User.php 23 ●●●●● patch | view | raw | blame | history
Config/app.php
@@ -31,7 +31,8 @@
        //模版列表
        'templates' => array(
            'register' => 'SMS_71216225'
            'register' => 'SMS_71216225',
            'resetPwd' => 'SMS_71216225'
        ),
        'app_key' => '23531128',
        'secretkey' => 'b079269785183c5a7520da9b8047bb42'
Library/Alidayu/Config/app.php
@@ -10,7 +10,8 @@
        //模版列表
        'templates' => array(
            'register' => '71245307'
            'register' => '71245307',
            'resetPwd' => '71245307'
        )
    )
);
Yfs/Api/Send.php
@@ -17,28 +17,36 @@
     */
    public function getRules(){
        return array(
            'register_sms' => array(
            'sms' => array(
                'phone' => array(
                    'name' => 'phone',
                    'type' => 'string',
                    'require' => true,
                    'desc' => '注册手机号'
                ),
                'type' => array(
                    'name' => 'type',
                    'type' => 'string',
                    'require' => true,
                    'desc' => '短信发送类型'
                )
            )
            ),
        );
    }
    /**
     * 注册短信
     * 发送短信接口
     * @desc 发送注册短信
     * @return bool code 操作码,0表示成功, 1表示失败
     * @return string msg 返回提示
     */
    public function register_sms(){
    public function sms(){
        $rs = array('code' => 0, 'msg' => '');
        $sms_service = new Domain_SmsCode();
        $scene = 'register';
        $promit_scene = array('register', 'resetPwd');
        if(in_array($this->type, $promit_scene)){
            $scene = $this->type;
        if($sms_service->check($this->phone, $scene)){
            $code = Common_Util::random(6, 1);
            $send_json_data = json_encode(array('mobile_validate' => $code));
@@ -63,6 +71,11 @@
            $rs['code'] = 1;
            $rs['msg'] = '请勿重复发送短信,间隔时间60秒'; 
        }
        }
        else{
            $rs['code'] = 1;
            $rs['msg'] = '非法的短信类型';
        }
        
        return $rs;
    }
Yfs/Api/User.php
@@ -19,6 +19,10 @@
            'getUserInfo' => array(
                'phone' => array('name' => 'phone', 'type' => 'string', 'require' => true, 'desc' => '用户电话'),
            ),
            'resetPwd' => array(
                'phone' => array('name' => 'phone', 'type' => 'string', 'require' => true, 'desc' => '用户电话'),
                'password' => array('name' => 'password', 'type' => 'string', 'require' => true, 'desc' => '密码'),
            )
        );
    }
@@ -117,7 +121,6 @@
     */
    public function getUserInfo(){
        $rs = array('code' => 0, 'msg' => '', 'info' => array());
        $user_service = new Domain_User();
        $user = $user_service->getUserInfoByPhone($this->phone);
@@ -134,4 +137,29 @@
        return $rs;
    }
    /**
     * 重置密码
     * @desc 重置密码
     * @return bool code 操作码,0表示成功, 1表示失败
     * @return string msg 返回提示
     */
    public function resetPwd(){
        $rs = array('code' => 0, 'msg' => '');
        $user_service = new Domain_User();
        $result = $user_service->resetPwd($this->phone, $this->password);
        if($reslt == 0){
            $rs['msg'] = '密码重置成功';
        }
        elseif($result == 1){
            $rs['code'] = 1;
            $rs['msg'] = '用户不存在或已禁用';
        }
        else{
            $rs['code'] = 1;
            $rs['msg'] = '密码重置失败';
        }
        return $rs;
    }
}
Yfs/Domain/Data.php
@@ -32,4 +32,6 @@
    }
}
Yfs/Domain/User.php
@@ -70,4 +70,27 @@
        }
    }
    /**
     * 重置密码
     * @param  [type] $phone  [description]
     * @param  [type] $newPwd [description]
     * @return [type]         [description]
     */
    public function resetPwd($phone, $newPwd){
        $user = $this->getUserInfoByPhone($phone);
        if($user && $user['is_lock'] == 0){
            $data['password'] = md5(md5($newPwd).$user['encrypt']);
            $result = $this->model->update($data, array('_id' => $user['_id']));
            if($result){
                return 0;
            }
            else{
                return 2;
            }
        }
        else{
            return 1;
        }
    }
}