需求 #19973
按这两个维度提取数据
100%
描述
8月1日到8月27日:
1.维度:是有折扣优惠的商品:销售原始价 折扣优惠 正常销售价 商品来源(售后无理由退货、售后质量问题退货,售后其它问题退货,多开、采购等)
2.维度:按售后退货的商品:售后退货原因,售后退货退款金额,售后退货成本价,售后退货后再重新销售的销售原始价 售后退货后再重新销售的正常销售价 售后退货后再重新销售的折扣优惠 售后退货的返回给供应商的成本价
历史记录
#4
由 李利婷 更新于 将近 5 年 之前
找到优惠订单商品明细之后关联出库记录表,找到对应的打标id fmys_stock_out_record;然后关联入库记录表判断来源即可
判断条件
,case when sir.work_id<>0 then '售后' else '采购' end as one_source
,case when sir.work_id<>0 and so.is_alone=1 and so.user_refund_id <> 0 THEN '售后_一手币退货工单 '
WHEN sir.work_id<>0 and so.user_refund_id <> 0 THEN '售后_VIP极速退货工单'
when sir.work_id<>0 and afrc.os_sn is not null then '售后_退货月卡'
WHEN sir.work_id<>0 THEN '售后_普通工单'
when sir.work_id=0 and sir.stock_source in (9,10) then '采购_盘盈'
when sir.work_id=0 and sir.stock_source in (11) then '采购_前置仓'
when sir.work_id=0 and sir.stock_source in (7) then '采购_核销'
when sir.work_id=0 and sir.stock_source in (1) then '采购_欠货'
when sir.work_id=0 and sir.stock_source in (2) then '采购_退换货欠货'
when sir.work_id=0 then '采购_其他'
else '未知'
end as two_source ---二级渠道分类
出库的打标id 关联入库
left outer join
yishou_data.all_fmys_stock_in_record sir----入库记录表,通过db_id,,获得采购详情id:woiid 和 工单id:work_id
on kod.dbid=sir.dbid
where sir.wheres=1 ---要限制正常区
)kod
join
yishou_data.all_fmys_stock_in_record sir----入库记录表,通过db_id,,获得采购详情id:woiid 和 工单id:work_id
on kod.dbid=sir.dbid
left outer join
yishou_data.all_fmys_wcg_order_info woi ---采购详情表
on woi.woiid=sir.woiid
left outer join
yishou_data.all_fmys_service_order so ----工单表,判断售后类型
on sir.work_id=so.id
left join
(---退货月卡使用
select distinct os_sn--,refund_card_sn
from
yishou_data.all_fmys_refund_card_log a
where a.type = 2 ---and a.refund_card_sn is not null
)afrc on so.os_sn = afrc.os_sn