Browse Source

平台扣点设置

qianyi
shanji 3 years ago
parent
commit
f76ff1fc4b
  1. 4
      BBWY.Client/APIServices/MdsApiService.cs
  2. 18
      BBWY.Client/APIServices/OrderService.cs
  3. 6
      BBWY.Client/APIServices/PurchaseOrderService.cs
  4. 2
      BBWY.Client/App.xaml.cs
  5. 4
      BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs
  6. 6
      BBWY.Client/Models/Shop/Shop.cs
  7. 2
      BBWY.Client/ViewModels/MainViewModel.cs
  8. 57
      BBWY.Client/ViewModels/Order/OrderListViewModel.cs
  9. 29
      BBWY.Client/ViewModels/Purchase/1688PreviewPurchaseViewModel.cs
  10. 34
      BBWY.Client/ViewModels/Setting/ShopSettingViewModel.cs
  11. 16
      BBWY.Client/Views/Setting/ShopSetting.xaml
  12. 30
      BBWY.Client/Views/Setting/ValidateManagePwd.xaml
  13. 30
      BBWY.Client/Views/Setting/ValidateManagePwd.xaml.cs
  14. 4
      BBWY.Server.Business/MDSBusiness.cs
  15. 43
      BBWY.Server.Business/Order/OrderBusiness.cs
  16. 6
      BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs
  17. 8
      BBWY.Server.Business/Vender/VenderBusiness.cs
  18. 5
      BBWY.Server.Model/Db/Mds/Shops.cs
  19. 4
      BBWY.Server.Model/Dto/Request/Order/AutoCalculationCostRequest.cs
  20. 5
      BBWY.Server.Model/Dto/Request/Order/ManualCalculationCostRequest.cs
  21. 2
      BBWY.Server.Model/Dto/Request/Order/RelationPurchaseOrderRequest.cs
  22. 7
      BBWY.Server.Model/Dto/Request/Order/SDCalculationCostRequest.cs
  23. 2
      BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs
  24. 4
      BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs

4
BBWY.Client/APIServices/MdsApiService.cs

@ -24,9 +24,9 @@ namespace BBWY.Client.APIServices
}, HttpMethod.Get);
}
public ApiResponse<IList<ShopResponse>> GetShopsByUserId(long userId)
public ApiResponse<IList<ShopResponse>> GetShopsByUserTeam(long userId)
{
return SendRequest<IList<ShopResponse>>(globalContext.MDSApiHost, "TaskList/Shop/GetShopsByUserId", $"userId={userId}", null, System.Net.Http.HttpMethod.Get);
return SendRequest<IList<ShopResponse>>(globalContext.MDSApiHost, "TaskList/Shop/GetShopsByUserTeam", $"userId={userId}", null, System.Net.Http.HttpMethod.Get);
}
}
}

18
BBWY.Client/APIServices/OrderService.cs

@ -85,9 +85,9 @@ namespace BBWY.Client.APIServices
/// <param name="isSetStorageType">是否设置仓储类型</param>
/// <param name="storageType"></param>
/// <returns></returns>
public ApiResponse<object> AutoCalculationCost(string orderId, bool isSetStorageType, StorageType storageType)
public ApiResponse<object> AutoCalculationCost(string orderId, bool isSetStorageType, StorageType storageType, decimal platformCommissionRatio)
{
return SendRequest<object>(globalContext.BBYWApiHost, "api/order/AutoCalculationCost", new { orderId, isSetStorageType, storageType }, null, HttpMethod.Post);
return SendRequest<object>(globalContext.BBYWApiHost, "api/order/AutoCalculationCost", new { orderId, isSetStorageType, storageType, platformCommissionRatio }, null, HttpMethod.Post);
}
/// <summary>
@ -97,7 +97,7 @@ namespace BBWY.Client.APIServices
/// <param name="isSetStorageType">是否设置仓储类型</param>
/// <param name="storageType"></param>
/// <returns></returns>
public ApiResponse<object> ManualCalculationCost(string orderId, bool isSetStorageType, StorageType storageType, decimal purchaseCost, decimal deliveryExpressFreight)
public ApiResponse<object> ManualCalculationCost(string orderId, bool isSetStorageType, StorageType storageType, decimal purchaseCost, decimal deliveryExpressFreight, decimal platformCommissionRatio)
{
return SendRequest<object>(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<object>(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
/// <param name="orderDropShipping"></param>
/// <param name="relationPurchaseOrderSkuList"></param>
/// <returns></returns>
public ApiResponse<object> RelationPurchaseOrder(OrderDropShipping orderDropShipping, IList<RelationPurchaseOrderSku> relationPurchaseOrderSkuList)
public ApiResponse<object> RelationPurchaseOrder(OrderDropShipping orderDropShipping, IList<RelationPurchaseOrderSku> relationPurchaseOrderSkuList,decimal platformCommissionRatio)
{
return SendRequest<object>(globalContext.BBYWApiHost, "api/order/RelationPurchaseOrder", new
{
orderDropShipping,
relationPurchaseOrderSkuList
relationPurchaseOrderSkuList,
platformCommissionRatio
}, null, HttpMethod.Post);
}

6
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<object>(globalContext.BBYWApiHost, "api/purchaseOrder/NewFastCreateOrder", new
{
@ -128,7 +129,8 @@ namespace BBWY.Client.APIServices
shopId,
purchaseAccountId,
buyerAccount,
sellerAccount
sellerAccount,
platformCommissionRatio
}, null, HttpMethod.Post);
}
}

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

4
BBWY.Client/Models/APIModel/Response/Shop/ShopResponse.cs

@ -21,5 +21,9 @@ namespace BBWY.Client.Models
public string AppToken { get; set; }
public IList<PurchaseAccountResponse> PurchaseList { get; set; }
public string ManagePwd { get; set; }
public decimal? PlatformCommissionRatio { get; set; }
}
}

6
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<PurchaseAccount> PurchaseAccountList { get; set; }
public string ManagePwd { get; set; }
/// <summary>
/// 店铺扣点
/// </summary>
public decimal? PlatformCommissionRatio { get; set; }
}
}

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

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

29
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<object>(null, "OnlinePurchase_Close");
});
//关闭当前窗口
GalaSoft.MvvmLight.Messaging.Messenger.Default.Send<object>(null, "OnlinePurchase_Close");
});
}
}
}

34
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;
});
}
}

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

@ -26,6 +26,7 @@
<Style x:Key="textboxValueStyle" TargetType="{x:Type c:BTextBox}">
<Setter Property="Width" Value="150"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Height" Value="30"/>
<Setter Property="Background" Value="White"/>
<Setter Property="BorderBrush" Value="{StaticResource TextBox.BorderBrush}"/>
@ -40,7 +41,7 @@
</b:EventTrigger>
</b:Interaction.Triggers>
<Grid>
<c:RoundWaitProgress Play="{Binding IsLoading}" Panel.ZIndex="999"/>
<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"/>
@ -59,12 +60,15 @@
</Grid.RowDefinitions>
<TextBlock Text="管理密码" Style="{StaticResource textblockPropertyStyle}"/>
<c:BTextBox Grid.Column="1" Style="{StaticResource textboxValueStyle}" IsEnabled="False"
DisableBgColor="{StaticResource TextBox.Disable.BgColor}"/>
<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" IsEnabled="False"
DisableBgColor="{StaticResource TextBox.Disable.BgColor}"/>
<TextBlock Text="平台扣点(%)" Style="{StaticResource textblockPropertyStyle}" Grid.Row="1"/>
<c:BTextBox Grid.Column="1" Style="{StaticResource textboxValueStyle}" Grid.Row="1"
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}}"

30
BBWY.Client/Views/Setting/ValidateManagePwd.xaml

@ -0,0 +1,30 @@
<c:BWindow x:Class="BBWY.Client.Views.Setting.ValidateManagePwd"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BBWY.Client.Views.Setting"
WindowStartupLocation="CenterScreen"
CloseButtonVisibility="Visible"
CloseButtonColor="{StaticResource WindowButtonColor}"
MinButtonVisibility="Collapsed"
MaxButtonVisibility="Collapsed"
RightButtonGroupMargin="0,7,7,0"
mc:Ignorable="d"
Title="验证店铺管理密码" Height="100" Width="300"
xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource MainMenu.BorderBrush}"
Background="{StaticResource Border.Background}">
<TextBlock Text="验证店铺管理密码" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="1">
<c:BTextBox x:Name="txtManagePwd" WaterRemark="管理密码" Width="200" IsPasswordBox="true"/>
<c:BButton Content="确定" Width="60" Margin="10,0,0,0" Click="BButton_Click"/>
</StackPanel>
</Grid>
</c:BWindow>

30
BBWY.Client/Views/Setting/ValidateManagePwd.xaml.cs

@ -0,0 +1,30 @@
using BBWY.Controls;
using System.Windows;
namespace BBWY.Client.Views.Setting
{
/// <summary>
/// ValidateManagePwd.xaml 的交互逻辑
/// </summary>
public partial class ValidateManagePwd : BWindow
{
private string managePwd;
public ValidateManagePwd(string managePwd)
{
InitializeComponent();
this.managePwd = managePwd;
}
private void BButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
if (txtManagePwd.PasswordStr == managePwd)
{
DialogResult = true;
this.Close();
}
else
MessageBox.Show("管理密码错误", "提示");
}
}
}

4
BBWY.Server.Business/MDSBusiness.cs

@ -45,7 +45,9 @@ namespace BBWY.Server.Business
Platform = (Enums.Platform)shopJToken.Value<int>("PlatformId"),
VenderType = shopJToken.Value<string>("ShopType"),
ShopId = shopId,
Name = shopJToken.Value<string>("ShopName")
Name = shopJToken.Value<string>("ShopName"),
ManagePwd = shopJToken.Value<string>("ManagePwd"),
PlatformCommissionRatio = shopJToken.Value<decimal>("PlatformCommissionRatio")
};
}
}

43
BBWY.Server.Business/Order/OrderBusiness.cs

@ -23,22 +23,31 @@ namespace BBWY.Server.Business
{
private ILogger logger;
private IFreeSql fsql;
private IDictionary<Enums.Platform, Action<JArray, long, string, string, string, string>> syncOrderMethodDic;
private IDictionary<Enums.Platform, Action<JArray, long, string, string, string, string, decimal>> syncOrderMethodDic;
private IIdGenerator idGenerator;
private TaskSchedulerManager taskSchedulerManager;
private MDSBusiness mdsBusiness;
public OrderBusiness(RestApiService restApiService, ILogger logger, IFreeSql fsql, IIdGenerator idGenerator, IOptions<GlobalConfig> options, TaskSchedulerManager taskSchedulerManager, MDSBusiness mdsBusiness) : base(restApiService, options)
private FreeSqlMultiDBManager freeSqlMultiDBManager;
public OrderBusiness(RestApiService restApiService,
ILogger logger,
IFreeSql fsql,
IIdGenerator idGenerator,
IOptions<GlobalConfig> options,
TaskSchedulerManager taskSchedulerManager,
MDSBusiness mdsBusiness,
FreeSqlMultiDBManager freeSqlMultiDBManager) : base(restApiService, options)
{
this.logger = logger;
this.fsql = fsql;
this.idGenerator = idGenerator;
this.taskSchedulerManager = taskSchedulerManager;
syncOrderMethodDic = new Dictionary<Enums.Platform, Action<JArray, long, string, string, string, string>>()
syncOrderMethodDic = new Dictionary<Enums.Platform, Action<JArray, long, string, string, string, string, decimal>>()
{
{ Enums.Platform., SyncJDOrder }
};
this.mdsBusiness = mdsBusiness;
this.freeSqlMultiDBManager = freeSqlMultiDBManager;
}
public OrderListResponse GetOrderList(SearchOrderRequest searchOrderRequest)
@ -457,11 +466,13 @@ namespace BBWY.Server.Business
if (orderCost == null)
{
if (autoCalculationCostRequest.PlatformCommissionRatio == 0M)
autoCalculationCostRequest.PlatformCommissionRatio = 0.05M;
#region 计算成本
orderCost = new OrderCost()
{
OrderId = autoCalculationCostRequest.OrderId,
PlatformCommissionRatio = 0.05M,
PlatformCommissionRatio = autoCalculationCostRequest.PlatformCommissionRatio,
PreferentialAmount = dbOrder.PreferentialAmount,
Profit = 0,
PurchaseAmount = orderCostPurchaseAmount,
@ -525,10 +536,12 @@ namespace BBWY.Server.Business
var orderCost = fsql.Select<OrderCost>(manualCalculationCostRequest.OrderId).ToOne();
if (orderCost == null)
{
if (manualCalculationCostRequest.PlatformCommissionRatio == 0M)
manualCalculationCostRequest.PlatformCommissionRatio = 0.05M;
orderCost = new OrderCost()
{
OrderId = manualCalculationCostRequest.OrderId,
PlatformCommissionRatio = 0.05M,
PlatformCommissionRatio = manualCalculationCostRequest.PlatformCommissionRatio,
PreferentialAmount = dbOrder.PreferentialAmount,
Profit = 0,
PurchaseAmount = manualCalculationCostRequest.PurchaseCost,
@ -607,10 +620,12 @@ namespace BBWY.Server.Business
var orderCost = fsql.Select<OrderCost>(sdCalculationCostRequest.OrderId).ToOne();
if (orderCost == null)
{
if (sdCalculationCostRequest.PlatformCommissionRatio == 0M)
sdCalculationCostRequest.PlatformCommissionRatio = 0.05M;
orderCost = new OrderCost()
{
OrderId = sdCalculationCostRequest.OrderId,
PlatformCommissionRatio = 0.05M,
PlatformCommissionRatio = sdCalculationCostRequest.PlatformCommissionRatio,
PreferentialAmount = dbOrder.PreferentialAmount,
Profit = 0,
DeliveryExpressFreight = sdCalculationCostRequest.DeliveryExpressFreight,
@ -721,15 +736,18 @@ namespace BBWY.Server.Business
{
var preferentialAmount = fsql.Select<OrderCoupon>().Where(oc => oc.OrderId == relationPurchaseOrderRequest.OrderDropShipping.OrderId)
.ToAggregate(g => g.Sum(g.Key.CouponPrice));
if (relationPurchaseOrderRequest.PlatformCommissionRatio == 0M)
relationPurchaseOrderRequest.PlatformCommissionRatio = 0.05M;
orderCost = new OrderCost()
{
OrderId = relationPurchaseOrderRequest.OrderDropShipping.OrderId,
CreateTime = DateTime.Now,
DeliveryExpressFreight = relationPurchaseOrderRequest.OrderDropShipping.DeliveryFreight,
PlatformCommissionRatio = 0.05M,
PlatformCommissionRatio = relationPurchaseOrderRequest.PlatformCommissionRatio,
SDCommissionAmount = 0,
PurchaseAmount = relationPurchaseOrderRequest.RelationPurchaseOrderSkuList.Sum(s => s.SingleSkuAmount * s.Quantity),
PlatformCommissionAmount = dbOrder.OrderSellerPrice * 0.05M,
PlatformCommissionAmount = dbOrder.OrderSellerPrice * relationPurchaseOrderRequest.PlatformCommissionRatio,
PreferentialAmount = preferentialAmount,
IsManualEdited = true
};
@ -883,7 +901,7 @@ namespace BBWY.Server.Business
if (orderListResponse.Data == null || orderListResponse.Data.Count == 0)
return;
syncOrderMethodDic[shop.Platform](orderListResponse.Data, shopId, relayAPIHost, shop.AppKey, shop.AppSecret, shop.AppToken);
syncOrderMethodDic[shop.Platform](orderListResponse.Data, shopId, relayAPIHost, shop.AppKey, shop.AppSecret, shop.AppToken, shop.PlatformCommissionRatio ?? 0.05M);
}
catch (Exception ex)
{
@ -948,8 +966,9 @@ namespace BBWY.Server.Business
}, System.Threading.CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.SyncOrderTaskScheduler);
}
private void SyncJDOrder(JArray orderTokenJArray, long shopId, string relayAPIHost, string appKey, string appSecret, string appToken)
private void SyncJDOrder(JArray orderTokenJArray, long shopId, string relayAPIHost, string appKey, string appSecret, string appToken, decimal platformCommissionRatio)
{
var orderTokenList = orderTokenJArray.Where(o => o.Value<decimal>("orderTotalPrice") != 0);
var interfaceOrderIdList = orderTokenList.Select(orderJToken => orderJToken.Value<string>("orderId"));
@ -1274,7 +1293,7 @@ namespace BBWY.Server.Business
orderCost = new OrderCost()
{
OrderId = orderId,
PlatformCommissionRatio = 0.05M,
PlatformCommissionRatio = platformCommissionRatio,
PreferentialAmount = dbOrder.PreferentialAmount,
Profit = 0,
PurchaseAmount = orderCostPurchaseAmount,

6
BBWY.Server.Business/PurchaseOrder/PurchaseOrderBusiness.cs

@ -222,6 +222,8 @@ namespace BBWY.Server.Business
public void NewFastCreateOrder(CreateOnlinePurchaseOrderRequest createOnlinePurchaseOrderRequest)
{
if (createOnlinePurchaseOrderRequest.PlatformCommissionRatio == 0M)
createOnlinePurchaseOrderRequest.PlatformCommissionRatio = 0.05M;
if (createOnlinePurchaseOrderRequest.Platform != Enums.Platform.)
throw new NotImplementedException();
var dbOrder = fsql.Select<Order>(createOnlinePurchaseOrderRequest.OrderId).ToOne();
@ -329,7 +331,7 @@ namespace BBWY.Server.Business
CreateTime = DateTime.Now,
DeliveryExpressFreight = 0,
IsManualEdited = false,
PlatformCommissionRatio = 0.05M,
PlatformCommissionRatio = createOnlinePurchaseOrderRequest.PlatformCommissionRatio,
PreferentialAmount = dbOrder.PreferentialAmount,
SDCommissionAmount = 0,
PurchaseAmount = purchaseOrderSimpleInfo.TotalAmount
@ -637,7 +639,7 @@ namespace BBWY.Server.Business
orderCost.PlatformCommissionAmount;
orderDropshipping.PurchaseAmount = purchaseOrderSimpleInfo.TotalAmount;
fsql.Transaction(() =>
{
foreach (var update in updatePurchaseOrders)

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

@ -115,7 +115,9 @@ namespace BBWY.Server.Business
{
freeSqlMultiDBManager.MDSfsql.Insert(mdspa).ExecuteAffrows();
//修改扣点和管理密码
freeSqlMultiDBManager.MDSfsql.Update<Shops>(mdsShop.Id).Set(s => s.ManagePwd, shopSettingRequest.ManagerPwd)
.Set(s => s.PlatformCommissionRatio, shopSettingRequest.PlatformCommissionRatio)
.ExecuteAffrows();
});
}
else
@ -136,7 +138,9 @@ namespace BBWY.Server.Business
.Set(pa => pa.AccountName, shopSettingRequest.AccountName)
.ExecuteAffrows();
//修改扣点和管理密码
freeSqlMultiDBManager.MDSfsql.Update<Shops>(mdsShop.Id).Set(s => s.ManagePwd, shopSettingRequest.ManagerPwd)
.Set(s => s.PlatformCommissionRatio, shopSettingRequest.PlatformCommissionRatio)
.ExecuteAffrows();
});
}
return shopSettingRequest.PurchaseAccountId;

5
BBWY.Server.Model/Db/Mds/Shops.cs

@ -95,6 +95,11 @@ namespace BBWY.Server.Model.Db.Mds
public string ShopType { get; set; }
public string ManagePwd { get; set; }
[Column(DbType = "decimal(11,2)")]
public decimal? PlatformCommissionRatio { get; set; }
}
}

4
BBWY.Server.Model/Dto/Request/Order/AutoCalculationCostRequest.cs

@ -8,5 +8,9 @@
public Enums.StorageType StorageType { get; set; }
/// <summary>
/// 店铺平台扣点
/// </summary>
public decimal PlatformCommissionRatio { get; set; }
}
}

5
BBWY.Server.Model/Dto/Request/Order/ManualCalculationCostRequest.cs

@ -17,5 +17,10 @@
/// 发货运费
/// </summary>
public decimal DeliveryExpressFreight { get; set; }
/// <summary>
/// 平台扣点
/// </summary>
public decimal PlatformCommissionRatio { get; set; }
}
}

2
BBWY.Server.Model/Dto/Request/Order/RelationPurchaseOrderRequest.cs

@ -7,6 +7,8 @@ namespace BBWY.Server.Model.Dto
public OrderDropShippingRequest OrderDropShipping { get; set; }
public IList<RelationPurchaseOrderSkuRequest> RelationPurchaseOrderSkuList { get; set; }
public decimal PlatformCommissionRatio { get; set; }
}
public class RelationPurchaseOrderSkuRequest

7
BBWY.Server.Model/Dto/Request/Order/SDCalculationCostRequest.cs

@ -1,6 +1,6 @@
namespace BBWY.Server.Model.Dto
{
public class SDCalculationCostRequest: PlatformRequest
public class SDCalculationCostRequest : PlatformRequest
{
public string OrderId { get; set; }
@ -21,5 +21,10 @@
/// 销售运费
/// </summary>
public decimal DeliveryExpressFreight { get; set; }
/// <summary>
/// 平台扣点
/// </summary>
public decimal PlatformCommissionRatio { get; set; }
}
}

2
BBWY.Server.Model/Dto/Request/PurchaseOrder/OnlinePurchase/CreateOnlinePurchaseOrderRequest.cs

@ -33,5 +33,7 @@
public string BuyerAccount { get; set; }
public string SellerAccount { get; set; }
public decimal PlatformCommissionRatio { get; set; }
}
}

4
BBWY.Server.Model/Dto/Response/Vender/ShopResponse.cs

@ -26,5 +26,9 @@ namespace BBWY.Server.Model.Dto
public string AppSecret { get; set; }
public string AppToken { get; set; }
public string ManagePwd { get; set; }
public decimal? PlatformCommissionRatio { get; set; }
}
}

Loading…
Cancel
Save