|
|
@ -27,6 +27,7 @@ namespace BBWY.Client.ViewModels |
|
|
|
private bool isShowPayBillPanel; |
|
|
|
private bool onlyException; |
|
|
|
private PurchaseOrderService purchaseOrderService; |
|
|
|
private FinancialTerminalService financialTerminalService; |
|
|
|
private Department selectedDepartment; |
|
|
|
private DateTime startDate; |
|
|
|
private DateTime endDate; |
|
|
@ -34,7 +35,7 @@ namespace BBWY.Client.ViewModels |
|
|
|
private bool noMatchPurchaseOrder; |
|
|
|
private bool noChooseFundType; |
|
|
|
private string searchResultPurchaseOrder; |
|
|
|
|
|
|
|
private Platform? selectPurchasePlatform; |
|
|
|
public Department SelectedDepartment |
|
|
|
{ |
|
|
|
get => selectedDepartment; set |
|
|
@ -96,6 +97,10 @@ namespace BBWY.Client.ViewModels |
|
|
|
public ICommand SearchHistoryCommand { get; set; } |
|
|
|
|
|
|
|
public ICommand SearchLocalCommand { get; set; } |
|
|
|
public ICommand ClearLocalConditionCommand { get; set; } |
|
|
|
|
|
|
|
public ICommand SaveCommand { get; set; } |
|
|
|
|
|
|
|
public Shop SelectResultShop { get => selectResultShop; set { Set(ref selectResultShop, value); } } |
|
|
|
|
|
|
|
public bool NoMatchPurchaseOrder { get => noMatchPurchaseOrder; set { Set(ref noMatchPurchaseOrder, value); } } |
|
|
@ -103,7 +108,9 @@ namespace BBWY.Client.ViewModels |
|
|
|
|
|
|
|
public string SearchResultPurchaseOrder { get => searchResultPurchaseOrder; set { Set(ref searchResultPurchaseOrder, value); } } |
|
|
|
|
|
|
|
public ProcurementAuditViewModel(PurchaseOrderService purchaseOrderService, GlobalContext globalContext) |
|
|
|
public Platform? SelectPurchasePlatform { get => selectPurchasePlatform; set { Set(ref selectPurchasePlatform, value); } } |
|
|
|
|
|
|
|
public ProcurementAuditViewModel(PurchaseOrderService purchaseOrderService, FinancialTerminalService financialTerminalService, GlobalContext globalContext) |
|
|
|
{ |
|
|
|
this.globalContext = globalContext; |
|
|
|
AuditFileList = new ObservableCollection<AuditFile>(); |
|
|
@ -112,7 +119,10 @@ namespace BBWY.Client.ViewModels |
|
|
|
ImportAliPayBillCommand = new RelayCommand(ImportAliPayBill); |
|
|
|
SearchHistoryCommand = new RelayCommand(SearchHistory); |
|
|
|
SearchLocalCommand = new RelayCommand(SearchLocal); |
|
|
|
ClearLocalConditionCommand = new RelayCommand(ClearLocalCondition); |
|
|
|
SaveCommand = new RelayCommand(Save); |
|
|
|
this.purchaseOrderService = purchaseOrderService; |
|
|
|
this.financialTerminalService = financialTerminalService; |
|
|
|
|
|
|
|
DepartmentList = new ObservableCollection<Department>(); |
|
|
|
AuditFileList = new ObservableCollection<AuditFile>(); |
|
|
@ -226,6 +236,7 @@ namespace BBWY.Client.ViewModels |
|
|
|
payBill.RelationShopOrderId = relationPurchaseOrder.OrderId; |
|
|
|
payBill.BelongShopId = relationPurchaseOrder.ShopId; |
|
|
|
payBill.BelongShop = shopList.FirstOrDefault(s => s.ShopId == relationPurchaseOrder.ShopId)?.ShopName; |
|
|
|
payBill.PurchasePlatform = relationPurchaseOrder.PurchasePlatform; |
|
|
|
if (payBill.IncomeAmount > 0) |
|
|
|
payBill.AuditCapitalType = AuditCapitalType.当月商品退款; |
|
|
|
else |
|
|
@ -275,7 +286,9 @@ namespace BBWY.Client.ViewModels |
|
|
|
//IsShowShopOrderPanel = false;
|
|
|
|
OnlyException = false; |
|
|
|
SelectResultShop = null; |
|
|
|
|
|
|
|
NoChooseFundType = false; |
|
|
|
NoMatchPurchaseOrder = false; |
|
|
|
SearchResultPurchaseOrder = string.Empty; |
|
|
|
} |
|
|
|
|
|
|
|
private (string ErrorMessage, string FileName, List<string> Lines) ImportAuditFile(AuditFileType auditFileType) |
|
|
@ -389,6 +402,16 @@ namespace BBWY.Client.ViewModels |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void ClearLocalCondition() |
|
|
|
{ |
|
|
|
OnlyException = false; |
|
|
|
NoMatchPurchaseOrder = false; |
|
|
|
NoChooseFundType = false; |
|
|
|
SelectResultShop = null; |
|
|
|
SelectPurchasePlatform = null; |
|
|
|
SearchLocal(); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 采购审计文件对象改变事件
|
|
|
|
/// </summary>
|
|
|
@ -409,12 +432,53 @@ namespace BBWY.Client.ViewModels |
|
|
|
where = where.Where(b => !string.IsNullOrEmpty(b.ErrorMessage) && b.ErrorMessage == "未选资金类型"); |
|
|
|
if (SelectResultShop != null) |
|
|
|
where = where.Where(b => b.BelongShopId != null && b.BelongShopId.Value == SelectResultShop.ShopId); |
|
|
|
if (string.IsNullOrEmpty(SearchResultPurchaseOrder)) |
|
|
|
where = where.Where(b => b.RelationPurchaseOrderId == SearchResultPurchaseOrder); |
|
|
|
if (!string.IsNullOrEmpty(SearchResultPurchaseOrder)) |
|
|
|
where = where.Where(b => !string.IsNullOrEmpty(b.RelationPurchaseOrderId) && b.RelationPurchaseOrderId.Contains(SearchResultPurchaseOrder)); |
|
|
|
if (SelectPurchasePlatform != null) |
|
|
|
where = where.Where(b => b.PurchasePlatform == SelectPurchasePlatform); |
|
|
|
var list = where.ToList(); |
|
|
|
foreach (var b in list) |
|
|
|
ShowAuditPayBillList.Add(b); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void Save() |
|
|
|
{ |
|
|
|
if (ShowAuditPayBillList.Count == 0) |
|
|
|
{ |
|
|
|
MessageBox.Show("没有需要保存的数据", "提示"); |
|
|
|
return; |
|
|
|
} |
|
|
|
var importShopIds = string.Join(',', SelectedDepartment.ShopList.Where(s => s.IsSelected).Select(s => s.ShopId)); |
|
|
|
|
|
|
|
var replaceResponse = financialTerminalService.IsExistAuditPayBill(importShopIds, StartDate, EndDate); |
|
|
|
if (!replaceResponse.Success) |
|
|
|
{ |
|
|
|
MessageBox.Show("检查重复账单失败", "提示"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (replaceResponse.Data) |
|
|
|
if (MessageBox.Show("存在重复账单数据,是否覆盖", "确认", MessageBoxButton.OKCancel) != MessageBoxResult.OK) |
|
|
|
return; |
|
|
|
|
|
|
|
IsLoading = true; |
|
|
|
|
|
|
|
foreach (var bill in ShowAuditPayBillList) |
|
|
|
bill.ImportShopIds = importShopIds; |
|
|
|
|
|
|
|
Task.Factory.StartNew(() => financialTerminalService.BatchInsertAuditPayBill(ShowAuditPayBillList)).ContinueWith(t => |
|
|
|
{ |
|
|
|
var insertResponse = t.Result; |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
if (insertResponse.Success) |
|
|
|
MessageBox.Show("保存成功", "提示"); |
|
|
|
else |
|
|
|
MessageBox.Show(insertResponse.Msg, "提示"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|