Exemplo n.º 1
0
        $app->response->headers->set('Content-Type', 'application/json');
        echo Util::resPonseJson($app, 4001, "User has existed", array());
        exit;
    }
    $user = new User();
    $user->setSystem_id($systemId);
    $user->setUsername($username);
    $user->setPassword_hash(password_hash($password, PASSWORD_BCRYPT));
    $user->setBirthday(strtotime($birthday));
    $user->setHome_town($home_town);
    $user->setId_number($id_number);
    $user->setNation($nation);
    $user->setPhone($phone);
    $user->setInviter($inviter);
    $user->setSex($sex);
    $user->setStatus(1);
    $user->setCreated_at(time());
    $user->setUpdated_at(time());
    $user->setPayment_password("");
    try {
        $em->persist($user);
        $em->flush();
    } catch (Execption $e) {
        $app->response->headers->set('Content-Type', 'application/json');
        echo Util::resPonseJson($app, 500, "System error", array());
        exit;
    }
    $app->response->headers->set('Content-Type', 'application/json');
    echo Util::resPonseJson($app, 200, "Register success", array("user_id" => $user->getId()));
    exit;
});