Commit c428b861 by guanzhenshan

优化SKU品类利润统计报表,增加二级和三级报表

parent 6d1aa63b
......@@ -10,5 +10,6 @@ namespace Bailun.DC.Models.Sku
public string product_type_desc { get; set; }
public string selected { get; set; }
}
}
......@@ -490,6 +490,25 @@ namespace Bailun.DC.Services
}
/// <summary>
/// 获取百伦新分类详情信息
/// </summary>
/// <param name="id">分类id</param>
/// <returns></returns>
public static Models.Sku.dc_base_bailuncategory getBailunNewCategory(int id)
{
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
return cn.QueryFirstOrDefault<Models.Sku.dc_base_bailuncategory>("select * from dc_base_bailuncategory where c_id="+id);
}
}
/// <summary>
/// 根据分类id获取所有子级id
/// </summary>
/// <param name="parentid">父级分类id</param>
......@@ -498,7 +517,7 @@ namespace Bailun.DC.Services
{
var str = "";
if (list.Count==0)
if (list==null || list.Count==0)
{
list = ListBailunNewCategory(null, null);
}
......@@ -530,6 +549,8 @@ namespace Bailun.DC.Services
}
}
#region 汇率实体 ExchangeRate
......
......@@ -1773,7 +1773,13 @@ namespace Bailun.DC.Services
if (skunewcategoryid.HasValue)
{
sql += " join dc_base_bailuncategory t70 on t60.bailun_category_id=t70.c_id and t70.c_level=1 and t70.has_delete=0 and t70.c_id in (" + Services.CommonServices.BailunNewCategory(skunewcategoryid.Value,null) + ")";
var str_children_category = Services.CommonServices.BailunNewCategory(skunewcategoryid.Value, null);
if (str_children_category == "")
{
str_children_category = skunewcategoryid.Value + "";
}
sql += " and t60.bailun_category_id in (" + str_children_category + ")";
}
}
else if (statistictype == 2) //sku来源
......@@ -1957,9 +1963,15 @@ namespace Bailun.DC.Services
if (skunewcategoryid.HasValue)
{
sql += " join dc_base_bailuncategory t70 on t60.bailun_category_id=t70.c_id and t70.c_level=1 and t70.has_delete=0 and t70.c_id in ("+Services.CommonServices.BailunNewCategory(skunewcategoryid.Value,null)+")";
var str_children_category = Services.CommonServices.BailunNewCategory(skunewcategoryid.Value, null);
if (str_children_category == "")
{
str_children_category = skunewcategoryid.Value + "";
}
sql += " and t60.bailun_category_id in (" + str_children_category + ")";
}
}
else if (statistictype == 2) //sku来源
{
......
......@@ -1831,6 +1831,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
if (m == null)
{
m = new Models.Orders.dc_base_oms_sku {
id = item.c_id,
platform_type= item.c_name,
cost_platform_fee = 0,
profit_total = 0,
......@@ -1850,6 +1851,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
};
}
m.id = item.c_id;
m.order_count += children.Sum(a => a.order_count);
m.customerprice += children.Sum(a => a.customerprice);
......@@ -1991,6 +1993,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
adfee = (p.adfee ?? 0).ToString("N2"),
putawayfee = (p.putawayfee ?? 0).ToString("N2"),
id = p.id,
}).ToList();
......@@ -2390,6 +2393,89 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
return View();
}
public ActionResult SkuProfitCount(string platform, string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, string currency, string product_type, int? skusource, int? shippingstrategy, int? skunewcategory, int statistictype = 0)
{
var _skuService = new Services.SkuInfoServices();
var listProductType = _skuService.ListSkuProductType().Where(a => !string.IsNullOrEmpty(a.product_type_desc)).ToList();
int index = -1;
var list = new List<Models.Sku.mSku_ProductType>();
var arr_producttype = new List<string>();
if (product_type != null)
{
product_type.Split(',').Where(a => !string.IsNullOrEmpty(a)).ToList();
}
foreach (var item in listProductType)
{
item.selected = "";
var mProductType = arr_producttype.Where(a => a == item.product_type.ToString()).FirstOrDefault();
if (mProductType != null)
{
item.selected = "selected";
}
if (item.product_type == 5 || item.product_type == 13)
{
if (index != -1)
{
list.Insert(index, item);
}
else
{
index = listProductType.IndexOf(item);
list.Add(item);
}
}
else
{
list.Add(item);
}
}
ViewBag.listSkuType = list;
ViewBag.listSource = _skuService.ListSkuSource().Where(a => a == 1 || a == 3 || a == 6 || a == 7).ToList(); //精准开发,线下美容,普货供应商推荐,服务供应商推荐
ViewBag.statistictype = statistictype;
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.shipstart = shipstart.HasValue ? shipstart.Value.ToString("yyyy-MM-dd") : "";
ViewBag.shipend = shipend.HasValue ? shipend.Value.ToString("yyyy-MM-dd") : "";
ViewBag.currency = currency;
ViewBag.product_type = product_type;
ViewBag.skusource = skusource.HasValue ? skusource.Value + "" : "";
ViewBag.shippingstrategy = shippingstrategy.HasValue ? shippingstrategy.Value+"" : "";
ViewBag.skunewcategory = skunewcategory.HasValue ? skunewcategory.Value + "" : "";
if (skunewcategory.HasValue)
{
var objCategory = Services.CommonServices.getBailunNewCategory(skunewcategory.Value);
if (objCategory != null)
{
ViewBag.level = objCategory.c_level;
}
else
{
ViewBag.level = 1;
}
}
else
{
ViewBag.level = 1;
}
return View();
}
#endregion
#region 订单退款明细
......
......@@ -56,7 +56,7 @@
<span>至</span>
<input id="shipend" name="shipend" type="text" class="form-control" style="width:130px;" placeholder="发货结束时间" />
</div>
<div class="form-group">
<div id="content_producttype" class="form-group" style="display:none;">
<label>产品类型</label>
<select id="producttype" name="producttype" class="form-control" multiple="multiple">
@*<option value="">选择产品类型</option>*@
......@@ -233,6 +233,10 @@
if ('@ViewBag.statistictype' == 0) {
$('#btn_left').show();
$('#content_producttype').show();
}
else if ('@ViewBag.statistictype' == '2') {
$('#content_producttype').show();
}
})
......@@ -302,7 +306,7 @@
$('#tb').append(s);
}
else if('@ViewBag.statistictype' == 1){
var s = '<tr><td class="platform" ><div style="width:220px;" class="mules" title="' + result[i].platform_type + '">' + result[i].platform_type + '</div></td>';
var s = '<tr><td class="platform" ><div style="width:220px;" class="mules" title="' + result[i].platform_type + '"><a onclick="skucategorychildren(' + result[i].id + ',\'' + result[i].platform_type +'\')">' + result[i].platform_type + '</a></div></td>';
s += '<td>' + result[i].order_count + '</td>';
s += '<td> ' + result[i].amount_sales + '</td>';
s += '<td>' + result[i].cost_product + '</td>';
......@@ -409,7 +413,7 @@
$('#footer').append(foot_s);
}
else if('@ViewBag.statistictype' == 1) {
var foot_s = '<tr><td class="platform">' + result[i].platform_type + '</td>';
var foot_s = '<tr>' + result[i].platform_type + '</td>';
foot_s += '<td>' + result[i].order_count + '</td>';
foot_s += '<td> ' + result[i].amount_sales + '</td>';
foot_s += '<td>' + result[i].cost_product + '</td>';
......@@ -600,6 +604,35 @@
layer_show(platform + " " + title+"曲线图", '@Url.Content("~/Reports/Orders/OrderProfitGraph?platform=")' + platform + '&start=' + $('#start').val() + '&end=' + $('#end').val() + '&col=' + colval + '&shipstart=' + $('#shipstart').val() + '&shipend=' + $('#shipend').val() + '&currency=' + $('#currency').val() + '&skucategoryids=' + s + '&titlename=' + title, '90%', '90%');
}
function skucategorychildren(categoryid, title) {
if (categoryid == 0) {
alert("抱歉,该分类在百伦新分类无法找到!");
return false;
}
var producttype = $("#producttype").ySelectedValues(",");
var shipstart = $('#shipstart').val();
var shipend = $('#shipend').val();
var start = $('#start').val();
var end = $('#end').val();
if ((shipstart != '' || shipend != '') && (start != '' || end != '')) {
layer.alert('搜索条件不能同时选择付款时间和发货时间,只能选其一。');
return false;
}
if (start == '' && end == '' && shipstart == '' && shipend == '') {
layer.alert('请选择时间进行搜索。');
return false;
}
var urlparam = $("#toolbar").serialize() + '&product_type=' + producttype + '&statistictype=@(ViewBag.statistictype)' + '&skunewcategory=' + categoryid;
layer_show(title + "的产品分类利润统计",'@Url.Content("~/Reports/Orders/SkuProfitCount?")'+urlparam,'95%','95%');
}
</script>
}
......

@{
ViewData["Title"] = "SKU产品类型利润统计";
Layout = "~/Pages/Shared/_MainLayout.cshtml";
ViewBag.Nav = new string[] { "统计", "SKU产品类型利润统计" };
}
<div class="row">
<div class="col-sm-12">
<div id="leftcontain" style="position:relative;float:left;width:215px;margin-right:-220px;background-color:#fff;height:780px;border-top:solid 1px #E7EAEC;display:none;">
<div id="ztree" class="ztree" style="margin:5px 10px;max-height: 800px;overflow: auto;">
</div>
</div>
<div style="float:right;width:100%;">
<div id="rightcontain">
<div class="alert alert-warning">
说明:退款数据统计的是时间段内的退款发生额,并且排除已取消订单的退款。
</div>
<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>&nbsp;</label>
<button id="btn_left" type="button" class="btn btn-success" onclick="showleft();" style="display:none;">分类筛选</button>
</div>
<div class="form-group">
<label>币种</label>
<select id="currency" name="currency" class="form-control">
<option value="CNY">人民币</option>
<option value="USD">美元</option>
</select>
</div>
<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)" placeholder="付款开始时间" />
<span>至</span>
<input id="end" name="end" type="text" class="form-control" style="width:130px;" value="@(ViewBag.end)" placeholder="付款结束时间" />
</div>
<div class="form-group">
<label>发货时间</label>
<input id="shipstart" name="shipstart" type="text" class="form-control" style="width:130px;" value="@(ViewBag.shipstart)" placeholder="发货开始时间" />
<span>至</span>
<input id="shipend" name="shipend" type="text" class="form-control" style="width:130px;" value="@(ViewBag.shipend)" placeholder="发货结束时间" />
</div>
<div id="content_producttype" class="form-group" style="display:none;">
<label>产品类型</label>
<select id="producttype" name="producttype" class="form-control" multiple="multiple">
@if (ViewBag.listSkuType.Count > 0)
{
foreach (var item in ViewBag.listSkuType)
{
<option value="@item.product_type" @item.selected>@item.product_type_desc</option>
}
}
</select>
</div>
<div class="form-group">
<label>产品来源</label>
<select id="skusource" name="skusource" class="form-control">
<option value="">选择产品来源</option>
@if (ViewBag.listSource.Count > 0)
{
foreach (var item in ViewBag.listSource)
{
<option value="@item">@Enum.GetName(typeof(Bailun.DC.Models.SkuSource), item)</option>
}
}
</select>
</div>
<div class="form-group">
<label>发货策略</label>
<select id="shippingstrategy" name="shippingstrategy" class="form-control">
<option value="">选择发货策略</option>
<option value="1">专线</option>
<option value="2">中国发货</option>
<option value="3">海外仓</option>
<option value="4">FBA仓</option>
</select>
</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" class="table table-hover table-bordered table-condensed table-striped">
<thead>
<tr>
@if (ViewBag.statistictype == 0)
{
<th style="width:110px;">平台</th>
}
else if (ViewBag.statistictype == 1)
{
<th style="width:160px;">产品类型</th>
}
else
{
<th style="width:160px;">SKU来源</th>
}
<th style="width:70px;">订单数</th>
@if (ViewBag.statistictype == 0)
{
<th style="width:40px"></th>
}
<th style="width:110px;">销售额</th>
@if (ViewBag.statistictype == 0)
{
<th style="width:40px"></th>
}
<th style="width:110px;">产品成本</th>
<th style="width:70px;">客单价</th>
<th style="width:100px;">平台费</th>
<th style="width:80px;">FBA费</th>
<th style="width:100px;">PayPal费</th>
<th style="width:100px;">头程费</th>
<th style="width:100px;">尾程费</th>
<th style="width:90px;">处理费</th>
<th style="width:130px;">平台操作费</th>
<th style="width:100px;">广告费</th>
<th style="width:100px;">上架费</th>
<th style="width:110px;">预收金额</th>
<th style="width:120px;">预收订单数</th>
<th style="width:110px;">利润</th>
@if (ViewBag.statistictype == 0)
{
<th style="width:40px"></th>
}
<th style="width:110px;">利润率%</th>
<th style="width:100px;">退款</th>
<th style="width:110px;">退款率%</th>
</tr>
</thead>
<tbody id="tb"></tbody>
<tfoot id="footer">
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
@section css{
<link href="~/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css" />
<link href="~/js/yselect/yselect.css" rel="stylesheet" />
<style>
.mules {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.alink {
color: cornflowerblue;
cursor: pointer;
}
.skuprofit {
color: #1D84C6;
cursor: pointer;
}
.tablesorter-headerDesc {
background-position: right;
background-repeat: no-repeat;
padding-right: 30px;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZUlEQVQ4y2NgGAWjYBSggaqGu5FA/BOIv2PBIPFEUgxjB+IdQPwfC94HxLykus4GiD+hGfQOiB3J8SojEE9EM2wuSJzcsFMG4ttQgx4DsRalkZENxL+AuJQaMcsGxBOAmGvopk8AVz1sLZgg0bsAAAAASUVORK5CYII=' );
}
.tablesorter-headerAsc {
background-position: right;
background-repeat: no-repeat;
padding-right: 30px;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg==');
}
</style>
}
@section scripts{
<script src="~/js/jquery.ztree.core.min.js"></script>
<script src="~/js/jquery.ztree.excheck.min.js"></script>
<script src="~/js/jquery.tablesorter.min.js" type="text/javascript"></script>
<script src="~/js/yselect/yselect.js"></script>
<script type="text/javascript">
var tb;
$(document).ready(function () {
laydate.render({ elem: '#start' });
laydate.render({ elem: '#end' });
laydate.render({ elem: '#shipstart' });
laydate.render({ elem: '#shipend' });
list();
listPlatform();
//listcategory12();
listsimplecategory();
$('#platform').change(function () {
listwebsite();
})
if ('@ViewBag.currency' != '') {
$('#currency').val('@ViewBag.currency');
}
if ('@ViewBag.skusource' != '') {
$('#skusource').val('@ViewBag.skusource');
}
if ('@ViewBag.shippingstrategy' != '') {
$('#shippingstrategy').val('@ViewBag.shippingstrategy');
}
$('#producttype').ySelect(
{
placeholder: '请选择产品类型',
searchText: '搜索',
showSearch: false,
numDisplayed: 10,
overflowText: '已选中 {n}项'
}
);
if ('@ViewBag.statistictype' == 0) {
$('#btn_left').show();
$('#content_producttype').show();
}
else if ('@ViewBag.statistictype' == '2') {
$('#content_producttype').show();
}
})
function list() {
var producttype = $("#producttype").ySelectedValues(",");
var shipstart = $('#shipstart').val();
var shipend = $('#shipend').val();
var start = $('#start').val();
var end = $('#end').val();
if ((shipstart != '' || shipend != '') && (start != '' || end != '')) {
layer.alert('搜索条件不能同时选择付款时间和发货时间,只能选其一。');
return false;
}
if (start == '' && end == '' && shipstart == '' && shipend == '') {
layer.alert('请选择时间进行搜索。');
return false;
}
var s = '';
try {
s = getChkNode();
} catch (e) {
s = '';
}
var lindex = layer.load(1, { shade: false }); //0代表加载的风格,支持0-2
$.submit({
type:'POST',
url: '@Url.Content("~/Reports/Orders/PlatformProfitCountJson")',
paramData: $("#toolbar").serialize() + '&skucategoryids=' + s + '&product_type=' + producttype + '&statistictype=@(ViewBag.statistictype)' +'&skunewcategory=@(ViewBag.skunewcategory)',
func: function (result) {
layer.close(lindex);
if (result && result.length > 0) {
$('#tb').html('');
$('#footer').html('');
for (var i = 0; i < result.length - 1; i++) {
if ('@ViewBag.statistictype' == 0) {
var s = '<tr><td class="platform"><a href="javascript:;" onclick="ShowWebsite(\'' + result[i].platform_type + '\');" title="查看订单明细">' + result[i].platform_type + '</a></td>';
s += '<td class="skuprofit" onclick="ShowSkuProfit(\'' + result[i].platform_type + '\',\'订单数\',\'order_count\',0)" title="查看sku分类利润">' + result[i].order_count + '</td>';
s += '<td><img style="width:16px;margin-left:3px" src="@Url.Content("~/img/chart-icon.png")" onclick="ShowChart(\'' + result[i].platform_type + '\',\'订单数\',\'order_count\');" title="点击查看订单数曲线图"></td>';
s += '<td class="skuprofit" onclick="ShowSkuProfit(\'' + result[i].platform_type + '\',\'销售额\',\'amount_sales\',0)" title="查看sku分类利润"> ' + result[i].amount_sales + '</td>';
s += '<td><img style="width:16px;margin-left:3px" src="@Url.Content("~/img/chart-icon.png")" onclick="ShowChart(\'' + result[i].platform_type + '\',\'销售额\',\'amount_sales\');" title="点击查看销售额曲线图"></td>';
s += '<td class="skuprofit" onclick="ShowSkuProfit(\'' + result[i].platform_type + '\',\'产品成本\',\'cost_product\',1)" title="查看sku分类利润">' + result[i].cost_product + '</td>';
s += '<td>' + result[i].customerprice + '</td>';
s += '<td class="skuprofit" onclick="ShowSkuProfit(\'' + result[i].platform_type + '\',\'平台费用\',\'cost_platform_fee\',1)" title="查看sku分类利润">' + result[i].cost_platform_fee + '</td>';
s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'FBA费\',\'cost_fba_fee\',1)" title="查看订单明细">' + result[i].cost_fba_fee + '</td>';
s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'PayPal费\',\'cost_paypal_fee\',1)" title="查看订单明细">' + result[i].cost_paypal_fee + '</td>';
s += '<td class="skuprofit" onclick="ShowSkuProfit(\'' + result[i].platform_type + '\',\'头程费\',\'cost_first\',1)" title="查看sku分类利润">' + result[i].cost_first + '</td>';
s += '<td class="skuprofit" onclick="ShowSkuProfit(\'' + result[i].platform_type + '\',\'尾程费\',\'cost_tail\',1)" title="查看sku分类利润">' + result[i].cost_tail + '</td>';
s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'处理费\',\'cost_handle_bailun\',1)" title="查看订单明细">' + result[i].cost_handle_bailun + '</td>';
s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'平台操作费\',\'cost_handle_platform\',1)" title="查看订单明细">' + result[i].cost_handle_platform + '</td>';
s += '<td>' + result[i].adfee + '</td>';
s += '<td>' + result[i].putawayfee + '</td>';
s += '<td class="skuprofit" onclick="ShowSkuProfit(\'' + result[i].platform_type + '\',\'预收款\',\'amount_prepaid\',1)" title="查看sku分类利润">' + result[i].amount_prepaid + '</td>';
s += '<td class="skuprofit" onclick="ShowSkuProfit(\'' + result[i].platform_type + '\',\'预收订单数\',\'noshippingcount\',1)" title="查看sku分类利润">' + result[i].noshippingcount + '</td>';
s += '<td class="skuprofit" onclick="ShowSkuProfit(\'' + result[i].platform_type + '\',\'利润\',\'profit_total\',1)" title="查看sku分类利润">' + result[i].profit_total + '</td>';
s += '<td><img style="width:16px;margin-left:3px" src="@Url.Content("~/img/chart-icon.png")" onclick="ShowChart(\'' + result[i].platform_type + '\',\'利润\',\'profit_total\');" title="点击查看利润曲线图"></td>';
s += '<td>' + result[i].profit_rate + '</td>';
//s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'退款金额\',\'amount_refund\',1)" title="查看订单明细">' + result[i].amount_refund + '</td>';
s += '<td>' + result[i].amount_refund + '</td>';
s += '<td>' + result[i].amount_refund_rate + '</td>';
$('#tb').append(s);
}
else if ('@ViewBag.statistictype' == 1) {
var s = '';
if ('@ViewBag.level' == 1) {
s = '<tr><td class="platform" ><div style="width:220px;" class="mules" title="' + result[i].platform_type + '"><a onclick="skucategorychildren(' + result[i].id + ',\'' + result[i].platform_type + '\')">' + result[i].platform_type + '</a></div></td>';
}
else {
s = '<tr><td class="platform" ><div style="width:220px;" class="mules" title="' + result[i].platform_type + '">' + result[i].platform_type + '</div></td>';
}
s += '<td>' + result[i].order_count + '</td>';
s += '<td> ' + result[i].amount_sales + '</td>';
s += '<td>' + result[i].cost_product + '</td>';
s += '<td>' + result[i].customerprice + '</td>';
s += '<td>' + result[i].cost_platform_fee + '</td>';
s += '<td>' + result[i].cost_fba_fee + '</td>';
s += '<td>' + result[i].cost_paypal_fee + '</td>';
s += '<td>' + result[i].cost_first + '</td>';
s += '<td>' + result[i].cost_tail + '</td>';
s += '<td>' + result[i].cost_handle_bailun + '</td>';
s += '<td>' + result[i].cost_handle_platform + '</td>';
s += '<td>' + result[i].adfee + '</td>';
s += '<td>' + result[i].putawayfee + '</td>';
s += '<td>' + result[i].amount_prepaid + '</td>';
s += '<td>' + result[i].noshippingcount + '</td>';
s += '<td>' + result[i].profit_total + '</td>';
s += '<td>' + result[i].profit_rate + '</td>';
//s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'退款金额\',\'amount_refund\',1)" title="查看订单明细">' + result[i].amount_refund + '</td>';
s += '<td>' + result[i].amount_refund + '</td>';
s += '<td>' + result[i].amount_refund_rate + '</td>';
$('#tb').append(s);
}
else if('@ViewBag.statistictype' == 2){
var s = '<tr><td class="platform">' + result[i].platform_type + '</td>';
s += '<td>' + result[i].order_count + '</td>';
s += '<td> ' + result[i].amount_sales + '</td>';
s += '<td>' + result[i].cost_product + '</td>';
s += '<td>' + result[i].customerprice + '</td>';
s += '<td>' + result[i].cost_platform_fee + '</td>';
s += '<td>' + result[i].cost_fba_fee + '</td>';
s += '<td>' + result[i].cost_paypal_fee + '</td>';
s += '<td>' + result[i].cost_first + '</td>';
s += '<td>' + result[i].cost_tail + '</td>';
s += '<td>' + result[i].cost_handle_bailun + '</td>';
s += '<td>' + result[i].cost_handle_platform + '</td>';
s += '<td>' + result[i].adfee + '</td>';
s += '<td>' + result[i].putawayfee + '</td>';
s += '<td>' + result[i].amount_prepaid + '</td>';
s += '<td>' + result[i].noshippingcount + '</td>';
s += '<td>' + result[i].profit_total + '</td>';
s += '<td>' + result[i].profit_rate + '</td>';
//s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'退款金额\',\'amount_refund\',1)" title="查看订单明细">' + result[i].amount_refund + '</td>';
s += '<td>' + result[i].amount_refund + '</td>';
s += '<td>' + result[i].amount_refund_rate + '</td>';
$('#tb').append(s);
}
}
$("#roletable").trigger("destroy");
$("#roletable").tablesorter();
var i = result.length - 1;
if ('@ViewBag.statistictype' == 0) {
var foot_s = '<tr><td class="platform"><a href="javascript:;" onclick="ShowWebsite(\'' + result[i].platform_type + '\');">' + result[i].platform_type + '</a></td>';
foot_s += '<td class="skuprofit" onclick="ShowSkuProfit(\'\',\'订单数\',\'order_count\',0)" title="查看sku分类利润">' + result[i].order_count + '</td>';
foot_s += '<td><img style="width:16px;margin-left:3px" src="@Url.Content("~/img/chart-icon.png")" onclick="ShowChart(\'\',\'订单数\',\'order_count\');" title="点击查看曲线图"></td>';
foot_s += '<td class="skuprofit" onclick="ShowSkuProfit(\'\',\'销售额\',\'amount_sales\',0)" title="查看sku分类利润"> ' + result[i].amount_sales + '</td>';
foot_s += '<td><img style="width:16px;margin-left:3px" src="@Url.Content("~/img/chart-icon.png")" onclick="ShowChart(\'\',\'销售额\',\'amount_sales\');" title="点击查看曲线图"></td>';
foot_s += '<td class="skuprofit" onclick="ShowSkuProfit(\'\',\'产品成本\',\'cost_product\',1)" title="查看sku分类利润">' + result[i].cost_product + '</td>';
foot_s += '<td>' + result[i].customerprice + '</td>';
foot_s += '<td class="skuprofit" onclick="ShowSkuProfit(\'\',\'平台费用\',\'cost_platform_fee\',1)" title="查看sku分类利润">' + result[i].cost_platform_fee + '</td>';
foot_s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'FBA费\',\'cost_fba_fee\',1)">' + result[i].cost_fba_fee + '</td>';
foot_s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'PayPal费\',\'cost_paypal_fee\',1)">' + result[i].cost_paypal_fee + '</td>';
foot_s += '<td class="skuprofit" onclick="ShowSkuProfit(\'\',\'头程费\',\'cost_first\',1)" title="查看sku分类利润">' + result[i].cost_first + '</td>';
foot_s += '<td class="skuprofit" onclick="ShowSkuProfit(\'\',\'尾程费\',\'cost_tail\',1)" title="查看sku分类利润">' + result[i].cost_tail + '</td>';
foot_s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'处理费\',\'cost_handle_bailun\',1)">' + result[i].cost_handle_bailun + '</td>';
foot_s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'平台操作费\',\'cost_handle_platform\',1)">' + result[i].cost_handle_platform + '</td>';
foot_s += '<td>' + result[i].adfee + '</td>';
foot_s += '<td>' + result[i].putawayfee + '</td>';
foot_s += '<td class="skuprofit" onclick="ShowSkuProfit(\'\',\'预收款\',\'amount_prepaid\',1)" title="查看sku分类利润">' + result[i].amount_prepaid + '</td>';
foot_s += '<td class="skuprofit" onclick="ShowSkuProfit(\'\',\'预收订单数\',\'noshippingcount\',1)" title="查看sku分类利润">' + result[i].noshippingcount + '</td>';
foot_s += '<td class="skuprofit" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'利润\',\'profit_total\',1)">' + result[i].profit_total + '</td>';
foot_s += '<td><img style="width:16px;margin-left:3px" src="@Url.Content("~/img/chart-icon.png")" onclick="ShowChart(\'\',\'利润\',\'profit_total\');" title="点击查看曲线图"></td>';
foot_s += '<td>' + result[i].profit_rate + '</td>';
//foot_s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'退款金额\',\'amount_refund\',1)">' + result[i].amount_refund + '</td>';
foot_s += '<td>' + result[i].amount_refund + '</td>';
foot_s += '<td>' + result[i].amount_refund_rate + '</td>';
foot_s += '</tr>';
$('#footer').append(foot_s);
}
else if('@ViewBag.statistictype' == 2) {
var foot_s = '<tr><td class="platform">' + result[i].platform_type + '</td>';
foot_s += '<td>' + result[i].order_count + '</td>';
foot_s += '<td> ' + result[i].amount_sales + '</td>';
foot_s += '<td>' + result[i].cost_product + '</td>';
foot_s += '<td>' + result[i].customerprice + '</td>';
foot_s += '<td>' + result[i].cost_platform_fee + '</td>';
foot_s += '<td>' + result[i].cost_fba_fee + '</td>';
foot_s += '<td>' + result[i].cost_paypal_fee + '</td>';
foot_s += '<td>' + result[i].cost_first + '</td>';
foot_s += '<td>' + result[i].cost_tail + '</td>';
foot_s += '<td>' + result[i].cost_handle_bailun + '</td>';
foot_s += '<td>' + result[i].cost_handle_platform + '</td>';
foot_s += '<td>' + result[i].adfee + '</td>';
foot_s += '<td>' + result[i].putawayfee + '</td>';
foot_s += '<td>' + result[i].amount_prepaid + '</td>';
foot_s += '<td>' + result[i].noshippingcount + '</td>';
foot_s += '<td>' + result[i].profit_total + '</td>';
foot_s += '<td>' + result[i].profit_rate + '</td>';
//s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'退款金额\',\'amount_refund\',1)" title="查看订单明细">' + result[i].amount_refund + '</td>';
foot_s += '<td>' + result[i].amount_refund + '</td>';
foot_s += '<td>' + result[i].amount_refund_rate + '</td>';
$('#footer').append(foot_s);
}
else if('@ViewBag.statistictype' == 1) {
var foot_s = '<tr><td class="platform">' + result[i].platform_type + '</td>';
foot_s += '<td>' + result[i].order_count + '</td>';
foot_s += '<td> ' + result[i].amount_sales + '</td>';
foot_s += '<td>' + result[i].cost_product + '</td>';
foot_s += '<td>' + result[i].customerprice + '</td>';
foot_s += '<td>' + result[i].cost_platform_fee + '</td>';
foot_s += '<td>' + result[i].cost_fba_fee + '</td>';
foot_s += '<td>' + result[i].cost_paypal_fee + '</td>';
foot_s += '<td>' + result[i].cost_first + '</td>';
foot_s += '<td>' + result[i].cost_tail + '</td>';
foot_s += '<td>' + result[i].cost_handle_bailun + '</td>';
foot_s += '<td>' + result[i].cost_handle_platform + '</td>';
foot_s += '<td>' + result[i].adfee + '</td>';
foot_s += '<td>' + result[i].putawayfee + '</td>';
foot_s += '<td>' + result[i].amount_prepaid + '</td>';
foot_s += '<td>' + result[i].noshippingcount + '</td>';
foot_s += '<td>' + result[i].profit_total + '</td>';
foot_s += '<td>' + result[i].profit_rate + '</td>';
//s += '<td class="alink" onclick="ShowDetail(\'' + result[i].platform_type + '\',\'退款金额\',\'amount_refund\',1)" title="查看订单明细">' + result[i].amount_refund + '</td>';
foot_s += '<td>' + result[i].amount_refund + '</td>';
foot_s += '<td>' + result[i].amount_refund_rate + '</td>';
$('#footer').append(foot_s);
}
}
else {
$('#tb').html('');
$('#footer').html('');
layer.alert('没有找到相应数据!');
}
}
})
}
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>');
}
if ('@ViewBag.platform' != '') {
$('#platform').val('@ViewBag.platform');
listwebsite();
}
}
}
})
}
function listwebsite()
{
var p = $('#platform').val();
if (p == '') {
$('#website').html('<option value="">选择站点</option>');
return false;
}
$.submit({
url: '@Url.Content("~/Reports/Orders/ListWebSite")',
type:'POST',
paramData: 'platform=' + p,
func: function (result) {
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>');
}
if ('@ViewBag.website' != '') {
$('#website').val('@ViewBag.website');
}
}
}
})
}
function ShowWebsite(platform) {
if ('@(ViewBag.statistictype)' == 0) {
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%');
}
}
function ShowDetail(platform, coltitle, colval, single) {
if ('@(ViewBag.statistictype)' == 0) {
layer_show(platform + " " + $('#start').val() + "至" + $('#end').val() + ' 订单明细', '@Url.Content("~/Reports/Orders/ListOrderDetail?platform=")' + platform + '&start=' + $('#start').val() + '&end=' + $('#end').val() + '&col=' + colval + '&coltitle=' + coltitle + '&showsingle=' + single + '&shipstart=' + $('#shipstart').val() + '&shipend=' + $('#shipend').val(), '90%', '90%');
}
}
function ShowSkuProfit(platform, coltitle, colval) {
var start = $('#start').val();
var end = $('#end').val();
if ('@(ViewBag.statistictype)' == 0) {
layer_show(platform + " " + coltitle + " " + $('#start').val() + "至" + $('#end').val() + ' 的SKU分类利润', '@Url.Content("~/Reports/Orders/SkuCategoryProfit?start=")' + start + '&end=' + end + '&colname=' + colval + '&platform=' + platform + '&coltitle=' + coltitle, '95%', '95%');
}
}
function showleft() {
var c = $('#leftcontain').css('display');
if (c == 'none') {
$('#leftcontain').css('display', 'inline');
$("#rightcontain").animate({ marginLeft: "220px" });
}
else {
$('#leftcontain').css('display', 'none');
$("#rightcontain").animate({ marginLeft: "0px" });
}
}
function listcategory12()
{
$.submit({
url: '@Url.Content("~/Reports/Orders/ListSkuCategoryOneAndSecondLevel")',
paramData: '',
type: 'POST',
func: function (result) {
var setting = {
check: {
chkStyle:'checkbox',
enable: true
}
};
zTreeObj = $.fn.zTree.init($("#ztree"), setting, eval('('+result+')'));
}
})
}
function listsimplecategory() {
$.submit({
url: '@Url.Content("~/Home/ListSimpleCategory")',
paramData: '',
type: 'POST',
func: function (result) {
var setting = {
check: {
chkStyle: 'checkbox',
enable: true
}
};
zTreeObj = $.fn.zTree.init($("#ztree"), setting, result);
}
})
}
function getChkNode() {
var s = '';
var o = $.fn.zTree.getZTreeObj("ztree");
var nodes = o.getCheckedNodes();
for (var i in nodes) {
if (nodes[i].children == null || nodes[i].children.length <= 0) {
s += (nodes[i].id) + '|';
}
}
return s;
}
function ShowChart(platform, title, colval) {
var s = '';
try {
s = getChkNode();
} catch (e) {
s = '';
}
var shipstart = $('#shipstart').val();
var shipend = $('#shipend').val();
var start = $('#start').val();
var end = $('#end').val();
if (start == '' && end == '') {
layer.alert('请选择付款时间。');
return false;
}
layer_show(platform + " " + title+"曲线图", '@Url.Content("~/Reports/Orders/OrderProfitGraph?platform=")' + platform + '&start=' + $('#start').val() + '&end=' + $('#end').val() + '&col=' + colval + '&shipstart=' + $('#shipstart').val() + '&shipend=' + $('#shipend').val() + '&currency=' + $('#currency').val() + '&skucategoryids=' + s + '&titlename=' + title, '90%', '90%');
}
function skucategorychildren(categoryid, title) {
if (categoryid == 0) {
alert("抱歉,该分类在百伦新分类无法找到!");
return false;
}
var producttype = $("#producttype").ySelectedValues(",");
var shipstart = $('#shipstart').val();
var shipend = $('#shipend').val();
var start = $('#start').val();
var end = $('#end').val();
if ((shipstart != '' || shipend != '') && (start != '' || end != '')) {
layer.alert('搜索条件不能同时选择付款时间和发货时间,只能选其一。');
return false;
}
if (start == '' && end == '' && shipstart == '' && shipend == '') {
layer.alert('请选择时间进行搜索。');
return false;
}
var urlparam = $("#toolbar").serialize() + '&product_type=' + producttype + '&statistictype=@(ViewBag.statistictype)' + '&skunewcategory=' + categoryid;
layer_show(title + "的产品分类利润统计",'@Url.Content("~/Reports/Orders/SkuProfitCount?")'+urlparam,'95%','95%');
}
</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