More custom price per registrar preparations

This commit is contained in:
Pinga 2024-07-28 18:33:54 +03:00
parent 52409dcfbd
commit 0799781491
3 changed files with 27 additions and 9 deletions

View file

@ -104,7 +104,7 @@ function checkUrlhaus($domain, Map $urlhausData) {
return $urlhausData->get($domain, false); return $urlhausData->get($domain, false);
} }
function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command = 'create') { function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command = 'create', $registrar_id = null) {
// Check if the domain is a premium domain // Check if the domain is a premium domain
$stmt = $pdo->prepare(" $stmt = $pdo->prepare("
SELECT c.category_price SELECT c.category_price
@ -145,8 +145,17 @@ function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command =
// Get regular price for the specified period // Get regular price for the specified period
$priceColumn = "m" . $date_add; $priceColumn = "m" . $date_add;
$stmt = $pdo->prepare("SELECT $priceColumn FROM domain_price WHERE tldid = ? AND command = '$command' LIMIT 1"); $sql = "
$stmt->execute([$tld_id]); SELECT $priceColumn
FROM domain_price
WHERE tldid = ?
AND command = ?
AND (registrar_id = ? OR registrar_id IS NULL)
ORDER BY registrar_id DESC
LIMIT 1
";
$stmt = $pdo->prepare($sql);
$stmt->execute([$tld_id, $command, $registrar_id]);
if ($stmt->rowCount() > 0) { if ($stmt->rowCount() > 0) {
$regularPrice = $stmt->fetch()[$priceColumn]; $regularPrice = $stmt->fetch()[$priceColumn];

View file

@ -338,7 +338,7 @@ function extractDomainAndTLD($urlString) {
return ['domain' => $sld, 'tld' => $tld]; return ['domain' => $sld, 'tld' => $tld];
} }
function getDomainPrice($db, $domain_name, $tld_id, $date_add = 12, $command = 'create') { function getDomainPrice($db, $domain_name, $tld_id, $date_add = 12, $command = 'create', $registrar_id = null) {
// Check if the domain is a premium domain // Check if the domain is a premium domain
$premiumDomain = $db->selectRow( $premiumDomain = $db->selectRow(
'SELECT c.category_price 'SELECT c.category_price
@ -377,8 +377,8 @@ function getDomainPrice($db, $domain_name, $tld_id, $date_add = 12, $command = '
// Get regular price for the specified period // Get regular price for the specified period
$priceColumn = "m" . $date_add; $priceColumn = "m" . $date_add;
$regularPrice = $db->selectValue( $regularPrice = $db->selectValue(
"SELECT $priceColumn FROM domain_price WHERE tldid = ? AND command = ? LIMIT 1", "SELECT $priceColumn FROM domain_price WHERE tldid = ? AND command = ? AND (registrar_id = ? OR registrar_id IS NULL) ORDER BY registrar_id DESC LIMIT 1",
[$tld_id, $command] [$tld_id, $command, $registrar_id]
); );
if ($regularPrice !== false) { if ($regularPrice !== false) {

View file

@ -515,7 +515,7 @@ function updatePermittedIPs($pool, $permittedIPsTable) {
} }
} }
function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command = 'create') { function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command = 'create', $registrar_id = null) {
// Check if the domain is a premium domain // Check if the domain is a premium domain
$stmt = $pdo->prepare(" $stmt = $pdo->prepare("
SELECT c.category_price SELECT c.category_price
@ -556,8 +556,17 @@ function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command =
// Get regular price for the specified period // Get regular price for the specified period
$priceColumn = "m" . $date_add; $priceColumn = "m" . $date_add;
$stmt = $pdo->prepare("SELECT $priceColumn FROM domain_price WHERE tldid = ? AND command = '$command' LIMIT 1"); $sql = "
$stmt->execute([$tld_id]); SELECT $priceColumn
FROM domain_price
WHERE tldid = ?
AND command = ?
AND (registrar_id = ? OR registrar_id IS NULL)
ORDER BY registrar_id DESC
LIMIT 1
";
$stmt = $pdo->prepare($sql);
$stmt->execute([$tld_id, $command, $registrar_id]);
if ($stmt->rowCount() > 0) { if ($stmt->rowCount() > 0) {
$regularPrice = $stmt->fetch()[$priceColumn]; $regularPrice = $stmt->fetch()[$priceColumn];