select 
detail.pnumber as pnumber, 
detail.pname as pname, 
detail.spec_type as specType, 
detail.measure_unit as measureUnit, 
detail.quantity - ifnull(detail.quantity_arrived,0) as quantity, 
0 as quantityArrived, 
0 as quantityReturned, 
detail.quantity_not_arrived as quantityNotArrived,
priceinfo.retail_price as purchasePrice, 
priceinfo.retail_price * (detail.quantity - ifnull(detail.quantity_arrived,0)) as money, 
detail.remark as remark, 
detail.goods_id  as goodsId,
detail.id as sourceBId,
orders.id as sourceId,
orders.order_Onumber as sourceCode,
partner.id as supplierId
from t_b_order_products detail
left join t_b_orders orders on  detail.fk_id = orders.id 
left join t_b_goods_info goods on detail.goods_id = goods.id
left join t_b_price_info priceinfo on priceinfo.goods_id=detail.goods_id and priceinfo.metering_unit = detail.measure_unit
left join  t_b_related_units partner on goods.default_provider = partner.id
where orders.id = :qgdID
and ifnull(detail.quantity_arrived,0) < quantity