|
|
|
using BBWY.Common.Models;
|
|
|
|
using BBWY.Server.Model;
|
|
|
|
using BBWY.Server.Model.Dto;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
namespace BBWY.Server.Business
|
|
|
|
{
|
|
|
|
public class LogisticsCompanyConverter : IDenpendency
|
|
|
|
{
|
|
|
|
private IDictionary<string, IList<LogisticsCompanyRelationship>> converterDictionary;
|
|
|
|
|
|
|
|
public LogisticsCompanyConverter()
|
|
|
|
{
|
|
|
|
converterDictionary = new Dictionary<string, IList<LogisticsCompanyRelationship>>();
|
|
|
|
converterDictionary.Add($"{Enums.Platform.阿里巴巴}_{Enums.Platform.京东}", new List<LogisticsCompanyRelationship>()
|
|
|
|
{
|
|
|
|
//new LogisticsCompanyRelationship(){SourceName="中通快递(ZTO)",TargetName="中通速递"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="圆通速递(YTO)",TargetName="圆通快递"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="邮政国内小包",TargetName="邮政快递包裹"},
|
|
|
|
// new LogisticsCompanyRelationship(){SourceName="韵达快递",TargetName="韵达快递"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="申通快递(STO)",TargetName="申通快递",SecondTargetName="厂家自送"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="顺丰速运",TargetName="顺丰快递"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="百世快递",TargetName="厂家自送"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="其他",TargetName="厂家自送"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="德邦",TargetName="德邦物流",SecondTargetName="德邦快递"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="EMS",TargetName="邮政快递包裹"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="德邦快递",TargetName="德邦快递",SecondTargetName="德邦快运"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="其它",TargetName="厂家自送"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="极兔速递",TargetName="厂家自送"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="中通快运",TargetName="中通快运"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="龙邦速递",TargetName="龙邦快递"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="安能物流",TargetName="安能物流"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="德坤物流",TargetName="厂家自送"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="顺丰快运",TargetName="顺丰快递"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="壹米滴答",TargetName="壹米滴答"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="优速快递",TargetName="优速快递"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="京广速递",TargetName="厂家自送"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="丰网速运",TargetName="丰网速运"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="顺心捷达",TargetName="顺心捷达"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="快捷快递",TargetName="快捷速递"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="极兔快递(原百世快递)",TargetName="京旗联盟-极兔",SecondTargetName ="厂家自送"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="极兔速递-原百世快递",TargetName="京旗联盟-极兔",SecondTargetName ="厂家自送"}
|
|
|
|
});
|
|
|
|
converterDictionary.Add($"{Enums.Platform.拳探}_{Enums.Platform.京东}", new List<LogisticsCompanyRelationship>()
|
|
|
|
{
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="韵达快递",TargetName="韵达快递"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="顺丰速运",TargetName="顺丰快递"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="圆通速递",TargetName="圆通快递"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="中通快递",TargetName="中通速递"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="申通快递",TargetName="厂家自送"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="百世快递",TargetName="厂家自送"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="德邦快递",TargetName="德邦快递"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="极兔速递",TargetName="京旗联盟-极兔"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="邮政快递包裹",TargetName="邮政快递包裹"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="天天快递",TargetName="厂家自送"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="EMS",TargetName="厂家自送"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="邮政标准快递",TargetName="邮政快递包裹"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="德邦",TargetName="德邦物流"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="众邮快递",TargetName="厂家自送"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="优速快递",TargetName="优速快递"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="中通快运",TargetName="中通快运"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="宅急送",TargetName="厂家自送"},
|
|
|
|
new LogisticsCompanyRelationship(){SourceName="苏宁物流",TargetName="厂家自送"}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 翻译各平台之间的物流公司
|
|
|
|
/// </summary>00
|
|
|
|
/// <param name="sourceName"></param>
|
|
|
|
/// <param name="sourcePlatform"></param>
|
|
|
|
/// <param name="targetPlatform"></param>
|
|
|
|
/// <param name="targetPlatformUserLogisticsCompanyList">用户支持的目标平台物流公司</param>
|
|
|
|
/// <returns>目标平台的物流公司Id</returns>
|
|
|
|
public string Converter(string sourceName,
|
|
|
|
Enums.Platform sourcePlatform,
|
|
|
|
Enums.Platform targetPlatform,
|
|
|
|
IList<LogisticsResponse> targetPlatformUserLogisticsCompanyList)
|
|
|
|
{
|
|
|
|
var key = $"{sourcePlatform}_{targetPlatform}";
|
|
|
|
if (!converterDictionary.TryGetValue(key, out IList<LogisticsCompanyRelationship> companyRelationShips))
|
|
|
|
throw new BusinessException($"不支持{sourcePlatform}与{targetPlatform}的物流公司翻译");
|
|
|
|
|
|
|
|
var targetShip = companyRelationShips.FirstOrDefault(l => l.SourceName == sourceName);
|
|
|
|
if (targetShip == null)
|
|
|
|
throw new BusinessException($"sourcePlatform:{sourcePlatform},targetPlatform:{targetPlatform},未找到{sourcePlatform}的物流公司{sourceName}");
|
|
|
|
|
|
|
|
var logisiticsCompany = targetPlatformUserLogisticsCompanyList.FirstOrDefault(c => c.Name.Equals(targetShip.TargetName));
|
|
|
|
if (logisiticsCompany == null)
|
|
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(targetShip.SecondTargetName))
|
|
|
|
{
|
|
|
|
logisiticsCompany = targetPlatformUserLogisticsCompanyList.FirstOrDefault(c => c.Name.Equals(targetShip.SecondTargetName));
|
|
|
|
if (logisiticsCompany == null)
|
|
|
|
{
|
|
|
|
throw new BusinessException($"sourcePlatform:{sourcePlatform},targetPlatform:{targetPlatform},targetShip:{targetShip.SecondTargetName},在用户支持的物流公司中不存在");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw new BusinessException($"sourcePlatform:{sourcePlatform},targetPlatform:{targetPlatform},targetShip:{targetShip.TargetName},在用户支持的物流公司中不存在");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return logisiticsCompany.Id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class LogisticsCompanyRelationship
|
|
|
|
{
|
|
|
|
public string SourceName { get; set; }
|
|
|
|
|
|
|
|
public string TargetName { get; set; }
|
|
|
|
|
|
|
|
public string TargetCode { get; set; }
|
|
|
|
|
|
|
|
public string SecondTargetName { get; set; }
|
|
|
|
|
|
|
|
public string SecondTargetCode { get; set; }
|
|
|
|
}
|
|
|
|
}
|