varbailun_skus=_connection.Query<dc_base_oms_sku>(" select * from dc_base_oms_sku_30 where warehouse_code='GZBLLM' and paid_time>=@btime ",new
varbailun_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)
btime=DateTime.Now.AddDays(-30)
},commandTimeout:0).ToList();
},commandTimeout:0).ToList();
if(bailun_skus!=null&&bailun_skus.Count>=1)
if(bailun_skus!=null&&bailun_skus.Count>=1)
{
{
// 找出这些sku是否有在海外仓有库存或者发货过
// 找出这些sku是否有在海外仓有库存或者发货过
varstockDatas=_connection.Query<dc_base_stock_warehouse_dto>($@" select t1.*,t2.area_name from dc_base_stock as t1
varstockDatas=_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
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{
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
varcountry_code=_connection.QueryFirstOrDefault<string>(" select `code` from dc_base_country where `name`=@name ",new{
varcountry_code=_connection.QueryFirstOrDefault<string>(" select `code` from dc_base_country where `name`=@name ",new
{
name=item.FirstOrDefault().area_name
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{
_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
_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{
_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
varsuccessDatas=_connection.Query<dc_base_oms_sku>(" select * from dc_base_oms_sku_30 where bailun_order_id in @bailun_order_ids and bailun_sku in @bailun_skus and warehouse_code=@warehouse_code ",new
log_data.id=_connection.QueryFirstOrDefault<int?>(" select id from dc_base_oms_transfer_warehouse_log where bailun_order_id=@bailun_order_id and bailun_sku=@bailun_sku and to_warehouse_code=@to_warehouse_code and from_warehouse_code=@from_warehouse_code ",new
{
bailun_order_id=log_data.bailun_order_id,
bailun_sku=log_data.bailun_sku,
to_warehouse_code=log_data.to_warehouse_code,
from_warehouse_code=log_data.from_warehouse_code,
})??0;
if(log_data.id<=0)
{
_connection.Insert(log_data);
}
}
}
}
}
}
}
}
}
...
@@ -63,6 +102,96 @@ where t2.hq_type in ('海外仓','第三方仓') and t1.warehouse_code in @wareh
...
@@ -63,6 +102,96 @@ where t2.hq_type in ('海外仓','第三方仓') and t1.warehouse_code in @wareh
_connection.Execute(" delete from dc_sys_allot_plan where status='待推送' ");
varskuStocks=newList<dc_base_stock_auto>();
foreach(variteminoriginal_datas)
{
// 查询转仓记录
vardc_base_oms_transfer_warehouse_log_item=_connection.Query<dc_base_oms_transfer_warehouse_log>(" select * from dc_base_oms_transfer_warehouse_log where from_warehouse_code='GZBLLM' and bailun_sku=@bailun_sku and to_warehouse_code=@to_warehouse_code ",new
varitemSkuStock=_connection.QueryFirstOrDefault<dc_base_stock>(" select * from dc_base_stock where bailun_sku=@bailun_sku and warehouse_code=@warehouse_code ",new
{
bailun_sku=item.bailun_sku,
warehouse_code="GZBLLM"
});
if(itemSkuStock!=null)
{
// 查询这个sku在国内仓是否冗余
// 查询国内仓周转表
varauto_data=_connection.QueryFirstOrDefault<Models.dc_auto_turnover>(" select * from dc_auto_turnover where bailun_sku=@bailun_sku and warehouse_code=@warehouse_code ",new