Commit d676272b by lizefeng

分类汇总新增导出

parent 61a5e1c0
...@@ -577,5 +577,71 @@ namespace AutoTurnOver.Services ...@@ -577,5 +577,71 @@ namespace AutoTurnOver.Services
} }
public MemoryStream GetGoodsExport(bailun_sku_goods_search_dto search_data,UserData user)
{
try
{
var fileName = AppContext.BaseDirectory + $@"Result\RealtimeStock\{user.UserAccount}商品汇总-{DateTime.Now.ToString("yyyyMMddHHmmss")}.csv";
var total = 0;
var list = GetGoods(search_data, 0, int.MaxValue, ref total);
// 查询站点,组织列头
var web_sites = ApiServices.PlatformtypeWebsiteList(search_data.platform_type);
if (list == null || list.Count <= 0) return null;
DataTable table = new DataTable();
List<string> cols = new List<string>() { "内部商品编码", "分类", "产品名称" };
foreach (var item in web_sites)
{
cols.Add($"{item.platform_type}-{item.website}-昨日销量");
cols.Add($"{item.platform_type}-{item.website}-近7天日均销量");
cols.Add($"{item.platform_type}-{item.website}-昨日销售额");
cols.Add($"{item.platform_type}-{item.website}-近7天总销售额");
}
foreach (var item in cols)
{
table.Columns.Add(item);
}
foreach (var itemData in list)
{
DataRow row = table.NewRow();
row["内部商品编码"] = itemData.product_inner_code;
row["分类"] = itemData.bailun_category_name;
row["产品名称"] = itemData.sku_title_cn;
foreach (var dat_item in web_sites)
{
row[($"{dat_item.platform_type}-{dat_item.website}-昨日销量")] = itemData["yesterday_count_" + (dat_item.platform_type + "-" + dat_item.website)];
row[($"{dat_item.platform_type}-{dat_item.website}-近7天日均销量")] = itemData["yesterday_average_7_" + (dat_item.platform_type + "-" + dat_item.website)];
row[($"{dat_item.platform_type}-{dat_item.website}-昨日销售额")] = itemData["yesterday_amount_" + (dat_item.platform_type + "-" + dat_item.website)];
row[($"{dat_item.platform_type}-{dat_item.website}-近7天总销售额")] = itemData["amount_7_" + (dat_item.platform_type + "-" + dat_item.website)];
}
table.Rows.Add(row);
}
CsvFileHelper.SaveCSV(table, fileName, true);
var memory = new MemoryStream();
using (var stream = new FileStream(fileName, FileMode.Open))
{
stream.CopyTo(memory);
}
memory.Position = 0;
return memory;
}
catch (Exception)
{
throw;
}
}
} }
} }
...@@ -718,6 +718,18 @@ namespace AutoTurnOver.Controllers ...@@ -718,6 +718,18 @@ namespace AutoTurnOver.Controllers
}); });
} }
public FileResult GetGoodsExport(string product_inner_code, string platform_type)
{
var user = AutoUtility.GetUser();
var m = new bailun_sku_goods_search_dto
{
product_inner_code = product_inner_code,
platform_type = platform_type
};
var memory = new ReportServices().GetGoodsExport(m, user);
return File(memory, "text/csv", $"{user.UserAccount}商品汇总数据信息.csv");
}
public JsonResult GetGoodsSumFooter(string product_inner_code, string platform_type) public JsonResult GetGoodsSumFooter(string product_inner_code, string platform_type)
{ {
......
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