Commit f1e16076 by 泽锋 李

提货单自动推送无库系统

parent c9e73abe
using AutoTurnOver.Models.ApiDto; using AutoTurnOver.Models;
using AutoTurnOver.Models.ApiDto;
using AutoTurnOver.Utility; using AutoTurnOver.Utility;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -314,6 +315,50 @@ namespace AutoTurnOver.DB ...@@ -314,6 +315,50 @@ namespace AutoTurnOver.DB
} }
/// <summary> /// <summary>
/// 提货单推送无库系统
/// </summary>
/// <returns></returns>
public static void ApiPushSupplierUpSkuInfo(List<api_push_SupplierAimsUpSkuInfoDto> datas)
{
try
{
//查询采购建议明细
string url = ConfigHelper.GetValue("distribution_sys:InsertAimsUpSkuInfo");
string resultStr = HttpHelper.Request(url, RequestType.POST, datas.ToJson(), "application/json", timeout: 1000 * 60 * 60 * 24);
var result = resultStr.ToObj<api_distribution_return_order_push_response_dto>();
if (result == null)
{
throw new Exception("无库系统接口未响应");
}
else
{
if (result.statusCode != 200)
{
throw new Exception(result.message);
}
else
{
if (result.result == null)
{
throw new Exception("无库系统接口未响应");
}
else
{
if (!result.result.isSucceeded)
{
throw new Exception(result.result.message);
}
}
}
}
}
catch (Exception ex)
{
throw new Exception("无库系统 退货单推送接口异常: " + ex.Message);
throw new Exception("无库系统 退货单推送接口异常: " + ex.StackTrace);
}
}
/// <summary>
/// 退货单推送无库系统 /// 退货单推送无库系统
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
......
...@@ -6,6 +6,7 @@ using System.Collections.Generic; ...@@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using AutoTurnOver.Utility; using AutoTurnOver.Utility;
using AutoTurnOver.Models.Report;
namespace AutoTurnOver.DB namespace AutoTurnOver.DB
{ {
...@@ -26,22 +27,24 @@ namespace AutoTurnOver.DB ...@@ -26,22 +27,24 @@ namespace AutoTurnOver.DB
etime = etime.ToString("yyyy-MM-dd 23:59:59") etime = etime.ToString("yyyy-MM-dd 23:59:59")
}).ToList(); }).ToList();
var count = 1;
foreach (var item in purchase_list.GroupBy(s => new { s.supplier_name, s.supplier_id })) foreach (var item in purchase_list.GroupBy(s => new { s.supplier_name, s.supplier_id }))
{ {
var dc_base_supplier_data = (_connection.QueryFirstOrDefault<dc_base_supplier>(" select * from dc_base_supplier where sup_value=@sup_value ", new { sup_value = item.Key.supplier_id }) ?? new dc_base_supplier()); var dc_base_supplier_data = (_connection.QueryFirstOrDefault<dc_base_supplier>(" select * from dc_base_supplier where sup_value=@sup_value ", new { sup_value = item.Key.supplier_id }) ?? new dc_base_supplier());
if (dc_base_supplier_data.isdaytakeinstore == 1) if (dc_base_supplier_data.isdaytakeinstore == 1)
{ {
var count = 0;
foreach (var itemP in item.GroupBy(s => s.purchase_id)) foreach (var itemP in item.GroupBy(s => s.purchase_id))
{ {
count++;
// 生成编号 // 生成编号
var order_no = $"{item.Key.supplier_name}-{DateTime.Now.ToString("MM-dd")}-提-{GetNumberStr(count)}"; var order_no = $"{item.Key.supplier_name}-{DateTime.Now.ToString("MM-dd")}-提-{GetNumberStr(count)}";
var order_data = new dc_auto_pick_up_goods_order() var order_data = new dc_auto_pick_up_goods_order()
{ {
create_date = DateTime.Now,
date = itemP.Max(s => s.create_time), date = itemP.Max(s => s.create_time),
no = order_no, no = order_no,
order_1688_time = new DateTime(1991, 1, 1), order_1688_time = new DateTime(1991, 1, 1),
...@@ -51,7 +54,10 @@ namespace AutoTurnOver.DB ...@@ -51,7 +54,10 @@ namespace AutoTurnOver.DB
warehouse_code = item.Max(v=>v.warehouse_code), warehouse_code = item.Max(v=>v.warehouse_code),
warehouse_name = item.Max(v=>v.warehouse_name), warehouse_name = item.Max(v=>v.warehouse_name),
suppliers_id =item.Key.supplier_id??0, suppliers_id =item.Key.supplier_id??0,
suppliers_name = item.Key.supplier_name suppliers_name = item.Key.supplier_name,
address = dc_base_supplier_data.companyaddress,
pick_up_tel = dc_base_supplier_data.contactphone,
pick_up_user = dc_base_supplier_data.contactname
}; };
// 查询是否已经存在 // 查询是否已经存在
...@@ -76,6 +82,48 @@ namespace AutoTurnOver.DB ...@@ -76,6 +82,48 @@ namespace AutoTurnOver.DB
price = (itemSku.price ?? 0) price = (itemSku.price ?? 0)
}); });
} }
var out_stock_list = _connection.Query<dc_mid_transit_dto>(" select * from dc_mid_transit where bailun_sku in @bailun_skus and warehouse_code=@warehouse_code ",new {
bailun_skus = itemP.Select(s=>s.bailun_sku).ToList(),
warehouse_code = order_data.warehouse_code
}).ToList();
try
{
ApiUtility.ApiPushSupplierUpSkuInfo(itemP.Select(s => new api_push_SupplierAimsUpSkuInfoDto
{
Address = order_data.address,
CheckGMV = (s.price ?? 0) * s.count,
CheckSale = s.count,
CheckTime = order_data.date,
LatestPickUpTime = order_data.pick_up_goods_time,
PickTime = order_data.create_date,
PickUpNo = order_data.no,
PickUpTel = order_data.pick_up_tel,
PickUpUser = order_data.pick_up_user,
Sku = s.bailun_sku,
Price = s.price,
SkuTitle = s.sku_name,
SupplierId = order_data.id,
SupplierName = order_data.suppliers_name,
WarehouseName = order_data.warehouse_name,
SupplierCheckSale = itemP.Sum(v => v.count),
DayOutStock = (out_stock_list.SingleOrDefault(v => v.bailun_sku == s.bailun_sku) ?? new dc_mid_transit_dto { }).quantity_out_stock
}).ToList());
}
catch (Exception ex)
{
Console.WriteLine("提货单推送无库系统异常:"+ex.Message);
Console.WriteLine("提货单推送无库系统异常:"+ex.StackTrace);
_connection.Insert(new dc_task_error_log {
date = DateTime.Now,
message = ex.Message,
task_name = "提货单推送无库系统异常 - "+ order_data.purchase_id,
stack_trace =ex.StackTrace
});
}
count++;
} }
} }
...@@ -122,12 +170,12 @@ where 1 = 1 "; ...@@ -122,12 +170,12 @@ where 1 = 1 ";
DynamicParameters parameters = new DynamicParameters(); DynamicParameters parameters = new DynamicParameters();
if (m.btime != null) if (m.btime != null)
{ {
sql += " and t1.date>=@btime "; sql += " and t2.date>=@btime ";
parameters.Add("btime", m.btime.Value.ToDayHome()); parameters.Add("btime", m.btime.Value.ToDayHome());
} }
if (m.etime != null) if (m.etime != null)
{ {
sql += " and t1.date<=@etime "; sql += " and t2.date<=@etime ";
parameters.Add("etime", m.etime.Value.ToDayEnd()); parameters.Add("etime", m.etime.Value.ToDayEnd());
} }
if (!string.IsNullOrWhiteSpace(m.warehousetype)) if (!string.IsNullOrWhiteSpace(m.warehousetype))
......
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models.Report
{
public class dc_mid_transit_dto
{
public string bailun_sku { get; set; }
public string warehouse_code { get; set; }
public decimal quantity_out_stock { get; set; }
}
}
...@@ -9,6 +9,7 @@ namespace AutoTurnOver.Models ...@@ -9,6 +9,7 @@ namespace AutoTurnOver.Models
public int id { get; set; } public int id { get; set; }
public string no { get; set; } public string no { get; set; }
public DateTime date { get; set; } public DateTime date { get; set; }
public DateTime create_date { get; set; }
public DateTime? pay_time { get; set; } public DateTime? pay_time { get; set; }
public DateTime? order_1688_time { get; set; } public DateTime? order_1688_time { get; set; }
public string pick_up_goods_time { get; set; } public string pick_up_goods_time { get; set; }
...@@ -17,6 +18,9 @@ namespace AutoTurnOver.Models ...@@ -17,6 +18,9 @@ namespace AutoTurnOver.Models
public string warehouse_name { get; set; } public string warehouse_name { get; set; }
public int suppliers_id { get; set; } public int suppliers_id { get; set; }
public string suppliers_name { get; set; } public string suppliers_name { get; set; }
public string address { get; set; }
public string pick_up_user { get; set; }
public string pick_up_tel { get; set; }
} }
public class dc_auto_pick_up_goods_order_sku public class dc_auto_pick_up_goods_order_sku
...@@ -68,4 +72,84 @@ namespace AutoTurnOver.Models ...@@ -68,4 +72,84 @@ namespace AutoTurnOver.Models
public int? warehousearea { get; set; } public int? warehousearea { get; set; }
} }
public class api_push_SupplierAimsUpSkuInfoDto
{
/// <summary>
/// 供应商名称
/// </summary>
public string SupplierName { get; set; }
/// <summary>
/// 供应商ID
/// </summary>
public long SupplierId { get; set; }
/// <summary>
/// 提货单号
/// </summary>
public string PickUpNo { get; set; }
/// <summary>
/// sku编码
/// </summary>
public string Sku { get; set; }
/// <summary>
/// sku名称
/// </summary>
public string SkuTitle { get; set; }
/// <summary>
/// 地址
/// </summary>
public string Address { get; set; }
/// <summary>
/// 取货对接人
/// </summary>
public string PickUpUser { get; set; }
/// <summary>
/// 对接人电话
/// </summary>
public string PickUpTel { get; set; }
/// <summary>
/// 仓库名称
/// </summary>
public string WarehouseName { get; set; }
/// <summary>
/// 日期
/// </summary>
public DateTime PickTime { get; set; }
/// <summary>
/// 单价
/// </summary>
public decimal? Price { get; set; }
/// <summary>
/// 下单数
/// </summary>
public int? CheckSale { get; set; }
/// <summary>
/// 供应商总下单数
/// </summary>
public int? SupplierCheckSale { get; set; }
/// <summary>
/// 总下单金额
/// </summary>
public decimal? CheckGMV { get; set; }
/// <summary>
/// 当日缺货数
/// </summary>
public decimal DayOutStock { get; set; }
/// <summary>
/// 供应商最晚提货时间
/// </summary>
public string LatestPickUpTime { get; set; }
/// <summary>
/// 下单时间
/// </summary>
public DateTime? CheckTime { get; set; }
}
} }
...@@ -28,6 +28,7 @@ namespace ResetOutofstock ...@@ -28,6 +28,7 @@ namespace ResetOutofstock
//report_cash_flow_dao.SynchroTransferCost(); //report_cash_flow_dao.SynchroTransferCost();
//dc_auto_pick_up_goods_order_dao.GenerateOrder(DateTime.Now.AddDays(-3), DateTime.Now); //dc_auto_pick_up_goods_order_dao.GenerateOrder(DateTime.Now.AddDays(-3), DateTime.Now);
//dc_auto_pick_up_goods_order_dao.GenerateOrder(DateTime.Now.AddDays(-1), DateTime.Now);
} }
catch (Exception ex) catch (Exception ex)
{ {
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
"CanLog": "yes" "CanLog": "yes"
}, },
"distribution_sys": { "distribution_sys": {
"getSupplierHolidayTimes": "http://pps.bailuntec.com/distributionapi/Manager/SupplierAssessmentData/getSupplierHolidayTimes" "getSupplierHolidayTimes": "http://pps.bailuntec.com/distributionapi/Manager/SupplierAssessmentData/getSupplierHolidayTimes",
"InsertAimsUpSkuInfo": "http://pps.bailuntec.com/distributionapi/Manager/SupplierReturnSkuInfo/InsertAimsUpSkuInfo"
}, },
"supplier_sys": { "supplier_sys": {
"list": "http://supplier.bailuntec.com/Api/ListSupplierAllByTime" "list": "http://supplier.bailuntec.com/Api/ListSupplierAllByTime"
......
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
"CanLog": "yes" "CanLog": "yes"
}, },
"distribution_sys": { "distribution_sys": {
"getSupplierHolidayTimes": "http://pps.bailuntec.com/distributionapi/Manager/SupplierAssessmentData/getSupplierHolidayTimes" "getSupplierHolidayTimes": "http://pps.bailuntec.com/distributionapi/Manager/SupplierAssessmentData/getSupplierHolidayTimes",
"InsertAimsUpSkuInfo": "http://pps.bailuntec.com/distributionapi/Manager/SupplierReturnSkuInfo/InsertAimsUpSkuInfo"
}, },
"supplier_sys": { "supplier_sys": {
"list": "http://supplier.bailuntec.com/Api/ListSupplierAllByTime" "list": "http://supplier.bailuntec.com/Api/ListSupplierAllByTime"
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
"CanLog": "yes" "CanLog": "yes"
}, },
"distribution_sys": { "distribution_sys": {
"getSupplierHolidayTimes": "http://pps.bailuntec.com/distributionapi/Manager/SupplierAssessmentData/getSupplierHolidayTimes" "getSupplierHolidayTimes": "http://pps.bailuntec.com/distributionapi/Manager/SupplierAssessmentData/getSupplierHolidayTimes",
"InsertAimsUpSkuInfo": "http://pps.bailuntec.com/distributionapi/Manager/SupplierReturnSkuInfo/InsertAimsUpSkuInfo"
}, },
"supplier_sys": { "supplier_sys": {
"list": "http://supplier.bailuntec.com/Api/ListSupplierAllByTime" "list": "http://supplier.bailuntec.com/Api/ListSupplierAllByTime"
......
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