Commit a2ea0329 by lizefeng

刷新缺货数据时,降低事务的锁级别

parent 73b940d0
......@@ -22,12 +22,12 @@ namespace AutoTurnOver.Models.ApiDto
public string SiteEn { get; set; }
}
public class AccountResultDto
public class PamsResultDto<T>
{
public bool Success { get; set; }
public string Message { get; set; }
public List<AccountDto> Data { get; set; }
public T Data { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models.ApiDto
{
/// <summary>
/// 物流方式
/// </summary>
public class LmsShipLogisticsDto
{
public string Line_Code { get; set; }
public string Line_Name { get; set; }
}
public class LmsResultDto<T>
{
public bool Success { get; set; }
public string ErrorMessage { get; set; }
public T Data { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models.ApiDto
{
public class PlatformDto
{
public int ID { get; set; }
public string Name
{
get
{
return EnglishName;
}
}
public string EnglishName { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models.ApiDto
{
public class crm_case_order_dto
{
public string order_no { get; set; }
public string platform_type { get; set; }
}
public class crm_message_dto
{
public string order_no { get; set; }
public string platform_type { get; set; }
}
public class crm_message_reply_dto
{
public string order_no { get; set; }
public string platform_type { get; set; }
}
public class crm_api_result_dto<T>
{
public bool success { get; set; }
public string message { get; set; }
public T data { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models.ApiDto
{
/// <summary>
/// crm 出信模板
/// </summary>
public class crm_message_custom_template_dto
{
public int ID { get; set; }
public string Content { get; set; }
public string Title { get; set; }
public string Subject { get; set; }
}
}
......@@ -198,6 +198,10 @@ namespace AutoTurnOver.Models.Report
public int sum_order_count { get; set; }
public int sum_sku_count { get; set; }
public int crm_case_count { get; set; }
public int crm_message_count { get; set; }
public int crm_message_reply_count { get; set; }
}
public class quantity_out_stock_detail_search_dto
......@@ -216,6 +220,13 @@ namespace AutoTurnOver.Models.Report
public int? bailun_account_id { get; set;}
public bool isSum { get; set; }
public DateTime? pay_time_min { get; set; }
public DateTime? pay_time_max { get; set; }
public string shiplogistics_code { get; set; }
public string platform_type { get; set; }
}
public class buy_ontheway_detail_dto
......
using System;
using System.Collections.Generic;
using System.Text;
namespace AutoTurnOver.Models
{
public class return_speed_change_dto
{
public int id { get; set; }
public string product_code { get; set; }
public string warehouse_code { get; set; }
public string warehouse_name { get; set; }
public string bailun_sku { get; set; }
public string sku_name { get; set; }
public int has_available_stock { get; set; }
public string buyer_name { get; set; }
public string ebay_bailun_require_logistics { get; set; }
public string ebay_logistics_method_name { get; set; }
}
public class return_speed_change_search_dto
{
public int? search_type { get; set; }
public string warehousetype { get; set; }
public int? warehousearea { get; set; }
public string warehouse_code { get; set; }
public string key_words { get; set; }
public string purchase_user { get; set; }
public bool isSum { get; set; }
public bool? has_available_stock { get; set; }
}
}
......@@ -147,7 +147,7 @@ namespace AutoTurnOver.Services
}
/// <summary>
/// 推送采购计划
/// 账号列表
/// </summary>
public static List<AccountDto> AccountList()
{
......@@ -156,7 +156,7 @@ namespace AutoTurnOver.Services
{
string url = ConfigHelper.GetValue("Pams_GetAccountToken");
string resultStr = HttpHelper.Request(url, RequestType.GET, "", timeout: 1000 * 60 * 60 * 24);
var result = resultStr.ToObj<AccountResultDto>();
var result = resultStr.ToObj<PamsResultDto<List<AccountDto>>>();
if (result == null)
{
throw new Exception("账号系统异常: 未获取到数据");
......@@ -167,9 +167,6 @@ namespace AutoTurnOver.Services
}
return result.Data;
});
}
public static List<AccountDto> AccountList(string name)
......@@ -202,5 +199,161 @@ namespace AutoTurnOver.Services
}
/// <summary>
/// 查询crm case 数据
/// </summary>
public static List<crm_case_order_dto> CrmCaseOrder(List<string> order_no_list)
{
if (order_no_list == null || order_no_list.Count <= 0)
{
return new List<crm_case_order_dto>();
}
string url = ConfigHelper.GetValue("Crm_Case_Order");
string resultStr = HttpHelper.Request(url, RequestType.POST, "order_no_list=" + string.Join(",", order_no_list), timeout: 1000 * 60 * 60 * 24);
var result = resultStr.ToObj<crm_api_result_dto<List<crm_case_order_dto>>>();
if (result == null)
{
throw new Exception("crm系统: 获取case 数据失败");
}
if (!result.success)
{
throw new Exception("crm系统: " + result.message);
}
return result.data;
}
public static List<crm_message_dto> CrmMessage(List<string> order_no_list)
{
if (order_no_list == null || order_no_list.Count <= 0)
{
return new List<crm_message_dto>();
}
string url = ConfigHelper.GetValue("Crm_Message");
string resultStr = HttpHelper.Request(url, RequestType.POST, "order_no_list=" + string.Join(",", order_no_list), timeout: 1000 * 60 * 60 * 24);
var result = resultStr.ToObj<crm_api_result_dto<List<crm_message_dto>>>();
if (result == null)
{
throw new Exception("crm系统: 获取客户来信 数据失败");
}
if (!result.success)
{
throw new Exception("crm系统: " + result.message);
}
return result.data;
}
public static List<crm_message_reply_dto> CrmMessageReply(List<string> order_no_list)
{
if (order_no_list == null || order_no_list.Count <= 0)
{
return new List<crm_message_reply_dto>();
}
string url = ConfigHelper.GetValue("Crm_Message_Reply");
string resultStr = HttpHelper.Request(url, RequestType.POST, "order_no_list=" + string.Join(",", order_no_list), timeout: 1000 * 60 * 60 * 24);
var result = resultStr.ToObj<crm_api_result_dto<List<crm_message_reply_dto>>>();
if (result == null)
{
throw new Exception("crm系统: 获取出信数据失败");
}
if (!result.success)
{
throw new Exception("crm系统: " + result.message);
}
return result.data;
}
public static List<LmsShipLogisticsDto> ShipLogisticsList()
{
//查询采购建议明细
return RedisHelper.Get(RedisConsts.Lms_GetLogistics, () =>
{
string url = ConfigHelper.GetValue("Lms_GetLogistics");
string resultStr = HttpHelper.Request(url, RequestType.GET, "", timeout: 1000 * 60 * 60 * 24);
var result = resultStr.ToObj<LmsResultDto<List<LmsShipLogisticsDto>>>();
if (result == null)
{
throw new Exception("lms系统异常: 未获取到数据");
}
if (!result.Success)
{
throw new Exception("lms系统异常: " + result.ErrorMessage);
}
return result.Data;
});
}
public static List<LmsShipLogisticsDto> ShipLogisticsList(string name)
{
try
{
if (string.IsNullOrWhiteSpace(name)) return ShipLogisticsList();
return ShipLogisticsList().Where(s =>
(s.Line_Code ?? "").Contains(name, StringComparison.OrdinalIgnoreCase)
||
(s.Line_Name ?? "").Contains(name, StringComparison.OrdinalIgnoreCase)
).ToList();
}
catch (Exception ex)
{
report.AddError(new dc_task_error_log
{
date = DateTime.Now,
message = ex.Message,
stack_trace = ex.StackTrace,
task_name = "ahipLogistics_api"
});
throw;
}
}
/// <summary>
/// 平台列表
/// </summary>
public static List<PlatformDto> PlatformList()
{
string url = ConfigHelper.GetValue("Pams_PlatformList");
string resultStr = HttpHelper.Request(url, RequestType.GET, "", timeout: 1000 * 60 * 60 * 24);
var result = resultStr.ToObj<PamsResultDto<List<PlatformDto>>>();
if (result == null)
{
throw new Exception("账号系统异常: 未获取到平台数据");
}
if (!result.Success)
{
throw new Exception("账号系统异常: " + result.Message);
}
return result.Data;
}
/// <summary>
/// 查询出信模板
/// </summary>
/// <param name="order_no_list"></param>
/// <returns></returns>
public static List<crm_message_custom_template_dto> MessageCustomTemplateList()
{
string url = ConfigHelper.GetValue("Crm_Message_Custom_Template");
string resultStr = HttpHelper.Request(url, RequestType.POST, "", timeout: 1000 * 60 * 60 * 24);
var result = resultStr.ToObj<crm_api_result_dto<List<crm_message_custom_template_dto>>>();
if (result == null)
{
throw new Exception("crm系统: 获取case 数据失败");
}
if (!result.success)
{
throw new Exception("crm系统: " + result.message);
}
return result.data;
}
}
}
......@@ -313,12 +313,47 @@ namespace AutoTurnOver.Services
public List<quantity_out_stock_dto> QuantityOutStockList(quantity_out_stock_search_dto m, int offset, int limit, ref int total, string order = "", string sort = "")
{
return report.QuantityOutStockList(m, offset, limit,ref total, order, sort);
return report.QuantityOutStockList(m, offset, limit, ref total, order, sort);
}
public List<quantity_out_stock_detail_dto> QuantityOutStockDetailList(quantity_out_stock_detail_search_dto m, int offset, int limit, ref int total, string order = "", string sort = "")
{
return report.QuantityOutStockDetailList(m, offset, limit, ref total, order, sort);
var datas = report.QuantityOutStockDetailList(m, offset, limit, ref total, order, sort);
if (datas.Count <= 200 && datas.Count >= 1 && !m.isSum)
{
var orders = datas.Select(s => ("ebay".Equals(s.platform_type) ? s.transaction_id : s.origin_order_id)).ToList();
var crm_case_order_list = ApiServices.CrmCaseOrder(orders);
var crm_case_message_list = ApiServices.CrmMessage(orders);
var crm_case_message_reply_list = ApiServices.CrmMessageReply(orders);
foreach (var item in datas)
{
item.crm_case_count = crm_case_order_list.Where(s =>
item.platform_type.Equals(s.platform_type) && (
("ebay".Equals(item.platform_type) && item.transaction_id.Equals(s.order_no))
||
(!"ebay".Equals(item.platform_type) && item.origin_order_id.Equals(s.order_no))
)
).Count();
item.crm_message_count = crm_case_message_list.Where(s =>
item.platform_type.Equals(s.platform_type) && (
("ebay".Equals(item.platform_type) && item.transaction_id.Equals(s.order_no))
||
(!"ebay".Equals(item.platform_type) && item.origin_order_id.Equals(s.order_no))
)
).Count();
item.crm_message_reply_count = crm_case_message_reply_list.Where(s =>
item.platform_type.Equals(s.platform_type) && (
("ebay".Equals(item.platform_type) && item.transaction_id.Equals(s.order_no))
||
(!"ebay".Equals(item.platform_type) && item.origin_order_id.Equals(s.order_no))
)
).Count();
}
}
return datas;
}
public List<out_stock_dto> OutStockList(out_stock_search_dto m, int offset, int limit, ref int total, string order = "", string sort = "")
......@@ -326,5 +361,20 @@ namespace AutoTurnOver.Services
return report.OutStockList(m, offset, limit, ref total, order, sort);
}
public List<return_speed_change_dto> ReturnSpeedChange(return_speed_change_search_dto m, int offset, int limit, ref int total, string order = "", string sort = "")
{
return report.ReturnSpeedChange(m, offset, limit, ref total, order, sort);
}
/// <summary>
/// 标记回货
/// </summary>
/// <param name="m"></param>
public int MarkReturnSpeedChange(return_speed_change_search_dto m)
{
return report.MarkReturnSpeedChange(m);
}
}
}
......@@ -7,5 +7,7 @@ namespace AutoTurnOver.Utility
public class RedisConsts
{
public static string Pams_GetAccountToken = "Pams_GetAccountToken";
public static string Lms_GetLogistics = "Lms_GetLogistics";
public static string Pams_PlatformList = "Pams_PlatformList";
}
}
......@@ -106,6 +106,42 @@ namespace AutoTurnOver.Controllers
}
public JsonResult ShipLogisticsList(string name)
{
try
{
var list = ApiServices.ShipLogisticsList(name);
return new JsonResult(list.Select(p => new
{
id = p.Line_Code,
text = p.Line_Code + " - " + p.Line_Name
}));
}
catch (Exception ex)
{
throw;
}
}
public JsonResult PlatformList()
{
var datas = ApiServices.PlatformList();
return new JsonResult(datas);
}
/// <summary>
/// crm 自定义出信模板
/// </summary>
/// <returns></returns>
public JsonResult MessageCustomTemplateList()
{
var datas = ApiServices.PlatformList();
return new JsonResult(datas);
}
......
......@@ -18,5 +18,12 @@
"Password": "SpaceHorse1",
"Defaultdatabase": 0
},
"SaveDefaultWares": "http://api.skums.bailuntec.com/api/sku/productware/savedefaultwares"
"SaveDefaultWares": "http://api.skums.bailuntec.com/api/sku/productware/savedefaultwares",
"Crm_Case_Order": "http://crm.bailuntec.com/api/CaseOrderList",
"Crm_Message": "http://crm.bailuntec.com/api/MessageList",
"Crm_Message_Reply": "http://crm.bailuntec.com/api/MessageReplyList",
"Lms_GetLogistics": "http://lms.bailuntec.com/api/DataInfo/ApiLogistics/GetLogistics",
"Pams_PlatformList": "http://pams.bailuntec.com/Api/GetPlatformSites?type=1",
"Crm_Message_Custom_Template": "http://crm.bailuntec.com/api/MessageCustomTemplateList"
}
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