欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

错误记录

程序员文章站 2022-05-31 11:46:49
...


原先:
if ($redpacket['haspwd'] &&  $pwd != $redpacket['pwd']) {
     
    $openCount = Redis::incrMemberRedpacketOpencount($this->userid, $id);
    $leftCount = 10 - $openCount;

    if ($leftCount > 0) {
            $this->returnError(300, '口令错误,还剩' . $leftCount . "次机会");
    } else {
            $this->returnError(300, '口令错误');
    }
}

修正后
if ($redpacket['haspwd']) {
    if (Redis::getMemberRedpacketOpencount($this->userid, $id) >= 10) {
        $this->returnError(300, '打开次数已超过限制');
    }

    if ($pwd != $redpacket['pwd']) {
        $openCount = Redis::incrMemberRedpacketOpencount($this->userid, $id);
        $leftCount = 10 - $openCount;

        if ($leftCount > 0) {
            $this->returnError(300, '口令错误,还剩' . $leftCount . "次机会");
        } else {
            $this->returnError(300, '口令错误');
        }
    }
}

原先会造成 10次后 输入正确密码也能进入下面逻辑