Commit 963161ce by guanzhenshan

非FBA销售统计增加处理费用字段显示,平台利润统计明细增加导出功能

parent 5696bbf3
...@@ -6,6 +6,7 @@ using Bailun.DC.DB; ...@@ -6,6 +6,7 @@ using Bailun.DC.DB;
using Dapper; using Dapper;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using Bailun.DC.Models.Stock; using Bailun.DC.Models.Stock;
using MySql.Data;
namespace Bailun.DC.Services namespace Bailun.DC.Services
{ {
...@@ -153,6 +154,7 @@ namespace Bailun.DC.Services ...@@ -153,6 +154,7 @@ namespace Bailun.DC.Services
} }
var liststock = cn.Query<Models.Warehouse.mStock>("select bailun_sku,warehouse_code,usable_stock from dc_base_stock"); var liststock = cn.Query<Models.Warehouse.mStock>("select bailun_sku,warehouse_code,usable_stock from dc_base_stock");
var tb = new System.Data.DataTable();
foreach (var item in liststock) foreach (var item in liststock)
{ {
try try
...@@ -217,13 +219,52 @@ namespace Bailun.DC.Services ...@@ -217,13 +219,52 @@ namespace Bailun.DC.Services
m.createtime = DateTime.Now; m.createtime = DateTime.Now;
m.day = DateTime.Now.AddDays(-1); m.day = DateTime.Now.AddDays(-1);
cn.Insert<Models.Warehouse.dc_mid_skuwarehouse_redundancy>(m); //MySqlBulkLoader loader = new MySqlBulkLoader(cn);
var row = tb.NewRow();
row["bailun_sku"] = item.bailun_sku;
row["bailun_sku_name"] = objsku.sku_title_cn;
row["warehouse_code"] = item.warehouse_code;
row["warehouse_name"] = objWarehouse.warehouse_name;
row["productcount"] = item.usable_stock;
row["amount_total"] = item.usable_stock * objsku.unit_price;
row["daily_productsale_count"] = obj7SaleAvg ?? 0;
row["dailysale_amount"] = (obj7SaleAvg ?? 0) * objsku.unit_price;
row["productsale_rate"] = item.usable_stock > 0 ? (obj7SaleAvg ?? 0) / item.usable_stock * 7 : 0;
row["saleamount_rate"] = item.usable_stock > 0 ? (obj7SaleAvg ?? 0) / item.usable_stock * 7 : 0;
row["redundancy_product_count"] = objRedundancy ?? 0;
row["redundancy_product_rate"] = item.usable_stock > 0 ? (objRedundancy ?? 0) / item.usable_stock : 0;
row["redundancy_amount"] = (objRedundancy ?? 0) * objsku.unit_price;
row["redundancy_amount_rate"] = item.usable_stock > 0 ? (objRedundancy ?? 0) / item.usable_stock : 0;
row["yesterdaysale_amount"] = (objYesterdaySale ?? 0) * objsku.unit_price;
row["yesterdaysale_count"] = (objYesterdaySale ?? 0);
row["sale_3d_avg"] = (obj3SaleAvg ?? 0) / 3;
row["sale_7d_avg"] = (obj7SaleAvg ?? 0) / 7;
row["sale_14d_avg"] = (obj14SaleAvg ?? 0) / 14;
row["sale_30d_avg"] = (obj30SaleAvg ?? 0) / 30;
row["day_turnover_rate"] = item.usable_stock > 0 ? objYesterdaySale ?? 0 / item.usable_stock : 0;
row["week_turnover_rate"] = item.usable_stock > 0 ? (obj7SaleAvg ?? 0) / item.usable_stock * 7 : 0;
row["month_turnover_rate"] = item.usable_stock > 0 ? (obj30SaleAvg ?? 0) / item.usable_stock * 30 : 0;
row["stockout"] = objStockout ?? 0;
row["createtime"] = DateTime.Now;
row["day"] = DateTime.Now.AddDays(-1);
tb.Rows.Add(row);
} }
catch (Exception ex) catch (Exception ex)
{ {
} }
} }
} }
return ""; return "";
......
...@@ -166,11 +166,11 @@ namespace Bailun.DC.Services ...@@ -166,11 +166,11 @@ namespace Bailun.DC.Services
/// <param name="end">付款结束时间</param> /// <param name="end">付款结束时间</param>
/// <param name="total">符合条件的记录数</param> /// <param name="total">符合条件的记录数</param>
/// <returns></returns> /// <returns></returns>
public List<Models.Orders.mAmazonStatistics> ListAmazonStatistics(BtTableParameter parameter, string account, string website, DateTime start, DateTime end,string warehoursetype,string warehousecode, ref int total) public List<dc_base_oms_order> ListAmazonStatistics(BtTableParameter parameter, string account, string website, DateTime start, DateTime end,string warehoursetype,string warehousecode, ref int total)
{ {
var sqlparam = new DynamicParameters(); var sqlparam = new DynamicParameters();
var sql = @"select platform_type,seller_account,website,sum(amount_sales*seller_order_exchange_rate) 'amount_product',sum(cost_product) 'cost_product',sum(cost_platform_fee*seller_order_exchange_rate) 'platform_fee',sum(cost_first) 'head_fee',count(t1.id) 'order_count',sum(cost_total) 'cost_count',sum(cost_tail) 'nofba_logisticsfee',sum(profit_total) 'profit_count',(sum(profit_total)/sum(amount_sales*seller_order_exchange_rate)) 'profit_rate',sum(amount_prepaid) amount_prepaid,sum(amount_refund*seller_order_exchange_rate) amount_refund,count(amount_prepaid>0 or null) as noshippingcount from dc_base_oms_order t1"; var sql = @"select platform_type,seller_account,website,sum(amount_sales*seller_order_exchange_rate) 'amount_sales',sum(cost_product) 'cost_product',sum(cost_platform_fee*seller_order_exchange_rate) 'cost_platform_fee',sum(cost_first) 'cost_first',count(t1.id) 'order_count',sum(cost_total) 'cost_total',sum(cost_logistics) 'cost_logistics',sum(profit_total) 'profit_total',(sum(profit_total)/sum(amount_sales*seller_order_exchange_rate)) 'profit_rate',sum(amount_prepaid) amount_prepaid,sum(amount_refund*seller_order_exchange_rate) amount_refund,count(amount_prepaid>0 or null) as noshippingcount,sum(cost_handle_bailun) cost_handle_bailun,sum(cost_handle_platform) cost_handle_platform from dc_base_oms_order t1";
var presql = "select platform_type,seller_account,website,sum(amount_prepaid) as amount_prepaid from dc_base_oms_sku t1 "; var presql = "select platform_type,seller_account,website,sum(amount_prepaid) as amount_prepaid from dc_base_oms_sku t1 ";
if (!string.IsNullOrEmpty(warehoursetype)) if (!string.IsNullOrEmpty(warehoursetype))
...@@ -225,26 +225,26 @@ namespace Bailun.DC.Services ...@@ -225,26 +225,26 @@ namespace Bailun.DC.Services
cn.Open(); cn.Open();
} }
var obj = cn.Page<Models.Orders.mAmazonStatistics>(parameter.pageIndex, parameter.limit, sql+fromsql, ref total, sqlparam); var obj = cn.Page<dc_base_oms_order>(parameter.pageIndex, parameter.limit, sql+fromsql, ref total, sqlparam);
//另外计算预收款金额 //另外计算预收款金额
var list = obj.AsList(); //var list = obj.AsList();
prefromsql+= " and bailun_sku_quantity_shipped<=0"; //prefromsql+= " and bailun_sku_quantity_shipped<=0";
prefromsql += " and seller_account in ('" + string.Join("','", list.Select(a => a.seller_account)) + "') and website in ('" + string.Join("','", list.Select(a => a.website)) + "')"; //prefromsql += " and seller_account in ('" + string.Join("','", list.Select(a => a.seller_account)) + "') and website in ('" + string.Join("','", list.Select(a => a.website)) + "')";
prefromsql += " group by seller_account,website,platform_type"; //prefromsql += " group by seller_account,website,platform_type";
var obj1 = cn.Query<Models.Orders.mAmazonStatistics>(presql+prefromsql,sqlparam); //var obj1 = cn.Query<Models.Orders.mAmazonStatistics>(presql+prefromsql,sqlparam);
foreach (var item in list) //foreach (var item in list)
{ //{
var temp = obj1.Where(a => a.seller_account == item.seller_account && a.website == item.website && a.platform_type == item.platform_type).FirstOrDefault(); // var temp = obj1.Where(a => a.seller_account == item.seller_account && a.website == item.website && a.platform_type == item.platform_type).FirstOrDefault();
if (temp != null) // if (temp != null)
{ // {
item.amount_prepaid = temp.amount_prepaid; // item.amount_prepaid = temp.amount_prepaid;
} // }
} //}
return list; return obj.ToList();
} }
} }
...@@ -259,12 +259,12 @@ namespace Bailun.DC.Services ...@@ -259,12 +259,12 @@ namespace Bailun.DC.Services
/// <param name="end">付款结束时间</param> /// <param name="end">付款结束时间</param>
/// <param name="total">符合条件的记录数</param> /// <param name="total">符合条件的记录数</param>
/// <returns></returns> /// <returns></returns>
public Models.Orders.mAmazonStatistics ListAmazonStatisticsCount(string account, string website, DateTime start, DateTime end,string warehoursetype,string warehousecode) public dc_base_oms_order ListAmazonStatisticsCount(string account, string website, DateTime start, DateTime end,string warehoursetype,string warehousecode)
{ {
var sqlparam = new DynamicParameters(); var sqlparam = new DynamicParameters();
var presql = "select sum(amount_prepaid) as amount_prepaid from dc_base_oms_sku t1 "; var presql = "select sum(amount_prepaid) as amount_prepaid from dc_base_oms_sku t1 ";
var sql = "select sum(amount_sales*seller_order_exchange_rate) 'amount_product',sum(cost_product) 'cost_product',sum(cost_platform_fee*seller_order_exchange_rate) 'platform_fee',sum(cost_first) 'head_fee',count(t1.id) 'order_count',sum(cost_total) 'cost_count',sum(cost_tail) 'nofba_logisticsfee',sum(profit_total) 'profit_count',(sum(profit_total)/sum(amount_sales*seller_order_exchange_rate)) 'profit_rate',sum(amount_prepaid) amount_prepaid,sum(amount_refund*seller_order_exchange_rate) amount_refund,count(amount_prepaid>0 or null) as noshippingcount from dc_base_oms_order t1 "; var sql = "select sum(amount_sales*seller_order_exchange_rate) 'amount_sales',sum(cost_product) 'cost_product',sum(cost_platform_fee*seller_order_exchange_rate) 'cost_platform_fee',sum(cost_first) 'cost_first',count(t1.id) 'order_count',sum(cost_total) 'cost_total',sum(cost_logistics) 'cost_logistics',sum(profit_total) 'profit_total',(sum(profit_total)/sum(amount_sales*seller_order_exchange_rate)) 'profit_rate',sum(amount_prepaid) amount_prepaid,sum(amount_refund*seller_order_exchange_rate) amount_refund,count(amount_prepaid>0 or null) as noshippingcount,sum(cost_handle_bailun) cost_handle_bailun,sum(cost_handle_platform) cost_handle_platform from dc_base_oms_order t1 ";
if (!string.IsNullOrEmpty(warehoursetype)) if (!string.IsNullOrEmpty(warehoursetype))
{ {
...@@ -314,22 +314,14 @@ namespace Bailun.DC.Services ...@@ -314,22 +314,14 @@ namespace Bailun.DC.Services
try try
{ {
var obj = cn.QueryFirst<Models.Orders.mAmazonStatistics>(sql+fromsql, sqlparam); var obj = cn.QueryFirst<dc_base_oms_order>(sql+fromsql, sqlparam);
prefromsql += " and bailun_sku_quantity_shipped<=0";
var obj1 = cn.QueryFirst<Models.Orders.mAmazonStatistics>(presql + prefromsql, sqlparam);
if (obj1 != null && obj!=null)
{
obj.amount_prepaid = obj1.amount_prepaid;
}
return obj; return obj;
} }
catch (Exception ex) catch (Exception ex)
{ {
return new Models.Orders.mAmazonStatistics(); return new Models.Orders.dc_base_oms_order();
} }
} }
} }
......
...@@ -104,8 +104,8 @@ ...@@ -104,8 +104,8 @@
}, },
{ field: 'website', title: '站点', width: '80', sortable: false, iscount: true }, { field: 'website', title: '站点', width: '80', sortable: false, iscount: true },
{ {
field: 'amount_product', title: '销售额', width: '100', sortable: true, iscount: true, formatter: function (idx, data) { field: 'amount_sales', title: '销售额', width: '100', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'商品收入\',\'amount_product\',1)">' + data.amount_product + '</span>'; return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'销售额\',\'amount_sales\',1)">' + data.amount_sales + '</span>';
} }
}, },
{ {
...@@ -119,24 +119,34 @@ ...@@ -119,24 +119,34 @@
} }
}, },
{ {
field: 'platform_fee', title: '平台佣金费', width: '110', sortable: true, iscount: true, formatter: function (idx, data) { field: 'cost_platform_fee', title: '平台佣金费', width: '110', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'平台佣金费\',\'cost_platform_fee\',1)">' + data.platform_fee + '</span>'; return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'平台佣金费\',\'cost_platform_fee\',1)">' + data.cost_platform_fee + '</span>';
} }
}, },
{ {
field: 'head_fee', title: '头程费', width: '100', sortable: true, iscount: true, formatter: function (idx, data) { field: 'cost_first', title: '头程费', width: '100', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'头程费\',\'cost_first\',1)">' + data.head_fee + '</span>'; return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'头程费\',\'cost_first\',1)">' + data.cost_first + '</span>';
} }
}, },
{ field: 'loss_withdrawal', title: '提现损耗', width: '100', sortable: false, iscount: true }, { field: 'loss_withdrawal', title: '提现损耗', width: '100', sortable: false, iscount: true },
{ {
field: 'cost_count', title: '总支出', width: '110', sortable: true, iscount: true, formatter: function (idx, data) { field: 'cost_logistics', title: '尾程费', width: '110', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'总支出\',\'cost_total\',1)">' + data.cost_count + '</span>'; return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'尾程费\',\'cost_logistics\',1)">' + data.cost_logistics + '</span>';
} }
}, },
{ {
field: 'nofba_logisticsfee', title: '实际物流费', width: '110', sortable: true, iscount: true, formatter: function (idx, data) { field: 'cost_handle_bailun', title: '处理费(百伦)', width: '130', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'实际物流费\',\'cost_shipping\',1)">' + data.nofba_logisticsfee + '</span>'; return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'处理费(百伦)\',\'cost_handle_bailun\',1)">' + data.cost_handle_bailun + '</span>';
}
},
{
field: 'cost_handle_platform', title: '平台操作费', width: '130', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'平台操作费\',\'cost_handle_platform\',1)">' + data.cost_handle_platform + '</span>';
}
},
{
field: 'cost_total', title: '总支出', width: '110', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'总支出\',\'cost_total\',1)">' + data.cost_total + '</span>';
} }
}, },
{ {
...@@ -154,8 +164,8 @@ ...@@ -154,8 +164,8 @@
}, },
//{ field: 'forecast_profit_rate', title: '预测利润率%', width: '120', sortable: true }, //{ field: 'forecast_profit_rate', title: '预测利润率%', width: '120', sortable: true },
{ {
field: 'profit_count', title: '实际利润', width: '120', sortable: true, iscount: true, formatter: function (idx, data) { field: 'profit_total', title: '实际利润', width: '120', sortable: true, iscount: true, formatter: function (idx, data) {
return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'实际利润\',\'profit_total\',1)">' + data.profit_count + '</span>'; return '<span class="alink" onclick="ShowDetail(\'' + data.platform_type + '\',\'' + data.website + '\',\'' + data.seller_account + '\',\'实际利润\',\'profit_total\',1)">' + data.profit_total + '</span>';
} }
}, },
{ field: 'profit_rate', title: '总实际利润率%', width: '130', sortable: true, iscount: true }, { field: 'profit_rate', title: '总实际利润率%', width: '130', sortable: true, iscount: true },
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
<div class="form-group"> <div class="form-group">
<label>&nbsp;</label> <label>&nbsp;</label>
<button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button> <button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button>
<button type="button" class="btn btn-success" onclick="exportxls();">导出</button>
</div> </div>
</div> </div>
</form> </form>
...@@ -70,6 +71,8 @@ ...@@ -70,6 +71,8 @@
<script src="~/js/bootstrap-table-fixed-columns.js" type="text/javascript"></script> <script src="~/js/bootstrap-table-fixed-columns.js" type="text/javascript"></script>
<script type="text/javascript"> <script type="text/javascript">
var tb; var tb;
var isdoneplatform = false, isdoneaccount = false, isdonewebsite = false;
var objTime;
$(document).ready(function () { $(document).ready(function () {
laydate.render({ elem: '#start' }); laydate.render({ elem: '#start' });
laydate.render({ elem: '#end' }); laydate.render({ elem: '#end' });
...@@ -80,8 +83,15 @@ ...@@ -80,8 +83,15 @@
var height = document.body.clientHeight; var height = document.body.clientHeight;
$("#roletable").attr("data-height", (height - 170)); $("#roletable").attr("data-height", (height - 170));
listAccount();
listPlatform(); listPlatform();
objTime = setInterval(function () {
if (isdoneaccount && isdoneplatform && isdonewebsite) {
list();
clearInterval(objTime);
}
}, 1000);
}) })
function list() { function list() {
...@@ -178,8 +188,9 @@ ...@@ -178,8 +188,9 @@
} }
$('#platform').val('@ViewBag.platform'); $('#platform').val('@ViewBag.platform');
listWebsite(); listWebsite();
listAccount();
isdoneplatform = true;
} }
} }
}) })
...@@ -200,8 +211,7 @@ ...@@ -200,8 +211,7 @@
} }
$('#website').val('@ViewBag.website'); $('#website').val('@ViewBag.website');
isdonewebsite = true;
listAccount();
} }
} }
}) })
...@@ -220,13 +230,16 @@ ...@@ -220,13 +230,16 @@
} }
$('#account').val('@ViewBag.account'); $('#account').val('@ViewBag.account');
isdoneaccount = true;
list();
} }
} }
}) })
} }
function exportxls() {
window.open('@Url.Content("~/Reports/Orders/ExportListOrderDetail?")' + $("#toolbar").serialize(), '_blank');
}
</script> </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