Merge pull request #172 from LQYBill/feat/Reconstruct_Sku_price

feat: Reconstruct_Sku_price update place order
pull/8523/head
Qiuyi LI 2025-06-04 16:18:43 +02:00 committed by GitHub
commit 746ada98e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 65 additions and 50 deletions

View File

@ -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
;
</select>
@ -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}
</if>
)
AND (
(sp.price_rmb IS NOT NULL AND sp.price_rmb &lt;&gt; 0)
OR (sp.price IS NOT NULL AND sp.price &lt;&gt; 0)
)
AND (sp.price IS NOT NULL AND sp.price &lt;&gt; 0)
ORDER BY s.erp_code
;
</select>
@ -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 @@
;
</select>
<select id="searchExistingSkuByKeywords" resultType="org.jeecg.modules.business.vo.SkuOrderPage">
rmb_id AS (
SELECT id FROM currency WHERE code = 'RMB'
)
SELECT
s.id,
s.erp_code,
@ -793,28 +808,28 @@
s.available_amount,
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
FROM sku s
LEFT JOIN sku_current_price sp ON s.id = sp.sku_id