'', 'phone' => '']; } /** * 设置支付密码 * @param $userId * @param $password * @return UserModel * @throws Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public static function setPayPassword($userId, $password) { if(empty($password)){ throw new Exception('请输入6位数字密码'); } if(!preg_match("/^[0-9]\d{5}$/", $password)){ throw new Exception('密码格式不正确,请输入6位数字密码'); } $payPassword = makePassword($password); return UserModel::where('user_id', $userId)->update(['pay_password'=>$payPassword,'update_time'=>time()]); } }