|
@@ -16,8 +16,6 @@
|
|
(t1.sumClaimMoney - t1.invoiceAmount) as unInvoiceAmount
|
|
(t1.sumClaimMoney - t1.invoiceAmount) as unInvoiceAmount
|
|
FROM (SELECT t1.*,
|
|
FROM (SELECT t1.*,
|
|
c.name customerName,
|
|
c.name customerName,
|
|
--- us.nick_name salesmanName,
|
|
|
|
--- us.user_id salesmanId,
|
|
|
|
(SELECT IFNULL(SUM(cc.contract_money), 0)
|
|
(SELECT IFNULL(SUM(cc.contract_money), 0)
|
|
FROM claim_contract cc
|
|
FROM claim_contract cc
|
|
JOIN claim cl ON cc.claim_id = cl.id
|
|
JOIN claim cl ON cc.claim_id = cl.id
|
|
@@ -42,7 +40,6 @@
|
|
AND iacd.contract_id = c.id) AS invoiceAmount
|
|
AND iacd.contract_id = c.id) AS invoiceAmount
|
|
FROM contract t1
|
|
FROM contract t1
|
|
left join customer c on t1.buy_corporation_id = c.id
|
|
left join customer c on t1.buy_corporation_id = c.id
|
|
--- left join sys_user us on c.user_id = us.user_id
|
|
|
|
LEFT JOIN production_order po ON po.contract_id = t1.id
|
|
LEFT JOIN production_order po ON po.contract_id = t1.id
|
|
LEFT JOIN (SELECT pod.contract_id,
|
|
LEFT JOIN (SELECT pod.contract_id,
|
|
IFNULL(sum(swd.quantity), 0) AS quantity,
|
|
IFNULL(sum(swd.quantity), 0) AS quantity,
|
|
@@ -50,18 +47,19 @@
|
|
FROM production_order_detail pod
|
|
FROM production_order_detail pod
|
|
JOIN stock_wait_details swd ON swd.prod_task_id = pod.id
|
|
JOIN stock_wait_details swd ON swd.prod_task_id = pod.id
|
|
GROUP BY pod.contract_id) t3 ON t3.contract_id = t1.id
|
|
GROUP BY pod.contract_id) t3 ON t3.contract_id = t1.id
|
|
- LEFT JOIN (SELECT t1.contract_id,
|
|
|
|
- t1.quantity,
|
|
|
|
- t1.deliverQuantity,
|
|
|
|
- (t1.quantity - t1.deliverQuantity) notDeliverQuantity
|
|
|
|
- FROM (SELECT cp.contract_id,
|
|
|
|
- IFNULL(sum(cp.quantity), 0) AS quantity,
|
|
|
|
- IFNULL(sum(cor.quantity), 0) AS deliverQuantity
|
|
|
|
- FROM contract_product cp
|
|
|
|
- LEFT JOIN contract_outbound_records cor ON cp.id = cor.contract_product_id
|
|
|
|
- LEFT JOIN contract_outbound_info coi ON cor.record_id = coi.id
|
|
|
|
- WHERE coi.`status` in (30, 60)
|
|
|
|
- GROUP BY cp.contract_id) t1) t4 ON t4.contract_id = t1.id) t1
|
|
|
|
|
|
+ LEFT JOIN (SELECT cp.contract_id,
|
|
|
|
+ IFNULL(sum(cp.quantity), 0) AS quantity,
|
|
|
|
+ IFNULL(t2.deliverQuantity, 0) AS deliverQuantity,
|
|
|
|
+ IFNULL(sum(cp.quantity), 0) - IFNULL(t2.deliverQuantity, 0) AS notDeliverQuantity
|
|
|
|
+ FROM contract_product cp
|
|
|
|
+ LEFT JOIN (SELECT cor.contract_id,
|
|
|
|
+ IFNULL(sum(cor.quantity), 0) AS deliverQuantity
|
|
|
|
+ FROM contract_outbound_records cor
|
|
|
|
+ JOIN contract_outbound_info coi ON cor.record_id = coi.id
|
|
|
|
+ WHERE coi.`status` IN (30, 60)
|
|
|
|
+ GROUP BY cor.contract_id) t2
|
|
|
|
+ ON cp.contract_id = t2.contract_id
|
|
|
|
+ GROUP BY cp.contract_id) t4 ON t4.contract_id = t1.id) t1
|
|
GROUP BY t1.id) t1
|
|
GROUP BY t1.id) t1
|
|
</sql>
|
|
</sql>
|
|
|
|
|