diff --git a/BBWY.Client/APIServices/MdsApiService.cs b/BBWY.Client/APIServices/MdsApiService.cs index 326f108a..3c918089 100644 --- a/BBWY.Client/APIServices/MdsApiService.cs +++ b/BBWY.Client/APIServices/MdsApiService.cs @@ -24,9 +24,9 @@ namespace BBWY.Client.APIServices }, HttpMethod.Get); } - public ApiResponse> GetShopsByUserId(long userId) + public ApiResponse> GetShopsByUserTeam(long userId) { - return SendRequest>(globalContext.MDSApiHost, "TaskList/Shop/GetShopsByUserId", $"userId={userId}", null, System.Net.Http.HttpMethod.Get); + return SendRequest>(globalContext.MDSApiHost, "TaskList/Shop/GetShopsByUserTeam", $"userId={userId}", null, System.Net.Http.HttpMethod.Get); } } } diff --git a/BBWY.Client/APIServices/OrderService.cs b/BBWY.Client/APIServices/OrderService.cs index 1b1fb135..867985e8 100644 --- a/BBWY.Client/APIServices/OrderService.cs +++ b/BBWY.Client/APIServices/OrderService.cs @@ -85,9 +85,9 @@ namespace BBWY.Client.APIServices /// 是否设置仓储类型 /// /// - public ApiResponse AutoCalculationCost(string orderId, bool isSetStorageType, StorageType storageType) + public ApiResponse AutoCalculationCost(string orderId, bool isSetStorageType, StorageType storageType, decimal platformCommissionRatio) { - return SendRequest(globalContext.BBYWApiHost, "api/order/AutoCalculationCost", new { orderId, isSetStorageType, storageType }, null, HttpMethod.Post); + return SendRequest(globalContext.BBYWApiHost, "api/order/AutoCalculationCost", new { orderId, isSetStorageType, storageType, platformCommissionRatio }, null, HttpMethod.Post); } /// @@ -97,7 +97,7 @@ namespace BBWY.Client.APIServices /// 是否设置仓储类型 /// /// - public ApiResponse ManualCalculationCost(string orderId, bool isSetStorageType, StorageType storageType, decimal purchaseCost, decimal deliveryExpressFreight) + public ApiResponse ManualCalculationCost(string orderId, bool isSetStorageType, StorageType storageType, decimal purchaseCost, decimal deliveryExpressFreight, decimal platformCommissionRatio) { return SendRequest(globalContext.BBYWApiHost, "api/order/ManualCalculationCost", new @@ -106,7 +106,8 @@ namespace BBWY.Client.APIServices isSetStorageType, storageType, purchaseCost, - deliveryExpressFreight + deliveryExpressFreight, + platformCommissionRatio }, null, HttpMethod.Post); } @@ -127,7 +128,8 @@ namespace BBWY.Client.APIServices decimal deliveryExpressFreight, SDType sdType, string flag, - string venderRemark) + string venderRemark, + decimal platformCommissionRatio) { return SendRequest(globalContext.BBYWApiHost, "api/order/SDCalculationCost", new { @@ -138,6 +140,7 @@ namespace BBWY.Client.APIServices sdType, sdCommissionAmount, deliveryExpressFreight, + platformCommissionRatio, Platform = globalContext.User.Shop.Platform, AppKey = globalContext.User.Shop.AppKey, AppSecret = globalContext.User.Shop.AppSecret, @@ -151,12 +154,13 @@ namespace BBWY.Client.APIServices /// /// /// - public ApiResponse RelationPurchaseOrder(OrderDropShipping orderDropShipping, IList relationPurchaseOrderSkuList) + public ApiResponse RelationPurchaseOrder(OrderDropShipping orderDropShipping, IList relationPurchaseOrderSkuList,decimal platformCommissionRatio) { return SendRequest(globalContext.BBYWApiHost, "api/order/RelationPurchaseOrder", new { orderDropShipping, - relationPurchaseOrderSkuList + relationPurchaseOrderSkuList, + platformCommissionRatio }, null, HttpMethod.Post); } diff --git a/BBWY.Client/APIServices/PurchaseOrderService.cs b/BBWY.Client/APIServices/PurchaseOrderService.cs index c063d583..5b61712e 100644 --- a/BBWY.Client/APIServices/PurchaseOrderService.cs +++ b/BBWY.Client/APIServices/PurchaseOrderService.cs @@ -104,7 +104,8 @@ namespace BBWY.Client.APIServices long shopId, long purchaseAccountId, string buyerAccount, - string sellerAccount) + string sellerAccount, + decimal platformCommissionRatio) { return SendRequest(globalContext.BBYWApiHost, "api/purchaseOrder/NewFastCreateOrder", new { @@ -128,7 +129,8 @@ namespace BBWY.Client.APIServices shopId, purchaseAccountId, buyerAccount, - sellerAccount + sellerAccount, + platformCommissionRatio }, null, HttpMethod.Post); } } diff --git a/BBWY.Client/App.xaml.cs b/BBWY.Client/App.xaml.cs index 051e0feb..00b3bee1 100644 --- a/BBWY.Client/App.xaml.cs +++ b/BBWY.Client/App.xaml.cs @@ -28,7 +28,7 @@ namespace BBWY.Client var gl = new GlobalContext(); string userToken = string.Empty; #if DEBUG - userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDA1MTUxNjE5NTk0NTg4MTYwIiwidGVhbUlkIjoiMTQzOTg5OTEyMzk1NTI3MzcyOCIsImV4cCI6MTY3MTkwMTU1NH0.UaUubqP442qxVc6ppQt7FO0jcFs3w6KR6q1OeBuL1i8"; //齐越小一 + userToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDM5OTA3NDY1MDMzNDIwODAwIiwidGVhbUlkIjoiMTQzNjI4ODUwMDIzNTI0MzUyMCIsImV4cCI6MTY4MjU3NzUzNn0.76Ll9syp3R21VD01NxpHmcs7TyBKzqeob3i5avpLv-E"; //齐越小一 //"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIxNDUzOTA0NTczMjM5Mzk4NDAwIiwidGVhbUlkIjoiMTQzOTg5ODI2MDg3MjM2ODEyOCIsImV4cCI6MTY4MjQwODY1OH0.Po9-Dw_CgbAB7kjh7broLGIjOdsL2JifPtodNKClRIw"; #else var uid = e.Args.Count() > 0 ? e.Args.LastOrDefault(args => args.StartsWith("uid:")) : string.Empty; diff --git a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs index e4e35e04..c76b1d4c 100644 --- a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs +++ b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs @@ -21,5 +21,9 @@ namespace BBWY.Client.Models public string AppToken { get; set; } public IList PurchaseList { get; set; } + + public string ManagePwd { get; set; } + + public decimal? PlatformCommissionRatio { get; set; } } } diff --git a/BBWY.Client/Models/Shop/Shop.cs b/BBWY.Client/Models/Shop/Shop.cs index 7e44f3ff..ccb3db65 100644 --- a/BBWY.Client/Models/Shop/Shop.cs +++ b/BBWY.Client/Models/Shop/Shop.cs @@ -30,5 +30,11 @@ namespace BBWY.Client.Models public string Name { get => name; set { Set(ref name, value); } } public IList PurchaseAccountList { get; set; } + + public string ManagePwd { get; set; } + /// + /// 店铺扣点 + /// + public decimal? PlatformCommissionRatio { get; set; } } } diff --git a/BBWY.Client/ViewModels/MainViewModel.cs b/BBWY.Client/ViewModels/MainViewModel.cs index 3524bec2..6042e405 100644 --- a/BBWY.Client/ViewModels/MainViewModel.cs +++ b/BBWY.Client/ViewModels/MainViewModel.cs @@ -153,7 +153,7 @@ namespace BBWY.Client.ViewModels // } //}; - var shopListResponse = mdsApiService.GetShopsByUserId(GlobalContext.User.Id); + var shopListResponse = mdsApiService.GetShopsByUserTeam(GlobalContext.User.Id); if (!shopListResponse.Success) throw new Exception(shopListResponse.Msg); if (shopListResponse.Data == null || shopListResponse.Data.Count == 0) diff --git a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs index f5debc7b..b7a44537 100644 --- a/BBWY.Client/ViewModels/Order/OrderListViewModel.cs +++ b/BBWY.Client/ViewModels/Order/OrderListViewModel.cs @@ -336,7 +336,7 @@ namespace BBWY.Client.ViewModels var orderDropShipping = relationPurchaseOrder.OrderDropShipping; var relationPurchaseOrderSkuList = relationPurchaseOrder.RelationPurchaseOrderSkuList; IsLoading = true; - Task.Factory.StartNew(() => orderService.RelationPurchaseOrder(orderDropShipping, relationPurchaseOrderSkuList)) + Task.Factory.StartNew(() => orderService.RelationPurchaseOrder(orderDropShipping, relationPurchaseOrderSkuList, globalContext.User.Shop.PlatformCommissionRatio ?? 0.05M)) .ContinueWith(r => { var response = r.Result; @@ -371,7 +371,8 @@ namespace BBWY.Client.ViewModels deliveryExpressFreight, sdType.Value, flag, - venderRemark)) + venderRemark, + globalContext.User.Shop.PlatformCommissionRatio ?? 0.05M)) .ContinueWith(r => { var response = r.Result; @@ -434,19 +435,19 @@ namespace BBWY.Client.ViewModels if (isAutoCalculation) { IsLoading = true; - Task.Factory.StartNew(() => orderService.AutoCalculationCost(orderId, isSetStorageType, storageType)).ContinueWith(r => - { - var response = r.Result; - if (!response.Success) - { - IsLoading = false; - App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "自动计算成本")); - return; - } - - //LoadOrder(PageIndex); //自动计算成功刷新订单列表 - RefreshOrder(orderId); - }); + Task.Factory.StartNew(() => orderService.AutoCalculationCost(orderId, isSetStorageType, storageType, globalContext.User.Shop.PlatformCommissionRatio ?? 0.05M)).ContinueWith(r => + { + var response = r.Result; + if (!response.Success) + { + IsLoading = false; + App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "自动计算成本")); + return; + } + + //LoadOrder(PageIndex); //自动计算成功刷新订单列表 + RefreshOrder(orderId); + }); } else { @@ -470,18 +471,18 @@ namespace BBWY.Client.ViewModels var deliveryExpressFreight = manualCalculationCost.DeliveryExpressFreight; IsLoading = true; - Task.Factory.StartNew(() => orderService.ManualCalculationCost(orderId, isSetStorageType, storageType, purchaseCost, deliveryExpressFreight)).ContinueWith(r => - { - var response = r.Result; - if (!response.Success) - { - IsLoading = false; - App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "手动计算成本")); - return; - } - //LoadOrder(PageIndex); //手动计算成功刷新订单列表 - RefreshOrder(orderId); - }); + Task.Factory.StartNew(() => orderService.ManualCalculationCost(orderId, isSetStorageType, storageType, purchaseCost, deliveryExpressFreight, globalContext.User.Shop.PlatformCommissionRatio ?? 0.05M)).ContinueWith(r => + { + var response = r.Result; + if (!response.Success) + { + IsLoading = false; + App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "手动计算成本")); + return; + } + //LoadOrder(PageIndex); //手动计算成功刷新订单列表 + RefreshOrder(orderId); + }); } private void OutStock(Order o) @@ -573,7 +574,7 @@ namespace BBWY.Client.ViewModels private void Export() { - var sfd = new SaveFileDialog() { Filter= "csv files(*.csv)|*.csv" }; + var sfd = new SaveFileDialog() { Filter = "csv files(*.csv)|*.csv" }; if (sfd.ShowDialog() != true) return; diff --git a/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs b/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs index 3811a21e..8b2a825a 100644 --- a/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs +++ b/BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs @@ -319,22 +319,23 @@ namespace BBWY.Client.ViewModels globalContext.User.Shop.ShopId, purchaseAccount.Id, purchaseAccount.AccountName, - purchaseSchemeList[0].PurchaserName)).ContinueWith(t => - { - IsLoading = false; - var r = t.Result; - if (!r.Success) - { - App.Current.Dispatcher.Invoke(() => MessageBox.Show(r.Msg, "下单")); - return; - } + purchaseSchemeList[0].PurchaserName, + globalContext.User.Shop.PlatformCommissionRatio ?? 0.05M)).ContinueWith(t => + { + IsLoading = false; + var r = t.Result; + if (!r.Success) + { + App.Current.Dispatcher.Invoke(() => MessageBox.Show(r.Msg, "下单")); + return; + } - //刷新订单列表 - orderListViewModel.RefreshOrder(order.Id); + //刷新订单列表 + orderListViewModel.RefreshOrder(order.Id); - //关闭当前窗口 - GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(null, "OnlinePurchase_Close"); - }); + //关闭当前窗口 + GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(null, "OnlinePurchase_Close"); + }); } } } diff --git a/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs b/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs index f320a62a..aff15715 100644 --- a/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs +++ b/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs @@ -1,5 +1,6 @@ using BBWY.Client.APIServices; using BBWY.Client.Models; +using BBWY.Client.Views.Setting; using BBWY.Common.Models; using GalaSoft.MvvmLight.Command; using System.Collections.Generic; @@ -12,14 +13,19 @@ namespace BBWY.Client.ViewModels { public class ShopSettingViewModel : BaseVM, IDenpendency { + private bool isValidated; private bool isLoading; private GlobalContext globalContext; private ShopService shopService; private PurchaseAccount purchaseAccount; + private string managePwd; + private decimal platformCommissionRatio; public PurchaseAccount PurchaseAccount { get => purchaseAccount; set { Set(ref purchaseAccount, value); } } public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } } public ICommand SaveCommand { get; set; } + public string ManagePwd { get => managePwd; set { Set(ref managePwd, value); } } + public decimal PlatformCommissionRatio { get => platformCommissionRatio; set { Set(ref platformCommissionRatio, value); } } public ShopSettingViewModel(GlobalContext globalContext, ShopService shopService) { @@ -30,9 +36,20 @@ namespace BBWY.Client.ViewModels protected override void Load() { + IsLoading = false; + if (!string.IsNullOrEmpty(globalContext.User.Shop.ManagePwd)) + { + var validatePwd = new ValidateManagePwd(globalContext.User.Shop.ManagePwd); + if (validatePwd.ShowDialog() != true) + return; + } + isValidated = true; + this.ManagePwd = globalContext.User.Shop.ManagePwd; + this.PlatformCommissionRatio = globalContext.User.Shop.PlatformCommissionRatio ?? 5; this.PurchaseAccount = globalContext.User.Shop.PurchaseAccountList == null || globalContext.User.Shop.PurchaseAccountList.Count() == 0 ? new PurchaseAccount() : globalContext.User.Shop.PurchaseAccountList[0].Clone() as PurchaseAccount; + } protected override void Unload() @@ -42,8 +59,21 @@ namespace BBWY.Client.ViewModels private void Save() { + if (!isValidated) + { + MessageBox.Show("店铺密码验证未通过", "保存店铺设置"); + return; + } + if (string.IsNullOrEmpty(PurchaseAccount.AppKey) || + string.IsNullOrEmpty(PurchaseAccount.AppKey) || + string.IsNullOrEmpty(PurchaseAccount.AppKey) || + string.IsNullOrEmpty(PurchaseAccount.AppKey)) + { + MessageBox.Show("采购信息不能为空", "保存店铺设置"); + return; + } IsLoading = true; - Task.Factory.StartNew(() => shopService.SaveShopSetting(globalContext.User.Shop.ShopId, "", 0, PurchaseAccount)).ContinueWith(r => + Task.Factory.StartNew(() => shopService.SaveShopSetting(globalContext.User.Shop.ShopId, ManagePwd, PlatformCommissionRatio, PurchaseAccount)).ContinueWith(r => { IsLoading = false; var response = r.Result; @@ -58,6 +88,8 @@ namespace BBWY.Client.ViewModels globalContext.User.Shop.PurchaseAccountList.Clear(); PurchaseAccount.Id = response.Data; globalContext.User.Shop.PurchaseAccountList.Add(PurchaseAccount); + globalContext.User.Shop.PlatformCommissionRatio = this.PlatformCommissionRatio; + globalContext.User.Shop.ManagePwd = this.ManagePwd; }); } } diff --git a/BBWY.Client/Views/Setting/ShopSetting.xaml b/BBWY.Client/Views/Setting/ShopSetting.xaml index dbe71da3..6cb091d6 100644 --- a/BBWY.Client/Views/Setting/ShopSetting.xaml +++ b/BBWY.Client/Views/Setting/ShopSetting.xaml @@ -26,6 +26,7 @@