diff --git a/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs b/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs index 39efc4d2..bc077039 100644 --- a/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs +++ b/BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs @@ -20,18 +20,34 @@ namespace BBWY.Client.ViewModels private PurchaseAccount purchaseAccount; private string managePwd; private decimal platformCommissionRatio; + private int panelIndex; + + + public ICommand SaveCommand { get; set; } + public ICommand SetPanelIndexCommand { get; set; } + 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 int PanelIndex { get => panelIndex; set { Set(ref panelIndex, value); } } + + public IList SafeDayList { get; set; } + public ShopSettingViewModel(GlobalContext globalContext, ShopService shopService) { + PanelIndex = 0; this.globalContext = globalContext; this.shopService = shopService; SaveCommand = new RelayCommand(Save); + SetPanelIndexCommand = new RelayCommand(i => + { + PanelIndex = i; + }); + SafeDayList = new List() { 0, 14, 21, 28 }; } protected override void Load() diff --git a/BBWY.Client/Views/Setting/ShopSetting.xaml b/BBWY.Client/Views/Setting/ShopSetting.xaml index 6cb091d6..1b5d1138 100644 --- a/BBWY.Client/Views/Setting/ShopSetting.xaml +++ b/BBWY.Client/Views/Setting/ShopSetting.xaml @@ -13,6 +13,10 @@ Title="ShopSetting" DataContext="{Binding ShopSetting,Source={StaticResource Locator}}"> + 0 + 1 + 2 + @@ -42,37 +46,60 @@ - - - - - + - - - - - - + - - - + + - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - + - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + diff --git a/BBWY.Server.API/Controllers/JDStockNumWarningController.cs b/BBWY.Server.API/Controllers/JDStockNumWarningController.cs new file mode 100644 index 00000000..b3d3b613 --- /dev/null +++ b/BBWY.Server.API/Controllers/JDStockNumWarningController.cs @@ -0,0 +1,25 @@ +using BBWY.Server.Business; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace BBWY.Server.API.Controllers +{ + public class JDStockNumWarningController : BaseApiController + { + private JDStockNumWarningBusiness jDStockNumWarningBusiness; + + public JDStockNumWarningController(IHttpContextAccessor httpContextAccessor, JDStockNumWarningBusiness jDStockNumWarningBusiness) : base(httpContextAccessor) + { + this.jDStockNumWarningBusiness = jDStockNumWarningBusiness; + } + + /// + /// 检查库存 + /// + [HttpGet] + public void StartCheckStockNum() + { + jDStockNumWarningBusiness.StartCheckStockNum(); + } + } +} diff --git a/BBWY.Server.Business/EarlyWarning/JD/JDStockNumWarningBusiness.cs b/BBWY.Server.Business/EarlyWarning/JD/JDStockNumWarningBusiness.cs index 4139c4dd..943b8407 100644 --- a/BBWY.Server.Business/EarlyWarning/JD/JDStockNumWarningBusiness.cs +++ b/BBWY.Server.Business/EarlyWarning/JD/JDStockNumWarningBusiness.cs @@ -210,7 +210,7 @@ namespace BBWY.Server.Business var stringToSign = timestamp + "\n" + secret; var sign = EncryptWithSHA256(stringToSign, secret); var url = $"{shop.DingDingWebHook}×tamp={timestamp}&sign={sign}"; - restApiService.SendRequest(url, string.Empty, new + var result = restApiService.SendRequest(url, string.Empty, new { msgtype = "text", text = new @@ -218,6 +218,8 @@ namespace BBWY.Server.Business content = dingdingContentBuilder.ToString() } }, null, HttpMethod.Post); + if (result.StatusCode != System.Net.HttpStatusCode.OK) + throw new Exception($"{shop.ShopName} 发送钉钉库存预警失败"); } } catch (Exception ex) @@ -232,7 +234,7 @@ namespace BBWY.Server.Business /// 待加密数据 /// 密钥 /// - public static string EncryptWithSHA256(string data, string secret) + private string EncryptWithSHA256(string data, string secret) { secret = secret ?? ""; diff --git a/BBWY.Server.Business/YunDingBusiness.cs b/BBWY.Server.Business/YunDingBusiness.cs index 92216892..eb9841eb 100644 --- a/BBWY.Server.Business/YunDingBusiness.cs +++ b/BBWY.Server.Business/YunDingBusiness.cs @@ -9,7 +9,7 @@ namespace BBWY.Server.Business { private IMemoryCache memoryCache; private IFreeSql fsql; - private TimeSpan expirationTimeSpan = TimeSpan.FromDays(1000); + private TimeSpan expirationTimeSpan = TimeSpan.FromDays(500); public YunDingBusiness(IMemoryCache memoryCache, IFreeSql fsql) { this.memoryCache = memoryCache;