mirror of https://github.com/jeecgboot/jeecg-boot
Merge pull request #164 from LQYBill/feat/optimizeTransactionView
feat: optimized transaction viewpull/8523/head
commit
fab81cd905
|
@ -1,71 +1,75 @@
|
||||||
CREATE VIEW transaction as
|
CREATE OR REPLACE VIEW transaction as
|
||||||
SELECT id AS id,
|
SELECT combined.id,
|
||||||
create_by AS create_by,
|
combined.create_by,
|
||||||
create_time AS create_time,
|
combined.create_time,
|
||||||
update_by AS update_by,
|
combined.update_by,
|
||||||
update_time AS update_time,
|
combined.update_time,
|
||||||
type AS type,
|
type,
|
||||||
client_id AS client_id,
|
client_id,
|
||||||
payment_proof AS payment_proof,
|
payment_proof,
|
||||||
invoice_number AS invoice_number,
|
invoice_number,
|
||||||
shipping_fee AS shipping_fee,
|
shipping_fee,
|
||||||
purchase_fee AS purchase_fee,
|
purchase_fee,
|
||||||
amount AS amount,
|
amount,
|
||||||
currency AS currency
|
currency.code AS currency
|
||||||
FROM (
|
FROM (
|
||||||
SELECT id AS id,
|
SELECT id,
|
||||||
create_by AS create_by,
|
create_by,
|
||||||
create_time AS create_time,
|
create_time,
|
||||||
update_by AS update_by,
|
update_by,
|
||||||
update_time AS update_time,
|
update_time,
|
||||||
'Credit' AS type,
|
'Credit' AS type,
|
||||||
client_id AS client_id,
|
client_id,
|
||||||
payment_proof AS payment_proof,
|
payment_proof,
|
||||||
NULL AS invoice_number,
|
NULL AS invoice_number,
|
||||||
NULL AS shipping_fee,
|
NULL AS shipping_fee,
|
||||||
NULL AS purchase_fee,
|
NULL AS purchase_fee,
|
||||||
amount AS amount,
|
amount,
|
||||||
(SELECT code FROM currency WHERE credit.currency_id = id) AS currency
|
currency_id
|
||||||
FROM credit
|
FROM credit
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT id AS id,
|
SELECT id,
|
||||||
create_by AS create_by,
|
create_by,
|
||||||
create_time AS create_time,
|
create_time,
|
||||||
update_by AS update_by,
|
update_by,
|
||||||
update_time AS update_time,
|
update_time,
|
||||||
'Debit' AS type,
|
'Debit' AS type,
|
||||||
client_id AS client_id,
|
client_id,
|
||||||
NULL AS payment_proof,
|
NULL AS payment_proof,
|
||||||
invoice_number AS invoice_number,
|
invoice_number,
|
||||||
total_amount AS shipping_fee,
|
total_amount AS shipping_fee,
|
||||||
if((invoice_number like '%%%%-%%-7%%%'),
|
pt.total AS purchase_fee,
|
||||||
purchase_total(invoice_number), NULL) AS purchase_fee,
|
COALESCE(pt.total + si.total_amount, si.total_amount) AS amount,
|
||||||
if((invoice_number like '%%%%-%%-7%%%'),
|
currency_id
|
||||||
(total_amount +
|
FROM shipping_invoice si
|
||||||
purchase_total(invoice_number)),
|
LEFT JOIN (
|
||||||
total_amount) AS amount,
|
SELECT po.shipping_invoice_number, SUM(poc.purchase_fee) AS total
|
||||||
(SELECT code FROM currency WHERE shipping_invoice.currency_id = id) AS currency
|
FROM platform_order_content poc
|
||||||
FROM shipping_invoice
|
JOIN platform_order po ON po.id = poc.platform_order_id
|
||||||
|
WHERE po.shipping_invoice_number LIKE '%-%-7%'
|
||||||
|
GROUP BY po.shipping_invoice_number
|
||||||
|
) pt ON pt.shipping_invoice_number = si.invoice_number
|
||||||
WHERE client_id IS NOT NULL
|
WHERE client_id IS NOT NULL
|
||||||
AND currency_id IS NOT NULL
|
AND currency_id IS NOT NULL
|
||||||
AND currency_id <> ''
|
AND currency_id <> ''
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT id AS id,
|
SELECT id,
|
||||||
create_by as create_by,
|
create_by,
|
||||||
create_time as create_time,
|
create_time,
|
||||||
update_by as update_by,
|
update_by,
|
||||||
update_time as update_time,
|
update_time,
|
||||||
'Debit' AS type,
|
'Debit' AS type,
|
||||||
client_id AS client_id,
|
client_id,
|
||||||
payment_document AS payment_proof,
|
payment_document AS payment_proof,
|
||||||
invoice_number AS invoice_number,
|
invoice_number,
|
||||||
NULL AS shipping_fee,
|
NULL AS shipping_fee,
|
||||||
final_amount AS purchase_fee,
|
final_amount AS purchase_fee,
|
||||||
final_amount AS amount,
|
final_amount AS amount,
|
||||||
(SELECT code FROM currency WHERE purchase_order.currency_id = id) AS currency
|
currency_id
|
||||||
FROM purchase_order
|
FROM purchase_order
|
||||||
WHERE invoice_number LIKE '%%%%-%%-1%%%'
|
WHERE invoice_number LIKE '%-%-1%'
|
||||||
AND client_id IS NOT NULL
|
AND client_id IS NOT NULL
|
||||||
AND currency_id IS NOT NULL
|
AND currency_id IS NOT NULL
|
||||||
AND currency_id <> ''
|
AND currency_id <> ''
|
||||||
) as id;
|
) as combined
|
||||||
|
LEFT JOIN currency ON combined.currency_id = currency.id
|
Loading…
Reference in New Issue