|
@@ -16,30 +16,33 @@
|
|
|
(t1.sumClaimMoney - t1.invoiceAmount) as unInvoiceAmount,
|
|
|
(CASE WHEN t1.sumClaimMoney < t1.outboundAmount THEN 1 ELSE 0 END) AS isSpecialOutbound
|
|
|
FROM (SELECT t1.*,
|
|
|
- c.name customerName,
|
|
|
+ c.name customerName,
|
|
|
(SELECT IFNULL(SUM(cc.contract_money), 0)
|
|
|
FROM claim_contract cc
|
|
|
JOIN claim cl ON cc.claim_id = cl.id
|
|
|
WHERE cl.confirm_status = 1
|
|
|
- and cc.contract_id = t1.id) AS sumClaimMoney,
|
|
|
+ and cc.contract_id = t1.id) AS sumClaimMoney,
|
|
|
po.produce_status,
|
|
|
- IFNULL(t3.quantity, 0) AS waitStockQuantity,
|
|
|
- IFNULL(t3.receipt_quantity, 0) AS receiptStockQuantity,
|
|
|
+ IFNULL(t3.quantity, 0) AS waitStockQuantity,
|
|
|
+ IFNULL(t3.receipt_quantity, 0) AS receiptStockQuantity,
|
|
|
IFNULL(
|
|
|
(SELECT sum(pod.finish_quantity * cp.price)
|
|
|
FROM contract_product cp
|
|
|
JOIN production_order_detail pod ON pod.contract_detail_id = cp.id
|
|
|
WHERE cp.contract_id = t1.id)
|
|
|
- , 0) AS settledAmount,
|
|
|
- po.delivery_period as prodDeliveryPeriod,
|
|
|
- IFNULL(t4.deliverQuantity, 0) as deliverQuantity,
|
|
|
- IFNULL(t4.notDeliverQuantity, 0) as notDeliverQuantity,
|
|
|
+ ,
|
|
|
+ 0) AS settledAmount,
|
|
|
+ po.delivery_period as prodDeliveryPeriod,
|
|
|
+ IFNULL(t4.deliverQuantity, 0) as deliverQuantity,
|
|
|
+ IFNULL(t4.notDeliverQuantity, 0) as notDeliverQuantity,
|
|
|
(SELECT IFNULL(sum(iacd.amount), 0)
|
|
|
FROM invoice_apply_contract_detail iacd
|
|
|
JOIN invoice_apply ia ON iacd.invoice_apply_id = ia.id
|
|
|
WHERE ia.`status` IN (10, 30, 60)
|
|
|
- AND iacd.contract_id = c.id) AS invoiceAmount,
|
|
|
- IFNULL(cor_1.outbound_amount, 0) AS outboundAmount
|
|
|
+ AND iacd.contract_id = c.id) AS invoiceAmount,
|
|
|
+ IFNULL(cor_1.outbound_amount, 0) AS outboundAmount,
|
|
|
+ TIMESTAMPDIFF(MINUTE, t1.review_begin_time, IFNULL(t1.review_end_time, now())) /
|
|
|
+ 24 AS reviewElapsedTime
|
|
|
FROM contract t1
|
|
|
left join customer c on t1.buy_corporation_id = c.id
|
|
|
LEFT JOIN production_order po ON po.contract_id = t1.id
|