Commit 68bfb138 by guanzhenshan

修改平台利润统计的需求

parent 8e16f6e0
......@@ -213,6 +213,11 @@ namespace Bailun.DC.Models.Orders
public decimal amount_refund { get; set; }
/// <summary>
/// 预付款-收钱没发货
/// </summary>
public decimal amount_prepaid { get; set; }
/// <summary>
/// 总支出费用-人民币
/// </summary>
public decimal cost_total { get; set; }
......@@ -268,6 +273,22 @@ namespace Bailun.DC.Models.Orders
public decimal cost_first { get; set; }
/// <summary>
/// 处理费-百伦收取-人民币
/// </summary>
public decimal cost_handle_bailun { get; set; }
/// <summary>
/// 处理费-平台收取-人民币
/// </summary>
public decimal cost_handle_platform { get; set; }
/// <summary>
/// 尾程费-人民币
/// </summary>
public decimal cost_tail { get; set; }
/// <summary>
/// 利润=总收入-总支出
/// </summary>
public decimal profit_total { get; set; }
......
......@@ -15,6 +15,11 @@ namespace Bailun.DC.Models.Orders
public string platform { get; set; }
/// <summary>
/// 站点
/// </summary>
public string website { get; set; }
/// <summary>
/// 订单数
/// </summary>
public int ordercount { get; set; }
......@@ -54,5 +59,25 @@ namespace Bailun.DC.Models.Orders
/// </summary>
public decimal returnamountrate { get; set; }
/// <summary>
/// 头程费
/// </summary>
public decimal cost_first { get; set; }
/// <summary>
/// 尾程费
/// </summary>
public decimal cost_tail { get; set; }
/// <summary>
/// 处理费(百伦)
/// </summary>
public decimal cost_handle_bailun { get; set; }
/// <summary>
/// 处理费(平台)
/// </summary>
public decimal cost_handle_platform { get; set; }
}
}
......@@ -383,6 +383,12 @@ namespace Bailun.DC.Services
{
var m = cn.QueryFirstOrDefault<dc_platform_balance>($"select * from dc_platform_balance where platformcode='{item.platformcode}' and currency='{item.currency}' and delstatus=0 order by day desc limit 1");
if (m.platformcode.ToUpper() != "EBAY" && m.platformcode.ToUpper() != "ALIEXPRESS" && m.amount==item.amount)
{
item.amount = m.amount + m.amount_sales - m.withdraw_amount;
item.amount_rmb = item.amount * item.exchangerate;
}
if (m != null)
{
item.before_balance = m.userable_amount + m.amount_sales - m.withdraw_amount;
......
......@@ -796,7 +796,7 @@ namespace Bailun.DC.Services
public List<Models.Orders.mPlatformProfit> ListPlatformProfit(string platform, DateTime? start, DateTime? end)
{
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(amount_total*seller_order_exchange_rate)-sum(cost_total)-sum(cost_shipping)) profit,((sum(amount_total*seller_order_exchange_rate)-sum(cost_total)-sum(cost_shipping))/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 from dc_base_oms_order where bailun_order_status!='Canceled'";
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(amount_total*seller_order_exchange_rate)-sum(cost_total)-sum(cost_shipping)) profit,((sum(amount_total*seller_order_exchange_rate)-sum(cost_total)-sum(cost_shipping))/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'";
if (!string.IsNullOrWhiteSpace(platform))
{
......@@ -830,6 +830,212 @@ namespace Bailun.DC.Services
}
/// <summary>
/// 获取平台利润 按站点
/// </summary>
/// <param name="platform"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <param name="parameter"></param>
/// <param name="total"></param>
/// <returns></returns>
public List<Models.Orders.mPlatformProfit> ListPlatformProfitByWebSite(string platform, DateTime? start, DateTime? end, BtTableParameter parameter, ref int total)
{
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(amount_total*seller_order_exchange_rate)-sum(cost_total)-sum(cost_shipping)) profit,((sum(amount_total*seller_order_exchange_rate)-sum(cost_total)-sum(cost_shipping))/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'";
if (!string.IsNullOrWhiteSpace(platform))
{
sql += " and platform_type=@platform_type";
sqlparam.Add("platform_type", platform);
}
if (start.HasValue)
{
sql += " and paid_time>=@paid_time_start";
sqlparam.Add("paid_time_start", start.Value);
}
if (end.HasValue)
{
sql += " and paid_time<@paid_time_end";
sqlparam.Add("paid_time_end", end.Value.AddDays(1));
}
sql += " group by website,platform_type";
if (!string.IsNullOrEmpty(parameter.sort))
{
sql += " order by " + parameter.sort + " " + parameter.order;
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
var obj = cn.Page<Models.Orders.mPlatformProfit>(parameter.pageIndex,parameter.limit,sql,ref total,sqlparam);
return obj.AsList();
}
}
/// <summary>
/// 获取平台利润 按站点 统计
/// </summary>
/// <param name="platform"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <param name="parameter"></param>
/// <param name="total"></param>
/// <returns></returns>
public Models.Orders.mPlatformProfit ListPlatformProfitByWebSiteCount(string platform, DateTime? start, DateTime? end, BtTableParameter parameter, ref int total)
{
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(amount_total*seller_order_exchange_rate)-sum(cost_total)-sum(cost_shipping)) profit,((sum(amount_total*seller_order_exchange_rate)-sum(cost_total)-sum(cost_shipping))/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'";
if (!string.IsNullOrWhiteSpace(platform))
{
sql += " and platform_type=@platform_type";
sqlparam.Add("platform_type", platform);
}
if (start.HasValue)
{
sql += " and paid_time>=@paid_time_start";
sqlparam.Add("paid_time_start", start.Value);
}
if (end.HasValue)
{
sql += " and paid_time<@paid_time_end";
sqlparam.Add("paid_time_end", end.Value.AddDays(1));
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
var obj = cn.QueryFirst<Models.Orders.mPlatformProfit>(sql, sqlparam);
return obj;
}
}
/// <summary>
/// 利润统计订单明细
/// </summary>
/// <param name="parameter">分页信息</param>
/// <param name="platform">平台信息</param>
/// <param name="website">站点信息</param>
/// <param name="start">付款开始时间</param>
/// <param name="end">付款结束时间</param>
/// <param name="orderno">百伦单号</param>
/// <param name="total">符合条件的记录数</param>
/// <returns></returns>
public List<Models.Orders.dc_base_oms_order> ListPlatformProfitOrders(BtTableParameter parameter, string platform, string website, DateTime? start, DateTime? end, string orderno, ref int total)
{
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 from dc_base_oms_order where bailun_order_status!='Canceled' ";
if (!string.IsNullOrWhiteSpace(platform))
{
sql += " and platform_type=@platform_type";
sqlparam.Add("platform_type", platform);
}
if (start.HasValue)
{
sql += " and paid_time>=@paid_time_start";
sqlparam.Add("paid_time_start", start.Value);
}
if (end.HasValue)
{
sql += " and paid_time<@paid_time_end";
sqlparam.Add("paid_time_end", end.Value.AddDays(1));
}
if (!string.IsNullOrEmpty(website))
{
sql += " and website=@website";
sqlparam.Add("website", website);
}
if (!string.IsNullOrEmpty(orderno))
{
sql += " and bailun_order_id=@bailun_order_id";
sqlparam.Add("bailun_order_id", orderno);
}
if (!string.IsNullOrEmpty(parameter.sort))
{
sql += " order by "+parameter.sort+" "+parameter.order;
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
var obj = cn.Page<Models.Orders.dc_base_oms_order>(parameter.pageIndex, parameter.limit, sql, ref total, sqlparam);
return obj.AsList();
}
}
/// <summary>
/// 利润统计订单明细 统计
/// </summary>
/// <param name="platform"></param>
/// <param name="website"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <param name="orderno"></param>
/// <returns></returns>
public Models.Orders.dc_base_oms_order ListPlatformProfitOrdersCount(string platform, string website, DateTime? start, DateTime? end, string orderno)
{
var sqlparam = new DynamicParameters();
var sql = "select sum(amount_total*seller_order_exchange_rate) amount_total,sum(amount_product*seller_order_exchange_rate) amount_product,sum(amount_shipping*seller_order_exchange_rate) amount_shipping,sum(amount_tax*seller_order_exchange_rate) amount_tax,sum(amount_adjustment*seller_order_exchange_rate) amount_adjustment,sum(amount_gift_wrap*seller_order_exchange_rate) amount_gift_wrap,sum(amount_refund*seller_order_exchange_rate) amount_refund,sum(cost_total) cost_total,sum(cost_promotion*seller_order_exchange_rate) cost_promotion,sum(cost_platform_fee*seller_order_exchange_rate) cost_platform_fee,sum(cost_product) cost_product,sum(cost_shipping) cost_shipping,sum(cost_package) cost_package,sum(cost_fba_fee*seller_order_exchange_rate) cost_fba_fee,sum(cost_paypal_fee*seller_order_exchange_rate) cost_paypal_fee,sum(cost_refund_commisson*seller_order_exchange_rate) cost_refund_commisson,sum(cost_handle_bailun) cost_handle_bailun,sum(cost_handle_platform) cost_handle_platform,sum(cost_tail) cost_tail,sum(cost_first) cost_first,sum(profit_total) profit_total from dc_base_oms_order where bailun_order_status!='Canceled' ";
if (!string.IsNullOrWhiteSpace(platform))
{
sql += " and platform_type=@platform_type";
sqlparam.Add("platform_type", platform);
}
if (start.HasValue)
{
sql += " and paid_time>=@paid_time_start";
sqlparam.Add("paid_time_start", start.Value);
}
if (end.HasValue)
{
sql += " and paid_time<@paid_time_end";
sqlparam.Add("paid_time_end", end.Value.AddDays(1));
}
if (!string.IsNullOrEmpty(website))
{
sql += " and website=@website";
sqlparam.Add("website", website);
}
if (!string.IsNullOrEmpty(orderno))
{
sql += " and bailun_order_id=@bailun_order_id";
sqlparam.Add("bailun_order_id", orderno);
}
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
var obj = cn.QueryFirst<Models.Orders.dc_base_oms_order>(sql,sqlparam);
return obj;
}
}
/// <summary>
/// 销售订单
/// </summary>
/// <param name="parameter">分页信息</param>
......
......@@ -429,12 +429,16 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
platform = "总计",
ordercount = result.Sum(a => a.ordercount),
saleamount = result.Sum(a => a.saleamount),
customerprice = result.Sum(a => a.customerprice),
platformfee = result.Sum(a=>a.platformfee),
profit = result.Sum(a=>a.profit),
customerprice = result.Sum(a => a.customerprice)/result.Count,
platformfee = result.Sum(a => a.platformfee),
profit = result.Sum(a => a.profit),
profitrate = 0,
returnamount = result.Sum(a=>a.returnamount),
returnamountrate = 0
returnamount = result.Sum(a => a.returnamount),
returnamountrate = 0,
cost_first = result.Sum(a => a.cost_first),
cost_handle_bailun = result.Sum(a => a.cost_handle_bailun),
cost_handle_platform = result.Sum(a => a.cost_handle_platform),
cost_tail = result.Sum(a => a.cost_tail),
};
result.Add(m);
......@@ -449,11 +453,178 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
returnamount= p.returnamount>0? p.returnamount.ToString("###,###.##"):"0",
returnamountrate = p.returnamountrate>0?(p.returnamountrate*100).ToString("###,###.##"):"0",
saleamount = p.saleamount>0? p.saleamount.ToString("###,###.##"):"0",
cost_first = p.cost_first>0?p.cost_first.ToString("###,###.##"):"0",
cost_handle_bailun = p.cost_handle_bailun>0?p.cost_handle_bailun.ToString("###,###.##"):"0",
cost_handle_platform = p.cost_handle_platform>0?p.cost_handle_platform.ToString("###,###.##"):"0",
cost_tail = p.cost_tail>0?p.cost_tail.ToString("###,###.##"):"0",
});
return Json(list);
}
/// <summary>
/// 平台利润,按站点
/// </summary>
/// <param name="platform">平台编码</param>
/// <param name="start">开始时间</param>
/// <param name="end">结束时间</param>
/// <returns></returns>
public ActionResult PlatformProfitCountByWebSite(string platform,DateTime? start,DateTime? end)
{
ViewBag.platform = platform;
ViewBag.start = start.HasValue?start.Value.ToString("yyyy-MM-dd"):"";
ViewBag.end = end.HasValue?end.Value.ToString("yyyy-MM-dd"):"";
return View();
}
/// <summary>
/// 平台利润,按站点
/// </summary>
/// <param name="platform"></param>
/// <param name="start"></param>
/// <param name="end"></param>
/// <param name="parameter"></param>
/// <returns></returns>
public string PlatformProfitCountByWebSiteJson(string platform, DateTime? start, DateTime? end,BtTableParameter parameter)
{
var total = 0;
var service = new Services.OrdersServices();
var result = service.ListPlatformProfitByWebSite(platform, start, end,parameter,ref total);
var countM = service.ListPlatformProfitByWebSiteCount(platform, start, end, parameter, ref total);
countM.website = "合计:";
countM.cost_first = Math.Round(countM.cost_first, 2, MidpointRounding.AwayFromZero);
countM.cost_handle_bailun = Math.Round(countM.cost_handle_bailun, 2, MidpointRounding.AwayFromZero);
countM.cost_handle_platform = Math.Round(countM.cost_handle_platform, 2, MidpointRounding.AwayFromZero);
countM.cost_tail = Math.Round(countM.cost_tail, 2, MidpointRounding.AwayFromZero);
countM.customerprice = Math.Round(countM.customerprice, 2, MidpointRounding.AwayFromZero);
countM.platformfee = Math.Round(countM.platformfee, 2, MidpointRounding.AwayFromZero);
countM.profit = Math.Round(countM.profit, 2, MidpointRounding.AwayFromZero);
countM.returnamount = Math.Round(countM.returnamount, 2, MidpointRounding.AwayFromZero);
countM.saleamount = Math.Round(countM.saleamount, 2, MidpointRounding.AwayFromZero);
var list = result.Select(p => new {
p.platform,
customerprice = p.customerprice > 0 ? p.customerprice.ToString("###,###.##") : "0",
p.ordercount,
platformfee = p.platformfee > 0 ? p.platformfee.ToString("###,###.##") : "0",
profit = p.profit > 0 ? p.profit.ToString("###,###.##") : "0",
profitrate = p.profitrate > 0 ? (p.profitrate * 100).ToString("###,###.##") : "0",
returnamount = p.returnamount > 0 ? p.returnamount.ToString("###,###.##") : "0",
returnamountrate = p.returnamountrate > 0 ? (p.returnamountrate * 100).ToString("###,###.##") : "0",
saleamount = p.saleamount > 0 ? p.saleamount.ToString("###,###.##") : "0",
cost_first = p.cost_first > 0 ? p.cost_first.ToString("###,###.##") : "0",
cost_handle_bailun = p.cost_handle_bailun > 0 ? p.cost_handle_bailun.ToString("###,###.##") : "0",
cost_handle_platform = p.cost_handle_platform > 0 ? p.cost_handle_platform.ToString("###,###.##") : "0",
cost_tail = p.cost_tail > 0 ? p.cost_tail.ToString("###,###.##") : "0",
p.website,
});
return JsonConvert.SerializeObject(new { total=total,rows = list,count_row=countM});
}
/// <summary>
/// 订单明细列表
/// </summary>
/// <returns></returns>
public ActionResult ListOrderDetail(string platform, string website, DateTime? start, DateTime? end, string orderno)
{
ViewBag.platform = platform;
ViewBag.website = website;
ViewBag.start = start.HasValue ? start.Value.ToString("yyyy-MM-dd") : "";
ViewBag.end = end.HasValue ? end.Value.ToString("yyyy-MM-dd") : "";
ViewBag.orderno = orderno;
return View();
}
/// <summary>
/// 订单明细列表 数据
/// </summary>
/// <param name="parameter">分页信息</param>
/// <param name="platform">平台类型</param>
/// <param name="website">站点</param>
/// <param name="start">付款开始时间</param>
/// <param name="end">付款结束时间</param>
/// <param name="orderno">百伦订单号</param>
/// <returns></returns>
public string ListOrderDetailJson(BtTableParameter parameter,string platform,string website,DateTime? start,DateTime? end,string orderno)
{
var total = 0;
var service = new Services.OrdersServices();
var obj = service.ListPlatformProfitOrders(parameter, platform, website, start, end, orderno, ref total);
var countM = service.ListPlatformProfitOrdersCount(platform, website, start, end, orderno);
countM.bailun_order_id = "总计";
countM.amount_total = Math.Round((countM.amount_total), 2, MidpointRounding.AwayFromZero);
countM.amount_product = Math.Round((countM.amount_product), 2, MidpointRounding.AwayFromZero);
countM.amount_shipping = Math.Round((countM.amount_shipping), 2, MidpointRounding.AwayFromZero);
countM.amount_tax = Math.Round((countM.amount_tax), 2, MidpointRounding.AwayFromZero);
countM.amount_adjustment = Math.Round((countM.amount_adjustment), 2, MidpointRounding.AwayFromZero);
countM.amount_gift_wrap = Math.Round((countM.amount_gift_wrap), 2, MidpointRounding.AwayFromZero);
countM.amount_refund = Math.Round((countM.amount_refund), 2, MidpointRounding.AwayFromZero);
countM.cost_total = Math.Round(countM.cost_total, 2, MidpointRounding.AwayFromZero);
countM.cost_promotion = Math.Round(countM.cost_promotion, 2, MidpointRounding.AwayFromZero);
countM.cost_platform_fee = Math.Round(countM.cost_platform_fee, 2, MidpointRounding.AwayFromZero);
countM.cost_product = Math.Round(countM.cost_product, 2, MidpointRounding.AwayFromZero);
countM.cost_shipping = Math.Round(countM.cost_shipping, 2, MidpointRounding.AwayFromZero);
countM.cost_package = Math.Round(countM.cost_package, 2, MidpointRounding.AwayFromZero);
countM.cost_fba_fee = Math.Round(countM.cost_fba_fee, 2, MidpointRounding.AwayFromZero);
countM.cost_paypal_fee = Math.Round(countM.cost_paypal_fee, 2, MidpointRounding.AwayFromZero);
countM.cost_refund_commisson = Math.Round(countM.cost_refund_commisson, 2, MidpointRounding.AwayFromZero);
countM.cost_handle_bailun = Math.Round(countM.cost_handle_bailun, 2, MidpointRounding.AwayFromZero);
countM.cost_handle_platform = Math.Round(countM.cost_handle_platform, 2, MidpointRounding.AwayFromZero);
countM.cost_first = Math.Round(countM.cost_first, 2, MidpointRounding.AwayFromZero);
countM.cost_tail = Math.Round(countM.cost_tail, 2, MidpointRounding.AwayFromZero);
countM.profit_total = Math.Round(countM.profit_total, 2, MidpointRounding.AwayFromZero);
var list = obj.Select(p => new
{
p.origin_order_id,
p.bailun_order_id,
p.platform_type,
p.website,
p.seller_account,
p.order_currency,
amount_total = Math.Round((p.amount_total * p.seller_order_exchange_rate),2,MidpointRounding.AwayFromZero),
amount_product = Math.Round((p.amount_product * p.seller_order_exchange_rate),2,MidpointRounding.AwayFromZero),
amount_shipping = Math.Round((p.amount_shipping * p.seller_order_exchange_rate),2,MidpointRounding.AwayFromZero),
amount_tax = Math.Round((p.amount_tax * p.seller_order_exchange_rate),2,MidpointRounding.AwayFromZero),
amount_adjustment = Math.Round((p.amount_adjustment * p.seller_order_exchange_rate),2,MidpointRounding.AwayFromZero),
amount_gift_wrap = Math.Round((p.amount_gift_wrap * p.seller_order_exchange_rate),2,MidpointRounding.AwayFromZero),
amount_refund = Math.Round((p.amount_refund * p.seller_order_exchange_rate),2,MidpointRounding.AwayFromZero),
cost_total = Math.Round(p.cost_total,2,MidpointRounding.AwayFromZero),
cost_promotion = Math.Round(p.cost_promotion * p.seller_order_exchange_rate,2,MidpointRounding.AwayFromZero),
cost_platform_fee = Math.Round(p.cost_platform_fee * p.seller_order_exchange_rate,2,MidpointRounding.AwayFromZero),
cost_product = Math.Round(p.cost_product,2,MidpointRounding.AwayFromZero),
cost_shipping = Math.Round(p.cost_shipping,2,MidpointRounding.AwayFromZero),
cost_package = Math.Round(p.cost_package,2,MidpointRounding.AwayFromZero),
cost_fba_fee = Math.Round(p.cost_fba_fee * p.seller_order_exchange_rate,2,MidpointRounding.AwayFromZero),
cost_paypal_fee = Math.Round(p.cost_paypal_fee*p.seller_order_exchange_rate,2,MidpointRounding.AwayFromZero),
cost_refund_commisson = Math.Round(p.cost_refund_commisson*p.seller_order_exchange_rate,2,MidpointRounding.AwayFromZero),
cost_handle_bailun = Math.Round(p.cost_handle_bailun,2,MidpointRounding.AwayFromZero),
cost_handle_platform = Math.Round(p.cost_handle_platform,2,MidpointRounding.AwayFromZero),
cost_first = Math.Round(p.cost_first,2,MidpointRounding.AwayFromZero),
cost_tail = Math.Round(p.cost_tail,2,MidpointRounding.AwayFromZero),
profit_total = Math.Round(p.profit_total,2,MidpointRounding.AwayFromZero),
profit_rate = Math.Round(p.profit_rate*100,2,MidpointRounding.AwayFromZero),
create_time = p.create_time.ToString("yyyy-MM-dd HH:mm:ss"),
paid_time = p.paid_time.ToString("yyyy-MM-dd HH:mm:ss"),
});
return JsonConvert.SerializeObject(new { total=total,rows = list,count_row = countM});
return Json(list);
}
/// <summary>
......

@{
ViewData["Title"] = "订单明细";
Layout = "~/Pages/Shared/_MainLayout.cshtml";
ViewBag.Nav = new string[] { "订单明细" };
}
<div class="row">
<div class="col-sm-12">
<div class="ibox-content m-b-sm border-bottom">
<form id="toolbar">
<div class="form-inline" style="line-height:40px;">
<div class="form-group">
<label>平台类型:</label>
<select id="platform" name="platform" class="form-control">
<option value="">选择平台</option>
</select>
</div>
<div class="form-group">
<label>站点:</label>
<select id="website" name="website" class="form-control">
<option value="">选择站点</option>
</select>
</div>
<div class="form-group">
<label>付款时间</label>
<input id="start" name="start" type="text" class="form-control" style="width:130px;" value="@(ViewBag.start)" />
<span>至</span>
<input id="end" name="end" type="text" class="form-control" style="width:130px;" value="@(ViewBag.end)" />
</div>
<div class="form-group">
<label>&nbsp;</label>
<input id="orderno" name="orderno" class="form-control" type="text" style="width:150px" value="@(ViewBag.orderno)" placeholder="百伦订单号" />
</div>
<div class="form-group">
<label>&nbsp;</label>
<button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button>
</div>
</div>
</form>
</div>
<div class="ibox-content m-b-sm border-bottom">
<table id="roletable" style="table-layout:fixed;"></table>
</div>
</div>
</div>
@section css{
<style>
.mules {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
}
@section scripts{
<script type="text/javascript">
var tb;
$(document).ready(function () {
laydate.render({ elem: '#start' });
laydate.render({ elem: '#end' });
var height = document.body.clientHeight;
$("#roletable").attr("data-height", (height - 170));
listPlatform();
})
function list() {
var columns = [
{
field: 'origin_order_id', title: '平台单号', width: '160', formatter: function (idx, data) {
return '<div class="mules" title="' + data.origin_order_id + '">' + data.origin_order_id + '</div>';
}
},
{
field: 'bailun_order_id', title: '订单号', width: '210', iscount: true, formatter: function (idx,data) {
return '<div class="mules" title="' + data.bailun_order_id + '">' + data.bailun_order_id + '</div>';
}
},
{ field: 'platform_type', title: '平台', width: '100' },
{ field: 'website', title: '站点', width: '90' },
{ 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_product', title: '产品收入', width: '110', sortable: true, iscount: true },
{
field: 'amount_shipping', title: '运费收入', width: '110', sortable: true, iscount: true
},
{ field: 'amount_tax', title: '税费收入', width: '110', sortable: true, iscount: true },
{ field: 'amount_adjustment', title: '调整金额', width: '120', sortable: true, iscount: true },
{ field: 'amount_gift_wrap', title: '礼品包装金额', width: '150', sortable: true, iscount: true },
{ field: 'amount_refund', title: '退款金额', width: '90', sortable: true, iscount: true },
{ field: 'cost_total', title: '总支出', width: '110', sortable: true, iscount: true },
{ field: 'cost_promotion', title: '促销费用', width: '110', sortable: true, iscount: true },
{ field: 'cost_platform_fee', title: '平台费用', width: '100', sortable: true, iscount: true },
{ field: 'cost_product', title: '产品成本', width: '100', sortable: true, iscount: true },
{ field: 'cost_shipping', title: '发货费用', width: '100', sortable: true, iscount: true },
{ field: 'cost_package', title: '包装费用', width: '100', sortable: true, iscount: true },
{ field: 'cost_fba_fee', title: 'FBA费用', width: '100', sortable: true, iscount: true },
{ field: 'cost_paypal_fee', title: 'Paypal费用', width: '120', sortable: true, iscount: true },
{ field: 'cost_refund_commisson', title: '退款佣金费用', width: '130', sortable: true, iscount: true },
{ field: 'cost_handle_bailun', title: '处理费(百伦)', width: '130', sortable: true, iscount: true },
{ field: 'cost_handle_platform', title: '处理费(平台)', width: '130', sortable: true, iscount: true },
{ field: 'cost_first', title: '头程费', width: '100', sortable: true, iscount: true },
{ field: 'cost_tail', title: '尾程费', width: '100', sortable: true, iscount: true },
{ field: 'profit_total', title: '利润', width: '100', sortable: true, iscount: true },
{ field: 'profit_rate', title: '利润率', width: '100', sortable: true },
{ field: 'create_time', title: '下单时间', width: '150', sortable: true },
{ field: 'paid_time', title: '付款时间', width: '150', sortable: true }
];
var url = '@Url.Content("~/Reports/Orders/ListOrderDetailJson")' + '?' + $("#toolbar").serialize();
if (tb == undefined) {
tb = OnlyTable("roletable", columns, url, "", {
showfooter: true, loadsuccess: function (d) {
//替换汇总行的相关列值
var tr = $('.fixed-table-footer').find('tr');
for (var c in columns) {
var key = columns[c].field;
if (columns[c].iscount) {
for (var v in d.count_row) {
if (key == v) {
tr.find('td').eq(c).children('div').first().html(d.count_row[v]);
break;
}
}
}
}
}
});
}
else {
tb.bootstrapTable('refresh', { url: url });
}
}
function listPlatform() {
var lindex = layer.load();
$.submit({
url: '@Url.Content("~/Reports/Orders/ListPlatform")',
type:'POST',
paramData: '',
func: function (result) {
layer.close(lindex);
if (result != null && result != undefined) {
$('#platform').html('<option value="">选择平台</option>');
for (var i = 0; i < result.length; i++) {
$('#platform').append('<option value="' + result[i] + '">' + result[i]+'</option>');
}
$('#platform').val('@ViewBag.platform');
listWebsite();
}
}
})
}
function listWebsite() {
var lindex = layer.load();
$.submit({
url: '@Url.Content("~/Reports/Orders/ListWebSite")',
type:'POST',
paramData: 'platform=' + $('#platform').val(),
func: function (result) {
layer.close(lindex);
if (result != null && result != undefined) {
$('#website').html('<option value="">选择平台</option>');
for (var i = 0; i < result.length; i++) {
$('#website').append('<option value="' + result[i] + '">' + result[i]+'</option>');
}
$('#website').val('@ViewBag.website');
list();
}
}
})
}
</script>
}
......@@ -9,7 +9,6 @@
<div class="col-sm-12">
<div class="ibox-content m-b-sm border-bottom">
<form id="toolbar">
<input id="platform" name="platform" type="hidden" value="@ViewBag.platform" />
<div class="form-inline" style="line-height:40px;">
<div class="form-group">
<label>平台类型:</label>
......@@ -39,6 +38,10 @@
<th>销售额</th>
<th>客单价</th>
<th>平台费</th>
<th>头程费</th>
<th>尾程费</th>
<th>处理费(百伦)</th>
<th>处理费(平台)</th>
<th>利润</th>
<th>利润率%</th>
<th>退款</th>
......@@ -87,17 +90,30 @@
if (result && result.length > 0) {
$('#tb').html('');
for (var i = 0; i < result.length; i++) {
var s = '<tr><td>' + result[i].platform + '</td>';
s += '<td>' + result[i].ordercount + '</td>';
s += '<td>' + result[i].saleamount + '</td>';
s += '<td>' + result[i].customerprice + '</td>';
s += '<td>' + result[i].platformfee + '</td>';
s += '<td>' + result[i].profit + '</td>';
s += '<td>' + result[i].profitrate + '</td>';
s += '<td>' + result[i].returnamount + '</td>';
s += '<td>' + result[i].returnamountrate + '</td>';
var s = '<tr><td class="platform"><a href="javascript:;" onclick="ShowWebsite(\'' + result[i].platform+'\');">' + result[i].platform + '</a></td>';
s += '<td title="' + result[i].platform+'">' + result[i].ordercount + '</td>';
s += '<td title="' + result[i].platform +'">' + result[i].saleamount + '</td>';
s += '<td title="' + result[i].platform +'">' + result[i].customerprice + '</td>';
s += '<td title="' + result[i].platform +'">' + result[i].platformfee + '</td>';
s += '<td title="' + result[i].platform +'">' + result[i].cost_first + '</td>';
s += '<td title="' + result[i].platform +'">' + result[i].cost_tail + '</td>';
s += '<td title="' + result[i].platform +'">' + result[i].cost_handle_bailun + '</td>';
s += '<td title="' + result[i].platform +'">' + result[i].cost_handle_platform + '</td>';
s += '<td title="' + result[i].platform +'">' + result[i].profit + '</td>';
s += '<td title="' + result[i].platform +'">' + result[i].profitrate + '</td>';
s += '<td title="' + result[i].platform +'">' + result[i].returnamount + '</td>';
s += '<td title="' + result[i].platform +'">' + result[i].returnamountrate + '</td>';
$('#tb').append(s);
}
$('#tb').find('td').each(function () {
$(this).css('cursor', 'pointer');
var platformcode = $(this).attr('title');
$(this).click(function () {
layer_show(platformcode + " " + $('#start').val() + "至" + $('#end').val() + ' 订单明细', '@Url.Content("~/Reports/Orders/ListOrderDetail?platform=")' + platformcode + '&start=' + $('#start').val() + '&end=' + $('#end').val(), '90%', '90%');
})
})
}
else {
layer.alert('出现异常,请重试!');
......@@ -123,6 +139,18 @@
})
}
function ShowWebsite(platform) {
if (platform == '总计') {
return false;
}
var start = $('#start').val();
var end = $('#end').val();
layer_show(platform + ' 按站点统计', '@Url.Content("~/Reports/Orders/PlatformProfitCountByWebSite?platform=")' + platform + '&start=' + start + '&end=' + end, '90%', '90%');
}
</script>
......

@{
ViewData["Title"] = "平台站点利润统计";
Layout = "~/Pages/Shared/_MainLayout.cshtml";
ViewBag.Nav = new string[] { "统计", "平台利润统计", ViewBag.platform, "站点利润" };
}
<div class="row">
<div class="col-sm-12">
<div class="ibox-content m-b-sm border-bottom">
<form id="toolbar">
<div class="form-inline" style="line-height:40px;">
<div class="form-group">
<label>平台类型:</label>
@*<select id="platform" name="platform" class="form-control">
<option value="">选择平台</option>
</select>*@
<input id="platform" name="platform" class="form-control" style="width:130px" value="@ViewBag.platform" readonly />
</div>
<div class="form-group">
<label>付款时间</label>
<input id="start" name="start" type="text" class="form-control" style="width:130px;" value="@(ViewBag.start)" readonly />
<span>至</span>
<input id="end" name="end" type="text" class="form-control" style="width:130px;" value="@(ViewBag.end)" readonly />
</div>
</div>
</form>
</div>
<div class="ibox-content m-b-sm border-bottom">
<table id="roletable" style="table-layout:fixed;"></table>
</div>
</div>
</div>
@section css{
<style>
.mules {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
}
@section scripts{
<script type="text/javascript">
var tb;
$(document).ready(function () {
laydate.render({ elem: '#start' });
laydate.render({ elem: '#end' });
//var height = document.body.clientHeight;
//$("#roletable").attr("data-height", (height - 170));
list();
//listPlatform();
})
function list() {
var columns = [
{ field: 'platform', title: '平台', width: '100' },
{ field: 'website', title: '站点', width: '90', iscount: true },
{ field: 'ordercount', title: '订单数', width: '100', sortable: true, iscount: true },
{ field: 'saleamount', title: '销售额', width: '90', sortable: true, iscount: true },
{
field: 'customerprice', title: '客单价', width: '90', sortable: true, iscount: true
},
{ field: 'platformfee', title: '平台费', width: '90', sortable: true, iscount: true },
{
field: 'cost_first', title: '头程费', width: '90', sortable: true, iscount: true
},
{ field: 'cost_tail', title: '尾程费', width: '100', sortable: true, iscount: true },
{ field: 'cost_handle_bailun', title: '处理费(百伦)', width: '120', sortable: true, iscount: true },
{ field: 'cost_handle_platform', title: '处理费(平台)', width: '120', sortable: true, iscount: true },
{ field: 'profit', title: '利润', width: '90', sortable: true, iscount: true },
{ field: 'profitrate', title: '利润率%', width: '110', sortable: true },
{ field: 'returnamount', title: '退款额', width: '110', sortable: true, iscount: true },
{ field: 'returnamountrate', title: '退款率%', width: '100', sortable: true }
];
var url = '@Url.Content("~/Reports/Orders/PlatformProfitCountByWebSiteJson")' + '?' + $("#toolbar").serialize();
if (tb == undefined) {
tb = OnlyTable("roletable", columns, url, "", {
showfooter: true, loadsuccess: function (d) {
//替换汇总行的相关列值
var tr = $('.fixed-table-footer').find('tr');
for (var c in columns) {
var key = columns[c].field;
if (columns[c].iscount) {
for (var v in d.count_row) {
if (key == v) {
tr.find('td').eq(c).children('div').first().html(d.count_row[v]);
break;
}
}
}
}
}
});
}
else {
tb.bootstrapTable('refresh', { url: url });
}
}
function listPlatform() {
$.submit({
url: '@Url.Content("~/Reports/Orders/ListPlatform")',
type:'POST',
paramData: '',
func: function (result) {
if (result != null && result != undefined) {
$('#platform').html('<option value="">选择平台</option>');
for (var i = 0; i < result.length; i++) {
$('#platform').append('<option value="' + result[i] + '">' + result[i]+'</option>');
}
}
}
})
}
function ShowWebsite(platform) {
if (platform == '总计') {
return false;
}
var start = $('#start').val();
var end = $('#end').val();
layer_show(platform+' 按站点统计', '@Url.Content("~/Reports/Orders/")', '90%', '90%');
}
</script>
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment