mirror of https://github.com/jeecgboot/jeecg-boot
Merge pull request #172 from LQYBill/feat/Reconstruct_Sku_price
feat: Reconstruct_Sku_price update place orderpull/8523/head
commit
746ada98e0
|
@ -188,6 +188,8 @@
|
||||||
AND po.can_send = 1
|
AND po.can_send = 1
|
||||||
AND poc.erp_status IN ('1','2')
|
AND poc.erp_status IN ('1','2')
|
||||||
GROUP BY sku_id
|
GROUP BY sku_id
|
||||||
|
), rmb_id AS (
|
||||||
|
SELECT id FROM currency WHERE code = 'RMB'
|
||||||
)
|
)
|
||||||
SELECT s.id,
|
SELECT s.id,
|
||||||
s.erp_code,
|
s.erp_code,
|
||||||
|
@ -199,28 +201,29 @@
|
||||||
s.available_amount + s.purchasing_amount - IF(qtyInOrdersNotShipped.quantity IS NULL, 0, qtyInOrdersNotShipped.quantity) as stock,
|
s.available_amount + s.purchasing_amount - IF(qtyInOrdersNotShipped.quantity IS NULL, 0, qtyInOrdersNotShipped.quantity) as stock,
|
||||||
s.image_source,
|
s.image_source,
|
||||||
s.service_fee,
|
s.service_fee,
|
||||||
IF(sp.price_rmb IS NULL, sp.price,
|
IF(sp.currency_id = (SELECT id FROM rmb_id),
|
||||||
(
|
(
|
||||||
ROUND(
|
ROUND(
|
||||||
sp.price_rmb /
|
sp.price /
|
||||||
(SELECT rate
|
(SELECT rate
|
||||||
FROM exchange_rates
|
FROM exchange_rates
|
||||||
WHERE original_currency = 'EUR' AND target_currency = 'RMB'
|
WHERE original_currency = 'EUR' AND target_currency = 'RMB'
|
||||||
ORDER BY create_time DESC LIMIT 1)
|
ORDER BY create_time DESC LIMIT 1)
|
||||||
,2)
|
,2)
|
||||||
)
|
),
|
||||||
|
sp.price
|
||||||
) as sku_price,
|
) as sku_price,
|
||||||
sp.threshold as discount_moq,
|
sp.threshold as discount_moq,
|
||||||
IF(sp.price_rmb IS NULL, sp.discounted_price,
|
IF(sp.currency_id = (SELECT id FROM rmb_id),
|
||||||
(
|
(
|
||||||
ROUND(
|
ROUND(
|
||||||
sp.discounted_price_rmb /
|
sp.discounted_price /
|
||||||
(SELECT rate
|
(SELECT rate
|
||||||
FROM exchange_rates
|
FROM exchange_rates
|
||||||
WHERE target_currency = 'EUR' AND original_currency = 'RMB'
|
WHERE target_currency = 'EUR' AND original_currency = 'RMB'
|
||||||
ORDER BY create_time DESC LIMIT 1)
|
ORDER BY create_time DESC LIMIT 1)
|
||||||
,2)
|
,2)
|
||||||
)
|
), sp.discounted_price
|
||||||
) as discounted_price,
|
) as discounted_price,
|
||||||
s7.quantity as sales_last_week,
|
s7.quantity as sales_last_week,
|
||||||
s28.quantity as sales_four_weeks,
|
s28.quantity as sales_four_weeks,
|
||||||
|
@ -378,6 +381,8 @@
|
||||||
AND po.can_send = 1
|
AND po.can_send = 1
|
||||||
AND poc.erp_status IN ('1','2')
|
AND poc.erp_status IN ('1','2')
|
||||||
GROUP BY sku_id
|
GROUP BY sku_id
|
||||||
|
), rmb_id AS (
|
||||||
|
SELECT id FROM currency WHERE code = 'RMB'
|
||||||
)
|
)
|
||||||
SELECT s.id,
|
SELECT s.id,
|
||||||
s.erp_code,
|
s.erp_code,
|
||||||
|
@ -389,28 +394,28 @@
|
||||||
s.available_amount + s.purchasing_amount - IF(qtyInOrdersNotShippedCTE.quantity IS NULL, 0, qtyInOrdersNotShippedCTE.quantity) as stock,
|
s.available_amount + s.purchasing_amount - IF(qtyInOrdersNotShippedCTE.quantity IS NULL, 0, qtyInOrdersNotShippedCTE.quantity) as stock,
|
||||||
s.image_source,
|
s.image_source,
|
||||||
s.service_fee,
|
s.service_fee,
|
||||||
IF(sp.price_rmb IS NULL, sp.price,
|
IF(sp.currency_id = (SELECT id FROM rmb_id),
|
||||||
(
|
(
|
||||||
ROUND(
|
ROUND(
|
||||||
sp.price_rmb /
|
sp.price /
|
||||||
(SELECT rate
|
(SELECT rate
|
||||||
FROM exchange_rates
|
FROM exchange_rates
|
||||||
WHERE original_currency = 'EUR' AND target_currency = 'RMB'
|
WHERE original_currency = 'EUR' AND target_currency = 'RMB'
|
||||||
ORDER BY create_time DESC LIMIT 1)
|
ORDER BY create_time DESC LIMIT 1)
|
||||||
,2)
|
,2)
|
||||||
)
|
), sp.price
|
||||||
) as sku_price,
|
) as sku_price,
|
||||||
sp.threshold as discount_moq,
|
sp.threshold as discount_moq,
|
||||||
IF(sp.price_rmb IS NULL, sp.discounted_price,
|
IF(sp.currency_id = (SELECT id FROM rmb_id),
|
||||||
(
|
(
|
||||||
ROUND(
|
ROUND(
|
||||||
sp.discounted_price_rmb /
|
sp.discounted_price /
|
||||||
(SELECT rate
|
(SELECT rate
|
||||||
FROM exchange_rates
|
FROM exchange_rates
|
||||||
WHERE target_currency = 'EUR' AND original_currency = 'RMB'
|
WHERE target_currency = 'EUR' AND original_currency = 'RMB'
|
||||||
ORDER BY create_time DESC LIMIT 1)
|
ORDER BY create_time DESC LIMIT 1)
|
||||||
,2)
|
,2)
|
||||||
)
|
), sp.discounted_price
|
||||||
) as discounted_price,
|
) as discounted_price,
|
||||||
s7.quantity as sales_last_week,
|
s7.quantity as sales_last_week,
|
||||||
s28.quantity as sales_four_weeks,
|
s28.quantity as sales_four_weeks,
|
||||||
|
@ -459,6 +464,8 @@
|
||||||
AND po.can_send = 1
|
AND po.can_send = 1
|
||||||
AND poc.erp_status IN ('1','2')
|
AND poc.erp_status IN ('1','2')
|
||||||
GROUP BY sku_id
|
GROUP BY sku_id
|
||||||
|
), rmb_id AS (
|
||||||
|
SELECT id FROM currency WHERE code = 'RMB'
|
||||||
)
|
)
|
||||||
SELECT s.id,
|
SELECT s.id,
|
||||||
s.erp_code,
|
s.erp_code,
|
||||||
|
@ -470,28 +477,29 @@
|
||||||
s.available_amount + s.purchasing_amount - IF(qtyInOrdersNotShippedCTE.quantity IS NULL, 0, qtyInOrdersNotShippedCTE.quantity) as stock,
|
s.available_amount + s.purchasing_amount - IF(qtyInOrdersNotShippedCTE.quantity IS NULL, 0, qtyInOrdersNotShippedCTE.quantity) as stock,
|
||||||
s.image_source,
|
s.image_source,
|
||||||
s.service_fee,
|
s.service_fee,
|
||||||
IF(sp.price_rmb IS NULL, sp.price,
|
IF(sp.currency_id = (SELECT id FROM rmb_id) ,
|
||||||
(
|
(
|
||||||
ROUND(
|
ROUND(
|
||||||
sp.price_rmb /
|
sp.price /
|
||||||
(SELECT rate
|
(SELECT rate
|
||||||
FROM exchange_rates
|
FROM exchange_rates
|
||||||
WHERE original_currency = 'EUR' AND target_currency = 'RMB'
|
WHERE original_currency = 'EUR' AND target_currency = 'RMB'
|
||||||
ORDER BY create_time DESC LIMIT 1)
|
ORDER BY create_time DESC LIMIT 1)
|
||||||
,2)
|
,2)
|
||||||
)
|
),sp.price,
|
||||||
) as sku_price,
|
) as sku_price,
|
||||||
sp.threshold as discount_moq,
|
sp.threshold as discount_moq,
|
||||||
IF(sp.price_rmb IS NULL, sp.discounted_price,
|
IF(sp.currency_id = (SELECT id FROM rmb_id),
|
||||||
(
|
(
|
||||||
ROUND(
|
ROUND(
|
||||||
sp.discounted_price_rmb /
|
sp.discounted_price /
|
||||||
(SELECT rate
|
(SELECT rate
|
||||||
FROM exchange_rates
|
FROM exchange_rates
|
||||||
WHERE target_currency = 'EUR' AND original_currency = 'RMB'
|
WHERE target_currency = 'EUR' AND original_currency = 'RMB'
|
||||||
ORDER BY create_time DESC LIMIT 1)
|
ORDER BY create_time DESC LIMIT 1)
|
||||||
,2)
|
,2
|
||||||
)
|
)
|
||||||
|
), sp.discounted_price,
|
||||||
) as discounted_price,
|
) as discounted_price,
|
||||||
s7.quantity as sales_last_week,
|
s7.quantity as sales_last_week,
|
||||||
s28.quantity as sales_four_weeks,
|
s28.quantity as sales_four_weeks,
|
||||||
|
@ -505,10 +513,7 @@
|
||||||
LEFT JOIN qtyInOrdersNotShippedCTE ON s.id = qtyInOrdersNotShippedCTE.ID
|
LEFT JOIN qtyInOrdersNotShippedCTE ON s.id = qtyInOrdersNotShippedCTE.ID
|
||||||
WHERE client_sku.client_id = #{clientId}
|
WHERE client_sku.client_id = #{clientId}
|
||||||
AND s.status = 3
|
AND s.status = 3
|
||||||
AND (
|
AND sp.price IS NOT NULL AND sp.price <> 0
|
||||||
(sp.price_rmb IS NOT NULL AND sp.price_rmb <> 0)
|
|
||||||
OR (sp.price IS NOT NULL AND sp.price <> 0)
|
|
||||||
)
|
|
||||||
ORDER BY s.erp_code
|
ORDER BY s.erp_code
|
||||||
;
|
;
|
||||||
</select>
|
</select>
|
||||||
|
@ -524,6 +529,8 @@
|
||||||
AND po.can_send = 1
|
AND po.can_send = 1
|
||||||
AND poc.erp_status IN ('1','2')
|
AND poc.erp_status IN ('1','2')
|
||||||
GROUP BY sku_id
|
GROUP BY sku_id
|
||||||
|
), rmb_id AS (
|
||||||
|
SELECT id FROM currency WHERE code = 'RMB'
|
||||||
)
|
)
|
||||||
SELECT s.id,
|
SELECT s.id,
|
||||||
s.erp_code,
|
s.erp_code,
|
||||||
|
@ -535,27 +542,29 @@
|
||||||
s.available_amount + s.purchasing_amount - IF(qtyInOrdersNotShippedCTE.quantity IS NULL, 0, qtyInOrdersNotShippedCTE.quantity) as stock,
|
s.available_amount + s.purchasing_amount - IF(qtyInOrdersNotShippedCTE.quantity IS NULL, 0, qtyInOrdersNotShippedCTE.quantity) as stock,
|
||||||
s.image_source,
|
s.image_source,
|
||||||
s.service_fee,
|
s.service_fee,
|
||||||
IF(sp.price_rmb IS NULL, sp.price,
|
IF(sp.currency_id = (SELECT id FROM rmb_id),
|
||||||
(
|
(
|
||||||
ROUND(
|
ROUND(
|
||||||
sp.price_rmb /
|
sp.price /
|
||||||
(SELECT rate
|
(SELECT rate
|
||||||
FROM exchange_rates
|
FROM exchange_rates
|
||||||
WHERE original_currency = 'EUR' AND target_currency = 'RMB'
|
WHERE original_currency = 'EUR' AND target_currency = 'RMB'
|
||||||
ORDER BY create_time DESC LIMIT 1)
|
ORDER BY create_time DESC LIMIT 1)
|
||||||
,2)
|
,2)
|
||||||
)) as sku_price,
|
), sp.price
|
||||||
|
) as sku_price,
|
||||||
sp.threshold as discount_moq,
|
sp.threshold as discount_moq,
|
||||||
IF(sp.price_rmb IS NULL, sp.discounted_price,
|
IF(sp.currency_id = (SELECT id FROM rmb_id),
|
||||||
(
|
(
|
||||||
ROUND(
|
ROUND(
|
||||||
sp.discounted_price_rmb /
|
sp.discounted_price /
|
||||||
(SELECT rate
|
(SELECT rate
|
||||||
FROM exchange_rates
|
FROM exchange_rates
|
||||||
WHERE target_currency = 'EUR' AND original_currency = 'RMB'
|
WHERE target_currency = 'EUR' AND original_currency = 'RMB'
|
||||||
ORDER BY create_time DESC LIMIT 1)
|
ORDER BY create_time DESC LIMIT 1)
|
||||||
,2)
|
,2)
|
||||||
)) as discounted_price,
|
), sp.discounted_price
|
||||||
|
) as discounted_price,
|
||||||
s7.quantity as sales_last_week,
|
s7.quantity as sales_last_week,
|
||||||
s28.quantity as sales_four_weeks,
|
s28.quantity as sales_four_weeks,
|
||||||
s42.quantity as sales_six_weeks
|
s42.quantity as sales_six_weeks
|
||||||
|
@ -585,10 +594,7 @@
|
||||||
s.en_name REGEXP #{enNames}
|
s.en_name REGEXP #{enNames}
|
||||||
</if>
|
</if>
|
||||||
)
|
)
|
||||||
AND (
|
AND (sp.price IS NOT NULL AND sp.price <> 0)
|
||||||
(sp.price_rmb IS NOT NULL AND sp.price_rmb <> 0)
|
|
||||||
OR (sp.price IS NOT NULL AND sp.price <> 0)
|
|
||||||
)
|
|
||||||
ORDER BY s.erp_code
|
ORDER BY s.erp_code
|
||||||
;
|
;
|
||||||
</select>
|
</select>
|
||||||
|
@ -609,6 +615,8 @@
|
||||||
AND po.erp_status IN ('1','2')
|
AND po.erp_status IN ('1','2')
|
||||||
AND poc.erp_status IN ('1','2')
|
AND poc.erp_status IN ('1','2')
|
||||||
GROUP BY sku_id
|
GROUP BY sku_id
|
||||||
|
), rmb_id AS (
|
||||||
|
SELECT id FROM currency WHERE code = 'RMB'
|
||||||
)
|
)
|
||||||
SELECT s.id,
|
SELECT s.id,
|
||||||
s.erp_code,
|
s.erp_code,
|
||||||
|
@ -624,28 +632,30 @@
|
||||||
as stock,
|
as stock,
|
||||||
s.image_source as image_source,
|
s.image_source as image_source,
|
||||||
s.service_fee as service_fee,
|
s.service_fee as service_fee,
|
||||||
IF(sp.price_rmb IS NULL, sp.price,
|
IF(sp.currency_id = (SELECT id FROM rmb_id),
|
||||||
(
|
(
|
||||||
ROUND(
|
ROUND(
|
||||||
sp.price_rmb /
|
sp.price /
|
||||||
(SELECT rate
|
(SELECT rate
|
||||||
FROM exchange_rates
|
FROM exchange_rates
|
||||||
WHERE original_currency = 'EUR' AND target_currency = 'RMB'
|
WHERE original_currency = 'EUR' AND target_currency = 'RMB'
|
||||||
ORDER BY create_time DESC LIMIT 1)
|
ORDER BY create_time DESC LIMIT 1)
|
||||||
,2)
|
,2)
|
||||||
)
|
) ,
|
||||||
|
sp.price
|
||||||
) as sku_price,
|
) as sku_price,
|
||||||
sp.threshold as discount_moq,
|
sp.threshold as discount_moq,
|
||||||
IF(sp.price_rmb IS NULL, sp.discounted_price,
|
IF(sp.currency_id = (SELECT id FROM rmb_id),
|
||||||
(
|
(
|
||||||
ROUND(
|
ROUND(
|
||||||
sp.discounted_price_rmb /
|
sp.discounted_price /
|
||||||
(SELECT rate
|
(SELECT rate
|
||||||
FROM exchange_rates
|
FROM exchange_rates
|
||||||
WHERE target_currency = 'EUR' AND original_currency = 'RMB'
|
WHERE target_currency = 'EUR' AND original_currency = 'RMB'
|
||||||
ORDER BY create_time DESC LIMIT 1)
|
ORDER BY create_time DESC LIMIT 1)
|
||||||
,2)
|
,2)
|
||||||
)
|
),
|
||||||
|
sp.discounted_price
|
||||||
) as discounted_price,
|
) as discounted_price,
|
||||||
IFNULL(s7.quantity, 0) as sales_last_week,
|
IFNULL(s7.quantity, 0) as sales_last_week,
|
||||||
IFNULL(s28.quantity, 0) as sales_four_weeks,
|
IFNULL(s28.quantity, 0) as sales_four_weeks,
|
||||||
|
@ -677,6 +687,8 @@
|
||||||
AND po.erp_status IN ('1','2')
|
AND po.erp_status IN ('1','2')
|
||||||
AND poc.erp_status IN ('1','2')
|
AND poc.erp_status IN ('1','2')
|
||||||
GROUP BY sku_id
|
GROUP BY sku_id
|
||||||
|
), rmb_id AS (
|
||||||
|
SELECT id FROM currency WHERE code = 'RMB'
|
||||||
)
|
)
|
||||||
SELECT s.id,
|
SELECT s.id,
|
||||||
s.erp_code,
|
s.erp_code,
|
||||||
|
@ -692,28 +704,28 @@
|
||||||
as stock,
|
as stock,
|
||||||
s.image_source as image_source,
|
s.image_source as image_source,
|
||||||
s.service_fee as service_fee,
|
s.service_fee as service_fee,
|
||||||
IF(sp.price_rmb IS NULL, sp.price,
|
IF(sp.currency_id = (SELECT id FROM rmb_id),
|
||||||
(
|
(
|
||||||
ROUND(
|
ROUND(
|
||||||
sp.price_rmb /
|
sp.price /
|
||||||
(SELECT rate
|
(SELECT rate
|
||||||
FROM exchange_rates
|
FROM exchange_rates
|
||||||
WHERE original_currency = 'EUR' AND target_currency = 'RMB'
|
WHERE original_currency = 'EUR' AND target_currency = 'RMB'
|
||||||
ORDER BY create_time DESC LIMIT 1)
|
ORDER BY create_time DESC LIMIT 1)
|
||||||
,2)
|
,2)
|
||||||
)
|
), sp.price
|
||||||
) as sku_price,
|
) as sku_price,
|
||||||
sp.threshold as discount_moq,
|
sp.threshold as discount_moq,
|
||||||
IF(sp.price_rmb IS NULL, sp.discounted_price,
|
IF(sp.currency_id = (SELECT id FROM rmb_id),
|
||||||
(
|
(
|
||||||
ROUND(
|
ROUND(
|
||||||
sp.discounted_price_rmb /
|
sp.discounted_price /
|
||||||
(SELECT rate
|
(SELECT rate
|
||||||
FROM exchange_rates
|
FROM exchange_rates
|
||||||
WHERE target_currency = 'EUR' AND original_currency = 'RMB'
|
WHERE target_currency = 'EUR' AND original_currency = 'RMB'
|
||||||
ORDER BY create_time DESC LIMIT 1)
|
ORDER BY create_time DESC LIMIT 1)
|
||||||
,2)
|
,2)
|
||||||
)
|
), sp.discounted_price
|
||||||
) as discounted_price,
|
) as discounted_price,
|
||||||
IFNULL(s7.quantity, 0) as sales_last_week,
|
IFNULL(s7.quantity, 0) as sales_last_week,
|
||||||
IFNULL(s28.quantity, 0) as sales_four_weeks,
|
IFNULL(s28.quantity, 0) as sales_four_weeks,
|
||||||
|
@ -784,6 +796,9 @@
|
||||||
;
|
;
|
||||||
</select>
|
</select>
|
||||||
<select id="searchExistingSkuByKeywords" resultType="org.jeecg.modules.business.vo.SkuOrderPage">
|
<select id="searchExistingSkuByKeywords" resultType="org.jeecg.modules.business.vo.SkuOrderPage">
|
||||||
|
rmb_id AS (
|
||||||
|
SELECT id FROM currency WHERE code = 'RMB'
|
||||||
|
)
|
||||||
SELECT
|
SELECT
|
||||||
s.id,
|
s.id,
|
||||||
s.erp_code,
|
s.erp_code,
|
||||||
|
@ -793,28 +808,28 @@
|
||||||
s.available_amount,
|
s.available_amount,
|
||||||
s.image_source,
|
s.image_source,
|
||||||
s.service_fee,
|
s.service_fee,
|
||||||
IF(sp.price_rmb IS NULL, sp.price,
|
IF(sp.currency_id = (SELECT id FROM rmb_id),
|
||||||
(
|
(
|
||||||
ROUND(
|
ROUND(
|
||||||
sp.price_rmb /
|
sp.price /
|
||||||
(SELECT rate
|
(SELECT rate
|
||||||
FROM exchange_rates
|
FROM exchange_rates
|
||||||
WHERE original_currency = 'EUR' AND target_currency = 'RMB'
|
WHERE original_currency = 'EUR' AND target_currency = 'RMB'
|
||||||
ORDER BY create_time DESC LIMIT 1)
|
ORDER BY create_time DESC LIMIT 1)
|
||||||
,2)
|
,2)
|
||||||
)
|
), sp.price
|
||||||
) as sku_price,
|
) as sku_price,
|
||||||
sp.threshold as discount_moq,
|
sp.threshold as discount_moq,
|
||||||
IF(sp.price_rmb IS NULL, sp.discounted_price,
|
IF(sp.currency_id = (SELECT id FROM rmb_id),
|
||||||
(
|
(
|
||||||
ROUND(
|
ROUND(
|
||||||
sp.discounted_price_rmb /
|
sp.discounted_price /
|
||||||
(SELECT rate
|
(SELECT rate
|
||||||
FROM exchange_rates
|
FROM exchange_rates
|
||||||
WHERE target_currency = 'EUR' AND original_currency = 'RMB'
|
WHERE target_currency = 'EUR' AND original_currency = 'RMB'
|
||||||
ORDER BY create_time DESC LIMIT 1)
|
ORDER BY create_time DESC LIMIT 1)
|
||||||
,2)
|
,2)
|
||||||
)
|
), sp.discounted_price
|
||||||
) as discounted_price
|
) as discounted_price
|
||||||
FROM sku s
|
FROM sku s
|
||||||
LEFT JOIN sku_current_price sp ON s.id = sp.sku_id
|
LEFT JOIN sku_current_price sp ON s.id = sp.sku_id
|
||||||
|
|
Loading…
Reference in New Issue