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 8469e48bd..12e6f21b1 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 @@ -188,6 +188,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, @@ -199,28 +201,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, @@ -378,6 +381,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, @@ -389,28 +394,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, @@ -459,6 +464,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, @@ -470,28 +477,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, @@ -505,10 +513,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 ; @@ -524,6 +529,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, @@ -535,27 +542,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 @@ -585,10 +594,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 ; @@ -609,6 +615,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, @@ -624,28 +632,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, @@ -677,6 +687,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, @@ -692,28 +704,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, @@ -784,6 +796,9 @@ ;