langjiu-project/BI/销售业绩/电商销售订单-废弃.sql

58 lines
1.6 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- ======================================
-- 2024-11-21由李维调整完毕
-- ======================================
SELECT
*
FROM dm.v_ag_sal_eorder a
-- 订单时间
WHERE order_time >= '${sOrder_start_date}'
AND order_time <= '${sOrder_end_date}'
-- 商品 eproduct_code 、eproduct_name
${if(len(sEproduct_code) == 0,"","and eproduct_name in ('" + sEproduct_code + "')")}
-- 单据号
${if(len(sBill) == 0,"","and order_code in ('" + sBill + "')")}
-- 是否有对照关系 is_refer
${if(len(sIs_refer) == 0,"","and is_refer in ('" + sIs_refer + "')")}
-- 城市单元 sCu
${if(len(sCu) == 0,"","and city_unit_code in ('" + sCu + "')")}
-- 退款标识 is_refund "0","无退款","含退款"
${if(len(sIs_refund) == 0,"","and is_refund in ('" + sIs_refund + "')")}
-- 订单状态 Order_status
${if(len(sOrder_status) == 0,"","and order_status in ('" + sOrder_status + "')")}
-- 品项 sPi
${if(len(sPi_name) == 0,"","and pi_name in ('" + sPi_name + "')")}
-- 产品 sProd
${if(len(sProd) == 0,"","and product_code in ('" + sProd + "')")}
-- 金额区间
${if(len(sStart_amt) == 0,"","and ordered_amt >= " + sStart_amt + "")}
${if(len(sEnd_amt) == 0,"","and ordered_amt <= " + sEnd_amt + "")}
-- 权限控制
AND exists (
select
1
from
dm.dm_bi_user_permisson
where
bi_user = '${fine_username}'
and per_model IN ('all','sal')
and (
is_all = 1
OR per_code = a.p_bu_code -- 事业部
-- OR per_code = a.region_code -- 大区
-- OR per_code = a.office_code -- 城市单元
OR per_code = a.city_unit_code -- 城市单元
)
)