|
|
@ -8,6 +8,7 @@ using System.Collections.ObjectModel; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Windows; |
|
|
|
|
|
|
|
namespace BBWY.Client.ViewModels |
|
|
|
{ |
|
|
@ -29,11 +30,13 @@ namespace BBWY.Client.ViewModels |
|
|
|
public string City { get => city; set { Set(ref city, value); } } |
|
|
|
public string County { get => county; set { Set(ref county, value); } } |
|
|
|
public string Town { get => town; set { Set(ref town, value); } } |
|
|
|
public string PrucahseRemark { get => prucahseRemark; set { Set(ref prucahseRemark, value); } } |
|
|
|
|
|
|
|
private string orderId; |
|
|
|
private int skuItemCount; |
|
|
|
private bool isLoading; |
|
|
|
private OneBoundAPIService oneBoundAPIService; |
|
|
|
private PurchaseOrderService purchaseOrderService; |
|
|
|
private DelayTrigger delayTrigger; |
|
|
|
|
|
|
|
private decimal productAmount; |
|
|
@ -46,10 +49,12 @@ namespace BBWY.Client.ViewModels |
|
|
|
private string city; |
|
|
|
private string county; |
|
|
|
private string town; |
|
|
|
private string prucahseRemark; |
|
|
|
|
|
|
|
public _1688PreviewPurchaseViewModel(OneBoundAPIService oneBoundAPIService) |
|
|
|
public _1688PreviewPurchaseViewModel(OneBoundAPIService oneBoundAPIService, PurchaseOrderService purchaseOrderService) |
|
|
|
{ |
|
|
|
this.oneBoundAPIService = oneBoundAPIService; |
|
|
|
this.purchaseOrderService = purchaseOrderService; |
|
|
|
this.delayTrigger = new DelayTrigger(); |
|
|
|
this.delayTrigger.OnExecute = OnDelayTriggerExecute; |
|
|
|
PurchaseSchemeProductSkuList = new ObservableCollection<PurchaseSchemeProductSku>(); |
|
|
@ -85,7 +90,8 @@ namespace BBWY.Client.ViewModels |
|
|
|
Task.Factory.StartNew(() => |
|
|
|
{ |
|
|
|
WaitHandle.WaitAll(waitList.ToArray()); |
|
|
|
IsLoading = false; |
|
|
|
//IsLoading = false;
|
|
|
|
OnDelayTriggerExecute(string.Empty); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
@ -102,7 +108,7 @@ namespace BBWY.Client.ViewModels |
|
|
|
var purchaseSchemeProductSkuList = LoadPurchaseProductCore(purchaseSchemeProduct.PurchaseProductId, out string errorMsg); |
|
|
|
if (purchaseSchemeProductSkuList != null && purchaseSchemeProductSkuList.Count > 0) |
|
|
|
{ |
|
|
|
App.Current.Dispatcher.BeginInvoke((Action)delegate |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
foreach (var purchaseSchemeProductSku in purchaseSchemeProductSkuList) |
|
|
|
{ |
|
|
@ -117,7 +123,6 @@ namespace BBWY.Client.ViewModels |
|
|
|
} |
|
|
|
ewh.Set(); |
|
|
|
ewh.Dispose(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private IList<PurchaseSchemeProductSku> LoadPurchaseProductCore(string purchseProductId, out string errorMsg) |
|
|
@ -185,7 +190,32 @@ namespace BBWY.Client.ViewModels |
|
|
|
|
|
|
|
private void OnDelayTriggerExecute(string key) |
|
|
|
{ |
|
|
|
|
|
|
|
IsLoading = true; |
|
|
|
Task.Factory.StartNew(() => purchaseOrderService.PreviewPurchaseOrder(new Consignee() |
|
|
|
{ |
|
|
|
Address = Address, |
|
|
|
City = City, |
|
|
|
ContactName = ContactName, |
|
|
|
County = County, |
|
|
|
Mobile = Mobile, |
|
|
|
Province = Province, |
|
|
|
TelePhone = Mobile, |
|
|
|
Town = Town |
|
|
|
}, PurchaseSchemeProductSkuList, Platform.阿里巴巴, PurchaseAccount)) |
|
|
|
.ContinueWith(t => |
|
|
|
{ |
|
|
|
IsLoading = false; |
|
|
|
var r = t.Result; |
|
|
|
if (!r.Success) |
|
|
|
{ |
|
|
|
ProductAmount = FreightAmount = TotalAmount = 0; |
|
|
|
App.Current.Dispatcher.Invoke(() => MessageBox.Show(r.Msg, "预览订单报价")); |
|
|
|
return; |
|
|
|
} |
|
|
|
ProductAmount = r.Data.ProductAmount; |
|
|
|
FreightAmount = r.Data.FreightAmount; |
|
|
|
TotalAmount = r.Data.TotalAmount; |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|