json.data do json.array! @staffs do |d| json.id d.id json.name d.user.real_name json.role d.role&.name json.area d.areas.present? ? d.areas.pluck(:name).join("、") : '' json.business_a d.businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @a_clazz&.id).count json.business_b d.businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @b_clazz&.id).count json.goal d.businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.stage_id in (?)", @step_ids).sum(:total_amount).round(2) json.return_money d.businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").sum("educode_sales_businesses.return_money") json.a_clazz_id @a_clazz&.id json.b_clazz_id @b_clazz&.id end end json.code 0 json.count @staffs.total_count