- 支付成功后写入 coupon_discount / member_discount 负数应收(币种、阶段跟随运费行,记录券码/会员等级) - 营销重算的折前应收排除抵扣行,避免重复扣减;规则公式忽略抵扣行 - 预报/入库计费任务跳过已付款订单,防止重复投递冲掉应收 - 手工新增费用禁止抵扣费用项;费用输出给出抵扣行显示名 - 订单详情返回折前小计、会员折扣、优惠券抵扣、客户实付 - 新增 fee_item 字典迁移 migrate_fee_item_marketing_discount_20261019.sql
35 lines
1.3 KiB
SQL
35 lines
1.3 KiB
SQL
-- 费用项字典:营销抵扣(支付时写入的负数应收行)。可重复执行。
|
|
-- coupon_discount 优惠券抵扣、member_discount 会员折扣;由 /order/pay 自动生成,禁止手工添加。
|
|
|
|
-- 确保字典类型存在
|
|
INSERT INTO `t_dict_type` (`DictType`, `Remark`, `TypeSort`, `IsDeleted`, `CreateUserId`)
|
|
SELECT 'fee_item', '费用项', 0, 0, 0
|
|
FROM DUAL
|
|
WHERE NOT EXISTS (
|
|
SELECT 1 FROM `t_dict_type`
|
|
WHERE `DictType` = 'fee_item' AND `IsDeleted` = 0
|
|
);
|
|
|
|
-- 曾被软删的同 code 项直接恢复
|
|
UPDATE `t_dict`
|
|
SET `IsDeleted` = 0, `UpdateTime` = NOW()
|
|
WHERE `DictType` = 'fee_item'
|
|
AND `DictCode` IN ('coupon_discount', 'member_discount')
|
|
AND `IsDeleted` = 1;
|
|
|
|
INSERT INTO `t_dict` (`DictType`, `DictSort`, `DictCode`, `DictName`, `IsDeleted`, `CreateUserId`)
|
|
SELECT 'fee_item', 900, 'coupon_discount', '优惠券抵扣', 0, 0
|
|
FROM DUAL
|
|
WHERE NOT EXISTS (
|
|
SELECT 1 FROM `t_dict`
|
|
WHERE `DictType` = 'fee_item' AND `DictCode` = 'coupon_discount'
|
|
);
|
|
|
|
INSERT INTO `t_dict` (`DictType`, `DictSort`, `DictCode`, `DictName`, `IsDeleted`, `CreateUserId`)
|
|
SELECT 'fee_item', 901, 'member_discount', '会员折扣', 0, 0
|
|
FROM DUAL
|
|
WHERE NOT EXISTS (
|
|
SELECT 1 FROM `t_dict`
|
|
WHERE `DictType` = 'fee_item' AND `DictCode` = 'member_discount'
|
|
);
|