Commit a9484837 by guanzhenshan

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

parent 68bfb138
......@@ -79,5 +79,10 @@ namespace Bailun.DC.Models.Orders
/// </summary>
public decimal cost_handle_platform { get; set; }
/// <summary>
/// 预收金额
/// </summary>
public decimal amount_prepaid { get; set; }
}
}
......@@ -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,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))
{
......@@ -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)
{
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))
{
......
......@@ -424,25 +424,30 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
{
var result = new Services.OrdersServices().ListPlatformProfit(platform, start, end);
var m = new Models.Orders.mPlatformProfit
if (result.Count > 0)
{
platform = "总计",
ordercount = result.Sum(a => a.ordercount),
saleamount = result.Sum(a => a.saleamount),
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,
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);
var m = new Models.Orders.mPlatformProfit
{
platform = "总计",
ordercount = result.Sum(a => a.ordercount),
saleamount = result.Sum(a => a.saleamount),
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,
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),
amount_prepaid = result.Sum(a=>a.amount_prepaid),
};
result.Add(m);
}
var list = result.Select(p => new {
p.platform,
customerprice = p.customerprice>0?p.customerprice.ToString("###,###.##"):"0",
......@@ -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_platform = p.cost_handle_platform>0?p.cost_handle_platform.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);
......@@ -504,6 +510,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
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);
countM.amount_prepaid = Math.Round(countM.amount_prepaid, 2, MidpointRounding.AwayFromZero);
var list = result.Select(p => new {
p.platform,
......@@ -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_tail = p.cost_tail > 0 ? p.cost_tail.ToString("###,###.##") : "0",
p.website,
amount_prepaid = p.amount_prepaid>0?p.amount_prepaid.ToString("###,###.##"):"0",
});
return JsonConvert.SerializeObject(new { total=total,rows = list,count_row=countM});
......
......@@ -42,6 +42,7 @@
<th>尾程费</th>
<th>处理费(百伦)</th>
<th>处理费(平台)</th>
<th>预收金额</th>
<th>利润</th>
<th>利润率%</th>
<th>退款</th>
......@@ -98,7 +99,8 @@
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].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].profitrate + '</td>';
s += '<td title="' + result[i].platform +'">' + result[i].returnamount + '</td>';
......@@ -110,13 +112,17 @@
$(this).css('cursor', 'pointer');
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%');
return;
})
}
})
}
else {
layer.alert('出现异常,请重试!');
layer.alert('没有找到相应数据!');
}
}
})
......
......@@ -59,22 +59,72 @@
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: '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: '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 }
{
field: 'returnamount', title: '退款额', width: '110', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span onclick="ShowDetail(\'' + data.website + '\')" style="cursor:pointer;">' + data.returnamount + '</span>';
}
},
{
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();
......@@ -95,6 +145,7 @@
}
}
}
}
});
}
......@@ -119,16 +170,12 @@
})
}
function ShowWebsite(platform) {
if (platform == '总计') {
return false;
}
function ShowDetail(website) {
var start = $('#start').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