Browse Source

合并

qianyi
shanji 3 years ago
parent
commit
2182510f1b
  1. 2
      BBWY.Client/App.xaml.cs
  2. 8
      BBWY.Client/BBWY.Client.csproj
  3. 77
      BBWY.Client/Extensions/ProcurementAuditExtension.cs
  4. 14
      BBWY.Client/Models/Enums.cs
  5. 9
      BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditFile.cs
  6. 70
      BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditPayBill.cs
  7. 73
      BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditPurchaseOrder.cs
  8. 80
      BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditShopOrder.cs
  9. 3
      BBWY.Client/Resources/Themes/Generic.xaml
  10. 538
      BBWY.Client/ViewModels/FinancialTerminal/ProcurementAuditViewModel.cs
  11. 16
      BBWY.Client/ViewModels/MainViewModel.cs
  12. 9
      BBWY.Client/ViewModels/ViewModelLocator.cs
  13. 168
      BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml
  14. 26
      BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml.cs
  15. 2
      BBWY.Client/Views/MainWindow.xaml
  16. 2
      BBWY.Client/Views/Ware/WareManager.xaml
  17. 2
      BBWY.Client/Views/Ware/WareStock.xaml
  18. 2
      BBWY.Server.Business/Order/OrderBusiness.cs
  19. 83
      BBWY.Server.Business/PlatformSDK/LogisticsCompanyConverter.cs
  20. 4
      BBWY.Server.Business/PlatformSDK/_1688Business.cs
  21. 61
      BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs

2
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

8
BBWY.Client/BBWY.Client.csproj

@ -15,13 +15,6 @@
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Extensions\**" />
<EmbeddedResource Remove="Extensions\**" />
<None Remove="Extensions\**" />
<Page Remove="Extensions\**" />
</ItemGroup>
<ItemGroup>
<None Remove="BBWYAppSettings.json" />
<None Remove="Resources\Images\defaultItem.png" />
@ -45,6 +38,7 @@
<PackageReference Include="MvvmLightLibsStd10" Version="5.4.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NLog" Version="4.7.12" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="6.0.0" />
</ItemGroup>
<ItemGroup>

77
BBWY.Client/Extensions/ProcurementAuditExtension.cs

@ -0,0 +1,77 @@
using System.Collections.Generic;
namespace BBWY.Client.Extensions
{
public static class ProcurementAuditExtension
{
/// <summary>
/// 跳过引号中的逗号,进行逗号分隔(字段内容中的逗号不参与分隔)
/// </summary>
/// <param name="strLine"></param>
/// <returns></returns>
public static string[] CSVstrToArry(this string splitStr)
{
var newstr = string.Empty;
List<string> sList = new List<string>();
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();
}
}
}

14
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
}
}

9
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; }
}
}

70
BBWY.Client/Models/FinancialTerminal/ProcurementAudit/AuditPayBill.cs

@ -0,0 +1,70 @@
using System;
namespace BBWY.Client.Models
{
public class AuditPayBill
{
/// <summary>
/// 账单流水号
/// </summary>
public string PayBillNo { get; set; }
/// <summary>
/// 支付时间
/// </summary>
public DateTime? PayTime { get; set; }
/// <summary>
/// 账单类型
/// </summary>
public PayBillType PayBillType { get; set; }
/// <summary>
/// 商家订单号
/// </summary>
public string SourceMerchantOrderNo { get; set; }
/// <summary>
/// 商家订单号(去掉账单添加的格式)
/// </summary>
public string MerchantOrderNo { get; set; }
/// <summary>
/// 商品名称
/// </summary>
public string ProductName { get; set; }
/// <summary>
/// 对方账户
/// </summary>
public string OppositeAccount { get; set; }
/// <summary>
/// 支出金额
/// </summary>
public decimal ExpenditureAmount { get; set; }
/// <summary>
/// 归属店铺
/// </summary>
public string BelongShop { get; set; }
public string BelongFileName { get; set; }
/// <summary>
/// 关联的采购单号
/// </summary>
public string RelationPurchaseOrderId { get; set; }
/// <summary>
/// 关联的店铺订单
/// </summary>
public string RelationShopOrderId { get; set; }
/// <summary>
/// 错误信息
/// </summary>
public string ErrorMessage { get; set; }
}
}

73
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; }
/// <summary>
/// 采购平台
/// </summary>
public Platform Platform { get; set; }
public DateTime CreateTime { get; set; }
public DateTime? PayTime { get; set; }
/// <summary>
/// 采购数量
/// </summary>
public int Quantity { get; set; }
/// <summary>
/// 货款
/// </summary>
public decimal ProductAmount { get; set; }
/// <summary>
/// 运费
/// </summary>
public decimal Freight { get; set; }
/// <summary>
/// 实付
/// </summary>
public decimal PayAmount { get; set; }
/// <summary>
/// 联系电话
/// </summary>
public string Phone { get; set; }
/// <summary>
/// 收货地址
/// </summary>
public string Address { get; set; }
/// <summary>
/// 收货人
/// </summary>
public string ContactName { get; set; }
/// <summary>
/// 归属店铺
/// </summary>
public string BelongShop { get; set; }
public string BelongFileName { get; set; }
/// <summary>
/// 关联账单Id
/// </summary>
public string RelationPayBillNo { get; set; }
/// <summary>
/// 关联的店铺订单
/// </summary>
public string RelationShopOrderId { get; set; }
public string ErrorMessage { get; set; }
}
}

80
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; }
/// <summary>
/// 产品名称
/// </summary>
public string ProductName { get; set; }
/// <summary>
/// 销售数量
/// </summary>
public int Quantity { get; set; }
/// <summary>
/// 实付
/// </summary>
public decimal PayAmount { get; set; }
/// <summary>
/// 下单时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 支付时间
/// </summary>
public DateTime? PayTime { get; set; }
/// <summary>
/// 联系电话
/// </summary>
public string Phone { get; set; }
/// <summary>
/// 收货地址
/// </summary>
public string Address { get; set; }
/// <summary>
/// 收货人
/// </summary>
public string ContactName { get; set; }
/// <summary>
/// 商家备注
/// </summary>
public string VenderRemark { get; set; }
/// <summary>
/// 关联的采购单号
/// </summary>
public string RelationPurchaseOrderId { get; set; }
/// <summary>
/// 关联账单Id
/// </summary>
public string RelationPayBillNo { get; set; }
/// <summary>
/// 归属店铺
/// </summary>
public string BelongShop { get; set; }
public string BelongFileName { get; set; }
/// <summary>
/// 错误信息
/// </summary>
public string ErrorMessage { get; set; }
}
}

3
BBWY.Client/Resources/Themes/Generic.xaml

@ -279,6 +279,9 @@
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style x:Key="verticalCenterTextBlock" TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style TargetType="DataGrid">
<Setter Property="AutoGenerateColumns" Value="False"/>

538
BBWY.Client/ViewModels/FinancialTerminal/ProcurementAuditViewModel.cs

@ -0,0 +1,538 @@
using BBWY.Client.Extensions;
using BBWY.Client.Models;
using BBWY.Common.Models;
using GalaSoft.MvvmLight.Command;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace BBWY.Client.ViewModels
{
public class ProcurementAuditViewModel : BaseVM, IDenpendency
{
private AuditFile selectAuditFile;
private bool isLoading;
private bool isAudited;
private bool isShowPayBillPanel;
private bool isShowPurchaseOrderPanel;
private bool isShowShopOrderPanel;
private bool onlyException;
public IList<AuditFile> AuditFileList { get; set; }
public IList<AuditPayBill> AuditPayBillList { get; set; }
public IList<AuditPurchaseOrder> AuditPurchaseOrderList { get; set; }
public IList<AuditShopOrder> AuditShopOrderList { get; set; }
public IList<AuditPayBill> ShowAuditPayBillList { get; set; }
public IList<AuditPurchaseOrder> ShowAuditPurchaseOrderList { get; set; }
public IList<AuditShopOrder> ShowAuditShopOrderList { get; set; }
public AuditFile SelectAuditFile
{
get => selectAuditFile; set
{
if (Set(ref selectAuditFile, value))
OnSelectAuditFileChanged();
}
}
public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } }
public bool IsAudited { get => isAudited; set { Set(ref isAudited, value); } }
public bool IsShowPayBillPanel
{
get => isShowPayBillPanel; set
{
if (Set(ref isShowPayBillPanel, value))
{
if (value)
{
IsShowPurchaseOrderPanel = false;
IsShowShopOrderPanel = false;
}
}
}
}
public bool IsShowPurchaseOrderPanel
{
get => isShowPurchaseOrderPanel; set
{
if (Set(ref isShowPurchaseOrderPanel, value))
{
if (value)
{
IsShowPayBillPanel = false;
IsShowShopOrderPanel = false;
}
}
}
}
public bool IsShowShopOrderPanel
{
get => isShowShopOrderPanel; set
{
if (Set(ref isShowShopOrderPanel, value))
{
if (value)
{
IsShowPayBillPanel = false;
IsShowPurchaseOrderPanel = false;
}
}
}
}
public bool OnlyException
{
get => onlyException; set
{
if (Set(ref onlyException, value))
OnOnlyExceptionChanged();
}
}
public ICommand AuditCommand { get; set; }
public ICommand ClearAuditCommand { get; set; }
public ICommand ImportAliPayBillCommand { get; set; }
public ICommand Import1688PurchaseOrderCommand { get; set; }
public ICommand ImportJDShopOrderCommand { get; set; }
public ProcurementAuditViewModel()
{
AuditFileList = new ObservableCollection<AuditFile>();
AuditCommand = new RelayCommand(Audit);
ClearAuditCommand = new RelayCommand(ClearAudit);
ImportAliPayBillCommand = new RelayCommand(ImportAliPayBill);
Import1688PurchaseOrderCommand = new RelayCommand(Import1688PurchaseOrder);
ImportJDShopOrderCommand = new RelayCommand(ImportJDShopOrder);
AuditFileList = new ObservableCollection<AuditFile>();
AuditPayBillList = new List<AuditPayBill>();
AuditPurchaseOrderList = new List<AuditPurchaseOrder>();
AuditShopOrderList = new List<AuditShopOrder>();
ShowAuditPayBillList = new ObservableCollection<AuditPayBill>();
ShowAuditPurchaseOrderList = new ObservableCollection<AuditPurchaseOrder>();
ShowAuditShopOrderList = new ObservableCollection<AuditShopOrder>();
//AuditFileList.Add(new AuditFile() { FileName = "支付宝账单20220527.csv", AuditFileType = AuditFileType.账单 });
//AuditFileList.Add(new AuditFile() { FileName = "1688采购单20220527.csv", AuditFileType = AuditFileType.采购单 });
//AuditFileList.Add(new AuditFile() { FileName = "支付宝账单20220527.csv", AuditFileType = AuditFileType.销售订单 });
}
private void Audit()
{
if (IsLoading)
return;
if (AuditPayBillList.Count() == 0 ||
AuditPurchaseOrderList.Count() == 0 ||
AuditShopOrderList.Count() == 0)
{
MessageBox.Show("审核数据不全", "提示");
return;
}
var waitList = new List<EventWaitHandle>()
{
new ManualResetEvent(false),
new ManualResetEvent(false)
};
IsLoading = true;
Task.Factory.StartNew(() =>
{
AuditByPayBill(waitList[0]);
AuditByPurchaseOrder(waitList[1]);
}).ContinueWith(t =>
{
WaitHandle.WaitAll(waitList.ToArray(), -1);
IsLoading = false;
IsAudited = true;
App.Current.Dispatcher.BeginInvoke((Action)delegate
{
SelectAuditFile = AuditFileList.FirstOrDefault(f => f.AuditFileType == AuditFileType.);
});
});
}
private void AuditByPayBill(EventWaitHandle ewh)
{
try
{
foreach (var payBill in AuditPayBillList)
{
#region 匹配采购单
var relationPurchaseOrder = AuditPurchaseOrderList.FirstOrDefault(p => p.PurchaseOrderId == payBill.MerchantOrderNo);
if (relationPurchaseOrder == null)
{
//未通过商户订单号找到采购单,则通过账单金额和日期匹配
relationPurchaseOrder = AuditPurchaseOrderList.FirstOrDefault(p => p.PayAmount == payBill.ExpenditureAmount &&
p.PayTime != null && payBill.PayTime != null &&
Math.Abs((payBill.PayTime.Value - p.PayTime.Value).TotalSeconds) <= 60);
}
if (relationPurchaseOrder == null)
{
payBill.ErrorMessage = "未匹配采购单";
continue;
}
payBill.RelationPurchaseOrderId = relationPurchaseOrder.PurchaseOrderId;
#endregion
#region 匹配销售订单
var relationShopOrder = AuditShopOrderList.FirstOrDefault(o => (!string.IsNullOrEmpty(o.VenderRemark) && o.VenderRemark.Contains(relationPurchaseOrder.PurchaseOrderId)) ||
(o.Phone == relationPurchaseOrder.Phone &&
o.ContactName == relationPurchaseOrder.ContactName &&
o.PayTime != null && relationPurchaseOrder.PayTime != null &&
(relationPurchaseOrder.PayTime.Value - o.PayTime.Value).TotalDays <= 2));
if (relationShopOrder == null)
{
payBill.ErrorMessage = "未匹配销售订单";
continue;
}
payBill.RelationShopOrderId = relationShopOrder.OrderId;
#endregion
}
}
catch (Exception ex)
{
App.Current.Dispatcher.Invoke(() => MessageBox.Show(ex.Message, "账单匹配"));
}
finally
{
ewh.Set();
}
}
private void AuditByPurchaseOrder(EventWaitHandle ewh)
{
try
{
foreach (var purchaseOrder in AuditPurchaseOrderList)
{
#region 匹配账单
var relationPayBill = AuditPayBillList.FirstOrDefault(b => b.MerchantOrderNo == purchaseOrder.PurchaseOrderId);
if (relationPayBill == null)
{
//未通过商户订单号找到采购单,则通过账单金额和日期匹配
relationPayBill = AuditPayBillList.FirstOrDefault(b => purchaseOrder.PayAmount == b.ExpenditureAmount &&
purchaseOrder.PayTime != null && b.PayTime != null &&
Math.Abs((b.PayTime.Value - purchaseOrder.PayTime.Value).TotalSeconds) <= 60);
}
if (relationPayBill == null)
{
purchaseOrder.ErrorMessage = "未匹配支付账单";
continue;
}
purchaseOrder.RelationPayBillNo = relationPayBill.PayBillNo;
#endregion
#region 匹配销售单
var relationShopOrder = AuditShopOrderList.FirstOrDefault(o => (!string.IsNullOrEmpty(o.VenderRemark) && o.VenderRemark.Contains(purchaseOrder.PurchaseOrderId)) ||
(o.Phone == purchaseOrder.Phone &&
o.ContactName == purchaseOrder.ContactName &&
o.PayTime != null && purchaseOrder.PayTime != null &&
(purchaseOrder.PayTime.Value - o.PayTime.Value).TotalDays <= 2));
if (relationShopOrder == null)
{
purchaseOrder.ErrorMessage = "未匹配销售订单";
continue;
}
purchaseOrder.RelationShopOrderId = relationShopOrder.OrderId;
#endregion
}
}
catch (Exception ex)
{
App.Current.Dispatcher.Invoke(() => MessageBox.Show(ex.Message, "采购单匹配"));
}
finally
{
ewh.Set();
}
}
private void ClearAudit()
{
SelectAuditFile = null;
AuditFileList.Clear();
AuditPayBillList.Clear();
AuditPurchaseOrderList.Clear();
AuditShopOrderList.Clear();
ShowAuditPayBillList.Clear();
ShowAuditPurchaseOrderList.Clear();
ShowAuditShopOrderList.Clear();
IsAudited = false;
IsShowPayBillPanel = false;
IsShowPurchaseOrderPanel = false;
IsShowShopOrderPanel = false;
OnlyException = false;
}
private (string ErrorMessage, string FileName, IList<string> Lines) ImportAuditFile(AuditFileType auditFileType)
{
var ofd = new OpenFileDialog() { Filter = "CSV Files (*.csv)|*.csv" };
if (ofd.ShowDialog() != true)
return (string.Empty, string.Empty, null);
var fileName = ofd.FileName.Substring(ofd.FileName.LastIndexOf("\\") + 1);
var filePath = ofd.FileName;
if (AuditFileList.Any(f => f.FileName == fileName))
return ("文件已存在", string.Empty, null);
try
{
var lines = File.ReadAllLines(filePath, Encoding.GetEncoding("GB2312")).ToList();
AuditFileList.Add(new AuditFile() { FileName = fileName, AuditFileType = auditFileType });
return (string.Empty, fileName, lines);
}
catch (Exception ex)
{
return (ex.Message, string.Empty, null);
}
}
/// <summary>
/// 导入支付宝账单
/// </summary>
private void ImportAliPayBill()
{
var importResult = ImportAuditFile(AuditFileType.);
if (!string.IsNullOrEmpty(importResult.ErrorMessage))
{
MessageBox.Show(importResult.ErrorMessage, "导入支付宝账单");
return;
}
if (importResult.Lines == null || importResult.Lines.Count() == 0)
return;
//忽略前5行
/*
#
#[20883422054731100156]
#[20220401 00:00:00] [20220501 00:00:00]
#---------------------------------------------------------------------------------
+ -
*/
for (var i = 0; i < 5; i++)
importResult.Lines.RemoveAt(0);
//忽略后4行
/*
#-----------------------------------------------------------------------------
#681-39623.27
#8543889.26
#[20220501 10:13:45]
*/
for (var i = 0; i < 4; i++)
{
importResult.Lines.RemoveAt(importResult.Lines.Count() - 1);
}
var payBillNo = "";
try
{
foreach (var line in importResult.Lines)
{
var array = line.CSVstrToArry();
var sourceMerchantOrderNo = array[2].FormatString();
if (!string.IsNullOrEmpty(sourceMerchantOrderNo) && sourceMerchantOrderNo.StartsWith("XP"))
continue; //暂时不支持此类商户单号
var expenditureAmount = decimal.Parse(array[7].FormatString());
if (expenditureAmount == 0) //支出为0的账单不参与审计
continue;
payBillNo = array[0].FormatString();
if (AuditPayBillList.Any(p => p.PayBillNo == payBillNo))
continue;
var payBill = new AuditPayBill()
{
BelongFileName = importResult.FileName,
PayBillNo = payBillNo,
PayBillType = PayBillType.AliPay,
SourceMerchantOrderNo = sourceMerchantOrderNo,
ProductName = array[3].FormatString(),
PayTime = DateTime.Parse(array[4].FormatString()),
OppositeAccount = array[5].FormatString(),
ExpenditureAmount = Math.Abs(expenditureAmount)
};
payBill.MerchantOrderNo = payBill.SourceMerchantOrderNo;
if (payBill.SourceMerchantOrderNo.StartsWith("T50060NP"))
payBill.MerchantOrderNo = payBill.SourceMerchantOrderNo.Substring(8);
AuditPayBillList.Add(payBill);
}
}
catch (Exception ex)
{
MessageBox.Show($"问题账单号{payBillNo} {ex.Message}", "导入支付宝账单");
}
}
/// <summary>
/// 导入1688采购单
/// </summary>
private void Import1688PurchaseOrder()
{
var importResult = ImportAuditFile(AuditFileType.);
if (!string.IsNullOrEmpty(importResult.ErrorMessage))
{
MessageBox.Show(importResult.ErrorMessage, "导入1688采购单");
return;
}
if (importResult.Lines == null || importResult.Lines.Count() == 0)
return;
//去掉列名
importResult.Lines.RemoveAt(0);
var purchaseOrderId = "";
try
{
foreach (var line in importResult.Lines)
{
var array = line.CSVstrToArry();
purchaseOrderId = array[0].FormatString();
if (string.IsNullOrEmpty(purchaseOrderId) || AuditPurchaseOrderList.Any(p => p.PurchaseOrderId == purchaseOrderId))
continue;
var purchaseOrder = new AuditPurchaseOrder()
{
PurchaseOrderId = purchaseOrderId,
Platform = Platform.,
BelongFileName = importResult.FileName,
ProductAmount = decimal.Parse(array[5].FormatString()),
Freight = decimal.Parse(array[6].FormatString()),
PayAmount = decimal.Parse(array[8].FormatString()),
CreateTime = DateTime.Parse(array[10].FormatString()),
ContactName = array[13].FormatString(),
Address = array[14].FormatString(),
Phone = array[17].FormatString(),
Quantity = int.Parse(array[20].FormatString())
};
if (!string.IsNullOrEmpty(array[11]))
purchaseOrder.PayTime = DateTime.Parse(array[11].FormatString());
AuditPurchaseOrderList.Add(purchaseOrder);
}
Console.WriteLine(AuditPurchaseOrderList.Count());
}
catch (Exception ex)
{
MessageBox.Show($"问题采购单号{purchaseOrderId} {ex.Message}", "导入1688采购单");
}
}
/// <summary>
/// 导入京东销售订单
/// </summary>
private void ImportJDShopOrder()
{
var importResult = ImportAuditFile(AuditFileType.);
if (!string.IsNullOrEmpty(importResult.ErrorMessage))
{
MessageBox.Show(importResult.ErrorMessage, "导入京东销售订单");
return;
}
if (importResult.Lines == null || importResult.Lines.Count() == 0)
return;
//去掉列名
importResult.Lines.RemoveAt(0);
var orderId = "";
try
{
foreach (var line in importResult.Lines)
{
var array = line.CSVstrToArry();
orderId = array[0].FormatString();
if (string.IsNullOrEmpty(orderId) || AuditShopOrderList.Any(p => p.OrderId == orderId))
continue;
var order = new AuditShopOrder()
{
OrderId = orderId,
Platform = Platform.,
BelongFileName = importResult.FileName,
Quantity = int.Parse(array[3].FormatString()),
CreateTime = DateTime.Parse(array[5].FormatString()),
PayAmount = decimal.Parse(array[10].FormatString()),
ContactName = array[14].FormatString(),
Address = array[15].FormatString(),
Phone = array[16].FormatString(),
ProductName = array[2].FormatString(),
VenderRemark = array[27].FormatString()
};
AuditShopOrderList.Add(order);
if (!string.IsNullOrEmpty(array[30]))
order.PayTime = DateTime.Parse(array[30].FormatString());
}
}
catch (Exception ex)
{
MessageBox.Show($"问题销售订单号{orderId} {ex.Message}", "导入京东销售订单");
}
}
/// <summary>
/// 采购审计文件对象改变事件
/// </summary>
private void OnSelectAuditFileChanged()
{
if (SelectAuditFile == null)
return;
if (SelectAuditFile.AuditFileType == AuditFileType.)
{
IsShowPayBillPanel = true;
ShowAuditPayBillList.Clear();
var where = AuditPayBillList.Where(b => b.BelongFileName == SelectAuditFile.FileName);
if (OnlyException)
where = where.Where(b => !string.IsNullOrEmpty(b.ErrorMessage));
var list = where.ToList();
foreach (var b in list)
ShowAuditPayBillList.Add(b);
}
else if (SelectAuditFile.AuditFileType == AuditFileType.)
{
IsShowPurchaseOrderPanel = true;
ShowAuditPurchaseOrderList.Clear();
var where = AuditPurchaseOrderList.Where(p => p.BelongFileName == SelectAuditFile.FileName);
if (OnlyException)
where = where.Where(p => !string.IsNullOrEmpty(p.ErrorMessage));
var list = where.ToList();
foreach (var p in list)
ShowAuditPurchaseOrderList.Add(p);
}
else if (SelectAuditFile.AuditFileType == AuditFileType.)
{
}
}
private void OnOnlyExceptionChanged()
{
if (SelectAuditFile == null || AuditFileList.Count() == 0)
return;
var f = SelectAuditFile;
SelectAuditFile = null;
SelectAuditFile = f;
//SelectAuditFile = AuditFileList.FirstOrDefault(f => f.AuditFileType == AuditFileType.账单);
}
}
}

16
BBWY.Client/ViewModels/MainViewModel.cs

@ -8,6 +8,7 @@ using Microsoft.Web.WebView2.Core;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
@ -83,7 +84,7 @@ namespace BBWY.Client.ViewModels
ChooseShopCommand = new RelayCommand<Shop>((s) => ChooseShop(s));
this.GlobalContext = globalContext;
ShopList = new ObservableCollection<Shop>();
MenuList = new List<MenuModel>()
MenuList = new ObservableCollection<MenuModel>()
{
new MenuModel()
{
@ -108,6 +109,15 @@ namespace BBWY.Client.ViewModels
new MenuModel(){ Name="店铺设置",Url="/Views/Setting/ShopSetting.xaml" },
new MenuModel(){ Name="团队配置",Url="/Views/Setting/TeamSetting.xaml" }
}
},
new MenuModel()
{
Name="财务端",ChildList=new List<MenuModel>()
{
new MenuModel(){ Name="采购审计",Url="/Views/FinancialTerminal/ProcurementAudit.xaml" }
//new MenuModel(){ Name="补单审计",Url="/Views/FinancialTerminal/ShopSetting.xaml" },
//new MenuModel(){ Name="利润表",Url="/Views/FinancialTerminal/ShopSetting.xaml" }
}
}
};
Task.Factory.StartNew(Login);
@ -136,6 +146,10 @@ namespace BBWY.Client.ViewModels
throw new Exception($"获取磨刀石用户信息失败 {mdsUserResponse.Msg}");
GlobalContext.User = mdsUserResponse.Data.Map<User>();
#if RELEASE
if (GlobalContext.User.TeamName != "财务部")
App.Current.Dispatcher.Invoke(() => MenuList.RemoveAt(MenuList.Count() - 1));
#endif
//请求用户信息接口
//GlobalContext.User = new User()

9
BBWY.Client/ViewModels/ViewModelLocator.cs

@ -97,5 +97,14 @@ namespace BBWY.Client.ViewModels
return s.ServiceProvider.GetRequiredService<ShopSettingViewModel>();
}
}
public ProcurementAuditViewModel ProcurementAudit
{
get
{
using var s = sp.CreateScope();
return s.ServiceProvider.GetRequiredService<ProcurementAuditViewModel>();
}
}
}
}

168
BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml

@ -0,0 +1,168 @@
<Page x:Class="BBWY.Client.Views.FinancialTerminal.ProcurementAudit"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BBWY.Client.Views.FinancialTerminal"
mc:Ignorable="d"
xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls"
d:DesignHeight="450" d:DesignWidth="800"
Title="ProcurementAudit"
DataContext="{Binding ProcurementAudit,Source={StaticResource Locator}}">
<Grid>
<c:RoundWaitProgress Play="{Binding IsLoading}" Panel.ZIndex="999"/>
<Grid Margin="5,0">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="5"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="5"/>
<RowDefinition Height="30"/>
<RowDefinition Height="5"/>
<RowDefinition Height="auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border Background="{StaticResource Border.Background}" Padding="5,0">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<ComboBox Width="100" IsEnabled="false"/>
<ComboBox Width="100" IsEnabled="false" Margin="5,0,0,0"/>
<DatePicker Width="100" IsEnabled="false" Height="30" Margin="5,0,0,0"/>
<DatePicker Width="100" IsEnabled="false" Height="30" Margin="5,0,0,0"/>
<c:BButton Content="执行" Margin="5,0,0,0" Padding="10,0" Command="{Binding AuditCommand}"/>
<c:BButton Content="清空" Margin="5,0,0,0" Padding="10,0" Command="{Binding ClearAuditCommand}"/>
</StackPanel>
</Border>
<Grid Grid.Row="2">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="支付数据"/>
<TextBlock Text="采购数据" Grid.Column="1"/>
<TextBlock Text="销售数据" Grid.Column="2"/>
<Border Background="{StaticResource Border.Background}" Grid.Row="1" Margin="0,0,5,0">
<StackPanel Orientation="Horizontal">
<c:BButton Content="导入支付宝账单" Padding="10,0" Margin="5,0,0,0" Command="{Binding ImportAliPayBillCommand}"/>
<c:BButton Content="导入微信账单" Padding="10,0" Margin="5,0,0,0"
IsEnabled="False" DisableText="{Binding Content,RelativeSource={RelativeSource Mode=Self}}"/>
</StackPanel>
</Border>
<Border Background="{StaticResource Border.Background}" Grid.Row="1" Grid.Column="1" Margin="0,0,5,0">
<StackPanel Orientation="Horizontal">
<c:BButton Content="导入1688采购单" Padding="10,0" Margin="5,0,0,0" Command="{Binding Import1688PurchaseOrderCommand}"/>
<c:BButton Content="导入淘宝采购单" Padding="10,0" Margin="5,0,0,0"
IsEnabled="False" DisableText="{Binding Content,RelativeSource={RelativeSource Mode=Self}}"/>
<c:BButton Content="导入拼多多采购单" Padding="10,0" Margin="5,0,0,0"
IsEnabled="False" DisableText="{Binding Content,RelativeSource={RelativeSource Mode=Self}}"/>
</StackPanel>
</Border>
<Border Background="{StaticResource Border.Background}" Grid.Row="1" Grid.Column="2">
<StackPanel Orientation="Horizontal">
<c:BButton Content="后台出单表(京东)" Padding="10,0" Margin="5,0,0,0" Command="{Binding ImportJDShopOrderCommand}"/>
<c:BButton Content="后台出单表(淘宝)" Padding="10,0" Margin="5,0,0,0"
IsEnabled="False" DisableText="{Binding Content,RelativeSource={RelativeSource Mode=Self}}"/>
<c:BButton Content="后台出单表(拼多多)" Padding="10,0" Margin="5,0,0,0"
IsEnabled="False" DisableText="{Binding Content,RelativeSource={RelativeSource Mode=Self}}"/>
</StackPanel>
</Border>
</Grid>
<ListBox ItemsSource="{Binding AuditFileList}"
SelectedItem="{Binding SelectAuditFile,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
Grid.Row="4"
IsEnabled="{Binding IsAudited,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource NoBgListBoxItemStyle}">
<Style.Triggers>
<DataTrigger Binding="{Binding AuditFileType}" Value="销售订单">
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderThickness="1"
BorderBrush="{StaticResource Border.Brush}"
Height="30"
Padding="5,0"
Margin="0,0,-1,0">
<TextBlock x:Name="txtFileName" Text="{Binding FileName}"
VerticalAlignment="Center"/>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsSelected,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBoxItem}}}"
Value="True">
<DataTrigger.Setters>
<Setter TargetName="txtFileName" Property="Foreground" Value="{StaticResource Text.Link.Color }"/>
</DataTrigger.Setters>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<CheckBox Content="仅显示异常" Grid.Row="6"
IsChecked="{Binding OnlyException,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
FocusVisualStyle="{x:Null}"/>
<DataGrid ItemsSource="{Binding ShowAuditPayBillList}"
Grid.Row="7"
Visibility="{Binding IsShowPayBillPanel,Converter={StaticResource objConverter},ConverterParameter=true:Visible:Collapsed}">
<DataGrid.Columns>
<DataGridTextColumn Header="账单流水号" Width="145" Binding="{Binding PayBillNo}" ElementStyle="{StaticResource verticalCenterTextBlock}"/>
<DataGridTextColumn Header="账单平台" Width="60" Binding="{Binding PayBillType}" ElementStyle="{StaticResource middleTextBlock}"/>
<DataGridTextColumn Header="支付时间" Width="130" Binding="{Binding PayTime,StringFormat=yyyy-MM-dd HH:mm:ss}" ElementStyle="{StaticResource verticalCenterTextBlock}"/>
<DataGridTextColumn Header="对方账号" Width="100" Binding="{Binding OppositeAccount}" ElementStyle="{StaticResource verticalCenterTextBlock}"/>
<DataGridTextColumn Header="支出金额" Width="60" Binding="{Binding ExpenditureAmount}" ElementStyle="{StaticResource middleTextBlock}"/>
<DataGridTextColumn Header="商户订单号" Width="200" Binding="{Binding SourceMerchantOrderNo}" ElementStyle="{StaticResource verticalCenterTextBlock}"/>
<DataGridTextColumn Header="归属店铺" Width="100" Binding="{Binding BelongShop}" ElementStyle="{StaticResource verticalCenterTextBlock}"/>
<DataGridTextColumn Header="关联采购单" Width="140" Binding="{Binding RelationPurchaseOrderId}" ElementStyle="{StaticResource verticalCenterTextBlock}"/>
<DataGridTextColumn Header="关联销售单" Width="140" Binding="{Binding RelationShopOrderId}" ElementStyle="{StaticResource verticalCenterTextBlock}"/>
<DataGridTextColumn Header="异常内容" Width="*" Binding="{Binding ErrorMessage}" Foreground="Red" ElementStyle="{StaticResource verticalCenterTextBlock}"/>
</DataGrid.Columns>
</DataGrid>
<DataGrid ItemsSource="{Binding ShowAuditPurchaseOrderList}"
Grid.Row="7"
Visibility="{Binding IsShowPurchaseOrderPanel,Converter={StaticResource objConverter},ConverterParameter=true:Visible:Collapsed}">
<DataGrid.Columns>
<DataGridTextColumn Header="采购单号" Width="145" Binding="{Binding PurchaseOrderId}" ElementStyle="{StaticResource verticalCenterTextBlock}"/>
<DataGridTextColumn Header="采购平台" Width="60" Binding="{Binding Platform}" ElementStyle="{StaticResource middleTextBlock}"/>
<DataGridTextColumn Header="创建时间" Width="130" Binding="{Binding CreateTime,StringFormat=yyyy-MM-dd HH:mm:ss}"
ElementStyle="{StaticResource verticalCenterTextBlock}"/>
<DataGridTextColumn Header="付款时间" Width="130" Binding="{Binding CreateTime,StringFormat=yyyy-MM-dd HH:mm:ss}"
ElementStyle="{StaticResource verticalCenterTextBlock}"/>
<DataGridTextColumn Header="货品总价" Width="60" Binding="{Binding ProductAmount}" ElementStyle="{StaticResource middleTextBlock}"/>
<DataGridTextColumn Header="运费" Width="60" Binding="{Binding Freight}" ElementStyle="{StaticResource middleTextBlock}"/>
<DataGridTextColumn Header="联系人" Width="60" Binding="{Binding ContactName}" ElementStyle="{StaticResource middleTextBlock}"/>
<DataGridTextColumn Header="手机号" Width="90" Binding="{Binding Phone}" ElementStyle="{StaticResource verticalCenterTextBlock}"/>
<DataGridTextColumn Header="收货地址" Width="150" Binding="{Binding Address}"/>
<DataGridTextColumn Header="归属店铺" Width="100" Binding="{Binding BelongShop}" ElementStyle="{StaticResource verticalCenterTextBlock}"/>
<DataGridTextColumn Header="关联账单" Width="140" Binding="{Binding RelationPayBillNo}" ElementStyle="{StaticResource verticalCenterTextBlock}"/>
<DataGridTextColumn Header="关联销售单" Width="140" Binding="{Binding RelationShopOrderId}" ElementStyle="{StaticResource verticalCenterTextBlock}"/>
<DataGridTextColumn Header="异常内容" Width="*" Binding="{Binding ErrorMessage}" Foreground="Red" ElementStyle="{StaticResource verticalCenterTextBlock}"/>
</DataGrid.Columns>
</DataGrid>
<DataGrid ItemsSource="{Binding ShowAuditShopOrderList}"
Grid.Row="7"
Visibility="{Binding IsShowShopOrderPanel,Converter={StaticResource objConverter},ConverterParameter=true:Visible:Collapsed}">
</DataGrid>
</Grid>
</Grid>
</Page>

26
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
{
/// <summary>
/// ProcurementAudit.xaml 的交互逻辑
/// </summary>
public partial class ProcurementAudit : Page
{
public ProcurementAudit()
{
InitializeComponent();
}
}
}

2
BBWY.Client/Views/MainWindow.xaml

@ -26,7 +26,7 @@
<!--<TextBlock Text="{Binding GlobalContext.User.TeamName}" Margin="5,0,0,0"/>
<TextBlock Text="{Binding GlobalContext.User.Shop.Platform}" Margin="5,0,0,0"/>-->
<TextBlock Text="{Binding GlobalContext.User.Shop.Name}" Margin="5,0,0,0"/>
<TextBlock Text="v10014" Margin="5,0,0,0"/>
<TextBlock Text="v10015" Margin="5,0,0,0"/>
</StackPanel>
</Border>
<Grid Grid.Row="1">

2
BBWY.Client/Views/Ware/WareManager.xaml

@ -23,7 +23,7 @@
<c:RoundWaitProgress Play="{Binding IsLoading}" Panel.ZIndex="999"/>
<Grid Margin="5,0">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="40"/>
<RowDefinition Height="5"/>
<RowDefinition Height="30"/>
<RowDefinition/>

2
BBWY.Client/Views/Ware/WareStock.xaml

@ -162,7 +162,7 @@
<c:RoundWaitProgress Play="{Binding IsLoading}" Panel.ZIndex="999"/>
<Grid Margin="5,0">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="40"/>
<RowDefinition Height="5"/>
<RowDefinition Height="30"/>
<RowDefinition/>

2
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)

83
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<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="厂家自送"},
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="厂家自送"}
});
}
/// <summary>
/// 翻译各平台之间的物流公司
/// </summary>
/// <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)
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; }
}
}

4
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<bool>("success") != true)
throw new BusinessException(result.Value<string>("errorMsg")) { Code = 0 };
logger.Info($"PreviewOrder Request:{JsonConvert.SerializeObject(previewOrderReuqest)} Response:{result}");
var orderPreviewResuslt = (JArray)result["orderPreviewResuslt"];
List<JToken> intersectTradeModeList = new List<JToken>();

61
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<Enums.Platform, string> deliverySelfDic;
private LogisticsCompanyConverter logisticsCompanyConverter;
//private IDictionary<Enums.Platform, string> 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, string>()
{
{Enums.Platform. , "1274"} //厂家自送
};
this.logisticsCompanyConverter = logisticsCompanyConverter;
//deliverySelfDic = new Dictionary<Enums.Platform, string>()
//{
// {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
}
}
/// <summary>
/// 物流公司翻译, 将发货平台的物流公司翻译为店铺平台的物流公司
/// </summary>
/// <param name="sourceLogisticsCompanyName"></param>
/// <param name="targetLogisticsList"></param>
/// <param name="tagetLogisticsPlatform"></param>
/// <returns></returns>
private string ConvertLogisticsCompanyId(string sourceLogisticsCompanyName, IList<LogisticsResponse> 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];
}
///// <summary>
///// 物流公司翻译, 将发货平台的物流公司翻译为店铺平台的物流公司
///// </summary>
///// <param name="sourceLogisticsCompanyName"></param>
///// <param name="targetLogisticsList"></param>
///// <param name="tagetLogisticsPlatform"></param>
///// <returns></returns>
//private string ConvertLogisticsCompanyId(string sourceLogisticsCompanyName, IList<LogisticsResponse> 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];
//}
/// <summary>
/// 采购平台改价回调

Loading…
Cancel
Save