Commit 6ca2c165 by guanzhenshan

平台利润报表增加按产品类型筛选,包括广告费和上架费,退款

parent af2acf0b
......@@ -1511,7 +1511,7 @@ 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,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, DateTime? createstart=null,DateTime? createend=null)
{
var sqlparam = new DynamicParameters();
var sql = "select tb.platform_type,count(tb.bailun_order_id) order_count,sum(tb.amount_sales*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ") 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") + "))) as cost_platform_fee,sum(tb.cost_first*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") as cost_first,sum(tb.cost_tail*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") cost_tail,sum(tb.cost_handle_bailun*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") cost_handle_bailun,sum(tb.cost_handle_platform*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") cost_handle_platform,sum(tb.amount_refund*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ") amount_refund,sum(tb.cost_fba_fee*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ") cost_fba_fee,sum(tb.cost_paypal_fee*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ") cost_paypal_fee,sum(tb.amount_shipping*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ") amount_shipping,sum(tb.cost_promotion*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ") cost_promotion,sum(tb.cost_product*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") cost_product,sum(tb.profit_total*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") 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") + ") amount_prepaid from dc_base_oms_order tb ";
......@@ -1575,6 +1575,7 @@ namespace Bailun.DC.Services
}
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 (companyid.HasValue && companyid.Value > 0)
......@@ -1643,6 +1644,173 @@ namespace Bailun.DC.Services
}
/// <summary>
/// 获取平台利润
/// </summary>
/// <param name="platform">平台类型</param>
/// <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)
{
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 ";
if (shipstart.HasValue || shipend.HasValue)
{
sql += " left join dc_base_oms_pick t1 on tb.bailun_order_id =t1.bailun_order_id ";
}
if (!string.IsNullOrWhiteSpace(skucategoryids))
{
sql += @" join (select distinct bailun_order_id from dc_base_oms_sku t3
join dc_base_sku t4 on t3.bailun_sku=t4.bailun_sku
";
var arr = skucategoryids.Split('|').Where(a => !string.IsNullOrEmpty(a)).ToList();
if (arr.Count > 0)
{
//获取选中分类下所有的分类
//var AllCategory = Services.CommonServices.GetCategoryList(0);
//var listcategory = new List<Models.Common.CategoryDto>();
//foreach (var item in arr)
//{
// listcategory.AddRange(Services.CommonServices.GetCategoryListAll(AllCategory, int.Parse(item)));
//}
var s = string.Join(",", arr);
if (!string.IsNullOrEmpty(s))
{
//sql += " and t3.bailun_category_id in (" + s + ") ";
sql += " and t4.category_simple_id in (" + s + ")";
}
}
sql += " where t3.bailun_order_status!='Canceled' and ((t3.platform_type!='FBA' and t3.bailun_order_status!='CantHandle') or t3.platform_type='FBA') and t3.has_scalp=0 and t3.has_innersale=0 and t3.bailun_interception_status in ('None','Failed') and t3.has_delete=0 ";
if (companyid.HasValue && companyid.Value > 0)
{
sql += " and t3.company_id=" + companyid.Value; //增加公司id过滤
}
if (!string.IsNullOrWhiteSpace(platform))
{
sql += " and t3.platform_type='" + platform + "'";
}
if (!string.IsNullOrWhiteSpace(website))
{
sql += " and t3.website='" + website + "'";
}
if (start.HasValue)
{
sql += " and t3.paid_time>='" + start.Value.ToString("yyyy-MM-dd") + "'";
}
if (end.HasValue)
{
sql += " and t3.paid_time<'" + end.Value.AddDays(1).ToString("yyyy-MM-dd") + "'";
}
sql += ") t33 on tb.bailun_order_id=t33.bailun_order_id";
}
//Add by Allan at 20200320,for 增加sku级别的利润统计
if (producttype.HasValue || skusource.HasValue || shippingstrategy.HasValue)
{
sql += " join dc_base_sku t10 on tb.bailun_sku=t10.bailun_sku ";
if (producttype.HasValue)
{
sql += " and t10.product_type=" + producttype.Value;
}
if (skusource.HasValue)
{
sql += " and t10.source=" + skusource;
}
if (shippingstrategy.HasValue) //1专线;2中国发货;3美国仓
{
}
}
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 (companyid.HasValue && companyid.Value > 0)
{
sql += " and tb.company_id=" + companyid.Value; //增加公司id过滤
}
if (!string.IsNullOrWhiteSpace(platform))
{
sql += " and tb.platform_type=@platform_type";
sqlparam.Add("platform_type", platform);
}
if (!string.IsNullOrWhiteSpace(website))
{
sql += " and tb.website=@website";
sqlparam.Add("website", website);
}
if (start.HasValue)
{
sql += " and tb.paid_time>=@paid_time_start";
sqlparam.Add("paid_time_start", start.Value);
}
if (end.HasValue)
{
sql += " and tb.paid_time<@paid_time_end";
sqlparam.Add("paid_time_end", end.Value.AddDays(1));
}
if (shipstart.HasValue)
{
sql += " and ((tb.platform_type='FBA' and tb.paid_time>=@shipstart) or (tb.platform_type!='FBA' and t1.shipping_time>=@shipstart))";
sqlparam.Add("shipstart", shipstart.Value);
}
if (shipend.HasValue)
{
sql += " and ((tb.platform_type='FBA' and tb.paid_time<@shipend) or (tb.platform_type!='FBA' and t1.shipping_time<@shipend))";
sqlparam.Add("shipend", shipend.Value.AddDays(1));
}
if (createstart.HasValue)
{
sql += " and tb.create_time>=@createstart";
sqlparam.Add("createstart", createstart.Value);
}
if (createend.HasValue)
{
sql += " and tb.create_time<@createend";
sqlparam.Add("createend", createend.Value.AddDays(1));
}
sql += " group by tb.platform_type";
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
var obj = cn.Query<Models.Orders.dc_base_oms_sku>(sql, sqlparam, null, true, 2 * 60);
return obj.AsList();
}
}
/// <summary>
/// 根据发货时间获取平台利润统计
/// </summary>
......@@ -1652,7 +1820,7 @@ 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)
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)
{
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 id,bailun_order_id,quantity_shipped,bailun_sku from dc_base_oms_pick where has_delete=0 and shipping_status = 'TotalShipping' ";
......@@ -1674,12 +1842,27 @@ 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 20200320,for 增加sku级别的利润统计
if (producttype.HasValue || skusource.HasValue || shippingstrategy.HasValue)
{
sql += " join dc_base_sku t10 on t2.bailun_sku=t10.bailun_sku ";
//if (companyid.HasValue && companyid.Value > 0)
//{
// sql += " and t2.company_id=" + companyid.Value; //增加公司id过滤
//}
if (producttype.HasValue)
{
sql += " and t10.product_type="+producttype.Value;
}
if (skusource.HasValue)
{
sql += " and t10.source="+skusource;
}
if (shippingstrategy.HasValue) //1专线;2中国发货;3美国仓
{
}
}
if (!string.IsNullOrWhiteSpace(platform))
{
......@@ -1731,7 +1914,16 @@ namespace Bailun.DC.Services
var strwhere = " ";
if (producttype.HasValue || skusource.HasValue || shippingstrategy.HasValue)
{
}
else
{
strwhere += " group by t2.platform_type";
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
......@@ -3083,7 +3275,7 @@ namespace Bailun.DC.Services
/// <param name="total"></param>
/// <param name="feetype"></param>
/// <returns></returns>
public dc_base_finance_ebay EbayFeeCount(int? companyid, DateTime? start, DateTime? end, string[] feetype, string orderno, string account,bool isUSD,string itemid)
public dc_base_finance_ebay EbayFeeCount(int? companyid, DateTime? start, DateTime? end, string[] feetype, string orderno, string account,bool isUSD,string itemid, int? producttype, int? skusource, int? shippingstrategy)
{
var sqlparam = new DynamicParameters();
var sql = $"select sum(t1.gross_amount) gross_amount,sum(t1.net_amount) net_amount,sum(t1.{(isUSD? "exchange_rate_usd" : "exchange_rate")}*t1.gross_amount) gross_amount_rmb from dc_base_finance_ebay t1 ";
......@@ -3095,8 +3287,43 @@ namespace Bailun.DC.Services
sqlparam.Add("account_name", account);
}
//Add by Allan at 20200320
if (producttype.HasValue || skusource.HasValue || shippingstrategy.HasValue)
{
sql = $"select 0 gross_amount,0 net_amount,sum(t1.{(isUSD ? "exchange_rate_usd" : "exchange_rate")}*t1.sku_amount*t1.sku_count) gross_amount_rmb from dc_base_finance_ebay_item t1 ";
sql += " where 1=1 ";
sqlparam = new DynamicParameters();
if (!string.IsNullOrWhiteSpace(account))
{
sql += " join dc_base_company_account t2 on t1.company_id=t2.company_id and t1.account_id=t2.account_id ";
sql += " and t2.account_name=@account_name ";
sqlparam.Add("account_name", account);
}
if (producttype.HasValue || skusource.HasValue || shippingstrategy.HasValue)
{
sql += " join dc_base_sku t10 on t1.bailun_sku=t10.bailun_sku ";
if (producttype.HasValue)
{
sql += " and t10.product_type=" + producttype.Value;
}
if (skusource.HasValue)
{
sql += " and t10.source=" + skusource;
}
if (shippingstrategy.HasValue) //1专线;2中国发货;3美国仓
{
}
}
}
sql += " where t1.id!=0 ";
if (start.HasValue)
{
......@@ -4974,10 +5201,32 @@ 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)
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)
{
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 where t1.shipping_status='TotalShipping' and t1.is_deleted=0 and is_freeze=0 ";
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 ";
if (producttype.HasValue || skusource.HasValue || shippingstrategy.HasValue)
{
sql += " join dc_base_sku t10 on t1.bailun_sku=t10.bailun_sku ";
if (producttype.HasValue)
{
sql += " and t10.product_type=" + producttype.Value;
}
if (skusource.HasValue)
{
sql += " and t10.source=" + skusource;
}
if (shippingstrategy.HasValue) //1专线;2中国发货;3美国仓
{
}
}
sql += " where t1.shipping_status='TotalShipping' and t1.is_deleted=0 and is_freeze=0 ";
if (companyid.HasValue && companyid.Value != 0)
{
......@@ -5156,7 +5405,7 @@ namespace Bailun.DC.Services
/// <param name="end"></param>
/// <param name="companyid"></param>
/// <returns></returns>
public dc_base_finance_amazon_ad_product ListAmazonADSkuCount(string account, DateTime? start, DateTime? end, int? companyid,bool isUSD)
public dc_base_finance_amazon_ad_product ListAmazonADSkuCount(string account, DateTime? start, DateTime? end, int? companyid,bool isUSD, int? producttype, int? skusource, int? shippingstrategy)
{
var sqlparam = new DynamicParameters();
var sql = $"select sum(cost) cost,sum(cost*{(isUSD?"exchange_rate_usd":"exchange_rate")}) cost_rmb from dc_base_finance_amazon_ad_product t1 join dc_base_company_account t2 on t1.account_id=t2.account_id ";
......@@ -5167,7 +5416,40 @@ namespace Bailun.DC.Services
sqlparam.Add("account", account);
}
sql += " where 1=1 ";
//Add by Allan at 20200320
if (producttype.HasValue || skusource.HasValue || shippingstrategy.HasValue)
{
sql = $"select sum(cost) cost,sum(cost*{(isUSD ? "exchange_rate_usd" : "exchange_rate")}) cost_rmb from dc_base_finance_amazon_item t1 join dc_base_company_account t2 on t1.account_id=t2.account_id ";
sqlparam = new DynamicParameters();
if (!string.IsNullOrEmpty(account))
{
sql += " and t2.account_name=@account";
sqlparam.Add("account", account);
}
sql += " join dc_base_sku t10 on t1.bailun_sku=t10.bailun_sku ";
if (producttype.HasValue)
{
sql += " and t10.product_type=" + producttype.Value;
}
if (skusource.HasValue)
{
sql += " and t10.source=" + skusource;
}
if (shippingstrategy.HasValue) //1专线;2中国发货;3美国仓
{
}
}
sql += " where t1.id!=0 ";
if (companyid.HasValue && companyid.Value > 0)
{
......
......@@ -1161,7 +1161,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
var obj = _service.ListEbayFee(parameter, companyid, start, end, ref total, feeType,orderno,account,"");
var countObj = _service.EbayFeeCount(companyid, start, end, feeType, orderno,account,false,"");
var countObj = _service.EbayFeeCount(companyid, start, end, feeType, orderno,account,false,"",null,null,null);
var list = obj.Select(a => new {
a.id,
......@@ -1225,7 +1225,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
var obj = _service.ListEbayFee(parameter, companyid, start, end, ref total, feeType, orderno, account,itemid);
var countObj = _service.EbayFeeCount(companyid, start, end, feeType, orderno, account,false,itemid);
var countObj = _service.EbayFeeCount(companyid, start, end, feeType, orderno, account,false,itemid,null,null,null);
var list = obj.Select(a => new {
a.id,
......@@ -1532,7 +1532,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
{
var _skuService = new Services.SkuInfoServices();
ViewBag.listSkuType = _skuService.ListSkuProductType();
ViewBag.listSkuType = _skuService.ListSkuProductType().Where(a=>!string.IsNullOrEmpty(a.product_type_desc)).ToList();
ViewBag.listSource = _skuService.ListSkuSource();
......@@ -1549,7 +1549,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
/// <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)
public JsonResult PlatformProfitCountJson(string platform,string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, string currency, string skucategoryids,int? producttype,int? skusource,int? shippingstrategy)
{
var _service = new Services.OrdersServices();
var companyid = HttpContextHelper.Current?.User?.GetCompanyId().ToInt32();
......@@ -1561,6 +1561,10 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
var ebayADFee = new dc_base_finance_ebay(); //Ebay 广告费
var ebayPutAway = new dc_base_finance_ebay(); //Ebay 上架费
var listRefund = new List<Models.Orders.dc_base_oms_order>();
var amazonAD = new dc_base_finance_amazon_ad_product();
var wishAD = new dc_base_finance_wish();
var aliexpressAD = new dc_base_finance_aliexpress();
var ADfeeType = new string[] {
"FeeAd"
};
......@@ -1586,32 +1590,66 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
"CrediteBayStores"
};
//Add by Allan at 20200320,for 增加sku级别的利润统计
if (producttype.HasValue || skusource.HasValue || shippingstrategy.HasValue)
{
if (shipstart.HasValue || shipend.HasValue)
{
result = _service.ListPlatformProfitByShipTime(platform,website, start, end, shipstart, shipend, currency.ToUpper() == "USD", companyid, skucategoryids);
result = _service.ListPlatformProfitByShipTime(platform, website, start, end, shipstart, shipend, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy);
var fbaResult = _service.ListPlatformProfit(string.IsNullOrEmpty(platform) ? "FBA" : "",website, null,null,null, null, currency.ToUpper() == "USD", companyid, skucategoryids, shipstart, shipend);
var fbaResult = _service.ListPlatformProfit(string.IsNullOrEmpty(platform) ? "FBA" : "", website, null, null, null, null, currency.ToUpper() == "USD", companyid, skucategoryids, producttype, skusource, shippingstrategy, shipstart, shipend);
result.AddRange(fbaResult);
dtstart = shipstart;
dtend = shipend;
listRefund = _service.ListPlatformRefund(dtstart, dtend, companyid, platform, website, currency.ToUpper() == "USD",false); //不包含未发货的退款金额
listRefund = _service.ListPlatformRefund(dtstart, dtend, companyid, platform, website, currency.ToUpper() == "USD", false, producttype, skusource, shippingstrategy); //不包含未发货的退款金额
}
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); //包含未发货的退款金额
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); //包含未发货的退款金额
}
ebayADFee = _service.EbayFeeCount(companyid, dtstart, dtend, ADfeeType, "", "", currency.ToUpper() == "USD","");
ebayPutAway = _service.EbayFeeCount(companyid, dtstart, dtend, PutAwayFeeType, "", "", currency.ToUpper() == "USD","");
var amazonAD = _service.ListAmazonADSkuCount("", dtstart, dtend, companyid, currency.ToUpper() == "USD");
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);
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");
}
else
{
if (shipstart.HasValue || shipend.HasValue)
{
result = _service.ListPlatformProfitByShipTime(platform, website, start, end, shipstart, shipend, currency.ToUpper() == "USD", companyid, skucategoryids, null, null, null);
var fbaResult = _service.ListPlatformProfit(string.IsNullOrEmpty(platform) ? "FBA" : "", website, null, null, null, null, currency.ToUpper() == "USD", companyid, skucategoryids, shipstart, shipend);
result.AddRange(fbaResult);
dtstart = shipstart;
dtend = shipend;
listRefund = _service.ListPlatformRefund(dtstart, dtend, companyid, platform, website, currency.ToUpper() == "USD", false, null, null, null); //不包含未发货的退款金额
}
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); //包含未发货的退款金额
}
ebayADFee = _service.EbayFeeCount(companyid, dtstart, dtend, ADfeeType, "", "", currency.ToUpper() == "USD", "",null,null,null);
ebayPutAway = _service.EbayFeeCount(companyid, dtstart, dtend, PutAwayFeeType, "", "", currency.ToUpper() == "USD", "",null,null,null);
amazonAD = _service.ListAmazonADSkuCount("", dtstart, dtend, companyid, currency.ToUpper() == "USD",null,null,null);
wishAD = _service.ListWishADCount(companyid, null, dtstart, dtend, currency.ToUpper() == "USD");
aliexpressAD = _service.ListAliexpressADCount(companyid, "", dtstart, dtend, currency.ToUpper() == "USD");
}
var wishAD = _service.ListWishADCount(companyid, null, dtstart, dtend, currency.ToUpper() == "USD");
var aliexpressAD = _service.ListAliexpressADCount(companyid, "", dtstart, dtend, currency.ToUpper() == "USD");
foreach (var item in result)
{
......@@ -1694,7 +1732,6 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
}
var list = result.Select(p => new {
p.platform_type,
customerprice = (p.amount_sales / p.order_count).ToString("N2"),
......@@ -2393,7 +2430,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
var total = 0;
var obj = _service.ListAmazonADSku(parameter, account, start, end, companyid, ref total);
var countObj = _service.ListAmazonADSkuCount(account, start, end, companyid,false);
var countObj = _service.ListAmazonADSkuCount(account, start, end, companyid,false,null,null,null);
var list = obj.Select(a => new {
a.account_name,
......@@ -3588,5 +3625,14 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
#endregion
#region private
#endregion
}
}
\ No newline at end of file
......@@ -29,8 +29,8 @@
<body class="fixed-sidebar full-height-layout gray-bg" style="overflow:hidden">
<script type="text/javascript">
//login_localhost();
login();
login_localhost();
//login();
window.location = "@Url.Content("~/Home/Main")";
</script>
</body>
......
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