支付密码设置和登录密码设置

1、登录后若用户未设置支付密码,且该用户零钱余额大于0,则进入app首页时进行设置支付密码提醒;

2、支付密码的设置与错误提醒同之前支付密码设置流程;

3、点击下方不在提醒,则不在弹出此弹窗;

4、点击取消,则在点击取消按钮第二天00:00开始计算,7天后的第一次登录则重新在用户进入app首页时出现此弹窗(无论此时用户零钱余额是否大于0都要提醒);

5、用户设置支付密码成功,吐司提示“设置成功”;

  

设置支付密码规则:

1、不要和登录密码一致(提示文案:不要和登录密码一致);

2、连续数字,重复数字不可设置(提示文案:支付密码过于简单);

3、用户设置支付密码,点击确定判断是否属于上面两种情况,若属于则进行拦截,并在“再次输入支付密码”文案后显示相应提示;

 连续数字定义:

扫描二维码关注公众号,回复: 2044308 查看本文章

密码中数字连续递增或递减,如:012345,987654;

 重复数字定义:

密码六位数字完全相同,如:111111;

1、输入支付密码的弹窗,如果第一次输入错误则弹出“重试/忘记密码”弹窗,点击重试返回输入支付密码弹窗,点击忘记密码进入验证码输入弹窗; 

2、验证码5分钟有效,若验证码弹窗中验证码输入错误,则提示输入错误,并清空输入框; 

3、若重试超过五次,则将重试按钮换成返回,提示文案如原型,点击返回关闭输入支付密码弹窗,并在五分钟内用户再次有付款的动作,拦截用户并做出同样的弹窗提示,五分中后点击用户再次有支付动作时可输入支付密码; 

4、若五分钟后第六次输入错误,则弹窗中已错误次数变为“6”次,重试时间变为“10”分钟。以此类推,“7”次——“30”分钟,“8”次——“1小时”,“9”次——“24”小时,此后每次输入错误加“24小时”; 

5、该试错拦截流程同样适用于登录流程,若密码错误5次以上,吐司提示“密码已输错5次,请5分钟后重试”五分钟内用户再次点击登录,做出相同的提示,五分钟后可正常登录,若用户再次输入错误,则参考Note4中的规则对用户予以提示; 

6、用户如果成功登录一次,则再次登录时,试错流程刷新,重新开始记录输入错误次数;

 /**
     * @title 判断是否可以设置支付密码--弹出设置支付密码弹窗
     * @return {"status":"0","errorCode":"0","msg":"成功","result":true}
     * @example PaySet.isSetPayPasswd? 调用参数:{"method":"PaySet.isSetPayPasswd","username":"17721355485","check_code":"123456"}
     * @return_param_explain result:true弹出、false不弹出
     * @method POST
     * @author 邹柯
     */
    public function isSetPayPasswd(){
        /*
         * 1、登录后若用户未设置支付密码,且该用户零钱余额大于0,则进入app首页时进行设置支付密码提醒;
         * 2、点击取消,则在点击取消按钮第二天00:00开始计算,7天后的第一次登录则重新在用户进入app首页时出现此弹窗(无论此时用户零钱余额是否大于0都要提醒)
         */
        $user_id=session('user.user_id');
        if(empty($user_id)){
            return false;
        }
        $customer = M('customer');
        $c_where['user_id']=$user_id;
        $c_info = $customer->where($c_where)->field('balance,securitycode')->find();
        $pps_info=$this->isLoginTime($user_id);
        if(empty($c_info['securitycode']) && $c_info['balance']> 0 && $pps_info==true){
            return true;
        }
        return false;
    }
    //判断登录时间
    public function isLoginTime($user_id){
        $pay_passwd_set=M('pay_passwd_set');
        $pps_where['user_id']=$user_id;
        $pps_where['type']=1;
        $pps_info=$pay_passwd_set->field('status,update_time')->where($pps_where)->find();
        if(empty($pps_info)){
            return true;
        }
        $dat=$pps_info['update_time'];
        $date=date("Y-m-d 00:00:00",strtotime("$dat +1day"));
        $time=date("Y-m-d H:i:s",strtotime( "$date +8day"));
        $now_time=date("Y-m-d H:i:s",time());
        if($pps_info['status']==1 && ($now_time > $time)){
            return true;
        }
        return false;
    }
    /**
     * @title 设置支付密码--不再提醒
     * @param status 是 int 是否再次提醒(1取消、2不在提醒)
     * @return {"status":"0","errorCode":"0","msg":"成功","result":true}
     * @example PaySet.setNotice? 调用参数:{"method":"PaySet.setNotice","username":"17721355485","check_code":"123456","status":"1"}
     * @method POST
     * @author 邹柯
     */
    public function setNotice($res){
        $user_id=session('user.user_id');
        if(empty($user_id)){
            return true;
        }
        $status=$res['status'];
        $time=date("Y-m-d H:i:s",time());
        $pay_passwd_set=M('pay_passwd_set');
        $pps_where['user_id']=$user_id;
        $pps_where['type']=1;
        $pps_info=$pay_passwd_set->field('status,update_time')->where($pps_where)->find();
        if(empty($pps_info)){
            $pps_data=[
                'user_id'=>$user_id,
                'status'=>$status,
                'update_time'=>$time,
                'type'=>1,
            ];
            $res=$pay_passwd_set->data($pps_data)->add();
        }else{
            $pps_data=[
                'status'=>$status,
                'update_time'=>$time
            ];
            $pps_where['user_id']=$user_id;
            $pps_where['type']=1;
            $res=$pay_passwd_set->data($pps_data)->where($pps_where)->save();
        }
        if(!$res){
            E("10001","设置失败");
        }
        return true;
    }
    //密码设置规则
    //1、不要和登录密码一致;
    //2、连续数字,重复数字不可设置;
    public function setPasswdRule($user_id,$securitycode){
        //先判断是否和登录密码一致
        $user=M('user');
        $u_where['user_id']=$user_id;
        $user_info=$user->field('password')->where($u_where)->find();
        if(md5($securitycode)==$user_info['password']){
             return array("status"=>1,"msg"=>"不要和登录密码一致","result"=>null);
        }
        //判断是否是重复数字
        $securitycode_array=str_split($securitycode);
        if (1 == count(array_unique($securitycode_array))) {
            return array("status"=>1,"msg"=>"支付密码过于简单","result"=>null);
        }
        //判断是否是连续数字
        $res=$this->getconsecutive($securitycode_array,6);
        if($res==false){
            return array("status"=>1,"msg"=>"支付密码过于简单","result"=>null);
        }
        return true;
    }
    //判断是否是连续数字
    public function getconsecutive($arr,$n){
        $temp = array();
        foreach($arr as $k =>$v){
            while($k<$n){
                $temp[$k] = $v+$k; $k++;
            }
            $arr_str=implode(",",$arr);
            $temp_str=implode(",",$temp);
            if($arr_str===$temp_str){
                return false;
            }
            return true;
        }
    }   //支付时输入支付密码错误的处理
    //$type 1支付密码 2登录密码
    public function tipByPayPasswdError($user_id,$type){
        //更新输入错误的次数
        $pay_passwd_set=M('pay_passwd_set');
        if($type==2){
            $user=M('user');
            $u_where['username']=$user_id;
            $user_info=$user->field('user_id')->where($u_where)->find();
            $user_id=$user_info['user_id'];
        }
        $pps_where['user_id']=$user_id;
        $pps_where['type']=$type;
        $count=$pay_passwd_set->where($pps_where)->count();
        if($count <= 0){
            $time=date("Y-m-d H:i:s",time());
            $pps_data=[
                'user_id'=>$user_id,
                'status'=>1,
                'update_time'=>$time,
                'type'=>$type
            ];
            $pay_passwd_set->data($pps_data)->add();
        }
        $pay_passwd_set->where($pps_where)->setInc("pay_passwd_nums",1);

        //查询总共输错的次数
        $pps_info=$pay_passwd_set->where($pps_where)->getField("pay_passwd_nums");
        /*
         * 若五分钟后第六次输入错误,则弹窗中已错误次数变为“6”次,重试时间变为“10”分钟。
         * 以此类推,“7”次——“30”分钟,“8”次——“1小时”,“9”次——“24”小时,此后每次输入错误加“24小时”;
         */
        if($pps_info>=5){
            switch($pps_info){
                case 5:
                    $time="5分钟";
                    $repay_time=date("Y-m-d H:i:s",strtotime("+5 minute"));
                    break;
                case 6:
                    $time="10分钟";
                    $repay_time=date("Y-m-d H:i:s",strtotime("+10 minute"));
                    break;
                case 7:
                    $time="30分钟";
                    $repay_time=date("Y-m-d H:i:s",strtotime("+30 minute"));
                    break;
                case 8:
                    $time="1小时";
                    $repay_time=date("Y-m-d H:i:s",strtotime("+1 hour"));
                    break;
                default:
                    $time="24小时";
                    $repay_time=date("Y-m-d H:i:s",strtotime("+24 hour"));
                    break;
            }
            //更新可以再次输入支付密码的时间
            $pay_passwd_set->where($pps_where)->data(["repay_time"=>$repay_time])->save();
            if($type==1){
                $msg="支付密码输入不正确,已错误".$pps_info."次,请点击忘记密码进行找回或".$time."后重试";
            }else{
                $msg="密码已输错".$pps_info."次,请".$time."后重试";
            }
            return array("status"=>1,"errorCode"=>"105", "msg"=>$msg,"result"=>null);
        }
        return true;
    }
    //支付密码输入成功,更新支付密码输入错误次数为0
    //$type 1支付密码 2登录密码
    public function setPayPasswdNums($user_id,$type){
        $pay_passwd_set=M('pay_passwd_set');
        if($type==2){
            $user=M('user');
            $u_where['username']=$user_id;
            $user_info=$user->field('user_id')->where($u_where)->find();
            $user_id=$user_info['user_id'];
        }
        $pps_where['user_id']=$user_id;
        $pps_where['type']=$type;
        $pps_data=[
            'pay_passwd_nums'=>0,
            'update_time'=>date("Y-m-d H:i:s"),
            'repay_time'=>date("Y-m-d H:i:s")
        ];
        $pay_passwd_set->where($pps_where)->data($pps_data)->save();
        return true;
    }
CREATE TABLE `lc_pay_passwd_set` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) DEFAULT NULL COMMENT '用户id',
  `status` tinyint(1) DEFAULT NULL COMMENT '提醒状态(1取消、2不在提醒)',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `pay_passwd_nums` int(2) NOT NULL DEFAULT '0' COMMENT '支付密码输入次数',
  `repay_time` datetime DEFAULT NULL COMMENT '再次可以输入的时间',
  `type` tinyint(1) DEFAULT NULL COMMENT '输入密码类型(1-支付密码、2登录密码)',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COMMENT='支付密码设置--提醒';

猜你喜欢

转载自www.cnblogs.com/zouke1220/p/9288929.html
今日推荐