Commit 61a5e1c0 by lizefeng

分类汇总报表新增订单明细导出

parent dc6ee1dc
......@@ -1321,6 +1321,37 @@ truncate table dc_base_purchase_7_temp;", new { time = DateTime.Now.AddDays(-8).
}).ToList(); ;
}
public static List<dc_base_oms_sku_label> GetSkuWebsiteSalesDetailed(bailun_sku_website_sales_detailed_search_dto search_data)
{
var sql = @" select t1.*,t2.label from dc_base_oms_sku_7 as t1 left join dc_auto_config_sku_label as t2 on t1.bailun_sku = t2.bailun_sku where 1=1 ";
DynamicParameters parameters = new DynamicParameters();
if (search_data != null)
{
if (!string.IsNullOrWhiteSpace(search_data.platform_type))
{
sql += " and t1.platform_type in @platform_type ";
parameters.Add("platform_type", search_data.platform_type.Split(','));
}
if (!string.IsNullOrWhiteSpace(search_data.website))
{
sql += " and t1.website = @website ";
parameters.Add("website", search_data.website);
}
if (!string.IsNullOrWhiteSpace(search_data.label))
{
sql += " and t2.label = @label ";
parameters.Add("label", search_data.label);
}
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);
sql += " and t1.pay_time >= @b_time and t1.pay_time <= @e_time ";
parameters.Add("b_time", b_time);
parameters.Add("e_time", b_time.ToString("yyyy-MM-dd 23:59:59"));
}
}
return _connection.Query<dc_base_oms_sku_label>(sql, parameters).AsList();
}
public static List<bailun_sku_website_sales_dto> GetSkuWebsiteSales(bailun_sku_website_sales_search_dto search_data)
{
var sql = @" select t1.*,t2.label from dc_base_oms_sku_7 as t1 left join dc_auto_config_sku_label as t2 on t1.bailun_sku = t2.bailun_sku where 1=1 ";
......@@ -1370,7 +1401,7 @@ truncate table dc_base_purchase_7_temp;", new { time = DateTime.Now.AddDays(-8).
labels = new List<string> { "服装精准开发" },
website = "小计",
website_show = "小计",
platform_type = "",
platform_type = search_data.platform_type,
days = new List<bailun_sku_website_sales_dto.bailun_sku_website_sales_date_dto>()
});
......@@ -1392,7 +1423,7 @@ truncate table dc_base_purchase_7_temp;", new { time = DateTime.Now.AddDays(-8).
labels = new List<string> { "服装供应商推荐" },
website = "小计",
website_show = "小计",
platform_type = "",
platform_type = search_data.platform_type,
days = new List<bailun_sku_website_sales_dto.bailun_sku_website_sales_date_dto>()
});
foreach (var item in website_list)
......@@ -1413,7 +1444,7 @@ truncate table dc_base_purchase_7_temp;", new { time = DateTime.Now.AddDays(-8).
labels = new List<string> { "服装供应商推荐", "服装精准开发" },
website = "小计",
website_show = "小计",
platform_type = "",
platform_type = search_data.platform_type,
days = new List<bailun_sku_website_sales_dto.bailun_sku_website_sales_date_dto>()
});
foreach (var item in website_list)
......@@ -1434,7 +1465,7 @@ truncate table dc_base_purchase_7_temp;", new { time = DateTime.Now.AddDays(-8).
labels = new List<string> { "非服装精准开发" },
website = "小计",
website_show = "小计",
platform_type = "",
platform_type = search_data.platform_type,
days = new List<bailun_sku_website_sales_dto.bailun_sku_website_sales_date_dto>()
});
}
......
......@@ -12,6 +12,18 @@ namespace AutoTurnOver.Models.Report
public bool? has_sum { get; set; }
public string platform_type { get; set; }
}
public class bailun_sku_website_sales_detailed_search_dto
{
public string platform_type { get; set; }
public string label { get; set; }
public string website { get; set; }
public int year { get; set; }
public int month { get; set; }
public int day { get; set; }
}
public class bailun_sku_website_sales_dto
{
public string label { get; set; }
......
......@@ -12,7 +12,7 @@ namespace AutoTurnOver.Models
public int id { get; set; }
public string transaction_id { get; set; }
public string bailun_order_id { get; set; }
public string origin_order_id { get; set; }
public string platform_type { get; set; }
......
......@@ -9,6 +9,7 @@ using AutoTurnOver.Models.Report;
using System.Data;
using AutoTurnOver.Models.ApiDto;
using System.Dynamic;
using System.IO;
namespace AutoTurnOver.Services
{
......@@ -477,10 +478,11 @@ namespace AutoTurnOver.Services
o.label = item.label;
o.platform_type = item.platform_type;
o.website = item.website_show;
o.data_website = item.website;
foreach (var dat_item in item.days)
{
var dic = (IDictionary<string, object>)o;
dic["count_" + (dat_item.month + "-" + dat_item.day)] = Math.Round( dat_item.count,2);
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);
}
......@@ -491,6 +493,59 @@ namespace AutoTurnOver.Services
}
public MemoryStream SkuWebsiteSalesExport(bailun_sku_website_sales_detailed_search_dto search_data,UserData user)
{
try
{
var fileName = AppContext.BaseDirectory + $@"Result\RealtimeStock\{user.UserAccount}商品分类明细-{DateTime.Now.ToString("yyyyMMddHHmmss")}.csv";
var list = report.GetSkuWebsiteSalesDetailed(search_data);
if (list == null || list.Count <= 0) return null;
DataTable table = new DataTable();
string[] cols = new string[] { "百伦订单号","平台单号","平台","站点","sku","标签","销售数量","单价_美元","付款时间" };
foreach (var item in cols)
{
table.Columns.Add(item);
}
foreach (var itemData in list)
{
DataRow row = table.NewRow();
row["百伦订单号"] = itemData.bailun_order_id;
row["平台单号"] = itemData.origin_order_id;
row["sku"] = itemData.bailun_sku;
row["标签"] = itemData.label;
row["销售数量"] = itemData.bailun_sku_quantity_ordered;
row["单价_美元"] = itemData.amount_sales * itemData.order_to_usd_exchange_rate;
row["付款时间"] = itemData.pay_time;
row["平台"] = itemData.platform_type;
row["站点"] = itemData.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;
}
}
public List<supplier_sales_dto> SupplierSalesList(supplier_sales_search_dto m, int offset, int limit, ref int total, string order = "", string sort = "")
{
return report.SupplierSalesList(m, offset, limit, ref total, order, sort);
......
......@@ -640,6 +640,20 @@ namespace AutoTurnOver.Controllers
});
}
public FileResult SkuWebsiteSalesExport(string platform_type,string label,string website,int? year,int? month,int? day)
{
var user = AutoUtility.GetUser();
var memory = new ReportServices().SkuWebsiteSalesExport(new bailun_sku_website_sales_detailed_search_dto {
day = day??0,
label = label,
month = month??0,
platform_type = platform_type,
website =website,
year = year??0
}, AutoUtility.GetUser());
return File(memory, "text/csv", $"{user.UserAccount}商品分类数据信息.csv");
}
public JsonResult GetSkuWebsiteSalesSumFooter(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