Actualizar server.js
This commit is contained in:
@@ -1708,7 +1708,7 @@ app.get("/public/portal/:token", async (req, res) => {
|
|||||||
p.name as plan_name, p.bricos_limit, p.urgencies_limit
|
p.name as plan_name, p.bricos_limit, p.urgencies_limit
|
||||||
FROM protection_subscriptions s
|
FROM protection_subscriptions s
|
||||||
JOIN protection_plans p ON s.plan_id = p.id
|
JOIN protection_plans p ON s.plan_id = p.id
|
||||||
WHERE s.company_id = $1 AND s.client_phone LIKE $2 AND s.status != 'expirado'
|
WHERE s.company_id = $1 AND s.client_phone LIKE $2 AND s.status = 'activo' AND s.payment_status = 'pagado'
|
||||||
ORDER BY s.created_at DESC LIMIT 1
|
ORDER BY s.created_at DESC LIMIT 1
|
||||||
`, [ownerId, `%${cleanPhoneSearch}%`]);
|
`, [ownerId, `%${cleanPhoneSearch}%`]);
|
||||||
|
|
||||||
@@ -4916,7 +4916,7 @@ app.get("/public/portal/:token/protection", async (req, res) => {
|
|||||||
const client = clientQ.rows[0];
|
const client = clientQ.rows[0];
|
||||||
const ownerId = client.owner_id;
|
const ownerId = client.owner_id;
|
||||||
|
|
||||||
// Comprobar si el cliente YA tiene un plan activo
|
// Comprobar si el cliente YA tiene un plan activo (Solo si está pagado y activo)
|
||||||
let cleanPhone = String(client.phone || "").replace(/[^0-9]/g, "");
|
let cleanPhone = String(client.phone || "").replace(/[^0-9]/g, "");
|
||||||
if (cleanPhone.length > 9) cleanPhone = cleanPhone.slice(-9);
|
if (cleanPhone.length > 9) cleanPhone = cleanPhone.slice(-9);
|
||||||
|
|
||||||
@@ -4924,7 +4924,7 @@ app.get("/public/portal/:token/protection", async (req, res) => {
|
|||||||
SELECT s.status, p.name as plan_name
|
SELECT s.status, p.name as plan_name
|
||||||
FROM protection_subscriptions s
|
FROM protection_subscriptions s
|
||||||
JOIN protection_plans p ON s.plan_id = p.id
|
JOIN protection_plans p ON s.plan_id = p.id
|
||||||
WHERE s.company_id = $1 AND s.client_phone LIKE $2 AND s.status != 'expirado'
|
WHERE s.company_id = $1 AND s.client_phone LIKE $2 AND s.status = 'activo' AND s.payment_status = 'pagado'
|
||||||
ORDER BY s.created_at DESC LIMIT 1
|
ORDER BY s.created_at DESC LIMIT 1
|
||||||
`, [ownerId, `%${cleanPhone}%`]);
|
`, [ownerId, `%${cleanPhone}%`]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user