Commit ef7e3b8d by guanzhenshan

修复Ebay相关报表页面数据,更改为按sku统计维度

parent abeccd91
...@@ -269,6 +269,11 @@ namespace Bailun.DC.Models.Orders ...@@ -269,6 +269,11 @@ namespace Bailun.DC.Models.Orders
public string bailun_sku_size { get; set; } public string bailun_sku_size { get; set; }
/// <summary> /// <summary>
/// 销售额
/// </summary>
public decimal amount_sales { get; set; }
/// <summary>
/// 收入总金额-原币种 /// 收入总金额-原币种
/// </summary> /// </summary>
public decimal amount_total { get; set; } public decimal amount_total { get; set; }
...@@ -304,6 +309,16 @@ namespace Bailun.DC.Models.Orders ...@@ -304,6 +309,16 @@ namespace Bailun.DC.Models.Orders
public decimal amount_refund { get; set; } public decimal amount_refund { get; set; }
/// <summary> /// <summary>
/// 退款率
/// </summary>
public decimal amount_refund_rate { get; set; }
/// <summary>
/// 预收款
/// </summary>
public decimal amount_prepaid { get; set; }
/// <summary>
/// 总支出费用 /// 总支出费用
/// </summary> /// </summary>
public decimal cost_total { get; set; } public decimal cost_total { get; set; }
...@@ -347,18 +362,28 @@ namespace Bailun.DC.Models.Orders ...@@ -347,18 +362,28 @@ namespace Bailun.DC.Models.Orders
/// 退款佣金费用 /// 退款佣金费用
/// </summary> /// </summary>
public decimal cost_refund_commisson { get; set; } public decimal cost_refund_commisson { get; set; }
/// <summary> /// <summary>
/// 估算物流费用 /// 处理费(百伦收取)
/// </summary> /// </summary>
public decimal cost_estimate_logistics { get; set; } public decimal cost_handle_bailun { get; set; }
/// <summary> /// <summary>
/// 处理费(平台收取)
/// </summary>
public decimal cost_handle_platform { get; set; }
/// <summary>
/// 头程费 /// 头程费
/// </summary> /// </summary>
public decimal cost_first { get; set; } public decimal cost_first { get; set; }
/// <summary> /// <summary>
/// 尾程费
/// </summary>
public decimal cost_tail { get; set; }
/// <summary>
/// 利润=总收入-总支出 /// 利润=总收入-总支出
/// </summary> /// </summary>
public decimal profit_total { get; set; } public decimal profit_total { get; set; }
...@@ -473,5 +498,20 @@ namespace Bailun.DC.Models.Orders ...@@ -473,5 +498,20 @@ namespace Bailun.DC.Models.Orders
/// </summary> /// </summary>
public decimal losswithdrawal { get; set; } public decimal losswithdrawal { get; set; }
/// <summary>
/// 订单总数
/// </summary>
public int order_count { get; set; }
/// <summary>
/// 客单价
/// </summary>
public decimal customerprice { get; set; }
/// <summary>
/// 利润率
/// </summary>
public decimal profitrate { get; set; }
} }
} }
...@@ -111,7 +111,7 @@ namespace Bailun.DC.Services ...@@ -111,7 +111,7 @@ namespace Bailun.DC.Services
{ {
var sqlparam = new DynamicParameters(); var sqlparam = new DynamicParameters();
var sql = @"select platform_type,seller_account,website,order_currency,sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped) 'amount_product',sum(cost_product*bailun_sku_quantity_shipped) 'cost_product',sum(cost_platform_fee*seller_order_exchange_rate*bailun_sku_quantity_shipped) 'platform_fee',sum(cost_first*bailun_sku_quantity_shipped) 'head_fee',count(t1.id) 'order_count',sum(cost_total*bailun_sku_quantity_shipped) 'cost_count',sum(cost_tail*bailun_sku_quantity_shipped) 'nofba_logisticsfee',sum(profit_total*bailun_sku_quantity_shipped) 'profit_count',(sum(profit_total*bailun_sku_quantity_shipped)/sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped)) 'profit_rate',sum(amount_prepaid) amount_prepaid,sum(amount_refund*seller_order_exchange_rate*bailun_sku_quantity_shipped) amount_refund from dc_base_oms_sku t1"; var sql = @"select platform_type,seller_account,website,order_currency,sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped) 'amount_product',sum(cost_product*bailun_sku_quantity_shipped) 'cost_product',sum(cost_platform_fee*seller_order_exchange_rate*bailun_sku_quantity_shipped) 'platform_fee',sum(cost_first*bailun_sku_quantity_shipped) 'head_fee',count(t1.bailun_order_id) 'order_count',sum(cost_total*bailun_sku_quantity_shipped) 'cost_count',sum(cost_tail*bailun_sku_quantity_shipped) 'nofba_logisticsfee',sum(profit_total*bailun_sku_quantity_shipped) 'profit_count',(sum(profit_total*bailun_sku_quantity_shipped)/sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped)) 'profit_rate',sum(amount_prepaid) amount_prepaid,sum(amount_refund*seller_order_exchange_rate*bailun_sku_quantity_shipped) amount_refund from dc_base_oms_sku t1";
var presql = "select platform_type,seller_account,website,order_currency,sum(amount_prepaid) as amount_prepaid from dc_base_oms_sku t1 "; var presql = "select platform_type,seller_account,website,order_currency,sum(amount_prepaid) as amount_prepaid from dc_base_oms_sku t1 ";
if (!string.IsNullOrEmpty(warehoursetype)) if (!string.IsNullOrEmpty(warehoursetype))
...@@ -936,28 +936,33 @@ namespace Bailun.DC.Services ...@@ -936,28 +936,33 @@ namespace Bailun.DC.Services
/// <param name="start">付款开始时间</param> /// <param name="start">付款开始时间</param>
/// <param name="end">付款结束时间</param> /// <param name="end">付款结束时间</param>
/// <returns></returns> /// <returns></returns>
public List<Models.Orders.mPlatformProfit> ListPlatformProfit(string platform, DateTime? start, DateTime? end) public List<Models.Orders.dc_base_oms_sku> ListPlatformProfit(string platform, DateTime? start, DateTime? end)
{ {
var sqlparam = new DynamicParameters(); var sqlparam = new DynamicParameters();
var sql = "select platform_type as platform, sum(amount_total*seller_order_exchange_rate) saleamount,count(id) ordercount,sum(cost_platform_fee*seller_order_exchange_rate) platformfee,(sum(amount_total*seller_order_exchange_rate)/count(id)) customerprice,sum(profit_total) profit,(sum(profit_total)/sum(amount_total*seller_order_exchange_rate)) profitrate,sum(amount_refund*seller_order_exchange_rate) returnamount,(sum(amount_refund*seller_order_exchange_rate)/sum(amount_total*seller_order_exchange_rate)) returnamountrate,sum(cost_first) cost_first,sum(cost_tail) cost_tail,sum(cost_handle_bailun) cost_handle_bailun,sum(cost_handle_platform) cost_handle_platform,sum(amount_prepaid) amount_prepaid from dc_base_oms_order where bailun_order_status!='Canceled'"; var sql = "select platform_type, sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped) amount_sales,count(bailun_order_id) order_count,sum(cost_platform_fee*seller_order_exchange_rate*bailun_sku_quantity_shipped) cost_platform_fee,(sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped)/count(bailun_order_id)) customerprice,sum(profit_total*bailun_sku_quantity_shipped) profit_total,(sum(profit_total*bailun_sku_quantity_shipped)/sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped)) profitrate,sum(amount_refund*seller_order_exchange_rate*bailun_sku_quantity_shipped) amount_refund,sum(cost_first*bailun_sku_quantity_shipped) cost_first,sum(cost_tail*bailun_sku_quantity_shipped) cost_tail,sum(cost_handle_bailun*bailun_sku_quantity_shipped) cost_handle_bailun,sum(cost_handle_platform*bailun_sku_quantity_shipped) cost_handle_platform from dc_base_oms_sku where bailun_order_status!='Canceled' and bailun_sku_quantity_shipped>0";
var presql = "select platform_type,sum(amount_prepaid) amount_prepaid from dc_base_oms_sku where bailun_order_status!='Canceled' and amount_prepaid>0 ";
if (!string.IsNullOrWhiteSpace(platform)) if (!string.IsNullOrWhiteSpace(platform))
{ {
sql += " and platform_type=@platform_type"; sql += " and platform_type=@platform_type";
presql += " and platform_type=@platform_type";
sqlparam.Add("platform_type", platform); sqlparam.Add("platform_type", platform);
} }
if (start.HasValue) if (start.HasValue)
{ {
sql += " and paid_time>=@paid_time_start"; sql += " and paid_time>=@paid_time_start";
presql += " and paid_time>=@paid_time_start";
sqlparam.Add("paid_time_start", start.Value); sqlparam.Add("paid_time_start", start.Value);
} }
if (end.HasValue) if (end.HasValue)
{ {
sql += " and paid_time<@paid_time_end"; sql += " and paid_time<@paid_time_end";
presql += " and paid_time<@paid_time_end";
sqlparam.Add("paid_time_end", end.Value.AddDays(1)); sqlparam.Add("paid_time_end", end.Value.AddDays(1));
} }
sql += " group by platform_type"; sql += " group by platform_type";
presql += " group by platform_type";
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString)) using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{ {
...@@ -966,7 +971,20 @@ namespace Bailun.DC.Services ...@@ -966,7 +971,20 @@ namespace Bailun.DC.Services
cn.Open(); cn.Open();
} }
var obj = cn.Query<Models.Orders.mPlatformProfit>(sql, sqlparam); var obj = cn.Query<Models.Orders.dc_base_oms_sku>(sql, sqlparam);
//增加预收款金额
var obj1 = cn.Query<Models.Orders.dc_base_oms_sku>(presql, sqlparam);
foreach (var item in obj)
{
var temp = obj1.Where(a => a.platform_type == item.platform_type).FirstOrDefault();
if (temp != null)
{
item.amount_prepaid = temp.amount_prepaid;
}
}
return obj.AsList(); return obj.AsList();
} }
...@@ -984,21 +1002,26 @@ namespace Bailun.DC.Services ...@@ -984,21 +1002,26 @@ namespace Bailun.DC.Services
public List<Models.Orders.mPlatformProfit> ListPlatformProfitByWebSite(string platform, DateTime? start, DateTime? end, BtTableParameter parameter, ref int total) public List<Models.Orders.mPlatformProfit> ListPlatformProfitByWebSite(string platform, DateTime? start, DateTime? end, BtTableParameter parameter, ref int total)
{ {
var sqlparam = new DynamicParameters(); var sqlparam = new DynamicParameters();
var sql = "select platform_type as platform,website,sum(amount_total*seller_order_exchange_rate) saleamount,count(id) ordercount,sum(cost_platform_fee*seller_order_exchange_rate) platformfee,(sum(amount_total*seller_order_exchange_rate)/count(id)) customerprice,sum(profit_total) profit,(sum(profit_total)/sum(amount_total*seller_order_exchange_rate)) profitrate,sum(amount_refund*seller_order_exchange_rate) returnamount,(sum(amount_refund*seller_order_exchange_rate)/sum(amount_total*seller_order_exchange_rate)) returnamountrate,sum(cost_first) cost_first,sum(cost_tail) cost_tail,sum(cost_handle_bailun) cost_handle_bailun,sum(cost_handle_platform) cost_handle_platform,sum(amount_prepaid*seller_order_exchange_rate) amount_prepaid from dc_base_oms_order where bailun_order_status!='Canceled'";
var precolumn = "select website,platform_type as platform,sum(amount_prepaid*seller_order_exchange_rate) amount_prepaid from dc_base_oms_sku where bailun_order_status!='Canceled' ";
var sql = "select platform_type as platform,website,sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped) saleamount,count(bailun_order_id) ordercount,sum(cost_platform_fee*seller_order_exchange_rate*bailun_sku_quantity_shipped) platformfee,(sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped)/count(bailun_order_id)) customerprice,sum(profit_total*bailun_sku_quantity_shipped) profit,(sum(profit_total)/sum(amount_sales*seller_order_exchange_rate)) profitrate,sum(amount_refund*seller_order_exchange_rate*bailun_sku_quantity_shipped) returnamount,(sum(amount_refund)/sum(amount_sales)) returnamountrate,sum(cost_first*bailun_sku_quantity_shipped) cost_first,sum(cost_tail*bailun_sku_quantity_shipped) cost_tail,sum(cost_handle_bailun*bailun_sku_quantity_shipped) cost_handle_bailun,sum(cost_handle_platform*bailun_sku_quantity_shipped) cost_handle_platform from dc_base_oms_sku where bailun_order_status!='Canceled' and bailun_sku_quantity_shipped>0";
if (!string.IsNullOrWhiteSpace(platform)) if (!string.IsNullOrWhiteSpace(platform))
{ {
sql += " and platform_type=@platform_type"; sql += " and platform_type=@platform_type";
precolumn += " and platform_type=@platform_type";
sqlparam.Add("platform_type", platform); sqlparam.Add("platform_type", platform);
} }
if (start.HasValue) if (start.HasValue)
{ {
sql += " and paid_time>=@paid_time_start"; sql += " and paid_time>=@paid_time_start";
precolumn += " and paid_time>=@paid_time_start";
sqlparam.Add("paid_time_start", start.Value); sqlparam.Add("paid_time_start", start.Value);
} }
if (end.HasValue) if (end.HasValue)
{ {
sql += " and paid_time<@paid_time_end"; sql += " and paid_time<@paid_time_end";
precolumn += " and paid_time<@paid_time_end";
sqlparam.Add("paid_time_end", end.Value.AddDays(1)); sqlparam.Add("paid_time_end", end.Value.AddDays(1));
} }
...@@ -1017,7 +1040,24 @@ namespace Bailun.DC.Services ...@@ -1017,7 +1040,24 @@ namespace Bailun.DC.Services
} }
var obj = cn.Page<Models.Orders.mPlatformProfit>(parameter.pageIndex,parameter.limit,sql,ref total,sqlparam); var obj = cn.Page<Models.Orders.mPlatformProfit>(parameter.pageIndex,parameter.limit,sql,ref total,sqlparam);
return obj.AsList();
var list = obj.AsList();
precolumn += " and amount_prepaid>0";
precolumn += " and website in ('" + string.Join("','", list.Select(a => a.website)) + "') and platform_type in ('" + string.Join("','", list.Select(a => a.platform).Distinct()) + "')";
precolumn += " group by website,platform_type";
var obj1 = cn.Query<Models.Orders.mPlatformProfit>(precolumn, sqlparam);
foreach (var item in list)
{
var temp = obj1.Where(a => a.website == item.website && a.platform == item.platform).FirstOrDefault();
if (temp != null)
{
item.amount_prepaid = temp.amount_prepaid;
}
}
return list;
} }
} }
...@@ -1033,21 +1073,25 @@ namespace Bailun.DC.Services ...@@ -1033,21 +1073,25 @@ namespace Bailun.DC.Services
public Models.Orders.mPlatformProfit ListPlatformProfitByWebSiteCount(string platform, DateTime? start, DateTime? end, BtTableParameter parameter, ref int total) public Models.Orders.mPlatformProfit ListPlatformProfitByWebSiteCount(string platform, DateTime? start, DateTime? end, BtTableParameter parameter, ref int total)
{ {
var sqlparam = new DynamicParameters(); var sqlparam = new DynamicParameters();
var sql = "select sum(amount_total*seller_order_exchange_rate) saleamount,count(id) ordercount,sum(cost_platform_fee*seller_order_exchange_rate) platformfee,(sum(amount_total*seller_order_exchange_rate)/count(id)) customerprice,sum(profit_total) profit,(sum(profit_total)/sum(amount_total*seller_order_exchange_rate)) profitrate,sum(amount_refund*seller_order_exchange_rate) returnamount,(sum(amount_refund*seller_order_exchange_rate)/sum(amount_total*seller_order_exchange_rate)) returnamountrate,sum(cost_first) cost_first,sum(cost_tail) cost_tail,sum(cost_handle_bailun) cost_handle_bailun,sum(cost_handle_platform) cost_handle_platform from dc_base_oms_order where bailun_order_status!='Canceled'"; var sql = "select sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped) saleamount,count(bailun_order_id) ordercount,sum(cost_platform_fee*seller_order_exchange_rate*bailun_sku_quantity_shipped) platformfee,(sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped)/count(bailun_order_id)) customerprice,sum(profit_total*bailun_sku_quantity_shipped) profit,(sum(profit_total)/sum(amount_sales*seller_order_exchange_rate)) profitrate,sum(amount_refund*seller_order_exchange_rate*bailun_sku_quantity_shipped) returnamount,(sum(amount_refund)/sum(amount_sales)) returnamountrate,sum(cost_first*bailun_sku_quantity_shipped) cost_first,sum(cost_tail*bailun_sku_quantity_shipped) cost_tail,sum(cost_handle_bailun*bailun_sku_quantity_shipped) cost_handle_bailun,sum(cost_handle_platform*bailun_sku_quantity_shipped) cost_handle_platform from dc_base_oms_sku where bailun_order_status!='Canceled' and bailun_sku_quantity_shipped>0";
var precolumn = "select sum(amount_prepaid*seller_order_exchange_rate) amount_prepaid from dc_base_oms_sku where bailun_order_status!='Canceled' ";
if (!string.IsNullOrWhiteSpace(platform)) if (!string.IsNullOrWhiteSpace(platform))
{ {
sql += " and platform_type=@platform_type"; sql += " and platform_type=@platform_type";
precolumn += " and platform_type=@platform_type";
sqlparam.Add("platform_type", platform); sqlparam.Add("platform_type", platform);
} }
if (start.HasValue) if (start.HasValue)
{ {
sql += " and paid_time>=@paid_time_start"; sql += " and paid_time>=@paid_time_start";
precolumn += " and paid_time>=@paid_time_start";
sqlparam.Add("paid_time_start", start.Value); sqlparam.Add("paid_time_start", start.Value);
} }
if (end.HasValue) if (end.HasValue)
{ {
sql += " and paid_time<@paid_time_end"; sql += " and paid_time<@paid_time_end";
precolumn += " and paid_time<@paid_time_end";
sqlparam.Add("paid_time_end", end.Value.AddDays(1)); sqlparam.Add("paid_time_end", end.Value.AddDays(1));
} }
...@@ -1059,6 +1103,14 @@ namespace Bailun.DC.Services ...@@ -1059,6 +1103,14 @@ namespace Bailun.DC.Services
} }
var obj = cn.QueryFirst<Models.Orders.mPlatformProfit>(sql, sqlparam); var obj = cn.QueryFirst<Models.Orders.mPlatformProfit>(sql, sqlparam);
var obj1 = cn.QueryFirst<Models.Orders.mPlatformProfit>(precolumn, sqlparam);
if (obj != null && obj1 != null)
{
obj.amount_prepaid = obj1.amount_prepaid;
}
return obj; return obj;
} }
} }
...@@ -1078,7 +1130,7 @@ namespace Bailun.DC.Services ...@@ -1078,7 +1130,7 @@ namespace Bailun.DC.Services
public List<Models.Orders.dc_base_oms_order> ListPlatformProfitOrders(BtTableParameter parameter, string platform, string website,string account, DateTime? start, DateTime? end, string orderno, ref int total) public List<Models.Orders.dc_base_oms_order> ListPlatformProfitOrders(BtTableParameter parameter, string platform, string website,string account, DateTime? start, DateTime? end, string orderno, ref int total)
{ {
var sqlparam = new DynamicParameters(); var sqlparam = new DynamicParameters();
var sql = "select id,platform_type,website,origin_order_id,bailun_order_id,seller_account,order_currency,amount_total,amount_product,amount_shipping,amount_tax,amount_adjustment,amount_gift_wrap,amount_refund,cost_total,cost_promotion,cost_platform_fee,cost_product,cost_shipping,cost_package,cost_fba_fee,cost_paypal_fee,cost_refund_commisson,cost_handle_bailun,cost_handle_platform,cost_tail,cost_first,profit_total,profit_rate,create_time,paid_time,seller_order_exchange_rate,seller_other_exchange_rate,(amount_prepaid) amount_prepaid from dc_base_oms_order where bailun_order_status!='Canceled' "; var sql = "select platform_type,website,origin_order_id,bailun_order_id,seller_account,order_currency,sum(amount_sales*bailun_sku_quantity_shipped*seller_order_exchange_rate) amount_total,sum(amount_product*bailun_sku_quantity_shipped*seller_order_exchange_rate) amount_product,sum(amount_shipping*bailun_sku_quantity_shipped*seller_order_exchange_rate) amount_shipping,sum(amount_tax*bailun_sku_quantity_shipped*seller_order_exchange_rate) amount_tax,sum(amount_adjustment*bailun_sku_quantity_shipped*seller_order_exchange_rate) amount_adjustment,sum(amount_gift_wrap*bailun_sku_quantity_shipped*seller_order_exchange_rate) amount_gift_wrap,sum(amount_refund*bailun_sku_quantity_shipped*seller_order_exchange_rate) amount_refund,sum(cost_total*bailun_sku_quantity_shipped) cost_total,sum(cost_promotion*bailun_sku_quantity_shipped*seller_order_exchange_rate) cost_promotion,sum(cost_platform_fee*bailun_sku_quantity_shipped*seller_order_exchange_rate) cost_platform_fee,sum(cost_product*bailun_sku_quantity_shipped) cost_product,sum(cost_shipping*bailun_sku_quantity_shipped) cost_shipping,sum(cost_package*bailun_sku_quantity_shipped*seller_order_exchange_rate) cost_package,sum(cost_fba_fee*bailun_sku_quantity_shipped*seller_order_exchange_rate) cost_fba_fee,sum(cost_paypal_fee*bailun_sku_quantity_shipped*seller_order_exchange_rate) cost_paypal_fee,sum(cost_refund_commisson*bailun_sku_quantity_shipped*seller_order_exchange_rate) cost_refund_commisson,sum(cost_handle_bailun*bailun_sku_quantity_shipped) cost_handle_bailun,sum(cost_handle_platform*bailun_sku_quantity_shipped) cost_handle_platform,sum(cost_tail*bailun_sku_quantity_shipped) cost_tail,sum(cost_first*bailun_sku_quantity_shipped) cost_first,sum(profit_total*bailun_sku_quantity_shipped) profit_total,(sum(profit_total)/sum(amount_sales)) profit_rate,create_time,paid_time,seller_order_exchange_rate,seller_other_exchange_rate,sum(amount_prepaid*seller_order_exchange_rate) amount_prepaid from dc_base_oms_sku where bailun_order_status!='Canceled' and bailun_sku_quantity_shipped>0";
if (!string.IsNullOrWhiteSpace(platform)) if (!string.IsNullOrWhiteSpace(platform))
{ {
...@@ -1111,6 +1163,8 @@ namespace Bailun.DC.Services ...@@ -1111,6 +1163,8 @@ namespace Bailun.DC.Services
sqlparam.Add("seller_account", account); sqlparam.Add("seller_account", account);
} }
sql += " group by bailun_order_id ";
if (!string.IsNullOrEmpty(parameter.sort)) if (!string.IsNullOrEmpty(parameter.sort))
{ {
sql += " order by "+parameter.sort+" "+parameter.order; sql += " order by "+parameter.sort+" "+parameter.order;
...@@ -1578,7 +1632,10 @@ namespace Bailun.DC.Services ...@@ -1578,7 +1632,10 @@ namespace Bailun.DC.Services
{ {
var sqlparam = new DynamicParameters(); var sqlparam = new DynamicParameters();
var sql = @"select t1.platform_type,t1.seller_account,t1.website,sum(t1.amount_product*t1.seller_order_exchange_rate) 'amount_product',sum(t1.cost_product) 'cost_product',sum(t1.cost_platform_fee*t1.seller_other_exchange_rate) 'cost_platform_fee',sum(t1.cost_first) 'cost_first',count(t1.id) 'order_count',sum(t1.cost_total) 'cost_total',sum(t1.cost_shipping) 'cost_shipping',sum(t1.profit_total) 'profit_total',(sum(t1.profit_total)/sum(t1.amount_total*t1.seller_order_exchange_rate)) 'profit_rate',sum(t1.amount_prepaid) amount_prepaid,sum(t1.amount_refund*t1.seller_order_exchange_rate) amount_refund from dc_base_oms_order t1"; var sql = @"select platform_type,seller_account,sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped) 'amount_product',sum(cost_paypal_fee*seller_order_exchange_rate*bailun_sku_quantity_shipped) 'cost_paypal_fee',sum(cost_product*bailun_sku_quantity_shipped) 'cost_product',sum(cost_platform_fee*seller_order_exchange_rate*bailun_sku_quantity_shipped) 'cost_platform_fee',sum(cost_first*bailun_sku_quantity_shipped) 'cost_first',count(t1.bailun_order_id) 'order_count',sum(cost_total*bailun_sku_quantity_shipped) 'cost_total',sum(cost_tail*bailun_sku_quantity_shipped) 'cost_tail',sum(profit_total*bailun_sku_quantity_shipped) 'profit_total',(sum(profit_total*bailun_sku_quantity_shipped)/sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped)) 'profit_rate',sum(amount_prepaid) amount_prepaid,sum(amount_refund*seller_order_exchange_rate*bailun_sku_quantity_shipped) amount_refund,sum(cost_handle_bailun*bailun_sku_quantity_shipped) cost_handle_bailun from dc_base_oms_sku t1";
var presql = "select platform_type,seller_account,website,order_currency,sum(amount_prepaid) as amount_prepaid from dc_base_oms_sku t1 ";
//var sql = @"select t1.platform_type,t1.seller_account,t1.website,sum(t1.amount_product*t1.seller_order_exchange_rate) 'amount_product',sum(t1.cost_product) 'cost_product',sum(t1.cost_platform_fee*t1.seller_other_exchange_rate) 'cost_platform_fee',sum(t1.cost_first) 'cost_first',count(t1.id) 'order_count',sum(t1.cost_total) 'cost_total',sum(t1.cost_shipping) 'cost_shipping',sum(t1.profit_total) 'profit_total',(sum(t1.profit_total)/sum(t1.amount_total*t1.seller_order_exchange_rate)) 'profit_rate',sum(t1.amount_prepaid) amount_prepaid,sum(t1.amount_refund*t1.seller_order_exchange_rate) amount_refund from dc_base_oms_order t1";
var sqlwhere = " where platform_type='Ebay' and bailun_order_status!='Canceled' "; var sqlwhere = " where platform_type='Ebay' and bailun_order_status!='Canceled' ";
if (!string.IsNullOrEmpty(warehousetype) || (!string.IsNullOrEmpty(warehousetype) && !string.IsNullOrEmpty(warehousecode))) if (!string.IsNullOrEmpty(warehousetype) || (!string.IsNullOrEmpty(warehousetype) && !string.IsNullOrEmpty(warehousecode)))
...@@ -1586,6 +1643,9 @@ namespace Bailun.DC.Services ...@@ -1586,6 +1643,9 @@ namespace Bailun.DC.Services
sql += " join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id " + (!string.IsNullOrEmpty(warehousecode) ? " and t2.warehouse_code=@warehousecode" : ""); sql += " join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id " + (!string.IsNullOrEmpty(warehousecode) ? " and t2.warehouse_code=@warehousecode" : "");
sql += " join dc_base_warehouse t3 on t2.warehouse_code =t3.warehouse_code and hq_type=@warehousetype"; sql += " join dc_base_warehouse t3 on t2.warehouse_code =t3.warehouse_code and hq_type=@warehousetype";
presql += " join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id " + (!string.IsNullOrEmpty(warehousecode) ? " and t2.warehouse_code=@warehousecode" : "");
presql += " join dc_base_warehouse t3 on t2.warehouse_code =t3.warehouse_code and hq_type=@warehousetype";
sqlparam.Add("warehousetype", warehousetype); sqlparam.Add("warehousetype", warehousetype);
if (!string.IsNullOrEmpty(warehousecode)) if (!string.IsNullOrEmpty(warehousecode))
{ {
...@@ -1595,6 +1655,7 @@ namespace Bailun.DC.Services ...@@ -1595,6 +1655,7 @@ namespace Bailun.DC.Services
else if (!string.IsNullOrEmpty(warehousecode)) else if (!string.IsNullOrEmpty(warehousecode))
{ {
sql += " join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id and t2.warehouse_code=@warehousecode"; sql += " join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id and t2.warehouse_code=@warehousecode";
presql += " join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id and t2.warehouse_code=@warehousecode";
sqlparam.Add("warehousecode", warehousecode); sqlparam.Add("warehousecode", warehousecode);
} }
...@@ -1621,8 +1682,9 @@ namespace Bailun.DC.Services ...@@ -1621,8 +1682,9 @@ namespace Bailun.DC.Services
sqlwhere += " and t1.paid_time<'" + end.Value.AddDays(1).ToString("yyyy-MM-dd") + "'"; sqlwhere += " and t1.paid_time<'" + end.Value.AddDays(1).ToString("yyyy-MM-dd") + "'";
} }
var prefromsql = sqlwhere;
sqlwhere += " group by t1.seller_account,t1.website,t1.order_currency,t1.platform_type"; sqlwhere += " and bailun_sku_quantity_shipped>0";
sqlwhere += " group by t1.seller_account,t1.platform_type";
if (!string.IsNullOrWhiteSpace(parameter.sort)) if (!string.IsNullOrWhiteSpace(parameter.sort))
{ {
...@@ -1638,6 +1700,23 @@ namespace Bailun.DC.Services ...@@ -1638,6 +1700,23 @@ namespace Bailun.DC.Services
var obj = cn.Page<Models.Orders.dc_base_oms_order>(parameter.pageIndex, parameter.limit, sql+sqlwhere, ref total, sqlparam); var obj = cn.Page<Models.Orders.dc_base_oms_order>(parameter.pageIndex, parameter.limit, sql+sqlwhere, ref total, sqlparam);
//另外计算预收款金额
var list = obj.AsList();
prefromsql += " and bailun_sku_quantity_shipped<=0";
prefromsql += " and seller_account in ('" + string.Join("','", list.Select(a => a.seller_account)) + "')";
prefromsql += " group by seller_account,platform_type";
var obj1 = cn.Query<Models.Orders.dc_base_oms_order>(presql + prefromsql, sqlparam);
foreach (var item in list)
{
var temp = obj1.Where(a => a.seller_account == item.seller_account && a.website == item.website && a.order_currency == item.order_currency && a.platform_type == item.platform_type).FirstOrDefault();
if (temp != null)
{
item.amount_prepaid = temp.amount_prepaid;
}
}
return obj.AsList(); return obj.AsList();
} }
...@@ -1658,7 +1737,10 @@ namespace Bailun.DC.Services ...@@ -1658,7 +1737,10 @@ namespace Bailun.DC.Services
{ {
var sqlparam = new DynamicParameters(); var sqlparam = new DynamicParameters();
var sql = @"select sum(t1.amount_product*t1.seller_order_exchange_rate) 'amount_product',sum(t1.cost_product) 'cost_product',sum(t1.cost_platform_fee*t1.seller_order_exchange_rate) 'cost_platform_fee',sum(t1.cost_first) 'cost_first',count(t1.id) 'order_count',sum(t1.cost_total) 'cost_total',sum(t1.cost_shipping) 'cost_shipping',sum(t1.profit_total) 'profit_total',(sum(t1.profit_total)/sum(t1.amount_total*t1.seller_order_exchange_rate)) 'profit_rate',sum(t1.amount_prepaid) amount_prepaid,sum(t1.amount_refund*t1.seller_order_exchange_rate) amount_refund from dc_base_oms_order t1"; var sql = @"select sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped) 'amount_product',sum(cost_paypal_fee*seller_order_exchange_rate*bailun_sku_quantity_shipped) 'cost_paypal_fee',sum(cost_product*bailun_sku_quantity_shipped) 'cost_product',sum(cost_platform_fee*seller_order_exchange_rate*bailun_sku_quantity_shipped) 'cost_platform_fee',sum(cost_first*bailun_sku_quantity_shipped) 'cost_first',count(t1.bailun_order_id) 'order_count',sum(cost_total*bailun_sku_quantity_shipped) 'cost_total',sum(cost_tail*bailun_sku_quantity_shipped) 'cost_tail',sum(profit_total*bailun_sku_quantity_shipped) 'profit_total',(sum(profit_total*bailun_sku_quantity_shipped)/sum(amount_sales*seller_order_exchange_rate*bailun_sku_quantity_shipped)) 'profit_rate',sum(amount_prepaid) amount_prepaid,sum(amount_refund*seller_order_exchange_rate*bailun_sku_quantity_shipped) amount_refund,sum(cost_handle_bailun*bailun_sku_quantity_shipped) cost_handle_bailun from dc_base_oms_sku t1";
var presql = "select platform_type,seller_account,website,order_currency,sum(amount_prepaid) as amount_prepaid from dc_base_oms_sku t1 ";
//var sql = @"select t1.platform_type,t1.seller_account,t1.website,sum(t1.amount_product*t1.seller_order_exchange_rate) 'amount_product',sum(t1.cost_product) 'cost_product',sum(t1.cost_platform_fee*t1.seller_other_exchange_rate) 'cost_platform_fee',sum(t1.cost_first) 'cost_first',count(t1.id) 'order_count',sum(t1.cost_total) 'cost_total',sum(t1.cost_shipping) 'cost_shipping',sum(t1.profit_total) 'profit_total',(sum(t1.profit_total)/sum(t1.amount_total*t1.seller_order_exchange_rate)) 'profit_rate',sum(t1.amount_prepaid) amount_prepaid,sum(t1.amount_refund*t1.seller_order_exchange_rate) amount_refund from dc_base_oms_order t1";
var sqlwhere = " where platform_type='Ebay' and bailun_order_status!='Canceled' "; var sqlwhere = " where platform_type='Ebay' and bailun_order_status!='Canceled' ";
if (!string.IsNullOrEmpty(warehousetype) || (!string.IsNullOrEmpty(warehousetype) && !string.IsNullOrEmpty(warehousecode))) if (!string.IsNullOrEmpty(warehousetype) || (!string.IsNullOrEmpty(warehousetype) && !string.IsNullOrEmpty(warehousecode)))
...@@ -1666,6 +1748,9 @@ namespace Bailun.DC.Services ...@@ -1666,6 +1748,9 @@ namespace Bailun.DC.Services
sql += " join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id " + (!string.IsNullOrEmpty(warehousecode) ? " and t2.warehouse_code=@warehousecode" : ""); sql += " join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id " + (!string.IsNullOrEmpty(warehousecode) ? " and t2.warehouse_code=@warehousecode" : "");
sql += " join dc_base_warehouse t3 on t2.warehouse_code =t3.warehouse_code and hq_type=@warehousetype"; sql += " join dc_base_warehouse t3 on t2.warehouse_code =t3.warehouse_code and hq_type=@warehousetype";
presql += " join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id " + (!string.IsNullOrEmpty(warehousecode) ? " and t2.warehouse_code=@warehousecode" : "");
presql += " join dc_base_warehouse t3 on t2.warehouse_code =t3.warehouse_code and hq_type=@warehousetype";
sqlparam.Add("warehousetype", warehousetype); sqlparam.Add("warehousetype", warehousetype);
if (!string.IsNullOrEmpty(warehousecode)) if (!string.IsNullOrEmpty(warehousecode))
{ {
...@@ -1675,6 +1760,7 @@ namespace Bailun.DC.Services ...@@ -1675,6 +1760,7 @@ namespace Bailun.DC.Services
else if (!string.IsNullOrEmpty(warehousecode)) else if (!string.IsNullOrEmpty(warehousecode))
{ {
sql += " join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id and t2.warehouse_code=@warehousecode"; sql += " join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id and t2.warehouse_code=@warehousecode";
presql += " join dc_base_oms_pick t2 on t1.origin_order_id=t2.origin_order_id and t2.warehouse_code=@warehousecode";
sqlparam.Add("warehousecode", warehousecode); sqlparam.Add("warehousecode", warehousecode);
} }
...@@ -1701,6 +1787,10 @@ namespace Bailun.DC.Services ...@@ -1701,6 +1787,10 @@ namespace Bailun.DC.Services
sqlwhere += " and t1.paid_time<'" + end.Value.AddDays(1).ToString("yyyy-MM-dd") + "'"; sqlwhere += " and t1.paid_time<'" + end.Value.AddDays(1).ToString("yyyy-MM-dd") + "'";
} }
var prefromsql = sqlwhere;
sqlwhere += " and bailun_sku_quantity_shipped>0";
//sqlwhere += " group by t1.seller_account,t1.platform_type";
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString)) using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{ {
if (cn.State == System.Data.ConnectionState.Closed) if (cn.State == System.Data.ConnectionState.Closed)
...@@ -1710,6 +1800,17 @@ namespace Bailun.DC.Services ...@@ -1710,6 +1800,17 @@ namespace Bailun.DC.Services
var obj = cn.QueryFirstOrDefault<Models.Orders.dc_base_oms_order>(sql + sqlwhere, sqlparam); var obj = cn.QueryFirstOrDefault<Models.Orders.dc_base_oms_order>(sql + sqlwhere, sqlparam);
//另外计算预收款金额
prefromsql += " and amount_prepaid>0";
prefromsql += " ";
var obj1 = cn.QueryFirstOrDefault<Models.Orders.dc_base_oms_order>(presql + prefromsql, sqlparam);
if (obj!=null && obj1 != null)
{
obj.amount_prepaid = obj1.amount_prepaid;
}
return obj; return obj;
} }
} }
......
...@@ -415,7 +415,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -415,7 +415,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
countM.amount_tax = Math.Round(countM.amount_tax, 2, MidpointRounding.AwayFromZero); countM.amount_tax = Math.Round(countM.amount_tax, 2, MidpointRounding.AwayFromZero);
countM.amount_total = Math.Round(countM.amount_total, 2, MidpointRounding.AwayFromZero); countM.amount_total = Math.Round(countM.amount_total, 2, MidpointRounding.AwayFromZero);
countM.cost_estimate_logistics = Math.Round(countM.cost_estimate_logistics, 2, MidpointRounding.AwayFromZero); //countM.cost_estimate_logistics = Math.Round(countM.cost_estimate_logistics, 2, MidpointRounding.AwayFromZero);
countM.cost_fba_fee = Math.Round(countM.cost_fba_fee, 2, MidpointRounding.AwayFromZero); countM.cost_fba_fee = Math.Round(countM.cost_fba_fee, 2, MidpointRounding.AwayFromZero);
countM.cost_first = Math.Round(countM.cost_first, 2, MidpointRounding.AwayFromZero); countM.cost_first = Math.Round(countM.cost_first, 2, MidpointRounding.AwayFromZero);
countM.cost_package = Math.Round(countM.cost_package, 2, MidpointRounding.AwayFromZero); countM.cost_package = Math.Round(countM.cost_package, 2, MidpointRounding.AwayFromZero);
...@@ -571,44 +571,42 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -571,44 +571,42 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
if (result.Count > 0) if (result.Count > 0)
{ {
var m = new Models.Orders.mPlatformProfit var m = new Models.Orders.dc_base_oms_sku
{ {
platform = "总计", platform_type = "总计",
ordercount = result.Sum(a => a.ordercount), order_count = result.Sum(a => a.order_count),
saleamount = result.Sum(a => a.saleamount), amount_sales = result.Sum(a => a.amount_sales),
customerprice = result.Sum(a => a.customerprice) / result.Count, customerprice = result.Sum(a => a.customerprice) / result.Count,
platformfee = result.Sum(a => a.platformfee), cost_platform_fee = result.Sum(a => a.cost_platform_fee),
profit = result.Sum(a => a.profit), profit_total = result.Sum(a => a.profit_total),
profitrate = result.Sum(a => a.profit) / result.Sum(a => a.saleamount), profit_rate = result.Sum(a => a.amount_sales)>0? result.Sum(a => a.amount_sales) / result.Sum(a => a.amount_sales):0,
returnamount = result.Sum(a => a.returnamount), amount_refund = result.Sum(a => a.amount_refund),
returnamountrate = result.Sum(a => a.returnamount)/ result.Sum(a => a.saleamount), amount_refund_rate = result.Sum(a => a.amount_sales) > 0 ? (result.Sum(a => a.amount_refund) / result.Sum(a => a.amount_sales)*100):0,
cost_first = result.Sum(a => a.cost_first), cost_first = result.Sum(a => a.cost_first),
cost_handle_bailun = result.Sum(a => a.cost_handle_bailun), cost_handle_bailun = result.Sum(a => a.cost_handle_bailun),
cost_handle_platform = result.Sum(a => a.cost_handle_platform), cost_handle_platform = result.Sum(a => a.cost_handle_platform),
cost_tail = result.Sum(a => a.cost_tail), cost_tail = result.Sum(a => a.cost_tail),
amount_prepaid = result.Sum(a=>a.amount_prepaid), amount_prepaid = result.Sum(a=>a.amount_prepaid),
}; };
result.Add(m); result.Add(m);
} }
var list = result.Select(p => new { var list = result.Select(p => new {
p.platform, p.platform_type,
customerprice = p.customerprice > 0 ? p.customerprice.ToString("N2") : "0", customerprice = p.customerprice > 0 ? p.customerprice.ToString("N2") : "0",
p.ordercount, p.order_count,
platformfee = p.platformfee > 0 ? p.platformfee.ToString("N2") : "0", cost_platform_fee = p.cost_platform_fee > 0 ? p.cost_platform_fee.ToString("N2") : "0",
profit = p.profit > 0 ? p.profit.ToString("N2") : "0", profit_total = p.profit_total.ToString("N2"),
profitrate = p.profitrate > 0 ? (p.profitrate * 100).ToString("N2") : "0", profit_rate = (p.amount_sales>0?p.profit_total*100/ p.amount_sales:0).ToString("N2"),
returnamount = p.returnamount > 0 ? p.returnamount.ToString("N2") : "0", amount_refund = p.amount_refund.ToString("N2"),
returnamountrate = p.returnamountrate.ToString("N4"), amount_refund_rate = p.amount_sales>0? (p.amount_refund*100/ p.amount_sales).ToString("N4"):"0",
saleamount = p.saleamount > 0 ? p.saleamount.ToString("N2") : "0", amount_sales = p.amount_sales.ToString("N2"),
cost_first = p.cost_first > 0 ? p.cost_first.ToString("N2") : "0", cost_first = p.cost_first.ToString("N2"),
cost_handle_bailun = p.cost_handle_bailun > 0 ? p.cost_handle_bailun.ToString("N2") : "0", cost_handle_bailun = p.cost_handle_bailun.ToString("N2"),
cost_handle_platform = p.cost_handle_platform > 0 ? p.cost_handle_platform.ToString("N2") : "0", cost_handle_platform = p.cost_handle_platform.ToString("N2"),
cost_tail = p.cost_tail > 0 ? p.cost_tail.ToString("N2") : "0", cost_tail = p.cost_tail.ToString("N2"),
amount_prepaid = p.amount_prepaid.ToString("N2"), amount_prepaid = p.amount_prepaid.ToString("N2"),
}); });
...@@ -657,6 +655,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -657,6 +655,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
countM.returnamount = Math.Round(countM.returnamount, 2, MidpointRounding.AwayFromZero); countM.returnamount = Math.Round(countM.returnamount, 2, MidpointRounding.AwayFromZero);
countM.saleamount = Math.Round(countM.saleamount, 2, MidpointRounding.AwayFromZero); countM.saleamount = Math.Round(countM.saleamount, 2, MidpointRounding.AwayFromZero);
countM.amount_prepaid = Math.Round(countM.amount_prepaid, 2, MidpointRounding.AwayFromZero); countM.amount_prepaid = Math.Round(countM.amount_prepaid, 2, MidpointRounding.AwayFromZero);
countM.returnamountrate = Math.Round(countM.returnamount*100 / countM.saleamount, 2, MidpointRounding.AwayFromZero);
countM.profitrate = Math.Round(countM.profit*100 / countM.saleamount, 2, MidpointRounding.AwayFromZero);
var list = result.Select(p => new { var list = result.Select(p => new {
p.platform, p.platform,
...@@ -677,7 +677,23 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -677,7 +677,23 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
amount_prepaid = p.amount_prepaid>0?p.amount_prepaid.ToString("N2"):"0", amount_prepaid = p.amount_prepaid>0?p.amount_prepaid.ToString("N2"):"0",
}); });
return JsonConvert.SerializeObject(new { total=total,rows = list,count_row=countM}); return JsonConvert.SerializeObject(new { total = total, rows = list, count_row = new {
countM.website,
cost_first = countM.cost_first.ToString("N2"),
cost_handle_bailun = countM.cost_handle_bailun.ToString("N2"),
cost_handle_platform = countM.cost_handle_platform.ToString("N2"),
cost_tail = countM.cost_tail.ToString("N2"),
customerprice = countM.customerprice.ToString("N2"),
platformfee = countM.platformfee.ToString("N2"),
profit = countM.profit.ToString("N2"),
returnamount = countM.returnamount.ToString("N2"),
saleamount = countM.saleamount.ToString("N2"),
amount_prepaid = countM.amount_prepaid.ToString("N2"),
returnamountrate = countM.returnamountrate.ToString("N2"),
profitrate = countM.profitrate.ToString("N2"),
countM.ordercount,
}
});
} }
...@@ -889,7 +905,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -889,7 +905,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
var countM = services.ListEbayStatisticsCount(website, selleraccount, start, end, warehousetype, warehousecode); var countM = services.ListEbayStatisticsCount(website, selleraccount, start, end, warehousetype, warehousecode);
countM.website = "总计:"; countM.seller_account = "总计:";
countM.amount_product = Math.Round(countM.amount_product, 2, MidpointRounding.AwayFromZero); countM.amount_product = Math.Round(countM.amount_product, 2, MidpointRounding.AwayFromZero);
countM.cost_product = Math.Round(countM.cost_product, 2, MidpointRounding.AwayFromZero); countM.cost_product = Math.Round(countM.cost_product, 2, MidpointRounding.AwayFromZero);
countM.cost_platform_fee = Math.Round(countM.cost_platform_fee, 2, MidpointRounding.AwayFromZero); countM.cost_platform_fee = Math.Round(countM.cost_platform_fee, 2, MidpointRounding.AwayFromZero);
...@@ -903,7 +919,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -903,7 +919,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
countM.amount_prepaid = Math.Round(countM.amount_prepaid, 2, MidpointRounding.AwayFromZero); countM.amount_prepaid = Math.Round(countM.amount_prepaid, 2, MidpointRounding.AwayFromZero);
countM.profit_total = Math.Round(countM.profit_total, 2, MidpointRounding.AwayFromZero); countM.profit_total = Math.Round(countM.profit_total, 2, MidpointRounding.AwayFromZero);
countM.profit_rate = countM.amount_product>0?Math.Round((countM.profit_total / countM.amount_product), 2, MidpointRounding.AwayFromZero):0; countM.profit_rate = countM.amount_product>0?Math.Round((countM.profit_total / countM.amount_product), 2, MidpointRounding.AwayFromZero):0;
countM.cost_tail = Math.Round(countM.cost_tail, 2, MidpointRounding.AwayFromZero);
countM.cost_handle_bailun = Math.Round(countM.cost_handle_bailun, 2, MidpointRounding.AwayFromZero);
var obj = list.Select(p => new var obj = list.Select(p => new
{ {
...@@ -925,6 +942,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -925,6 +942,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
amount_prepaid = p.amount_prepaid.ToString("N2"), amount_prepaid = p.amount_prepaid.ToString("N2"),
profit_total = p.profit_total.ToString("N2"), profit_total = p.profit_total.ToString("N2"),
profit_rate = (100 * p.profit_rate).ToString("N2"), profit_rate = (100 * p.profit_rate).ToString("N2"),
cost_tail = p.cost_tail.ToString("N2"),
cost_handle_bailun = p.cost_handle_bailun.ToString("N2"),
}); });
return JsonConvert.SerializeObject(new return JsonConvert.SerializeObject(new
...@@ -933,6 +952,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -933,6 +952,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
rows = obj, rows = obj,
count_row = new count_row = new
{ {
countM.platform_type,
countM.seller_account,
countM.website, countM.website,
amount_product = countM.amount_product.ToString("N2"), amount_product = countM.amount_product.ToString("N2"),
cost_product = countM.cost_product.ToString("N2"), cost_product = countM.cost_product.ToString("N2"),
...@@ -948,6 +969,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -948,6 +969,8 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
amount_prepaid = countM.amount_prepaid.ToString("N2"), amount_prepaid = countM.amount_prepaid.ToString("N2"),
profit_total = countM.profit_total.ToString("N2"), profit_total = countM.profit_total.ToString("N2"),
profit_rate = (100 * countM.profit_rate).ToString("N2"), profit_rate = (100 * countM.profit_rate).ToString("N2"),
cost_tail = countM.cost_tail.ToString("N2"),
cost_handle_bailun = countM.cost_handle_bailun.ToString("N2"),
} }
}); });
} }
......
...@@ -97,30 +97,30 @@ ...@@ -97,30 +97,30 @@
var columns = [ var columns = [
{ field: 'platform_type', title: '平台', width: '100', sortable: false }, { field: 'platform_type', title: '平台', width: '100', sortable: false },
{ {
field: 'seller_account', title: '销售帐号', width: '130', sortable: false, formatter: function (idx, data) { field: 'seller_account', title: '销售帐号', width: '130', sortable: false, iscount: true, formatter: function (idx, data) {
var str = '<p class="mules" title="' + data.seller_account + '">' + data.seller_account + '</p>'; var str = '<p class="mules" title="' + data.seller_account + '">' + data.seller_account + '</p>';
return str; return str;
} }
}, },
//{ field: 'website', title: '站点', width: '80', sortable: false, iscount: true }, //{ field: 'website', title: '站点', width: '80', sortable: false, iscount: true },
{ {
field: 'amount_product', title: '商品收入', width: '100', sortable: true, iscount: true, formatter: function (idx, data) { field: 'order_count', title: '订单数量', width: '100', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'商品收入\',\'amount_product\',1)">' + data.amount_product + '</span>'; return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'订单数量\',\'\',0)">' + data.order_count + '</span>';
} }
}, },
{ {
field: 'cost_product', title: '产品成本', width: '100', sortable: true, iscount: true, formatter: function (idx, data) { field: 'amount_product', title: '销售额', width: '100', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'产品成本\',\'cost_product\',1)">' + data.cost_product + '</span>'; return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'销售额\',\'amount_product\',1)">' + data.amount_product + '</span>';
} }
}, },
{ {
field: 'cost_platform_fee', title: '平台佣金费', width: '110', sortable: true, iscount: true, formatter: function (idx, data) { field: 'cost_product', title: '产品成本', width: '100', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'平台佣金费\',\'cost_platform_fee\',1)">' + data.cost_platform_fee + '</span>'; return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'产品成本\',\'cost_product\',1)">' + data.cost_product + '</span>';
} }
}, },
{ {
field: 'cost_package', title: '包装费用', width: '110', sortable: true, iscount: true, formatter: function (idx, data) { field: 'cost_platform_fee', title: '平台费', width: '110', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'包装费用\',\'cost_package\',1)">' + data.cost_package + '</span>'; return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'平台费\',\'cost_platform_fee\',1)">' + data.cost_platform_fee + '</span>';
} }
}, },
{ {
...@@ -134,19 +134,19 @@ ...@@ -134,19 +134,19 @@
} }
}, },
{ {
field: 'order_count', title: '销售数量', width: '100', sortable: true, iscount: true, formatter: function (idx, data) { field: 'cost_tail', title: '尾程费', width: '100', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account+ '\',\'订单数\',\'\',0)">' + data.order_count + '</span>'; return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'尾程费\',\'cost_tail\',1)">' + data.cost_tail + '</span>';
} }
}, },
{ field: 'loss_withdrawal', title: '提现损耗', width: '100', sortable: false, iscount: true },
{ {
field: 'cost_total', title: '总支出', width: '110', sortable: true, iscount: true, formatter: function (idx, data) { field: 'cost_handle_bailun', title: '处理费', width: '100', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'总支出\',\'cost_total\',1)">' + data.cost_total + '</span>'; return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'处理费\',\'cost_first\',1)">' + data.cost_handle_bailun + '</span>';
} }
}, },
{ field: 'loss_withdrawal', title: '提现损耗', width: '100', sortable: false, iscount: true },
{ {
field: 'cost_shipping', title: '实际物流费', width: '110', sortable: true, iscount: true, formatter: function (idx, data) { field: 'cost_total', title: '总支出', width: '110', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'实际物流费\',\'cost_shipping\',1)">' + data.cost_shipping + '</span>'; return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'总支出\',\'cost_total\',1)">' + data.cost_total + '</span>';
} }
}, },
{ {
......
...@@ -88,7 +88,6 @@ ...@@ -88,7 +88,6 @@
{ field: 'platform_type', title: '平台', width: '100' }, { field: 'platform_type', title: '平台', width: '100' },
{ field: 'website', title: '站点', width: '90' }, { field: 'website', title: '站点', width: '90' },
{ field: 'seller_account', title: '销售帐号', width: '110', sortable: false }, { field: 'seller_account', title: '销售帐号', width: '110', sortable: false },
//{ field: 'order_currency', title: '订单币种', width: '110', sortable: false, iscount: true },
{ {
field: 'amount_total', title: '总收入', width: '90', sortable: true, iscount: true field: 'amount_total', title: '总收入', width: '90', sortable: true, iscount: true
}, },
......
...@@ -92,20 +92,20 @@ ...@@ -92,20 +92,20 @@
if (result && result.length > 0) { if (result && result.length > 0) {
$('#tb').html(''); $('#tb').html('');
for (var i = 0; i < result.length; i++) { for (var i = 0; i < result.length; i++) {
var s = '<tr><td class="platform"><a href="javascript:;" onclick="ShowWebsite(\'' + result[i].platform+'\');">' + result[i].platform + '</a></td>'; var s = '<tr><td class="platform"><a href="javascript:;" onclick="ShowWebsite(\'' + result[i].platform_type + '\');">' + result[i].platform_type + '</a></td>';
s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform + '\',\'订单数\',\'\',0)">' + result[i].ordercount + '</td>'; s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'订单数\',\'\',0)">' + result[i].order_count + '</td>';
s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform + '\',\'销售额\',\'amount_total\',1)">' + result[i].saleamount + '</td>'; s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'销售额\',\'amount_sales\',1)">' + result[i].amount_sales + '</td>';
s += '<td>' + result[i].customerprice + '</td>'; s += '<td>' + result[i].customerprice + '</td>';
s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform + '\',\'平台费用\',\'cost_platform_fee\',1)">' + result[i].platformfee + '</td>'; s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'平台费用\',\'cost_platform_fee\',1)">' + result[i].cost_platform_fee + '</td>';
s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform + '\',\'头程费\',\'cost_first\',1)">' + result[i].cost_first + '</td>'; s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'头程费\',\'cost_first\',1)">' + result[i].cost_first + '</td>';
s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform + '\',\'尾程费\',\'cost_tail\',1)">' + result[i].cost_tail + '</td>'; s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'尾程费\',\'cost_tail\',1)">' + result[i].cost_tail + '</td>';
s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform + '\',\'处理费(百伦)\',\'cost_handle_bailun\',1)">' + result[i].cost_handle_bailun + '</td>'; s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'处理费(百伦)\',\'cost_handle_bailun\',1)">' + result[i].cost_handle_bailun + '</td>';
s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform + '\',\'平台操作费\',\'cost_handle_platform\',1)">' + result[i].cost_handle_platform + '</td>'; s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'平台操作费\',\'cost_handle_platform\',1)">' + result[i].cost_handle_platform + '</td>';
s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform + '\',\'预收款\',\'amount_prepaid\',1)">' + result[i].amount_prepaid + '</td>'; s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'预收款\',\'amount_prepaid\',1)">' + result[i].amount_prepaid + '</td>';
s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform + '\',\'利润\',\'profit_total\',1)">' + result[i].profit + '</td>'; s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'利润\',\'profit_total\',1)">' + result[i].profit_total + '</td>';
s += '<td>' + result[i].profitrate + '</td>'; s += '<td>' + result[i].profit_rate + '</td>';
s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform + '\',\'退款金额\',\'amount_refund\',1)">' + result[i].returnamount + '</td>'; s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'退款金额\',\'amount_refund\',1)">' + result[i].amount_refund + '</td>';
s += '<td>' + result[i].returnamountrate + '</td>'; s += '<td>' + result[i].amount_refund_rate + '</td>';
$('#tb').append(s); $('#tb').append(s);
} }
......
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
} }
}, },
{ {
field: 'profitrate', title: '利润率%', width: '110', sortable: true, formatter: function (idx, data) { field: 'profitrate', title: '利润率%', width: '110', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span>' + data.profitrate + '</span>'; return '<span>' + data.profitrate + '</span>';
} }
}, },
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
} }
}, },
{ {
field: 'returnamountrate', title: '退款率%', width: '100', sortable: true field: 'returnamountrate', title: '退款率%', width: '100', sortable: true, iscount: true
, formatter: function (idx, data) { , formatter: function (idx, data) {
return '<span>' + data.returnamountrate + '</span>'; return '<span>' + data.returnamountrate + '</span>';
} }
......
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