Commit 503903de by 泽锋 李

第三方海外仓统计表

parent 38141ab7
...@@ -238,7 +238,7 @@ where 1=1 ...@@ -238,7 +238,7 @@ where 1=1
} }
} }
if( !string.IsNullOrWhiteSpace(m.platform_type)) if (!string.IsNullOrWhiteSpace(m.platform_type))
{ {
sql += " and t1.platform_type=@platform_type "; sql += " and t1.platform_type=@platform_type ";
countSql += " and t1.platform_type=@platform_type "; countSql += " and t1.platform_type=@platform_type ";
...@@ -562,7 +562,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh ...@@ -562,7 +562,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh
return shortage_list; return shortage_list;
} }
} }
...@@ -638,7 +638,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh ...@@ -638,7 +638,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh
/// </summary> /// </summary>
/// <param name="is_all">是否全量数据</param> /// <param name="is_all">是否全量数据</param>
/// <returns></returns> /// <returns></returns>
public static List<dc_auto_shortage_push> NotChinaShortagePush(List<string> warehouse_codes,string platform, bool is_all = false) public static List<dc_auto_shortage_push> NotChinaShortagePush(List<string> warehouse_codes, string platform, 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>();
...@@ -682,7 +682,7 @@ and ( ifnull(t6.usable_stock,0)<ifnull(t7.quantity_unshipped,0) ) -- 有缺货 ...@@ -682,7 +682,7 @@ and ( ifnull(t6.usable_stock,0)<ifnull(t7.quantity_unshipped,0) ) -- 有缺货
{ {
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}' and dc_auto_shortage_push.has_return_goods=0 ) "; 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}' and dc_auto_shortage_push.has_return_goods=0 ) ";
} }
//shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(sql,new { warehouse_codes = warehouse_codes, platform = platform }, commandTimeout: 0)); //shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(sql,new { warehouse_codes = warehouse_codes, platform = platform }, commandTimeout: 0));
// 0库存推送 // 0库存推送
...@@ -714,7 +714,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh ...@@ -714,7 +714,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh
{ {
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}' and dc_auto_shortage_push.has_return_goods=0 ) "; 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}' and dc_auto_shortage_push.has_return_goods=0 ) ";
} }
shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(no_library_sql,new { warehouse_codes = warehouse_codes, platform = platform }, commandTimeout: 0)); shortage_list.AddRange(conn.Query<dc_auto_shortage_push>(no_library_sql, new { warehouse_codes = warehouse_codes, platform = platform }, commandTimeout: 0));
return shortage_list; return shortage_list;
...@@ -765,7 +765,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh ...@@ -765,7 +765,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh
{ {
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' ) "; 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));
// 0库存推送 // 0库存推送
string no_library_sql = @" select t1.bailun_sku, string no_library_sql = @" select t1.bailun_sku,
...@@ -826,7 +826,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh ...@@ -826,7 +826,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh
public static void removeShortagePush(IEnumerable<int> datas) public static void removeShortagePush(IEnumerable<int> datas)
{ {
if(datas!=null && datas.Count() >= 1) if (datas != null && datas.Count() >= 1)
{ {
var conn = _connection; var conn = _connection;
//foreach (var item in datas) //foreach (var item in datas)
...@@ -835,7 +835,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh ...@@ -835,7 +835,7 @@ and not exists ( select * from dc_auto_shortage_push_not_config where dc_auto_sh
//} //}
conn.Execute(" update dc_auto_shortage_push set has_return_goods=1 where id in @ids ", new { ids = datas }); conn.Execute(" update dc_auto_shortage_push set has_return_goods=1 where id in @ids ", new { ids = datas });
} }
} }
...@@ -1065,7 +1065,7 @@ end ...@@ -1065,7 +1065,7 @@ end
) )
"; ";
shortage_list.AddRange(conn.Query<dc_return_goods_push>(sql,new { platform= platform }, commandTimeout: 0)); shortage_list.AddRange(conn.Query<dc_return_goods_push>(sql, new { platform = platform }, commandTimeout: 0));
return shortage_list; return shortage_list;
...@@ -1102,7 +1102,7 @@ else 0 ...@@ -1102,7 +1102,7 @@ else 0
end end
) = 1 ) = 1
"; ";
shortage_list.AddRange(conn.Query<dc_return_goods_push>(sql,new { platform= platform }, commandTimeout: 0)); shortage_list.AddRange(conn.Query<dc_return_goods_push>(sql, new { platform = platform }, commandTimeout: 0));
return shortage_list; return shortage_list;
...@@ -1126,12 +1126,12 @@ end ...@@ -1126,12 +1126,12 @@ end
public static int MarkReturnSpeedChange(return_speed_change_search_dto m) public static int MarkReturnSpeedChange(return_speed_change_search_dto m)
{ {
int total = 0; int total = 0;
var datas = ReturnSpeedChange(m, 0, int.MaxValue,ref total); var datas = ReturnSpeedChange(m, 0, int.MaxValue, ref total);
if (datas == null) if (datas == null)
{ {
throw new Exception("未选择数据"); throw new Exception("未选择数据");
} }
_connection.Execute(" delete from dc_outofstock_history where id in @ids ",new { ids = datas.Select(s=>s.id).ToArray() }); _connection.Execute(" delete from dc_outofstock_history where id in @ids ", new { ids = datas.Select(s => s.id).ToArray() });
return datas.Count(); return datas.Count();
} }
...@@ -1362,44 +1362,44 @@ alter table buy_ontheway_detailTemp rename buy_ontheway_detail_temp; ...@@ -1362,44 +1362,44 @@ alter table buy_ontheway_detailTemp rename buy_ontheway_detail_temp;
truncate table buy_ontheway_detail_temp; ", commandTimeout: 0); truncate table buy_ontheway_detail_temp; ", commandTimeout: 0);
//刷新无库仓商品日均 //刷新无库仓商品日均
// _connection.Execute(@" -- 刷新无库仓商品日均 // _connection.Execute(@" -- 刷新无库仓商品日均
//set session transaction isolation level read uncommitted; //set session transaction isolation level read uncommitted;
//start transaction; //start transaction;
//-- 清空视图表的数据 //-- 清空视图表的数据
//Truncate table dc_not_stock_goods_sales_temp; //Truncate table dc_not_stock_goods_sales_temp;
//INSERT into dc_not_stock_goods_sales_temp(`product_inner_code`,`warehouse_code`,`test_sales`,`success_sales`) ( //INSERT into dc_not_stock_goods_sales_temp(`product_inner_code`,`warehouse_code`,`test_sales`,`success_sales`) (
// select // select
//t2.product_inner_code,t2.warehouse_code, //t2.product_inner_code,t2.warehouse_code,
//sum(case when TIMESTAMPDIFF(day,t2.push_time,t1.pay_time)<=21 then t1.bailun_sku_quantity_ordered else 0 end) as 'test_sales', -- 推送之后 21 日的销量 //sum(case when TIMESTAMPDIFF(day,t2.push_time,t1.pay_time)<=21 then t1.bailun_sku_quantity_ordered else 0 end) as 'test_sales', -- 推送之后 21 日的销量
//sum(case when TIMESTAMPDIFF(day,t1.pay_time,now())<=7 then t1.bailun_sku_quantity_ordered else 0 end) as 'success_sales' -- 最近7日销量 //sum(case when TIMESTAMPDIFF(day,t1.pay_time,now())<=7 then t1.bailun_sku_quantity_ordered else 0 end) as 'success_sales' -- 最近7日销量
//from dc_base_sku as t2 //from dc_base_sku as t2
//left join dc_base_oms_sku as t1 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code //left join dc_base_oms_sku as t1 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
//left join dc_auto_config_sku_warehouse as t3 on t1.bailun_sku = t3.bailun_sku and t1.warehouse_code = t3.warehouse_code //left join dc_auto_config_sku_warehouse as t3 on t1.bailun_sku = t3.bailun_sku and t1.warehouse_code = t3.warehouse_code
//where t2.warehouse_code='BLGZ03' and (t1.id is null or t1.bailun_order_status!='Canceled') and (t3.`status`=0 or t3.`status` is null) and t2.push_time >= '2010-01-01' //where t2.warehouse_code='BLGZ03' and (t1.id is null or t1.bailun_order_status!='Canceled') and (t3.`status`=0 or t3.`status` is null) and t2.push_time >= '2010-01-01'
//GROUP BY t2.product_inner_code,t2.warehouse_code //GROUP BY t2.product_inner_code,t2.warehouse_code
//); //);
//alter table dc_not_stock_goods_sales rename dc_not_stock_goods_salesTemp; //alter table dc_not_stock_goods_sales rename dc_not_stock_goods_salesTemp;
//alter table dc_not_stock_goods_sales_temp rename dc_not_stock_goods_sales; //alter table dc_not_stock_goods_sales_temp rename dc_not_stock_goods_sales;
//alter table dc_not_stock_goods_salesTemp rename dc_not_stock_goods_sales_temp; //alter table dc_not_stock_goods_salesTemp rename dc_not_stock_goods_sales_temp;
//truncate table dc_not_stock_goods_sales_temp; ", commandTimeout: 0); //truncate table dc_not_stock_goods_sales_temp; ", commandTimeout: 0);
// _connection.Execute(@" -- 记录历史缺货 // _connection.Execute(@" -- 记录历史缺货
//set session transaction isolation level read uncommitted; //set session transaction isolation level read uncommitted;
//start transaction; //start transaction;
//insert ignore into dc_outofstock_history(`bailun_sku`,`warehouse_code`,`date`) ( //insert ignore into dc_outofstock_history(`bailun_sku`,`warehouse_code`,`date`) (
// select // select
// t1.bailun_sku,t1.warehouse_code,now() as 'date' // t1.bailun_sku,t1.warehouse_code,now() as 'date'
// 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
//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 china_warehouse_stock as t3 on t1.bailun_sku = t3.bailun_sku and t_db.hq_type='国内仓' //left join china_warehouse_stock as t3 on t1.bailun_sku = t3.bailun_sku and t_db.hq_type='国内仓'
//left join china_warehouse_unshipped as t4 on t1.bailun_sku = t4.bailun_sku and t_db.hq_type='国内仓' //left join china_warehouse_unshipped as t4 on t1.bailun_sku = t4.bailun_sku and t_db.hq_type='国内仓'
//where ( t_db.hq_type!='国内仓' or t2.buyer_name not in ('张莹霞','张莹霞1') ) and t_db.hq_type!='fba仓' and (case when t_db.hq_type='国内仓' then (ifnull(t4.sum_unshipped_quantity,0) - ifnull(t3.sum_usable_stock,0)) else t1.quantity_out_stock end )>0 //where ( t_db.hq_type!='国内仓' or t2.buyer_name not in ('张莹霞','张莹霞1') ) and t_db.hq_type!='fba仓' and (case when t_db.hq_type='国内仓' then (ifnull(t4.sum_unshipped_quantity,0) - ifnull(t3.sum_usable_stock,0)) else t1.quantity_out_stock end )>0
//) "); //) ");
_connection.Execute(@" -- 刷新在途 _connection.Execute(@" -- 刷新在途
set session transaction isolation level read uncommitted; set session transaction isolation level read uncommitted;
start transaction; start transaction;
...@@ -1446,7 +1446,7 @@ GROUP BY ...@@ -1446,7 +1446,7 @@ GROUP BY
alter table dc_auto_purchase_ontheway rename dc_auto_purchase_onthewayTemp; alter table dc_auto_purchase_ontheway rename dc_auto_purchase_onthewayTemp;
alter table dc_auto_purchase_ontheway_temp rename dc_auto_purchase_ontheway; alter table dc_auto_purchase_ontheway_temp rename dc_auto_purchase_ontheway;
alter table dc_auto_purchase_onthewayTemp rename dc_auto_purchase_ontheway_temp; alter table dc_auto_purchase_onthewayTemp rename dc_auto_purchase_ontheway_temp;
truncate table dc_auto_purchase_ontheway_temp; ",commandTimeout:0); truncate table dc_auto_purchase_ontheway_temp; ", commandTimeout: 0);
_connection.Execute(@"-- 刷新 订单sku 标签表 _connection.Execute(@"-- 刷新 订单sku 标签表
set session transaction isolation level read uncommitted; set session transaction isolation level read uncommitted;
...@@ -1601,7 +1601,7 @@ where t1.company_id=1 and t1.has_innersale=0 and t1.create_time>@time and t1.ha ...@@ -1601,7 +1601,7 @@ where t1.company_id=1 and t1.has_innersale=0 and t1.create_time>@time and t1.ha
alter table dc_base_oms_sku_7 rename dc_base_oms_sku_7Temp; alter table dc_base_oms_sku_7 rename dc_base_oms_sku_7Temp;
alter table dc_base_oms_sku_7_temp rename dc_base_oms_sku_7; alter table dc_base_oms_sku_7_temp rename dc_base_oms_sku_7;
alter table dc_base_oms_sku_7Temp rename dc_base_oms_sku_7_temp; alter table dc_base_oms_sku_7Temp rename dc_base_oms_sku_7_temp;
truncate table dc_base_oms_sku_7_temp; ", new { time = DateTime.Now.AddDays(-8).ToString("yyyy-MM-dd 00:00:00") },commandTimeout:0); truncate table dc_base_oms_sku_7_temp; ", new { time = DateTime.Now.AddDays(-8).ToString("yyyy-MM-dd 00:00:00") }, commandTimeout: 0);
_connection.Execute(@" _connection.Execute(@"
set session transaction isolation level read uncommitted; set session transaction isolation level read uncommitted;
...@@ -1664,8 +1664,8 @@ INSERT into dc_auto_monitor_sku_temp(`bailun_sku`) ( ...@@ -1664,8 +1664,8 @@ INSERT into dc_auto_monitor_sku_temp(`bailun_sku`) (
alter table dc_auto_monitor_sku rename dc_auto_monitor_skuTemp; alter table dc_auto_monitor_sku rename dc_auto_monitor_skuTemp;
alter table dc_auto_monitor_sku_temp rename dc_auto_monitor_sku; alter table dc_auto_monitor_sku_temp rename dc_auto_monitor_sku;
alter table dc_auto_monitor_skuTemp rename dc_auto_monitor_sku_temp; alter table dc_auto_monitor_skuTemp rename dc_auto_monitor_sku_temp;
truncate table dc_auto_monitor_sku_temp; ", commandTimeout: 0); truncate table dc_auto_monitor_sku_temp; ", commandTimeout: 0);
_connection.Execute(@" -- 刷新 订单 dc_auto_monitor_sku_type_temp 映射表 _connection.Execute(@" -- 刷新 订单 dc_auto_monitor_sku_type_temp 映射表
set session transaction isolation level read uncommitted; set session transaction isolation level read uncommitted;
start transaction; start transaction;
...@@ -1843,7 +1843,7 @@ truncate table dc_base_stock_record_temp; ...@@ -1843,7 +1843,7 @@ truncate table dc_base_stock_record_temp;
", commandTimeout: 0); ", commandTimeout: 0);
_connection.Execute(@" -- 刷新sku汇总 _connection.Execute(@" -- 刷新sku汇总
set session transaction isolation level read uncommitted; set session transaction isolation level read uncommitted;
start transaction; start transaction;
...@@ -1960,7 +1960,7 @@ GROUP BY t1.bailun_sku,t1.warehouse_code; ...@@ -1960,7 +1960,7 @@ GROUP BY t1.bailun_sku,t1.warehouse_code;
alter table dc_base_lastweek_data rename dc_base_lastweek_dataTemp; alter table dc_base_lastweek_data rename dc_base_lastweek_dataTemp;
alter table dc_base_lastweek_data_temp rename dc_base_lastweek_data; alter table dc_base_lastweek_data_temp rename dc_base_lastweek_data;
alter table dc_base_lastweek_dataTemp rename dc_base_lastweek_data_temp; alter table dc_base_lastweek_dataTemp rename dc_base_lastweek_data_temp;
truncate table dc_base_lastweek_data_temp; ", new { btime = DateTime.Now.AddDays(-7).GetWeekFirstDayMon().ToDayHome(),etime = DateTime.Now.AddDays(-7).GetWeekLastDaySun().ToDayEnd() }, commandTimeout: 0); truncate table dc_base_lastweek_data_temp; ", new { btime = DateTime.Now.AddDays(-7).GetWeekFirstDayMon().ToDayHome(), etime = DateTime.Now.AddDays(-7).GetWeekLastDaySun().ToDayEnd() }, commandTimeout: 0);
} }
public static void ResetCashFlowData() public static void ResetCashFlowData()
...@@ -1980,7 +1980,7 @@ insert dc_report_cash_flow_group_day_temp (`platform_type`,`web_site`,`year`,`mo ...@@ -1980,7 +1980,7 @@ insert dc_report_cash_flow_group_day_temp (`platform_type`,`web_site`,`year`,`mo
select platform_type,web_site,year(occur_time) as 'year',month(occur_time) as 'month',day(occur_time) as 'day',sum(val) as 'val',data_type,1,min(occur_time) as 'date' from dc_report_cash_flow_log where is_delete=0 and occur_time>=@btime GROUP BY occur_time_year_month_no,day(occur_time) select platform_type,web_site,year(occur_time) as 'year',month(occur_time) as 'month',day(occur_time) as 'day',sum(val) as 'val',data_type,1,min(occur_time) as 'date' from dc_report_cash_flow_log where is_delete=0 and occur_time>=@btime GROUP BY occur_time_year_month_no,day(occur_time)
) )
; ;
", new { btime =DateTime.Now.AddMonths(-3).ToString("yyyy-MM-01 00:00:00")}, commandTimeout: 0); ", new { btime = DateTime.Now.AddMonths(-3).ToString("yyyy-MM-01 00:00:00") }, commandTimeout: 0);
_connection.Execute(@" -- 刷新 现金流汇总表 _connection.Execute(@" -- 刷新 现金流汇总表
insert dc_report_cash_flow_group_day_temp (`platform_type`,`web_site`,`year`,`month`,`day`,`val`,`data_type`,`type`,`date`) insert dc_report_cash_flow_group_day_temp (`platform_type`,`web_site`,`year`,`month`,`day`,`val`,`data_type`,`type`,`date`)
...@@ -1994,7 +1994,8 @@ alter table dc_report_cash_flow_group_dayTemp rename dc_report_cash_flow_group_d ...@@ -1994,7 +1994,8 @@ alter table dc_report_cash_flow_group_dayTemp rename dc_report_cash_flow_group_d
truncate table dc_report_cash_flow_group_day_temp; truncate table dc_report_cash_flow_group_day_temp;
", new { btime = DateTime.Now.AddMonths(-3).ToString("yyyy-MM-01 00:00:00") }, commandTimeout: 0); ", new { btime = DateTime.Now.AddMonths(-3).ToString("yyyy-MM-01 00:00:00") }, commandTimeout: 0);
var datePar = new { var datePar = new
{
btime = DateTime.Now.GetMonthFirstDay(), btime = DateTime.Now.GetMonthFirstDay(),
etime = DateTime.Now.LastDayOfMonth().ToString("yyyy-MM-dd 23:59:59"), etime = DateTime.Now.LastDayOfMonth().ToString("yyyy-MM-dd 23:59:59"),
lastBtime = DateTime.Now.AddMonths(-1).GetMonthFirstDay(), lastBtime = DateTime.Now.AddMonths(-1).GetMonthFirstDay(),
...@@ -2059,7 +2060,7 @@ sum(case when data_type in (2) then val else 0 end ) as 'income_amount_30' ...@@ -2059,7 +2060,7 @@ sum(case when data_type in (2) then val else 0 end ) as 'income_amount_30'
from dc_report_cash_flow_log where occur_time >=@btime and is_delete=0 and data_type in (2,3,5,8,9,10,11,12,13,14) GROUP BY bailun_sku,warehouse_code ) as t2 from dc_report_cash_flow_log where occur_time >=@btime and is_delete=0 and data_type in (2,3,5,8,9,10,11,12,13,14) GROUP BY bailun_sku,warehouse_code ) as t2
set t1.pay_amount_30 =t2.pay_amount_30, t1.income_amount_30 = t2.income_amount_30 set t1.pay_amount_30 =t2.pay_amount_30, t1.income_amount_30 = t2.income_amount_30
where t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code; where t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code;
", new { btime = DateTime.Now.AddDays(-30).ToDayHome()},commandTimeout: 0); ", new { btime = DateTime.Now.AddDays(-30).ToDayHome() }, commandTimeout: 0);
_connection.Execute(@" _connection.Execute(@"
update dc_base_stock set available_days=0; update dc_base_stock set available_days=0;
...@@ -2254,9 +2255,9 @@ truncate table dc_auto_stock_monitor_temp; ", commandTimeout: 0); ...@@ -2254,9 +2255,9 @@ truncate table dc_auto_stock_monitor_temp; ", commandTimeout: 0);
sql += " and t2.label = @label "; sql += " and t2.label = @label ";
parameters.Add("label", search_data.label); parameters.Add("label", search_data.label);
} }
if(search_data.year>0 && search_data.month>0 && search_data.day > 0) if (search_data.year > 0 && search_data.month > 0 && search_data.day > 0)
{ {
var b_time = new DateTime(search_data.year,search_data.month,search_data.day,0,0,0); var b_time = new DateTime(search_data.year, search_data.month, search_data.day, 0, 0, 0);
sql += " and t1.pay_time >= @b_time and t1.pay_time <= @e_time "; sql += " and t1.pay_time >= @b_time and t1.pay_time <= @e_time ";
parameters.Add("b_time", b_time); parameters.Add("b_time", b_time);
parameters.Add("e_time", b_time.ToString("yyyy-MM-dd 23:59:59")); parameters.Add("e_time", b_time.ToString("yyyy-MM-dd 23:59:59"));
...@@ -2276,7 +2277,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2276,7 +2277,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
DynamicParameters parameters = new DynamicParameters(); DynamicParameters parameters = new DynamicParameters();
if (search_data != null) if (search_data != null)
{ {
if(search_data.btime!=null && search_data.etime!=null) if (search_data.btime != null && search_data.etime != null)
{ {
sql += " and t1.paid_time>=@btime and t1.paid_time<=@etime "; sql += " and t1.paid_time>=@btime and t1.paid_time<=@etime ";
parameters.Add("btime", search_data.btime.Value.ToString("yyyy-MM-dd 00:00:00")); parameters.Add("btime", search_data.btime.Value.ToString("yyyy-MM-dd 00:00:00"));
...@@ -2284,7 +2285,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2284,7 +2285,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
} }
if (!string.IsNullOrWhiteSpace(search_data.platform_type)) if (!string.IsNullOrWhiteSpace(search_data.platform_type))
{ {
if("amazon".Equals(search_data.platform_type, StringComparison.OrdinalIgnoreCase)) if ("amazon".Equals(search_data.platform_type, StringComparison.OrdinalIgnoreCase))
{ {
sql += " and t1.platform_type in @platform_types "; sql += " and t1.platform_type in @platform_types ";
parameters.Add("platform_types", new List<string> { "Amazon", "FBA" }); parameters.Add("platform_types", new List<string> { "Amazon", "FBA" });
...@@ -2294,7 +2295,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2294,7 +2295,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
sql += " and t1.platform_type = @platform_type "; sql += " and t1.platform_type = @platform_type ";
parameters.Add("platform_type", search_data.platform_type); parameters.Add("platform_type", search_data.platform_type);
} }
} }
if (!string.IsNullOrWhiteSpace(search_data.warehousetype)) if (!string.IsNullOrWhiteSpace(search_data.warehousetype))
{ {
...@@ -2328,15 +2329,15 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2328,15 +2329,15 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
} }
var oms_sku_list = _connection.Query<dc_base_oms_sku_label>(sql, parameters); var oms_sku_list = _connection.Query<dc_base_oms_sku_label>(sql, parameters);
List<bailun_sku_website_sales_dto> datas = new List<bailun_sku_website_sales_dto>(); List<bailun_sku_website_sales_dto> datas = new List<bailun_sku_website_sales_dto>();
var website_list = oms_sku_list.GroupBy(s=>new { s.platform_type,s.website}).Where(s=> !"EBayMotors".Equals(s.Key.website,StringComparison.OrdinalIgnoreCase)).OrderBy(s=>s.Key.platform_type); var website_list = oms_sku_list.GroupBy(s => new { s.platform_type, s.website }).Where(s => !"EBayMotors".Equals(s.Key.website, StringComparison.OrdinalIgnoreCase)).OrderBy(s => s.Key.platform_type);
if (search_data.has_sum == true) if (search_data.has_sum == true)
{ {
datas.Add(new bailun_sku_website_sales_dto datas.Add(new bailun_sku_website_sales_dto
{ {
label = "总计", label = "总计",
labels = new List<string> { "服装精准开发", "服装供应商推荐", "非服装精准开发", "无库普货推荐","美甲", "精油+美容" }, labels = new List<string> { "服装精准开发", "服装供应商推荐", "非服装精准开发", "无库普货推荐", "美甲", "精油+美容" },
website = "总计", website = "总计",
website_show = "总计", website_show = "总计",
platform_type = "总计", platform_type = "总计",
...@@ -2454,7 +2455,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2454,7 +2455,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
platform_type = search_data.platform_type, platform_type = search_data.platform_type,
days = new List<bailun_sku_website_sales_dto.bailun_sku_website_sales_date_dto>() days = new List<bailun_sku_website_sales_dto.bailun_sku_website_sales_date_dto>()
}); });
foreach (var item in website_list) foreach (var item in website_list)
{ {
datas.Add(new bailun_sku_website_sales_dto datas.Add(new bailun_sku_website_sales_dto
...@@ -2476,7 +2477,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2476,7 +2477,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
platform_type = search_data.platform_type, platform_type = search_data.platform_type,
days = new List<bailun_sku_website_sales_dto.bailun_sku_website_sales_date_dto>() days = new List<bailun_sku_website_sales_dto.bailun_sku_website_sales_date_dto>()
}); });
foreach (var item in website_list) foreach (var item in website_list)
{ {
datas.Add(new bailun_sku_website_sales_dto datas.Add(new bailun_sku_website_sales_dto
...@@ -2500,20 +2501,20 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2500,20 +2501,20 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
}); });
} }
var b_time = DateTime.Now.AddDays(-1); var b_time = DateTime.Now.AddDays(-1);
var e_time = b_time.AddDays(-7); var e_time = b_time.AddDays(-7);
if(search_data.btime!=null && search_data.etime!=null) if (search_data.btime != null && search_data.etime != null)
{ {
e_time = search_data.btime.Value; e_time = search_data.btime.Value;
b_time = search_data.etime.Value; b_time = search_data.etime.Value;
} }
var this_time = b_time; var this_time = b_time;
while (this_time>= e_time) while (this_time >= e_time)
{ {
foreach (var item in datas) foreach (var item in datas)
{ {
var temp_datas = oms_sku_list.Where(s=> s.pay_time!=null && s.pay_time.Year== this_time.Year && s.pay_time.Month == this_time.Month && s.pay_time.Day== this_time.Day); var temp_datas = oms_sku_list.Where(s => s.pay_time != null && s.pay_time.Year == this_time.Year && s.pay_time.Month == this_time.Month && s.pay_time.Day == this_time.Day);
if (!"总计".Equals(item.website)) if (!"总计".Equals(item.website))
{ {
temp_datas = temp_datas.Where(s => item.labels.Contains(s.label)); temp_datas = temp_datas.Where(s => item.labels.Contains(s.label));
...@@ -2522,12 +2523,13 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2522,12 +2523,13 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
temp_datas = temp_datas.Where(s => s.platform_type == item.platform_type && s.website == item.website); temp_datas = temp_datas.Where(s => s.platform_type == item.platform_type && s.website == item.website);
} }
} }
item.days.Add(new bailun_sku_website_sales_dto.bailun_sku_website_sales_date_dto { item.days.Add(new bailun_sku_website_sales_dto.bailun_sku_website_sales_date_dto
{
year = this_time.Year, year = this_time.Year,
month = this_time.Month, month = this_time.Month,
day = this_time.Day, day = this_time.Day,
count = temp_datas.Sum(s=>s.bailun_sku_quantity_ordered), count = temp_datas.Sum(s => s.bailun_sku_quantity_ordered),
sum = temp_datas.Sum(s => s.bailun_sku_quantity_ordered * s.amount_sales * s.order_to_usd_exchange_rate) sum = temp_datas.Sum(s => s.bailun_sku_quantity_ordered * s.amount_sales * s.order_to_usd_exchange_rate)
}); });
} }
...@@ -2537,7 +2539,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2537,7 +2539,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
return datas; return datas;
} }
public static List<bailun_sku_warehouse_code_dto> GetSkuWarehouseSales(bailun_sku_website_sales_search_dto search_data) public static List<bailun_sku_warehouse_code_dto> GetSkuWarehouseSales(bailun_sku_website_sales_search_dto search_data)
{ {
var tableName = "dc_base_oms_sku_7"; var tableName = "dc_base_oms_sku_7";
...@@ -2557,7 +2559,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2557,7 +2559,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
DynamicParameters parameters = new DynamicParameters(); DynamicParameters parameters = new DynamicParameters();
if (search_data != null) if (search_data != null)
{ {
if(search_data.btime!=null && search_data.etime!=null) if (search_data.btime != null && search_data.etime != null)
{ {
sql += " and t1.paid_time>=@btime and t1.paid_time<=@etime "; sql += " and t1.paid_time>=@btime and t1.paid_time<=@etime ";
parameters.Add("btime", search_data.btime.Value.ToString("yyyy-MM-dd 00:00:00")); parameters.Add("btime", search_data.btime.Value.ToString("yyyy-MM-dd 00:00:00"));
...@@ -2565,7 +2567,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2565,7 +2567,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
} }
if (!string.IsNullOrWhiteSpace(search_data.platform_type)) if (!string.IsNullOrWhiteSpace(search_data.platform_type))
{ {
if("amazon".Equals(search_data.platform_type, StringComparison.OrdinalIgnoreCase)) if ("amazon".Equals(search_data.platform_type, StringComparison.OrdinalIgnoreCase))
{ {
sql += " and t1.platform_type in @platform_types "; sql += " and t1.platform_type in @platform_types ";
parameters.Add("platform_types", new List<string> { "Amazon", "FBA" }); parameters.Add("platform_types", new List<string> { "Amazon", "FBA" });
...@@ -2575,7 +2577,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2575,7 +2577,7 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
sql += " and t1.platform_type = @platform_type "; sql += " and t1.platform_type = @platform_type ";
parameters.Add("platform_type", search_data.platform_type); parameters.Add("platform_type", search_data.platform_type);
} }
} }
if (!string.IsNullOrWhiteSpace(search_data.warehousetype)) if (!string.IsNullOrWhiteSpace(search_data.warehousetype))
{ {
...@@ -2595,15 +2597,15 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2595,15 +2597,15 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
} }
var oms_sku_list = _connection.Query<dc_base_oms_sku_label>(sql, parameters); var oms_sku_list = _connection.Query<dc_base_oms_sku_label>(sql, parameters);
List<bailun_sku_warehouse_code_dto> datas = new List<bailun_sku_warehouse_code_dto>(); List<bailun_sku_warehouse_code_dto> datas = new List<bailun_sku_warehouse_code_dto>();
var warehouse_code_list = oms_sku_list.GroupBy(s=>new { s.warehouse_name,s.warehouse_code}).OrderBy(s=>s.Key.warehouse_name); var warehouse_code_list = oms_sku_list.GroupBy(s => new { s.warehouse_name, s.warehouse_code }).OrderBy(s => s.Key.warehouse_name);
if (search_data.has_sum == true) if (search_data.has_sum == true)
{ {
datas.Add(new bailun_sku_warehouse_code_dto datas.Add(new bailun_sku_warehouse_code_dto
{ {
label = "总计", label = "总计",
labels = new List<string> { "服装精准开发", "服装供应商推荐", "非服装精准开发", "无库普货推荐","美甲", "精油+美容","未知" }, labels = new List<string> { "服装精准开发", "服装供应商推荐", "非服装精准开发", "无库普货推荐", "美甲", "精油+美容", "未知" },
warehouse_name = "总计", warehouse_name = "总计",
warehouse_code = "", warehouse_code = "",
days = new List<bailun_sku_warehouse_code_dto.bailun_sku_warehouse_code_date_dto>() days = new List<bailun_sku_warehouse_code_dto.bailun_sku_warehouse_code_date_dto>()
...@@ -2648,31 +2650,31 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2648,31 +2650,31 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe
} }
} }
var b_time = DateTime.Now.AddDays(-1); var b_time = DateTime.Now.AddDays(-1);
var e_time = b_time.AddDays(-7); var e_time = b_time.AddDays(-7);
if(search_data.btime!=null && search_data.etime!=null) if (search_data.btime != null && search_data.etime != null)
{ {
e_time = search_data.btime.Value; e_time = search_data.btime.Value;
b_time = search_data.etime.Value; b_time = search_data.etime.Value;
} }
var this_time = b_time; var this_time = b_time;
while (this_time>= e_time) while (this_time >= e_time)
{ {
foreach (var item in datas) foreach (var item in datas)
{ {
var temp_datas = oms_sku_list.Where(s=> s.pay_time!=null && s.pay_time.Year== this_time.Year && s.pay_time.Month == this_time.Month && s.pay_time.Day== this_time.Day); var temp_datas = oms_sku_list.Where(s => s.pay_time != null && s.pay_time.Year == this_time.Year && s.pay_time.Month == this_time.Month && s.pay_time.Day == this_time.Day);
if (!"总计".Equals(item.warehouse_name)) if (!"总计".Equals(item.warehouse_name))
{ {
temp_datas = temp_datas.Where(s => item.labels.Contains(s.label) && s.warehouse_name == item.warehouse_name); temp_datas = temp_datas.Where(s => item.labels.Contains(s.label) && s.warehouse_name == item.warehouse_name);
} }
item.days.Add(new bailun_sku_warehouse_code_dto.bailun_sku_warehouse_code_date_dto item.days.Add(new bailun_sku_warehouse_code_dto.bailun_sku_warehouse_code_date_dto
{ {
year = this_time.Year, year = this_time.Year,
month = this_time.Month, month = this_time.Month,
day = this_time.Day, day = this_time.Day,
count = temp_datas.Sum(s=>s.bailun_sku_quantity_ordered), count = temp_datas.Sum(s => s.bailun_sku_quantity_ordered),
sum = temp_datas.Sum(s => s.bailun_sku_quantity_ordered * s.amount_sales * s.order_to_usd_exchange_rate) sum = temp_datas.Sum(s => s.bailun_sku_quantity_ordered * s.amount_sales * s.order_to_usd_exchange_rate)
}); });
} }
...@@ -2726,7 +2728,7 @@ where t2.buyer_name = '赵美聪' ...@@ -2726,7 +2728,7 @@ where t2.buyer_name = '赵美聪'
"; ";
parameters.Add("time1",DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00")); parameters.Add("time1", DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00"));
parameters.Add("time2", DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59")); parameters.Add("time2", DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59"));
parameters.Add("time3", DateTime.Now.AddDays(-8).ToString("yyyy-MM-dd 00:00:00")); parameters.Add("time3", DateTime.Now.AddDays(-8).ToString("yyyy-MM-dd 00:00:00"));
parameters.Add("time4", DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd 00:00:00")); parameters.Add("time4", DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd 00:00:00"));
...@@ -2765,7 +2767,7 @@ where t2.buyer_name = '赵美聪' ...@@ -2765,7 +2767,7 @@ where t2.buyer_name = '赵美聪'
sql += " limit " + offset + "," + limit; sql += " limit " + offset + "," + limit;
} }
var obj = _connection.Query<supplier_sales_dto>(sql, parameters, buffered: false, commandTimeout: 0); var obj = _connection.Query<supplier_sales_dto>(sql, parameters, buffered: false, commandTimeout: 0);
return obj.AsList(); return obj.AsList();
...@@ -2797,14 +2799,14 @@ where t2.buyer_name = '赵美聪' ...@@ -2797,14 +2799,14 @@ where t2.buyer_name = '赵美聪'
List<bailun_sku_goods_dto> datas = new List<bailun_sku_goods_dto>(); List<bailun_sku_goods_dto> datas = new List<bailun_sku_goods_dto>();
var website_list = oms_sku_list.GroupBy(s => new { s.platform_type, s.website }).OrderBy(s => s.Key.platform_type).ToList(); var website_list = oms_sku_list.GroupBy(s => new { s.platform_type, s.website }).OrderBy(s => s.Key.platform_type).ToList();
if (search_data.has_sum == true) if (search_data.has_sum == true)
{ {
total = 0; total = 0;
datas.Add(new bailun_sku_goods_dto datas.Add(new bailun_sku_goods_dto
{ {
product_inner_code ="总计", product_inner_code = "总计",
bailun_category_name = "", bailun_category_name = "",
sku_title_cn = "", sku_title_cn = "",
websites = new List<bailun_sku_goods_dto.bailun_sku_goods_date_dto>() websites = new List<bailun_sku_goods_dto.bailun_sku_goods_date_dto>()
...@@ -2826,11 +2828,11 @@ where t2.buyer_name = '赵美聪' ...@@ -2826,11 +2828,11 @@ where t2.buyer_name = '赵美聪'
}); });
} }
} }
var now = DateTime.Now; var now = DateTime.Now;
var yesterday_time = DateTime.Now.AddDays(-1); var yesterday_time = DateTime.Now.AddDays(-1);
var time_7 = DateTime.Parse( DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd 00:00:00")); var time_7 = DateTime.Parse(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd 00:00:00"));
foreach (var website_item in website_list) foreach (var website_item in website_list)
{ {
foreach (var item in datas) foreach (var item in datas)
...@@ -2842,12 +2844,12 @@ where t2.buyer_name = '赵美聪' ...@@ -2842,12 +2844,12 @@ where t2.buyer_name = '赵美聪'
} }
var yesterday_datas = temp_datas.Where(s => s.create_time.Year == yesterday_time.Year && s.create_time.Month == yesterday_time.Month && s.create_time.Day == yesterday_time.Day); var yesterday_datas = temp_datas.Where(s => s.create_time.Year == yesterday_time.Year && s.create_time.Month == yesterday_time.Month && s.create_time.Day == yesterday_time.Day);
var datas_7 = temp_datas.Where(s => s.create_time >= time_7); var datas_7 = temp_datas.Where(s => s.create_time >= time_7);
var sum_count_7 = temp_datas.Sum(s=>s.bailun_sku_quantity_ordered); // 7日总销量 var sum_count_7 = temp_datas.Sum(s => s.bailun_sku_quantity_ordered); // 7日总销量
item.websites.Add(new bailun_sku_goods_dto.bailun_sku_goods_date_dto item.websites.Add(new bailun_sku_goods_dto.bailun_sku_goods_date_dto
{ {
platform_type = website_item.Key.platform_type, platform_type = website_item.Key.platform_type,
website = website_item.Key.website, website = website_item.Key.website,
yesterday_count = yesterday_datas.Sum(s=>s.bailun_sku_quantity_ordered), yesterday_count = yesterday_datas.Sum(s => s.bailun_sku_quantity_ordered),
yesterday_amount = yesterday_datas.Sum(s => s.bailun_sku_quantity_ordered * s.amount_sales * s.order_to_usd_exchange_rate), yesterday_amount = yesterday_datas.Sum(s => s.bailun_sku_quantity_ordered * s.amount_sales * s.order_to_usd_exchange_rate),
amount_7 = datas_7.Sum(s => s.bailun_sku_quantity_ordered * s.amount_sales * s.order_to_usd_exchange_rate), amount_7 = datas_7.Sum(s => s.bailun_sku_quantity_ordered * s.amount_sales * s.order_to_usd_exchange_rate),
yesterday_average_7 = sum_count_7 / 7 yesterday_average_7 = sum_count_7 / 7
...@@ -2911,7 +2913,7 @@ where 1=1 ...@@ -2911,7 +2913,7 @@ where 1=1
{ {
sql += " GROUP BY t2.warehouse_code "; sql += " GROUP BY t2.warehouse_code ";
} }
var pageDatas = _connection.Page<quantity_safe_inventory_dto>(sql, search_data, parameters,isCount:false); var pageDatas = _connection.Page<quantity_safe_inventory_dto>(sql, search_data, parameters, isCount: false);
if (!search_data.is_sum) if (!search_data.is_sum)
{ {
pageDatas.TotalItems = connectionHelper._connection.QueryFirstOrDefault<int?>(sqlCount, parameters) ?? 0; pageDatas.TotalItems = connectionHelper._connection.QueryFirstOrDefault<int?>(sqlCount, parameters) ?? 0;
...@@ -2939,17 +2941,232 @@ where 1=1 ...@@ -2939,17 +2941,232 @@ where 1=1
sql += " and t1.warehouse_code like @warehouse_code "; sql += " and t1.warehouse_code like @warehouse_code ";
parameters.Add("warehouse_code", search.warehouse_code); parameters.Add("warehouse_code", search.warehouse_code);
} }
return _connection.Page<dc_base_wip_stock_dto>(sql, search, parameters); return _connection.Page<dc_base_wip_stock_dto>(sql, search, parameters);
} }
public static List<platform_type_website_dto> PlatformtypeWebsiteList(string platform_type) public static List<platform_type_website_dto> PlatformtypeWebsiteList(string platform_type)
{ {
return _connection.Query<platform_type_website_dto>(" select DISTINCT platform_type,web_site as 'website' from dc_report_cash_flow_group_day ").AsList(); return _connection.Query<platform_type_website_dto>(" select DISTINCT platform_type,web_site as 'website' from dc_report_cash_flow_group_day ").AsList();
} }
public static List<string> BrandList() public static List<string> BrandList()
{ {
return _connection.Query<string>(" SELECT DISTINCT brand FROM `dc_base_sku` ").AsList(); return _connection.Query<string>(" SELECT DISTINCT brand FROM `dc_base_sku` ").AsList();
} }
/// <summary>
/// 库存每周备份
/// </summary>
public static void StockWeekBackUp()
{
var btime = DateTime.Now.AddDays(-7).GetWeekFirstDayMon().ToDayHome();
var etime = btime.GetWeekLastDaySun().ToDayEnd();
var week_tag = $"{btime.ToString("MM-dd")} ~ {etime.ToString("MM-dd")}";
_connection.Execute(@"
delete from dc_report_stock_week where week_tag=@week_tag;
insert into dc_report_stock_week(`stock`,`week_tag`,`warehouse_code`,`bailun_sku`,`first_day_date`,`web_site`,`sku_tag`,`stock_amount`,`is_order`)
(
select
t1.stock,
t1.week_tag,
t1.warehouse_code,
t1.bailun_sku,
t1.first_day_date,
t1.web_site,
t1.sku_tag,
t1.stock_amount,
1 as 'is_order'
from (select
t3.usable_stock as 'stock',
@week_tag as 'week_tag',
t1.warehouse_code,
t1.bailun_sku,
@btime as 'first_day_date',
t2.area_name as 'web_site',
'' as 'sku_tag',
t3.usable_stock * ifnull(t4.unit_price,0) 'stock_amount',
t2.hq_type
from dc_base_oms_sku as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
left join dc_base_stock t3 on t1.bailun_sku = t3.bailun_sku and t1.warehouse_code = t3.warehouse_code
left join dc_base_sku as t4 on t1.bailun_sku = t4.bailun_sku
where t1.paid_time>=@btime and t1.paid_time<=@etime group by t1.warehouse_code,t1.bailun_sku ) as t1
where t1.hq_type='第三方仓库'
);
insert ignore into dc_report_stock_week(`stock`,`week_tag`,`warehouse_code`,`bailun_sku`,`first_day_date`,`web_site`,`sku_tag`,`stock_amount`,`is_order`)
(
select t1.usable_stock as 'stock',
@week_tag as 'week_tag',
t1.warehouse_code,
t1.bailun_sku,
@btime as 'first_day_date',
t2.area_name as 'web_site',
'' as 'sku_tag',
t1.usable_stock * ifnull(t3.unit_price,0) 'stock_amount',
0 as 'is_order'
from dc_base_stock as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
left join dc_base_sku as t3 on t1.bailun_sku = t3.bailun_sku
where t2.hq_type='第三方仓库' and
(
t1.usable_stock>0
)
);
", new { btime, etime, week_tag }, commandTimeout: 0);
}
public static List<report_stock_week_view_dto> ReportStockWeekView(report_stock_week_view_search_dto search)
{
var btime = DateTime.Now.AddDays(-(7 * 4)).GetWeekFirstDayMon().ToDayHome();
var etime = btime.AddDays(7*24).GetWeekLastDaySun().ToDayEnd();
if (search.btime != null)
{
btime = search.btime.Value;
}
if (search.etime != null)
{
etime = search.etime.Value;
}
var datas = _connection.Query<dc_report_stock_week>(" select * from dc_report_stock_week where first_day_date>=@btime and first_day_date <=@etime ", new { btime, etime });
List<report_stock_week_view_dto> r_datas = new List<report_stock_week_view_dto>();
var datas_web_site_group = datas.GroupBy(s => s.web_site).ToList();
foreach (var websiteGroupItem in datas_web_site_group)
{
r_datas.Add(new report_stock_week_view_dto { web_site = websiteGroupItem.Key, tag = "出单sku数量占比", weeks = new List<report_stock_week_view_dto.week>() { } });
r_datas.Add(new report_stock_week_view_dto { web_site = websiteGroupItem.Key, tag = "不出单数量sku占比", weeks = new List<report_stock_week_view_dto.week>() { } });
r_datas.Add(new report_stock_week_view_dto { web_site = websiteGroupItem.Key, tag = "出单sku库存数量占比", weeks = new List<report_stock_week_view_dto.week>() { } });
r_datas.Add(new report_stock_week_view_dto { web_site = websiteGroupItem.Key, tag = "不出单sku库存数量占比", weeks = new List<report_stock_week_view_dto.week>() { } });
r_datas.Add(new report_stock_week_view_dto { web_site = websiteGroupItem.Key, tag = "出单sku库存金额占比", weeks = new List<report_stock_week_view_dto.week>() { } });
r_datas.Add(new report_stock_week_view_dto { web_site = websiteGroupItem.Key, tag = "不出单sku库存金额占比", weeks = new List<report_stock_week_view_dto.week>() { } });
r_datas.Add(new report_stock_week_view_dto { web_site = websiteGroupItem.Key, tag = "普货-精准开发", weeks = new List<report_stock_week_view_dto.week>() { } });
r_datas.Add(new report_stock_week_view_dto { web_site = websiteGroupItem.Key, tag = "清货", weeks = new List<report_stock_week_view_dto.week>() { } });
r_datas.Add(new report_stock_week_view_dto { web_site = websiteGroupItem.Key, tag = "美容SKU", weeks = new List<report_stock_week_view_dto.week>() { } });
r_datas.Add(new report_stock_week_view_dto { web_site = websiteGroupItem.Key, tag = "总SKU数", weeks = new List<report_stock_week_view_dto.week>() { } });
var this_date = btime.GetWeekFirstDayMon().ToDayHome();
while (this_date <= etime)
{
var b_thie_date = this_date.ToDayHome();
var e_thie_date = b_thie_date.GetWeekLastDaySun().ToDayEnd();
var this_datas = websiteGroupItem.Where(s => s.first_day_date >= b_thie_date && s.first_day_date <= e_thie_date).ToList();
var sum_val = this_datas.Count();
var sum_stock_val = this_datas.Sum(s=>s.stock);
var sum_stock_amount_val = this_datas.Sum(s=>s.stock_amount);
var chudan_sku_val = (decimal)this_datas.Where(s => s.is_order==1).Count();
var bu_chudan_sku_val = (decimal)this_datas.Where(s => s.is_order==0).Count();
var chudan_sku_stock_val = (decimal)this_datas.Where(s => s.is_order==1).Sum(s=>s.stock);
var bu_chudan_sku_stock_val = (decimal)this_datas.Where(s => s.is_order==0).Sum(s => s.stock);
var chudan_sku_stock_amount_val = (decimal)this_datas.Where(s => s.is_order==1).Sum(s=>s.stock_amount);
var bu_chudan_sku_stock_amount_val = (decimal)this_datas.Where(s => s.is_order==0).Sum(s => s.stock_amount);
var jinzhun_sku_val = (decimal)this_datas.Where(s => s.sku_tag== "普货-精准开发").Count();
var qinhuo_sku_val = (decimal)this_datas.Where(s => s.sku_tag== "清货").Count();
var meirong_sku_val = (decimal)this_datas.Where(s => s.sku_tag== "美容SKU").Count();
r_datas.SingleOrDefault(s => s.web_site== websiteGroupItem.Key && s.tag == "出单sku数量占比").weeks.Add(new report_stock_week_view_dto.week
{
tag = $" {b_thie_date.ToString("MM-dd")} ~ {e_thie_date.ToString("MM-dd")}",
val = chudan_sku_val,
ratio = chudan_sku_val.Division(sum_val)
});
r_datas.SingleOrDefault(s => s.web_site == websiteGroupItem.Key && s.tag == "不出单数量sku占比").weeks.Add(new report_stock_week_view_dto.week
{
tag = $" {b_thie_date.ToString("MM-dd")} ~ {e_thie_date.ToString("MM-dd")}",
val = bu_chudan_sku_val,
ratio = bu_chudan_sku_val.Division(sum_val)
});
r_datas.SingleOrDefault(s => s.web_site == websiteGroupItem.Key && s.tag == "出单sku库存数量占比").weeks.Add(new report_stock_week_view_dto.week
{
tag = $" {b_thie_date.ToString("MM-dd")} ~ {e_thie_date.ToString("MM-dd")}",
val = chudan_sku_stock_val,
ratio = chudan_sku_stock_val.Division(sum_stock_val)
});
r_datas.SingleOrDefault(s => s.web_site == websiteGroupItem.Key && s.tag == "不出单sku库存数量占比").weeks.Add(new report_stock_week_view_dto.week
{
tag = $" {b_thie_date.ToString("MM-dd")} ~ {e_thie_date.ToString("MM-dd")}",
val = bu_chudan_sku_stock_val,
ratio = bu_chudan_sku_stock_val.Division(sum_stock_val)
});
r_datas.SingleOrDefault(s => s.web_site == websiteGroupItem.Key && s.tag == "出单sku库存金额占比").weeks.Add(new report_stock_week_view_dto.week
{
tag = $" {b_thie_date.ToString("MM-dd")} ~ {e_thie_date.ToString("MM-dd")}",
val = chudan_sku_stock_amount_val,
ratio = chudan_sku_stock_amount_val.Division(sum_stock_amount_val)
});
r_datas.SingleOrDefault(s => s.web_site == websiteGroupItem.Key && s.tag == "不出单sku库存金额占比").weeks.Add(new report_stock_week_view_dto.week
{
tag = $" {b_thie_date.ToString("MM-dd")} ~ {e_thie_date.ToString("MM-dd")}",
val = bu_chudan_sku_stock_amount_val,
ratio = bu_chudan_sku_stock_amount_val.Division(sum_stock_amount_val)
});
r_datas.SingleOrDefault(s => s.web_site == websiteGroupItem.Key && s.tag == "普货-精准开发").weeks.Add(new report_stock_week_view_dto.week
{
tag = $" {b_thie_date.ToString("MM-dd")} ~ {e_thie_date.ToString("MM-dd")}",
val = jinzhun_sku_val,
ratio = jinzhun_sku_val.Division(sum_val)
});
r_datas.SingleOrDefault(s => s.web_site == websiteGroupItem.Key && s.tag == "清货").weeks.Add(new report_stock_week_view_dto.week
{
tag = $" {b_thie_date.ToString("MM-dd")} ~ {e_thie_date.ToString("MM-dd")}",
val = qinhuo_sku_val,
ratio = qinhuo_sku_val.Division(sum_val)
});
r_datas.SingleOrDefault(s => s.web_site == websiteGroupItem.Key && s.tag == "美容SKU").weeks.Add(new report_stock_week_view_dto.week
{
tag = $" {b_thie_date.ToString("MM-dd")} ~ {e_thie_date.ToString("MM-dd")}",
val = meirong_sku_val,
ratio = meirong_sku_val.Division(sum_val)
});
r_datas.SingleOrDefault(s => s.web_site == websiteGroupItem.Key && s.tag == "总SKU数").weeks.Add(new report_stock_week_view_dto.week
{
tag = $" {b_thie_date.ToString("MM-dd")} ~ {e_thie_date.ToString("MM-dd")}",
val = sum_val,
ratio = 1
});
this_date = this_date.AddDays(7);
}
}
return r_datas;
}
public static List<string> ReportStockWeekViewGetWeekList(report_stock_week_view_search_dto search)
{
var weeks = new List<string>();
var btime = DateTime.Now.AddDays(-(7 * 4)).GetWeekFirstDayMon().ToDayHome();
var etime = btime.AddDays(7*4).GetWeekLastDaySun().ToDayEnd();
if (search.btime != null)
{
btime = search.btime.Value;
}
if (search.etime != null)
{
etime = search.etime.Value;
}
var this_date = btime.GetWeekFirstDayMon().ToDayHome();
while (this_date <= etime)
{
var b_thie_date = this_date.ToDayHome();
var e_thie_date = b_thie_date.GetWeekLastDaySun().ToDayEnd();
weeks.Add($" {b_thie_date.ToString("MM-dd")} ~ {e_thie_date.ToString("MM-dd")}");
this_date = this_date.AddDays(7);
}
return weeks;
}
} }
} }
......
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models.Report
{
public class report_stock_week_view_dto
{
public string web_site { get; set; }
/// <summary>
/// 指标
/// </summary>
public string tag { get; set; }
public List<week> weeks { get; set; }
public class week
{
public string tag { get; set; }
public decimal val { get; set; }
public decimal ratio { get; set; }
public string ratio_str { get{
return ratio.ToString("p");
} }
}
}
public class report_stock_week_view_search_dto
{
public DateTime? btime { get; set; }
public DateTime? etime { get; set; }
}
public class dc_report_stock_week
{
public int id { get; set; }
public int stock { get; set; }
public string week_tag { get; set; }
public string warehouse_code { get; set; }
public string bailun_sku { get; set; }
public DateTime first_day_date { get; set; }
public string web_site { get; set; }
public string sku_tag { get; set; }
public decimal stock_amount { get; set; }
public int is_order { get; set; }
}
}
...@@ -698,6 +698,7 @@ namespace AutoTurnOver.Services ...@@ -698,6 +698,7 @@ namespace AutoTurnOver.Services
} }
return datas; return datas;
} }
/// <summary> /// <summary>
/// 获取缺货数据 /// 获取缺货数据
......
...@@ -871,7 +871,32 @@ namespace AutoTurnOver.Services ...@@ -871,7 +871,32 @@ namespace AutoTurnOver.Services
return base_sku_dao.GetPage(search); return base_sku_dao.GetPage(search);
} }
public List<dynamic> ReportStockWeekView(report_stock_week_view_search_dto search_data)
{
var order_list = report.ReportStockWeekView(search_data);
List<dynamic> datas = new List<dynamic>();
foreach (var item in order_list)
{
dynamic o = new ExpandoObject();
o.web_site = item.web_site;
o.tag = item.tag;
foreach (var dat_item in item.weeks)
{
var dic = (IDictionary<string, object>)o;
dic["val_" + (dat_item.tag)] = Math.Round(dat_item.val, 2);
dic["ratio_" + (dat_item.tag)] = dat_item.ratio_str;
}
datas.Add(o);
}
return datas;
}
public List<string> ReportStockWeekViewGetWeekList(report_stock_week_view_search_dto search)
{
return report.ReportStockWeekViewGetWeekList(search);
}
} }
} }
...@@ -651,7 +651,93 @@ namespace AutoTurnOver.Controllers ...@@ -651,7 +651,93 @@ namespace AutoTurnOver.Controllers
total = 0, total = 0,
}); });
} }
[BrowseLog("Bailun_aims", "访问【百伦自动周转系统】->【报表】->【第三方海外仓统计表】->【搜索】页面", 0)]
public JsonResult ReportStockWeekView(DateTime? btime, DateTime? etime)
{
report_stock_week_view_search_dto search_data = new report_stock_week_view_search_dto
{
etime = etime,
btime = btime
};
var list = new ReportServices().ReportStockWeekView(search_data);
return new JsonResult(new
{
rows = list,
total = 0,
});
}
[BrowseLog("Bailun_aims", "访问【百伦自动周转系统】->【报表】->【第三方海外仓统计表】->【导出】", 0)]
public FileResult ExportTableReportStockWeekView(DateTime? btime, DateTime? etime)
{
report_stock_week_view_search_dto search_data = new report_stock_week_view_search_dto
{
etime = etime,
btime = btime
};
var list = new ReportServices().ReportStockWeekView(search_data);
var time_list = new ReportServices().ReportStockWeekViewGetWeekList(search_data);
DataTable table = new DataTable();
string[] cols = new string[] { "站点", "标签" };
foreach (var item in cols)
{
table.Columns.Add(item);
}
foreach (var item in time_list)
{
table.Columns.Add($"{item}-值");
table.Columns.Add($"{item}-占比");
}
foreach (var itemDataD in list)
{
DataRow row = table.NewRow();
var itemData = (IDictionary<string, object>)itemDataD;
row["站点"] = itemData["web_site"];
row["标签"] = itemData["tag"];
foreach (var item in time_list)
{
row[$"{item}-值"] = itemData["val_" + $"{item}"];
row[$"{item}-占比"] = itemData["ratio_" + $"{item}"];
}
table.Rows.Add(row);
}
var fileName = AppContext.BaseDirectory + @"Result\RealtimeStock\第三方海外仓统计表.csv";
DataTableHelper.SaveCSV(table, fileName);
var memory = new MemoryStream();
using (var stream = new FileStream(fileName, FileMode.Open))
{
stream.CopyTo(memory);
}
memory.Position = 0;
return File(memory, "text/csv", "第三方海外仓统计表.csv");
}
public JsonResult ReportStockWeekViewGetWeekList(DateTime? btime, DateTime? etime)
{
report_stock_week_view_search_dto search_data = new report_stock_week_view_search_dto
{
etime = etime,
btime = btime
};
var list = new ReportServices().ReportStockWeekViewGetWeekList(search_data);
return new JsonResult(list);
}
public JsonResult GetSkuWarehouseSales(string platform_type,string warehousetype, int? warehousearea, string warehousecode,DateTime? btime,DateTime? etime) public JsonResult GetSkuWarehouseSales(string platform_type,string warehousetype, int? warehousearea, string warehousecode,DateTime? btime,DateTime? etime)
{ {
bailun_sku_website_sales_search_dto search_data = new bailun_sku_website_sales_search_dto { bailun_sku_website_sales_search_dto search_data = new bailun_sku_website_sales_search_dto {
......
...@@ -16,6 +16,7 @@ namespace ResetOutofstock ...@@ -16,6 +16,7 @@ namespace ResetOutofstock
try try
{ {
var now = DateTime.Now; var now = DateTime.Now;
//report.StockWeekBackUp();
//report_cash_flow_dao.CalculationTransferOrder(now.AddMonths(-3), DateTime.Parse(now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59"))); //report_cash_flow_dao.CalculationTransferOrder(now.AddMonths(-3), DateTime.Parse(now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59")));
//report_cash_flow_dao.SynchroTransferCost(); //report_cash_flow_dao.SynchroTransferCost();
} }
...@@ -30,6 +31,7 @@ namespace ResetOutofstock ...@@ -30,6 +31,7 @@ namespace ResetOutofstock
{ {
services.AddHostedService<ResetOutofstockBackgrounService>(); services.AddHostedService<ResetOutofstockBackgrounService>();
services.AddHostedService<CaseFlowBackgrounService>(); services.AddHostedService<CaseFlowBackgrounService>();
services.AddHostedService<StockBackgrounService>();
}); });
await builder.RunConsoleAsync(); await builder.RunConsoleAsync();
......
using AutoTurnOver.DB;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ResetOutofstock
{
public class StockBackgrounService : BackgroundService
{
private Timer _timer;
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
_timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromMinutes(1));
return Task.CompletedTask;
}
private void DoWork(object state)
{
var now = DateTime.Now;
if (now.DayOfWeek == DayOfWeek.Monday)
{
if (now.Hour == 0 && now.Minute == 10)
{
Console.WriteLine($"开始 备份上周库存,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
report.StockWeekBackUp();
Console.WriteLine($"结束 备份上周库存,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
}
}
public override void Dispose()
{
base.Dispose();
_timer?.Dispose();
}
}
}
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