Fix: register maestro test player

This commit is contained in:
2018-07-19 13:59:10 +09:00
parent 93a1332f4d
commit c8b1e15447
3 changed files with 81 additions and 17 deletions
-5
View File
@@ -89,11 +89,6 @@
function register(inputButton) { function register(inputButton) {
let id = $(inputButton).siblings(".maestro_id"); let id = $(inputButton).siblings(".maestro_id");
let maestroID = id.text(); let maestroID = id.text();
// console.log(maestroID);
// let name = $(inputButton).siblings(".maestro_name");
// let maestroName = name.val();
// console.log(maestroName);
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode); sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/admin/register_maestro.php", "./../server/admin/register_maestro.php",
+80 -11
View File
@@ -4,25 +4,94 @@ header("Content-Type: application/json");
include "./../lib/send_reply_json.php"; include "./../lib/send_reply_json.php";
include "./../setup/connect_db.php"; include "./../setup/connect_db.php";
$maestro_id = $_POST["maestro_id"]; $maestroID = $_POST["maestro_id"];
$query = " $result = register_maestro($maestroID);
UPDATE moty_maestro if($result <= 0) {
SET ActivateStatus = 1, AvailableActivateDateTime = DATE_ADD(NOW(), INTERVAL 1 YEAR)
WHERE MaestroID = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestro_id);
$stmt->execute();
if($stmt->affected_rows <= 0) {
set_error_message("마에스트로 계정 활성화 실패"); set_error_message("마에스트로 계정 활성화 실패");
send_result_fail(); send_result_fail();
exit; exit;
} }
add_maestro_test_player($maestroID);
$playerID = get_maestro_test_player($maestroID);
if($playerID === null) {
set_error_message("마에스트로 테스트 플레이어 생성 실패");
send_result_fail();
exit;
}
$result = set_maestro_test_player($maestroID, $playerID);
if($result === null || $result === 0) {
set_error_message("마에스트로 테스트 플레이어 등록 실패");
send_result_fail();
exit;
}
send_result_success(); send_result_success();
exit; exit;
function register_maestro($maestroID) {
global $db_conn;
$query = "
UPDATE moty_maestro
SET ActivateStatus = 1, AvailableActivateDateTime = DATE_ADD(NOW(), INTERVAL 1 YEAR)
WHERE MaestroID = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestroID);
$stmt->execute();
return $stmt->affected_rows;
}
function add_maestro_test_player($maestroID) {
global $db_conn;
$query = "
INSERT INTO moty_player (MaestroID, Name, EnterCode, AccountType)
VALUES (?, 'Test', '', 1)
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestroID);
$stmt->execute();
}
function get_maestro_test_player($maestroID) {
global $db_conn;
$query = "
SELECT PlayerID
FROM moty_player
WHERE MaestroID = ? AND AccountType = 1
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestroID);
$stmt->execute();
$stmt->bind_result($playerID);
$stmt->fetch();
$stmt->close();
return $playerID;
}
function set_maestro_test_player($maestroID, $playerID) {
global $db_conn;
$query = "
UPDATE moty_maestro
SET MaestroTestID = ?
WHERE MaestroID = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("ii", $playerID, $maestroID);
$stmt->execute();
return $stmt->affected_rows;
}
?> ?>
+1 -1
View File
@@ -64,7 +64,7 @@ function addMaestro($maestro_name, $password, $email, $account_type) {
global $db_conn; global $db_conn;
$query = " $query = "
INSERT INTO moty_Maestro (Name, Password, Email, AccountType, ActivateStatus, UserCount, AcceptClausesDateTime, MaestroTestID) INSERT INTO moty_maestro (Name, Password, Email, AccountType, ActivateStatus, UserCount, AcceptClausesDateTime, MaestroTestID)
VALUES (?, PASSWORD(?), ?, ?, 0, 0, NOW(), -1)"; VALUES (?, PASSWORD(?), ?, ?, 0, 0, NOW(), -1)";
$stmt = $db_conn->prepare($query); $stmt = $db_conn->prepare($query);
$stmt->bind_param("sssi", $maestro_name, $password, $email, $account_type); $stmt->bind_param("sssi", $maestro_name, $password, $email, $account_type);