Commit c57eae0e by 泽锋 李

张莹霞的备货单,初始建议数  小于5的,  系统建议数  改5下单。

parent 1e590397
...@@ -62,7 +62,7 @@ select ...@@ -62,7 +62,7 @@ select
t1.quantity_init_advise as 'quantity_init_advise', -- 原始采购建议数量 new t1.quantity_init_advise as 'quantity_init_advise', -- 原始采购建议数量 new
( (
case case
when t7.sum_quantity_init_advise>=t7.max_moq then t1.quantity_init_advise -- 如果商品的下单总量达到moq了,就直接下单 when t7.sum_quantity_init_advise>=t7.max_moq then ( case when t6.buyer_name in ('张莹霞') then greatest(t1.quantity_init_advise,t6.moq) else t1.quantity_init_advise end )-- 如果商品的下单总量达到moq了,就直接下单 (张莹霞的sku取moq下单)
when t7.sku_count=1 then t7.max_moq -- 如果该商品只有一个sku需要下单,则直接下一个moq when t7.sku_count=1 then t7.max_moq -- 如果该商品只有一个sku需要下单,则直接下一个moq
else else
FLOOR( FLOOR(
......
...@@ -12,6 +12,7 @@ namespace AutoTurnOver.Models.ApiDto ...@@ -12,6 +12,7 @@ namespace AutoTurnOver.Models.ApiDto
/// sku类型 1.库存为零的sku 2.有库存 /// sku类型 1.库存为零的sku 2.有库存
/// </summary> /// </summary>
public int skuType { get; set; } public int skuType { get; set; }
public string platform { get; set; }
} }
public class ShortagePush_Item_RequestDto public class ShortagePush_Item_RequestDto
......
...@@ -29,5 +29,10 @@ namespace AutoTurnOver.Models ...@@ -29,5 +29,10 @@ namespace AutoTurnOver.Models
private int _stocks; private int _stocks;
public int stocks { get { return Math.Max(0, _stocks); } set { _stocks = value; } } public int stocks { get { return Math.Max(0, _stocks); } set { _stocks = value; } }
/// <summary>
/// 平台
/// </summary>
public string platform { get; set; }
} }
} }
...@@ -18,5 +18,6 @@ namespace AutoTurnOver.Models ...@@ -18,5 +18,6 @@ namespace AutoTurnOver.Models
private int _stocks; private int _stocks;
public int stocks { get { return Math.Max(0, _stocks); } set { _stocks = value; } } public int stocks { get { return Math.Max(0, _stocks); } set { _stocks = value; } }
} }
} }
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
public class shortage_push_view_dto
{
public string hq_type { get; set; }
public string warehouse_code { get; set; }
public string bailun_sku { get; set; }
public string buyer_name { get; set; }
/// <summary>
/// 国内仓总库存
/// </summary>
public decimal? china_sum_usable_stock { get; set; }
/// <summary>
/// 国内仓待发货
/// </summary>
public decimal? china_sum_unshipped_quantity { get; set; }
/// <summary>
/// 缺货
/// </summary>
public decimal? quantity_out_stock { get; set; }
/// <summary>
/// 可用库存
/// </summary>
public decimal? usable_stock { get; set; }
/// <summary>
/// 待发货
/// </summary>
public decimal? quantity_unshipped { get; set; }
}
}
...@@ -459,7 +459,7 @@ namespace AutoTurnOver.Services ...@@ -459,7 +459,7 @@ namespace AutoTurnOver.Services
/// <summary> /// <summary>
/// 缺货推送 (分页推送) /// 缺货推送 (分页推送)
/// </summary> /// </summary>
public static List<ShortagePush_Item_RequestDto> ShortagePush(List<dc_auto_shortage_push> datas) public static List<ShortagePush_Item_RequestDto> ShortagePush(List<dc_auto_shortage_push> datas,string platform)
{ {
var err_datas = new List<ShortagePush_Item_RequestDto>(); var err_datas = new List<ShortagePush_Item_RequestDto>();
...@@ -471,6 +471,7 @@ namespace AutoTurnOver.Services ...@@ -471,6 +471,7 @@ namespace AutoTurnOver.Services
{ {
var result = ShortagePushApi(new ShortagePush_RequestDto var result = ShortagePushApi(new ShortagePush_RequestDto
{ {
platform= platform,
skuType = 1, skuType = 1,
amisSkuInfos = datas.Skip((page - 1) * rows).Take(rows).Select(s => new ShortagePush_Item_RequestDto amisSkuInfos = datas.Skip((page - 1) * rows).Take(rows).Select(s => new ShortagePush_Item_RequestDto
{ {
...@@ -510,7 +511,7 @@ namespace AutoTurnOver.Services ...@@ -510,7 +511,7 @@ namespace AutoTurnOver.Services
/// <summary> /// <summary>
/// 回货速改推送 (分页推送) /// 回货速改推送 (分页推送)
/// </summary> /// </summary>
public static List<ShortagePush_Item_RequestDto> ReturnGoodsPush(List<dc_return_goods_push> datas) public static List<ShortagePush_Item_RequestDto> ReturnGoodsPush(List<dc_return_goods_push> datas, string platform)
{ {
var err_datas = new List<ShortagePush_Item_RequestDto>(); var err_datas = new List<ShortagePush_Item_RequestDto>();
...@@ -522,6 +523,7 @@ namespace AutoTurnOver.Services ...@@ -522,6 +523,7 @@ namespace AutoTurnOver.Services
{ {
var result = ReturnGoodsPushApi(new ShortagePush_RequestDto var result = ReturnGoodsPushApi(new ShortagePush_RequestDto
{ {
platform = platform,
skuType = 2, skuType = 2,
amisSkuInfos = datas.Skip((page - 1) * rows).Take(rows).Select(s => new ShortagePush_Item_RequestDto amisSkuInfos = datas.Skip((page - 1) * rows).Take(rows).Select(s => new ShortagePush_Item_RequestDto
{ {
......
...@@ -327,7 +327,7 @@ namespace AutoTurnOver.Services ...@@ -327,7 +327,7 @@ namespace AutoTurnOver.Services
if (datas.Count <= 200 && datas.Count >= 1 && !m.isSum) if (datas.Count <= 200 && datas.Count >= 1 && !m.isSum)
{ {
var orders = datas.Select(s => ("ebay".Equals(s.platform_type,StringComparison.OrdinalIgnoreCase) ? s.transaction_id : s.origin_order_id)).ToList(); var orders = datas.Select(s => ("ebay".Equals(s.platform_type, StringComparison.OrdinalIgnoreCase) ? s.transaction_id : s.origin_order_id)).ToList();
//var crm_case_order_list = ApiServices.CrmCaseOrder(orders); //var crm_case_order_list = ApiServices.CrmCaseOrder(orders);
//var crm_case_message_list = ApiServices.CrmMessage(orders); //var crm_case_message_list = ApiServices.CrmMessage(orders);
//var crm_case_message_reply_list = ApiServices.CrmMessageReply(orders); //var crm_case_message_reply_list = ApiServices.CrmMessageReply(orders);
...@@ -446,22 +446,69 @@ namespace AutoTurnOver.Services ...@@ -446,22 +446,69 @@ namespace AutoTurnOver.Services
return result_data; return result_data;
} }
public void ShortagePush(bool is_all = false,string platform = null)
{
// 国内仓
List<string> platform1s = new List<string> {"ebay","amazon", "aliexpress", "shopee", "wish", "lazada" };
foreach (var item in platform1s.Where(s=> string.IsNullOrWhiteSpace(platform) || platform==s))
{
List<dc_auto_shortage_push> datas = new List<dc_auto_shortage_push>();
datas.AddRange(report.ChinaShortagePush(item, is_all));
var err_datas = ApiServices.ShortagePush(datas, item);
// 记录推送状态
report.AddShortagePush(datas.Where(s => !err_datas.Any(e => e.warehouseCode == s.warehouse_code && s.bailun_sku == e.sku)));
}
//国外仓1
List<string> platform2s = new List<string> { "ebay", "wish" };
List<string> rule1 = new List<string> { "GBYKD", "JZHYBLGC", "MDBLWYT", "MXBLWYT", "BLUSGDC", "GBBMHBL", "GB4PXBL", "DEBLDG", "USGCBL", "USHWBL", "US4PXBL", "AUWYTBL", "AU4PXBL", "GBWYTUK", "BLGBPX" };
foreach (var item in platform2s.Where(s => string.IsNullOrWhiteSpace(platform) || platform == s))
{
List<dc_auto_shortage_push> datas = new List<dc_auto_shortage_push>();
datas.AddRange(report.NotChinaShortagePush(rule1, item, is_all));
var err_datas = ApiServices.ShortagePush(datas, item);
// 记录推送状态
report.AddShortagePush(datas.Where(s => !err_datas.Any(e => e.warehouseCode == s.warehouse_code && s.bailun_sku == e.sku)));
}
// 国外仓2
List<string> platform3s = new List<string> { "opensky", "sears", "walmart" };
List<string> rule2 = new List<string> {"MDBLWYT", "MXBLWYT", "BLUSGDC", "USGCBL", "USHWBL", "US4PXBL" };
foreach (var item in platform3s.Where(s => string.IsNullOrWhiteSpace(platform) || platform == s))
{
List<dc_auto_shortage_push> datas = new List<dc_auto_shortage_push>();
datas.AddRange(report.NotChinaShortagePush(rule2, item, is_all));
var err_datas = ApiServices.ShortagePush(datas, item);
// 记录推送状态
report.AddShortagePush(datas.Where(s => !err_datas.Any(e => e.warehouseCode == s.warehouse_code && s.bailun_sku == e.sku)));
}
}
/// <summary> /// <summary>
/// 缺货推送 /// 缺货推送
/// </summary> /// </summary>
public void ShortagePush(bool is_all = false) public void EbayShortagePush(bool is_all = false)
{ {
var datas = report.ShortagePush(is_all); var datas = report.EbayShortagePush(is_all);
var err_datas = ApiServices.ShortagePush(datas); var err_datas = ApiServices.ShortagePush(datas, "ebay");
// 记录推送状态 // 记录推送状态
report.AddShortagePush(datas.Where(s=> !err_datas.Any(e=>e.warehouseCode==s.warehouse_code && s.bailun_sku==e.sku ))); report.AddShortagePush(datas.Where(s => !err_datas.Any(e => e.warehouseCode == s.warehouse_code && s.bailun_sku == e.sku)));
} }
public void ReturnGoodsPush(string platform = null)
public void ReturnGoodsPush() {
var platform_list = new List<string> { "ebay", "amazon", "aliexpress", "shopee", "wish", "lazada","opensky", "sears", "walmart" };
foreach (var item in platform_list.Where(s => string.IsNullOrWhiteSpace(platform) || platform == s))
{
PlatformReturnGoodsPush(item);
}
}
public void PlatformReturnGoodsPush(string platform)
{ {
var datas = report.ReturnGoodsPush(); var datas = report.ReturnGoodsPush(platform);
var err_datas = ApiServices.ReturnGoodsPush(datas); var err_datas = ApiServices.ReturnGoodsPush(datas, platform);
// 记录推送状态 // 记录推送状态
report.AddReturnGoodsPush(datas.Where(s => !err_datas.Any(e => e.warehouseCode == s.warehouse_code && s.bailun_sku == e.sku))); report.AddReturnGoodsPush(datas.Where(s => !err_datas.Any(e => e.warehouseCode == s.warehouse_code && s.bailun_sku == e.sku)));
......
...@@ -12,7 +12,7 @@ namespace ShortagePush ...@@ -12,7 +12,7 @@ namespace ShortagePush
static async Task Main(string[] args) static async Task Main(string[] args)
{ {
Console.WriteLine("推送缺货数据服务"); Console.WriteLine("推送缺货数据服务");
//var datas = report.ShortagePush(); new ReportServices().ShortagePush();
var builder = new HostBuilder().ConfigureServices((hostContext, services) => var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{ {
services.AddHostedService<ShortagePushBackgroundService>(); services.AddHostedService<ShortagePushBackgroundService>();
......
...@@ -20,11 +20,11 @@ namespace ShortagePush ...@@ -20,11 +20,11 @@ namespace ShortagePush
try try
{ {
System.Console.WriteLine($"开始推送改零数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); System.Console.WriteLine($"开始推送改零数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
new ReportServices().ShortagePush(); new ReportServices().ShortagePush(platform:"ebay");
System.Console.WriteLine($"结束推送改零数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); System.Console.WriteLine($"结束推送改零数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
System.Console.WriteLine($"开始推送回货数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); System.Console.WriteLine($"开始推送回货数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
new ReportServices().ReturnGoodsPush(); new ReportServices().ReturnGoodsPush("ebay");
System.Console.WriteLine($"结束推送回货数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); System.Console.WriteLine($"结束推送回货数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
} }
catch (Exception ex) catch (Exception ex)
......
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