diff --git a/BBWYB.Client/APIServices/PurchaseOrderService.cs b/BBWYB.Client/APIServices/PurchaseOrderService.cs index 2773b73..a7e9909 100644 --- a/BBWYB.Client/APIServices/PurchaseOrderService.cs +++ b/BBWYB.Client/APIServices/PurchaseOrderService.cs @@ -59,9 +59,10 @@ namespace BBWYB.Client.APIServices /// 预览订单 /// /// - /// + /// + /// /// - public ApiResponse PreviewPurchaseOrder(Consignee consignee, IList productSkuWithSchemeList, Platform purchasePlatform, PurchaseOrderMode purchaseOrderMode) + public ApiResponse PreviewPurchaseOrder(Consignee consignee, IList productSkuWithSchemeList, PurchaseOrderMode purchaseOrderMode) { var cargoParamGroupList = CombineCargoParamGroup(productSkuWithSchemeList); return SendRequest(globalContext.BBYWApiHost, "api/PurchaseOrder/PreviewPurchaseOrder", new @@ -77,47 +78,31 @@ namespace BBWYB.Client.APIServices /// 创建采购单 /// /// - /// - /// - /// + /// /// /// /// /// - /// /// /// public ApiResponse FastCreateOrder(Consignee consignee, - IList purchaseSchemeProductSkuList, + IList productSkuWithSchemeList, PurchaseOrderMode purchaseOrderMode, string remark, string orderId, long shopId, string extensions) { + var cargoParamGroupList = CombineCargoParamGroup(productSkuWithSchemeList); return SendRequest(globalContext.BBYWApiHost, "api/purchaseOrder/CreatePurchaseOrder", new { purchaseOrderMode, consignee, - CargoParamList = purchaseSchemeProductSkuList.Select(sku => new - { - ProductId = sku.PurchaseProductId, - SkuId = sku.PurchaseSkuId, - SpecId = sku.PurchaseSkuSpecId, - Quantity = sku.ItemTotal, - BelongSkuId = sku.SkuId - }), - Platform = purchasePlatform, - purchaseAccount.AppKey, - purchaseAccount.AppSecret, - purchaseAccount.AppToken, - SaveResponseLog = true, + cargoParamGroupList, + globalContext.User.Shop.PurchaseAccountList, remark, orderId, shopId, - purchaseAccountId = purchaseAccount.Id, - purchaseAccountName = purchaseAccount.AccountName, - purchaserName, extensions }, null, HttpMethod.Post); } diff --git a/BBWYB.Client/ViewModels/Purchase/OnlinePurchaseViewModel.cs b/BBWYB.Client/ViewModels/Purchase/OnlinePurchaseViewModel.cs index 6223c3c..506ec76 100644 --- a/BBWYB.Client/ViewModels/Purchase/OnlinePurchaseViewModel.cs +++ b/BBWYB.Client/ViewModels/Purchase/OnlinePurchaseViewModel.cs @@ -111,8 +111,6 @@ namespace BBWYB.Client.ViewModels public void SetData(Order order, IList schemeList) { this.order = order; - //this.purchaser = purchaser; - //this.purchaseAccount = purchaseAccount; this.schemeList = schemeList; this.ContactName = order.Consignee.ContactName; this.Address = order.Consignee.Address; @@ -229,35 +227,35 @@ namespace BBWYB.Client.ViewModels return; } - //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, purchaseAccount.PurchasePlatformId, purchaseAccount, PurchaseOrderMode)) - // .ContinueWith(t => - // { - // IsLoading = false; - // var r = t.Result; - // if (!r.Success) - // { - // ProductAmount = FreightAmount = TotalAmount = 0; - // extensions = string.Empty; - // App.Current.Dispatcher.Invoke(() => MessageBox.Show(r.Msg, "预览订单报价")); - // return; - // } - // ProductAmount = r.Data.ProductAmount; - // FreightAmount = r.Data.FreightAmount; - // TotalAmount = r.Data.TotalAmount; - // //tradeMode = r.Data.OrderTradeType?.Code; - // extensions = r.Data.Extensions; - // }); + 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 + }, ProductSkuWithSchemeList, PurchaseOrderMode)) + .ContinueWith(t => + { + IsLoading = false; + var r = t.Result; + if (!r.Success) + { + ProductAmount = FreightAmount = TotalAmount = 0; + extensions = string.Empty; + App.Current.Dispatcher.Invoke(() => MessageBox.Show(r.Msg, "预览订单报价")); + return; + } + ProductAmount = r.Data.ProductAmount; + FreightAmount = r.Data.FreightAmount; + TotalAmount = r.Data.TotalAmount; + //tradeMode = r.Data.OrderTradeType?.Code; + extensions = r.Data.Extensions; + }); } private void FastCreateOrder() @@ -286,43 +284,40 @@ namespace BBWYB.Client.ViewModels 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, - // purchaseAccount.PurchasePlatformId, - // purchaseAccount, - // PurchaseOrderMode, - // PrucahseRemark, - // order.Id, - // globalContext.User.Shop.ShopId, - // purchaseSchemeList[0].PurchaserName, - // extensions)).ContinueWith(t => - // { - // IsLoading = false; - // var r = t.Result; - // if (!r.Success) - // { - // App.Current.Dispatcher.Invoke(() => MessageBox.Show(r.Msg, "下单")); - // return; - // } - - // //刷新订单列表 - // //orderListViewModel.RefreshOrder(order.Id); - // orderVM.RefreshOrder(order.Id); - - // //关闭当前窗口 - // //GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(null, "OnlinePurchase_Close"); - // WeakReferenceMessenger.Default.Send(new Message_OnlinePurchase_Close(null)); - // }); + 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 + }, ProductSkuWithSchemeList, + PurchaseOrderMode, + PrucahseRemark, + order.Id, + globalContext.User.Shop.ShopId, + extensions)).ContinueWith(t => + { + IsLoading = false; + var r = t.Result; + if (!r.Success) + { + App.Current.Dispatcher.Invoke(() => MessageBox.Show(r.Msg, "下单")); + return; + } + + //刷新订单列表 + //orderListViewModel.RefreshOrder(order.Id); + orderVM.RefreshOrder(order.Id); + + //关闭当前窗口 + //GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(null, "OnlinePurchase_Close"); + WeakReferenceMessenger.Default.Send(new Message_OnlinePurchase_Close(null)); + }); } private void PreviewOrder()