From ed62a4e187187c7a6273277b3b4aae75bc019bbc Mon Sep 17 00:00:00 2001 From: Xue YANG Date: Wed, 4 Jun 2025 16:15:48 +0200 Subject: [PATCH] feat: Reconstruct_Sku_price update place order --- .../modules/business/mapper/xml/SkuMapper.xml | 115 ++++++++++-------- 1 file changed, 65 insertions(+), 50 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/SkuMapper.xml b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/SkuMapper.xml index dc9266eba..ae1173ec9 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/SkuMapper.xml +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/SkuMapper.xml @@ -186,6 +186,8 @@ AND po.can_send = 1 AND poc.erp_status IN ('1','2') GROUP BY sku_id + ), rmb_id AS ( + SELECT id FROM currency WHERE code = 'RMB' ) SELECT s.id, s.erp_code, @@ -197,28 +199,29 @@ s.available_amount + s.purchasing_amount - IF(qtyInOrdersNotShipped.quantity IS NULL, 0, qtyInOrdersNotShipped.quantity) as stock, s.image_source, s.service_fee, - IF(sp.price_rmb IS NULL, sp.price, + IF(sp.currency_id = (SELECT id FROM rmb_id), ( ROUND( - sp.price_rmb / + sp.price / (SELECT rate FROM exchange_rates WHERE original_currency = 'EUR' AND target_currency = 'RMB' ORDER BY create_time DESC LIMIT 1) ,2) - ) + ), + sp.price ) as sku_price, sp.threshold as discount_moq, - IF(sp.price_rmb IS NULL, sp.discounted_price, + IF(sp.currency_id = (SELECT id FROM rmb_id), ( ROUND( - sp.discounted_price_rmb / + sp.discounted_price / (SELECT rate FROM exchange_rates WHERE target_currency = 'EUR' AND original_currency = 'RMB' ORDER BY create_time DESC LIMIT 1) ,2) - ) + ), sp.discounted_price ) as discounted_price, s7.quantity as sales_last_week, s28.quantity as sales_four_weeks, @@ -335,6 +338,8 @@ AND po.can_send = 1 AND poc.erp_status IN ('1','2') GROUP BY sku_id + ), rmb_id AS ( + SELECT id FROM currency WHERE code = 'RMB' ) SELECT s.id, s.erp_code, @@ -346,28 +351,28 @@ s.available_amount + s.purchasing_amount - IF(qtyInOrdersNotShippedCTE.quantity IS NULL, 0, qtyInOrdersNotShippedCTE.quantity) as stock, s.image_source, s.service_fee, - IF(sp.price_rmb IS NULL, sp.price, + IF(sp.currency_id = (SELECT id FROM rmb_id), ( ROUND( - sp.price_rmb / + sp.price / (SELECT rate FROM exchange_rates WHERE original_currency = 'EUR' AND target_currency = 'RMB' ORDER BY create_time DESC LIMIT 1) ,2) - ) + ), sp.price ) as sku_price, sp.threshold as discount_moq, - IF(sp.price_rmb IS NULL, sp.discounted_price, + IF(sp.currency_id = (SELECT id FROM rmb_id), ( ROUND( - sp.discounted_price_rmb / + sp.discounted_price / (SELECT rate FROM exchange_rates WHERE target_currency = 'EUR' AND original_currency = 'RMB' ORDER BY create_time DESC LIMIT 1) ,2) - ) + ), sp.discounted_price ) as discounted_price, s7.quantity as sales_last_week, s28.quantity as sales_four_weeks, @@ -416,6 +421,8 @@ AND po.can_send = 1 AND poc.erp_status IN ('1','2') GROUP BY sku_id + ), rmb_id AS ( + SELECT id FROM currency WHERE code = 'RMB' ) SELECT s.id, s.erp_code, @@ -427,28 +434,29 @@ s.available_amount + s.purchasing_amount - IF(qtyInOrdersNotShippedCTE.quantity IS NULL, 0, qtyInOrdersNotShippedCTE.quantity) as stock, s.image_source, s.service_fee, - IF(sp.price_rmb IS NULL, sp.price, + IF(sp.currency_id = (SELECT id FROM rmb_id) , ( ROUND( - sp.price_rmb / + sp.price / (SELECT rate FROM exchange_rates WHERE original_currency = 'EUR' AND target_currency = 'RMB' ORDER BY create_time DESC LIMIT 1) ,2) - ) + ),sp.price, ) as sku_price, sp.threshold as discount_moq, - IF(sp.price_rmb IS NULL, sp.discounted_price, + IF(sp.currency_id = (SELECT id FROM rmb_id), ( ROUND( - sp.discounted_price_rmb / + sp.discounted_price / (SELECT rate FROM exchange_rates WHERE target_currency = 'EUR' AND original_currency = 'RMB' ORDER BY create_time DESC LIMIT 1) - ,2) + ,2 ) + ), sp.discounted_price, ) as discounted_price, s7.quantity as sales_last_week, s28.quantity as sales_four_weeks, @@ -462,10 +470,7 @@ LEFT JOIN qtyInOrdersNotShippedCTE ON s.id = qtyInOrdersNotShippedCTE.ID WHERE client_sku.client_id = #{clientId} AND s.status = 3 - AND ( - (sp.price_rmb IS NOT NULL AND sp.price_rmb <> 0) - OR (sp.price IS NOT NULL AND sp.price <> 0) - ) + AND sp.price IS NOT NULL AND sp.price <> 0 ORDER BY s.erp_code ; @@ -481,6 +486,8 @@ AND po.can_send = 1 AND poc.erp_status IN ('1','2') GROUP BY sku_id + ), rmb_id AS ( + SELECT id FROM currency WHERE code = 'RMB' ) SELECT s.id, s.erp_code, @@ -492,27 +499,29 @@ s.available_amount + s.purchasing_amount - IF(qtyInOrdersNotShippedCTE.quantity IS NULL, 0, qtyInOrdersNotShippedCTE.quantity) as stock, s.image_source, s.service_fee, - IF(sp.price_rmb IS NULL, sp.price, + IF(sp.currency_id = (SELECT id FROM rmb_id), ( ROUND( - sp.price_rmb / + sp.price / (SELECT rate FROM exchange_rates WHERE original_currency = 'EUR' AND target_currency = 'RMB' ORDER BY create_time DESC LIMIT 1) ,2) - )) as sku_price, + ), sp.price + ) as sku_price, sp.threshold as discount_moq, - IF(sp.price_rmb IS NULL, sp.discounted_price, + IF(sp.currency_id = (SELECT id FROM rmb_id), ( ROUND( - sp.discounted_price_rmb / + sp.discounted_price / (SELECT rate FROM exchange_rates WHERE target_currency = 'EUR' AND original_currency = 'RMB' ORDER BY create_time DESC LIMIT 1) ,2) - )) as discounted_price, + ), sp.discounted_price + ) as discounted_price, s7.quantity as sales_last_week, s28.quantity as sales_four_weeks, s42.quantity as sales_six_weeks @@ -542,10 +551,7 @@ s.en_name REGEXP #{enNames} ) - AND ( - (sp.price_rmb IS NOT NULL AND sp.price_rmb <> 0) - OR (sp.price IS NOT NULL AND sp.price <> 0) - ) + AND (sp.price IS NOT NULL AND sp.price <> 0) ORDER BY s.erp_code ; @@ -566,6 +572,8 @@ AND po.erp_status IN ('1','2') AND poc.erp_status IN ('1','2') GROUP BY sku_id + ), rmb_id AS ( + SELECT id FROM currency WHERE code = 'RMB' ) SELECT s.id, s.erp_code, @@ -581,28 +589,30 @@ as stock, s.image_source as image_source, s.service_fee as service_fee, - IF(sp.price_rmb IS NULL, sp.price, + IF(sp.currency_id = (SELECT id FROM rmb_id), ( ROUND( - sp.price_rmb / + sp.price / (SELECT rate FROM exchange_rates WHERE original_currency = 'EUR' AND target_currency = 'RMB' ORDER BY create_time DESC LIMIT 1) ,2) - ) + ) , + sp.price ) as sku_price, sp.threshold as discount_moq, - IF(sp.price_rmb IS NULL, sp.discounted_price, + IF(sp.currency_id = (SELECT id FROM rmb_id), ( ROUND( - sp.discounted_price_rmb / + sp.discounted_price / (SELECT rate FROM exchange_rates WHERE target_currency = 'EUR' AND original_currency = 'RMB' ORDER BY create_time DESC LIMIT 1) ,2) - ) + ), + sp.discounted_price ) as discounted_price, IFNULL(s7.quantity, 0) as sales_last_week, IFNULL(s28.quantity, 0) as sales_four_weeks, @@ -634,6 +644,8 @@ AND po.erp_status IN ('1','2') AND poc.erp_status IN ('1','2') GROUP BY sku_id + ), rmb_id AS ( + SELECT id FROM currency WHERE code = 'RMB' ) SELECT s.id, s.erp_code, @@ -649,28 +661,28 @@ as stock, s.image_source as image_source, s.service_fee as service_fee, - IF(sp.price_rmb IS NULL, sp.price, + IF(sp.currency_id = (SELECT id FROM rmb_id), ( ROUND( - sp.price_rmb / + sp.price / (SELECT rate FROM exchange_rates WHERE original_currency = 'EUR' AND target_currency = 'RMB' ORDER BY create_time DESC LIMIT 1) ,2) - ) + ), sp.price ) as sku_price, sp.threshold as discount_moq, - IF(sp.price_rmb IS NULL, sp.discounted_price, + IF(sp.currency_id = (SELECT id FROM rmb_id), ( ROUND( - sp.discounted_price_rmb / + sp.discounted_price / (SELECT rate FROM exchange_rates WHERE target_currency = 'EUR' AND original_currency = 'RMB' ORDER BY create_time DESC LIMIT 1) ,2) - ) + ), sp.discounted_price ) as discounted_price, IFNULL(s7.quantity, 0) as sales_last_week, IFNULL(s28.quantity, 0) as sales_four_weeks, @@ -741,6 +753,9 @@ ;