21 changed files with 1208 additions and 43 deletions
@ -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(); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
namespace BBWY.Client.Models |
||||
|
{ |
||||
|
public class AuditFile |
||||
|
{ |
||||
|
public string FileName { get; set; } |
||||
|
|
||||
|
public AuditFileType AuditFileType { get; set; } |
||||
|
} |
||||
|
} |
@ -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; } |
||||
|
|
||||
|
} |
||||
|
} |
@ -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; } |
||||
|
} |
||||
|
} |
@ -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; } |
||||
|
} |
||||
|
} |
@ -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] |
||||
|
#起始日期:[2022年04月01日 00:00:00] 终止日期:[2022年05月01日 00:00:00] |
||||
|
#-----------------------------------------账务明细列表---------------------------------------- |
||||
|
账务流水号 业务流水号 商户订单号 商品名称 发生时间 对方账号 收入金额(+元) 支出金额(-元) 账户余额(元) 交易渠道 业务类型 备注 |
||||
|
*/ |
||||
|
for (var i = 0; i < 5; i++) |
||||
|
importResult.Lines.RemoveAt(0); |
||||
|
|
||||
|
//忽略后4行
|
||||
|
/* |
||||
|
#-----------------------------------------账务明细列表结束------------------------------------ |
||||
|
#支出合计:681笔,共-39623.27元 |
||||
|
#收入合计:85笔,共43889.26元 |
||||
|
#导出时间:[2022年05月01日 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.账单);
|
||||
|
} |
||||
|
} |
||||
|
} |
@ -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> |
@ -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(); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -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; } |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue