需求背景:
(1)业务操作,美客多自动补货策略勾选了第三条,导致可用库存在5-30间的SKU,因为渠道SKU日均销量小于平台日均销量被调0,导致很多店铺在线listing数量从几万下降到了几千,目前已修改策略。需要把之前执行的数据恢复在线
(2)历史数据中,也存在很多缺失下架且有库存的数据,也需要恢复在线
需求内容:
写SQL将满足条件的数据查询出来后,推送到补货队列表处理
(1)查询listing表SubStatus =out_of_stock 且listing_site 表 Status=paused
(2)关联p_product_warehouse_dynamicinventory 表,查询出 SKU库存>0的数据(四个仓库)
(3)关联产品禁售表,排除禁售数据
(4)将满足条件的数据,导出给到业务抽查,是否满足修改条件
(5)分批推送到补货队列,将可售数由0改为200
查询美客多缺货下架且有库存的产品总数SQL
SELECT
COUNT(1)
FROM
m_mercadolibre_listing a INNER JOIN
(select * from (
select CustomerId,Sku,SUM(GoodNum) as GoodNums from p_product_warehouse_dynamicinventory WHERE CustomerId = 1 and WarehouseType = 1 and WarehouseId in (2,333,5312,3922)
GROUP BY CustomerId,Sku) as tt where GoodNums>0) b
on a.CustomerId=b.CustomerId AND a.Sku=b.Sku
inner join m_mercadolibre_listing_site s
on a.CustomerId = s.CustomerId and a.ProductId = s.ProductId and a.OrderSourceId = s.OrderSourceId
WHERE
a.CustomerID=1 and a.Sku <>'' and a.SubStatus='["out_of_stock"]' AND a.OnlineStatus=2 AND s.`Status`='paused'