热数据条件:
1、FBA的Listing(不管是否出单):FBA状态字段的值为“FBA”
2、有品的Listing:来源渠道对应的销售员所属部门为有品的
3、人工刊登近半年Listing(不管是否出单): 1、上架方式非“自动刊登”“智能刊登”2、记录时间离现在小于半年时间 3、 关联导入 和 凤凰重刊算自动刊登
4、所有已出单Listing:渠道SKU表存在对应Listing的渠道SKU
5、渠道SKU表存在对应Listing的渠道SKU :Asin+国家相同,存在FBA的自发货Listing
二、新产生的Listing上架方式为下述7个时,Listing每天定时同步至冷数据库系统
上架方式:一键上架、草稿上架、表格上架、批量跟卖、复制上架、关联导入、凤凰重刊
一键上架、草稿上架、表格上架、批量跟卖这些上架方式的listing同步时, “是否热数据”字段值标记为是
关联导入、凤凰重刊这些上架方式的listing同步时, “是否热数据”字段值标记为否
三、每天定时跑listing数据,对符合冷数据条件的数据做逻辑删除标记,并同步状态至冷数据库系统标记 “是否热数据”字段值为否
=====================
开发要求:
1、在ZhcxkjErpWorker项目进行服务开发
2、服务需兼顾全量初始化迁移和后续日常迁移
3、热数据 获取思路,可参考如下SQL,适当进行性能优化改进。
--1、FBA的Listing(不管是否出单):FBA状态字段的值为“FBA”
select top 100 * from RB_Amazon_Product_Base (nolock) pb where pb.CustomerID=1 and pb.IsFBA=1 and pb.IsDelete=0
--2、有品的Listing:来源渠道对应的销售员所属部门为有品的
select top 100 * from RB_Amazon_Product_Base (nolock) pb where pb.CustomerID=1 and pb.IsDelete=0 and pb.OrderSourceID in (
select b.ID from RB_OrderSource (nolock) b
inner join RB_Admin (nolock) a on a.id=b.SaleAdminID and a.CustomerID=b.CustomerID
where CHARINDEX('{500}',a.UserFullPath )>0 and a.IsActive=1 and isnull(a.IsLock,0)=0 and b.IsDelete=0 and b.IsActive=1
)
--3、近180天人工刊登(上架方式为:一键上架、草稿上架、表格上架、批量跟卖、复制上架)的Listing数据,不管Listing是否出单
select top 100 * from RB_Amazon_Product_Base (nolock) pb where pb.CustomerID=1 and pb.IsDelete=0 and pb.OnShelfMode in (1,2,3,5,7)
union
select top 100 * from RB_Amazon_Product_Base (nolock) pb where pb.CustomerID=1 and pb.IsDelete=0 and pb.PublishTime>=dateadd(dd,-180, pb.PublishTime)
-- 4、所有已出单Listing:渠道SKU表存在对应Listing的渠道SKU
select top 100 * from RB_Amazon_Product_Base (nolock) pb
inner join RB_Product_OrderSourceSKU(nolock) ss on ss.CustomerID=pb.CustomerID and ss.OrderSourceID=pb.OrderSourceID and ss.OrderSourceSKU=pb.OrderSourceSKU
where pb.CustomerID=1 and pb.IsDelete=0 and ss.isDelete=0
--5、相同Asin+国家的Listing数据,只要存在一条Listing是FBA,这组数据全部都归属于热数据
select top 100 * from RB_Amazon_Product_Base (nolock) prb where prb.CustomerID=1 and prb.IsDelete=0 and
exists (
select pb.ASINorItemID,pb.OrderSourceCountry,
sum(
case when isnull(pb.Isfba,0)=1 then 1 else 0 end
) fbaCount,
sum(
case when isnull(pb.Isfba,0)=0 then 1 else 0 end
) nofbaCount
from RB_Amazon_Product_Base (nolock) pb
where pb.CustomerID=1 and pb.IsDelete=0 and pb.PublishTime>='2022-09-29 00:00:00' and pb.ASINorItemID is not null and pb.ASINorItemID='B09K3P5C2S'
and pb.OrderSourceCountry=prb.OrderSourceCountry and pb.ASINorItemID=prb.ASINorItemID
group by pb.ASINorItemID,pb.OrderSourceCountry
having sum(
case when isnull(pb.Isfba,0)=1 then 1 else 0 end
)>0 and sum(
case when isnull(pb.Isfba,0)=0 then 1 else 0 end
)>0
)
同步店铺ID:5018 名称:亚马逊销售B部 的数据