2024-11-24 15:21:04 +08:00
|
|
|
|
-- ======================================
|
|
|
|
|
-- 2024-11-21:由李维调整完毕
|
|
|
|
|
-- ======================================
|
|
|
|
|
|
2024-09-20 17:28:15 +08:00
|
|
|
|
SELECT
|
|
|
|
|
*
|
2024-11-24 15:21:04 +08:00
|
|
|
|
FROM dm.v_ag_sal_eorder a
|
2024-11-17 22:55:05 +08:00
|
|
|
|
-- 订单时间
|
2024-11-24 15:21:04 +08:00
|
|
|
|
WHERE order_time >= '${sOrder_start_date}'
|
|
|
|
|
AND order_time <= '${sOrder_end_date}'
|
2024-11-17 22:55:05 +08:00
|
|
|
|
-- 商品 eproduct_code 、eproduct_name
|
|
|
|
|
${if(len(sEproduct_code) == 0,"","and eproduct_name in ('" + sEproduct_code + "')")}
|
2024-09-20 17:28:15 +08:00
|
|
|
|
|
2024-11-17 22:55:05 +08:00
|
|
|
|
-- 单据号
|
|
|
|
|
${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 + "')")}
|
|
|
|
|
|
|
|
|
|
-- 金额区间
|
2024-11-24 15:21:04 +08:00
|
|
|
|
${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 -- 城市单元
|
|
|
|
|
)
|
|
|
|
|
)
|
2024-09-20 17:28:15 +08:00
|
|
|
|
|