diff --git a/BBWY.Client/App.xaml.cs b/BBWY.Client/App.xaml.cs index 00b3bee1..0949e230 100644 --- a/BBWY.Client/App.xaml.cs +++ b/BBWY.Client/App.xaml.cs @@ -10,6 +10,7 @@ using System.IO; using System.IO.MemoryMappedFiles; using System.Linq; using System.Reflection; +using System.Text; using System.Threading.Tasks; using System.Windows; @@ -25,6 +26,7 @@ namespace BBWY.Client protected override void OnStartup(StartupEventArgs e) { + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); var gl = new GlobalContext(); string userToken = string.Empty; #if DEBUG diff --git a/BBWY.Client/BBWY.Client.csproj b/BBWY.Client/BBWY.Client.csproj index cfa2c1b6..8c701914 100644 --- a/BBWY.Client/BBWY.Client.csproj +++ b/BBWY.Client/BBWY.Client.csproj @@ -15,13 +15,6 @@ x64 - - - - - - - @@ -45,6 +38,7 @@ + diff --git a/BBWY.Client/Extensions/ProcurementAuditExtension.cs b/BBWY.Client/Extensions/ProcurementAuditExtension.cs new file mode 100644 index 00000000..0b28597f --- /dev/null +++ b/BBWY.Client/Extensions/ProcurementAuditExtension.cs @@ -0,0 +1,77 @@ +using System.Collections.Generic; + +namespace BBWY.Client.Extensions +{ + public static class ProcurementAuditExtension + { + /// + /// 跳过引号中的逗号,进行逗号分隔(字段内容中的逗号不参与分隔) + /// + /// + /// + public static string[] CSVstrToArry(this string splitStr) + { + var newstr = string.Empty; + List sList = new List(); + + bool isSplice = false; + string[] array = splitStr.Split(new char[] { ',' }); + foreach (var str in array) + { + if (!string.IsNullOrEmpty(str) && str.IndexOf('"') > -1) + { + var firstchar = str.Substring(0, 1); + var lastchar = string.Empty; + if (str.Length > 0) + { + lastchar = str.Substring(str.Length - 1, 1); + } + if (firstchar.Equals("\"") && !lastchar.Equals("\"")) + { + isSplice = true; + } + if (lastchar.Equals("\"")) + { + if (!isSplice) + newstr += str; + else + newstr = newstr + "," + str; + + isSplice = false; + } + } + else + { + if (string.IsNullOrEmpty(newstr)) + newstr += str; + } + + if (isSplice) + { + //添加因拆分时丢失的逗号 + if (string.IsNullOrEmpty(newstr)) + newstr += str; + else + newstr = newstr + "," + str; + } + else + { + sList.Add(newstr.Replace("\"", "").Trim());//去除字符中的双引号和首尾空格 + newstr = string.Empty; + } + } + return sList.ToArray(); + } + + public static string FormatString(this string str) + { + //if (str.Contains(",")) + // str = str.Replace(",", string.Empty); + if (str.Contains("\"")) + str = str.Replace("\"", string.Empty); + if (str.Contains("\t")) + str = str.Replace("\t", string.Empty); + return str.Trim(); + } + } +} diff --git a/BBWY.Client/Models/Enums.cs b/BBWY.Client/Models/Enums.cs index 3790cc9d..bf867902 100644 --- a/BBWY.Client/Models/Enums.cs +++ b/BBWY.Client/Models/Enums.cs @@ -99,4 +99,18 @@ 在线采购 = 0, 关联订单 = 1 } + + public enum PayBillType + { + AliPay = 0, + WeiXin = 1, + BankCard = 2 + } + + public enum AuditFileType + { + 账单 = 0, + 采购单 = 1, + 销售订单 = 2 + } } diff --git a/BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditFile.cs b/BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditFile.cs new file mode 100644 index 00000000..95f41b76 --- /dev/null +++ b/BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditFile.cs @@ -0,0 +1,9 @@ +namespace BBWY.Client.Models +{ + public class AuditFile + { + public string FileName { get; set; } + + public AuditFileType AuditFileType { get; set; } + } +} diff --git a/BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditPayBill.cs b/BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditPayBill.cs new file mode 100644 index 00000000..4bba9fce --- /dev/null +++ b/BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditPayBill.cs @@ -0,0 +1,70 @@ +using System; + +namespace BBWY.Client.Models +{ + public class AuditPayBill + { + /// + /// 账单流水号 + /// + public string PayBillNo { get; set; } + + /// + /// 支付时间 + /// + public DateTime? PayTime { get; set; } + + /// + /// 账单类型 + /// + public PayBillType PayBillType { get; set; } + + /// + /// 商家订单号 + /// + public string SourceMerchantOrderNo { get; set; } + + /// + /// 商家订单号(去掉账单添加的格式) + /// + public string MerchantOrderNo { get; set; } + + /// + /// 商品名称 + /// + public string ProductName { get; set; } + + /// + /// 对方账户 + /// + public string OppositeAccount { get; set; } + + /// + /// 支出金额 + /// + public decimal ExpenditureAmount { get; set; } + + /// + /// 归属店铺 + /// + public string BelongShop { get; set; } + + public string BelongFileName { get; set; } + + /// + /// 关联的采购单号 + /// + public string RelationPurchaseOrderId { get; set; } + + /// + /// 关联的店铺订单 + /// + public string RelationShopOrderId { get; set; } + + /// + /// 错误信息 + /// + public string ErrorMessage { get; set; } + + } +} diff --git a/BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditPurchaseOrder.cs b/BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditPurchaseOrder.cs new file mode 100644 index 00000000..b095f269 --- /dev/null +++ b/BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditPurchaseOrder.cs @@ -0,0 +1,73 @@ +using System; + +namespace BBWY.Client.Models +{ + public class AuditPurchaseOrder + { + public string PurchaseOrderId { get; set; } + + /// + /// 采购平台 + /// + public Platform Platform { get; set; } + + public DateTime CreateTime { get; set; } + + public DateTime? PayTime { get; set; } + + /// + /// 采购数量 + /// + public int Quantity { get; set; } + + /// + /// 货款 + /// + public decimal ProductAmount { get; set; } + + /// + /// 运费 + /// + public decimal Freight { get; set; } + + /// + /// 实付 + /// + public decimal PayAmount { get; set; } + + /// + /// 联系电话 + /// + public string Phone { get; set; } + + /// + /// 收货地址 + /// + public string Address { get; set; } + + /// + /// 收货人 + /// + public string ContactName { get; set; } + + /// + /// 归属店铺 + /// + public string BelongShop { get; set; } + + public string BelongFileName { get; set; } + + /// + /// 关联账单Id + /// + public string RelationPayBillNo { get; set; } + + /// + /// 关联的店铺订单 + /// + public string RelationShopOrderId { get; set; } + + + public string ErrorMessage { get; set; } + } +} diff --git a/BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditShopOrder.cs b/BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditShopOrder.cs new file mode 100644 index 00000000..9f561f8d --- /dev/null +++ b/BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditShopOrder.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BBWY.Client.Models +{ + public class AuditShopOrder + { + public string OrderId { get; set; } + + public Platform Platform { get; set; } + + /// + /// 产品名称 + /// + public string ProductName { get; set; } + + /// + /// 销售数量 + /// + public int Quantity { get; set; } + + /// + /// 实付 + /// + public decimal PayAmount { get; set; } + + /// + /// 下单时间 + /// + public DateTime CreateTime { get; set; } + + /// + /// 支付时间 + /// + public DateTime? PayTime { get; set; } + + /// + /// 联系电话 + /// + public string Phone { get; set; } + + /// + /// 收货地址 + /// + public string Address { get; set; } + + /// + /// 收货人 + /// + public string ContactName { get; set; } + + /// + /// 商家备注 + /// + public string VenderRemark { get; set; } + + /// + /// 关联的采购单号 + /// + public string RelationPurchaseOrderId { get; set; } + + /// + /// 关联账单Id + /// + public string RelationPayBillNo { get; set; } + + /// + /// 归属店铺 + /// + public string BelongShop { get; set; } + + public string BelongFileName { get; set; } + + /// + /// 错误信息 + /// + public string ErrorMessage { get; set; } + } +} diff --git a/BBWY.Client/Resources/Themes/Generic.xaml b/BBWY.Client/Resources/Themes/Generic.xaml index 7853ca8f..f75c12c2 100644 --- a/BBWY.Client/Resources/Themes/Generic.xaml +++ b/BBWY.Client/Resources/Themes/Generic.xaml @@ -279,6 +279,9 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml.cs b/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml.cs new file mode 100644 index 00000000..67eaed14 --- /dev/null +++ b/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace BBWY.Client.Views.FinancialTerminal +{ + /// + /// ProcurementAudit.xaml 的交互逻辑 + /// + public partial class ProcurementAudit : Page + { + public ProcurementAudit() + { + InitializeComponent(); + } + } +} diff --git a/BBWY.Client/Views/MainWindow.xaml b/BBWY.Client/Views/MainWindow.xaml index 27110fe5..6e3fb1f5 100644 --- a/BBWY.Client/Views/MainWindow.xaml +++ b/BBWY.Client/Views/MainWindow.xaml @@ -26,7 +26,7 @@ - + diff --git a/BBWY.Client/Views/Ware/WareManager.xaml b/BBWY.Client/Views/Ware/WareManager.xaml index e8397011..5f2abc06 100644 --- a/BBWY.Client/Views/Ware/WareManager.xaml +++ b/BBWY.Client/Views/Ware/WareManager.xaml @@ -23,7 +23,7 @@ - + diff --git a/BBWY.Client/Views/Ware/WareStock.xaml b/BBWY.Client/Views/Ware/WareStock.xaml index d2c491f3..bebeb534 100644 --- a/BBWY.Client/Views/Ware/WareStock.xaml +++ b/BBWY.Client/Views/Ware/WareStock.xaml @@ -162,7 +162,7 @@ - + diff --git a/BBWY.Server.Business/Order/OrderBusiness.cs b/BBWY.Server.Business/Order/OrderBusiness.cs index b5d2fe24..d3b4dbbc 100644 --- a/BBWY.Server.Business/Order/OrderBusiness.cs +++ b/BBWY.Server.Business/Order/OrderBusiness.cs @@ -887,7 +887,7 @@ namespace BBWY.Server.Business PageSize = 100, Platform = shop.Platform, JDColType = string.IsNullOrEmpty(shop.VenderType) ? "0" : shop.VenderType, - SaveResponseLog = true, + SaveResponseLog = false, OrderId = orderId }, null, HttpMethod.Post); if (orderListApiResult.StatusCode != System.Net.HttpStatusCode.OK) diff --git a/BBWY.Server.Business/PlatformSDK/LogisticsCompanyConverter.cs b/BBWY.Server.Business/PlatformSDK/LogisticsCompanyConverter.cs new file mode 100644 index 00000000..9d47c321 --- /dev/null +++ b/BBWY.Server.Business/PlatformSDK/LogisticsCompanyConverter.cs @@ -0,0 +1,83 @@ +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> converterDictionary; + + public LogisticsCompanyConverter() + { + converterDictionary = new Dictionary>(); + converterDictionary.Add($"{Enums.Platform.阿里巴巴}_{Enums.Platform.京东}", new List() + { + new LogisticsCompanyRelationship(){SourceName="中通快递(ZTO)",TargetName="中通速递"}, + new LogisticsCompanyRelationship(){SourceName="圆通速递(YTO)",TargetName="圆通快递"}, + new LogisticsCompanyRelationship(){SourceName="邮政国内小包",TargetName="邮政快递包裹"}, + new LogisticsCompanyRelationship(){SourceName="韵达快递",TargetName="韵达快递"}, + new LogisticsCompanyRelationship(){SourceName="申通快递(STO)",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="厂家自送"}, + 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="厂家自送"} + }); + } + + /// + /// 翻译各平台之间的物流公司 + /// + /// + /// + /// + /// 用户支持的目标平台物流公司 + /// 目标平台的物流公司Id + public string Converter(string sourceName, + Enums.Platform sourcePlatform, + Enums.Platform targetPlatform, + IList targetPlatformUserLogisticsCompanyList) + { + var key = $"{sourcePlatform}_{targetPlatform}"; + if (!converterDictionary.TryGetValue(key, out IList 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) + 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; } + } +} diff --git a/BBWY.Server.Business/PlatformSDK/_1688Business.cs b/BBWY.Server.Business/PlatformSDK/_1688Business.cs index 733b1299..d0db87ee 100644 --- a/BBWY.Server.Business/PlatformSDK/_1688Business.cs +++ b/BBWY.Server.Business/PlatformSDK/_1688Business.cs @@ -79,7 +79,7 @@ namespace BBWY.Server.Business public override PreviewOrderResponse PreviewOrder(PreviewOrderReuqest previewOrderReuqest) { - logger.Info($"PreviewOrder {JsonConvert.SerializeObject(previewOrderReuqest)}"); + //logger.Info($"PreviewOrder {JsonConvert.SerializeObject(previewOrderReuqest)}"); var client = GetSyncAPIClient(previewOrderReuqest.AppKey, previewOrderReuqest.AppSecret); RequestPolicy reqPolicy = new RequestPolicy(); @@ -130,6 +130,8 @@ namespace BBWY.Server.Business if (result.Value("success") != true) throw new BusinessException(result.Value("errorMsg")) { Code = 0 }; + logger.Info($"PreviewOrder Request:{JsonConvert.SerializeObject(previewOrderReuqest)} Response:{result}"); + var orderPreviewResuslt = (JArray)result["orderPreviewResuslt"]; List intersectTradeModeList = new List(); diff --git a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs index a309612b..585e1e8b 100644 --- a/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs +++ b/BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs @@ -25,8 +25,8 @@ namespace BBWY.Server.Business private OrderBusiness orderBusiness; private MDSBusiness mdsBusiness; private VenderBusiness venderBusiness; - - private IDictionary deliverySelfDic; + private LogisticsCompanyConverter logisticsCompanyConverter; + //private IDictionary deliverySelfDic; public PurchaseOrderBusiness(IFreeSql fsql, NLog.ILogger logger, @@ -35,18 +35,19 @@ namespace BBWY.Server.Business TaskSchedulerManager taskSchedulerManager, OrderBusiness orderBusiness, MDSBusiness mdsBusiness, - VenderBusiness venderBusiness) : base(fsql, logger, idGenerator) + VenderBusiness venderBusiness, + LogisticsCompanyConverter logisticsCompanyConverter) : base(fsql, logger, idGenerator) { this.platformSDKBusinessList = platformSDKBusinessList; this.taskSchedulerManager = taskSchedulerManager; this.orderBusiness = orderBusiness; this.mdsBusiness = mdsBusiness; this.venderBusiness = venderBusiness; - - deliverySelfDic = new Dictionary() - { - {Enums.Platform.京东 , "1274"} //厂家自送 - }; + this.logisticsCompanyConverter = logisticsCompanyConverter; + //deliverySelfDic = new Dictionary() + //{ + // {Enums.Platform.京东 , "1274"} //厂家自送 + //}; } public void AddPurchaseOrder(AddPurchaseOrderRequest addPurchaseOrderRequest) @@ -507,8 +508,9 @@ namespace BBWY.Server.Business #endregion #region 物流公司翻译 - currentProgress = "将采购单的物流公司翻译为店铺平台的物流公司"; - logisticsCompanyId = ConvertLogisticsCompanyId(wayBillNoResponse.LogisticsCompanyName, logisticsCompanyList, shop.Platform); + currentProgress = "物流公司翻译"; + //logisticsCompanyId = ConvertLogisticsCompanyId(wayBillNoResponse.LogisticsCompanyName, logisticsCompanyList, shop.Platform); + logisticsCompanyId = logisticsCompanyConverter.Converter(wayBillNoResponse.LogisticsCompanyName, callbackPlatform, shop.Platform, logisticsCompanyList); #endregion #region 店铺平台订单出库 @@ -533,25 +535,26 @@ namespace BBWY.Server.Business } } - /// - /// 物流公司翻译, 将发货平台的物流公司翻译为店铺平台的物流公司 - /// - /// - /// - /// - /// - private string ConvertLogisticsCompanyId(string sourceLogisticsCompanyName, IList targetLogisticsList, Enums.Platform tagetLogisticsPlatform) - { - var match = Regex.Match(sourceLogisticsCompanyName, "(中通|圆通|申通|顺丰|韵达|邮政快递包裹|平邮|EMS|德邦|百世|天天|优速)"); - if (match.Success) - { - var sname = match.Groups[1].Value; - var targetLogistics = targetLogisticsList.FirstOrDefault(t => t.Name.Contains(sname)); - if (targetLogistics != null) - return targetLogistics.Id; - } - return deliverySelfDic[tagetLogisticsPlatform]; - } + ///// + ///// 物流公司翻译, 将发货平台的物流公司翻译为店铺平台的物流公司 + ///// + ///// + ///// + ///// + ///// + //private string ConvertLogisticsCompanyId(string sourceLogisticsCompanyName, IList targetLogisticsList, Enums.Platform tagetLogisticsPlatform) + //{ + // var match = Regex.Match(sourceLogisticsCompanyName, "(中通|圆通|申通|顺丰|韵达|邮政快递包裹|平邮|EMS|德邦|百世|天天|优速)"); + // if (match.Success) + // { + // var sname = match.Groups[1].Value; + // var targetLogistics = targetLogisticsList.FirstOrDefault(t => t.Name.Contains(sname)); + // if (targetLogistics != null) + // return targetLogistics.Id; + // } + // return deliverySelfDic[tagetLogisticsPlatform]; + //} + /// /// 采购平台改价回调