shanji 3 years ago
parent
commit
224b66e279
  1. 18
      BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs
  2. 155
      BBWY.Client/Views/Setting/ShopSetting.xaml
  3. 25
      BBWY.Server.API/Controllers/JDStockNumWarningController.cs
  4. 6
      BBWY.Server.Business/EarlyWarning/JD/JDStockNumWarningBusiness.cs
  5. 2
      BBWY.Server.Business/YunDingBusiness.cs

18
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<int> SafeDayList { get; set; }
public ShopSettingViewModel(GlobalContext globalContext, ShopService shopService)
{
PanelIndex = 0;
this.globalContext = globalContext;
this.shopService = shopService;
SaveCommand = new RelayCommand(Save);
SetPanelIndexCommand = new RelayCommand<int>(i =>
{
PanelIndex = i;
});
SafeDayList = new List<int>() { 0, 14, 21, 28 };
}
protected override void Load()

155
BBWY.Client/Views/Setting/ShopSetting.xaml

@ -13,6 +13,10 @@
Title="ShopSetting"
DataContext="{Binding ShopSetting,Source={StaticResource Locator}}">
<Page.Resources>
<sys:Int32 x:Key="p0">0</sys:Int32>
<sys:Int32 x:Key="p1">1</sys:Int32>
<sys:Int32 x:Key="p2">2</sys:Int32>
<ObjectDataProvider x:Key="PlatformProvider" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="cmodel:Platform"/>
@ -42,37 +46,60 @@
</b:Interaction.Triggers>
<Grid>
<c:RoundWaitProgress Play="{Binding IsLoading}" Panel.ZIndex="999" Visibility="{Binding IsLoading,Converter={StaticResource objConverter},ConverterParameter=true:Visible:Collapsed}"/>
<Grid Margin="5,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="20,0">
<TextBlock Text="管理密码" Style="{StaticResource textblockPropertyStyle}"/>
<c:BTextBox Grid.Column="1" Style="{StaticResource textboxValueStyle}"
DisableBgColor="{StaticResource TextBox.Disable.BgColor}"
PasswordStr="{Binding ManagePwd,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
IsPasswordBox="True"/>
<TextBlock Text="平台扣点(%)" Style="{StaticResource textblockPropertyStyle}" Grid.Row="1"/>
<c:BTextBox Grid.Column="1" Style="{StaticResource textboxValueStyle}" Grid.Row="1"
<TextBlock Text="平台扣点(%)" Style="{StaticResource textblockPropertyStyle}" Margin="10,0,0,0"/>
<c:BTextBox Grid.Column="1" Style="{StaticResource textboxValueStyle}" Margin="5,0,0,0"
DisableBgColor="{StaticResource TextBox.Disable.BgColor}"
Text="{Binding PlatformCommissionRatio,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="采购平台" Style="{StaticResource textblockPropertyStyle}" Grid.Row="2"/>
<ComboBox ItemsSource="{Binding Source={StaticResource PlatformProvider}}"
Grid.Row="2" Grid.Column="1"
<TextBlock Text="税务扣点(%)" Style="{StaticResource textblockPropertyStyle}" Margin="10,0,0,0"/>
<c:BTextBox Grid.Column="1" Style="{StaticResource textboxValueStyle}" Margin="5,0,0,0"
DisableBgColor="{StaticResource TextBox.Disable.BgColor}"
IsEnabled="false"/>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="20,0">
<c:BButton Content="采购配置" Width="100"
Command="{Binding SetPanelIndexCommand}" CommandParameter="{StaticResource p0}"
Background="{Binding PanelIndex,Converter={StaticResource objConverter},ConverterParameter=0:#8080FF:#F2F2F2}"
Foreground="{Binding PanelIndex,Converter={StaticResource objConverter},ConverterParameter=0:White:#4A4A4A}"/>
<c:BButton Content="库存预警" Width="100" Command="{Binding SetPanelIndexCommand}" CommandParameter="{StaticResource p1}"
Background="{Binding PanelIndex,Converter={StaticResource objConverter},ConverterParameter=1:#8080FF:#F2F2F2}"
Foreground="{Binding PanelIndex,Converter={StaticResource objConverter},ConverterParameter=1:White:#4A4A4A}"/>
<c:BButton Content="司南" Width="100" Command="{Binding SetPanelIndexCommand}" CommandParameter="{StaticResource p2}"
Background="{Binding PanelIndex,Converter={StaticResource objConverter},ConverterParameter=2:#8080FF:#F2F2F2}"
Foreground="{Binding PanelIndex,Converter={StaticResource objConverter},ConverterParameter=2:White:#4A4A4A}"/>
</StackPanel>
<Grid Grid.Row="2" Margin="20,0" Visibility="{Binding PanelIndex,Converter={StaticResource objConverter},ConverterParameter=0:Visible:Collapsed}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="采购平台" Style="{StaticResource textblockPropertyStyle}"/>
<ComboBox ItemsSource="{Binding Source={StaticResource PlatformProvider}}" Grid.Column="1"
SelectedItem="{Binding PurchaseAccount.PurchasePlatformId}"
DisplayMemberPath="."
Height="25"
@ -80,24 +107,98 @@
HorizontalAlignment="Left"
VerticalContentAlignment="Center"/>
<TextBlock Text="账号名称" Style="{StaticResource textblockPropertyStyle}" Grid.Row="3"/>
<c:BTextBox Grid.Column="1" Style="{StaticResource textboxValueStyle}" Grid.Row="3"
<TextBlock Text="账号名称" Style="{StaticResource textblockPropertyStyle}" Grid.Row="1"/>
<c:BTextBox Grid.Column="1" Style="{StaticResource textboxValueStyle}" Grid.Row="1"
Text="{Binding PurchaseAccount.AccountName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="AppKey" Style="{StaticResource textblockPropertyStyle}" Grid.Row="4"/>
<c:BTextBox Grid.Column="1" Grid.Row="4"
<TextBlock Text="AppKey" Style="{StaticResource textblockPropertyStyle}" Grid.Row="2"/>
<c:BTextBox Grid.Column="1" Grid.Row="2"
Text="{Binding PurchaseAccount.AppKey,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="AppSecret" Style="{StaticResource textblockPropertyStyle}" Grid.Row="5"/>
<c:BTextBox Grid.Column="1" Grid.Row="5"
<TextBlock Text="AppSecret" Style="{StaticResource textblockPropertyStyle}" Grid.Row="3"/>
<c:BTextBox Grid.Column="1" Grid.Row="3"
Text="{Binding PurchaseAccount.AppSecret,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="AppToken" Style="{StaticResource textblockPropertyStyle}" Grid.Row="6"/>
<c:BTextBox Grid.Column="1" Grid.Row="6"
<TextBlock Text="AppToken" Style="{StaticResource textblockPropertyStyle}" Grid.Row="4"/>
<c:BTextBox Grid.Column="1" Grid.Row="4"
Text="{Binding PurchaseAccount.AppToken,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
<c:BButton Content="保存" Grid.Column="1" Grid.Row="7" Width="80" HorizontalAlignment="Left"
Command="{Binding SaveCommand}"/>
<Grid Grid.Row="2" Margin="20,0" Visibility="{Binding PanelIndex,Converter={StaticResource objConverter},ConverterParameter=1:Visible:Collapsed}">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="通知设置" Style="{StaticResource textblockPropertyStyle}"/>
<TextBlock Text="密钥" Style="{StaticResource textblockPropertyStyle}" Grid.Row="1"/>
<c:BTextBox Grid.Column="1" Style="{StaticResource textboxValueStyle}" Grid.Row="1" Width="500"
Text="{Binding PurchaseAccount.AccountName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="WebHook" Style="{StaticResource textblockPropertyStyle}" Grid.Row="2"/>
<c:BTextBox Grid.Column="1" Style="{StaticResource textboxValueStyle}" Grid.Row="2" Width="500"
Text="{Binding PurchaseAccount.AccountName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<Border Height="1" SnapsToDevicePixels="True" UseLayoutRounding="True" Background="{StaticResource Border.Brush}" Grid.ColumnSpan="2" Grid.Row="3"
VerticalAlignment="Center"/>
<TextBlock Text="策略设置" Style="{StaticResource textblockPropertyStyle}" Grid.Row="4"/>
<TextBlock Text="安全周转天数" Style="{StaticResource textblockPropertyStyle}" Grid.Row="5"/>
<ComboBox ItemsSource="{Binding SafeDayList}" Grid.Column="1" Grid.Row="5" HorizontalAlignment="Left" Height="30"
VerticalContentAlignment="Center"/>
<Grid Grid.ColumnSpan="2" Grid.Row="6" Margin="4.5,0">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="增长期定义" FontWeight="Bold" Margin="0,0,0,5"/>
<TextBlock Text="以3天为1个周期,连续2个周期增长幅度均超20%。" Margin="0,0,0,5"/>
<TextBlock Text="提醒规则" FontWeight="Bold" Margin="0,0,0,5"/>
<TextBlock Text="总库存/近七天日均销量小于15天" Margin="0,0,0,5"/>
<TextBlock Text="备货量建议:" Margin="0,0,0,5"/>
<TextBlock Text="14天周转天数:近7天总单量*2*1.5" Margin="0,0,0,5"/>
<TextBlock Text="21天周转天数:近7天总单量*3*1.5" Margin="0,0,0,5"/>
<TextBlock Text="28天周转天数:近7天总单量*4*1.5" Margin="0,0,0,5"/>
</StackPanel>
<StackPanel Grid.Column="1">
<TextBlock Text="稳定期定义" FontWeight="Bold" Margin="0,0,0,5"/>
<TextBlock Text="以3天为1个周期,两两组合的波动幅度不超20%。" Margin="0,0,0,5"/>
<TextBlock Text="提醒规则" FontWeight="Bold" Margin="0,0,0,5"/>
<TextBlock Text="总库存/近七天日均销量小于8天" Margin="0,0,0,5"/>
<TextBlock Text="备货量建议:" Margin="0,0,0,5"/>
<TextBlock Text="14天周转天数:近7天总单量*2*1" Margin="0,0,0,5"/>
<TextBlock Text="21天周转天数:近7天总单量*3*1" Margin="0,0,0,5"/>
<TextBlock Text="28天周转天数:近7天总单量*4*1" Margin="0,0,0,5"/>
</StackPanel>
<StackPanel Grid.Column="2">
<TextBlock Text="衰退期定义" FontWeight="Bold" Margin="0,0,0,5"/>
<TextBlock Text="以3天为1个周期,连续2个周期下降幅度均超20%,或7个周期内两两下降幅度最高超50%。" Margin="0,0,0,5"/>
<TextBlock Text="提醒规则" FontWeight="Bold" Margin="0,0,0,5"/>
<TextBlock Text="总库存/近七天日均销量小于8天" Margin="0,0,0,5"/>
<TextBlock Text="备货量建议:" Margin="0,0,0,5"/>
<TextBlock Text="暂停备货,采购代发。" Margin="0,0,0,5"/>
</StackPanel>
</Grid>
</Grid>
<c:BButton Content="保存" Grid.Row="3" Width="80" HorizontalAlignment="Left"
Command="{Binding SaveCommand}" Margin="20,0,0,0"/>
</Grid>
</Grid>
</Page>

25
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;
}
/// <summary>
/// 检查库存
/// </summary>
[HttpGet]
public void StartCheckStockNum()
{
jDStockNumWarningBusiness.StartCheckStockNum();
}
}
}

6
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}&timestamp={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
/// <param name="data">待加密数据</param>
/// <param name="secret">密钥</param>
/// <returns></returns>
public static string EncryptWithSHA256(string data, string secret)
private string EncryptWithSHA256(string data, string secret)
{
secret = secret ?? "";

2
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;

Loading…
Cancel
Save