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

58 lines
1.6 KiB
MySQL
Raw Permalink Normal View History

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-24 15:21:04 +08:00
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 + "')")}
2024-09-20 17:28:15 +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