feat(product): add show_in_list toggle and TV price formula

- New `show_in_list` column to control product visibility in customer list
- New `tv_price_formula_enabled` + `tv_price_formula` columns for separate TV pricing
- FormulaPriceService: isTvEnabled() and calculateTvForProduct()
- listTvProducts applies TV formula overrides before returning
- filterProductData handles both new field sets

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-19 11:51:54 +03:30
co-authored by Cursor
parent b0296c6e94
commit a321ebdaad
7 changed files with 348 additions and 0 deletions
+53
View File
@@ -68,6 +68,36 @@ PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
-- ---------------------------------------------------------------------------
-- products.show_in_list (لیست محصولات اپ مشتری)
-- ---------------------------------------------------------------------------
SET @sql = IF(
(SELECT COUNT(*) FROM information_schema.TABLES
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'products') > 0
AND (SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'products' AND COLUMN_NAME = 'show_in_list') = 0,
IF(
(SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'products' AND COLUMN_NAME = 'show_on_tv') > 0,
'ALTER TABLE `products` ADD COLUMN `show_in_list` TINYINT(1) NOT NULL DEFAULT 1 COMMENT ''نمایش در لیست محصولات مشتری'' AFTER `show_on_tv`',
IF(
(SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'products' AND COLUMN_NAME = 'show_in_assets') > 0,
'ALTER TABLE `products` ADD COLUMN `show_in_list` TINYINT(1) NOT NULL DEFAULT 1 COMMENT ''نمایش در لیست محصولات مشتری'' AFTER `show_in_assets`',
IF(
(SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'products' AND COLUMN_NAME = 'show') > 0,
'ALTER TABLE `products` ADD COLUMN `show_in_list` TINYINT(1) NOT NULL DEFAULT 1 COMMENT ''نمایش در لیست محصولات مشتری'' AFTER `show`',
'ALTER TABLE `products` ADD COLUMN `show_in_list` TINYINT(1) NOT NULL DEFAULT 1 COMMENT ''نمایش در لیست محصولات مشتری'''
)
)
),
'SELECT ''skip products.show_in_list'' AS info'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
-- ---------------------------------------------------------------------------
-- products.use_last_price_if_zero (fallback وقتی provider صفر است)
-- ---------------------------------------------------------------------------
@@ -555,6 +585,29 @@ PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
-- tv_price_formula_enabled / tv_price_formula ---
SET @sql = IF(
(SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'products' AND COLUMN_NAME = 'tv_price_formula_enabled') = 0,
CONCAT('ALTER TABLE `products` ADD COLUMN `tv_price_formula_enabled` TINYINT(1) NOT NULL DEFAULT 0 COMMENT ''فرمول قیمت TV فعال'' AFTER ',
IF((SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'products' AND COLUMN_NAME = 'price_formula') > 0,
'`price_formula`', '`show_on_tv`')),
'SELECT ''skip tv_price_formula_enabled'' AS info'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET @sql = IF(
(SELECT COUNT(*) FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'products' AND COLUMN_NAME = 'tv_price_formula') = 0,
'ALTER TABLE `products` ADD COLUMN `tv_price_formula` TEXT NULL COMMENT ''فرمول قیمت مخصوص TV'' AFTER `tv_price_formula_enabled`',
'SELECT ''skip tv_price_formula'' AS info'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
-- ---------------------------------------------------------------------------
-- پایان — برای بورس‌مس (اختیاری، جدا اجرا کنید):
-- UPDATE `settings` SET `value` = 'کیلوگرم' WHERE `key` = 'unit';