Commit bcf7cc59 by guanzhenshan

增加sku来源利润统计报表

parent 88f097fb
......@@ -560,5 +560,10 @@ namespace Bailun.DC.Models.Orders
/// 产品类型
/// </summary>
public string product_type_desc { get; set; }
/// <summary>
/// sku来源
/// </summary>
public int source { get; set; }
}
}
......@@ -1653,10 +1653,21 @@ namespace Bailun.DC.Services
/// <param name="start">付款开始时间</param>
/// <param name="end">付款结束时间</param>
/// <returns></returns>
public List<Models.Orders.dc_base_oms_sku> ListPlatformProfit(string platform, string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, bool isUSD, int? companyid, string skucategoryids, int[] producttype, int? skusource, int? shippingstrategy, DateTime? createstart = null, DateTime? createend = null)
public List<Models.Orders.dc_base_oms_sku> ListPlatformProfit(string platform, string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, bool isUSD, int? companyid, string skucategoryids, int[] producttype, int? skusource, int? shippingstrategy,int statistictype, DateTime? createstart = null, DateTime? createend = null)
{
var str_statistic_col = "tb.platform_type";
if(statistictype==1) //sku品类
{
}
else if(statistictype==2) //sku来源
{
str_statistic_col = "t60.source as platform_type";
}
var sqlparam = new DynamicParameters();
var sql = "select tb.platform_type,count(distinct tb.bailun_order_id) order_count,sum(tb.amount_sales*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "* tb.bailun_sku_quantity_ordered) as amount_sales,sum(tb.cost_platform_fee*(if(tb.platform_type='Ebay'," + (isUSD ? "tb.other_to_usd_exchange_rate" : "tb.seller_other_exchange_rate") + "," + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "))*tb.bailun_sku_quantity_ordered) as cost_platform_fee,sum(tb.cost_first*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + "*tb.bailun_sku_quantity_ordered) as cost_first,sum(tb.cost_tail*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + "*tb.bailun_sku_quantity_ordered) cost_tail,sum(tb.cost_handle_bailun*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + "*tb.bailun_sku_quantity_ordered) cost_handle_bailun,sum(tb.cost_handle_platform*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + "*tb.bailun_sku_quantity_ordered) cost_handle_platform,sum(tb.amount_refund*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "*tb.bailun_sku_quantity_ordered) amount_refund,sum(tb.cost_fba_fee*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "*tb.bailun_sku_quantity_ordered) cost_fba_fee,sum(tb.cost_paypal_fee*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "*tb.bailun_sku_quantity_ordered) cost_paypal_fee,sum(tb.amount_shipping*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "*tb.bailun_sku_quantity_ordered) amount_shipping,sum(tb.cost_promotion*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "*tb.bailun_sku_quantity_ordered) cost_promotion,sum(tb.cost_product*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + "*tb.bailun_sku_quantity_ordered) cost_product,sum(tb.profit_total*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + "*tb.bailun_sku_quantity_ordered) profit_total,(sum(tb.profit_total*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ")/sum(tb.amount_sales*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ")) profit_rate,count((tb.amount_prepaid>0 and tb.bailun_order_status!='Finished') or null) as noshippingcount,sum(tb.amount_prepaid*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + "*tb.bailun_sku_quantity_ordered) amount_prepaid from dc_base_oms_sku tb ";
var sql = $"select {str_statistic_col},count(distinct tb.bailun_order_id) order_count,sum(tb.amount_sales*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "* tb.bailun_sku_quantity_ordered) as amount_sales,sum(tb.cost_platform_fee*(if(tb.platform_type='Ebay'," + (isUSD ? "tb.other_to_usd_exchange_rate" : "tb.seller_other_exchange_rate") + "," + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "))*tb.bailun_sku_quantity_ordered) as cost_platform_fee,sum(tb.cost_first*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + "*tb.bailun_sku_quantity_ordered) as cost_first,sum(tb.cost_tail*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + "*tb.bailun_sku_quantity_ordered) cost_tail,sum(tb.cost_handle_bailun*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + "*tb.bailun_sku_quantity_ordered) cost_handle_bailun,sum(tb.cost_handle_platform*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + "*tb.bailun_sku_quantity_ordered) cost_handle_platform,sum(tb.amount_refund*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "*tb.bailun_sku_quantity_ordered) amount_refund,sum(tb.cost_fba_fee*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "*tb.bailun_sku_quantity_ordered) cost_fba_fee,sum(tb.cost_paypal_fee*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "*tb.bailun_sku_quantity_ordered) cost_paypal_fee,sum(tb.amount_shipping*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "*tb.bailun_sku_quantity_ordered) amount_shipping,sum(tb.cost_promotion*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "*tb.bailun_sku_quantity_ordered) cost_promotion,sum(tb.cost_product*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + "*tb.bailun_sku_quantity_ordered) cost_product,sum(tb.profit_total*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + "*tb.bailun_sku_quantity_ordered) profit_total,(sum(tb.profit_total*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ")/sum(tb.amount_sales*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ")) profit_rate,count((tb.amount_prepaid>0 and tb.bailun_order_status!='Finished') or null) as noshippingcount,sum(tb.amount_prepaid*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + "*tb.bailun_sku_quantity_ordered) amount_prepaid from dc_base_oms_sku tb ";
if (shipstart.HasValue || shipend.HasValue)
{
......@@ -1754,13 +1765,23 @@ namespace Bailun.DC.Services
}
}
}
if (statistictype == 1) //sku品类
{
}
else if (statistictype == 2) //sku来源
{
sql += " join dc_base_sku t60 on tb.bailun_sku=t60.bailun_sku and t60.source in (1,2,3,6,7,11) ";
}
sql += " where tb.bailun_order_status!='Canceled' and ((tb.platform_type!='FBA' and tb.bailun_order_status!='CantHandle') or tb.platform_type='FBA') and tb.has_scalp=0 and tb.has_innersale=0 and tb.bailun_interception_status in ('None','Failed') ";
if (shippingstrategy.HasValue) //1专线;2中国发货;3海外仓; 4FBA仓
{
var listSpecialLogistics = CommonServices.ListLogisticsConfig(1);
......@@ -1825,8 +1846,18 @@ namespace Bailun.DC.Services
sqlparam.Add("createend", createend.Value.AddDays(1));
}
if (statistictype == 0)
{
sql += " group by tb.platform_type";
}
else if (statistictype == 1) //sku品类
{
}
else if (statistictype == 2)
{
sql += " group by t60.source";
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
......@@ -1844,7 +1875,6 @@ namespace Bailun.DC.Services
/// <summary>
/// 根据发货时间获取平台利润统计
/// </summary>
......@@ -1854,10 +1884,22 @@ namespace Bailun.DC.Services
/// <param name="shipstart">发货开始时间</param>
/// <param name="shipend">发货结束时间</param>
/// <returns></returns>
public List<Models.Orders.dc_base_oms_sku> ListPlatformProfitByShipTime(string platform, string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, bool isUSD, int? companyid, string skucategoryids, int[] producttype, int? skusource, int? shippingstrategy)
public List<Models.Orders.dc_base_oms_sku> ListPlatformProfitByShipTime(string platform, string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, bool isUSD, int? companyid, string skucategoryids, int[] producttype, int? skusource, int? shippingstrategy,int statistictype)
{
var str_statistic_col = "t2.platform_type";
if (statistictype == 1) //sku品类
{
}
else if (statistictype == 2) //sku来源
{
str_statistic_col = "t60.source as platform_type";
}
var sqlparam = new DynamicParameters();
var sql = @"select t2.platform_type,count(DISTINCT t2.bailun_order_id) order_count,sum(t2.amount_sales*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) as amount_sales,sum(t2.cost_platform_fee*(if(t2.platform_type='Ebay'," + (isUSD ? "t2.other_to_usd_exchange_rate" : "t2.seller_other_exchange_rate") + "," + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "))*t1.quantity_shipped) as cost_platform_fee,sum(t2.cost_first*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) as cost_first,sum(t2.cost_logistics*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_tail,sum(t2.cost_handle_bailun*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_handle_bailun,sum(t2.cost_handle_platform*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_handle_platform,sum(t2.amount_refund*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) amount_refund,sum(t2.cost_product*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_product,sum(t2.profit_total*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) profit_total,(sum(t2.profit_total*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped)/sum(t2.amount_sales*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped)) profit_rate,count(t2.amount_prepaid>0 or null) as noshippingcount,sum(t2.amount_prepaid*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) amount_prepaid,sum(t2.cost_fba_fee*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) cost_fba_fee,sum(t2.cost_paypal_fee*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) cost_paypal_fee,sum(t2.amount_shipping*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) amount_shipping,sum(t2.cost_promotion*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) cost_promotion from (select t0.id,t0.bailun_order_id,t0.quantity_shipped,t0.bailun_sku from dc_base_oms_pick t0 ";
var sql = $@"select {str_statistic_col},count(DISTINCT t2.bailun_order_id) order_count,sum(t2.amount_sales*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) as amount_sales,sum(t2.cost_platform_fee*(if(t2.platform_type='Ebay'," + (isUSD ? "t2.other_to_usd_exchange_rate" : "t2.seller_other_exchange_rate") + "," + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "))*t1.quantity_shipped) as cost_platform_fee,sum(t2.cost_first*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) as cost_first,sum(t2.cost_logistics*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_tail,sum(t2.cost_handle_bailun*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_handle_bailun,sum(t2.cost_handle_platform*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_handle_platform,sum(t2.amount_refund*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) amount_refund,sum(t2.cost_product*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_product,sum(t2.profit_total*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) profit_total,(sum(t2.profit_total*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped)/sum(t2.amount_sales*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped)) profit_rate,count(t2.amount_prepaid>0 or null) as noshippingcount,sum(t2.amount_prepaid*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) amount_prepaid,sum(t2.cost_fba_fee*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) cost_fba_fee,sum(t2.cost_paypal_fee*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) cost_paypal_fee,sum(t2.amount_shipping*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) amount_shipping,sum(t2.cost_promotion*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) cost_promotion from (select t0.id,t0.bailun_order_id,t0.quantity_shipped,t0.bailun_sku from dc_base_oms_pick t0 ";
var tempsql = "";
......@@ -1903,6 +1945,17 @@ namespace Bailun.DC.Services
sql += " ) t1 ";
sql += " join dc_base_oms_sku t2 on t1.bailun_order_id = t2.bailun_order_id and t1.bailun_sku=t2.bailun_sku and t2.bailun_order_status != 'Canceled' and t2.has_scalp = 0 and ((t2.platform_type!='FBA' and t2.bailun_order_status!='CantHandle') or t2.platform_type='FBA') and t2.has_scalp = 0 and t2.has_innersale = 0 and t2.has_delete=0 ";
//Add by Allan at 20200325
if (statistictype == 1) //sku品类
{
}
else if (statistictype == 2) //sku来源
{
sql += " join dc_base_sku t60 on t2.bailun_sku=t60.bailun_sku and t60.source in (1,2,3,6,7,11) ";
}
//Add by Allan at 20200320,for 增加sku级别的利润统计
if ((producttype != null && producttype.Count() > 0) || skusource.HasValue || shippingstrategy.HasValue)
{
......@@ -1969,7 +2022,19 @@ namespace Bailun.DC.Services
var strwhere = " ";
//Edit by Allan at 20200325
if (statistictype == 0)
{
strwhere += " group by t2.platform_type";
}
else if (statistictype == 1) //sku品类
{
}
else if (statistictype == 2) //sku来源
{
sql += " group by t60.source ";
}
......@@ -5246,10 +5311,21 @@ namespace Bailun.DC.Services
/// <param name="website"></param>
/// <param name="isUSD"></param>
/// <returns></returns>
public List<dc_base_oms_order> ListPlatformRefund(DateTime? start, DateTime? end, int? companyid, string platform, string website, bool isUSD,bool containNotShipping, int[] producttype, int? skusource, int? shippingstrategy)
public List<dc_base_oms_order> ListPlatformRefund(DateTime? start, DateTime? end, int? companyid, string platform, string website, bool isUSD,bool containNotShipping, int[] producttype, int? skusource, int? shippingstrategy,int statistictype)
{
var str_statistic_col = "t1.platform_type";
if (statistictype == 1) //sku品类
{
}
else if (statistictype == 2) //sku来源
{
str_statistic_col = "t60.source as platform_type";
}
var sqlparam = new DynamicParameters();
var sql = $"select t1.platform_type,{(isUSD? "sum(t1.amount_refund_usd)" : "sum(t1.amount_refund_rmb)")} as amount_refund from dc_base_crm_refund t1 ";
var sql = $"select {str_statistic_col},{(isUSD? "sum(t1.amount_refund_usd)" : "sum(t1.amount_refund_rmb)")} as amount_refund from dc_base_crm_refund t1 ";
if ((producttype!=null && producttype.Count()>0) || skusource.HasValue || shippingstrategy.HasValue)
{
......@@ -5304,6 +5380,16 @@ namespace Bailun.DC.Services
}
}
if (statistictype == 1) //sku品类
{
}
else if (statistictype == 2) //sku来源
{
sql += " join dc_base_sku t60 on t1.bailun_sku=t60.bailun_sku and t60.source in (1,2,3,6,7,11) ";
}
sql += " where t1.shipping_status='TotalShipping' and t1.is_deleted=0 and is_freeze=0 ";
if (companyid.HasValue && companyid.Value != 0)
......@@ -5340,7 +5426,20 @@ namespace Bailun.DC.Services
sql += " and t1.shipping_status!='UnShipping'";
}
if (statistictype == 0)
{
sql += " group by t1.platform_type";
}
else if (statistictype == 1)
{
}
else if (statistictype == 2)
{
sql += " group by t60.source";
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
......
......@@ -1528,7 +1528,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
/// 平台利润统计
/// </summary>
/// <returns></returns>
public ActionResult PlatformProfitCount()
public ActionResult PlatformProfitCount(int statistictype = 0)
{
var _skuService = new Services.SkuInfoServices();
......@@ -1559,6 +1559,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
ViewBag.listSkuType = list;
ViewBag.listSource = _skuService.ListSkuSource().Where(a=>a==1||a==3||a==6||a==7).ToList(); //精准开发,线下美容,普货供应商推荐,服务供应商推荐
ViewBag.statistictype = statistictype;
return View();
}
......@@ -1569,10 +1570,12 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
/// <param name="platform">平台类型</param>
/// <param name="start">付款开始时间</param>
/// <param name="end">付款结束时间</param>
/// <param name="skunewcategory">Sku品类</param>
/// <param name="statistictype">统计方式,0:平台类型,1:sku品类,2:sku来源</param>
/// <returns></returns>
[BailunAuthentication(LoginMode.Enforce)]
[HttpPost]
public JsonResult PlatformProfitCountJson(string platform,string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, string currency, string skucategoryids,string product_type,int? skusource,int? shippingstrategy)
public JsonResult PlatformProfitCountJson(string platform,string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, string currency, string skucategoryids,string product_type,int? skusource,int? shippingstrategy,string skunewcategory,int statistictype=0)
{
var _service = new Services.OrdersServices();
var companyid = HttpContextHelper.Current?.User?.GetCompanyId().ToInt32();
......@@ -1626,14 +1629,14 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
{
if (shipstart.HasValue || shipend.HasValue)
{
result = _service.ListPlatformProfitByShipTime(platform, website, start, end, shipstart, shipend, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy);
result = _service.ListPlatformProfitByShipTime(platform, website, start, end, shipstart, shipend, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy,statistictype);
var fbaResult = _service.ListPlatformProfit(string.IsNullOrEmpty(platform) ? "FBA" : "", website, null, null, null, null, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy, shipstart, shipend);
var fbaResult = _service.ListPlatformProfit(string.IsNullOrEmpty(platform) ? "FBA" : "", website, null, null, null, null, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy,statistictype,shipstart, shipend);
dtstart = shipstart;
dtend = shipend;
listRefund = _service.ListPlatformRefund(dtstart, dtend, companyid, platform, website, currency.ToUpper() == "USD", false, producttype, skusource, shippingstrategy); //不包含未发货的退款金额
listRefund = _service.ListPlatformRefund(dtstart, dtend, companyid, platform, website, currency.ToUpper() == "USD", false, producttype, skusource, shippingstrategy,statistictype); //不包含未发货的退款金额
//针对SKU FJH-L-2 做特殊处理
if (producttype.Length > 0)
......@@ -1704,8 +1707,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
}
else
{
result = _service.ListPlatformProfit(platform, website, start, end, shipstart, shipend, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy);
listRefund = _service.ListPlatformRefund(dtstart, dtend, companyid, platform, website, currency.ToUpper() == "USD", true, producttype, skusource, shippingstrategy); //包含未发货的退款金额
result = _service.ListPlatformProfit(platform, website, start, end, shipstart, shipend, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy,statistictype);
listRefund = _service.ListPlatformRefund(dtstart, dtend, companyid, platform, website, currency.ToUpper() == "USD", true, producttype, skusource, shippingstrategy,statistictype); //包含未发货的退款金额
//针对SKU FJH-L-2 做特殊处理
if (producttype.Length > 0)
......@@ -1748,13 +1751,17 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
}
ebayADFee = _service.EbayFeeCount(companyid, dtstart, dtend, ADfeeType, "", "", currency.ToUpper() == "USD", "",producttype,skusource,shippingstrategy);
ebayPutAway = _service.EbayFeeCount(companyid, dtstart, dtend, PutAwayFeeType, "", "", currency.ToUpper() == "USD", "",producttype,skusource,shippingstrategy);
if (statistictype == 0)
{
ebayADFee = _service.EbayFeeCount(companyid, dtstart, dtend, ADfeeType, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy);
ebayPutAway = _service.EbayFeeCount(companyid, dtstart, dtend, PutAwayFeeType, "", "", currency.ToUpper() == "USD", "", producttype, skusource, shippingstrategy);
amazonAD = _service.ListAmazonADSkuCount("", dtstart, dtend, companyid, currency.ToUpper() == "USD",producttype,skusource,shippingstrategy);
amazonAD = _service.ListAmazonADSkuCount("", dtstart, dtend, companyid, currency.ToUpper() == "USD", producttype, skusource, shippingstrategy);
aliexpressAD = _service.ListAliexpressADCount(companyid, "", dtstart, dtend, currency.ToUpper() == "USD");
wishAD = _service.ListWishADCount(companyid, null, dtstart, dtend, currency.ToUpper() == "USD");
}
//aliexpressAD = _service.ListAliexpressADCount(companyid, "", dtstart, dtend, currency.ToUpper() == "USD");
}
......@@ -1762,7 +1769,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
{
if (shipstart.HasValue || shipend.HasValue)
{
result = _service.ListPlatformProfitByShipTime(platform, website, start, end, shipstart, shipend, currency.ToUpper() == "USD", companyid, skucategoryids, null, null, null);
result = _service.ListPlatformProfitByShipTime(platform, website, start, end, shipstart, shipend, currency.ToUpper() == "USD", companyid, skucategoryids, null, null, null,statistictype);
var fbaResult = _service.ListPlatformProfit(string.IsNullOrEmpty(platform) ? "FBA" : "", website, null, null, null, null, currency.ToUpper() == "USD", companyid, skucategoryids, shipstart, shipend);
......@@ -1770,12 +1777,12 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
dtstart = shipstart;
dtend = shipend;
listRefund = _service.ListPlatformRefund(dtstart, dtend, companyid, platform, website, currency.ToUpper() == "USD", false, null, null, null); //不包含未发货的退款金额
listRefund = _service.ListPlatformRefund(dtstart, dtend, companyid, platform, website, currency.ToUpper() == "USD", false, null, null, null,statistictype); //不包含未发货的退款金额
}
else
{
result = _service.ListPlatformProfit(platform, website, start, end, shipstart, shipend, currency.ToUpper() == "USD", companyid, skucategoryids);
listRefund = _service.ListPlatformRefund(dtstart, dtend, companyid, platform, website, currency.ToUpper() == "USD", true, null, null, null); //包含未发货的退款金额
result = _service.ListPlatformProfit(platform, website, start, end, shipstart, shipend, currency.ToUpper() == "USD", companyid, skucategoryids,null,null,null,statistictype);
listRefund = _service.ListPlatformRefund(dtstart, dtend, companyid, platform, website, currency.ToUpper() == "USD", true, null, null, null,statistictype); //包含未发货的退款金额
}
ebayADFee = _service.EbayFeeCount(companyid, dtstart, dtend, ADfeeType, "", "", currency.ToUpper() == "USD", "",null,null,null);
......@@ -1789,6 +1796,11 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
foreach (var item in result)
{
if (statistictype == 2)
{
item.platform_type = Enum.GetName(typeof(SkuSource), int.Parse(item.platform_type));
}
item.adfee = 0;
item.putawayfee = 0;
......@@ -1837,6 +1849,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
item.profit_total = (item.profit_total - item.amount_refund);
item.profit_rate = item.amount_sales!=0?Math.Round((item.profit_total / item.amount_sales), 2):0;
}
if (result.Count > 0)
......
......@@ -23,7 +23,7 @@
<div class="form-inline" style="line-height:40px;">
<div class="form-group">
<label>&nbsp;</label>
<button type="button" class="btn btn-success" onclick="showleft();">分类筛选</button>
<button id="btn_left" type="button" class="btn btn-success" onclick="showleft();" style="display:none;">分类筛选</button>
</div>
<div class="form-group">
<label>币种</label>
......@@ -104,11 +104,26 @@
<table id="roletable" class="table table-hover table-bordered table-condensed table-striped" >
<thead>
<tr>
@if (ViewBag.statistictype == 0)
{
<th style="width:110px;">平台</th>
}
else
{
<th style="width:160px;">平台</th>
}
<th style="width:70px;">订单数</th>
@if (ViewBag.statistictype == 0)
{
<th style="width:40px"></th>
}
<th style="width:110px;">销售额</th>
@if (ViewBag.statistictype == 0)
{
<th style="width:40px"></th>
}
<th style="width:110px;">产品成本</th>
<th style="width:70px;">客单价</th>
<th style="width:100px;">平台费</th>
......@@ -123,7 +138,10 @@
<th style="width:110px;">预收金额</th>
<th style="width:120px;">预收订单数</th>
<th style="width:110px;">利润</th>
@if (ViewBag.statistictype == 0)
{
<th style="width:40px"></th>
}
<th style="width:110px;">利润率%</th>
<th style="width:100px;">退款</th>
<th style="width:110px;">退款率%</th>
......@@ -209,6 +227,10 @@
}
);
if ('@ViewBag.statistictype' == 0) {
$('#btn_left').show();
}
})
function list() {
......@@ -241,13 +263,14 @@
$.submit({
type:'POST',
url: '@Url.Content("~/Reports/Orders/PlatformProfitCountJson")',
paramData: $("#toolbar").serialize() + '&skucategoryids=' + s + '&product_type=' + producttype,
paramData: $("#toolbar").serialize() + '&skucategoryids=' + s + '&product_type=' + producttype +'&statistictype=@(ViewBag.statistictype)',
func: function (result) {
layer.close(lindex);
if (result && result.length > 0) {
$('#tb').html('');
$('#footer').html('');
for (var i = 0; i < result.length-1; i++) {
for (var i = 0; i < result.length - 1; i++) {
if ('@ViewBag.statistictype' == 0) {
var s = '<tr><td class="platform"><a href="javascript:;" onclick="ShowWebsite(\'' + result[i].platform_type + '\');" title="查看订单明细">' + result[i].platform_type + '</a></td>';
s += '<td class="skuprofit" onclick="ShowSkuProfit(\'' + result[i].platform_type + '\',\'订单数\',\'order_count\',0)" title="查看sku分类利润">' + result[i].order_count + '</td>';
s += '<td><img style="width:16px;margin-left:3px" src="@Url.Content("~/img/chart-icon.png")" onclick="ShowChart(\'' + result[i].platform_type + '\',\'订单数\',\'order_count\');" title="点击查看订单数曲线图"></td>';
......@@ -274,11 +297,38 @@
s += '<td>' + result[i].amount_refund_rate + '</td>';
$('#tb').append(s);
}
else {
var s = '<tr><td class="platform">' + result[i].platform_type + '</td>';
s += '<td>' + result[i].order_count + '</td>';
s += '<td> ' + result[i].amount_sales + '</td>';
s += '<td>' + result[i].cost_product + '</td>';
s += '<td>' + result[i].customerprice + '</td>';
s += '<td>' + result[i].cost_platform_fee + '</td>';
s += '<td>' + result[i].cost_fba_fee + '</td>';
s += '<td>' + result[i].cost_paypal_fee + '</td>';
s += '<td>' + result[i].cost_first + '</td>';
s += '<td>' + result[i].cost_tail + '</td>';
s += '<td>' + result[i].cost_handle_bailun + '</td>';
s += '<td>' + result[i].cost_handle_platform + '</td>';
s += '<td>' + result[i].adfee + '</td>';
s += '<td>' + result[i].putawayfee + '</td>';
s += '<td>' + result[i].amount_prepaid + '</td>';
s += '<td>' + result[i].noshippingcount + '</td>';
s += '<td>' + result[i].profit_total + '</td>';
s += '<td>' + result[i].profit_rate + '</td>';
//s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'退款金额\',\'amount_refund\',1)" title="查看订单明细">' + result[i].amount_refund + '</td>';
s += '<td>' + result[i].amount_refund + '</td>';
s += '<td>' + result[i].amount_refund_rate + '</td>';
$('#tb').append(s);
}
}
$("#roletable").trigger("destroy");
$("#roletable").tablesorter();
var i = result.length - 1;
if ('@ViewBag.statistictype' == 0) {
var foot_s = '<tr><td class="platform"><a href="javascript:;" onclick="ShowWebsite(\'' + result[i].platform_type + '\');">' + result[i].platform_type + '</a></td>';
foot_s += '<td class="skuprofit" onclick="ShowSkuProfit(\'\',\'订单数\',\'order_count\',0)" title="查看sku分类利润">' + result[i].order_count + '</td>';
foot_s += '<td><img style="width:16px;margin-left:3px" src="@Url.Content("~/img/chart-icon.png")" onclick="ShowChart(\'\',\'订单数\',\'order_count\');" title="点击查看曲线图"></td>';
......@@ -306,6 +356,33 @@
foot_s += '</tr>';
$('#footer').append(foot_s);
}
else if ('@ViewBag.statistictype' == 2) {
var foot_s = '<tr><td class="platform">' + result[i].platform_type + '</td>';
foot_s += '<td>' + result[i].order_count + '</td>';
foot_s += '<td> ' + result[i].amount_sales + '</td>';
foot_s += '<td>' + result[i].cost_product + '</td>';
foot_s += '<td>' + result[i].customerprice + '</td>';
foot_s += '<td>' + result[i].cost_platform_fee + '</td>';
foot_s += '<td>' + result[i].cost_fba_fee + '</td>';
foot_s += '<td>' + result[i].cost_paypal_fee + '</td>';
foot_s += '<td>' + result[i].cost_first + '</td>';
foot_s += '<td>' + result[i].cost_tail + '</td>';
foot_s += '<td>' + result[i].cost_handle_bailun + '</td>';
foot_s += '<td>' + result[i].cost_handle_platform + '</td>';
foot_s += '<td>' + result[i].adfee + '</td>';
foot_s += '<td>' + result[i].putawayfee + '</td>';
foot_s += '<td>' + result[i].amount_prepaid + '</td>';
foot_s += '<td>' + result[i].noshippingcount + '</td>';
foot_s += '<td>' + result[i].profit_total + '</td>';
foot_s += '<td>' + result[i].profit_rate + '</td>';
//s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'退款金额\',\'amount_refund\',1)" title="查看订单明细">' + result[i].amount_refund + '</td>';
foot_s += '<td>' + result[i].amount_refund + '</td>';
foot_s += '<td>' + result[i].amount_refund_rate + '</td>';
$('#footer').append(foot_s);
}
}
else {
$('#tb').html('');
$('#footer').html('');
......@@ -334,6 +411,7 @@
function listwebsite()
{
if ('@(ViewBag.statistictype)'== 0) {
var p = $('#platform').val();
if (p == '') {
$('#website').html('<option value="">选择站点</option>');
......@@ -354,8 +432,10 @@
}
})
}
}
function ShowWebsite(platform) {
if ('@(ViewBag.statistictype)' == 0) {
if (platform == '总计') {
return false;
}
......@@ -366,16 +446,23 @@
layer_show(platform + ' 按站点统计', '@Url.Content("~/Reports/Orders/PlatformProfitCountByWebSite?platform=")' + platform + '&start=' + start + '&end=' + end, '90%', '90%');
}
}
function ShowDetail(platform, coltitle, colval, single) {
if ('@(ViewBag.statistictype)' == 0) {
layer_show(platform + " " + $('#start').val() + "至" + $('#end').val() + ' 订单明细', '@Url.Content("~/Reports/Orders/ListOrderDetail?platform=")' + platform + '&start=' + $('#start').val() + '&end=' + $('#end').val() + '&col=' + colval + '&coltitle=' + coltitle + '&showsingle=' + single + '&shipstart=' + $('#shipstart').val() + '&shipend=' + $('#shipend').val(), '90%', '90%');
}
}
function ShowSkuProfit(platform, coltitle, colval) {
var start = $('#start').val();
var end = $('#end').val();
if ('@(ViewBag.statistictype)' == 0) {
layer_show(platform + " " + coltitle + " " + $('#start').val() + "至" + $('#end').val() + ' 的SKU分类利润', '@Url.Content("~/Reports/Orders/SkuCategoryProfit?start=")' + start + '&end=' + end + '&colname=' + colval + '&platform=' + platform + '&coltitle=' + coltitle, '95%', '95%');
}
}
function showleft() {
var c = $('#leftcontain').css('display');
......
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