Commit b3f7294d by guanzhenshan

优化发货策略筛选

parent d4285fe1
using System;
using System.Collections.Generic;
using System.Text;
namespace Bailun.DC.Models
{
public class dc_base_logistics_config
{
public int id { get; set; }
public string code { get; set; }
public string name { get; set; }
public int type { get; set; }
public DateTime createtime { get; set; }
}
}
......@@ -432,6 +432,28 @@ namespace Bailun.DC.Services
return obj;
}
}
/// <summary>
/// 获取物流方式配置
/// </summary>
/// <param name="type">1:专线</param>
/// <returns></returns>
public static List<dc_base_logistics_config> ListLogisticsConfig(int type)
{
using (var cn = new MySqlConnection(Common.GlobalConfig.ConnectionString))
{
if (cn.State == System.Data.ConnectionState.Closed)
{
cn.Open();
}
var obj = cn.Query<dc_base_logistics_config>("select * from dc_base_logistics_config where type="+1);
return obj.ToList();
}
}
}
#region 汇率实体 ExchangeRate
......
......@@ -1734,7 +1734,25 @@ namespace Bailun.DC.Services
if (shippingstrategy.HasValue) //1专线;2中国发货;3美国仓
{
if (shippingstrategy.Value != 1)
{
sql += " join dc_base_warehouse t20 on tb.warehouse_code = t20.warehouse_code ";
if (shippingstrategy.Value == 2) //中国发货
{
sql += " and t20.area_id=18 ";
}
else if (shippingstrategy.Value == 3) //海外仓
{
sql += " and t20.hq_type='第三方仓库' ";
}
else if (shippingstrategy.Value == 4) //FBA仓
{
sql += " and t20.hq_type='FBA仓' ";
}
}
}
}
......@@ -1742,6 +1760,22 @@ namespace Bailun.DC.Services
sql += " where tb.bailun_order_status!='Canceled' and ((tb.platform_type!='FBA' and tb.bailun_order_status!='CantHandle') or tb.platform_type='FBA') and tb.has_scalp=0 and tb.has_innersale=0 and tb.bailun_interception_status in ('None','Failed') ";
if (shippingstrategy.HasValue) //1专线;2中国发货;3美国仓
{
var listSpecialLogistics = CommonServices.ListLogisticsConfig(1);
if (shippingstrategy.Value == 1)
{
sql += " and tb.logistics_method_code in ('" + string.Join("','", listSpecialLogistics.Select(a => a.code)) + "')";
}
else if (shippingstrategy.Value == 2)
{
sql += " and tb.logistics_method_code not in ('" + string.Join("','", listSpecialLogistics.Select(a => a.code)) + "')";
}
}
if (companyid.HasValue && companyid.Value > 0)
{
sql += " and tb.company_id=" + companyid.Value; //增加公司id过滤
......@@ -1823,20 +1857,47 @@ 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, int[] producttype, int? skusource, int? shippingstrategy)
{
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_logistics*" + (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,sum(t2.cost_fba_fee*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) cost_fba_fee,sum(t2.cost_paypal_fee*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) cost_paypal_fee,sum(t2.amount_shipping*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) amount_shipping,sum(t2.cost_promotion*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) cost_promotion from (select id,bailun_order_id,quantity_shipped,bailun_sku from dc_base_oms_pick where has_delete=0 and shipping_status = 'TotalShipping' ";
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_logistics*" + (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,sum(t2.cost_fba_fee*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) cost_fba_fee,sum(t2.cost_paypal_fee*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) cost_paypal_fee,sum(t2.amount_shipping*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) amount_shipping,sum(t2.cost_promotion*" + (isUSD ? "t2.order_to_usd_exchange_rate" : "t2.seller_order_exchange_rate") + "*t1.quantity_shipped) cost_promotion from (select t0.id,t0.bailun_order_id,t0.quantity_shipped,t0.bailun_sku from dc_base_oms_pick t0 ";
var tempsql = "";
if (shippingstrategy.HasValue) //1专线;2中国发货;3海外仓 4 FBA仓
{
var listSpecialLogistics = CommonServices.ListLogisticsConfig(1);
if (shippingstrategy.Value == 1) //专线
{
tempsql = " and t0.logistics_order_id in ('" + string.Join("','", listSpecialLogistics.Select(a => a.code)) + "') ";
}
else if (shippingstrategy.Value == 2) //中国发货
{
sql += " join dc_base_warehouse t2 on t0.warehouse_code=t2.warehouse_code and t2.area_id=18 ";
tempsql = " and t0.logistics_order_id not in ('" + string.Join("','", listSpecialLogistics.Select(a => a.code)) + "') ";
}
else if (shippingstrategy.Value == 3) //海外仓
{
sql += " join dc_base_warehouse t2 on t0.warehouse_code=t2.warehouse_code and t2.hq_type='第三方仓库' ";
}
else if (shippingstrategy.Value == 4) //FBA仓
{
sql += " join dc_base_warehouse t2 on t0.warehouse_code=t2.warehouse_code and t2.hq_type='FBA仓' ";
}
}
sql += " where t0.has_delete=0 and t0.shipping_status = 'TotalShipping'"+ tempsql;
if (companyid.HasValue && companyid.Value > 0)
{
sql += " and company_id=" + companyid.Value; //增加公司id过滤
sql += " and t0.company_id=" + companyid.Value; //增加公司id过滤
}
if (shipstart.HasValue)
{
sql += " and shipping_time>='" + shipstart.Value.ToString("yyyy-MM-dd") + "'";
sql += " and t0.shipping_time>='" + shipstart.Value.ToString("yyyy-MM-dd") + "'";
}
if (shipend.HasValue)
{
sql += " and shipping_time<'" + shipend.Value.AddDays(1).ToString("yyyy-MM-dd") + "'";
sql += " and t0.shipping_time<'" + shipend.Value.AddDays(1).ToString("yyyy-MM-dd") + "'";
}
sql += " ) t1 ";
......@@ -1856,12 +1917,6 @@ namespace Bailun.DC.Services
{
sql += " and t10.source="+skusource;
}
if (shippingstrategy.HasValue) //1专线;2中国发货;3美国仓
{
}
}
if (!string.IsNullOrWhiteSpace(platform))
......
......@@ -1790,7 +1790,7 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
}).ToList();
var objEbay = list.Where(a => a.platform_type == "Ebay").FirstOrDefault();
if (objEbay != null && list.Count > 3)
if (objEbay != null && list.Count > 4)
{
list.Remove(objEbay);
list.Insert(3, objEbay);
......
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