Add: maestro account extension php

This commit is contained in:
2019-10-17 14:04:11 +09:00
parent 65ec3e040c
commit 6ed7028e90
2 changed files with 74 additions and 1 deletions
+1 -1
View File
@@ -63,7 +63,7 @@ function extendMaestroAccount() {
// console.log("extend maestro account");
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/maestro/request_extend_maestro.php",
"./../server/maestro/request_extension_maestro.php",
"maestro_id=" + maestroID + "&account_type=" + registeredAccountType,
(function(jsonData) {
@@ -0,0 +1,73 @@
<?php
header("Content-Type: application/json");
include "./../setup/connect_db.php";
include "./../lib/send_reply_json.php";
include "./../lib/db_maestro.php";
include "./../lib/maestro_account_info.php";
include "./../mail/mail_setting.php";
include "./../mail/send_mail.php";
$maestro_id = $_POST["maestro_id"];
$account_type = $_POST["account_type"];
// $maestro_id = has_maestro_name($maestro_name);
// if($maestro_id !== null) {
// set_error_message($maestro_name." : 이미 등록된 마에스트로 계정입니다.");
// send_result_fail();
// exit;
// }
add_maestro_extension($maestro_id, $account_type);
// simplely check if maestro upgrade db added or not
$countUpgrade = count_maestro_extension($maestro_id);
if($countUpgrade === null || $countUpgrade < 1) {
// $maestro_data = get_maestro_data($maestro_id);
// set_error_message($maestro_data["name"]." : 알 수 없는 이유로 마에스트로 계정 업그레이드 요청이 취소되었습니다.");
set_error_message("알 수 없는 이유로 마에스트로 계정 업그레이드 요청이 취소되었습니다.");
send_result_fail();
exit;
}
$maestro_data = get_maestro_data($maestro_id);
// sendMailExtensionBankInfo($maestro_data["name"], $maestro_data["email"], $account_type);
send_result_success();
exit;
function count_maestro_extension($maestro_id) {
global $db_conn;
$query = "
SELECT COUNT(MaestroID)
FROM maestro_extension
WHERE MaestroID = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("i", $maestro_id);
$stmt->execute();
$stmt->bind_result($countUpgrade);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
return $countUpgrade;
}
function add_maestro_extension($maestro_id, $account_type) {
global $db_conn;
$query = "
INSERT INTO maestro_extension (AccountType, RequestedDateTime, Status, MaestroID)
VALUES (?, NOW(), 1, ?);
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("ii", $account_type, $maestro_id);
$stmt->execute();
}
?>