d2f9289338
- 新增促销规则/规格促销价/使用记录模型与幂等迁移 - EvaluatePromo 支持 new_user/inactive_user/campaign 规则判定 - purchase/preCreate 接入促销判定:命中促销时跳过百分比折扣 - activate 激活后按 order_no 幂等写入 promo_usage - 订单模型和响应结构新增 promo_rule_id、promo_discount 字段 Co-authored-by: multica-agent <github@multica.ai>
40 lines
922 B
SQL
40 lines
922 B
SQL
SET @column_exists = (
|
|
SELECT COUNT(*)
|
|
FROM INFORMATION_SCHEMA.COLUMNS
|
|
WHERE TABLE_SCHEMA = DATABASE()
|
|
AND TABLE_NAME = 'order'
|
|
AND COLUMN_NAME = 'promo_discount'
|
|
);
|
|
|
|
SET @sql = IF(
|
|
@column_exists = 1,
|
|
'ALTER TABLE `order` DROP COLUMN `promo_discount`',
|
|
'SELECT ''Column promo_discount does not exist in order table'''
|
|
);
|
|
|
|
PREPARE stmt FROM @sql;
|
|
EXECUTE stmt;
|
|
DEALLOCATE PREPARE stmt;
|
|
|
|
SET @column_exists = (
|
|
SELECT COUNT(*)
|
|
FROM INFORMATION_SCHEMA.COLUMNS
|
|
WHERE TABLE_SCHEMA = DATABASE()
|
|
AND TABLE_NAME = 'order'
|
|
AND COLUMN_NAME = 'promo_rule_id'
|
|
);
|
|
|
|
SET @sql = IF(
|
|
@column_exists = 1,
|
|
'ALTER TABLE `order` DROP COLUMN `promo_rule_id`',
|
|
'SELECT ''Column promo_rule_id does not exist in order table'''
|
|
);
|
|
|
|
PREPARE stmt FROM @sql;
|
|
EXECUTE stmt;
|
|
DEALLOCATE PREPARE stmt;
|
|
|
|
DROP TABLE IF EXISTS `promo_usage`;
|
|
DROP TABLE IF EXISTS `subscribe_promo`;
|
|
DROP TABLE IF EXISTS `promo_rule`;
|