From 27076343dbdf0d6191b62ee9686dcb63807c61f5 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Tue, 9 May 2023 01:56:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=96=E6=B6=88=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BBWYB.Client/APIServices/OrderService.cs | 13 +++++++ .../ViewModels/Order/OrderViewModel.cs | 23 +++++++++++ BBWYB.Client/Views/Order/OrderList.xaml | 39 +++++++++++-------- 3 files changed, 59 insertions(+), 16 deletions(-) diff --git a/BBWYB.Client/APIServices/OrderService.cs b/BBWYB.Client/APIServices/OrderService.cs index 0105a32..e69664a 100644 --- a/BBWYB.Client/APIServices/OrderService.cs +++ b/BBWYB.Client/APIServices/OrderService.cs @@ -44,5 +44,18 @@ namespace BBWYB.Client.APIServices sourceSku }, null, HttpMethod.Post); } + + public ApiResponse CancelOrder(string orderId, string remark) + { + return SendRequest(globalContext.BBYWApiHost, "api/order/CancelOrder", new + { + orderId, + remark, + globalContext.User.Shop.AppKey, + globalContext.User.Shop.AppSecret, + globalContext.User.Shop.AppToken, + globalContext.User.Shop.Platform + }, null, HttpMethod.Post); + } } } diff --git a/BBWYB.Client/ViewModels/Order/OrderViewModel.cs b/BBWYB.Client/ViewModels/Order/OrderViewModel.cs index 1e42313..9a5189a 100644 --- a/BBWYB.Client/ViewModels/Order/OrderViewModel.cs +++ b/BBWYB.Client/ViewModels/Order/OrderViewModel.cs @@ -60,6 +60,8 @@ namespace BBWYB.Client.ViewModels public ICommand OnlinePurchaseCommand { get; set; } + public ICommand CancelOrderCommand { get; set; } + public OrderViewModel(GlobalContext globalContext, OrderService orderService) { OrderList = new ObservableCollection(); @@ -81,6 +83,7 @@ namespace BBWYB.Client.ViewModels Task.Factory.StartNew(() => LoadOrder(p.PageIndex)); }); OnlinePurchaseCommand = new RelayCommand(OnlinePurchase); + CancelOrderCommand = new RelayCommand(CancelOrder); PageIndex = 1; PageSize = 10; EndDate = DateTime.Now; @@ -213,6 +216,26 @@ namespace BBWYB.Client.ViewModels }); } + + private void CancelOrder(string orderId) + { + if (MessageBox.Show("是否确认取消订单", "提示", MessageBoxButton.OKCancel) != MessageBoxResult.OK) + return; + + IsLoading = true; + Task.Factory.StartNew(() => orderService.CancelOrder(orderId, string.Empty)) + .ContinueWith(t => + { + IsLoading = false; + var response = t.Result; + if (!response.Success) + { + App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "取消订单")); + return; + } + RefreshOrder(orderId); + }); + } } } diff --git a/BBWYB.Client/Views/Order/OrderList.xaml b/BBWYB.Client/Views/Order/OrderList.xaml index 1f8075d..13cb72e 100644 --- a/BBWYB.Client/Views/Order/OrderList.xaml +++ b/BBWYB.Client/Views/Order/OrderList.xaml @@ -463,8 +463,15 @@ + CommandParameter="{Binding }"> + + + + + + + - - - @@ -662,6 +655,20 @@ + + + + + + + + + + +