Commit af15ca54 by guanzhenshan

1、解决数据中心数据仓监控状态错误的问题;2、解决数据中心平台利润统计报表按发货时间查询慢的问题

parent 7ad5af44
...@@ -1145,6 +1145,8 @@ namespace Bailun.DC.Services ...@@ -1145,6 +1145,8 @@ namespace Bailun.DC.Services
} }
public List<Models.Orders.dc_base_oms_order> ListPlatformFeeAbnormal(BtTableParameter parameter, string platform, string account, string website, string orderno, DateTime? start, DateTime? end,int? companyid, ref int total,string skucategoryids) public List<Models.Orders.dc_base_oms_order> ListPlatformFeeAbnormal(BtTableParameter parameter, string platform, string account, string website, string orderno, DateTime? start, DateTime? end,int? companyid, ref int total,string skucategoryids)
{ {
var sqlparam = new DynamicParameters(); var sqlparam = new DynamicParameters();
...@@ -1473,13 +1475,25 @@ namespace Bailun.DC.Services ...@@ -1473,13 +1475,25 @@ namespace Bailun.DC.Services
public List<Models.Orders.dc_base_oms_sku> ListPlatformProfitByShipTime(string platform,string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, bool isUSD, int? companyid, string skucategoryids) public List<Models.Orders.dc_base_oms_sku> ListPlatformProfitByShipTime(string platform,string website, DateTime? start, DateTime? end, DateTime? shipstart, DateTime? shipend, bool isUSD, int? companyid, string skucategoryids)
{ {
var sqlparam = new DynamicParameters(); var sqlparam = new DynamicParameters();
var sql = @"select t2.platform_type,count(DISTINCT t2.bailun_order_id) order_count,sum(t2.amount_sales*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) as amount_sales,sum(t2.cost_platform_fee*(if(t2.platform_type='Ebay'," + (isUSD ? "t2.other_to_usd_exchange_rate" : "t2.seller_other_exchange_rate") + "," + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "))*t1.quantity_shipped) as cost_platform_fee,sum(t2.cost_first*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) as cost_first,sum(t2.cost_tail*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_tail,sum(t2.cost_handle_bailun*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_handle_bailun,sum(t2.cost_handle_platform*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_handle_platform,sum(t2.amount_refund*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) amount_refund,sum(t2.cost_product*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_product,sum(t2.profit_total*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) profit_total,(sum(t2.profit_total*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped)/sum(t2.amount_sales*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped)) profit_rate,count(t2.amount_prepaid>0 or null) as noshippingcount,sum(t2.amount_prepaid*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) amount_prepaid from dc_base_oms_pick t1"; var sql = @"select t2.platform_type,count(DISTINCT t2.bailun_order_id) order_count,sum(t2.amount_sales*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) as amount_sales,sum(t2.cost_platform_fee*(if(t2.platform_type='Ebay'," + (isUSD ? "t2.other_to_usd_exchange_rate" : "t2.seller_other_exchange_rate") + "," + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "))*t1.quantity_shipped) as cost_platform_fee,sum(t2.cost_first*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) as cost_first,sum(t2.cost_tail*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_tail,sum(t2.cost_handle_bailun*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_handle_bailun,sum(t2.cost_handle_platform*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_handle_platform,sum(t2.amount_refund*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) amount_refund,sum(t2.cost_product*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) cost_product,sum(t2.profit_total*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) profit_total,(sum(t2.profit_total*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped)/sum(t2.amount_sales*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped)) profit_rate,count(t2.amount_prepaid>0 or null) as noshippingcount,sum(t2.amount_prepaid*" + (isUSD ? "t2.cny_to_usd_exchange_rate" : "1") + "*t1.quantity_shipped) amount_prepaid from (select id,bailun_order_id,quantity_shipped from dc_base_oms_pick where has_delete=0 and shipping_status = 'TotalShipping' ";
sql += " join dc_base_oms_sku t2 on t1.bailun_order_id = t2.bailun_order_id and t2.bailun_order_status != 'Canceled' and t2.has_scalp = 0 and t2.bailun_order_status != 'CantHandle' and t2.has_scalp = 0 and t2.has_innersale = 0 ";
//where t1.shipping_status = 'TotalShipping' and t1.shipping_time >= '2019-06-14' and t1.shipping_time < '2019-06-15' and t1.company_id = 1
//GROUP BY t2.platform_type";
if (companyid.HasValue && companyid.Value > 0)
{
sql += " and company_id=" + companyid.Value; //增加公司id过滤
}
if (shipstart.HasValue)
{
sql += " and shipping_time>='" + shipstart.Value.ToString("yyyy-MM-dd") + "'";
}
if (shipend.HasValue)
{
sql += " and shipping_time<'" + shipend.Value.AddDays(1).ToString("yyyy-MM-dd") + "'";
}
sql += " ) t1 ";
sql += " join dc_base_oms_sku t2 on t1.bailun_order_id = t2.bailun_order_id and t2.bailun_order_status != 'Canceled' and t2.has_scalp = 0 and t2.bailun_order_status != 'CantHandle' and t2.has_scalp = 0 and t2.has_innersale = 0 ";
//var sql = "select tb.platform_type,count(tb.bailun_order_id) order_count,sum(tb.amount_sales*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ") as amount_sales,sum(tb.cost_platform_fee*(if(tb.platform_type='Ebay'," + (isUSD ? "tb.other_to_usd_exchange_rate" : "tb.seller_other_exchange_rate") + "," + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + "))) as cost_platform_fee,sum(cost_first*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") as cost_first,sum(cost_tail*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") cost_tail,sum(cost_handle_bailun*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") cost_handle_bailun,sum(cost_handle_platform*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") cost_handle_platform,sum(amount_refund*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ") amount_refund,sum(cost_product*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") cost_product,sum(profit_total*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") profit_total,(sum(profit_total*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ")/sum(tb.amount_sales*" + (isUSD ? "tb.order_to_usd_exchange_rate" : "tb.seller_order_exchange_rate") + ")) profit_rate,count(amount_prepaid>0 or null) as noshippingcount,sum(amount_prepaid*" + (isUSD ? "tb.cny_to_usd_exchange_rate" : "1") + ") amount_prepaid from dc_base_oms_order tb ";
if (!string.IsNullOrWhiteSpace(skucategoryids)) if (!string.IsNullOrWhiteSpace(skucategoryids))
{ {
...@@ -1503,21 +1517,11 @@ namespace Bailun.DC.Services ...@@ -1503,21 +1517,11 @@ namespace Bailun.DC.Services
} }
} }
var strwhere = " where t1.has_delete=0 and t1.shipping_status = 'TotalShipping' ";
if (shipstart.HasValue)
{
strwhere += " and t1.shipping_time>='" + shipstart.Value.ToString("yyyy-MM-dd") + "'";
}
if (shipend.HasValue)
{
strwhere += " and t1.shipping_time<'" + shipend.Value.AddDays(1).ToString("yyyy-MM-dd") + "'";
}
if (companyid.HasValue && companyid.Value > 0) if (companyid.HasValue && companyid.Value > 0)
{ {
strwhere += " and t1.company_id=" + companyid.Value; //增加公司id过滤 //strwhere += " and t1.company_id=" + companyid.Value; //增加公司id过滤
sql += " and t2.company_id=" + companyid.Value; //增加公司id过滤 sql += " and t2.company_id=" + companyid.Value; //增加公司id过滤
} }
...@@ -1546,6 +1550,8 @@ namespace Bailun.DC.Services ...@@ -1546,6 +1550,8 @@ namespace Bailun.DC.Services
sqlparam.Add("paid_time_end", end.Value.AddDays(1)); sqlparam.Add("paid_time_end", end.Value.AddDays(1));
} }
var strwhere = " ";
strwhere += " group by t2.platform_type"; strwhere += " group by t2.platform_type";
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString)) using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
......
...@@ -34,7 +34,7 @@ namespace Bailun.DC.Services ...@@ -34,7 +34,7 @@ namespace Bailun.DC.Services
var sqlparams = new DynamicParameters(); var sqlparams = new DynamicParameters();
var sql = @"select t2.hq_type as warehousetype,t2.warehouse_name as warehousename,t2.warehouse_code,t1.bailun_sku as sku,t3.category_id,t3.category_name,t3.sku_title_cn as skuname,(case when t4.status=0 then 1 else 2 end) monitorstatus,t5.clearancestatus,t5.tortstatus,t5.str_skutag,t3.unit_price as buyprice,t1.usable_stock,(t1.usable_stock*t3.unit_price) amount_stock,t6.quantity_purchase,(t6.quantity_purchase*t3.unit_price) as purchase_amount,t6.quantity_transfer,(t6.quantity_transfer*t3.unit_price) amount_transit,t6.quantity_out_stock,t7.oneday_total_sales,(t7.oneday_total_sales*t3.unit_price) as amount_onedaysale,t7.sevenday_total_sales,(t7.sevenday_total_sales*t3.unit_price) amount_sevendaysale,t7.fourteenday_total_sales,t7.thirtyday_total_sales,t7.sevenday_average_sales,t7.fourteenday_average_sales,t7.thirtyday_average_sales,t3.create_time as skucreatetime,t2.area_id,t2.area_name,t5.groupname,t6.quantity_unshipped var sql = @"select t2.hq_type as warehousetype,t2.warehouse_name as warehousename,t2.warehouse_code,t1.bailun_sku as sku,t3.category_id,t3.category_name,t3.sku_title_cn as skuname,(case when t4.status=1 then 0 else 1 end) status,t5.clearancestatus,t5.tortstatus,t5.str_skutag,t3.unit_price as buyprice,t1.usable_stock,(t1.usable_stock*t3.unit_price) amount_stock,t6.quantity_purchase,(t6.quantity_purchase*t3.unit_price) as purchase_amount,t6.quantity_transfer,(t6.quantity_transfer*t3.unit_price) amount_transit,t6.quantity_out_stock,t7.oneday_total_sales,(t7.oneday_total_sales*t3.unit_price) as amount_onedaysale,t7.sevenday_total_sales,(t7.sevenday_total_sales*t3.unit_price) amount_sevendaysale,t7.fourteenday_total_sales,t7.thirtyday_total_sales,t7.sevenday_average_sales,t7.fourteenday_average_sales,t7.thirtyday_average_sales,t3.create_time as skucreatetime,t2.area_id,t2.area_name,t5.groupname,t6.quantity_unshipped
from dc_base_stock t1 from dc_base_stock t1
left join dc_base_warehouse t2 on t1.warehouse_code=t2.warehouse_code left join dc_base_warehouse t2 on t1.warehouse_code=t2.warehouse_code
left join dc_base_sku t3 on t1.bailun_sku=t3.bailun_sku left join dc_base_sku t3 on t1.bailun_sku=t3.bailun_sku
......
...@@ -1042,7 +1042,6 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers ...@@ -1042,7 +1042,6 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
"ExtendedDurationFee", "ExtendedDurationFee",
"FeeAuctionEndEarly", "FeeAuctionEndEarly",
"FeeBold", "FeeBold",
"FeeFinalValueShipping",
"FeeGalleryPlus", "FeeGalleryPlus",
"FeeInsertion", "FeeInsertion",
"FeeLargePicture", "FeeLargePicture",
......
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