Commit c428b861 by guanzhenshan

优化SKU品类利润统计报表,增加二级和三级报表

parent 6d1aa63b
...@@ -10,5 +10,6 @@ namespace Bailun.DC.Models.Sku ...@@ -10,5 +10,6 @@ namespace Bailun.DC.Models.Sku
public string product_type_desc { get; set; } public string product_type_desc { get; set; }
public string selected { get; set; }
} }
} }
...@@ -490,6 +490,25 @@ namespace Bailun.DC.Services ...@@ -490,6 +490,25 @@ namespace Bailun.DC.Services
} }
/// <summary> /// <summary>
/// 获取百伦新分类详情信息
/// </summary>
/// <param name="id">分类id</param>
/// <returns></returns>
public static Models.Sku.dc_base_bailuncategory getBailunNewCategory(int id)
{
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
return cn.QueryFirstOrDefault<Models.Sku.dc_base_bailuncategory>("select * from dc_base_bailuncategory where c_id="+id);
}
}
/// <summary>
/// 根据分类id获取所有子级id /// 根据分类id获取所有子级id
/// </summary> /// </summary>
/// <param name="parentid">父级分类id</param> /// <param name="parentid">父级分类id</param>
...@@ -498,7 +517,7 @@ namespace Bailun.DC.Services ...@@ -498,7 +517,7 @@ namespace Bailun.DC.Services
{ {
var str = ""; var str = "";
if (list.Count==0) if (list==null || list.Count==0)
{ {
list = ListBailunNewCategory(null, null); list = ListBailunNewCategory(null, null);
} }
...@@ -530,6 +549,8 @@ namespace Bailun.DC.Services ...@@ -530,6 +549,8 @@ namespace Bailun.DC.Services
} }
} }
#region 汇率实体 ExchangeRate #region 汇率实体 ExchangeRate
......
...@@ -1773,7 +1773,13 @@ namespace Bailun.DC.Services ...@@ -1773,7 +1773,13 @@ namespace Bailun.DC.Services
if (skunewcategoryid.HasValue) if (skunewcategoryid.HasValue)
{ {
sql += " join dc_base_bailuncategory t70 on t60.bailun_category_id=t70.c_id and t70.c_level=1 and t70.has_delete=0 and t70.c_id in (" + Services.CommonServices.BailunNewCategory(skunewcategoryid.Value,null) + ")"; var str_children_category = Services.CommonServices.BailunNewCategory(skunewcategoryid.Value, null);
if (str_children_category == "")
{
str_children_category = skunewcategoryid.Value + "";
}
sql += " and t60.bailun_category_id in (" + str_children_category + ")";
} }
} }
else if (statistictype == 2) //sku来源 else if (statistictype == 2) //sku来源
...@@ -1957,9 +1963,15 @@ namespace Bailun.DC.Services ...@@ -1957,9 +1963,15 @@ namespace Bailun.DC.Services
if (skunewcategoryid.HasValue) if (skunewcategoryid.HasValue)
{ {
sql += " join dc_base_bailuncategory t70 on t60.bailun_category_id=t70.c_id and t70.c_level=1 and t70.has_delete=0 and t70.c_id in ("+Services.CommonServices.BailunNewCategory(skunewcategoryid.Value,null)+")"; var str_children_category = Services.CommonServices.BailunNewCategory(skunewcategoryid.Value, null);
if (str_children_category == "")
{
str_children_category = skunewcategoryid.Value + "";
}
sql += " and t60.bailun_category_id in (" + str_children_category + ")";
} }
} }
else if (statistictype == 2) //sku来源 else if (statistictype == 2) //sku来源
{ {
......
...@@ -1831,6 +1831,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -1831,6 +1831,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
if (m == null) if (m == null)
{ {
m = new Models.Orders.dc_base_oms_sku { m = new Models.Orders.dc_base_oms_sku {
id = item.c_id,
platform_type= item.c_name, platform_type= item.c_name,
cost_platform_fee = 0, cost_platform_fee = 0,
profit_total = 0, profit_total = 0,
...@@ -1850,6 +1851,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -1850,6 +1851,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
}; };
} }
m.id = item.c_id;
m.order_count += children.Sum(a => a.order_count); m.order_count += children.Sum(a => a.order_count);
m.customerprice += children.Sum(a => a.customerprice); m.customerprice += children.Sum(a => a.customerprice);
...@@ -1991,6 +1993,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -1991,6 +1993,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
adfee = (p.adfee ?? 0).ToString("N2"), adfee = (p.adfee ?? 0).ToString("N2"),
putawayfee = (p.putawayfee ?? 0).ToString("N2"), putawayfee = (p.putawayfee ?? 0).ToString("N2"),
id = p.id,
}).ToList(); }).ToList();
...@@ -2390,6 +2393,89 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -2390,6 +2393,89 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
return View(); return View();
} }
public ActionResult SkuProfitCount(string platform, string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, string currency, string product_type, int? skusource, int? shippingstrategy, int? skunewcategory, int statistictype = 0)
{
var _skuService = new Services.SkuInfoServices();
var listProductType = _skuService.ListSkuProductType().Where(a => !string.IsNullOrEmpty(a.product_type_desc)).ToList();
int index = -1;
var list = new List<Models.Sku.mSku_ProductType>();
var arr_producttype = new List<string>();
if (product_type != null)
{
product_type.Split(',').Where(a => !string.IsNullOrEmpty(a)).ToList();
}
foreach (var item in listProductType)
{
item.selected = "";
var mProductType = arr_producttype.Where(a => a == item.product_type.ToString()).FirstOrDefault();
if (mProductType != null)
{
item.selected = "selected";
}
if (item.product_type == 5 || item.product_type == 13)
{
if (index != -1)
{
list.Insert(index, item);
}
else
{
index = listProductType.IndexOf(item);
list.Add(item);
}
}
else
{
list.Add(item);
}
}
ViewBag.listSkuType = list;
ViewBag.listSource = _skuService.ListSkuSource().Where(a => a == 1 || a == 3 || a == 6 || a == 7).ToList(); //精准开发,线下美容,普货供应商推荐,服务供应商推荐
ViewBag.statistictype = statistictype;
ViewBag.platform = platform;
ViewBag.website = website;
ViewBag.start = start.HasValue ? start.Value.ToString("yyyy-MM-dd") : "";
ViewBag.end = end.HasValue ? end.Value.ToString("yyyy-MM-dd") : "";
ViewBag.shipstart = shipstart.HasValue ? shipstart.Value.ToString("yyyy-MM-dd") : "";
ViewBag.shipend = shipend.HasValue ? shipend.Value.ToString("yyyy-MM-dd") : "";
ViewBag.currency = currency;
ViewBag.product_type = product_type;
ViewBag.skusource = skusource.HasValue ? skusource.Value + "" : "";
ViewBag.shippingstrategy = shippingstrategy.HasValue ? shippingstrategy.Value+"" : "";
ViewBag.skunewcategory = skunewcategory.HasValue ? skunewcategory.Value + "" : "";
if (skunewcategory.HasValue)
{
var objCategory = Services.CommonServices.getBailunNewCategory(skunewcategory.Value);
if (objCategory != null)
{
ViewBag.level = objCategory.c_level;
}
else
{
ViewBag.level = 1;
}
}
else
{
ViewBag.level = 1;
}
return View();
}
#endregion #endregion
#region 订单退款明细 #region 订单退款明细
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
<span>至</span> <span>至</span>
<input id="shipend" name="shipend" type="text" class="form-control" style="width:130px;" placeholder="发货结束时间" /> <input id="shipend" name="shipend" type="text" class="form-control" style="width:130px;" placeholder="发货结束时间" />
</div> </div>
<div class="form-group"> <div id="content_producttype" class="form-group" style="display:none;">
<label>产品类型</label> <label>产品类型</label>
<select id="producttype" name="producttype" class="form-control" multiple="multiple"> <select id="producttype" name="producttype" class="form-control" multiple="multiple">
@*<option value="">选择产品类型</option>*@ @*<option value="">选择产品类型</option>*@
...@@ -233,6 +233,10 @@ ...@@ -233,6 +233,10 @@
if ('@ViewBag.statistictype' == 0) { if ('@ViewBag.statistictype' == 0) {
$('#btn_left').show(); $('#btn_left').show();
$('#content_producttype').show();
}
else if ('@ViewBag.statistictype' == '2') {
$('#content_producttype').show();
} }
}) })
...@@ -302,7 +306,7 @@ ...@@ -302,7 +306,7 @@
$('#tb').append(s); $('#tb').append(s);
} }
else if('@ViewBag.statistictype' == 1){ else if('@ViewBag.statistictype' == 1){
var s = '<tr><td class="platform" ><div style="width:220px;" class="mules" title="' + result[i].platform_type + '">' + result[i].platform_type + '</div></td>'; var s = '<tr><td class="platform" ><div style="width:220px;" class="mules" title="' + result[i].platform_type + '"><a onclick="skucategorychildren(' + result[i].id + ',\'' + result[i].platform_type +'\')">' + result[i].platform_type + '</a></div></td>';
s += '<td>' + result[i].order_count + '</td>'; s += '<td>' + result[i].order_count + '</td>';
s += '<td> ' + result[i].amount_sales + '</td>'; s += '<td> ' + result[i].amount_sales + '</td>';
s += '<td>' + result[i].cost_product + '</td>'; s += '<td>' + result[i].cost_product + '</td>';
...@@ -409,7 +413,7 @@ ...@@ -409,7 +413,7 @@
$('#footer').append(foot_s); $('#footer').append(foot_s);
} }
else if('@ViewBag.statistictype' == 1) { else if('@ViewBag.statistictype' == 1) {
var foot_s = '<tr><td class="platform">' + result[i].platform_type + '</td>'; var foot_s = '<tr>' + result[i].platform_type + '</td>';
foot_s += '<td>' + result[i].order_count + '</td>'; foot_s += '<td>' + result[i].order_count + '</td>';
foot_s += '<td> ' + result[i].amount_sales + '</td>'; foot_s += '<td> ' + result[i].amount_sales + '</td>';
foot_s += '<td>' + result[i].cost_product + '</td>'; foot_s += '<td>' + result[i].cost_product + '</td>';
...@@ -600,6 +604,35 @@ ...@@ -600,6 +604,35 @@
layer_show(platform + " " + title+"曲线图", '@Url.Content("~/Reports/Orders/OrderProfitGraph?platform=")' + platform + '&start=' + $('#start').val() + '&end=' + $('#end').val() + '&col=' + colval + '&shipstart=' + $('#shipstart').val() + '&shipend=' + $('#shipend').val() + '&currency=' + $('#currency').val() + '&skucategoryids=' + s + '&titlename=' + title, '90%', '90%'); layer_show(platform + " " + title+"曲线图", '@Url.Content("~/Reports/Orders/OrderProfitGraph?platform=")' + platform + '&start=' + $('#start').val() + '&end=' + $('#end').val() + '&col=' + colval + '&shipstart=' + $('#shipstart').val() + '&shipend=' + $('#shipend').val() + '&currency=' + $('#currency').val() + '&skucategoryids=' + s + '&titlename=' + title, '90%', '90%');
} }
function skucategorychildren(categoryid, title) {
if (categoryid == 0) {
alert("抱歉,该分类在百伦新分类无法找到!");
return false;
}
var producttype = $("#producttype").ySelectedValues(",");
var shipstart = $('#shipstart').val();
var shipend = $('#shipend').val();
var start = $('#start').val();
var end = $('#end').val();
if ((shipstart != '' || shipend != '') && (start != '' || end != '')) {
layer.alert('搜索条件不能同时选择付款时间和发货时间,只能选其一。');
return false;
}
if (start == '' && end == '' && shipstart == '' && shipend == '') {
layer.alert('请选择时间进行搜索。');
return false;
}
var urlparam = $("#toolbar").serialize() + '&product_type=' + producttype + '&statistictype=@(ViewBag.statistictype)' + '&skunewcategory=' + categoryid;
layer_show(title + "的产品分类利润统计",'@Url.Content("~/Reports/Orders/SkuProfitCount?")'+urlparam,'95%','95%');
}
</script> </script>
} }
......
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