Commit 9035700d by 泽锋 李

新增商品汇总(仓库)

parent 16c13690
...@@ -21,7 +21,6 @@ namespace AutoGeneratePurchaseAdvise ...@@ -21,7 +21,6 @@ namespace AutoGeneratePurchaseAdvise
} }
catch (Exception ex) catch (Exception ex)
{ {
throw; throw;
} }
......
...@@ -1382,7 +1382,7 @@ t1.bailun_sku, ...@@ -1382,7 +1382,7 @@ t1.bailun_sku,
( (
case case
when t1.buyer_name='李华娟' then '无库普货推荐' when t1.buyer_name='李华娟' then '无库普货推荐'
when t1.buyer_name='张莹霞' then '美甲' when t1.buyer_name in ('张莹霞','黄境洁','古艳洋1') then '美甲'
when t1.buyer_name='张莹霞1' then '精油+美容' when t1.buyer_name='张莹霞1' then '精油+美容'
when t1.buyer_name='赵美聪' and t1.source = 1 then '服装精准开发' when t1.buyer_name='赵美聪' and t1.source = 1 then '服装精准开发'
when t1.buyer_name='赵美聪' then '服装供应商推荐' when t1.buyer_name='赵美聪' then '服装供应商推荐'
...@@ -2133,6 +2133,11 @@ truncate table dc_auto_stock_monitor_temp; ", commandTimeout: 0); ...@@ -2133,6 +2133,11 @@ truncate table dc_auto_stock_monitor_temp; ", commandTimeout: 0);
sql += " and t1.website = @website "; sql += " and t1.website = @website ";
parameters.Add("website", search_data.website); parameters.Add("website", search_data.website);
} }
if (!string.IsNullOrWhiteSpace(search_data.warehouse_code))
{
sql += " and t1.warehouse_code = @warehouse_code ";
parameters.Add("warehouse_code", search_data.warehouse_code);
}
if (!string.IsNullOrWhiteSpace(search_data.label)) if (!string.IsNullOrWhiteSpace(search_data.label))
{ {
sql += " and t2.label = @label "; sql += " and t2.label = @label ";
...@@ -2421,6 +2426,158 @@ left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code whe ...@@ -2421,6 +2426,158 @@ 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)
{
var tableName = "dc_base_oms_sku_7";
if (search_data.btime != null || search_data.etime != null)
{
tableName = "dc_base_oms_sku";
}
var sql = $@" select t1.*,t2.label,tdb.warehouse_name from {tableName} as t1 left join dc_auto_config_sku_label as t2 on t1.bailun_sku = t2.bailun_sku
left join dc_base_warehouse as tdb on t1.warehouse_code = tdb.warehouse_code where tdb.hq_type='第三方仓库' ";
DynamicParameters parameters = new DynamicParameters();
if (search_data != null)
{
if(search_data.btime!=null && search_data.etime!=null)
{
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("etime", search_data.etime.Value.ToString("yyyy-MM-dd 23:59:59"));
}
if (!string.IsNullOrWhiteSpace(search_data.platform_type))
{
if("amazon".Equals(search_data.platform_type, StringComparison.OrdinalIgnoreCase))
{
sql += " and t1.platform_type in @platform_types ";
parameters.Add("platform_types", new List<string> { "Amazon", "FBA" });
}
else
{
sql += " and t1.platform_type = @platform_type ";
parameters.Add("platform_type", search_data.platform_type);
}
}
if (!string.IsNullOrWhiteSpace(search_data.warehousetype))
{
if (search_data.warehousetype == "国内仓")
{
sql += " and tdb.hq_type=@warehousetype ";
parameters.Add("warehousetype", "国内仓");
}
else
{
if ("amazon".Equals(search_data.platform_type, StringComparison.OrdinalIgnoreCase))
{
sql += " and tdb.hq_type in ('fba仓') ";
}
else
{
sql += " and tdb.hq_type not in ('国内仓') ";
}
}
}
if (search_data.warehousearea > 0)
{
sql += " and tdb.area_id = @area_id ";
parameters.Add("area_id", search_data.warehousearea);
}
if (!string.IsNullOrWhiteSpace(search_data.warehouse_code))
{
sql += " and t1.warehouse_code=@warehouse_code ";
parameters.Add("warehouse_code", search_data.warehouse_code);
}
}
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>();
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)
{
datas.Add(new bailun_sku_warehouse_code_dto
{
label = "总计",
labels = new List<string> { "服装精准开发", "服装供应商推荐", "非服装精准开发", "无库普货推荐","美甲", "精油+美容","未知" },
warehouse_name = "总计",
warehouse_code = "",
days = new List<bailun_sku_warehouse_code_dto.bailun_sku_warehouse_code_date_dto>()
});
}
else
{
foreach (var item in warehouse_code_list)
{
datas.Add(new bailun_sku_warehouse_code_dto
{
label = "美甲",
labels = new List<string> { "美甲" },
warehouse_name = item.Key.warehouse_name,
warehouse_code = item.Key.warehouse_code,
days = new List<bailun_sku_warehouse_code_dto.bailun_sku_warehouse_code_date_dto>()
});
}
foreach (var item in warehouse_code_list)
{
datas.Add(new bailun_sku_warehouse_code_dto
{
label = "精油+美容",
labels = new List<string> { "精油+美容" },
warehouse_name = item.Key.warehouse_name,
warehouse_code = item.Key.warehouse_code,
days = new List<bailun_sku_warehouse_code_dto.bailun_sku_warehouse_code_date_dto>()
});
}
foreach (var item in warehouse_code_list)
{
datas.Add(new bailun_sku_warehouse_code_dto
{
label = "普货",
labels = new List<string> { "服装精准开发", "服装供应商推荐", "非服装精准开发", "无库普货推荐", "未知" },
warehouse_name = item.Key.warehouse_name,
warehouse_code = item.Key.warehouse_code,
days = new List<bailun_sku_warehouse_code_dto.bailun_sku_warehouse_code_date_dto>()
});
}
}
var b_time = DateTime.Now.AddDays(-1);
var e_time = b_time.AddDays(-7);
if(search_data.btime!=null && search_data.etime!=null)
{
e_time = search_data.btime.Value;
b_time = search_data.etime.Value;
}
var this_time = b_time;
while (this_time>= e_time)
{
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);
if (!"总计".Equals(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
{
year = this_time.Year,
month = this_time.Month,
day = this_time.Day,
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)
});
}
this_time = this_time.AddDays(-1);
}
return datas;
}
public static List<supplier_sales_dto> SupplierSalesList(supplier_sales_search_dto m, int offset, int limit, ref int total, string order = "", string sort = "") public static List<supplier_sales_dto> SupplierSalesList(supplier_sales_search_dto m, int offset, int limit, ref int total, string order = "", string sort = "")
{ {
......
...@@ -25,6 +25,7 @@ namespace AutoTurnOver.Models.Report ...@@ -25,6 +25,7 @@ namespace AutoTurnOver.Models.Report
public string label { get; set; } public string label { get; set; }
public string website { get; set; } public string website { get; set; }
public string warehouse_code { get; set; }
public int year { get; set; } public int year { get; set; }
public int month { get; set; } public int month { get; set; }
...@@ -56,6 +57,30 @@ namespace AutoTurnOver.Models.Report ...@@ -56,6 +57,30 @@ namespace AutoTurnOver.Models.Report
} }
} }
public class bailun_sku_warehouse_code_dto
{
public string label { get; set; }
public string warehouse_name { get; set; }
public string warehouse_code { get; set; }
public List<string> labels { get; set; }
public List<bailun_sku_warehouse_code_date_dto> days { get; set; }
public class bailun_sku_warehouse_code_date_dto
{
public int year { get; set; }
public int month { get; set; }
public int day { get; set; }
public decimal count { get; set; }
public decimal sum { get; set; }
}
}
public class bailun_sku_goods_search_dto public class bailun_sku_goods_search_dto
{ {
public bool? has_sum { get; set; } public bool? has_sum { get; set; }
......
...@@ -25,6 +25,7 @@ namespace AutoTurnOver.Models ...@@ -25,6 +25,7 @@ namespace AutoTurnOver.Models
public string bailun_sku { get; set; } public string bailun_sku { get; set; }
public string warehouse_code { get; set; } public string warehouse_code { get; set; }
public string warehouse_name { get; set; }
public string bailun_sku_title_cn { get; set; } public string bailun_sku_title_cn { get; set; }
......
...@@ -632,6 +632,29 @@ namespace AutoTurnOver.Services ...@@ -632,6 +632,29 @@ namespace AutoTurnOver.Services
return datas; return datas;
} }
public List<dynamic> GetSkuWarehouseSales(bailun_sku_website_sales_search_dto search_data)
{
var order_list = report.GetSkuWarehouseSales(search_data);
List<dynamic> datas = new List<dynamic>();
foreach (var item in order_list)
{
dynamic o = new ExpandoObject();
o.label = item.label;
o.warehouse_name = item.warehouse_name;
o.warehouse_code = item.warehouse_code;
foreach (var dat_item in item.days)
{
var dic = (IDictionary<string, object>)o;
dic["count_" + (dat_item.month + "-" + dat_item.day)] = new { val = Math.Round(dat_item.count, 2), year = dat_item.year, month = dat_item.month, day = dat_item.day };
dic["sum_" + (dat_item.month + "-" + dat_item.day)] = Math.Round(dat_item.sum,2);
}
datas.Add(o);
}
return datas;
}
public MemoryStream SkuWebsiteSalesExport(bailun_sku_website_sales_detailed_search_dto search_data,UserData user) public MemoryStream SkuWebsiteSalesExport(bailun_sku_website_sales_detailed_search_dto search_data,UserData user)
{ {
......
...@@ -644,8 +644,27 @@ namespace AutoTurnOver.Controllers ...@@ -644,8 +644,27 @@ namespace AutoTurnOver.Controllers
total = 0, total = 0,
}); });
} }
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 {
platform_type = platform_type,
warehousetype = warehousetype,
etime = etime,
btime = btime,
warehousearea =warehousearea,
warehouse_code = warehousecode
};
var list = new ReportServices().GetSkuWarehouseSales(search_data);
return new JsonResult(new
{
rows = list,
total = 0,
});
}
public FileResult SkuWebsiteSalesExport(string platform_type,string label,string website,int? year,int? month,int? day) public FileResult SkuWebsiteSalesExport(string platform_type,string label,string website,string warehouse_code, int? year,int? month,int? day)
{ {
var user = AutoUtility.GetUser(); var user = AutoUtility.GetUser();
var memory = new ReportServices().SkuWebsiteSalesExport(new bailun_sku_website_sales_detailed_search_dto { var memory = new ReportServices().SkuWebsiteSalesExport(new bailun_sku_website_sales_detailed_search_dto {
...@@ -654,6 +673,7 @@ namespace AutoTurnOver.Controllers ...@@ -654,6 +673,7 @@ namespace AutoTurnOver.Controllers
month = month??0, month = month??0,
platform_type = platform_type, platform_type = platform_type,
website =website, website =website,
warehouse_code = warehouse_code,
year = year??0 year = year??0
}, AutoUtility.GetUser()); }, AutoUtility.GetUser());
return File(memory, "text/csv", $"{user.UserAccount}商品分类数据信息.csv"); return File(memory, "text/csv", $"{user.UserAccount}商品分类数据信息.csv");
...@@ -676,6 +696,25 @@ namespace AutoTurnOver.Controllers ...@@ -676,6 +696,25 @@ namespace AutoTurnOver.Controllers
var list = new ReportServices().GetSkuWebsiteSales(search_data); var list = new ReportServices().GetSkuWebsiteSales(search_data);
return new JsonResult(list == null || list.Count <= 0 ? new dc_base_stock_dto() : list[0]); return new JsonResult(list == null || list.Count <= 0 ? new dc_base_stock_dto() : list[0]);
}
public JsonResult GetSkuWarehouseSalesSumFooter(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
{
platform_type = platform_type,
warehousetype = warehousetype,
has_sum =true,
etime = etime,
btime = btime,
warehousearea = warehousearea,
warehouse_code = warehousecode
};
var list = new ReportServices().GetSkuWarehouseSales(search_data);
return new JsonResult(list == null || list.Count <= 0 ? new dc_base_stock_dto() : list[0]);
} }
[UseAction] [UseAction]
......
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