From 7bf2927eecdf8cdfc6b9d7d8f5cf6c294dfbb8c6 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Mon, 21 Nov 2022 14:37:09 +0800 Subject: [PATCH] 1 --- BBWY.Client/APIServices/ShopService.cs | 30 ++++++++++++++++--- .../APIModel/Response/Shop/ShopResponse.cs | 6 ++++ BBWY.Client/Models/Shop/Shop.cs | 6 ++++ BBWY.Client/ViewModels/MainViewModel.cs | 29 ++++++++++++++++++ .../Setting/ShopSettingViewModel.cs | 23 ++++++++++++-- BBWY.Client/Views/MainWindow.xaml | 2 +- BBWY.Client/Views/Setting/ShopSetting.xaml | 25 ++++++++-------- .../Controllers/VenderController.cs | 11 +++++++ BBWY.Server.Business/Vender/VenderBusiness.cs | 23 ++++++++++++-- .../Request/Vender/QueryShopByIdsRequest.cs | 11 +++++++ .../Dto/Request/Vender/ShopSettingRequest.cs | 6 ++++ 11 files changed, 150 insertions(+), 22 deletions(-) create mode 100644 BBWY.Server.Model/Dto/Request/Vender/QueryShopByIdsRequest.cs diff --git a/BBWY.Client/APIServices/ShopService.cs b/BBWY.Client/APIServices/ShopService.cs index ea8e5def..06d04e3c 100644 --- a/BBWY.Client/APIServices/ShopService.cs +++ b/BBWY.Client/APIServices/ShopService.cs @@ -12,8 +12,18 @@ namespace BBWY.Client.APIServices { public ShopService(RestApiService restApiService, GlobalContext globalContext) : base(restApiService, globalContext) { } - public ApiResponse SaveShopSetting(long shopId, string managerPwd, decimal platformCommissionRatio, PurchaseAccount purchaseAccount) + public ApiResponse SaveShopSetting(long shopId, + string managerPwd, + decimal platformCommissionRatio, + PurchaseAccount purchaseAccount, + string dingDingWebHook, + string dingDingKey, + int skuSafeTurnoverDays) { + if (skuSafeTurnoverDays == 0) + { + dingDingWebHook = dingDingKey = string.Empty; + } return SendRequest(globalContext.BBYWApiHost, "api/vender/SaveShopSetting", new { shopId, @@ -24,7 +34,10 @@ namespace BBWY.Client.APIServices purchaseAccount.AppKey, purchaseAccount.AppSecret, purchaseAccount.AppToken, - purchaseAccount.PurchasePlatformId + purchaseAccount.PurchasePlatformId, + dingDingWebHook, + dingDingKey, + skuSafeTurnoverDays }, null, HttpMethod.Post); } @@ -47,11 +60,20 @@ namespace BBWY.Client.APIServices return SendRequest>(globalContext.BBYWApiHost, "api/vender/GetDeparmentList", null, new Dictionary() { - { "bbwyTempKey", "21jfhayu27q" } + { "bbwyTempKey", "21jfhayu27q" } }, HttpMethod.Get); } + public ApiResponse> GetShopListByIds(IList shopIds) + { + return SendRequest>(globalContext.BBYWApiHost, "api/vender/GetShopListByShopIds", new + { + shopIds + }, new Dictionary() + { + { "bbwyTempKey", "21jfhayu27q" } + }, HttpMethod.Post); + } - } } diff --git a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs index 9b9ef0aa..36dd79f3 100644 --- a/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs +++ b/BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs @@ -29,6 +29,12 @@ namespace BBWY.Client.Models public string TeamId { get; set; } public string TeamName { get; set; } + + public string DingDingWebHook { get; set; } + + public string DingDingKey { get; set; } + + public int SkuSafeTurnoverDays { get; set; } } public class DepartmentResponse diff --git a/BBWY.Client/Models/Shop/Shop.cs b/BBWY.Client/Models/Shop/Shop.cs index 796df30d..c3709e5f 100644 --- a/BBWY.Client/Models/Shop/Shop.cs +++ b/BBWY.Client/Models/Shop/Shop.cs @@ -43,6 +43,12 @@ namespace BBWY.Client.Models public string TeamName { get; set; } + public string DingDingWebHook { get; set; } + + public string DingDingKey { get; set; } + + public int SkuSafeTurnoverDays { get; set; } + public override string ToString() { return ShopName; diff --git a/BBWY.Client/ViewModels/MainViewModel.cs b/BBWY.Client/ViewModels/MainViewModel.cs index 8b29617c..10d47e18 100644 --- a/BBWY.Client/ViewModels/MainViewModel.cs +++ b/BBWY.Client/ViewModels/MainViewModel.cs @@ -222,6 +222,35 @@ namespace BBWY.Client.ViewModels departmentList = response.Data; if (departmentList.Count == 0) throw new Exception("缺少有效的部门数据"); + + var shopIds = new List(); + foreach (var d in departmentList) + { + if (d.ShopList != null && d.ShopList.Count > 0) + { + foreach (var s in d.ShopList) + shopIds.Add(s.ShopId.ToString()); + } + } + + var shopList2Res = shopService.GetShopListByIds(shopIds); + if (shopList2Res.Success && shopList2Res.Data != null && shopList2Res.Data.Count() > 0) + { + foreach (var d in departmentList) + { + foreach (var shop in d.ShopList) + { + var s2 = shopList2Res.Data.FirstOrDefault(s => s.ShopId == shop.ShopId); + if (s2 != null) + { + shop.DingDingKey = s2.DingDingKey; + shop.DingDingWebHook = s2.DingDingWebHook; + shop.SkuSafeTurnoverDays = s2.SkuSafeTurnoverDays; + } + } + } + } + if (departmentList.Count == 1 && departmentList[0].ShopList.Count == 1) { ShowShopChoosePanel = false; diff --git a/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs b/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs index bc077039..9831524e 100644 --- a/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs +++ b/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs @@ -21,6 +21,10 @@ namespace BBWY.Client.ViewModels private string managePwd; private decimal platformCommissionRatio; private int panelIndex; + private int skuSafeTurnoverDays; + private string dingDingWebHook; + private string dingDingKey; + private int selectedSkuSafeTurnoverDay; public ICommand SaveCommand { get; set; } @@ -36,6 +40,11 @@ namespace BBWY.Client.ViewModels public int PanelIndex { get => panelIndex; set { Set(ref panelIndex, value); } } public IList SafeDayList { get; set; } + public int SkuSafeTurnoverDays { get => skuSafeTurnoverDays; set { Set(ref skuSafeTurnoverDays, value); } } + public string DingDingWebHook { get => dingDingWebHook; set { Set(ref dingDingWebHook, value); } } + public string DingDingKey { get => dingDingKey; set { Set(ref dingDingKey, value); } } + + public int SelectedSkuSafeTurnoverDay { get => selectedSkuSafeTurnoverDay; set { Set(ref selectedSkuSafeTurnoverDay, value); } } public ShopSettingViewModel(GlobalContext globalContext, ShopService shopService) { @@ -65,7 +74,9 @@ namespace BBWY.Client.ViewModels this.PurchaseAccount = globalContext.User.Shop.PurchaseAccountList == null || globalContext.User.Shop.PurchaseAccountList.Count() == 0 ? new PurchaseAccount() : globalContext.User.Shop.PurchaseAccountList[0].Clone() as PurchaseAccount; - + DingDingKey = globalContext.User.Shop.DingDingKey; + DingDingWebHook = globalContext.User.Shop.DingDingWebHook; + SelectedSkuSafeTurnoverDay = globalContext.User.Shop.SkuSafeTurnoverDays; } protected override void Unload() @@ -74,6 +85,8 @@ namespace BBWY.Client.ViewModels this.PlatformCommissionRatio = 0M; this.ManagePwd = string.Empty; this.isValidated = false; + this.DingDingKey = this.DingDingWebHook = string.Empty; + SelectedSkuSafeTurnoverDay = 0; } private void Save() @@ -99,7 +112,13 @@ namespace BBWY.Client.ViewModels var p = PlatformCommissionRatio / 100; IsLoading = true; - Task.Factory.StartNew(() => shopService.SaveShopSetting(globalContext.User.Shop.ShopId, ManagePwd, p, PurchaseAccount)).ContinueWith(r => + Task.Factory.StartNew(() => shopService.SaveShopSetting(globalContext.User.Shop.ShopId, + ManagePwd, + p, + PurchaseAccount, + DingDingWebHook, + DingDingKey, + SelectedSkuSafeTurnoverDay)).ContinueWith(r => { IsLoading = false; var response = r.Result; diff --git a/BBWY.Client/Views/MainWindow.xaml b/BBWY.Client/Views/MainWindow.xaml index 8e4b7e8f..c21f05d8 100644 --- a/BBWY.Client/Views/MainWindow.xaml +++ b/BBWY.Client/Views/MainWindow.xaml @@ -26,7 +26,7 @@ - + diff --git a/BBWY.Client/Views/Setting/ShopSetting.xaml b/BBWY.Client/Views/Setting/ShopSetting.xaml index 1b5d1138..603a9e1c 100644 --- a/BBWY.Client/Views/Setting/ShopSetting.xaml +++ b/BBWY.Client/Views/Setting/ShopSetting.xaml @@ -133,7 +133,6 @@ - @@ -144,11 +143,11 @@ + Text="{Binding DingDingKey,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/> + Text="{Binding DingDingWebHook,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/> @@ -156,18 +155,18 @@ - - - - + + + - - + + @@ -177,8 +176,8 @@ - - + + @@ -188,8 +187,8 @@ - - + + diff --git a/BBWY.Server.API/Controllers/VenderController.cs b/BBWY.Server.API/Controllers/VenderController.cs index 0b7f7ba5..000ae1cc 100644 --- a/BBWY.Server.API/Controllers/VenderController.cs +++ b/BBWY.Server.API/Controllers/VenderController.cs @@ -88,5 +88,16 @@ namespace BBWY.Server.API.Controllers throw new BusinessException("非法请求"); return venderBusiness.GetDeparmentList(); } + + /// + /// 根据ShopId获取店铺 + /// + /// + /// + [HttpPost] + public IList GetShopListByShopIds(QueryShopByIdsRequest request) + { + return venderBusiness.GetShopListByShopIds(request); + } } } diff --git a/BBWY.Server.Business/Vender/VenderBusiness.cs b/BBWY.Server.Business/Vender/VenderBusiness.cs index c4e81847..9010d976 100644 --- a/BBWY.Server.Business/Vender/VenderBusiness.cs +++ b/BBWY.Server.Business/Vender/VenderBusiness.cs @@ -120,6 +120,9 @@ namespace BBWY.Server.Business //修改扣点和管理密码 freeSqlMultiDBManager.MDSfsql.Update(mdsShop.Id).Set(s => s.ManagePwd, shopSettingRequest.ManagerPwd) .Set(s => s.PlatformCommissionRatio, shopSettingRequest.PlatformCommissionRatio) + .Set(s => s.DingDingKey, shopSettingRequest.DingDingKey) + .Set(s => s.DingDingWebHook, shopSettingRequest.DingDingWebHook) + .Set(s => s.SkuSafeTurnoverDays, shopSettingRequest.SkuSafeTurnoverDays) .ExecuteAffrows(); }); } @@ -145,6 +148,9 @@ namespace BBWY.Server.Business //修改扣点和管理密码 freeSqlMultiDBManager.MDSfsql.Update(mdsShop.Id).Set(s => s.ManagePwd, shopSettingRequest.ManagerPwd) .Set(s => s.PlatformCommissionRatio, shopSettingRequest.PlatformCommissionRatio) + .Set(s => s.DingDingKey, shopSettingRequest.DingDingKey) + .Set(s => s.DingDingWebHook, shopSettingRequest.DingDingWebHook) + .Set(s => s.SkuSafeTurnoverDays, shopSettingRequest.SkuSafeTurnoverDays) .ExecuteAffrows(); }); } @@ -170,7 +176,10 @@ namespace BBWY.Server.Business s.AppToken, s.ManagePwd, s.PlatformCommissionRatio, - s.PlatformId + s.PlatformId, + s.DingDingKey, + s.DingDingWebHook, + s.SkuSafeTurnoverDays }).GroupBy(x => x.DepartmentId); if (relationGroups.Count() == 0) return null; @@ -194,7 +203,10 @@ namespace BBWY.Server.Business PlatformCommissionRatio = x.PlatformCommissionRatio, ShopId = x.ShopId, ShopName = x.ShopName, - ShopType = x.ShopType + ShopType = x.ShopType, + DingDingKey = x.DingDingKey, + DingDingWebHook = x.DingDingWebHook, + SkuSafeTurnoverDays = x.SkuSafeTurnoverDays }).ToList() }; departmentList.Add(department); @@ -231,6 +243,13 @@ namespace BBWY.Server.Business .ToList(); } + public IList GetShopListByShopIds(QueryShopByIdsRequest request) + { + return freeSqlMultiDBManager.MDSfsql.Select().Where(s => !string.IsNullOrEmpty(s.ShopId)) + .Where(s => request.ShopIds.Contains(s.ShopId)) + .ToList(); + } + public ShopResponse GetShopByShopId(string shopId) { return freeSqlMultiDBManager.MDSfsql.Select().Where(s => s.ShopId == shopId).ToOne(); diff --git a/BBWY.Server.Model/Dto/Request/Vender/QueryShopByIdsRequest.cs b/BBWY.Server.Model/Dto/Request/Vender/QueryShopByIdsRequest.cs new file mode 100644 index 00000000..62f8e674 --- /dev/null +++ b/BBWY.Server.Model/Dto/Request/Vender/QueryShopByIdsRequest.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace BBWY.Server.Model.Dto +{ + public class QueryShopByIdsRequest + { + public IList ShopIds { get; set; } + } +} diff --git a/BBWY.Server.Model/Dto/Request/Vender/ShopSettingRequest.cs b/BBWY.Server.Model/Dto/Request/Vender/ShopSettingRequest.cs index 26442fcb..ee164d84 100644 --- a/BBWY.Server.Model/Dto/Request/Vender/ShopSettingRequest.cs +++ b/BBWY.Server.Model/Dto/Request/Vender/ShopSettingRequest.cs @@ -30,5 +30,11 @@ namespace BBWY.Server.Model.Dto public string AppToken { get; set; } public Enums.Platform PurchasePlatformId { get; set; } + + public string DingDingWebHook { get; set; } + + public string DingDingKey { get; set; } + + public int SkuSafeTurnoverDays { get; set; } } }