select cb.*,re.customer_name,re.phone_number,re.car_brand,re.car_model,re.reception_status,re.bussiness_type,ind.customer_type,ind.avg_defence as def_score,
select cb.*,re.customer_name,re.phone_number,re.car_brand,re.car_model,re.reception_status,re.bussiness_type,ind.customer_type,ind.avg_defence as def_score,
ibr.defence_result_flag, ibr.defence_task_id,if(t3.Is_mentioned=1,true,false) as axbOpenFlag, re.merchant_id, re.reception_start_time,ibr.check_history_flag as checkHistoryFlag
ibr.defence_result_flag, ibr.defence_task_id,if(t3.Is_mentioned=1,true,false) as axbOpenFlag, re.merchant_id, re.reception_start_time,ibr.check_history_flag as checkHistoryFlag,
from
COALESCE(orders.has_anxin, 0) AS isFinishFlag, -- 安心包是否成交 → isFinishFlag
COALESCE(orders.has_completed, 0) AS isOrderFinishFlag -- 订单是否成交 → isOrderFinishFlag
from
inspection_conversation_batch cb
inspection_conversation_batch cb
left join reception_customer_info re on cb.task_id = re.id
left join reception_customer_info re on cb.task_id = re.id
left join inspection_defence ind on ind.batch_id = cb.id and ind.deleted_flag = 'N'
left join inspection_defence ind on ind.batch_id = cb.id and ind.deleted_flag = 'N'
left join inspection_badge_recordings ibr on ibr.id = cb.record_id and ibr.deleted_flag = 'N'
left join inspection_badge_recordings ibr on ibr.id = cb.record_id and ibr.deleted_flag = 'N'
left join recording_batch_model_call_axb t3 on cb.id=t3.batch_id
left join recording_batch_model_call_axb t3 on cb.id=t3.batch_id
LEFT JOIN (
SELECT
phone,
1 AS has_completed, -- 因为 WHERE 已限定 order_status IN (4,6)
select t1.conversation_id as conversationId,t2.customer_name as customerName,t2.phone_number as phoneNumber,t2.reception_status,t1.start_time,t1.file_url,t1.duration,
select t1.conversation_id as conversationId,t2.customer_name as customerName,t2.phone_number as phoneNumber,t2.reception_status,t1.start_time,t1.file_url,t1.duration,
if(t3.Is_mentioned=1,true,false) as axbOpenFlag,if(t4.Is_mentioned=1,true,false) as dtcOpenFlag
if(t3.Is_mentioned=1,true,false) as axbOpenFlag,if(t4.Is_mentioned=1,true,false) as dtcOpenFlag,
-- 👇 关键:按你的 Java 字段命名
COALESCE(orders.has_anxin, 0) AS isFinishFlag, -- 安心包是否成交 → isFinishFlag
COALESCE(orders.has_completed, 0) AS isOrderFinishFlag -- 订单是否成交 → isOrderFinishFlag
from inspection_conversation_batch t1
from inspection_conversation_batch t1
left join reception_customer_info t2 on t1.task_id = t2.id
left join reception_customer_info t2 on t1.task_id = t2.id
left join recording_batch_model_call_axb t3 on t1.id=t3.batch_id
left join recording_batch_model_call_axb t3 on t1.id=t3.batch_id
left join recording_batch_model_call_dtc t4 on t1.id=t4.batch_id
left join recording_batch_model_call_dtc t4 on t1.id=t4.batch_id
LEFT JOIN (
SELECT
phone,
1 AS has_completed, -- 因为 WHERE 已限定 order_status IN (4,6)
MAX(is_anxin_package) AS has_anxin -- 👈 关键:取最大值(0/1),只要有一个1就是1