WHEN '1' THEN (SELECT ldds.driver_phone FROM logpm_distribution_delivery_self AS ldds WHERE ldds.delivery_id = lddl.id AND ldds.is_master = 2)
WHEN '2' THEN (SELECT lddt.driver_phone FROM logpm_distribution_delivery_tripartite AS lddt WHERE lddt.delivery_id = lddl.id )
ELSE ''
END driverPhone,
(SELECT GROUP_CONCAT(ldpl.material_name SEPARATOR ',') FROM logpm_distribution_parcel_list ldpl WHERE ldpl.stock_article_id = ldsa.id) materialName,
(SELECT COALESCE (count(*) ,0) FROM logpm_distribution_reservation_package ldrpp WHERE ldsa.id = ldrpp.stock_article_id and ldrpp.reservation_id =ldrs.reservation_id) totalNumber,
(select COALESCE (count(*) ,0) from logpm_distribution_loadscan ldl WHERE ldl.order_id =ldsa.id and ldl.signfor_state =2) signfornum