Commit b089b3f6 by 张富康

fix(sql): 修正库存类型插入逻辑

- 修改插入语句,新增对商品类型的判断条件
- 根据goods_type字段设置inventory_type,goods_type为10时为1,否则为2
- 添加关联dj_car_life_upgrade_goods和dj_car_life_goods_info表以获取goods_type
- 保持原有套餐编码和删除标记过滤条件不变
- 优化SQL格式,提高可读性
1 parent aef44931
...@@ -10,31 +10,33 @@ WHERE ...@@ -10,31 +10,33 @@ WHERE
AND r.event_type = 1; AND r.event_type = 1;
INSERT INTO dj_car_life_merchant_goods_inventory_type_ref INSERT INTO dj_car_life_merchant_goods_inventory_type_ref
( (merchant_goods_id,
merchant_goods_id, package_code,
package_code, inventory_type,
inventory_type, merchant_id,
merchant_id, created_by,
created_by, created_date,
created_date, updated_by,
updated_by, updated_date,
updated_date, deleted_flag)
deleted_flag SELECT r.merchant_goods_id,
) NULL AS package_code,
SELECT IF(gi.goods_type = 10, 1, 2) AS inventory_type,
r.merchant_goods_id, r.merchant_id,
NULL AS package_code, 'system' AS created_by,
2 AS inventory_type, NOW() AS created_date,
r.merchant_id, 'system' AS updated_by,
'system' AS created_by, NOW() AS updated_date,
NOW() AS created_date, 'N' AS deleted_flag
'system' AS updated_by, FROM dj_car_life_merchant_goods_ref r
NOW() AS updated_date, INNER JOIN dj_car_life_merchant_goods_info i
'N' AS deleted_flag ON r.merchant_goods_id = i.id
FROM dj_car_life_merchant_goods_ref r inner join dj_car_life_merchant_goods_info i on r.merchant_goods_id = i.id LEFT JOIN dj_car_life_upgrade_goods ug
WHERE ON ug.id = i.upgrade_goods_id
(i.package_code IS NULL OR i.package_code = '') -- 套餐编码为空 LEFT JOIN dj_car_life_goods_info gi
AND r.deleted_flag = 'N'; -- 源数据未删除 ON gi.goods_code = ug.goods_code
WHERE (i.package_code IS NULL OR i.package_code = '')
AND r.deleted_flag = 'N';
### 璐琦 -----------------start------------------- ### 璐琦 -----------------start-------------------
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!