shanji 3 years ago
parent
commit
7bf2927eec
  1. 28
      BBWY.Client/APIServices/ShopService.cs
  2. 6
      BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs
  3. 6
      BBWY.Client/Models/Shop/Shop.cs
  4. 29
      BBWY.Client/ViewModels/MainViewModel.cs
  5. 23
      BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs
  6. 2
      BBWY.Client/Views/MainWindow.xaml
  7. 25
      BBWY.Client/Views/Setting/ShopSetting.xaml
  8. 11
      BBWY.Server.API/Controllers/VenderController.cs
  9. 23
      BBWY.Server.Business/Vender/VenderBusiness.cs
  10. 11
      BBWY.Server.Model/Dto/Request/Vender/QueryShopByIdsRequest.cs
  11. 6
      BBWY.Server.Model/Dto/Request/Vender/ShopSettingRequest.cs

28
BBWY.Client/APIServices/ShopService.cs

@ -12,8 +12,18 @@ namespace BBWY.Client.APIServices
{
public ShopService(RestApiService restApiService, GlobalContext globalContext) : base(restApiService, globalContext) { }
public ApiResponse<long> SaveShopSetting(long shopId, string managerPwd, decimal platformCommissionRatio, PurchaseAccount purchaseAccount)
public ApiResponse<long> SaveShopSetting(long shopId,
string managerPwd,
decimal platformCommissionRatio,
PurchaseAccount purchaseAccount,
string dingDingWebHook,
string dingDingKey,
int skuSafeTurnoverDays)
{
if (skuSafeTurnoverDays == 0)
{
dingDingWebHook = dingDingKey = string.Empty;
}
return SendRequest<long>(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);
}
@ -51,7 +64,16 @@ namespace BBWY.Client.APIServices
}, HttpMethod.Get);
}
public ApiResponse<IList<ShopResponse>> GetShopListByIds(IList<string> shopIds)
{
return SendRequest<IList<ShopResponse>>(globalContext.BBYWApiHost, "api/vender/GetShopListByShopIds", new
{
shopIds
}, new Dictionary<string, string>()
{
{ "bbwyTempKey", "21jfhayu27q" }
}, HttpMethod.Post);
}
}
}

6
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

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

29
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<string>();
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;

23
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<int> 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;

2
BBWY.Client/Views/MainWindow.xaml

@ -26,7 +26,7 @@
<!--<TextBlock Text="{Binding GlobalContext.User.TeamName}" Margin="5,0,0,0"/>
<TextBlock Text="{Binding GlobalContext.User.Shop.Platform}" Margin="5,0,0,0"/>-->
<TextBlock Text="{Binding GlobalContext.User.Shop.ShopName}" Margin="5,0,0,0"/>
<TextBlock Text="v10060" Margin="5,0,0,0"/>
<TextBlock Text="v10061" Margin="5,0,0,0"/>
</StackPanel>
</Border>
<Grid Grid.Row="1">

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

@ -133,7 +133,6 @@
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/>
@ -144,11 +143,11 @@
<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}"/>
Text="{Binding DingDingKey,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}"/>
Text="{Binding DingDingWebHook,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<Border Height="1" SnapsToDevicePixels="True" UseLayoutRounding="True" Background="{StaticResource Border.Brush}" Grid.ColumnSpan="2" Grid.Row="3"
VerticalAlignment="Center"/>
@ -156,18 +155,18 @@
<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"
<ComboBox ItemsSource="{Binding SafeDayList}" SelectedItem="{Binding SelectedSkuSafeTurnoverDay,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" Grid.Row="5" HorizontalAlignment="Left" Height="30" Width="100"
VerticalContentAlignment="Center"/>
<Grid Grid.ColumnSpan="2" Grid.Row="6" Margin="4.5,0">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition Width="0.32*"/>
<ColumnDefinition Width="0.32*"/>
<ColumnDefinition Width="0.36*"/>
</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,10,0,5"/>
<TextBlock Text="以3天为1个周期,连续2个周期增长幅度均超20%。" Margin="0,0,0,15"/>
<TextBlock Text="提醒规则" FontWeight="Bold" Margin="0,0,0,5"/>
<TextBlock Text="总库存/近七天日均销量小于15天" Margin="0,0,0,5"/>
<TextBlock Text="备货量建议:" Margin="0,0,0,5"/>
@ -177,8 +176,8 @@
</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,10,0,5"/>
<TextBlock Text="以3天为1个周期,两两组合的波动幅度不超20%。" Margin="0,0,0,15"/>
<TextBlock Text="提醒规则" FontWeight="Bold" Margin="0,0,0,5"/>
<TextBlock Text="总库存/近七天日均销量小于8天" Margin="0,0,0,5"/>
<TextBlock Text="备货量建议:" Margin="0,0,0,5"/>
@ -188,8 +187,8 @@
</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,10,0,5"/>
<TextBlock Text="以3天为1个周期,连续2个周期下降幅度均超20%,或7个周期内两两下降幅度最高超50%。" Margin="0,0,0,15"/>
<TextBlock Text="提醒规则" FontWeight="Bold" Margin="0,0,0,5"/>
<TextBlock Text="总库存/近七天日均销量小于8天" Margin="0,0,0,5"/>
<TextBlock Text="备货量建议:" Margin="0,0,0,5"/>

11
BBWY.Server.API/Controllers/VenderController.cs

@ -88,5 +88,16 @@ namespace BBWY.Server.API.Controllers
throw new BusinessException("非法请求");
return venderBusiness.GetDeparmentList();
}
/// <summary>
/// 根据ShopId获取店铺
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public IList<ShopResponse> GetShopListByShopIds(QueryShopByIdsRequest request)
{
return venderBusiness.GetShopListByShopIds(request);
}
}
}

23
BBWY.Server.Business/Vender/VenderBusiness.cs

@ -120,6 +120,9 @@ namespace BBWY.Server.Business
//修改扣点和管理密码
freeSqlMultiDBManager.MDSfsql.Update<Shops>(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<Shops>(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<ShopResponse>();
}
public IList<ShopResponse> GetShopListByShopIds(QueryShopByIdsRequest request)
{
return freeSqlMultiDBManager.MDSfsql.Select<Shops>().Where(s => !string.IsNullOrEmpty(s.ShopId))
.Where(s => request.ShopIds.Contains(s.ShopId))
.ToList<ShopResponse>();
}
public ShopResponse GetShopByShopId(string shopId)
{
return freeSqlMultiDBManager.MDSfsql.Select<Shops>().Where(s => s.ShopId == shopId).ToOne<ShopResponse>();

11
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<string> ShopIds { get; set; }
}
}

6
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; }
}
}

Loading…
Cancel
Save