SELECT
*
,CASE WHEN bu_code ='0202/0223'
      THEN (CASE WHEN pl_name = '小郎酒' THEN '小郎酒事业部'
                 WHEN pl_name IN ('郎牌特曲', '郎牌原浆', '新郎酒') THEN '郎牌特曲事业部'
                 WHEN pl_name in ('青花郎', '老郎酒', '藏品') THEN '青花郎事业部'END)
      ELSE bu_name END report_bu_name -- 报表事业部
,CASE WHEN office_name LIKE '%成都%'
      THEN '成都市场'
      ELSE region_name
      END AS report_region_name -- 报表大区
FROM dm.v_ag_sal_cust_flow
where 1=1
-- 子主经销商筛选
${if(p_is_src_deal== "主经销商",if(len(p_deal_name)==0,"","and deal_name in ('" + p_deal_name + "')"),if(len(p_deal_name)==0,"","and src_deal_name in ('" + p_deal_name + "')"))}
-- 单据号 bill_code
${if(len(p_bill_code) == 0,"","and bill_code in ('" + p_bill_code + "')")}
-- 省
${if(len(p_province) == 0,"","and province_name in ('" + p_province + "')")}
-- 市
${if(len(p_city) == 0,"","and city_name in ('" + p_city + "')")}
-- 收货方
${if(len(p_opposite) == 0,"","and opposite_name in ('" + p_opposite + "')")}
