|
|
@ -1,6 +1,7 @@ |
|
|
|
using BBWY.Client.APIServices; |
|
|
|
using BBWY.Client.Models; |
|
|
|
using BBWY.Common.Trigger; |
|
|
|
using GalaSoft.MvvmLight.Command; |
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
@ -9,11 +10,14 @@ using System.Linq; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Windows; |
|
|
|
using System.Windows.Input; |
|
|
|
|
|
|
|
namespace BBWY.Client.ViewModels |
|
|
|
{ |
|
|
|
public class _1688PreviewPurchaseViewModel : BaseVM |
|
|
|
{ |
|
|
|
public ICommand FastCreateOrderCommand { get; set; } |
|
|
|
|
|
|
|
public IList<PurchaseSchemeProductSku> PurchaseSchemeProductSkuList { get; set; } |
|
|
|
|
|
|
|
public PurchaseScheme PurchaseScheme { get; set; } |
|
|
@ -32,6 +36,8 @@ namespace BBWY.Client.ViewModels |
|
|
|
public string Town { get => town; set { Set(ref town, value); } } |
|
|
|
public string PrucahseRemark { get => prucahseRemark; set { Set(ref prucahseRemark, value); } } |
|
|
|
|
|
|
|
private OrderListViewModel orderListViewModel; |
|
|
|
private GlobalContext globalContext; |
|
|
|
private string orderId; |
|
|
|
private int skuItemCount; |
|
|
|
private bool isLoading; |
|
|
@ -53,13 +59,16 @@ namespace BBWY.Client.ViewModels |
|
|
|
|
|
|
|
private string tradeMode; |
|
|
|
|
|
|
|
public _1688PreviewPurchaseViewModel(OneBoundAPIService oneBoundAPIService, PurchaseOrderService purchaseOrderService) |
|
|
|
public _1688PreviewPurchaseViewModel(OneBoundAPIService oneBoundAPIService, PurchaseOrderService purchaseOrderService, GlobalContext globalContext, OrderListViewModel orderListViewModel) |
|
|
|
{ |
|
|
|
this.oneBoundAPIService = oneBoundAPIService; |
|
|
|
this.purchaseOrderService = purchaseOrderService; |
|
|
|
this.delayTrigger = new DelayTrigger(); |
|
|
|
this.delayTrigger.OnExecute = OnDelayTriggerExecute; |
|
|
|
PurchaseSchemeProductSkuList = new ObservableCollection<PurchaseSchemeProductSku>(); |
|
|
|
FastCreateOrderCommand = new RelayCommand(FastCreateOrder); |
|
|
|
this.globalContext = globalContext; |
|
|
|
this.orderListViewModel = orderListViewModel; |
|
|
|
} |
|
|
|
|
|
|
|
public void SetData(string orderId, int skuItemCount, PurchaseScheme purchaseScheme, PurchaseAccount purchaseAccount, Consignee consignee) |
|
|
@ -102,7 +111,11 @@ namespace BBWY.Client.ViewModels |
|
|
|
PurchaseSchemeProductSkuList.Clear(); |
|
|
|
PurchaseScheme = null; |
|
|
|
orderId = string.Empty; |
|
|
|
tradeMode = string.Empty; |
|
|
|
skuItemCount = 0; |
|
|
|
ProductAmount = FreightAmount = TotalAmount = 0; |
|
|
|
ContactName = Address = Mobile = Province = City = County = Town = PrucahseRemark = string.Empty; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void LoadPurchaseProduct(PurchaseSchemeProduct purchaseSchemeProduct, ManualResetEvent ewh) |
|
|
@ -221,5 +234,51 @@ namespace BBWY.Client.ViewModels |
|
|
|
tradeMode = r.Data.OrderTradeType?.Code; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private void FastCreateOrder() |
|
|
|
{ |
|
|
|
if (TotalAmount == 0) |
|
|
|
{ |
|
|
|
MessageBox.Show("总金额为0不能提交订单", "提示"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
IsLoading = true; |
|
|
|
|
|
|
|
Task.Factory.StartNew(() => purchaseOrderService.FastCreateOrder(new Consignee() |
|
|
|
{ |
|
|
|
Address = Address, |
|
|
|
City = City, |
|
|
|
ContactName = ContactName, |
|
|
|
County = County, |
|
|
|
Mobile = Mobile, |
|
|
|
Province = Province, |
|
|
|
TelePhone = Mobile, |
|
|
|
Town = Town |
|
|
|
}, PurchaseSchemeProductSkuList, |
|
|
|
Platform.阿里巴巴, |
|
|
|
PurchaseAccount, |
|
|
|
tradeMode, |
|
|
|
PrucahseRemark, |
|
|
|
orderId, |
|
|
|
globalContext.User.Shop.ShopId, |
|
|
|
PurchaseAccount.AccountName, |
|
|
|
PurchaseScheme.PurchaserName)).ContinueWith(t => |
|
|
|
{ |
|
|
|
IsLoading = false; |
|
|
|
var r = t.Result; |
|
|
|
if (!r.Success) |
|
|
|
{ |
|
|
|
App.Current.Dispatcher.Invoke(() => MessageBox.Show(r.Msg, "下单")); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
//刷新订单列表
|
|
|
|
orderListViewModel.RefreshOrder(); |
|
|
|
|
|
|
|
//关闭当前窗口
|
|
|
|
GalaSoft.MvvmLight.Messaging.Messenger.Default.Send<object>(null, "OnlinePurchase_Close"); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|