Commit 01d29956 by 泽锋 李

新增lm产品订单换仓服务

parent 681411c3
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using Dapper;
using AutoTurnOver.Models.Report;
using AutoTurnOver.Models;
namespace AutoTurnOver.DB
{
/// <summary>
/// 独立站自动转海外仓备货
/// </summary>
public class lm_dao : connectionHelper
{
/// <summary>
/// 换仓备货
/// </summary>
public static void ChangeWarehouseStockUp()
{
var abroad_warehouse_list = new List<string> {"" };
// 找出最近30t天有在lm仓出单的sku
var bailun_skus = _connection.Query<dc_base_oms_sku>(" select * from dc_base_oms_sku_30 where warehouse_code='GZBLLM' and paid_time>=@btime ", new
{
btime = DateTime.Now.AddDays(-30)
},commandTimeout:0).ToList();
if(bailun_skus!=null && bailun_skus.Count >= 1)
{
// 找出这些sku是否有在海外仓有库存或者发货过
var stockDatas = _connection.Query<dc_base_stock_warehouse_dto>($@" select t1.*,t2.area_name from dc_base_stock as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
where t2.hq_type in ('海外仓','第三方仓') and t1.warehouse_code in @warehouse_codes and t1.bailun_sku in @bailun_skus and (t1.usable_stock>0 || t1.shipped_stock>0) ", new {
bailun_skus = bailun_skus.Select(s => s.bailun_sku).ToList(),
warehouse_codes = abroad_warehouse_list
}, commandTimeout: 0).ToList();
if (stockDatas != null && stockDatas.Count >= 1)
{
// 把这些国家的单转移到海外仓
foreach (var item in stockDatas.GroupBy(s=>s.warehouse_code))
{
var country_code = _connection.QueryFirstOrDefault<string>(" select `code` from dc_base_country where `name`=@name ",new {
name = item.FirstOrDefault().area_name
});
// 把这个国家的单,都转到海外仓
_connection.Execute(" update dc_base_oms_sku_30 set warehouse_code=@warehouse_code where bailun_order_id in @bailun_order_ids and bailun_sku in @bailun_skus and receipt_country=@receipt_country ",new {
warehouse_code = item.Key,
bailun_order_ids = bailun_skus.Select(s=>s.bailun_order_id).ToList(),
bailun_skus = item.Select(s=>s.bailun_sku).ToList(),
receipt_country = country_code
},commandTimeout:0);
// 把这个国家的单,都转到海外仓
_connection.Execute(" update dc_base_oms_sku set warehouse_code=@warehouse_code where bailun_order_id in @bailun_order_ids and bailun_sku in @bailun_skus and receipt_country=@receipt_country ",new {
warehouse_code = item.Key,
bailun_order_ids = bailun_skus.Select(s=>s.bailun_order_id).ToList(),
bailun_skus = item.Select(s=>s.bailun_sku).ToList(),
receipt_country = country_code
}, commandTimeout: 0);
}
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
public class dc_base_stock_warehouse_dto : dc_base_stock
{
public string area_name { get; set; }
}
}
......@@ -41,11 +41,12 @@ namespace ResetOutofstock
//report.ClearShopifyJitInventory();
//report.ShopifyJitInventory();
//daily.ResetOrders7();
lm_dao.ChangeWarehouseStockUp();
}
catch (Exception ex)
{
throw;
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
......
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