Commit 223d7a49 by 泽锋 李

新增一个 pps 产品晚上8点的回货服务

parent 11aad69f
...@@ -881,5 +881,20 @@ where t1.`code`=@code limit 1 ...@@ -881,5 +881,20 @@ where t1.`code`=@code limit 1
}.ToJson(), "application/json", timeout: 1000 * 60 * 60 * 24); }.ToJson(), "application/json", timeout: 1000 * 60 * 60 * 24);
return response_json.ToObj<api_order_transfer_status_log_dto>().data; return response_json.ToObj<api_order_transfer_status_log_dto>().data;
} }
/// <summary>
/// 查询pps的跟卖sku
/// </summary>
/// <param name="page"></param>
/// <param name="rows"></param>
/// <returns></returns>
public static List<api_dc_base_pps_sell_product_dto.data_dto> GetPPSSellProduct(int page,int rows)
{
var url = ConfigHelper.GetValue("pps-sys:pps_sell_product");
var response_json = HttpHelper.Request(url+ $"?PageIndex={page}&PageNumber={rows}", RequestType.POST, "", timeout: 1000 * 60 * 60 * 24);
var datas = response_json.ToObj<api_dc_base_pps_sell_product_dto>().data;
return datas;
}
} }
} }
using AutoTurnOver.Models;
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.DB
{
/// <summary>
/// pps 跟卖商品
/// </summary>
public class dc_base_pps_sell_product_dao : connectionHelper
{
/// <summary>
/// 同步数据
/// </summary>
public static void SyncData()
{
int page = 1;
int rows = 100;
// 清理数据重抓
_connection.Execute(" TRUNCATE table dc_base_pps_sell_product; ");
while (true)
{
var datas = ApiUtility.GetPPSSellProduct(page, rows);
page++;
if (datas != null && datas.Count >= 1)
{
foreach (var item in datas)
{
dc_base_pps_sell_product dbData = new dc_base_pps_sell_product();
dbData.pro_code = item.proCode ?? "";
dbData.sku_code = item.skuCode ?? "";
dbData.platform_sku = item.platformSku ?? "";
dbData.item_id = item.itemId ?? "";
dbData.productId = item.productId;
dbData.platform = "walmart";
dbData.warehouse_code = "GZBLWH";
_connection.Insert(dbData);
}
}
else
{
break;
}
}
}
}
}
...@@ -1206,6 +1206,57 @@ end ...@@ -1206,6 +1206,57 @@ end
} }
/// <summary>
/// pps 推在线
/// </summary>
public static List<dc_return_goods_push> PPSReturnGoodsPush(string platform)
{
List<string> ch_rule1 = new List<string>() { "GZBLWH" };
var shortage_list = new List<dc_return_goods_push>();
// 回货速改推送
string sql = @"select
t1.id as 'shortage_push_id',
t1.sku_code as 'bailun_sku',
t1.warehouse_code,
now() as 'push_time',
ifnull(tc1.sum_usable_stock,0) - ifnull(tc2.sum_unshipped_quantity,0) as 'stocks',
t2.buyer_name,
t_sp.title as 'supplier_holiday_time'
from dc_base_pps_sell_product as t1
left join dc_base_sku as t2 on t1.sku_code = t2.bailun_sku
left join dc_mid_transit as t3 on t1.sku_code = t3.bailun_sku and t1.warehouse_code = t3.warehouse_code
left join dc_base_warehouse as t_db on t1.warehouse_code = t_db.warehouse_code
left join dc_base_stock as t_stock on t1.sku_code = t_stock.bailun_sku and t1.warehouse_code = t_stock.warehouse_code
left join dc_auto_config_sku_warehouse as t7 on t1.sku_code = t7.bailun_sku and t1.warehouse_code = t7.warehouse_code
left join (
select t1.bailun_sku,t2.area_id,sum(t1.usable_stock) as 'sum_usable_stock' from dc_base_stock as t1
left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
where t1.warehouse_code in @ch_rule1
GROUP BY t1.bailun_sku,t2.area_id
) as tc1 on t1.sku_code = tc1.bailun_sku and t_db.area_id = tc1.area_id
left join (
select t1.bailun_sku,t2.area_id,sum(t1.quantity_unshipped) as 'sum_unshipped_quantity',sum(t1.quantity_purchase) as 'sum_quantity_purchase' from dc_mid_transit as t1 left join dc_base_warehouse as t2 on t1.warehouse_code = t2.warehouse_code
where t1.quantity_unshipped>0 and t1.warehouse_code in @ch_rule1
GROUP BY t1.bailun_sku,t2.area_id
) as tc2 on t1.sku_code = tc2.bailun_sku and t_db.area_id = tc2.area_id
left join holiday_supplier_view as t_sp on t2.suppliers_id = t_sp.supplier_id
where
t_sp.supplier_id is null and
t1.platform=@platform
and
(
ifnull(tc2.sum_unshipped_quantity,0) < ifnull(tc1.sum_usable_stock,0)
)
";
shortage_list.AddRange(_connection.Query<dc_return_goods_push>(sql, new { platform = platform, ch_rule1 = ch_rule1 }, commandTimeout: 0));
return shortage_list;
}
public static List<dc_return_goods_push> ReturnGoodsPushWish(string platform) public static List<dc_return_goods_push> ReturnGoodsPushWish(string platform)
{ {
List<string> rule1 = new List<string> { "USGCBL", "BLUSGDC", "US4PXBL", "GB4PXBL" }; List<string> rule1 = new List<string> { "USGCBL", "BLUSGDC", "US4PXBL", "GB4PXBL" };
......
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models.ApiDto
{
public class api_dc_base_pps_sell_product_dto
{
public List<data_dto> data { get; set; }
public class data_dto
{
public int productId { get; set; }
public string proCode { get; set; }
public string skuCode { get; set; }
public string platformSku { get; set; }
public string itemId { get; set; }
public int quantity { get; set; }
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
/// <summary>
/// pps 跟卖表
/// </summary>
public class dc_base_pps_sell_product
{
public long id { get; set; }
public int productId { get; set; }
public string pro_code { get; set; }
public string sku_code { get; set; }
public string platform_sku { get; set; }
public string item_id { get; set; }
public string platform { get; set; }
public string warehouse_code { get; set; }
public int quantity { get; set; }
}
}
...@@ -708,6 +708,23 @@ namespace AutoTurnOver.Services ...@@ -708,6 +708,23 @@ namespace AutoTurnOver.Services
} }
/// <summary> /// <summary>
/// pps改回货
/// </summary>
public void PPSReturnGoodsPush(string platform)
{
//先同步pps的数据
dc_base_pps_sell_product_dao.SyncData();
var datas = report.PPSReturnGoodsPush(platform);
// 先走一遍过滤条件,把数据过滤一遍
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.removeShortagePush(datas.Where(s => !err_datas.Any(e => e.warehouseCode == s.warehouse_code && s.bailun_sku == e.sku)).Select(s => s.shortage_push_id));
}
/// <summary>
/// 过滤掉一部分不需要改在线的数据 /// 过滤掉一部分不需要改在线的数据
/// </summary> /// </summary>
public List<dc_return_goods_push> ReturnGoodsPushFilter(List<dc_return_goods_push> datas) public List<dc_return_goods_push> ReturnGoodsPushFilter(List<dc_return_goods_push> datas)
......
...@@ -35,7 +35,8 @@ namespace ResetOutofstock ...@@ -35,7 +35,8 @@ namespace ResetOutofstock
//dc_auto_turnover.set_full_stock_use_days_turnover_sales(dc_auto_turnover.GetModel("250924601", "USFBABLXJ")); //dc_auto_turnover.set_full_stock_use_days_turnover_sales(dc_auto_turnover.GetModel("250924601", "USFBABLXJ"));
//dc_base_trans_temp_schedule_dao.SynchroTransTempScheduleData(true); //dc_base_trans_temp_schedule_dao.SynchroTransTempScheduleData(true);
//daily.ResetGmvExtendSales(now); //daily.ResetGmvExtendSales(now);
report.ResetTransExpectArrivaltime(); //report.ResetTransExpectArrivaltime();
dc_base_pps_sell_product_dao.SyncData();
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -6,7 +6,7 @@ using System.Text; ...@@ -6,7 +6,7 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ResetOutofstock namespace ShortagePush
{ {
public class StockBackgrounService : BackgroundService public class StockBackgrounService : BackgroundService
{ {
......
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
"api_finance_body": "http://cw.bailuntec.com/API/API/GetCompanyMainBody", "api_finance_body": "http://cw.bailuntec.com/API/API/GetCompanyMainBody",
"api_trans_temp_schedule": "http://api.wms.bailuntec.com/api/services/app/AllotScheduleService/GetTempSchedulePageList", "api_trans_temp_schedule": "http://api.wms.bailuntec.com/api/services/app/AllotScheduleService/GetTempSchedulePageList",
"pps-sys": { "pps-sys": {
"review": "https://pps.bailuntec.com/Api/amazon/analyze/Download/GetReviewInfoBy" "review": "https://pps.bailuntec.com/Api/amazon/analyze/Download/GetReviewInfoBy",
"pps_sell_product": "http://pps.bailuntec.com/WalmartApi/Publish/GetWithSellProductAsync"
}, },
"prod-sys": { "prod-sys": {
"order": "http://mjzz.bailuntec.com/api/ApiOrderList" "order": "http://mjzz.bailuntec.com/api/ApiOrderList"
......
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
"api_finance_body": "http://cw.bailuntec.com/API/API/GetCompanyMainBody", "api_finance_body": "http://cw.bailuntec.com/API/API/GetCompanyMainBody",
"api_trans_temp_schedule": "http://api.wms.bailuntec.com/api/services/app/AllotScheduleService/GetTempSchedulePageList", "api_trans_temp_schedule": "http://api.wms.bailuntec.com/api/services/app/AllotScheduleService/GetTempSchedulePageList",
"pps-sys": { "pps-sys": {
"review": "https://pps.bailuntec.com/Api/amazon/analyze/Download/GetReviewInfoBy" "review": "https://pps.bailuntec.com/Api/amazon/analyze/Download/GetReviewInfoBy",
"pps_sell_product": "http://pps.bailuntec.com/WalmartApi/Publish/GetWithSellProductAsync"
}, },
"prod-sys": { "prod-sys": {
"order": "http://mjzz.bailuntec.com/api/ApiOrderList" "order": "http://mjzz.bailuntec.com/api/ApiOrderList"
......
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
"api_finance_body": "http://cw.bailuntec.com/API/API/GetCompanyMainBody", "api_finance_body": "http://cw.bailuntec.com/API/API/GetCompanyMainBody",
"api_trans_temp_schedule": "http://api.wms.bailuntec.com/api/services/app/AllotScheduleService/GetTempSchedulePageList", "api_trans_temp_schedule": "http://api.wms.bailuntec.com/api/services/app/AllotScheduleService/GetTempSchedulePageList",
"pps-sys": { "pps-sys": {
"review": "https://pps.bailuntec.com/Api/amazon/analyze/Download/GetReviewInfoBy" "review": "https://pps.bailuntec.com/Api/amazon/analyze/Download/GetReviewInfoBy",
"pps_sell_product": "http://pps.bailuntec.com/WalmartApi/Publish/GetWithSellProductAsync"
}, },
"prod-sys": { "prod-sys": {
"order": "http://mjzz.bailuntec.com/api/ApiOrderList" "order": "http://mjzz.bailuntec.com/api/ApiOrderList"
......
using AutoTurnOver.DB;
using AutoTurnOver.Services;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ResetOutofstock
{
/// <summary>
/// pps 产品改回货
/// </summary>
public class PPSPushBackgrounService : BackgroundService
{
private Timer _timer;
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
_timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromSeconds(60));
return Task.CompletedTask;
}
private void DoWork(object state)
{
var now = DateTime.Now;
if (now.Hour == 20 && now.Minute == 02)
{
System.Console.WriteLine($"开始 推送pps回货数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
new ReportServices().PPSReturnGoodsPush("walmart");
System.Console.WriteLine($"结束 推送pps回货数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
}
public override void Dispose()
{
base.Dispose();
_timer?.Dispose();
}
}
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using AutoTurnOver.Services; using AutoTurnOver.Services;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using ResetOutofstock;
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -21,6 +22,7 @@ namespace ShortagePush ...@@ -21,6 +22,7 @@ namespace ShortagePush
//new ReportServices().ShortagePushEbay(true, true); //new ReportServices().ShortagePushEbay(true, true);
//new ReportServices().ShortagePushEbay(true); //new ReportServices().ShortagePushEbay(true);
//new ReportServices().ReturnGoodsPush(); //new ReportServices().ReturnGoodsPush();
//new ReportServices().ShortagePushEbay();
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -34,6 +36,7 @@ namespace ShortagePush ...@@ -34,6 +36,7 @@ namespace ShortagePush
var builder = new HostBuilder().ConfigureServices((hostContext, services) => var builder = new HostBuilder().ConfigureServices((hostContext, services) =>
{ {
services.AddHostedService<ShortagePushBackgroundService>(); services.AddHostedService<ShortagePushBackgroundService>();
services.AddHostedService<PPSPushBackgrounService>();
}); });
await builder.RunConsoleAsync(); await builder.RunConsoleAsync();
......
...@@ -71,7 +71,7 @@ namespace ShortagePush ...@@ -71,7 +71,7 @@ namespace ShortagePush
new ReportServices().ShortagePushEbay(true,true); new ReportServices().ShortagePushEbay(true,true);
System.Console.WriteLine($"结束推送 Ebay - 全量 改零数据,线程Id:{Thread.CurrentThread.ManagedThreadId}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); System.Console.WriteLine($"结束推送 Ebay - 全量 改零数据,线程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