Commit a9484837 by guanzhenshan

调整利润统计报表,解决数据为空报表会出错的问题,增加预收金额字段

parent 68bfb138
...@@ -79,5 +79,10 @@ namespace Bailun.DC.Models.Orders ...@@ -79,5 +79,10 @@ namespace Bailun.DC.Models.Orders
/// </summary> /// </summary>
public decimal cost_handle_platform { get; set; } public decimal cost_handle_platform { get; set; }
/// <summary>
/// 预收金额
/// </summary>
public decimal amount_prepaid { get; set; }
} }
} }
...@@ -796,7 +796,7 @@ namespace Bailun.DC.Services ...@@ -796,7 +796,7 @@ namespace Bailun.DC.Services
public List<Models.Orders.mPlatformProfit> ListPlatformProfit(string platform, DateTime? start, DateTime? end) public List<Models.Orders.mPlatformProfit> 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(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'"; 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,sum(amount_prepaid*seller_order_exchange_rate) amount_prepaid from dc_base_oms_order where bailun_order_status!='Canceled'";
if (!string.IsNullOrWhiteSpace(platform)) if (!string.IsNullOrWhiteSpace(platform))
{ {
...@@ -841,7 +841,7 @@ namespace Bailun.DC.Services ...@@ -841,7 +841,7 @@ 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(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'"; 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,sum(amount_prepaid*seller_order_exchange_rate) amount_prepaid from dc_base_oms_order where bailun_order_status!='Canceled'";
if (!string.IsNullOrWhiteSpace(platform)) if (!string.IsNullOrWhiteSpace(platform))
{ {
......
...@@ -424,25 +424,30 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -424,25 +424,30 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
{ {
var result = new Services.OrdersServices().ListPlatformProfit(platform, start, end); var result = new Services.OrdersServices().ListPlatformProfit(platform, start, end);
var m = new Models.Orders.mPlatformProfit if (result.Count > 0)
{ {
platform = "总计", var m = new Models.Orders.mPlatformProfit
ordercount = result.Sum(a => a.ordercount), {
saleamount = result.Sum(a => a.saleamount), platform = "总计",
customerprice = result.Sum(a => a.customerprice)/result.Count, ordercount = result.Sum(a => a.ordercount),
platformfee = result.Sum(a => a.platformfee), saleamount = result.Sum(a => a.saleamount),
profit = result.Sum(a => a.profit), customerprice = result.Sum(a => a.customerprice) / result.Count,
profitrate = 0, platformfee = result.Sum(a => a.platformfee),
returnamount = result.Sum(a => a.returnamount), profit = result.Sum(a => a.profit),
returnamountrate = 0, profitrate = 0,
cost_first = result.Sum(a => a.cost_first), returnamount = result.Sum(a => a.returnamount),
cost_handle_bailun = result.Sum(a => a.cost_handle_bailun), returnamountrate = 0,
cost_handle_platform = result.Sum(a => a.cost_handle_platform), cost_first = result.Sum(a => a.cost_first),
cost_tail = result.Sum(a => a.cost_tail), 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); amount_prepaid = result.Sum(a=>a.amount_prepaid),
};
result.Add(m);
}
var list = result.Select(p => new { var list = result.Select(p => new {
p.platform, p.platform,
customerprice = p.customerprice>0?p.customerprice.ToString("###,###.##"):"0", customerprice = p.customerprice>0?p.customerprice.ToString("###,###.##"):"0",
...@@ -458,6 +463,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -458,6 +463,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
cost_handle_bailun = p.cost_handle_bailun>0?p.cost_handle_bailun.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_handle_platform = p.cost_handle_platform>0?p.cost_handle_platform.ToString("###,###.##"):"0",
cost_tail = p.cost_tail>0?p.cost_tail.ToString("###,###.##"):"0", cost_tail = p.cost_tail>0?p.cost_tail.ToString("###,###.##"):"0",
amount_prepaid = p.amount_prepaid>0?p.amount_prepaid.ToString("###,###.##"):"0"
}); });
return Json(list); return Json(list);
...@@ -504,6 +510,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -504,6 +510,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
countM.profit = Math.Round(countM.profit, 2, MidpointRounding.AwayFromZero); countM.profit = Math.Round(countM.profit, 2, MidpointRounding.AwayFromZero);
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);
var list = result.Select(p => new { var list = result.Select(p => new {
p.platform, p.platform,
...@@ -521,6 +528,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -521,6 +528,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
cost_handle_platform = p.cost_handle_platform > 0 ? p.cost_handle_platform.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", cost_tail = p.cost_tail > 0 ? p.cost_tail.ToString("###,###.##") : "0",
p.website, p.website,
amount_prepaid = p.amount_prepaid>0?p.amount_prepaid.ToString("###,###.##"):"0",
}); });
return JsonConvert.SerializeObject(new { total=total,rows = list,count_row=countM}); return JsonConvert.SerializeObject(new { total=total,rows = list,count_row=countM});
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
<th>尾程费</th> <th>尾程费</th>
<th>处理费(百伦)</th> <th>处理费(百伦)</th>
<th>处理费(平台)</th> <th>处理费(平台)</th>
<th>预收金额</th>
<th>利润</th> <th>利润</th>
<th>利润率%</th> <th>利润率%</th>
<th>退款</th> <th>退款</th>
...@@ -98,7 +99,8 @@ ...@@ -98,7 +99,8 @@
s += '<td title="' + result[i].platform +'">' + result[i].cost_first + '</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_tail + '</td>';
s += '<td title="' + result[i].platform +'">' + result[i].cost_handle_bailun + '</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].cost_handle_platform + '</td>';
s += '<td title="' + result[i].platform + '">' + result[i].amount_prepaid + '</td>';
s += '<td title="' + result[i].platform +'">' + result[i].profit + '</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].profitrate + '</td>';
s += '<td title="' + result[i].platform +'">' + result[i].returnamount + '</td>'; s += '<td title="' + result[i].platform +'">' + result[i].returnamount + '</td>';
...@@ -110,13 +112,17 @@ ...@@ -110,13 +112,17 @@
$(this).css('cursor', 'pointer'); $(this).css('cursor', 'pointer');
var platformcode = $(this).attr('title'); var platformcode = $(this).attr('title');
$(this).click(function () { if (!$(this).hasClass('platform')) {
$(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%'); layer_show(platformcode + " " + $('#start').val() + "至" + $('#end').val() + ' 订单明细', '@Url.Content("~/Reports/Orders/ListOrderDetail?platform=")' + platformcode + '&start=' + $('#start').val() + '&end=' + $('#end').val(), '90%', '90%');
return;
}) })
}
}) })
} }
else { else {
layer.alert('出现异常,请重试!'); layer.alert('没有找到相应数据!');
} }
} }
}) })
......
...@@ -59,22 +59,72 @@ ...@@ -59,22 +59,72 @@
var columns = [ var columns = [
{ field: 'platform', title: '平台', width: '100' }, { field: 'platform', title: '平台', width: '100' },
{ field: 'website', title: '站点', width: '90', iscount: true }, { 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: 'ordercount', title: '订单数', width: '100', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span onclick="ShowDetail(\'' + data.website + '\')" style="cursor:pointer;">' + data.ordercount + '</span>';
}
},
{
field: 'saleamount', title: '销售额', width: '90', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span onclick="ShowDetail(\'' + data.website + '\')" style="cursor:pointer;">' + data.saleamount + '</span>';
}
},
{
field: 'customerprice', title: '客单价', width: '90', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span onclick="ShowDetail(\'' + data.website + '\')" style="cursor:pointer;">' + data.customerprice + '</span>';
}
},
{
field: 'platformfee', title: '平台费', width: '90', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span onclick="ShowDetail(\'' + data.website + '\')" style="cursor:pointer;">' + data.platformfee + '</span>';
}
},
{
field: 'cost_first', title: '头程费', width: '90', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span onclick="ShowDetail(\'' + data.website + '\')" style="cursor:pointer;">' + data.cost_first + '</span>';
}
},
{
field: 'cost_tail', title: '尾程费', width: '100', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span onclick="ShowDetail(\'' + data.website + '\')" style="cursor:pointer;">' + data.cost_tail + '</span>';
}
},
{
field: 'cost_handle_bailun', title: '处理费(百伦)', width: '120', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span onclick="ShowDetail(\'' + data.website + '\')" style="cursor:pointer;">' + data.cost_handle_bailun + '</span>';
}
}, },
{ field: 'platformfee', title: '平台费', width: '90', sortable: true, iscount: true },
{ {
field: 'cost_first', title: '头程费', width: '90', sortable: true, iscount: true field: 'cost_handle_platform', title: '处理费(平台)', width: '120', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span onclick="ShowDetail(\'' + data.website + '\')" style="cursor:pointer;">' + data.cost_handle_platform + '</span>';
}
},
{
field: 'amount_prepaid', title: '预收款', width: '100', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span onclick="ShowDetail(\'' + data.website + '\')" style="cursor:pointer;">' + data.amount_prepaid + '</span>';
}
},
{
field: 'profit', title: '利润', width: '90', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span onclick="ShowDetail(\'' + data.website + '\')" style="cursor:pointer;">' + data.profit + '</span>';
}
},
{
field: 'profitrate', title: '利润率%', width: '110', sortable: true, formatter: function (idx, data) {
return '<span onclick="ShowDetail(\'' + data.website + '\')" style="cursor:pointer;">' + data.profitrate + '</span>';
}
}, },
{ field: 'cost_tail', title: '尾程费', width: '100', sortable: true, iscount: true }, {
{ field: 'cost_handle_bailun', title: '处理费(百伦)', width: '120', sortable: true, iscount: true }, field: 'returnamount', title: '退款额', width: '110', sortable: true, iscount: true, formatter: function (idx, data) {
{ field: 'cost_handle_platform', title: '处理费(平台)', width: '120', sortable: true, iscount: true }, return '<span onclick="ShowDetail(\'' + data.website + '\')" style="cursor:pointer;">' + data.returnamount + '</span>';
{ 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 } field: 'returnamountrate', title: '退款率%', width: '100', sortable: true
, formatter: function (idx, data) {
return '<span onclick="ShowDetail(\'' + data.website + '\')" style="cursor:pointer;">' + data.returnamountrate + '</span>';
}
}
]; ];
var url = '@Url.Content("~/Reports/Orders/PlatformProfitCountByWebSiteJson")' + '?' + $("#toolbar").serialize(); var url = '@Url.Content("~/Reports/Orders/PlatformProfitCountByWebSiteJson")' + '?' + $("#toolbar").serialize();
...@@ -95,6 +145,7 @@ ...@@ -95,6 +145,7 @@
} }
} }
} }
} }
}); });
} }
...@@ -119,16 +170,12 @@ ...@@ -119,16 +170,12 @@
}) })
} }
function ShowWebsite(platform) { function ShowDetail(website) {
if (platform == '总计') {
return false;
}
var start = $('#start').val(); var start = $('#start').val();
var end = $('#end').val(); var end = $('#end').val();
layer_show(platform+' 按站点统计', '@Url.Content("~/Reports/Orders/")', '90%', '90%'); layer_show("@(ViewBag.platform) " + website + " " + $('#start').val() + "至" + $('#end').val() + ' 订单明细', '@Url.Content("~/Reports/Orders/ListOrderDetail?platform="+ViewBag.platform)' + '&start=' + $('#start').val() + '&end=' + $('#end').val() + '&website=' + website, '90%', '90%');
} }
......
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