Initial admin edits

This commit is contained in:
2026-10-01 21:02:58 +03:30
parent ac0cd63dbd
commit 301f3ff1c8
50 changed files with 1191 additions and 867 deletions
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "AppBanner" ADD COLUMN "bannerLink" TEXT;
@@ -0,0 +1,23 @@
-- Preserve customer ↔ company links where only CustomerBrand existed (match by brand/company name or slug)
UPDATE "Customer" c
SET "companyId" = comp.id
FROM "CustomerBrand" cb
JOIN "Brand" b ON b.id = cb."brandId"
JOIN "Company" comp ON LOWER(TRIM(comp.name)) = LOWER(TRIM(b.name))
WHERE cb."customerId" = c.id
AND c."companyId" IS NULL;
UPDATE "Customer" c
SET "companyId" = comp.id
FROM "CustomerBrand" cb
JOIN "Brand" b ON b.id = cb."brandId"
JOIN "Company" comp ON b.slug IS NOT NULL AND comp.slug = b.slug
WHERE cb."customerId" = c.id
AND c."companyId" IS NULL;
ALTER TABLE "Product" DROP CONSTRAINT IF EXISTS "Product_brandId_fkey";
DROP INDEX IF EXISTS "Product_brandId_idx";
ALTER TABLE "Product" DROP COLUMN IF EXISTS "brandId";
DROP TABLE IF EXISTS "CustomerBrand";
DROP TABLE IF EXISTS "Brand";
@@ -0,0 +1,30 @@
-- نادمی تکس: شرکت اصلی (دریافت پرداخت + پیش‌فرض محصولات بدون شرکت مشخص)
INSERT INTO "Company" (
"id",
"name",
"slug",
"description",
"isActive",
"displayOrder",
"cashInvoiceValidityHours",
"updatedAt"
)
VALUES (
'company-nademitex',
'نادمی تکس',
'nademitex',
'شرکت اصلی — تمام پرداخت‌های اپ به حساب‌های این شرکت واریز می‌شود',
true,
0,
8,
CURRENT_TIMESTAMP
)
ON CONFLICT ("slug") DO UPDATE SET
"name" = EXCLUDED."name",
"description" = EXCLUDED."description",
"isActive" = true;
-- حساب‌های بانکی فقط برای دریافت پرداخت نادمی تکس
UPDATE "BankAccount"
SET "companyId" = (SELECT "id" FROM "Company" WHERE "slug" = 'nademitex' LIMIT 1)
WHERE "companyId" IS NOT NULL;
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Product" ADD COLUMN "specs" TEXT;
@@ -0,0 +1,3 @@
ALTER TABLE "SystemSettings" ADD COLUMN "supportWhatsapp" TEXT;
ALTER TABLE "SystemSettings" ADD COLUMN "supportTelegram" TEXT;
ALTER TABLE "SystemSettings" ADD COLUMN "supportInstagram" TEXT;
@@ -0,0 +1,5 @@
-- AlterEnum
ALTER TYPE "SettlementType" ADD VALUE 'cash_check';
-- AlterTable
ALTER TABLE "SystemSettings" ADD COLUMN "defaultSettlementCashCheck" BOOLEAN NOT NULL DEFAULT false;
+28 -49
View File
@@ -11,6 +11,7 @@ datasource db {
enum SettlementType {
cash
check
cash_check
}
enum CheckRegistrationMode {
@@ -175,6 +176,8 @@ model Product {
code String
color String
description String?
/// مشخصات آزاد محصول (نمایش در specs-extra اپ)
specs String? @db.Text
minMeterage Float @default(30)
orderMultiplier Float @default(10)
/// قیمت هر متر (تومان) برای نمایش کاتالوگ / پیش‌فاکتور
@@ -194,12 +197,10 @@ model Product {
subtitle String?
rollMeters Float @default(50)
isNew Boolean @default(false)
brandId String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)
brand Brand? @relation(fields: [brandId], references: [id], onDelete: SetNull)
cartItems CartItem[]
orderItems OrderItem[]
favorites ProductFavorite[]
@@ -208,7 +209,6 @@ model Product {
@@unique([companyId, code])
@@index([companyId])
@@index([brandId])
@@index([usageCategory])
@@index([season])
}
@@ -254,7 +254,6 @@ model Customer {
favorites ProductFavorite[]
catalogRequests CatalogRequest[]
productSuggestions ProductSuggestion[]
customerBrands CustomerBrand[]
addresses CustomerAddress[]
@@index([companyId])
@@ -482,31 +481,35 @@ model Shipment {
}
model SystemSettings {
id String @id @default("default")
maxMeteragePerInvoice Int @default(5000)
cashInvoiceValidityHours Int @default(8)
defaultSettlementCheck Boolean @default(true)
defaultSettlementCash Boolean @default(true)
id String @id @default("default")
maxMeteragePerInvoice Int @default(5000)
cashInvoiceValidityHours Int @default(8)
defaultSettlementCheck Boolean @default(true)
defaultSettlementCash Boolean @default(true)
defaultSettlementCashCheck Boolean @default(false)
/// حداقل سفارش: تعداد طاقه از هر محصول (§۱۹)
minOrderRollsPerProduct Int @default(1)
minOrderRollsPerProduct Int @default(1)
/// نمایش قیمت عمومی در کاتالوگ (پیش‌فرض خاموش)
showCatalogPublicPrice Boolean @default(false)
showCatalogPublicPrice Boolean @default(false)
/// اجازه قیمت‌گذاری توسط واسطه (§۱۹)
allowAgentPricing Boolean @default(false)
allowAgentPricing Boolean @default(false)
/// کف قیمت واحد برای قیمت‌گذاری واسطه (ریال) — اختیاری
agentMinUnitPrice Int?
smsOrderRegistered Boolean @default(true)
smsPricingReady Boolean @default(true)
smsPaymentReminder Boolean @default(true)
smsCheckReview Boolean @default(true)
smsShippingUpdate Boolean @default(true)
supportPhone String?
supportEmail String?
agentMinUnitPrice Int?
smsOrderRegistered Boolean @default(true)
smsPricingReady Boolean @default(true)
smsPaymentReminder Boolean @default(true)
smsCheckReview Boolean @default(true)
smsShippingUpdate Boolean @default(true)
supportPhone String?
supportEmail String?
supportWhatsapp String?
supportTelegram String?
supportInstagram String?
/// تصاویر دسته‌های کاربرد/فصل اپ کاربر: { trousers: dataUrl, summer: dataUrl, ... }
categoryImagesJson Json?
categoryImagesJson Json?
/// تعاریف دسته‌ها (کاربرد/فصل). اگر خالی باشد از مقادیر پیش‌فرض کد استفاده می‌شود.
categoryDefsJson Json?
updatedAt DateTime @updatedAt
categoryDefsJson Json?
updatedAt DateTime @updatedAt
}
/// بنرهای قابل مدیریت بخش‌های اپ کاربر
@@ -517,6 +520,8 @@ model AppBanner {
subtitle String?
ctaLabel String?
ctaLink String?
/// لینک کلیک روی تصویر بنر (مستقل از لینک دکمه)
bannerLink String?
imageUrl String?
displayOrder Int @default(0)
isActive Boolean @default(true)
@@ -627,32 +632,6 @@ model ProductFavorite {
@@index([customerId])
}
model Brand {
id String @id @default(cuid())
name String
slug String? @unique
description String?
isActive Boolean @default(true)
displayOrder Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
customers CustomerBrand[]
products Product[]
}
model CustomerBrand {
customerId String
brandId String
createdAt DateTime @default(now())
customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade)
brand Brand @relation(fields: [brandId], references: [id], onDelete: Cascade)
@@id([customerId, brandId])
@@index([brandId])
}
model CustomerLevelDef {
id String @id @default(cuid())
code String @unique
+28 -28
View File
File diff suppressed because one or more lines are too long
+367 -446
View File
File diff suppressed because one or more lines are too long