Browse Source

取消订单

updatebug
shanji 2 years ago
parent
commit
27076343db
  1. 13
      BBWYB.Client/APIServices/OrderService.cs
  2. 23
      BBWYB.Client/ViewModels/Order/OrderViewModel.cs
  3. 39
      BBWYB.Client/Views/Order/OrderList.xaml

13
BBWYB.Client/APIServices/OrderService.cs

@ -44,5 +44,18 @@ namespace BBWYB.Client.APIServices
sourceSku
}, null, HttpMethod.Post);
}
public ApiResponse<object> CancelOrder(string orderId, string remark)
{
return SendRequest<object>(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);
}
}
}

23
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<Order>();
@ -81,6 +83,7 @@ namespace BBWYB.Client.ViewModels
Task.Factory.StartNew(() => LoadOrder(p.PageIndex));
});
OnlinePurchaseCommand = new RelayCommand<Order>(OnlinePurchase);
CancelOrderCommand = new RelayCommand<string>(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);
});
}
}
}

39
BBWYB.Client/Views/Order/OrderList.xaml

@ -463,8 +463,15 @@
<c:BButton Content="采购" Grid.Column="1" Width="100"
Command="{Binding DataContext.OnlinePurchaseCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}}}"
CommandParameter="{Binding }"
Visibility="{Binding IsPurchased,ConverterParameter=false:Visible:Collapsed,Converter={StaticResource objConverter}}"/>
CommandParameter="{Binding }">
<c:BButton.Visibility>
<MultiBinding Converter="{StaticResource mobjConverter}"
ConverterParameter="已取消;true:|:Collapsed:Visible:1">
<Binding Path="OrderState"/>
<Binding Path="IsPurchased"/>
</MultiBinding>
</c:BButton.Visibility>
</c:BButton>
<ListBox Grid.Column="1"
Visibility="{Binding IsPurchased,ConverterParameter=true:Visible:Collapsed,Converter={StaticResource objConverter}}"
@ -577,20 +584,6 @@
<Grid x:Name="sp_store" Grid.Column="4">
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<!--<StackPanel Orientation="Horizontal"
Visibility="{Binding WaybillNo,ConverterParameter=#null:Collapsed:Visible,Converter={StaticResource objConverter}}">
<TextBlock Text="{Binding ExpressName}" TextWrapping="Wrap"/>
--><!--{Binding ExpressName}-->
<!--{Binding WaybillNo}--><!--
<c:BButton Style="{StaticResource LinkButton}"
Content="{Binding WaybillNo}"
Command="{Binding DataContext.CopyTextCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}}}"
CommandParameter="{Binding WaybillNo}"
Margin="10,0,0,0"/>
</StackPanel>-->
<ListBox ItemsSource="{Binding OrderPurchaseInfoList}"
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}"
Style="{StaticResource NoScrollViewListBoxStyle}">
@ -662,6 +655,20 @@
<TextBlock Text="{Binding PurchaseRemark}" TextWrapping="Wrap"/>
</StackPanel>
</StackPanel>
<StackPanel Grid.Column="7" VerticalAlignment="Center">
<c:BButton Content="取消" Style="{StaticResource LinkButton}"
Command="{Binding DataContext.CancelOrderCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}}}"
CommandParameter="{Binding Id}">
<c:BButton.Visibility>
<MultiBinding Converter="{StaticResource mobjConverter}"
ConverterParameter="已取消;true:|:Collapsed:Visible:1">
<Binding Path="OrderState"/>
<Binding Path="IsPurchased"/>
</MultiBinding>
</c:BButton.Visibility>
</c:BButton>
</StackPanel>
</Grid>
<Border Grid.Row="1" VerticalAlignment="Bottom" Height="1" Background="{StaticResource Border.Brush}"/>
</Grid>

Loading…
Cancel
Save