Commit c57eae0e by 泽锋 李

张莹霞的备货单,初始建议数  小于5的,  系统建议数  改5下单。

parent 1e590397
...@@ -62,7 +62,7 @@ select ...@@ -62,7 +62,7 @@ select
t1.quantity_init_advise as 'quantity_init_advise', -- 原始采购建议数量 new t1.quantity_init_advise as 'quantity_init_advise', -- 原始采购建议数量 new
( (
case case
when t7.sum_quantity_init_advise>=t7.max_moq then t1.quantity_init_advise -- 如果商品的下单总量达到moq了,就直接下单 when t7.sum_quantity_init_advise>=t7.max_moq then ( case when t6.buyer_name in ('张莹霞') then greatest(t1.quantity_init_advise,t6.moq) else t1.quantity_init_advise end )-- 如果商品的下单总量达到moq了,就直接下单 (张莹霞的sku取moq下单)
when t7.sku_count=1 then t7.max_moq -- 如果该商品只有一个sku需要下单,则直接下一个moq when t7.sku_count=1 then t7.max_moq -- 如果该商品只有一个sku需要下单,则直接下一个moq
else else
FLOOR( FLOOR(
......
...@@ -449,11 +449,170 @@ where ( t_db.hq_type!='国内仓' or t2.buyer_name not in ('张莹霞','张莹 ...@@ -449,11 +449,170 @@ where ( t_db.hq_type!='国内仓' or t2.buyer_name not in ('张莹霞','张莹
} }
/// <summary> /// <summary>
/// 国内仓缺货计算
/// </summary>
/// <param name="is_all">是否全量数据</param>
/// <returns></returns>
public static List<dc_auto_shortage_push> ChinaShortagePush(string platform, bool is_all = false)
{
var conn = _connection;
var shortage_list = new List<dc_auto_shortage_push>();
// 缺货推送
string sql = @"select
t1.bailun_sku,
t1.warehouse_code,
now() as 'push_date',
1 as 'type',
t5.usable_stock as 'stocks',
'ebay' as 'platform'
from dc_mid_transit as t1
left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join (
select t1.bailun_sku,t2.area_id,sum(t1.usable_stock) as 'sum_usable_stock' from dc_base_stock as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
where t1.warehouse_code in ( 'GZBLWH', 'QYBLZZ' )
GROUP BY t1.bailun_sku,t2.area_id
) as t3 on t1.bailun_sku = t3.bailun_sku and t_db.area_id = t3.area_id
left join (
select t1.bailun_sku,t2.area_id,sum(t1.quantity_unshipped) as 'sum_unshipped_quantity',sum(t1.quantity_purchase) as 'sum_quantity_purchase' from dc_mid_transit as t1 left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
where t1.quantity_unshipped>0 and t1.warehouse_code in ( 'GZBLWH', 'QYBLZZ' )
GROUP BY t1.bailun_sku,t2.area_id
) as t4 on t1.bailun_sku = t4.bailun_sku and t_db.area_id = t4.area_id
left join dc_base_stock as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
where
t1.warehouse_code in ('GZBLWH', 'QYBLZZ')
and t1.bailun_sku not in ('942904501')
and ( t2.buyer_name not in ('张莹霞','张莹霞1','赵美聪','黄镜洁','赵美聪','赵美聪1','秦振荣','李志民1') or t2.`status`=1 )
and ( t1.quantity_purchase<=0 and (ifnull(t4.sum_unshipped_quantity,0) - ifnull(t3.sum_usable_stock,0))>0 ) -- 有缺货
and (ifnull(t4.sum_unshipped_quantity,0) - ifnull(t3.sum_usable_stock,0))>0 -- 有缺货
and ( ifnull(t4.sum_quantity_purchase,0)<=0 or t2.buyer_name in ('张莹霞','张莹霞1','赵美聪','黄镜洁','赵美聪','赵美聪1','秦振荣','李志民1') ) -- 无在途 或者 自产 (自产的有在途也要推)
and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_shortage_push_not_config.warehouse_code=t1.warehouse_code and dc_auto_shortage_push_not_config.bailun_sku=t1.bailun_sku )
";
if (!is_all)
{
sql += $" and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku and dc_auto_shortage_push.`type`=1 and dc_auto_shortage_push.platform='{platform}' ) ";
}
shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(sql,commandTimeout: 0));
// 0库存推送
string no_library_sql = @" select t1.bailun_sku,
t1.warehouse_code,
now() as 'push_date',
0 as 'stocks',
'ebay' as 'platform',
2 as 'type' from dc_base_stock as t1
left join dc_mid_transit as t2 on t1.warehouse_code =t2.warehouse_code and t1.bailun_sku =t2.bailun_sku
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
left join (
select t1.bailun_sku,t2.area_id,sum(t1.usable_stock) as 'sum_usable_stock' from dc_base_stock as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
where t1.warehouse_code in ( 'GZBLWH', 'QYBLZZ' )
GROUP BY t1.bailun_sku,t2.area_id
) as t4 on t1.bailun_sku = t4.bailun_sku and t_db.area_id = t4.area_id
left join (
select t1.bailun_sku,t2.area_id,sum(t1.quantity_purchase) as 'sum_quantity_purchase' from dc_mid_transit as t1 left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
where t1.quantity_unshipped>0 and t1.warehouse_code in ( 'GZBLWH', 'QYBLZZ' )
GROUP BY t1.bailun_sku,t2.area_id
) as t5 on t1.bailun_sku = t5.bailun_sku and t_db.area_id = t5.area_id
where t1.usable_stock<=0 and t1.bailun_sku!=''
and t1.warehouse_code in ('GZBLWH', 'QYBLZZ')
and t1.bailun_sku not in ('942904501')
and ( t3.buyer_name not in ('张莹霞','张莹霞1','赵美聪','黄镜洁','赵美聪','赵美聪1','秦振荣','李志民1') or t3.`status`=1 )
and IFNULL(t4.sum_usable_stock,0)<=0 -- 无库存
and ( ifnull(t5.sum_quantity_purchase,0)<=0 or t3.buyer_name in ('张莹霞','张莹霞1','赵美聪','黄镜洁','赵美聪','赵美聪1','秦振荣','李志民1')
) -- 无在途 或者 自产 (自产的有在途也要推)
and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_shortage_push_not_config.warehouse_code=t1.warehouse_code and dc_auto_shortage_push_not_config.bailun_sku=t1.bailun_sku )
";
if (!is_all)
{
no_library_sql += $" and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku and dc_auto_shortage_push.`type`=2 and dc_auto_shortage_push.platform='{platform}' ) ";
}
shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(no_library_sql, commandTimeout: 0));
return shortage_list;
}
/// <summary>
/// 国外仓缺货计算
/// </summary>
/// <param name="is_all">是否全量数据</param>
/// <returns></returns>
public static List<dc_auto_shortage_push> NotChinaShortagePush(List<string> warehouse_codes,string platform, bool is_all = false)
{
var conn = _connection;
var shortage_list = new List<dc_auto_shortage_push>();
// 缺货推送
string sql = @"select
t1.bailun_sku,
t1.warehouse_code,
now() as 'push_date',
1 as 'type',
t5.usable_stock as 'stocks',
'ebay' as 'platform'
from dc_mid_transit as t1
left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_stock as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
left join (
select t1.bailun_sku,t2.area_id,sum(t1.usable_stock) as 'usable_stock' from dc_base_stock as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
where t1.warehouse_code in @warehouse_codes
GROUP BY t1.bailun_sku,t2.area_id
) as t6 on t1.bailun_sku = t6.bailun_sku and t_db.area_id = t6.area_id
left join (
select t1.bailun_sku,t2.area_id,sum(t1.quantity_unshipped) as 'quantity_unshipped' from dc_mid_transit as t1 left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
where t1.quantity_unshipped>0 and t1.warehouse_code in @warehouse_codes
GROUP BY t1.bailun_sku,t2.area_id
) as t7 on t1.bailun_sku = t7.bailun_sku and t_db.area_id = t7.area_id
where
t1.warehouse_code in @warehouse_codes
and ( ifnull(t6.usable_stock,0)<ifnull(t7.quantity_unshipped,0) ) -- 有缺货
";
if (!is_all)
{
sql += $" and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku and dc_auto_shortage_push.`type`=1 and dc_auto_shortage_push.platform='{platform}' ) ";
}
shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(sql,new { warehouse_codes = warehouse_codes }, commandTimeout: 0));
// 0库存推送
string no_library_sql = @" select t1.bailun_sku,
t1.warehouse_code,
now() as 'push_date',
0 as 'stocks',
'ebay' as 'platform',
2 as 'type'
from dc_base_stock as t1
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join (
select t1.bailun_sku,t2.area_id,sum(t1.usable_stock) as 'usable_stock' from dc_base_stock as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
where t1.warehouse_code in @warehouse_codes
GROUP BY t1.bailun_sku,t2.area_id
) as t6 on t1.bailun_sku = t6.bailun_sku and t_db.area_id = t6.area_id
where t1.warehouse_code in @warehouse_codes
and ifnull(t6.usable_stock,0)<=0
and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_shortage_push_not_config.warehouse_code=t1.warehouse_code and dc_auto_shortage_push_not_config.bailun_sku=t1.bailun_sku )
";
if (!is_all)
{
no_library_sql += $" and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku and dc_auto_shortage_push.`type`=2 and dc_auto_shortage_push.platform='{platform}' ) ";
}
shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(no_library_sql,new { warehouse_codes = warehouse_codes }, commandTimeout: 0));
return shortage_list;
}
/// <summary>
/// 缺货推送 /// 缺货推送
/// </summary> /// </summary>
/// <param name="is_all">是否全量数据</param> /// <param name="is_all">是否全量数据</param>
/// <returns></returns> /// <returns></returns>
public static List<dc_auto_shortage_push> ShortagePush(bool is_all = false) public static List<dc_auto_shortage_push> EbayShortagePush(bool is_all = false)
{ {
var conn = _connection; var conn = _connection;
var shortage_list = new List<dc_auto_shortage_push>(); var shortage_list = new List<dc_auto_shortage_push>();
...@@ -463,6 +622,7 @@ t1.bailun_sku, ...@@ -463,6 +622,7 @@ t1.bailun_sku,
t1.warehouse_code, t1.warehouse_code,
now() as 'push_date', now() as 'push_date',
1 as 'type', 1 as 'type',
'ebay' as 'platform',
(case when t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) and t2.buyer_name not in ('张莹霞','张莹霞1') then t5.usable_stock else ifnull(t3.sum_usable_stock,0) end ) as 'stocks' (case when t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) and t2.buyer_name not in ('张莹霞','张莹霞1') then t5.usable_stock else ifnull(t3.sum_usable_stock,0) end ) as 'stocks'
from dc_mid_transit as t1 from dc_mid_transit as t1
left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku left join dc_base_sku as t2 on t1.bailun_sku = t2.bailun_sku
...@@ -470,10 +630,14 @@ left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code ...@@ -470,10 +630,14 @@ left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join china_warehouse_stock as t3 on t1.bailun_sku = t3.bailun_sku and t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) left join china_warehouse_stock as t3 on t1.bailun_sku = t3.bailun_sku and t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' )
left join china_warehouse_unshipped as t4 on t1.bailun_sku = t4.bailun_sku and t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) left join dc_base_stock as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code left join china_warehouse_unshipped as t4 on t1.bailun_sku = t4.bailun_sku and t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) left join dc_base_stock as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
where where
t1.warehouse_code in ('AU4PXBL','BLGZ03','DYGXC','GB4PXBL','GBBLJW','GBYKD','GZBLWH','QYBLZZ','US4PXBL','USGCBL') t1.warehouse_code in ('GBYKD','JZHYBLGC','MDBLWYT','MXBLWYT','BLUSGDC','GBBMHBL','GBBLJW','GB4PXBL','DEBLDG','QYBLZZ','USGCBL','USHWBL','US4PXBL','AUWYTBL','AU4PXBL','GBWYTUK','BLGBPX','DYGXC','GZBLWH')
and t2.buyer_name not in ('李志民1') and ( t_db.hq_type!='国内仓' or
and t1.bailun_sku not in ('944943401','944943402','944885401','944884901','944884902','944884902','944937701','944919101','942904501') (
and ( t_db.hq_type!='国内仓' or t2.buyer_name not in ('张莹霞','张莹霞1','赵美聪') ) t1.bailun_sku not in ('942904501')
and
t2.buyer_name not in ('张莹霞','张莹霞1','赵美聪','黄镜洁','赵美聪','赵美聪1','秦振荣','李志民1')
)
)
and t_db.hq_type!='fba仓' and t_db.hq_type!='fba仓'
and ( and (
case case
...@@ -486,7 +650,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh ...@@ -486,7 +650,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh
"; ";
if (!is_all) if (!is_all)
{ {
sql += " and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku and dc_auto_shortage_push.`type`=1 ) "; sql += " and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku and dc_auto_shortage_push.`type`=1 and dc_auto_shortage_push.platform='ebay' ) ";
} }
shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(sql,commandTimeout: 0)); shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(sql,commandTimeout: 0));
...@@ -495,15 +659,20 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh ...@@ -495,15 +659,20 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh
t1.warehouse_code, t1.warehouse_code,
now() as 'push_date', now() as 'push_date',
0 as 'stocks', 0 as 'stocks',
'ebay' as 'platform',
2 as 'type' from dc_base_stock as t1 2 as 'type' from dc_base_stock as t1
left join dc_mid_transit as t2 on t1.warehouse_code =t2.warehouse_code and t1.bailun_sku =t2.bailun_sku left join dc_mid_transit as t2 on t1.warehouse_code =t2.warehouse_code and t1.bailun_sku =t2.bailun_sku
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
where t1.usable_stock<=0 and t1.bailun_sku!='' where t1.usable_stock<=0 and t1.bailun_sku!=''
and ( t_db.hq_type!='国内仓' or t3.buyer_name not in ('张莹霞','张莹霞1','黄镜洁','赵美聪') ) and t1.warehouse_code in ('GBYKD','JZHYBLGC','MDBLWYT','MXBLWYT','BLUSGDC','GBBMHBL','GBBLJW','GB4PXBL','DEBLDG','QYBLZZ','USGCBL','USHWBL','US4PXBL','AUWYTBL','AU4PXBL','GBWYTUK','BLGBPX','DYGXC','GZBLWH')
and t1.warehouse_code in ('AU4PXBL','GB4PXBL','GBBLJW','GBYKD','GZBLWH','QYBLZZ','US4PXBL','USGCBL') and ( t_db.hq_type!='国内仓' or
and t3.buyer_name not in ('李志民1') (
and t1.bailun_sku not in ('944943401','944943402','944885401','944884901','944884902','944884902','944937701','944919101','942904501') t1.bailun_sku not in ('942904501')
and
t3.buyer_name not in ('张莹霞','张莹霞1','赵美聪','黄镜洁','赵美聪','赵美聪1','秦振荣','李志民1')
)
)
and ( and (
case case
when t_db.hq_type='国内仓' then 0 when t_db.hq_type='国内仓' then 0
...@@ -518,21 +687,14 @@ and not EXISTS ( ...@@ -518,21 +687,14 @@ and not EXISTS (
t_stock.warehouse_code != 'BLGZ03' t_stock.warehouse_code != 'BLGZ03'
and ( ( t_stock_w.hq_type='国内仓' and t_db.hq_type='国内仓' ) or ( t_db.hq_type!='国内仓' and t_stock_w.hq_type!='国内仓' and t_db.area_id=t_stock_w.area_id ) ) and ( ( t_stock_w.hq_type='国内仓' and t_db.hq_type='国内仓' ) or ( t_db.hq_type!='国内仓' and t_stock_w.hq_type!='国内仓' and t_db.area_id=t_stock_w.area_id ) )
and t_stock.bailun_sku= t1.bailun_sku and and t_stock.bailun_sku= t1.bailun_sku and
( t_stock.usable_stock>0 or ( t_stock.usable_stock>0 )
(
case
when t_stock_w.hq_type='国内仓' then 0 -- 国内其他仓有没有在途都要推 , 国外仓有调拨在途就不推了
else t_stock_t.quantity_transfer
end
)>0
)
) -- 同属性仓库 (是否国内) 有库存,就不算 0库存 ) -- 同属性仓库 (是否国内) 有库存,就不算 0库存
and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_shortage_push_not_config.warehouse_code=t1.warehouse_code and dc_auto_shortage_push_not_config.bailun_sku=t1.bailun_sku ) and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_shortage_push_not_config.warehouse_code=t1.warehouse_code and dc_auto_shortage_push_not_config.bailun_sku=t1.bailun_sku )
"; ";
if (!is_all) if (!is_all)
{ {
no_library_sql += " and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku and dc_auto_shortage_push.`type`=2 ) "; no_library_sql += " and not exists ( select * from dc_auto_shortage_push where dc_auto_shortage_push.warehouse_code = t1.warehouse_code and dc_auto_shortage_push.bailun_sku = t1.bailun_sku and dc_auto_shortage_push.`type`=2 and dc_auto_shortage_push.platform='ebay' ) ";
} }
shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(no_library_sql, commandTimeout: 0)); shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(no_library_sql, commandTimeout: 0));
...@@ -720,7 +882,7 @@ end ...@@ -720,7 +882,7 @@ end
/// <summary> /// <summary>
/// 回货速改推送 /// 回货速改推送
/// </summary> /// </summary>
public static List<dc_return_goods_push> ReturnGoodsPush() public static List<dc_return_goods_push> ReturnGoodsPush(string platform)
{ {
var conn = _connection; var conn = _connection;
var shortage_list = new List<dc_return_goods_push>(); var shortage_list = new List<dc_return_goods_push>();
...@@ -743,14 +905,14 @@ left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code ...@@ -743,14 +905,14 @@ left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join china_warehouse_unshipped as t5 on t1.bailun_sku = t5.bailun_sku and t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) left join china_warehouse_unshipped as t5 on t1.bailun_sku = t5.bailun_sku and t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' )
left join dc_base_stock as t_stock on t1.bailun_sku = t_stock.bailun_sku and t1.warehouse_code = t_stock.warehouse_code left join dc_base_stock as t_stock on t1.bailun_sku = t_stock.bailun_sku and t1.warehouse_code = t_stock.warehouse_code
left join dc_auto_config_sku_warehouse as t7 on t1.bailun_sku = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code left join dc_auto_config_sku_warehouse as t7 on t1.bailun_sku = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code
where 1=1 where t1.platform=@platform
and (case and (case
when t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) and t2.buyer_name not in ('张莹霞','张莹霞1') and (ifnull(t4.sum_usable_stock, 0) - ifnull(t5.sum_unshipped_quantity, 0) > 0) then 1 when t_db.warehouse_code in ( 'GZBLWH', 'QYBLZZ' ) and t2.buyer_name not in ('张莹霞','张莹霞1') and (ifnull(t4.sum_usable_stock, 0) - ifnull(t5.sum_unshipped_quantity, 0) > 0) then 1
when(t3.quantity_out_stock is null or t3.quantity_out_stock <= 0) and ifnull(t_stock.usable_stock,0)> ifnull(t3.quantity_unshipped, 0) then 1 when(t3.quantity_out_stock is null or t3.quantity_out_stock <= 0) and ifnull(t_stock.usable_stock,0)> ifnull(t3.quantity_unshipped, 0) then 1
else 0 else 0
end end
) = 1"; ) = 1";
shortage_list.AddRange(conn.Query<dc_return_goods_push>(sql, commandTimeout: 0)); shortage_list.AddRange(conn.Query<dc_return_goods_push>(sql,new { platform= platform }, commandTimeout: 0));
return shortage_list; return shortage_list;
......
...@@ -12,6 +12,7 @@ namespace AutoTurnOver.Models.ApiDto ...@@ -12,6 +12,7 @@ namespace AutoTurnOver.Models.ApiDto
/// sku类型 1.库存为零的sku 2.有库存 /// sku类型 1.库存为零的sku 2.有库存
/// </summary> /// </summary>
public int skuType { get; set; } public int skuType { get; set; }
public string platform { get; set; }
} }
public class ShortagePush_Item_RequestDto public class ShortagePush_Item_RequestDto
......
...@@ -29,5 +29,10 @@ namespace AutoTurnOver.Models ...@@ -29,5 +29,10 @@ namespace AutoTurnOver.Models
private int _stocks; private int _stocks;
public int stocks { get { return Math.Max(0, _stocks); } set { _stocks = value; } } public int stocks { get { return Math.Max(0, _stocks); } set { _stocks = value; } }
/// <summary>
/// 平台
/// </summary>
public string platform { get; set; }
} }
} }
...@@ -18,5 +18,6 @@ namespace AutoTurnOver.Models ...@@ -18,5 +18,6 @@ namespace AutoTurnOver.Models
private int _stocks; private int _stocks;
public int stocks { get { return Math.Max(0, _stocks); } set { _stocks = value; } } public int stocks { get { return Math.Max(0, _stocks); } set { _stocks = value; } }
} }
} }
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
public class shortage_push_view_dto
{
public string hq_type { get; set; }
public string warehouse_code { get; set; }
public string bailun_sku { get; set; }
public string buyer_name { get; set; }
/// <summary>
/// 国内仓总库存
/// </summary>
public decimal? china_sum_usable_stock { get; set; }
/// <summary>
/// 国内仓待发货
/// </summary>
public decimal? china_sum_unshipped_quantity { get; set; }
/// <summary>
/// 缺货
/// </summary>
public decimal? quantity_out_stock { get; set; }
/// <summary>
/// 可用库存
/// </summary>
public decimal? usable_stock { get; set; }
/// <summary>
/// 待发货
/// </summary>
public decimal? quantity_unshipped { get; set; }
}
}
...@@ -459,7 +459,7 @@ namespace AutoTurnOver.Services ...@@ -459,7 +459,7 @@ namespace AutoTurnOver.Services
/// <summary> /// <summary>
/// 缺货推送 (分页推送) /// 缺货推送 (分页推送)
/// </summary> /// </summary>
public static List<ShortagePush_Item_RequestDto> ShortagePush(List<dc_auto_shortage_push> datas) public static List<ShortagePush_Item_RequestDto> ShortagePush(List<dc_auto_shortage_push> datas,string platform)
{ {
var err_datas = new List<ShortagePush_Item_RequestDto>(); var err_datas = new List<ShortagePush_Item_RequestDto>();
...@@ -471,6 +471,7 @@ namespace AutoTurnOver.Services ...@@ -471,6 +471,7 @@ namespace AutoTurnOver.Services
{ {
var result = ShortagePushApi(new ShortagePush_RequestDto var result = ShortagePushApi(new ShortagePush_RequestDto
{ {
platform= platform,
skuType = 1, skuType = 1,
amisSkuInfos = datas.Skip((page - 1) * rows).Take(rows).Select(s => new ShortagePush_Item_RequestDto amisSkuInfos = datas.Skip((page - 1) * rows).Take(rows).Select(s => new ShortagePush_Item_RequestDto
{ {
...@@ -510,7 +511,7 @@ namespace AutoTurnOver.Services ...@@ -510,7 +511,7 @@ namespace AutoTurnOver.Services
/// <summary> /// <summary>
/// 回货速改推送 (分页推送) /// 回货速改推送 (分页推送)
/// </summary> /// </summary>
public static List<ShortagePush_Item_RequestDto> ReturnGoodsPush(List<dc_return_goods_push> datas) public static List<ShortagePush_Item_RequestDto> ReturnGoodsPush(List<dc_return_goods_push> datas, string platform)
{ {
var err_datas = new List<ShortagePush_Item_RequestDto>(); var err_datas = new List<ShortagePush_Item_RequestDto>();
...@@ -522,6 +523,7 @@ namespace AutoTurnOver.Services ...@@ -522,6 +523,7 @@ namespace AutoTurnOver.Services
{ {
var result = ReturnGoodsPushApi(new ShortagePush_RequestDto var result = ReturnGoodsPushApi(new ShortagePush_RequestDto
{ {
platform = platform,
skuType = 2, skuType = 2,
amisSkuInfos = datas.Skip((page - 1) * rows).Take(rows).Select(s => new ShortagePush_Item_RequestDto amisSkuInfos = datas.Skip((page - 1) * rows).Take(rows).Select(s => new ShortagePush_Item_RequestDto
{ {
......
...@@ -327,7 +327,7 @@ namespace AutoTurnOver.Services ...@@ -327,7 +327,7 @@ namespace AutoTurnOver.Services
if (datas.Count <= 200 && datas.Count >= 1 && !m.isSum) if (datas.Count <= 200 && datas.Count >= 1 && !m.isSum)
{ {
var orders = datas.Select(s => ("ebay".Equals(s.platform_type,StringComparison.OrdinalIgnoreCase) ? s.transaction_id : s.origin_order_id)).ToList(); var orders = datas.Select(s => ("ebay".Equals(s.platform_type, StringComparison.OrdinalIgnoreCase) ? s.transaction_id : s.origin_order_id)).ToList();
//var crm_case_order_list = ApiServices.CrmCaseOrder(orders); //var crm_case_order_list = ApiServices.CrmCaseOrder(orders);
//var crm_case_message_list = ApiServices.CrmMessage(orders); //var crm_case_message_list = ApiServices.CrmMessage(orders);
//var crm_case_message_reply_list = ApiServices.CrmMessageReply(orders); //var crm_case_message_reply_list = ApiServices.CrmMessageReply(orders);
...@@ -446,22 +446,69 @@ namespace AutoTurnOver.Services ...@@ -446,22 +446,69 @@ namespace AutoTurnOver.Services
return result_data; return result_data;
} }
public void ShortagePush(bool is_all = false,string platform = null)
{
// 国内仓
List<string> platform1s = new List<string> {"ebay","amazon", "aliexpress", "shopee", "wish", "lazada" };
foreach (var item in platform1s.Where(s=> string.IsNullOrWhiteSpace(platform) || platform==s))
{
List<dc_auto_shortage_push> datas = new List<dc_auto_shortage_push>();
datas.AddRange(report.ChinaShortagePush(item, is_all));
var err_datas = ApiServices.ShortagePush(datas, item);
// 记录推送状态
report.AddShortagePush(datas.Where(s => !err_datas.Any(e => e.warehouseCode == s.warehouse_code && s.bailun_sku == e.sku)));
}
//国外仓1
List<string> platform2s = new List<string> { "ebay", "wish" };
List<string> rule1 = new List<string> { "GBYKD", "JZHYBLGC", "MDBLWYT", "MXBLWYT", "BLUSGDC", "GBBMHBL", "GB4PXBL", "DEBLDG", "USGCBL", "USHWBL", "US4PXBL", "AUWYTBL", "AU4PXBL", "GBWYTUK", "BLGBPX" };
foreach (var item in platform2s.Where(s => string.IsNullOrWhiteSpace(platform) || platform == s))
{
List<dc_auto_shortage_push> datas = new List<dc_auto_shortage_push>();
datas.AddRange(report.NotChinaShortagePush(rule1, item, is_all));
var err_datas = ApiServices.ShortagePush(datas, item);
// 记录推送状态
report.AddShortagePush(datas.Where(s => !err_datas.Any(e => e.warehouseCode == s.warehouse_code && s.bailun_sku == e.sku)));
}
// 国外仓2
List<string> platform3s = new List<string> { "opensky", "sears", "walmart" };
List<string> rule2 = new List<string> {"MDBLWYT", "MXBLWYT", "BLUSGDC", "USGCBL", "USHWBL", "US4PXBL" };
foreach (var item in platform3s.Where(s => string.IsNullOrWhiteSpace(platform) || platform == s))
{
List<dc_auto_shortage_push> datas = new List<dc_auto_shortage_push>();
datas.AddRange(report.NotChinaShortagePush(rule2, item, is_all));
var err_datas = ApiServices.ShortagePush(datas, item);
// 记录推送状态
report.AddShortagePush(datas.Where(s => !err_datas.Any(e => e.warehouseCode == s.warehouse_code && s.bailun_sku == e.sku)));
}
}
/// <summary> /// <summary>
/// 缺货推送 /// 缺货推送
/// </summary> /// </summary>
public void ShortagePush(bool is_all = false) public void EbayShortagePush(bool is_all = false)
{ {
var datas = report.ShortagePush(is_all); var datas = report.EbayShortagePush(is_all);
var err_datas = ApiServices.ShortagePush(datas); var err_datas = ApiServices.ShortagePush(datas, "ebay");
// 记录推送状态 // 记录推送状态
report.AddShortagePush(datas.Where(s=> !err_datas.Any(e=>e.warehouseCode==s.warehouse_code && s.bailun_sku==e.sku ))); report.AddShortagePush(datas.Where(s => !err_datas.Any(e => e.warehouseCode == s.warehouse_code && s.bailun_sku == e.sku)));
} }
public void ReturnGoodsPush(string platform = null)
public void ReturnGoodsPush() {
var platform_list = new List<string> { "ebay", "amazon", "aliexpress", "shopee", "wish", "lazada","opensky", "sears", "walmart" };
foreach (var item in platform_list.Where(s => string.IsNullOrWhiteSpace(platform) || platform == s))
{
PlatformReturnGoodsPush(item);
}
}
public void PlatformReturnGoodsPush(string platform)
{ {
var datas = report.ReturnGoodsPush(); var datas = report.ReturnGoodsPush(platform);
var err_datas = ApiServices.ReturnGoodsPush(datas); var err_datas = ApiServices.ReturnGoodsPush(datas, platform);
// 记录推送状态 // 记录推送状态
report.AddReturnGoodsPush(datas.Where(s => !err_datas.Any(e => e.warehouseCode == s.warehouse_code && s.bailun_sku == e.sku))); report.AddReturnGoodsPush(datas.Where(s => !err_datas.Any(e => e.warehouseCode == s.warehouse_code && s.bailun_sku == e.sku)));
......
...@@ -12,7 +12,7 @@ namespace ShortagePush ...@@ -12,7 +12,7 @@ namespace ShortagePush
static async Task Main(string[] args) static async Task Main(string[] args)
{ {
Console.WriteLine("推送缺货数据服务"); Console.WriteLine("推送缺货数据服务");
//var datas = report.ShortagePush(); new ReportServices().ShortagePush();
var builder = new HostBuilder().ConfigureServices((hostContext, services) => var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{ {
services.AddHostedService<ShortagePushBackgroundService>(); services.AddHostedService<ShortagePushBackgroundService>();
......
...@@ -20,11 +20,11 @@ namespace ShortagePush ...@@ -20,11 +20,11 @@ namespace ShortagePush
try try
{ {
System.Console.WriteLine($"开始推送改零数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); System.Console.WriteLine($"开始推送改零数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
new ReportServices().ShortagePush(); new ReportServices().ShortagePush(platform:"ebay");
System.Console.WriteLine($"结束推送改零数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); System.Console.WriteLine($"结束推送改零数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
System.Console.WriteLine($"开始推送回货数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); System.Console.WriteLine($"开始推送回货数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
new ReportServices().ReturnGoodsPush(); new ReportServices().ReturnGoodsPush("ebay");
System.Console.WriteLine($"结束推送回货数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); System.Console.WriteLine($"结束推送回货数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
} }
catch (Exception ex) catch (Exception ex)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment