Commit ebaf26e1 by 泽锋 李

旧品30天内之出一单的,不备货;新品出一单时,只补缺货

parent f95437a6
......@@ -452,7 +452,7 @@ where t1.bailun_sku = t2.bailun_sku and t1.gmt_modified>=@btime ;
Console.WriteLine("开始出建议");
// 生成采购建议 (只补缺货的不管)
var datas1 = MyMySqlConnection._connection.Query<dc_auto_purchase_advise_detailed>(@"select * from (
var datas3 = MyMySqlConnection._connection.Query<dc_auto_purchase_advise_detailed>(@"select * from (
select
t1.bailun_sku,
CONCAT(t1.bailun_sku,(case when t8.group_id=2 then 'GZBLWH' else t1.warehouse_code end )) as 'bailun_sku_warehouse_code',
......@@ -512,7 +512,8 @@ t9.quantity_transfer_temporary_storage as 'quantity_transfer_temporary_storage',
t1.first_order_date as 'first_order_date',
t1.first_order_bailun_order_id as 'first_order_bailun_order_id',
t1.is_mother_sku as 'is_mother_map_sku',
t1.daily_weighted_sales as 'fixed_daily_weighted_sales'
t1.daily_weighted_sales as 'fixed_daily_weighted_sales',
t1.quantity_out_stock as 'fixed_quantity_out_stock'
from (select * from dc_auto_turnover where gmt_modified>=@btime ) as t1
left join dc_auto_sales as t2 on t1.bailun_sku = t2.bailun_sku and t1.warehouse_code = t2.warehouse_code
left join dc_auto_config_sku_warehouse as t5 on t1.bailun_sku = t5.bailun_sku and t1.warehouse_code = t5.warehouse_code
......@@ -538,6 +539,9 @@ and ( t5.`status`=0 or t5.`status` is null ) and t7.sum_quantity_init_advise>0
", new { main_id = mainID, btime = date }, commandTimeout: 0).ToList();
Console.WriteLine("开始出建议 完");
// 旧品30天内只有1单,不备货;新品只出过单则只出缺货
var datas1 = OldProductCalculation(datas3);
if (datas1 != null && datas1.Count >= 1)
{
var datas2 = SetMotherSkuStorageCapacity(datas1);
......@@ -1125,14 +1129,11 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse
{
//物流切换拆分
var datas = LogisticsChangeSplit(originalDatas);
foreach (var item in datas)
{
item.bailun_sku_warehouse_code = $"{item.bailun_sku}{item.warehouse_code}";
if (item.bailun_sku_warehouse_code == "948801701CHUKFBA")
{
}
item.create_time = DateTime.Now;
// 查询是否有未过期 未推送的数据 (不包含本次需求)
var oldCreateDate = _connection.QuerySingleOrDefault<DateTime?>(" select create_time from dc_auto_purchase_advise_detailed where bailun_sku_warehouse_code = @bailun_sku_warehouse_code and main_id!=@main_id and status=0 and ispush=0 limit 1 ", new
......@@ -1155,6 +1156,55 @@ left join dc_mid_transit as t9 on t1.bailun_sku = t9.bailun_sku and t1.warehouse
}
/// <summary>
/// 新旧品出单计算
/// </summary>
public static List<dc_auto_purchase_advise_detailed> OldProductCalculation(List<dc_auto_purchase_advise_detailed> originalDatas)
{
List<dc_auto_purchase_advise_detailed> datas = new List<dc_auto_purchase_advise_detailed>();
var btime = DateTime.Now.AddDays(-31);
var now = DateTime.Now;
var order_sql = @"select count(DISTINCT bailun_order_id) as 'ordered' from dc_base_oms_sku_30 as t1
where t1.bailun_order_status != 'Canceled'
and t1.has_delete = 0
and t1.has_scalp = 0
and t1.has_buyer_remark = 0
and t1.has_platsku_remark = 0
and t1.paid_time>=@btime ";
foreach (var item in originalDatas)
{
DynamicParameters parameters = new DynamicParameters();
parameters.Add("btime", btime);
parameters.Add("bailun_sku",item.bailun_sku);
parameters.Add("warehouse_code", item.warehouse_code);
// 新品 (只出过一个单,就只补缺货了)
var orders = _connection.QueryFirstOrDefault<int?>(order_sql+ " and bailun_sku=@bailun_sku and warehouse_code=@warehouse_code ", parameters) ?? 0;
//新旧品判定
if ( item.first_order_date!=null && (now - item.first_order_date.Value).TotalDays > 14)
{
// 旧品
if (orders <= 1)
{
item.quantity_final_advise = 0;
item.remarks = $"旧品({item.first_order_date}), 30天内只出了 {orders} 单,不备货";
}
}
else
{
if (orders <= 1)
{
item.quantity_final_advise = (int)Math.Ceiling( item.fixed_quantity_out_stock??0);
item.remarks = $"新品({item.first_order_date}), 30天内只出了 {orders} 单,只补缺货 ({(item.fixed_quantity_out_stock ?? 0)}) ";
}
}
datas.Add(item);
}
return datas;
}
/// <summary>
/// 物流切换拆分
/// 多余35天的量,走海运
/// </summary>
......
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