159 changed files with 10122 additions and 840 deletions
@ -1,14 +0,0 @@ |
|||
<Page x:Class="BBWYB.Client.Views.WebB.WebB" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:local="clr-namespace:BBWYB.Client.Views.WebB" |
|||
mc:Ignorable="d" |
|||
d:DesignHeight="450" d:DesignWidth="800" |
|||
Title="WebB"> |
|||
|
|||
<Grid x:Name="grid"> |
|||
|
|||
</Grid> |
|||
</Page> |
@ -1,105 +0,0 @@ |
|||
using CommunityToolkit.Mvvm.Messaging; |
|||
using CommunityToolkit.Mvvm.Messaging.Messages; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
|
|||
namespace BBWYB.Client.Views.WebB |
|||
{ |
|||
/// <summary>
|
|||
/// WebB.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class WebB : Page |
|||
{ |
|||
private WebView2Manager w2m; |
|||
private bool isNavigated; |
|||
|
|||
private GlobalContext globalContext; |
|||
|
|||
public WebB() |
|||
{ |
|||
InitializeComponent(); |
|||
this.Loaded += WebB_Loaded; |
|||
this.Unloaded += WebB_Unloaded; |
|||
|
|||
WeakReferenceMessenger.Default.Register<Message_WebB_Refresh>(this, (o, x) => |
|||
{ |
|||
this.Dispatcher.Invoke(() => |
|||
{ |
|||
_ = w2m.wb2.ExecuteScriptAsync("window.location.reload();"); |
|||
}); |
|||
}); |
|||
|
|||
WeakReferenceMessenger.Default.Register<Message_WebB_RefreshPack>(this, (o, x) => |
|||
{ |
|||
this.Dispatcher.Invoke(() => |
|||
{ |
|||
_ = w2m.wb2.ExecuteScriptAsync("window.BBWY_B_WebContex('PACK_CONFIG_SUCCESS');"); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
private void WebB_Unloaded(object sender, RoutedEventArgs e) |
|||
{ |
|||
grid.Children.Remove(w2m.wb2); |
|||
//w2m.wb2.Dispose();
|
|||
w2m.Close(); |
|||
WeakReferenceMessenger.Default.UnregisterAll(this); |
|||
} |
|||
|
|||
private void WebB_Loaded(object sender, System.Windows.RoutedEventArgs e) |
|||
{ |
|||
var sp = (App.Current as App).ServiceProvider; |
|||
using (var s = sp.CreateScope()) |
|||
{ |
|||
w2m = s.ServiceProvider.GetRequiredService<WebView2Manager>(); |
|||
globalContext = s.ServiceProvider.GetRequiredService<GlobalContext>(); |
|||
} |
|||
|
|||
#if DEBUG
|
|||
var url = "http://192.168.1.8:8080"; |
|||
var registerName = "webTestContext"; |
|||
//var url = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "s.html");
|
|||
#else
|
|||
var url = "http://qtbbwy.qiyue666.com"; |
|||
var registerName = "webContext"; |
|||
#endif
|
|||
//var url = "http://qtbbwy.qiyue666.com";
|
|||
w2m.CoreWebView2InitializationCompleted = (e) => |
|||
{ |
|||
w2m.wb2.CoreWebView2.AddHostObjectToScript(registerName, this.globalContext); |
|||
isNavigated = true; |
|||
w2m.wb2.CoreWebView2.Navigate(url); |
|||
}; |
|||
|
|||
|
|||
w2m.Init("bbwyb_web"); |
|||
w2m.wb2.SetValue(Grid.RowProperty, 1); |
|||
w2m.wb2.Margin = new Thickness(1, 0, 1, 0); |
|||
//grid.Children.Clear();
|
|||
grid.Children.Add(w2m.wb2); |
|||
|
|||
if (w2m.IsInitializationCompleted && !isNavigated) |
|||
{ |
|||
w2m.wb2.CoreWebView2.Navigate(url); |
|||
//w2m.wb2.CoreWebView2.NavigateToString(content);
|
|||
isNavigated = true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
public class Message_WebB_Refresh : ValueChangedMessage<object> |
|||
{ |
|||
public Message_WebB_Refresh(object value) : base(value) |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public class Message_WebB_RefreshPack : ValueChangedMessage<object> |
|||
{ |
|||
public Message_WebB_RefreshPack(object value) : base(value) |
|||
{ |
|||
} |
|||
} |
|||
} |
@ -1,14 +0,0 @@ |
|||
<Page x:Class="BBWYB.Client.Views.WebB.WebB_GoodsSource" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:local="clr-namespace:BBWYB.Client.Views.WebB" |
|||
mc:Ignorable="d" |
|||
d:DesignHeight="450" d:DesignWidth="800" |
|||
Title="WebB"> |
|||
|
|||
<Grid x:Name="grid"> |
|||
|
|||
</Grid> |
|||
</Page> |
@ -1,104 +0,0 @@ |
|||
using CommunityToolkit.Mvvm.Messaging; |
|||
using CommunityToolkit.Mvvm.Messaging.Messages; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
|
|||
namespace BBWYB.Client.Views.WebB |
|||
{ |
|||
/// <summary>
|
|||
/// WebB.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class WebB_GoodsSource : Page |
|||
{ |
|||
private WebView2Manager w2m; |
|||
private bool isNavigated; |
|||
|
|||
private GlobalContext globalContext; |
|||
|
|||
public WebB_GoodsSource() |
|||
{ |
|||
InitializeComponent(); |
|||
this.Loaded += WebB_Loaded; |
|||
this.Unloaded += WebB_Unloaded; |
|||
|
|||
//WeakReferenceMessenger.Default.Register<Message_WebB_Refresh>(this, (o, x) =>
|
|||
//{
|
|||
// this.Dispatcher.Invoke(() =>
|
|||
// {
|
|||
// _ = w2m.wb2.ExecuteScriptAsync("window.location.reload();");
|
|||
// });
|
|||
//});
|
|||
|
|||
//WeakReferenceMessenger.Default.Register<Message_WebB_RefreshPack>(this, (o, x) =>
|
|||
//{
|
|||
// this.Dispatcher.Invoke(() =>
|
|||
// {
|
|||
// _ = w2m.wb2.ExecuteScriptAsync("window.BBWY_B_WebContex('PACK_CONFIG_SUCCESS');");
|
|||
// });
|
|||
//});
|
|||
} |
|||
|
|||
private void WebB_Unloaded(object sender, RoutedEventArgs e) |
|||
{ |
|||
grid.Children.Remove(w2m.wb2); |
|||
//w2m.wb2.Dispose();
|
|||
w2m.Close(); |
|||
WeakReferenceMessenger.Default.UnregisterAll(this); |
|||
} |
|||
|
|||
private void WebB_Loaded(object sender, System.Windows.RoutedEventArgs e) |
|||
{ |
|||
var sp = (App.Current as App).ServiceProvider; |
|||
using (var s = sp.CreateScope()) |
|||
{ |
|||
w2m = s.ServiceProvider.GetRequiredService<WebView2Manager>(); |
|||
globalContext = s.ServiceProvider.GetRequiredService<GlobalContext>(); |
|||
} |
|||
|
|||
#if DEBUG
|
|||
var url = "http://192.168.1.2:8080/#/goods-source"; |
|||
var registerName = "webTestContext"; |
|||
//var url = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "s.html");
|
|||
#else
|
|||
var url = "http://qtbbwy.qiyue666.com/#/goods-source"; |
|||
var registerName = "webContext"; |
|||
#endif
|
|||
w2m.CoreWebView2InitializationCompleted = (e) => |
|||
{ |
|||
w2m.wb2.CoreWebView2.AddHostObjectToScript(registerName, this.globalContext); |
|||
isNavigated = true; |
|||
w2m.wb2.CoreWebView2.Navigate(url); |
|||
}; |
|||
|
|||
|
|||
w2m.Init("bbwyb_web"); |
|||
w2m.wb2.SetValue(Grid.RowProperty, 1); |
|||
w2m.wb2.Margin = new Thickness(1, 0, 1, 0); |
|||
//grid.Children.Clear();
|
|||
grid.Children.Add(w2m.wb2); |
|||
|
|||
if (w2m.IsInitializationCompleted && !isNavigated) |
|||
{ |
|||
w2m.wb2.CoreWebView2.Navigate(url); |
|||
//w2m.wb2.CoreWebView2.NavigateToString(content);
|
|||
isNavigated = true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
//public class Message_WebB_GoodsSource_Refresh : ValueChangedMessage<object>
|
|||
//{
|
|||
// public Message_WebB_GoodsSource_Refresh(object value) : base(value)
|
|||
// {
|
|||
// }
|
|||
//}
|
|||
|
|||
//public class Message_WebB_GoodsSource_RefreshPack : ValueChangedMessage<object>
|
|||
//{
|
|||
// public Message_WebB_GoodsSource_RefreshPack(object value) : base(value)
|
|||
// {
|
|||
// }
|
|||
//}
|
|||
} |
@ -1,14 +0,0 @@ |
|||
<Page x:Class="BBWYB.Client.Views.WebB.WebB_KPI" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:local="clr-namespace:BBWYB.Client.Views.WebB" |
|||
mc:Ignorable="d" |
|||
d:DesignHeight="450" d:DesignWidth="800" |
|||
Title="WebB_KPI"> |
|||
|
|||
<Grid x:Name="grid"> |
|||
|
|||
</Grid> |
|||
</Page> |
@ -1,87 +0,0 @@ |
|||
using CommunityToolkit.Mvvm.Messaging; |
|||
using CommunityToolkit.Mvvm.Messaging.Messages; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using System; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
|
|||
namespace BBWYB.Client.Views.WebB |
|||
{ |
|||
/// <summary>
|
|||
/// WebB_KPI.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class WebB_KPI : Page |
|||
{ |
|||
private WebView2Manager w2m; |
|||
private bool isNavigated; |
|||
|
|||
private GlobalContext globalContext; |
|||
public WebB_KPI() |
|||
{ |
|||
InitializeComponent(); |
|||
|
|||
this.Loaded += WebB_KPI_Loaded; ; |
|||
this.Unloaded += WebB_KPI_Unloaded; |
|||
|
|||
WeakReferenceMessenger.Default.Register<Message_WebBKPI_Refresh>(this, (o, x) => |
|||
{ |
|||
this.Dispatcher.Invoke(() => |
|||
{ |
|||
_ = w2m.wb2.ExecuteScriptAsync("window.location.reload();"); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
private void WebB_KPI_Unloaded(object sender, RoutedEventArgs e) |
|||
{ |
|||
grid.Children.Remove(w2m.wb2); |
|||
w2m.Close(); |
|||
WeakReferenceMessenger.Default.UnregisterAll(this); |
|||
} |
|||
|
|||
private void WebB_KPI_Loaded(object sender, RoutedEventArgs e) |
|||
{ |
|||
var sp = (App.Current as App).ServiceProvider; |
|||
using (var s = sp.CreateScope()) |
|||
{ |
|||
w2m = s.ServiceProvider.GetRequiredService<WebView2Manager>(); |
|||
globalContext = s.ServiceProvider.GetRequiredService<GlobalContext>(); |
|||
} |
|||
|
|||
#if DEBUG
|
|||
var url = "http://localhost:8080/#/performance"; |
|||
var registerName = "webTestContext"; |
|||
#else
|
|||
var url = "http://qtbbwy.qiyue666.com/#/performance"; |
|||
var registerName = "webContext"; |
|||
#endif
|
|||
w2m.CoreWebView2InitializationCompleted = (e) => |
|||
{ |
|||
w2m.wb2.CoreWebView2.AddHostObjectToScript(registerName, this.globalContext); |
|||
isNavigated = true; |
|||
w2m.wb2.CoreWebView2.Navigate(url); |
|||
}; |
|||
|
|||
|
|||
w2m.Init("bbwyb_web"); |
|||
w2m.wb2.SetValue(Grid.RowProperty, 1); |
|||
w2m.wb2.Margin = new Thickness(1, 0, 1, 0); |
|||
//grid.Children.Clear();
|
|||
grid.Children.Add(w2m.wb2); |
|||
|
|||
if (w2m.IsInitializationCompleted && !isNavigated) |
|||
{ |
|||
w2m.wb2.CoreWebView2.Navigate(url); |
|||
//w2m.wb2.CoreWebView2.NavigateToString(content);
|
|||
isNavigated = true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public class Message_WebBKPI_Refresh : ValueChangedMessage<object> |
|||
{ |
|||
public Message_WebBKPI_Refresh(object value) : base(value) |
|||
{ |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,29 @@ |
|||
namespace BBWYB.Common.Extensions |
|||
{ |
|||
public static class ConverterExtensions |
|||
{ |
|||
public static long? ToInt64(this object? o) |
|||
{ |
|||
try |
|||
{ |
|||
return Convert.ToInt64(o); |
|||
} |
|||
catch |
|||
{ |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public static int? ToInt32(this object? o) |
|||
{ |
|||
try |
|||
{ |
|||
return Convert.ToInt32(o); |
|||
} |
|||
catch |
|||
{ |
|||
return null; |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,9 @@ |
|||
<Application x:Class="BBWYB.PurchaserCapture.App" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:local="clr-namespace:BBWYB.PurchaserCapture" |
|||
StartupUri="MainWindow.xaml"> |
|||
<Application.Resources> |
|||
|
|||
</Application.Resources> |
|||
</Application> |
@ -0,0 +1,22 @@ |
|||
using Microsoft.Extensions.Configuration; |
|||
using System.Configuration; |
|||
using System.Data; |
|||
using System.Windows; |
|||
|
|||
namespace BBWYB.PurchaserCapture |
|||
{ |
|||
/// <summary>
|
|||
/// Interaction logic for App.xaml
|
|||
/// </summary>
|
|||
public partial class App : Application |
|||
{ |
|||
public IServiceProvider ServiceProvider { get; private set; } |
|||
public IConfiguration Configuration { get; private set; } |
|||
|
|||
protected override void OnStartup(StartupEventArgs e) |
|||
{ |
|||
base.OnStartup(e); |
|||
} |
|||
} |
|||
|
|||
} |
@ -0,0 +1,10 @@ |
|||
using System.Windows; |
|||
|
|||
[assembly: ThemeInfo( |
|||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
|||
//(used if a resource is not found in the page,
|
|||
// or application resource dictionaries)
|
|||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
|||
//(used if a resource is not found in the page,
|
|||
// app, or any theme specific resource dictionaries)
|
|||
)] |
@ -0,0 +1,21 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net6.0-windows</TargetFramework> |
|||
<Nullable>enable</Nullable> |
|||
<ImplicitUsings>enable</ImplicitUsings> |
|||
<UseWPF>true</UseWPF> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" /> |
|||
<PackageReference Include="FreeSql" Version="3.2.690" /> |
|||
<PackageReference Include="FreeSql.Provider.MySql" Version="3.2.690" /> |
|||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.2-mauipre.1.22102.15" /> |
|||
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.2-mauipre.1.22102.15" /> |
|||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2210.55" /> |
|||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
@ -0,0 +1,83 @@ |
|||
using System.IO; |
|||
using System.Security.Cryptography; |
|||
using System.Text; |
|||
|
|||
namespace BBWYB.Common.Extensions |
|||
{ |
|||
public static class EncryptionExtension |
|||
{ |
|||
|
|||
public static string Md5Encrypt(this string originStr) |
|||
{ |
|||
using (var md5 = MD5.Create()) |
|||
{ |
|||
return string.Join(string.Empty, md5.ComputeHash(Encoding.UTF8.GetBytes(originStr)).Select(x => x.ToString("x2"))); |
|||
} |
|||
} |
|||
|
|||
//AES加密 传入,要加密的串和, 解密key
|
|||
public static string AESEncrypt(this string input) |
|||
{ |
|||
var key = "dataplatform2019"; |
|||
var ivStr = "1012132405963708"; |
|||
|
|||
var encryptKey = Encoding.UTF8.GetBytes(key); |
|||
var iv = Encoding.UTF8.GetBytes(ivStr); //偏移量,最小为16
|
|||
using (var aesAlg = Aes.Create()) |
|||
{ |
|||
using (var encryptor = aesAlg.CreateEncryptor(encryptKey, iv)) |
|||
{ |
|||
using (var msEncrypt = new MemoryStream()) |
|||
{ |
|||
using (var csEncrypt = new CryptoStream(msEncrypt, encryptor, |
|||
CryptoStreamMode.Write)) |
|||
|
|||
using (var swEncrypt = new StreamWriter(csEncrypt)) |
|||
{ |
|||
swEncrypt.Write(input); |
|||
} |
|||
var decryptedContent = msEncrypt.ToArray(); |
|||
|
|||
return Convert.ToBase64String(decryptedContent); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static string AESDecrypt(this string cipherText) |
|||
{ |
|||
var fullCipher = Convert.FromBase64String(cipherText); |
|||
|
|||
var ivStr = "1012132405963708"; |
|||
var key = "dataplatform2019"; |
|||
|
|||
var iv = Encoding.UTF8.GetBytes(ivStr); |
|||
var decryptKey = Encoding.UTF8.GetBytes(key); |
|||
|
|||
using (var aesAlg = Aes.Create()) |
|||
{ |
|||
using (var decryptor = aesAlg.CreateDecryptor(decryptKey, iv)) |
|||
{ |
|||
string result; |
|||
using (var msDecrypt = new MemoryStream(fullCipher)) |
|||
{ |
|||
using (var csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read)) |
|||
{ |
|||
using (var srDecrypt = new StreamReader(csDecrypt)) |
|||
{ |
|||
result = srDecrypt.ReadToEnd(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static string Base64Encrypt(this string originStr) |
|||
{ |
|||
return Convert.ToBase64String(Encoding.UTF8.GetBytes(originStr)); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,19 @@ |
|||
<Window x:Class="BBWYB.PurchaserCapture.MainWindow" |
|||
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:BBWYB.PurchaserCapture" |
|||
mc:Ignorable="d" |
|||
Title="MainWindow" Height="450" Width="800"> |
|||
<Grid x:Name="grid"> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition/> |
|||
<RowDefinition Height="40"/> |
|||
<RowDefinition Height="40"/> |
|||
</Grid.RowDefinitions> |
|||
<TextBox x:Name="txt_url" Grid.Row="1" Height="30" Margin="5,0" VerticalContentAlignment="Center"/> |
|||
<TextBlock x:Name="txtInfo" Text="" Grid.Row="2" VerticalAlignment="Center" Margin="5,0,0,0" HorizontalAlignment="Left"/> |
|||
<Button x:Name="btn_start" Grid.Row="2" Width="80" Content="开始" Height="25" Click="btn_start_Click"/> |
|||
</Grid> |
|||
</Window> |
@ -0,0 +1,184 @@ |
|||
using BBWYB.Common.Extensions; |
|||
using BBWYB.Server.Model.Db; |
|||
using Microsoft.Web.WebView2.Core; |
|||
using Microsoft.Web.WebView2.Wpf; |
|||
using System.IO; |
|||
using System.Reflection.Metadata; |
|||
using System.Text; |
|||
using System.Text.RegularExpressions; |
|||
using System.Windows; |
|||
using io = System.IO; |
|||
|
|||
namespace BBWYB.PurchaserCapture |
|||
{ |
|||
/// <summary>
|
|||
/// Interaction logic for MainWindow.xaml
|
|||
/// </summary>
|
|||
public partial class MainWindow : Window |
|||
{ |
|||
private IFreeSql fsql; |
|||
private WebView2 wb2; |
|||
private string purchaserId; |
|||
private string purchaserMemberId; |
|||
|
|||
public MainWindow() |
|||
{ |
|||
InitializeComponent(); |
|||
|
|||
fsql = new FreeSql.FreeSqlBuilder().UseConnectionString(FreeSql.DataType.MySql, "data source=rm-bp1508okrh23710yfao.mysql.rds.aliyuncs.com;port=3306;user id=qyroot;password=kaicn1132+-;initial catalog=bbwyb;charset=utf8;sslmode=none;").Build(); |
|||
this.Loaded += MainWindow_Loaded; |
|||
} |
|||
|
|||
private async void MainWindow_Loaded(object sender, RoutedEventArgs e) |
|||
{ |
|||
wb2 = new WebView2(); |
|||
grid.Children.Add(wb2); |
|||
var wb2Setting = CoreWebView2Environment.CreateAsync(userDataFolder: io.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AdvUnion.Capturer")).Result; |
|||
wb2.CoreWebView2InitializationCompleted += Wb2_CoreWebView2InitializationCompleted; |
|||
await wb2.EnsureCoreWebView2Async(wb2Setting); |
|||
wb2.CoreWebView2.AddWebResourceRequestedFilter("*", CoreWebView2WebResourceContext.All); |
|||
wb2.CoreWebView2.WebResourceResponseReceived += CoreWebView2_WebResourceResponseReceived; |
|||
wb2.CoreWebView2.WebResourceRequested += CoreWebView2_WebResourceRequested; |
|||
wb2.CoreWebView2.NavigationCompleted += CoreWebView2_NavigationCompleted; |
|||
wb2.CoreWebView2.Navigate("https://www.1688.com"); |
|||
} |
|||
|
|||
private void CoreWebView2_NavigationCompleted(object? sender, CoreWebView2NavigationCompletedEventArgs e) |
|||
{ |
|||
var scriptBuilder = new StringBuilder(); |
|||
scriptBuilder.AppendLine("var divElement = document.querySelector('div[style=\"position: relative; display: flex; flex-direction: row;\"]');"); |
|||
scriptBuilder.AppendLine("var mouseeoverEvent = new MouseEvent('mouseover', {'view': window,'bubbles': true,'cancelable': false});"); |
|||
scriptBuilder.AppendLine("divElement.dispatchEvent(mouseeoverEvent);"); |
|||
wb2.CoreWebView2.ExecuteScriptAsync(scriptBuilder.ToString()); |
|||
} |
|||
|
|||
private async void CoreWebView2_WebResourceResponseReceived(object? sender, CoreWebView2WebResourceResponseReceivedEventArgs e) |
|||
{ |
|||
if (e.Request.Method.ToUpper() != "GET" || |
|||
!e.Request.Uri.StartsWith("https://h5api.m.1688.com/h5/mtop.alibaba.alisite.cbu.server.moduleasyncservice") || |
|||
!e.Request.Uri.Contains("wp_pc_common_header")) |
|||
{ |
|||
Console.WriteLine($"不满足URL规则,已忽略 {e.Request.Uri}"); |
|||
return; |
|||
} |
|||
if (e.Response.StatusCode != 200) |
|||
{ |
|||
Console.WriteLine($"HttpCode {e.Response.StatusCode},已忽略 {e.Request.Uri}"); |
|||
return; |
|||
} |
|||
try |
|||
{ |
|||
var stream = await e.Response.GetContentAsync(); |
|||
var sr = new StreamReader(stream); |
|||
var content = sr.ReadToEnd(); |
|||
sr.Dispose(); |
|||
var match = Regex.Match(content, "\"bizTypeName\":\\s?\"(.*)\",\"isShili"); |
|||
if (!match.Success) |
|||
{ |
|||
Console.WriteLine($"bizTypeName解析失败,已忽略 {e.Request.Uri}"); |
|||
return; |
|||
} |
|||
var bizTypeName = match.Groups[1].Value; |
|||
Console.WriteLine(bizTypeName); |
|||
if (!string.IsNullOrEmpty(purchaserId)) |
|||
{ |
|||
if (!string.IsNullOrEmpty(purchaserMemberId)) |
|||
{ |
|||
if (!content.Contains(purchaserMemberId)) |
|||
{ |
|||
Console.WriteLine($"memberId验证失败,已忽略 {e.Request.Uri}"); |
|||
return; |
|||
} |
|||
} |
|||
Console.ForegroundColor = ConsoleColor.Green; |
|||
Console.WriteLine($"更新采购商{purchaserId}"); |
|||
Console.ResetColor(); |
|||
fsql.Update<Purchaser>(purchaserId).Set(p => p.ManagmentModeText, bizTypeName).ExecuteAffrows(); |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Console.WriteLine(ex.Message); |
|||
} |
|||
} |
|||
|
|||
private void CoreWebView2_WebResourceRequested(object? sender, CoreWebView2WebResourceRequestedEventArgs e) |
|||
{ |
|||
|
|||
|
|||
} |
|||
|
|||
private void Wb2_CoreWebView2InitializationCompleted(object? sender, CoreWebView2InitializationCompletedEventArgs e) |
|||
{ |
|||
|
|||
} |
|||
|
|||
private void SetInfo(string msg) |
|||
{ |
|||
this.Dispatcher.Invoke(() => txtInfo.Text = msg); |
|||
} |
|||
|
|||
private void Navigate(string url) |
|||
{ |
|||
this.Dispatcher.Invoke(() => |
|||
{ |
|||
txt_url.Text = url; |
|||
wb2.CoreWebView2.Navigate(url); |
|||
}); |
|||
} |
|||
|
|||
private void btn_start_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
Task.Factory.StartNew(() => |
|||
{ |
|||
var sk = "order"; |
|||
//var sk = "consign";
|
|||
|
|||
var select = fsql.Select<OrderPurchaseInfo, Purchaser>() |
|||
.InnerJoin((opi, p) => opi.PurchaserId == p.Id) |
|||
.Where((opi, p) => string.IsNullOrEmpty(p.ManagmentModeText)) |
|||
.GroupBy((opi, p) => new { p.Id, p.MemberId }) |
|||
.WithTempQuery(g => new |
|||
{ |
|||
MaxPoId = g.Max(g.Value.Item1.PurchaseOrderId), |
|||
PurchaserId = g.Key.Id, |
|||
g.Key.MemberId |
|||
}) |
|||
.From<OrderPurchaseSkuInfo>() |
|||
.InnerJoin((opi1, ops) => opi1.MaxPoId == ops.PurchaseOrderId) |
|||
.GroupBy((opi1, ops) => new { opi1.PurchaserId, opi1.MemberId, opi1.MaxPoId, ops.PurchaseProductId }); |
|||
var sql = select.ToSql(g => new { g.Key.PurchaserId, g.Key.MemberId, g.Key.MaxPoId, g.Key.PurchaseProductId }); |
|||
var pspList = select.ToList(g => new { g.Key.PurchaserId, g.Key.MemberId, g.Key.MaxPoId, g.Key.PurchaseProductId }); |
|||
|
|||
|
|||
|
|||
|
|||
//var pspList = fsql.Select<PurchaseSchemeProduct, Purchaser>()
|
|||
// .InnerJoin((psp2, p) => psp2.PurchaserId == p.Id)
|
|||
// .Where((psp2, p) => string.IsNullOrEmpty(p.ManagmentModeText))
|
|||
// .GroupBy((psp2, p) => new { p.Id, p.MemberId })
|
|||
// .WithTempQuery(g => new { MaxId = g.Max(g.Value.Item1.Id), PurchaserId = g.Key.Id, MemberId = g.Key.MemberId })
|
|||
// .From<PurchaseSchemeProduct>()
|
|||
// .InnerJoin((psp2, psp1) => psp2.MaxId == psp1.Id)
|
|||
// .OrderByDescending((psp2, psp1) => Guid.NewGuid())
|
|||
// .ToList((psp2, psp1) => new
|
|||
// {
|
|||
// psp1.PurchaserId,
|
|||
// psp2.MemberId,
|
|||
// psp1.PurchaseProductId
|
|||
// });
|
|||
|
|||
for (var i = 0; i < pspList.Count; i++) |
|||
{ |
|||
SetInfo($"{i + 1}/{pspList.Count}"); |
|||
purchaserId = pspList[i].PurchaserId; |
|||
purchaserMemberId = pspList[i].MemberId; |
|||
var url = $"https://detail.1688.com/offer/{pspList[i].PurchaseProductId}.html?clickid={Guid.NewGuid().ToString().Md5Encrypt()}&sessionid={Guid.NewGuid().ToString().Md5Encrypt()}&sk={sk}"; |
|||
Navigate(url); |
|||
|
|||
Thread.Sleep(10000); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,94 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
[Table(Name = "orderpurchaseinfo", DisableSyncStructure = true)] |
|||
public partial class OrderPurchaseInfo |
|||
{ |
|||
[Column(IsPrimary = true, IsNullable = false)] |
|||
public long Id { get; set; } |
|||
|
|||
[Column(StringLength = 50, IsNullable = false)] |
|||
public string OrderId { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 꽃뭔瑯뵀Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 100)] |
|||
public string PurchaseAccountId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 꽃뭔瑯뵀츰냔
|
|||
/// </summary>
|
|||
[Column(StringLength = 100)] |
|||
public string PurchaseAccountName { get; set; } |
|||
|
|||
[Column(MapType = typeof(int?))] |
|||
public Enums.PurchaseMethod? PurchaseMethod { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 꽃뭔데Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 100)] |
|||
public string PurchaseOrderId { get; set; } |
|||
|
|||
[Column(MapType = typeof(int?))] |
|||
public Enums.Platform? PurchasePlatform { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 꽃뭔�Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 100)] |
|||
public string PurchaserId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 꽃뭔�츰냔
|
|||
/// </summary>
|
|||
[Column(StringLength = 100)] |
|||
public string PurchaserName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 듦팟Id
|
|||
/// </summary>
|
|||
public long? ShopId { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 백橄땐데Sku
|
|||
/// </summary>
|
|||
[Column(StringLength = 500)] |
|||
public string BelongSkuIds { get; set; } |
|||
|
|||
[Column(DbType = "bit")] |
|||
public bool IsEnabled { get; set; } = true; |
|||
|
|||
/// <summary>
|
|||
/// 꽃뭔데구鬧
|
|||
/// </summary>
|
|||
[Column(StringLength = 500)] |
|||
public string Remark { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// �零저袈꽃뭔데珂쇌
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime", IsNullable = true)] |
|||
public DateTime HistorySettingTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 꽃뭔데榴檄
|
|||
/// </summary>
|
|||
[Column(MapType = typeof(int?))] |
|||
public Enums.PurchaseOrderState? OrderState { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 角뤠틱송
|
|||
/// </summary>
|
|||
[Column(MapType = typeof(int?))] |
|||
public Enums.AutoEditOrderPriceType? IsAutoEditOrderPrice { get; set; } |
|||
} |
|||
|
|||
} |
@ -0,0 +1,67 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 采购单Sku表
|
|||
/// </summary>
|
|||
[Table(Name = "orderpurchaseskuinfo", DisableSyncStructure = true)] |
|||
public partial class OrderPurchaseSkuInfo |
|||
{ |
|||
|
|||
[Column(IsPrimary = true, StringLength = 100)] |
|||
public string Id { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
///// <summary>
|
|||
///// 物流变更时间
|
|||
///// </summary>
|
|||
//[Column(DbType = "datetime")]
|
|||
//public DateTime? ExpressChangeTime { get; set; }
|
|||
|
|||
///// <summary>
|
|||
///// 物流状态
|
|||
///// </summary>
|
|||
//[Column(StringLength = 100)]
|
|||
//public string ExpressState { get; set; }
|
|||
|
|||
/// <summary>
|
|||
/// 店铺订单Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 100)] |
|||
public string OrderId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购订单Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 100)] |
|||
public string PurchaseOrderId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购商品Id(spu)
|
|||
/// </summary>
|
|||
[Column(StringLength = 100)] |
|||
public string PurchaseProductId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购Sku
|
|||
/// </summary>
|
|||
[Column(StringLength = 100)] |
|||
public string PurchaseSkuId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 店铺Id
|
|||
/// </summary>
|
|||
public long? ShopId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 快递单
|
|||
/// </summary>
|
|||
[Column(StringLength = 100)] |
|||
public string WaybillNo { get; set; } |
|||
} |
|||
|
|||
} |
@ -0,0 +1,119 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 采购商表
|
|||
/// </summary>
|
|||
[Table(Name = "purchaser", DisableSyncStructure = true)] |
|||
public partial class Purchaser |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 采购商Id (1688 SellerUserId)
|
|||
/// </summary>
|
|||
[Column(StringLength = 20, IsPrimary = true, IsNullable = false)] |
|||
public string Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购商Id2 (1688 SellerLoginId)
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string Id2 { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 发货地(产地)
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string Location { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 经营模式 0贸易 1厂家
|
|||
/// </summary>
|
|||
[Column(DbType = "int", MapType = typeof(int))] |
|||
public Enums.ManagmentMode? ManagmentMode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 经营模式(文本)
|
|||
/// </summary>
|
|||
public string ManagmentModeText { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string MemberId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购商名称
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string Name { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购平台
|
|||
/// </summary>
|
|||
[Column(MapType = typeof(int?))] |
|||
public Enums.Platform? Platform { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 商家标签 (超级工厂/实力工厂/实力供应商),可空
|
|||
/// </summary>
|
|||
[Column(StringLength = 20)] |
|||
public string Tag { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 绑定SPU数
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? BindingSpuCount { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// 采购SPU数
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? PurchasedSpuCount { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// 绑定SKU数
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? BindingSkuCount { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// 采购SKU数
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? PurchasedSkuCount { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// 采购次数/采购订单数
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? PurchasedCount { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// 采购金额
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? PurchasedAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 上次采购时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? LastPurchasedTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 最近90天采购金额
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? Recent90dPurchasedAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 最近90天采购次数
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? Recent90dPurchasedCount { get; set; } = 0.00M; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,53 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 采购方案商品表
|
|||
/// </summary>
|
|||
[Table(Name = "purchaseschemeproduct", DisableSyncStructure = true)] |
|||
public partial class PurchaseSchemeProduct |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 采购商品和采购方案的关系Id
|
|||
/// </summary>
|
|||
[Column(IsPrimary = true)] |
|||
public long Id { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
[Column(StringLength = 50, IsNullable = false)] |
|||
public string ProductId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购商品Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 50, IsNullable = false)] |
|||
public string PurchaseProductId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购商品链接
|
|||
/// </summary>
|
|||
[Column(StringLength = 100)] |
|||
public string PurchaseUrl { get; set; } |
|||
|
|||
[Column(StringLength = 50, IsNullable = false)] |
|||
public string SkuId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Sku采购方案Id
|
|||
/// </summary>
|
|||
public long SkuPurchaseSchemeId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购商Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 20)] |
|||
public string PurchaserId { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,359 @@ |
|||
namespace BBWYB.Server.Model |
|||
{ |
|||
public class Enums |
|||
{ |
|||
/// <summary>
|
|||
/// 电商平台 淘宝 = 0,京东 = 1,阿里巴巴 = 2,拼多多 = 3,微信 = 4,拳探 = 10,抖音 = 11
|
|||
/// </summary>
|
|||
public enum Platform |
|||
{ |
|||
淘宝 = 0, |
|||
京东 = 1, |
|||
阿里巴巴 = 2, |
|||
拼多多 = 3, |
|||
微信 = 4, |
|||
拳探 = 10, |
|||
抖音 = 11 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 采购方式 线上采购 = 0,关联外部单 = 1,手动下单 = 2
|
|||
/// </summary>
|
|||
public enum PurchaseMethod |
|||
{ |
|||
线上采购 = 0, |
|||
关联外部单 = 1, |
|||
手动下单 = 2 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 采购单模式 批发 = 0,代发 = 1
|
|||
/// </summary>
|
|||
public enum PurchaseOrderMode |
|||
{ |
|||
批发 = 0, |
|||
代发 = 1 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 仓储类型
|
|||
/// </summary>
|
|||
public enum StorageType |
|||
{ |
|||
京仓 = 0, |
|||
云仓 = 1, |
|||
本地自发 = 2, |
|||
代发 = 3, |
|||
SD = 4 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 订单类型
|
|||
/// </summary>
|
|||
public enum OrderType |
|||
{ |
|||
#region JD订单类型
|
|||
SOP = 22, |
|||
LOC = 75, |
|||
FBP = 21 |
|||
#endregion
|
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 支付方式
|
|||
/// </summary>
|
|||
public enum PayType |
|||
{ |
|||
货到付款 = 1, |
|||
邮局汇款 = 2, |
|||
自提 = 3, |
|||
在线支付 = 4, |
|||
公司转账 = 5, |
|||
银行卡转账 = 6 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 订单状态
|
|||
/// <para>待付款 = 0</para>
|
|||
/// <para>等待采购 = 1, 部分采购 = 110</para>
|
|||
/// <para>待发货 = 2, 部分发货 = 120</para>
|
|||
/// <para>待收货 = 3, 部分收货 = 130</para>
|
|||
/// <para>已完成 = 4</para>
|
|||
/// <para>已取消 = 6</para>
|
|||
/// <para>待验收 = 140</para>
|
|||
/// <para>待核算 = 150</para>
|
|||
/// </summary>
|
|||
public enum OrderState |
|||
{ |
|||
待付款 = 0, |
|||
等待采购 = 1, |
|||
部分采购 = 110, |
|||
待发货 = 2, |
|||
部分发货 = 120, |
|||
待收货 = 3, |
|||
部分收货 = 130, |
|||
已完成 = 4, |
|||
已取消 = 6, |
|||
待验收 = 140, |
|||
待核算 = 150 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 采购单状态 待发货 = 0, 部分发货=1, 待收货 = 10, 部分收货=11, 已签收 = 20, 已取消 = 100
|
|||
/// </summary>
|
|||
public enum PurchaseOrderState |
|||
{ |
|||
待发货 = 0, |
|||
部分发货 = 1, |
|||
待收货 = 10, |
|||
部分收货 = 11, |
|||
已签收 = 20, |
|||
已取消 = 100 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 刷单类型
|
|||
/// </summary>
|
|||
public enum SDType |
|||
{ |
|||
自刷 = 0, |
|||
其他 = 1, |
|||
京礼金 = 2, |
|||
刷单组 = 3 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 订单同步任务状态
|
|||
/// </summary>
|
|||
public enum OrderSyncState |
|||
{ |
|||
Running = 0, |
|||
End = 1 |
|||
} |
|||
|
|||
public enum PayChannelType |
|||
{ |
|||
支付宝 = 0, |
|||
微信 = 1, |
|||
银行卡 = 2 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 服务单处理结果
|
|||
/// </summary>
|
|||
public enum ServiceResult |
|||
{ |
|||
退货 = 0, |
|||
换新 = 1, |
|||
原返 = 2, |
|||
线下换新 = 3, |
|||
维修 = 4, |
|||
商品补发 = 5, |
|||
仅退款 = 6, |
|||
SD退货 = 7 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 商品处理方式
|
|||
/// </summary>
|
|||
public enum ProductResult |
|||
{ |
|||
一件代发_退回厂家 = 0, |
|||
退回齐越仓 = 1, |
|||
退回京仓 = 2, |
|||
退回云仓 = 3, |
|||
客户无退货 = 4 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 商品情况
|
|||
/// </summary>
|
|||
public enum ProductHealth |
|||
{ |
|||
可二次销售 = 0, |
|||
残次品_无法二次销售 = 1, |
|||
厂家退货退款 = 2, |
|||
客户无退货 = 3, |
|||
破损 = 4 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 排序时间类型 ModifyTime = 0, StartTime = 1
|
|||
/// </summary>
|
|||
public enum SortTimeType |
|||
{ |
|||
ModifyTime = 0, StartTime = 1 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 支付账单类型
|
|||
/// </summary>
|
|||
public enum PayBillType |
|||
{ |
|||
支付宝 = 0, |
|||
微信 = 1, |
|||
银行卡 = 2 |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 资金类型
|
|||
/// </summary>
|
|||
public enum AuditCapitalType |
|||
{ |
|||
当月商品采购 = 0, |
|||
当月商品退款 = 1, |
|||
上月商品采购 = 2, |
|||
上月商品退款 = 3, |
|||
批量采购商品 = 4, |
|||
采购运费 = 5, |
|||
入仓运费 = 6, |
|||
售后成本 = 7, |
|||
发票点数 = 8, |
|||
快递单号 = 9, |
|||
诚e赊还款 = 10, |
|||
空单号 = 11, |
|||
购买刷单号 = 12, |
|||
手机费 = 13, |
|||
质检报告 = 14, |
|||
备用金转入 = 15, |
|||
平台补贴 = 16, |
|||
快递赔付 = 17, |
|||
自定义 = 18, |
|||
备用金充值 = 19 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 京东仓库类型 1商家仓 2京东仓
|
|||
/// </summary>
|
|||
public enum StockType |
|||
{ |
|||
商家仓 = 1, 京仓 = 2 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 仓库状态 0暂停,1使用
|
|||
/// </summary>
|
|||
public enum StockStatus |
|||
{ |
|||
暂停 = 0, 使用 = 1 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// SKU库存周期 暂无周期=0,增长期=1,稳定期=2,衰退期=3
|
|||
/// </summary>
|
|||
public enum SkuStockNumCycleType |
|||
{ |
|||
暂无周期 = 0, |
|||
增长期 = 1, |
|||
稳定期 = 2, |
|||
衰退期 = 3 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 司南周期 暂无周期 = -1,成长加速期 = 0,成熟利润期 = 1,稳定日销期 = 2,策马奔腾期 = 3
|
|||
/// </summary>
|
|||
public enum SiNanCycleType |
|||
{ |
|||
暂无周期 = -1, |
|||
成长加速期 = 0, |
|||
成熟利润期 = 1, |
|||
稳定日销期 = 2, |
|||
策马奔腾期 = 3 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 促销任务状态 等待 = 0,进行中 = 1,已完成 = 2, 已停止 = 3
|
|||
/// </summary>
|
|||
public enum PromitionTaskStatus |
|||
{ |
|||
等待 = 0, |
|||
进行中 = 1, |
|||
已完成 = 2, |
|||
已停止 = 3 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// AppKey类型 全类型 = 0, 订单管理 = 1, 商品管理 = 2
|
|||
/// </summary>
|
|||
public enum AppKeyType |
|||
{ |
|||
全类型 = 0, 订单管理 = 1, 商品管理 = 2 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 采购商品API模式 Spider = 0,OneBound = 1
|
|||
/// </summary>
|
|||
public enum PurchaseProductAPIMode |
|||
{ |
|||
Spider = 0, |
|||
OneBound = 1 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 打包配置状态 待配置 = 0,已配置 = 1,需修改 = 2
|
|||
/// </summary>
|
|||
public enum PackConfigState |
|||
{ |
|||
待配置 = 0, |
|||
已配置 = 1, |
|||
需修改 = 2 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 入仓类型 (发回齐越 = 0, 厂商代发入仓 = 1,其他仓不包装 = 2)
|
|||
/// </summary>
|
|||
public enum IntoStoreType |
|||
{ |
|||
发回齐越 = 0, 厂商代发入仓 = 1, 其他仓不包装 = 2 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 限时任务类型 采购任务 = 0, 合格证拟定任务 = 10, 合格证补充任务 = 11, 待核算任务 = 20, 待议价任务 = 30
|
|||
/// </summary>
|
|||
public enum TimeLimitTaskType |
|||
{ |
|||
采购任务 = 0, 合格证拟定任务 = 10, 合格证补充任务 = 11, 待核算任务 = 20, 待议价任务 = 30 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 平价状态 未平价=0 已平价=1 部分平价=2
|
|||
/// </summary>
|
|||
public enum AutoEditOrderPriceType |
|||
{ |
|||
未平价 = 0, 已平价 = 1, 部分平价 = 2 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 触发优化原因 首次采购 = 0, 首次优化 = 1, 再次优化 = 2
|
|||
/// </summary>
|
|||
public enum TriggerOptimizationReason |
|||
{ |
|||
首次采购 = 0, 首次优化 = 1, 再次优化 = 2 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 厂家经营模式 贸易 = 0, 厂家 = 1
|
|||
/// </summary>
|
|||
public enum ManagmentMode |
|||
{ |
|||
贸易 = 0, 厂家 = 1 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 厂家扩展信息类型 主营类目 = 0, 标签 = 1
|
|||
/// </summary>
|
|||
public enum PurchaserBasicInfoType |
|||
{ |
|||
主营类目 = 0, 标签 = 1 |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 比较运算符 大于 = 0, 小于 = 1, 等于 = 2, 介于 = 3
|
|||
/// </summary>
|
|||
public enum ComparisonOperator |
|||
{ |
|||
大于 = 0, 小于 = 1, 等于 = 2, 介于 = 3 |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,33 @@ |
|||
using BBWYB.Server.Business; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace BBWYB.Server.API.Controllers |
|||
{ |
|||
|
|||
public class AggregationPurchaseSchemeController : BaseApiController |
|||
{ |
|||
private AggregionPurchaseSchemeBusiness aggregionPurchaseSchemeBusiness; |
|||
public AggregationPurchaseSchemeController(IHttpContextAccessor httpContextAccessor, AggregionPurchaseSchemeBusiness aggregionPurchaseSchemeBusiness) : base(httpContextAccessor) |
|||
{ |
|||
this.aggregionPurchaseSchemeBusiness = aggregionPurchaseSchemeBusiness; |
|||
} |
|||
|
|||
[HttpPost] |
|||
public void AutoAggregion() |
|||
{ |
|||
aggregionPurchaseSchemeBusiness.AutoAggregion(); |
|||
} |
|||
|
|||
[HttpPost] |
|||
public void AggregionBySchemeIdList([FromBody]IList<long> schemeIdList) |
|||
{ |
|||
aggregionPurchaseSchemeBusiness.AggregionBySchemeIdList(schemeIdList); |
|||
} |
|||
|
|||
[HttpPost] |
|||
public void AggregionAllScheme() |
|||
{ |
|||
aggregionPurchaseSchemeBusiness.AggregionAllScheme(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,44 @@ |
|||
using BBWYB.Server.Business; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace BBWYB.Server.API.Controllers |
|||
{ |
|||
|
|||
public class AggregationPurchaserController : BaseApiController |
|||
{ |
|||
private AggregionPurchaserBusiness aggregionPurchaserBusiness; |
|||
|
|||
public AggregationPurchaserController(IHttpContextAccessor httpContextAccessor, AggregionPurchaserBusiness aggregionPurchaserBusiness) : base(httpContextAccessor) |
|||
{ |
|||
this.aggregionPurchaserBusiness = aggregionPurchaserBusiness; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 采购商聚合
|
|||
/// </summary>
|
|||
[HttpPost] |
|||
public void AutoAggregion() |
|||
{ |
|||
aggregionPurchaserBusiness.AutoAggregion(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 根据指定采购商Id聚合
|
|||
/// </summary>
|
|||
/// <param name="purchaserIdList"></param>
|
|||
[HttpPost] |
|||
public void AggregionByPurchaserIdList([FromBody] IList<string> purchaserIdList) |
|||
{ |
|||
aggregionPurchaserBusiness.AggregionByPurchaserIdList(purchaserIdList); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 聚合所有采购商
|
|||
/// </summary>
|
|||
[HttpPost] |
|||
public void AggregionAllPurchaser() |
|||
{ |
|||
aggregionPurchaserBusiness.AggregionAllPurchaser(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,44 @@ |
|||
using BBWYB.Server.Business; |
|||
using BBWYB.Server.Business.Sync; |
|||
using BBWYB.Server.Model; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace BBWYB.Server.API.Controllers |
|||
{ |
|||
public class ProductSyncController : BaseApiController |
|||
{ |
|||
private ProductSyncBusiness productSyncBusiness; |
|||
public ProductSyncController(IHttpContextAccessor httpContextAccessor, ProductSyncBusiness productSyncBusiness) : base(httpContextAccessor) |
|||
{ |
|||
this.productSyncBusiness = productSyncBusiness; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 全店同步产品
|
|||
/// </summary>
|
|||
[HttpPost] |
|||
public void SyncAllShopAllProduct() |
|||
{ |
|||
productSyncBusiness.SyncAllShopAllProduct(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 同步所有店铺最近变化产品
|
|||
/// </summary>
|
|||
[HttpPost] |
|||
public void SyncAllShopUpdateProduct() |
|||
{ |
|||
productSyncBusiness.SyncAllShopUpdateProduct(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 同步指定店铺最近变化产品
|
|||
/// </summary>
|
|||
/// <param name="shopId"></param>
|
|||
[HttpPost("{shopId}")] |
|||
public void SyncOneShopUpdateProduct([FromRoute] long shopId) |
|||
{ |
|||
productSyncBusiness.SyncOneShopUpdateProduct(shopId); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,74 @@ |
|||
using BBWYB.Server.Business; |
|||
using BBWYB.Server.Model.Db; |
|||
using BBWYB.Server.Model.Dto; |
|||
using Microsoft.AspNetCore.Authentication.JwtBearer; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace BBWYB.Server.API.Controllers |
|||
{ |
|||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] |
|||
public class PurchaserController : BaseApiController |
|||
{ |
|||
private PurchaserBusiness purchaserBusiness; |
|||
|
|||
public PurchaserController(IHttpContextAccessor httpContextAccessor, PurchaserBusiness purchaserBusiness) : base(httpContextAccessor) |
|||
{ |
|||
this.purchaserBusiness = purchaserBusiness; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 根据关键词搜索采购商名称列表
|
|||
/// </summary>
|
|||
/// <param name="keywords"></param>
|
|||
/// <returns></returns>
|
|||
[HttpGet("{keywords}")] |
|||
public ListResponse<string> QueryPurchaserNameList([FromRoute] string keywords) |
|||
{ |
|||
return purchaserBusiness.QueryPurchaserNameList(keywords); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 根据关键词搜索采购商产地列表
|
|||
/// </summary>
|
|||
/// <param name="keywords"></param>
|
|||
/// <returns></returns>
|
|||
[HttpGet("{keywords}")] |
|||
public ListResponse<string> QueryPurchaserLocationList([FromRoute] string keywords) |
|||
{ |
|||
return purchaserBusiness.QueryPurchaserLocationList(keywords); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 查询采购商列表
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost] |
|||
public ListResponse<PurchaserResponse> QueryPurchaserList([FromBody] QueryPurchaserRequest request) |
|||
{ |
|||
return purchaserBusiness.QueryPurchaserList(request); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 查询供应商主营类目或标签列表
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost] |
|||
public ListResponse<PurchaserExtendedInfoResponse> QueryPurchaserCategoryList([FromBody] QueryPurchaserExtendedRequest request) |
|||
{ |
|||
return purchaserBusiness.QueryPurchaserCategoryList(request); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 修改供应商扩展信息
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
[HttpPost] |
|||
public void EditPurchaserExtendedInfo([FromBody] EditPurchaserExtendedInfoRequest request) |
|||
{ |
|||
purchaserBusiness.EditPurchaserExtendedInfo(request); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,84 @@ |
|||
using BBWYB.Server.Business; |
|||
using BBWYB.Server.Model.Dto; |
|||
using Microsoft.AspNetCore.Authentication.JwtBearer; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
|
|||
namespace BBWYB.Server.API.Controllers |
|||
{ |
|||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] |
|||
public class SkuOptimizationController : BaseApiController |
|||
{ |
|||
private OptimizationBusiness optimizationBusiness; |
|||
|
|||
public SkuOptimizationController(IHttpContextAccessor httpContextAccessor, OptimizationBusiness optimizationBusiness) : base(httpContextAccessor) |
|||
{ |
|||
this.optimizationBusiness = optimizationBusiness; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 良库预警通知
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
[HttpPost] |
|||
[AllowAnonymous] |
|||
public void LKInventoryAlertNotification([FromBody] BatchLKInventoryAlertRequest request) |
|||
{ |
|||
optimizationBusiness.LKInventoryAlertNotification(request); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 完成待优化任务(当所有议价组的子任务优化完成, 所属待优化任务才会完成)
|
|||
/// </summary>
|
|||
/// <param name="taskId">待优化任务Id</param>
|
|||
[HttpPost("{taskId}")] |
|||
public void CompleteOptimization([FromRoute] long taskId) |
|||
{ |
|||
var userId = GetUserId(); |
|||
optimizationBusiness.CompleteOptimization(taskId, userId); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 更新报价
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
[HttpPost] |
|||
public void BatchUpdateCompetitiveTenderQuotation([FromBody] BatchUpdateCompetitiveTenderQuotationRequest request) |
|||
{ |
|||
optimizationBusiness.BatchUpdateCompetitiveTenderQuotation(request, GetUserId()); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 查询待议价任务列表
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost] |
|||
public ListResponse<SpuOptimizationTaskResponse> GetNoCompletionSkuOptimizationTask([FromBody] QueryNoCompletionOptimizationTaskRequest request) |
|||
{ |
|||
var userId = GetUserId(); |
|||
return optimizationBusiness.GetNoCompletionSkuOptimizationTask(request, userId); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 删除采购方案分组(包括采购方案和竞标关系)
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
[HttpPost] |
|||
public void DeleteSchemeGroup(DeleteSchemeGroupFromSpuOptimizationTaskRequest request) |
|||
{ |
|||
var userId = GetUserId(); |
|||
optimizationBusiness.DeleteSchemeGroup(request, userId); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取未完成spu优化任务数量
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
[HttpGet] |
|||
public long GetNoCompletedSpuOptimizationTaskCount() |
|||
{ |
|||
return optimizationBusiness.GetNoCompletedSpuOptimizationTaskCount(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,147 @@ |
|||
using BBWYB.Common.Log; |
|||
using BBWYB.Common.Models; |
|||
using BBWYB.Server.Model; |
|||
using BBWYB.Server.Model.Db; |
|||
using FreeSql; |
|||
using Yitter.IdGenerator; |
|||
|
|||
namespace BBWYB.Server.Business |
|||
{ |
|||
public class AggregionPurchaseSchemeBusiness : BaseBusiness, IDenpendency |
|||
{ |
|||
private TaskSchedulerManager taskSchedulerManager; |
|||
public AggregionPurchaseSchemeBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager) : base(fsql, nLogManager, idGenerator) |
|||
{ |
|||
this.taskSchedulerManager = taskSchedulerManager; |
|||
} |
|||
|
|||
public void AutoAggregion() |
|||
{ |
|||
var startTime = DateTime.Now.Date.AddDays(-2); |
|||
//查询最近有采购的采购方案
|
|||
var schemeIdList = fsql.Select<OrderPurchaseInfo, OrderPurchaseRelationInfo>() |
|||
.InnerJoin((opi, opri) => opi.OrderId == opri.OrderId && |
|||
opi.PurchaseOrderId == opri.PurchaseOrderId) |
|||
.Where((opi, opri) => opi.IsEnabled == true && |
|||
opi.UpdateTime >= startTime && |
|||
opri.SchemeId != null) |
|||
.Distinct().ToList((opi, opri) => opri.SchemeId.Value); |
|||
Task.Factory.StartNew(() => AggregionByGroup(schemeIdList), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.AggregationPurchaserTaskScheduler); |
|||
} |
|||
|
|||
public void AggregionBySchemeIdList(IList<long> schemeIdList) |
|||
{ |
|||
Task.Factory.StartNew(() => AggregionByGroup(schemeIdList), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.AggregationPurchaserTaskScheduler); |
|||
} |
|||
|
|||
public void AggregionAllScheme() |
|||
{ |
|||
var schemeIdList = fsql.Select<PurchaseScheme>().ToList(ps => ps.Id); |
|||
Task.Factory.StartNew(() => AggregionByGroup(schemeIdList), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.AggregationPurchaserTaskScheduler); |
|||
} |
|||
|
|||
private void AggregionByGroup(IList<long> schemeIdList) |
|||
{ |
|||
var tempSchemeIdList = new List<long>(); |
|||
for (var i = 0; i < schemeIdList.Count(); i++) |
|||
{ |
|||
tempSchemeIdList.Add(schemeIdList[i]); |
|||
if (i != 0 && i % 30 == 0) |
|||
{ |
|||
Console.WriteLine($"聚合{i + 1}/{schemeIdList.Count()}"); |
|||
Aggregion(tempSchemeIdList); |
|||
tempSchemeIdList.Clear(); |
|||
Thread.Sleep(2000); |
|||
} |
|||
} |
|||
if (tempSchemeIdList.Count() > 0) |
|||
{ |
|||
Console.WriteLine($"最后聚合"); |
|||
Aggregion(tempSchemeIdList); |
|||
tempSchemeIdList.Clear(); |
|||
} |
|||
} |
|||
|
|||
private void Aggregion(IList<long> schemeIdList) |
|||
{ |
|||
var pssIdList = fsql.Select<PurchaseSchemeProductSku>() |
|||
.Where(pss => schemeIdList.Contains(pss.SkuPurchaseSchemeId)) |
|||
.Distinct() |
|||
.ToList(pss => pss.PurchaseSkuId); |
|||
|
|||
var dbStatisticList = fsql.Select<PurchaseSchemeProductSkuStatistic>(pssIdList).ToList(); |
|||
|
|||
List<PurchaseSchemeProductSkuStatistic> insertStatisticList = new List<PurchaseSchemeProductSkuStatistic>(); |
|||
List<IUpdate<PurchaseSchemeProductSkuStatistic>> updateStatisticList = new List<IUpdate<PurchaseSchemeProductSkuStatistic>>(); |
|||
|
|||
#region 采购件数/采购金额
|
|||
var aggregationItemCountAndAmountList = fsql.Select<OrderPurchaseInfo, OrderPurchaseSkuInfo>() |
|||
.InnerJoin((opi, opsi) => opi.OrderId == opsi.OrderId && |
|||
opi.PurchaseOrderId == opsi.PurchaseOrderId) |
|||
.Where((opi, opsi) => opi.IsEnabled == true && pssIdList.Contains(opsi.PurchaseSkuId)) |
|||
.GroupBy((opi, opsi) => opsi.PurchaseSkuId) |
|||
.ToList(g => new |
|||
{ |
|||
PurchaseSkuId = g.Key, |
|||
PurchasedItemCount = g.Sum(g.Value.Item2.PurchasedItemCount), |
|||
PurchasedAmount = g.Sum(g.Value.Item2.PurchasedAmount) |
|||
}); |
|||
#endregion
|
|||
|
|||
#region 最近采购单价
|
|||
|
|||
var recentPurchaseSkuList = fsql.Select<OrderPurchaseInfo, OrderPurchaseSkuInfo>() |
|||
.InnerJoin((opi, opsi) => opi.OrderId == opsi.OrderId && |
|||
opi.PurchaseOrderId == opsi.PurchaseOrderId) |
|||
.Where((opi, opsi) => opi.IsEnabled == true && pssIdList.Contains(opsi.PurchaseSkuId)) |
|||
.GroupBy((opi, opsi) => opsi.PurchaseSkuId) |
|||
.WithTempQuery(g => new { MaxId = g.Max(g.Value.Item2.Id) }) |
|||
.From<OrderPurchaseSkuInfo>() |
|||
.InnerJoin((opsi, opsi2) => opsi.MaxId == opsi2.Id) |
|||
.ToList((opsi, opsi2) => opsi2); |
|||
#endregion
|
|||
|
|||
foreach (var purchaseSkuId in pssIdList) |
|||
{ |
|||
var statistic = dbStatisticList.FirstOrDefault(x => x.PurchaseSkuId == purchaseSkuId); |
|||
var aggregation = aggregationItemCountAndAmountList.FirstOrDefault(x => x.PurchaseSkuId == purchaseSkuId); |
|||
var recent = recentPurchaseSkuList.FirstOrDefault(x => x.PurchaseSkuId == purchaseSkuId); |
|||
if (statistic == null) |
|||
{ |
|||
insertStatisticList.Add(new PurchaseSchemeProductSkuStatistic() |
|||
{ |
|||
PurchaseSkuId = purchaseSkuId, |
|||
CreateTime = DateTime.Now, |
|||
PurchasedAmount = aggregation?.PurchasedAmount ?? 0M, |
|||
PurchasedItemCount = Convert.ToInt32(aggregation?.PurchasedItemCount ?? 0M), |
|||
LastPurchasedPrice = recent?.PurchasedPrice, |
|||
LastPurchasedTime = recent?.CreateTime |
|||
}); |
|||
} |
|||
else |
|||
{ |
|||
if (aggregation != null || recent != null) |
|||
{ |
|||
var update = fsql.Update<PurchaseSchemeProductSkuStatistic>(purchaseSkuId) |
|||
.SetIf(aggregation != null, x => x.PurchasedAmount, aggregation?.PurchasedAmount ?? 0M) |
|||
.SetIf(aggregation != null, x => x.PurchasedItemCount, Convert.ToInt32(aggregation?.PurchasedItemCount ?? 0)) |
|||
.SetIf(recent != null, x => x.LastPurchasedPrice, recent.PurchasedPrice) |
|||
.SetIf(recent != null, x => x.LastPurchasedTime, recent.CreateTime); |
|||
updateStatisticList.Add(update); |
|||
} |
|||
} |
|||
} |
|||
|
|||
fsql.Transaction(() => |
|||
{ |
|||
if (insertStatisticList.Count() > 0) |
|||
fsql.Insert(insertStatisticList).ExecuteAffrows(); |
|||
if (updateStatisticList.Count() > 0) |
|||
{ |
|||
foreach (var update in updateStatisticList) |
|||
update.ExecuteAffrows(); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,266 @@ |
|||
using BBWYB.Common.Log; |
|||
using BBWYB.Common.Models; |
|||
using BBWYB.Server.Model; |
|||
using BBWYB.Server.Model.Db; |
|||
using FreeSql; |
|||
using Yitter.IdGenerator; |
|||
|
|||
namespace BBWYB.Server.Business |
|||
{ |
|||
public class AggregionPurchaserBusiness : BaseBusiness, IDenpendency |
|||
{ |
|||
private TaskSchedulerManager taskSchedulerManager; |
|||
public AggregionPurchaserBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, TaskSchedulerManager taskSchedulerManager) : base(fsql, nLogManager, idGenerator) |
|||
{ |
|||
this.taskSchedulerManager = taskSchedulerManager; |
|||
} |
|||
|
|||
public void AutoAggregion() |
|||
{ |
|||
var startTime = DateTime.Now.Date.AddDays(-90); |
|||
//查询最近有采购的采购商列表
|
|||
var purchaserIdList = fsql.Select<OrderPurchaseInfo, Order>() |
|||
.InnerJoin((opi, o) => opi.OrderId == o.Id) |
|||
.Where((opi, o) => opi.IsEnabled == true && |
|||
o.OrderState != Enums.OrderState.已取消 && |
|||
o.StartTime >= startTime && |
|||
!string.IsNullOrEmpty(opi.PurchaserId)) |
|||
.Distinct() |
|||
.ToList((opi, o) => opi.PurchaserId); |
|||
Task.Factory.StartNew(() => AggregionByGroup(purchaserIdList), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.AggregationPurchaserTaskScheduler); |
|||
} |
|||
|
|||
public void AggregionByPurchaserIdList(IList<string> purchaserIdList) |
|||
{ |
|||
Task.Factory.StartNew(() => AggregionByGroup(purchaserIdList), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.AggregationPurchaserTaskScheduler); |
|||
} |
|||
|
|||
public void AggregionAllPurchaser() |
|||
{ |
|||
var purchaserIdList = fsql.Select<Purchaser>().ToList(p => p.Id); |
|||
Task.Factory.StartNew(() => AggregionByGroup(purchaserIdList), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.AggregationPurchaserTaskScheduler); |
|||
} |
|||
|
|||
private void AggregionByGroup(IList<string> purchaserIdList) |
|||
{ |
|||
var tempPurchaserIdList = new List<string>(); |
|||
for (var i = 0; i < purchaserIdList.Count(); i++) |
|||
{ |
|||
tempPurchaserIdList.Add(purchaserIdList[i]); |
|||
if (i != 0 && i % 30 == 0) |
|||
{ |
|||
Console.WriteLine($"聚合{i + 1}/{purchaserIdList.Count()}"); |
|||
Aggregion(tempPurchaserIdList); |
|||
tempPurchaserIdList.Clear(); |
|||
Thread.Sleep(2000); |
|||
} |
|||
} |
|||
if (tempPurchaserIdList.Count() > 0) |
|||
{ |
|||
Console.WriteLine($"最后聚合"); |
|||
Aggregion(tempPurchaserIdList); |
|||
tempPurchaserIdList.Clear(); |
|||
} |
|||
} |
|||
|
|||
private void Aggregion(IList<string> purchaserIdList) |
|||
{ |
|||
List<IUpdate<Purchaser>> updatePurchaserList = new List<IUpdate<Purchaser>>(); |
|||
List<long> deletePeiList = new List<long>(); |
|||
List<Purchaser_ExtendedInfo_Relation> insertPeiList = new List<Purchaser_ExtendedInfo_Relation>(); |
|||
|
|||
List<Purchaser_ExtendedInfo_Relation> dbPeiList = fsql.Select<Purchaser_ExtendedInfo_Relation>() |
|||
.Where(pei => pei.ExtendedType == Enums.PurchaserBasicInfoType.主营类目 && |
|||
purchaserIdList.Contains(pei.PurchaserId)) |
|||
.ToList(); |
|||
|
|||
var pspList = fsql.Select<PurchaseSchemeProduct, Product>() |
|||
.InnerJoin((psp, p) => psp.ProductId == p.Id) |
|||
.Where((psp, p) => p.CategoryId != null && purchaserIdList.Contains(psp.PurchaserId)) |
|||
.ToList((psp, p) => new |
|||
{ |
|||
psp.PurchaserId, |
|||
psp.ProductId, |
|||
p.CategoryId |
|||
}); |
|||
|
|||
#region 查询SPU绑定数/SKU绑定数
|
|||
var bindList = fsql.Select<PurchaseSchemeProduct, PurchaseScheme>() |
|||
.InnerJoin((psp, psc) => psp.SkuPurchaseSchemeId == psc.Id) |
|||
.Where((psp, psc) => purchaserIdList.Contains(psp.PurchaserId)) |
|||
.GroupBy((psp, psc) => new { psp.PurchaserId, psp.ProductId, psp.SkuId }) |
|||
.ToList(g => new |
|||
{ |
|||
g.Key.PurchaserId, |
|||
g.Key.ProductId, |
|||
g.Key.SkuId |
|||
}); |
|||
#endregion
|
|||
|
|||
#region 查询SPU采购数/SKU采购数
|
|||
var purchasedList = fsql.Select<ProductSku, OrderPurchaseRelationInfo, OrderPurchaseInfo, Order>() |
|||
.InnerJoin((ps, ori, opi, o) => ps.Id == ori.BelongSkuId) |
|||
.InnerJoin((ps, ori, opi, o) => ori.PurchaseOrderId == opi.PurchaseOrderId && |
|||
ori.OrderId == opi.OrderId) |
|||
.InnerJoin((ps, ori, opi, o) => opi.OrderId == o.Id) |
|||
.Where((ps, ori, opi, o) => o.OrderState != Enums.OrderState.已取消 && |
|||
opi.IsEnabled == true && |
|||
purchaserIdList.Contains(opi.PurchaserId)) |
|||
.GroupBy((ps, ori, opi, o) => new { opi.PurchaserId, ps.Id, ps.ProductId }) |
|||
.ToList(g => new |
|||
{ |
|||
g.Key.PurchaserId, |
|||
g.Key.ProductId, |
|||
SkuId = g.Key.Id |
|||
}); |
|||
|
|||
#endregion
|
|||
|
|||
#region 查询订单数/最近采购时间
|
|||
var poList = fsql.Select<OrderPurchaseInfo, Order>() |
|||
.InnerJoin((opi, o) => opi.OrderId == o.Id) |
|||
.Where((opi, o) => opi.IsEnabled == true && |
|||
o.OrderState != Enums.OrderState.已取消 && |
|||
purchaserIdList.Contains(opi.PurchaserId)) |
|||
.GroupBy((opi, o) => opi.PurchaserId) |
|||
.ToList(g => new |
|||
{ |
|||
PurchaserId = g.Key, |
|||
Count = g.Count(), |
|||
MaxPurchaseTime = g.Max(g.Value.Item1.CreateTime) |
|||
}); |
|||
|
|||
#endregion
|
|||
|
|||
#region 查询最近90天采购数量
|
|||
var recent90d = DateTime.Now.Date.AddDays(-90); |
|||
var recent90dPurchasedCountList = fsql.Select<OrderPurchaseInfo, Order>() |
|||
.InnerJoin((opi, o) => opi.OrderId == o.Id) |
|||
.Where((opi, o) => o.OrderState != Enums.OrderState.已取消 && |
|||
opi.IsEnabled == true && |
|||
opi.CreateTime >= recent90d && |
|||
purchaserIdList.Contains(opi.PurchaserId)) |
|||
.GroupBy((opi, o) => opi.PurchaserId) |
|||
.ToList(g => new |
|||
{ |
|||
PurchaserId = g.Key, |
|||
Count = g.Count(), |
|||
}); |
|||
#endregion
|
|||
|
|||
#region 查询采购金额
|
|||
var purchasedAmountList = fsql.Select<OrderCostDetail, Order, OrderPurchaseInfo>() |
|||
.InnerJoin((ocd, o, opi) => ocd.OrderId == o.Id) |
|||
.InnerJoin((ocd, o, opi) => o.Id == opi.OrderId) |
|||
.Where((ocd, o, opi) => o.OrderState != Enums.OrderState.已取消 && |
|||
ocd.IsEnabled == true && |
|||
opi.IsEnabled == true && |
|||
purchaserIdList.Contains(opi.PurchaserId)) |
|||
.GroupBy((ocd, o, opi) => opi.PurchaserId) |
|||
.ToList(g => new |
|||
{ |
|||
PurchaserId = g.Key, |
|||
PurchasedAmount = g.Sum(g.Value.Item1.SkuAmount + g.Value.Item1.PurchaseFreight) |
|||
}); |
|||
#endregion
|
|||
|
|||
#region 查询最近90天采购金额
|
|||
var recent90dPurchasedAmountList = fsql.Select<OrderCostDetail, Order, OrderPurchaseInfo>() |
|||
.InnerJoin((ocd, o, opi) => ocd.OrderId == o.Id) |
|||
.InnerJoin((ocd, o, opi) => o.Id == opi.OrderId) |
|||
.Where((ocd, o, opi) => o.OrderState != Enums.OrderState.已取消 && |
|||
ocd.IsEnabled == true && |
|||
opi.IsEnabled == true && |
|||
opi.CreateTime >= recent90d && |
|||
purchaserIdList.Contains(opi.PurchaserId)) |
|||
.GroupBy((ocd, o, opi) => opi.PurchaserId) |
|||
.ToList(g => new |
|||
{ |
|||
PurchaserId = g.Key, |
|||
PurchasedAmount = g.Sum(g.Value.Item1.SkuAmount + g.Value.Item1.PurchaseFreight) |
|||
}); |
|||
#endregion
|
|||
|
|||
foreach (var purchaserId in purchaserIdList) |
|||
{ |
|||
#region SPU绑定数/SKU绑定数
|
|||
var currentBindList = bindList.Where(x => x.PurchaserId == purchaserId).ToList(); |
|||
var bindingSpuCount = currentBindList.Select(x => x.ProductId).Distinct().Count(); |
|||
var bindingSkuCount = currentBindList.Select(x => x.SkuId).Count(); |
|||
#endregion
|
|||
|
|||
#region SPU采购数/SKU采购数
|
|||
var currentPurchasedList = purchasedList.Where(x => x.PurchaserId == purchaserId).ToList(); |
|||
var purchasedSpuCount = currentPurchasedList.Select(x => x.ProductId).Distinct().Count(); |
|||
var purchasedSkuCount = currentPurchasedList.Select(x => x.SkuId).Count(); |
|||
#endregion
|
|||
|
|||
#region 订单数/最近采购时间
|
|||
var purchasedCountAndTime = poList.FirstOrDefault(x => x.PurchaserId == purchaserId); |
|||
var purchasedCount = purchasedCountAndTime?.Count ?? 0; |
|||
var lastPurchasedTime = purchasedCountAndTime?.MaxPurchaseTime; |
|||
#endregion
|
|||
|
|||
#region 采购金额
|
|||
var purchasedAmount = purchasedAmountList.FirstOrDefault(x => x.PurchaserId == purchaserId)?.PurchasedAmount ?? 0; |
|||
#endregion
|
|||
|
|||
#region 最近90天采购金额
|
|||
var recent90dPurchasedAmount = recent90dPurchasedAmountList.FirstOrDefault(x => x.PurchaserId == purchaserId)?.PurchasedAmount ?? 0; |
|||
#endregion
|
|||
|
|||
#region 最近90天采购数量
|
|||
var recent90dPurchasedCount = recent90dPurchasedCountList.FirstOrDefault(x => x.PurchaserId == purchaserId)?.Count ?? 0; |
|||
#endregion
|
|||
|
|||
#region 主营类目
|
|||
{ |
|||
var currentDbPeiList = dbPeiList.Where(pei => pei.PurchaserId == purchaserId).ToList(); |
|||
var currentDbPspList = pspList.Where(psp => psp.PurchaserId == purchaserId).ToList(); |
|||
|
|||
var currentDeletePeiList = currentDbPeiList.Where(pei => !currentDbPspList.Any(psp => psp.PurchaserId == pei.PurchaserId && |
|||
psp.CategoryId == pei.ExtendedInfoId)) |
|||
.Select(pei => pei.Id).ToList(); |
|||
if (currentDeletePeiList.Count() > 0) |
|||
deletePeiList.AddRange(currentDeletePeiList); |
|||
|
|||
var currentInsertPeiList = currentDbPspList.Where(psp => !currentDbPeiList.Any(pei => pei.PurchaserId == psp.PurchaserId && |
|||
pei.ExtendedInfoId == psp.CategoryId)) |
|||
.GroupBy(psp => psp.CategoryId) |
|||
.Select(g => new Purchaser_ExtendedInfo_Relation() |
|||
{ |
|||
Id = idGenerator.NewLong(), |
|||
ExtendedInfoId = g.Key, |
|||
ExtendedType = Enums.PurchaserBasicInfoType.主营类目, |
|||
PurchaserId = purchaserId |
|||
}).ToList(); |
|||
if (currentInsertPeiList.Count() > 0) |
|||
insertPeiList.AddRange(currentInsertPeiList); |
|||
} |
|||
#endregion
|
|||
|
|||
var update = fsql.Update<Purchaser>(purchaserId) |
|||
.Set(p => p.BindingSpuCount, bindingSpuCount) |
|||
.Set(p => p.BindingSkuCount, bindingSkuCount) |
|||
.Set(p => p.PurchasedSpuCount, purchasedSpuCount) |
|||
.Set(p => p.PurchasedSkuCount, purchasedSkuCount) |
|||
.Set(p => p.PurchasedCount, purchasedCount) |
|||
.Set(p => p.PurchasedAmount, purchasedAmount) |
|||
.Set(p => p.LastPurchasedTime, lastPurchasedTime) |
|||
.Set(p => p.Recent90dPurchasedAmount, recent90dPurchasedAmount) |
|||
.Set(p => p.Recent90dPurchasedCount, recent90dPurchasedCount); |
|||
updatePurchaserList.Add(update); |
|||
} |
|||
|
|||
fsql.Transaction(() => |
|||
{ |
|||
foreach (var update in updatePurchaserList) |
|||
update.ExecuteAffrows(); |
|||
if (deletePeiList.Count() > 0) |
|||
fsql.Delete<Purchaser_ExtendedInfo_Relation>(deletePeiList).ExecuteAffrows(); |
|||
if (insertPeiList.Count() > 0) |
|||
fsql.Insert(insertPeiList).ExecuteAffrows(); |
|||
}); |
|||
} |
|||
} |
|||
} |
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,263 @@ |
|||
using BBWYB.Common.Log; |
|||
using BBWYB.Common.Models; |
|||
using BBWYB.Server.Model; |
|||
using BBWYB.Server.Model.Db; |
|||
using BBWYB.Server.Model.Dto; |
|||
using FreeSql; |
|||
using Yitter.IdGenerator; |
|||
|
|||
namespace BBWYB.Server.Business |
|||
{ |
|||
public class PurchaserBusiness : BaseBusiness, IDenpendency |
|||
{ |
|||
private FreeSqlMultiDBManager _freeSqlMultiDBManager; |
|||
|
|||
public PurchaserBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, FreeSqlMultiDBManager freeSqlMultiDBManager) : base(fsql, nLogManager, idGenerator) |
|||
{ |
|||
this._freeSqlMultiDBManager = freeSqlMultiDBManager; |
|||
} |
|||
|
|||
public ListResponse<string> QueryPurchaserNameList(string keywords) |
|||
{ |
|||
if (string.IsNullOrEmpty(keywords)) |
|||
throw new BusinessException("关键字不能为空"); |
|||
var list = fsql.Select<Purchaser>().Where(p => p.Name.Contains(keywords)).Distinct().ToList(x => x.Name); |
|||
return new ListResponse<string> { Items = list, TotalCount = list.Count() }; |
|||
} |
|||
|
|||
public ListResponse<string> QueryPurchaserLocationList(string keywords) |
|||
{ |
|||
if (string.IsNullOrEmpty(keywords)) |
|||
throw new BusinessException("关键字不能为空"); |
|||
var list = fsql.Select<Purchaser>().Where(p => p.Location.Contains(keywords)).Distinct().ToList(x => x.Location); |
|||
return new ListResponse<string> { Items = list, TotalCount = list.Count() }; |
|||
} |
|||
|
|||
public ListResponse<PurchaserResponse> QueryPurchaserList(QueryPurchaserRequest request) |
|||
{ |
|||
//默认ShopId为空
|
|||
request.ShopId = null; |
|||
|
|||
#region 数据验证
|
|||
if (request.RecentDayCondition != null) // && request.RecentDayCondition.RecentDay > 0
|
|||
{ |
|||
if (request.RecentDayCondition.PurchasedCountComparisonOperator != null) |
|||
{ |
|||
if (request.RecentDayCondition.PurchasedCount == null || (request.RecentDayCondition.PurchasedCountComparisonOperator == Enums.ComparisonOperator.介于 && |
|||
request.RecentDayCondition.PurchasedCount2 == null)) |
|||
throw new BusinessException("采购量条件不完整"); |
|||
} |
|||
|
|||
if (request.RecentDayCondition.PurchasedAmountComparisonOperator != null) |
|||
{ |
|||
if (request.RecentDayCondition.PurchasedAmount == null || (request.RecentDayCondition.PurchasedAmountComparisonOperator == Enums.ComparisonOperator.介于 && |
|||
request.RecentDayCondition.PurchasedAmount2 == null)) |
|||
throw new BusinessException("采购金额条件不完整"); |
|||
} |
|||
} |
|||
#endregion
|
|||
|
|||
if (request.PageSize > 20) |
|||
request.PageSize = 20; |
|||
|
|||
var select = fsql.Select<Purchaser>() |
|||
.WhereIf(!string.IsNullOrEmpty(request.Spu), p => fsql.Select<PurchaseSchemeProduct>() |
|||
.Where(psp1 => psp1.PurchaserId == p.Id && |
|||
psp1.ProductId == request.Spu) |
|||
.Any()) |
|||
.WhereIf(!string.IsNullOrEmpty(request.Sku), p => fsql.Select<PurchaseSchemeProduct>() |
|||
.Where(psp2 => psp2.PurchaserId == p.Id && |
|||
psp2.SkuId == request.Sku) |
|||
.Any()) |
|||
.WhereIf(request.PurchaserNameList != null && |
|||
request.PurchaserNameList.Count() > 0, p => request.PurchaserNameList.Contains(p.Name)) |
|||
.WhereIf(request.CategoryIdList != null && |
|||
request.CategoryIdList.Count() > 0, p => fsql.Select<Purchaser_ExtendedInfo_Relation>() |
|||
.Where(per => per.PurchaserId == p.Id && |
|||
request.CategoryIdList.Contains(per.ExtendedInfoId.Value)).Any()) |
|||
.WhereIf(request.LocationList != null && request.LocationList.Count() > 0, p => request.LocationList.Contains(p.Location)) |
|||
.WhereIf(request.ManagmentMode != null, p => p.ManagmentMode == request.ManagmentMode); |
|||
|
|||
if (request.RecentDayCondition != null) // && request.RecentDayCondition.RecentDay > 0
|
|||
{ |
|||
//var recentStartDay = DateTime.Now.Date.AddDays(request.RecentDayCondition.RecentDay.Value * -1);
|
|||
if (request.RecentDayCondition.PurchasedCountComparisonOperator != null && |
|||
request.RecentDayCondition.PurchasedCount != null && |
|||
request.RecentDayCondition.PurchasedCount != 0) |
|||
{ |
|||
select = select.WhereIf(request.RecentDayCondition.PurchasedCountComparisonOperator == Enums.ComparisonOperator.等于, |
|||
p => p.Recent90dPurchasedCount != null && p.Recent90dPurchasedCount == request.RecentDayCondition.PurchasedCount) |
|||
.WhereIf(request.RecentDayCondition.PurchasedCountComparisonOperator == Enums.ComparisonOperator.小于, |
|||
p => p.Recent90dPurchasedCount != null && p.Recent90dPurchasedCount <= request.RecentDayCondition.PurchasedCount) |
|||
.WhereIf(request.RecentDayCondition.PurchasedCountComparisonOperator == Enums.ComparisonOperator.大于, |
|||
p => p.Recent90dPurchasedCount != null && p.Recent90dPurchasedCount >= request.RecentDayCondition.PurchasedCount) |
|||
.WhereIf(request.RecentDayCondition.PurchasedCountComparisonOperator == Enums.ComparisonOperator.介于, |
|||
p => p.Recent90dPurchasedCount != null && p.Recent90dPurchasedCount >= request.RecentDayCondition.PurchasedCount && |
|||
p.Recent90dPurchasedCount <= request.RecentDayCondition.PurchasedCount2); |
|||
} |
|||
if (request.RecentDayCondition.PurchasedAmountComparisonOperator != null && |
|||
request.RecentDayCondition.PurchasedAmount != null && |
|||
request.RecentDayCondition.PurchasedAmount != 0) |
|||
{ |
|||
select = select.WhereIf(request.RecentDayCondition.PurchasedCountComparisonOperator == Enums.ComparisonOperator.等于, |
|||
p => p.Recent90dPurchasedAmount != null && p.Recent90dPurchasedAmount == request.RecentDayCondition.PurchasedAmount) |
|||
.WhereIf(request.RecentDayCondition.PurchasedCountComparisonOperator == Enums.ComparisonOperator.小于, |
|||
p => p.Recent90dPurchasedAmount != null && p.Recent90dPurchasedAmount <= request.RecentDayCondition.PurchasedAmount) |
|||
.WhereIf(request.RecentDayCondition.PurchasedCountComparisonOperator == Enums.ComparisonOperator.大于, |
|||
p => p.Recent90dPurchasedAmount != null && p.Recent90dPurchasedAmount >= request.RecentDayCondition.PurchasedAmount) |
|||
.WhereIf(request.RecentDayCondition.PurchasedCountComparisonOperator == Enums.ComparisonOperator.介于, |
|||
p => p.Recent90dPurchasedAmount != null && p.Recent90dPurchasedAmount >= request.RecentDayCondition.PurchasedAmount && |
|||
p.Recent90dPurchasedAmount <= request.RecentDayCondition.PurchasedAmount2); |
|||
} |
|||
} |
|||
|
|||
select = select.Page(request.PageIndex, request.PageSize) |
|||
.OrderByPropertyNameIf(!string.IsNullOrEmpty(request.SortColumn), request.SortColumn, request.SortType == 0); |
|||
var sql = select.ToSql(); |
|||
var purchaserList = select.Count(out var count).ToList<PurchaserResponse>(); |
|||
if (purchaserList.Count() > 0) |
|||
{ |
|||
var purchaserIdList = purchaserList.Select(p => p.Id).ToList(); |
|||
|
|||
#region 查询标签/主营类目
|
|||
var purchaserExtendInfoList = fsql.Select<PurchaserExtendedInfo, Purchaser_ExtendedInfo_Relation>() |
|||
.InnerJoin((pei, per) => pei.Id == per.ExtendedInfoId) |
|||
.Where((pei, per) => purchaserIdList.Contains(per.PurchaserId)) |
|||
.ToList((pei, per) => new |
|||
{ |
|||
pei.Id, |
|||
pei.Name, |
|||
pei.Type, |
|||
per.PurchaserId, |
|||
pei.ExtendInfo |
|||
}); |
|||
#endregion
|
|||
|
|||
#region 最近采购的店铺商品
|
|||
var recentStartDay = DateTime.Now.Date.AddDays(-90); |
|||
var recentEndDay = DateTime.Now.Date; |
|||
var bePurchasedProductSkuList = fsql.Select<OrderPurchaseInfo, OrderPurchaseRelationInfo, Order, ProductSku>() |
|||
.InnerJoin((opi, opri, o, ps) => opi.OrderId == o.Id) |
|||
.InnerJoin((opi, opri, o, ps) => opri.PurchaseOrderId == opi.PurchaseOrderId) |
|||
.InnerJoin((opi, opri, o, ps) => opri.BelongSkuId == ps.Id) |
|||
.WhereIf(request.ShopId != null && request.ShopId > 0, (opi, opri, o, ps) => o.ShopId == request.ShopId) |
|||
.Where((opi, opri, o, ps) => o.OrderState != Enums.OrderState.已取消 && |
|||
opi.IsEnabled == true && |
|||
opi.CreateTime >= recentStartDay && |
|||
opi.CreateTime < recentEndDay && |
|||
purchaserIdList.Contains(opi.PurchaserId)) |
|||
.GroupBy((opi, opri, o, ps) => new |
|||
{ |
|||
ps.Id, |
|||
opi.PurchaserId, |
|||
ps.Logo, |
|||
ps.SkuName, |
|||
opri.SourceSkuId |
|||
}) |
|||
.ToList(g => new |
|||
{ |
|||
g.Key.Id, |
|||
g.Key.PurchaserId, |
|||
g.Key.Logo, |
|||
g.Key.SkuName, |
|||
g.Key.SourceSkuId, |
|||
MaxPurchasedTime = g.Max(g.Value.Item1.CreateTime) |
|||
}); |
|||
var belongSkuIdList = bePurchasedProductSkuList.Select(x => x.SourceSkuId).Distinct().ToList(); |
|||
var belongSkuList = _freeSqlMultiDBManager.BBWYCfsql.Select<BBWYB.Server.Model.Db.BBWY.ProductSku>(belongSkuIdList).ToList(ps => new { ps.Id, ps.Logo }); |
|||
|
|||
|
|||
#endregion
|
|||
|
|||
foreach (var purchaser in purchaserList) |
|||
{ |
|||
#region 主营类目/标签
|
|||
var currentExtendInfoList = purchaserExtendInfoList.Where(x => x.PurchaserId == purchaser.Id).ToList(); |
|||
purchaser.CategoryList = currentExtendInfoList.Where(x => x.Type == Enums.PurchaserBasicInfoType.主营类目) |
|||
.Select(x => new PurchaserExtendedInfoResponse() |
|||
{ |
|||
Id = x.Id, |
|||
Name = x.Name, |
|||
Type = x.Type, |
|||
ExtendInfo = x.ExtendInfo |
|||
}).ToList(); |
|||
|
|||
purchaser.TagList = currentExtendInfoList.Where(x => x.Type == Enums.PurchaserBasicInfoType.标签) |
|||
.Select(x => new PurchaserExtendedInfoResponse() |
|||
{ |
|||
Id = x.Id, |
|||
Name = x.Name, |
|||
Type = x.Type, |
|||
ExtendInfo = x.ExtendInfo |
|||
}).ToList(); |
|||
#endregion
|
|||
|
|||
#region 最近采购店铺商品
|
|||
purchaser.Recent30dProductSku = bePurchasedProductSkuList.Where(x => x.PurchaserId == purchaser.Id) |
|||
.OrderByDescending(x => x.MaxPurchasedTime) |
|||
.Take(10) |
|||
.Select(x => |
|||
{ |
|||
var belongSku = belongSkuList.FirstOrDefault(b => b.Id == x.SourceSkuId); |
|||
return new RecentPurchasedSkuResponse() |
|||
{ |
|||
Id = x.Id, |
|||
Logo = belongSku?.Logo ?? x.Logo, |
|||
SkuName = x.SkuName, |
|||
BelongSku = x.SourceSkuId, |
|||
MaxPurchasedTime = x.MaxPurchasedTime |
|||
}; |
|||
}).ToList(); |
|||
#endregion
|
|||
|
|||
} |
|||
} |
|||
|
|||
return new ListResponse<PurchaserResponse>() |
|||
{ |
|||
Items = purchaserList, |
|||
TotalCount = count |
|||
}; |
|||
} |
|||
|
|||
public ListResponse<PurchaserExtendedInfoResponse> QueryPurchaserCategoryList(QueryPurchaserExtendedRequest request) |
|||
{ |
|||
var list = fsql.Select<PurchaserExtendedInfo>() |
|||
.WhereIf(request.Type != null, x => x.Type == request.Type) |
|||
.WhereIf(!string.IsNullOrEmpty(request.Keywords), x => x.Name.Contains(request.Keywords)) |
|||
.Count(out var count) |
|||
.ToList<PurchaserExtendedInfoResponse>(); |
|||
return new ListResponse<PurchaserExtendedInfoResponse> { Items = list, TotalCount = count }; |
|||
} |
|||
|
|||
public void EditPurchaserExtendedInfo(EditPurchaserExtendedInfoRequest request) |
|||
{ |
|||
var insertRelationList = new List<Purchaser_ExtendedInfo_Relation>(); |
|||
insertRelationList.AddRange(request.CategoryIdList.Select(x => new Purchaser_ExtendedInfo_Relation() |
|||
{ |
|||
Id = idGenerator.NewLong(), |
|||
PurchaserId = request.PurchaserId, |
|||
ExtendedType = Enums.PurchaserBasicInfoType.主营类目, |
|||
ExtendedInfoId = x |
|||
})); |
|||
|
|||
insertRelationList.AddRange(request.TagIdList.Select(x => new Purchaser_ExtendedInfo_Relation() |
|||
{ |
|||
Id = idGenerator.NewLong(), |
|||
PurchaserId = request.PurchaserId, |
|||
ExtendedType = Enums.PurchaserBasicInfoType.标签, |
|||
ExtendedInfoId = x |
|||
})); |
|||
|
|||
fsql.Transaction(() => |
|||
{ |
|||
fsql.Delete<Purchaser_ExtendedInfo_Relation>().Where(r => r.PurchaserId == request.PurchaserId).ExecuteAffrows(); |
|||
fsql.Update<Purchaser>(request.PurchaserId).Set(p => p.ManagmentMode, request.ManagmentMode).ExecuteAffrows(); |
|||
if (insertRelationList.Count() > 0) |
|||
fsql.Insert(insertRelationList).ExecuteAffrows(); |
|||
|
|||
}); |
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,954 @@ |
|||
using BBWYB.Common.Extensions; |
|||
using BBWYB.Common.Log; |
|||
using BBWYB.Common.Models; |
|||
using BBWYB.Server.Model; |
|||
using BBWYB.Server.Model.Db; |
|||
using BBWYB.Server.Model.Db.BBWY; |
|||
using BBWYB.Server.Model.Db.SpuOptimization; |
|||
using BBWYB.Server.Model.Dto; |
|||
using FreeSql; |
|||
using Newtonsoft.Json; |
|||
using System.Numerics; |
|||
using System.Text.RegularExpressions; |
|||
using Yitter.IdGenerator; |
|||
|
|||
namespace BBWYB.Server.Business |
|||
{ |
|||
public class OptimizationBusiness : BaseBusiness, IDenpendency |
|||
{ |
|||
private FreeSqlMultiDBManager fsqlManager; |
|||
private VenderBusiness venderBusiness; |
|||
private TimeLimitRules timeLimitRules; |
|||
private UserBusiness userBusiness; |
|||
private PurchaseSchemeBusiness purchaseSchemeBusiness; |
|||
|
|||
public OptimizationBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, FreeSqlMultiDBManager fsqlManager, VenderBusiness venderBusiness, TimeLimitRules timeLimitRules, UserBusiness userBusiness, PurchaseSchemeBusiness purchaseSchemeBusiness) : base(fsql, nLogManager, idGenerator) |
|||
{ |
|||
this.fsqlManager = fsqlManager; |
|||
this.venderBusiness = venderBusiness; |
|||
this.timeLimitRules = timeLimitRules; |
|||
this.userBusiness = userBusiness; |
|||
this.purchaseSchemeBusiness = purchaseSchemeBusiness; |
|||
} |
|||
|
|||
|
|||
public Enums.TriggerOptimizationReason? GetOptimizationReason(SpuTotalSaleInfo s) |
|||
{ |
|||
if (s.IsFirstPurchaseCompleted == false) |
|||
return Enums.TriggerOptimizationReason.首次采购; |
|||
if (s.IsFirstPurchaseCompleted == true && |
|||
s.IsFirstOptimizationCompleted == false) |
|||
{ |
|||
if (s.ItemCount - s.FirstPurchaseCompletedItemCount >= 20) |
|||
return Enums.TriggerOptimizationReason.首次优化; |
|||
if (s.LastOptimizationTime != null && |
|||
(DateTime.Now.Date - s.LastOptimizationTime.Value.Date).TotalDays > 30) |
|||
return Enums.TriggerOptimizationReason.首次优化; |
|||
} |
|||
if (s.IsFirstOptimizationCompleted == true) |
|||
{ |
|||
if (s.LastOptimizationItemCount != 0 && s.ItemCount * 1.0 / s.LastOptimizationItemCount >= 2) |
|||
return Enums.TriggerOptimizationReason.再次优化; |
|||
|
|||
if (s.LastOptimizationTime != null && |
|||
(DateTime.Now.Date - s.LastOptimizationTime.Value.Date).TotalDays > 30) |
|||
return Enums.TriggerOptimizationReason.再次优化; |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 良库预警
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
/// <exception cref="BusinessException"></exception>
|
|||
public void LKInventoryAlertNotification(BatchLKInventoryAlertRequest request) |
|||
{ |
|||
nLogManager.Default().Info($"LKInventoryAlertNotification {JsonConvert.SerializeObject(request)}"); |
|||
|
|||
#region 确定JDSKU对应的拳探SKU和拳探SPU
|
|||
var jdSkuIdList = request.Items.Select(x => x.Sku).Distinct().ToList(); |
|||
|
|||
var jdqtskuList = fsqlManager.BBWYCfsql.Select<PurchaseOrderSku>() |
|||
.Where(ps1 => ps1.ShopId == request.ShopId && jdSkuIdList.Contains(ps1.SkuId)) |
|||
.GroupBy(ps1 => ps1.SkuId) |
|||
.WithTempQuery(g => new { MaxId = g.Max(g.Value.Id) }) |
|||
.From<PurchaseOrderSku>() |
|||
.InnerJoin((ps1, ps2) => ps1.MaxId == ps2.Id) |
|||
.ToList((ps1, ps2) => ps2); |
|||
|
|||
var qtSkuIdList = jdqtskuList.Select(x => x.PurchaseSkuIds).Distinct().ToList(); |
|||
|
|||
var productSkuList = fsql.Select<Model.Db.ProductSku>(qtSkuIdList).ToList(); |
|||
if (productSkuList.Count() == 0) |
|||
return; |
|||
|
|||
var shopId = productSkuList.FirstOrDefault()?.ShopId; |
|||
var productIdList = productSkuList.Select(ps => ps.ProductId).Distinct().ToList(); |
|||
var productList = fsql.Select<Product>(productIdList).ToList(); |
|||
var dbSpuTotalInfoList = fsql.Select<SpuTotalSaleInfo>().Where(spi => productIdList.Contains(spi.ProductId)).ToList(); |
|||
#endregion
|
|||
|
|||
|
|||
//查询已存在未结束的优化任务
|
|||
var dbSpuOptimizationTaskList = fsql.Select<SpuOptimizationTask>() |
|||
.Where(t => t.ShopId == shopId && |
|||
t.IsOptimizationCompleted == false && |
|||
productIdList.Contains(t.ProductId)) |
|||
.ToList(); |
|||
|
|||
|
|||
//优化历史
|
|||
var dbSpuOptimizationHistoryList = fsql.Select<SpuOptimizationTask>() |
|||
.Where(s1 => productIdList.Contains(s1.ProductId) && s1.IsOptimizationCompleted == true) |
|||
.GroupBy(s1 => s1.ProductId) |
|||
.WithTempQuery(g => new { MaxId = g.Max(g.Value.Id) }) |
|||
.From<SpuOptimizationTask>() |
|||
.InnerJoin((s1, s2) => s1.MaxId == s2.Id) |
|||
.ToList((s1, s2) => s2); |
|||
|
|||
|
|||
#region DB Operation
|
|||
List<SpuOptimizationTask> insertSpuOptimizationTaskList = new List<SpuOptimizationTask>(); |
|||
List<SkuOptimizationTask> insertSkuOptimizationTaskList = new List<SkuOptimizationTask>(); |
|||
List<SpuOptimizationBargainTeamTask> insertSpuOptimizationBargainTeamTaskList = new List<SpuOptimizationBargainTeamTask>(); |
|||
List<SpuOptimizationCompetitiveTenderTask> insertSpuOptimizationCompetitiveTenderTaskList = new List<SpuOptimizationCompetitiveTenderTask>(); |
|||
//List<SpuOptimizationPurchaserCompetitiveTenderTask> insertSpuOptimizationPurchaserCompetitiveTenderTaskList = new List<SpuOptimizationPurchaserCompetitiveTenderTask>();
|
|||
List<TimeLimitTask> insertTimeLimitTaskList = new List<TimeLimitTask>(); |
|||
#endregion
|
|||
|
|||
var belongShop = venderBusiness.GetShopList(request.ShopId).FirstOrDefault(); |
|||
if (belongShop == null) |
|||
throw new BusinessException("店铺不存在"); |
|||
|
|||
var bargainTeamList = venderBusiness.GetYiJiaGroup(); //获取议价组
|
|||
var bargainTeamIdList = bargainTeamList.Select(t => t.Id).ToList(); |
|||
var waitToCompetitiveTenderSchemeList = fsql.Select<PurchaseScheme>() |
|||
.Where(ps => bargainTeamIdList.Contains(ps.BelongBargainTeamId) && |
|||
productIdList.Contains(ps.ProductId)) |
|||
.ToList(); //需要参与竞标采购方案
|
|||
|
|||
var waitToCompetitiveTenderSchemeIdList = waitToCompetitiveTenderSchemeList.Select(ps => ps.Id).ToList(); |
|||
var waitToCompetitiveTenderSchemePurchaserList = fsql.Select<PurchaseSchemeProduct>() |
|||
.Where(psp => waitToCompetitiveTenderSchemeIdList.Contains(psp.SkuPurchaseSchemeId)) |
|||
.GroupBy(psp => new { psp.SkuPurchaseSchemeId, psp.PurchaserId }) |
|||
.ToList(g => new { g.Key.SkuPurchaseSchemeId, g.Key.PurchaserId }); //需要参与竞标的采购商
|
|||
|
|||
foreach (var productId in productIdList) |
|||
{ |
|||
#region 验证
|
|||
if (dbSpuOptimizationTaskList.Any(s => s.ProductId == productId)) //过滤未结束的spu任务
|
|||
continue; |
|||
|
|||
var spuTotalInfo = dbSpuTotalInfoList.FirstOrDefault(psi => psi.ProductId == productId); //spu销量
|
|||
if (spuTotalInfo == null) |
|||
continue; |
|||
|
|||
var reason = GetOptimizationReason(spuTotalInfo); //过滤不需要优化的spu
|
|||
if (reason == null) |
|||
continue; |
|||
#endregion
|
|||
|
|||
var skuOptimizationHistory = dbSpuOptimizationHistoryList.FirstOrDefault(h => h.ProductId == productId); //优化历史
|
|||
|
|||
#region qtsku - jdsku 关系匹配
|
|||
var currentProductSkuList = productSkuList.Where(ps => ps.ProductId == productId && |
|||
jdqtskuList.Any(x => x.PurchaseSkuIds == ps.Id)).ToList(); |
|||
if (currentProductSkuList.Count() == 0) |
|||
continue; |
|||
|
|||
//拳探sku-京东sku下单关系映射表
|
|||
var mappingQT_JDSKUDictionary = new Dictionary<string, string>(); |
|||
foreach (var ps in currentProductSkuList) |
|||
{ |
|||
var jdsku = jdqtskuList.FirstOrDefault(x => x.PurchaseSkuIds == ps.Id)?.SkuId; |
|||
if (string.IsNullOrEmpty(jdsku)) |
|||
continue; |
|||
if (!mappingQT_JDSKUDictionary.ContainsKey(ps.Id)) |
|||
mappingQT_JDSKUDictionary.TryAdd(ps.Id, jdsku); |
|||
} |
|||
var jdskus = mappingQT_JDSKUDictionary.Values.ToList(); |
|||
var qtskus = mappingQT_JDSKUDictionary.Keys.ToList(); |
|||
#endregion
|
|||
|
|||
#region 读取JDSKU预估金额
|
|||
var jdskuRecentCostList = fsqlManager.BBWYCfsql.Select<SkuRecentCost>(jdskus).ToList(); |
|||
#endregion
|
|||
|
|||
#region 创建SPU优化任务
|
|||
var spuOptimizationTask = new SpuOptimizationTask() |
|||
{ |
|||
Id = idGenerator.NewLong(), |
|||
BelongShopId = long.Parse(belongShop.ShopId), |
|||
BelongShopName = belongShop.ShopName, |
|||
CompletionTime = null, |
|||
CreateTime = DateTime.Now, |
|||
IsOptimizationCompleted = false, |
|||
LastOptimizationTime = null, |
|||
ProductId = productId, |
|||
ShopId = shopId, |
|||
ProductTitle = productList.FirstOrDefault(p => p.Id == productId)?.ProductName, |
|||
TriggerOptimizationReason = reason, |
|||
PreSkuCount = jdskus.Count(), |
|||
PreItemCount = 0, |
|||
PrePurchaseAmount = 0M |
|||
}; |
|||
insertSpuOptimizationTaskList.Add(spuOptimizationTask); |
|||
#endregion
|
|||
|
|||
#region 创建SKU优化任务
|
|||
foreach (var sku in mappingQT_JDSKUDictionary.Keys) |
|||
{ |
|||
mappingQT_JDSKUDictionary.TryGetValue(sku, out string jdSkuId); |
|||
var requestSkuItem = request.Items.FirstOrDefault(x => x.Sku == jdSkuId); |
|||
if (requestSkuItem == null) |
|||
continue; |
|||
|
|||
var preItemCount = requestSkuItem.PreItemCount; |
|||
var prePurchaseAmount = 0M; |
|||
if (!string.IsNullOrEmpty(jdSkuId)) |
|||
{ |
|||
var jdSkuRecentCost = jdskuRecentCostList.FirstOrDefault(x => x.SkuId == jdSkuId); |
|||
if (jdSkuRecentCost != null) |
|||
{ |
|||
prePurchaseAmount = (jdSkuRecentCost.SingleSkuAmount ?? 0M + |
|||
jdSkuRecentCost.SingleFirstFreight ?? 0M + |
|||
jdSkuRecentCost.SingleFreight ?? 0M + |
|||
jdSkuRecentCost.SingleDeliveryFreight ?? 0M + |
|||
jdSkuRecentCost.SingleConsumableAmount ?? 0M + |
|||
jdSkuRecentCost.SingleInStorageAmount ?? 0M + |
|||
jdSkuRecentCost.SingleOutStorageAmount ?? 0M + |
|||
jdSkuRecentCost.SinglePackagingLaborAmount ?? 0M + |
|||
jdSkuRecentCost.SingleOperationAmount ?? 0M) * preItemCount; |
|||
} |
|||
} |
|||
var skuOptimizationTask = new SkuOptimizationTask() |
|||
{ |
|||
Id = idGenerator.NewLong(), |
|||
CreateTime = DateTime.Now, |
|||
JDSkuId = jdSkuId, |
|||
PreItemCount = preItemCount, |
|||
SkuId = sku, |
|||
SpuOptimizationTaskId = spuOptimizationTask.Id, |
|||
PrePurchaseAmount = prePurchaseAmount |
|||
}; |
|||
insertSkuOptimizationTaskList.Add(skuOptimizationTask); |
|||
|
|||
//累计spu优化任务信息
|
|||
spuOptimizationTask.PreItemCount += preItemCount; |
|||
spuOptimizationTask.PrePurchaseAmount += prePurchaseAmount; |
|||
} |
|||
#endregion
|
|||
|
|||
#region 创建SPU优化议价组任务
|
|||
foreach (var department in bargainTeamList) |
|||
{ |
|||
var spuOptimizationBargainTeamTask = new SpuOptimizationBargainTeamTask() |
|||
{ |
|||
Id = idGenerator.NewLong(), |
|||
BelongTeamId = department.Id, |
|||
BelongTeamName = department.DepartmentName, |
|||
CompletionTime = null, |
|||
IsOptimizationCompleted = false, |
|||
SpuOptimizationTaskId = spuOptimizationTask.Id |
|||
}; |
|||
insertSpuOptimizationBargainTeamTaskList.Add(spuOptimizationBargainTeamTask); |
|||
|
|||
#region 创建采购方案竞标任务
|
|||
var waitJoinSchemeList = waitToCompetitiveTenderSchemeList.Where(ps => ps.BelongBargainTeamId == department.Id && |
|||
qtskus.Contains(ps.SkuId)) |
|||
.ToList(); |
|||
|
|||
//var waitJoinSchemeIdList = waitJoinSchemeList.Select(ps => ps.Id).ToList();
|
|||
//var waitJonPurchaserList = waitToCompetitiveTenderSchemePurchaserList.Where(x => waitJoinSchemeIdList.Contains(x.SkuPurchaseSchemeId));
|
|||
if (waitJoinSchemeList.Count() > 0) |
|||
{ |
|||
insertSpuOptimizationCompetitiveTenderTaskList.AddRange(waitJoinSchemeList.Select(ps => new SpuOptimizationCompetitiveTenderTask() |
|||
{ |
|||
Id = idGenerator.NewLong(), |
|||
BargainTeamId = ps.BelongBargainTeamId, |
|||
CreateTime = DateTime.Now, |
|||
IsUpdateQuotedPrice = false, |
|||
SchemeGroupId = ps.SchemeGroupId, |
|||
SchemeId = ps.Id, |
|||
SkuId = ps.SkuId, |
|||
SpuOptimizationBargainTeamTaskId = spuOptimizationBargainTeamTask.Id, |
|||
SpuOptimizationTaskId = spuOptimizationTask.Id, |
|||
UpdateTime = DateTime.Now |
|||
})); |
|||
|
|||
//insertSpuOptimizationPurchaserCompetitiveTenderTaskList.AddRange(waitJonPurchaserList.Select(x =>
|
|||
//{
|
|||
// var ps = waitJoinSchemeList.FirstOrDefault(ps => ps.Id == x.SkuPurchaseSchemeId);
|
|||
// return new SpuOptimizationPurchaserCompetitiveTenderTask()
|
|||
// {
|
|||
// Id = idGenerator.NewLong(),
|
|||
// BargainTeamId = ps.BelongBargainTeamId,
|
|||
// CreateTime = DateTime.Now,
|
|||
// UpdateTime = DateTime.Now,
|
|||
// IsUpdateQuotedPrice = false,
|
|||
// PurchaserId = x.PurchaserId,
|
|||
// SchemeGroupId = ps.SchemeGroupId,
|
|||
// SchemeId = ps.Id,
|
|||
// SkuId = ps.SkuId,
|
|||
// SpuOptimizationTaskId = spuOptimizationTask.Id
|
|||
// };
|
|||
//}));
|
|||
} |
|||
#endregion
|
|||
} |
|||
#endregion
|
|||
|
|||
#region 创建优化限时任务
|
|||
|
|||
{ |
|||
//判断sku是否首次采购
|
|||
//var isFirst = !dbSpuTotalInfoList.Any(s => s.ProductId == productId);
|
|||
|
|||
insertTimeLimitTaskList.Add(new TimeLimitTask() |
|||
{ |
|||
Id = idGenerator.NewLong(), |
|||
CreateTme = DateTime.Now, |
|||
//ExpirationTime = DateTime.Now.AddDays(isFirst ? 2 : 1),
|
|||
ExpirationTime = timeLimitRules.CalculateExpirationTime(Enums.TimeLimitTaskType.待议价任务, DateTime.Now), |
|||
//OrderId = o.OrderId,
|
|||
//OrderSn = o.OrderSn,
|
|||
ShopId = shopId, |
|||
//SkuId = waitCheckOrderSku.SkuId,
|
|||
TaskType = Enums.TimeLimitTaskType.待议价任务, |
|||
TaskId = spuOptimizationTask.Id, |
|||
Remark = "首次采购限时任务" |
|||
}); |
|||
} |
|||
#endregion
|
|||
|
|||
} |
|||
|
|||
|
|||
fsql.Transaction(() => |
|||
{ |
|||
if (insertSpuOptimizationTaskList.Count() > 0) |
|||
fsql.Insert(insertSpuOptimizationTaskList).ExecuteAffrows(); |
|||
if (insertSkuOptimizationTaskList.Count() > 0) |
|||
fsql.Insert(insertSkuOptimizationTaskList).ExecuteAffrows(); |
|||
if (insertSpuOptimizationBargainTeamTaskList.Count() > 0) |
|||
fsql.Insert(insertSpuOptimizationBargainTeamTaskList).ExecuteAffrows(); |
|||
if (insertSpuOptimizationCompetitiveTenderTaskList.Count() > 0) |
|||
fsql.Insert(insertSpuOptimizationCompetitiveTenderTaskList).ExecuteAffrows(); |
|||
//if (insertSpuOptimizationPurchaserCompetitiveTenderTaskList.Count() > 0)
|
|||
// fsql.Insert(insertSpuOptimizationPurchaserCompetitiveTenderTaskList).ExecuteAffrows();
|
|||
if (insertTimeLimitTaskList.Count() > 0) |
|||
fsql.Insert(insertTimeLimitTaskList).ExecuteAffrows(); |
|||
}); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 更新报价
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
/// <param name="userId"></param>
|
|||
public void BatchUpdateCompetitiveTenderQuotation(BatchUpdateCompetitiveTenderQuotationRequest request, string userId) |
|||
{ |
|||
#region 获取用户和部门信息
|
|||
var uInfo = userBusiness.GetisBargainTeamByUserId(userId, true); |
|||
#endregion
|
|||
|
|||
#region 业务验证
|
|||
var spuOptimizationTask = fsql.Select<SpuOptimizationTask>(request.SpuOptimizationTaskId).ToOne(); |
|||
if (spuOptimizationTask == null) |
|||
throw new BusinessException($"待优化任务{request.SpuOptimizationTaskId}不存在"); |
|||
var spuOptimizationBargainTeamTask = fsql.Select<SpuOptimizationBargainTeamTask>().Where(sbt => sbt.SpuOptimizationTaskId == request.SpuOptimizationTaskId && sbt.BelongTeamId == uInfo.bargainTeam.Id).ToOne(); |
|||
if (spuOptimizationBargainTeamTask == null) |
|||
throw new BusinessException($"待优化任务{request.SpuOptimizationTaskId}中不存在议价组{uInfo.bargainTeam.Id}/{uInfo.bargainTeam.DepartmentName}的子任务"); |
|||
var skuIdList = fsql.Select<SkuOptimizationTask>().Where(s => s.SpuOptimizationTaskId == request.SpuOptimizationTaskId).ToList(s => s.SkuId); |
|||
#endregion
|
|||
|
|||
#region DBOperation
|
|||
List<SpuOptimizationCompetitiveTenderTask> insertSpuOptimizationCompetitiveTenderTaskList = new List<SpuOptimizationCompetitiveTenderTask>(); |
|||
List<long> updateCompetitiveTenderTaskIdList = new List<long>(); |
|||
List<SpuOptimizationProductSkuUpdateQuotedPriceRecord> insertUpdatePriceList = new List<SpuOptimizationProductSkuUpdateQuotedPriceRecord>(); |
|||
#endregion
|
|||
|
|||
//var skuList = request.ItemList.Select(x => x.SkuId).Distinct().ToList();
|
|||
var purchaseSkuIdList = request.ItemList.Select(x => x.PurchaseSkuId).Distinct().ToList(); |
|||
|
|||
//查询竞标任务
|
|||
var competitiveTenderTaskList = fsql.Select<SpuOptimizationCompetitiveTenderTask>() |
|||
.Where(ct => ct.BargainTeamId == uInfo.bargainTeam.Id && |
|||
ct.SpuOptimizationTaskId == request.SpuOptimizationTaskId && |
|||
ct.SchemeGroupId == request.SchemeGroupId) |
|||
.ToList(); |
|||
|
|||
//查询配件关联的采购方案
|
|||
var relationPurchaseSchemeIdList = fsql.Select<PurchaseScheme>() |
|||
.Where(ps => ps.SchemeGroupId == request.SchemeGroupId && |
|||
ps.BelongBargainTeamId == uInfo.bargainTeam.Id && |
|||
fsql.Select<PurchaseSchemeProductSku>() |
|||
.Where(pss => skuIdList.Contains(pss.SkuId) && |
|||
purchaseSkuIdList.Contains(pss.PurchaseSkuId) && |
|||
pss.SkuPurchaseSchemeId == ps.Id).Any()) |
|||
.ToList(ps => ps.Id); |
|||
var relationPurchaseSchemeList = purchaseSchemeBusiness.GetPurchaseSchemeList(new QuerySchemeRequest() |
|||
{ |
|||
SchemeIdList = relationPurchaseSchemeIdList, |
|||
IncludePurchaseSkuBasicInfo = 0 |
|||
}); |
|||
|
|||
//查询配件级报价任务
|
|||
var updatePriceRecordList = fsql.Select<SpuOptimizationProductSkuUpdateQuotedPriceRecord>() |
|||
.Where(x => x.SpuOptimizationTaskId == request.SpuOptimizationTaskId && |
|||
x.BargainTeamId == uInfo.bargainTeam.Id) |
|||
.ToList(); |
|||
|
|||
//筛选出不在竞标任务中的采购方案
|
|||
var noJoinCompetitiveTenderPurchaseSchemeList = relationPurchaseSchemeList.Where(ps => !competitiveTenderTaskList.Any(ct => ct.SchemeId == ps.Id)).ToList(); |
|||
|
|||
|
|||
{ |
|||
var batchEditPurchaseSkuActualPriceRequest = request.Map<BatchEditPurchaseSkuActualPriceRequest>(); |
|||
batchEditPurchaseSkuActualPriceRequest.ProductId = spuOptimizationTask.ProductId; |
|||
purchaseSchemeBusiness.BatchEditPurchaseSkuActualPrice(batchEditPurchaseSkuActualPriceRequest, uInfo); |
|||
} |
|||
|
|||
insertUpdatePriceList.AddRange(request.ItemList.Where(x => !updatePriceRecordList.Any(r => r.PurchaseSkuId == x.PurchaseSkuId)).Select(x => new SpuOptimizationProductSkuUpdateQuotedPriceRecord() |
|||
{ |
|||
Id = idGenerator.NewLong(), |
|||
BargainTeamId = uInfo.bargainTeam.Id, |
|||
CreateTime = DateTime.Now, |
|||
PurchaseSkuId = x.PurchaseSkuId, |
|||
SpuOptimizationTaskId = request.SpuOptimizationTaskId, |
|||
UserId = uInfo.user.Id |
|||
})); |
|||
|
|||
if (noJoinCompetitiveTenderPurchaseSchemeList.Count() > 0) |
|||
{ |
|||
insertSpuOptimizationCompetitiveTenderTaskList.AddRange(noJoinCompetitiveTenderPurchaseSchemeList.Select(ps => new SpuOptimizationCompetitiveTenderTask() |
|||
{ |
|||
Id = idGenerator.NewLong(), |
|||
CreateTime = DateTime.Now, |
|||
BargainTeamId = uInfo.bargainTeam.Id, |
|||
IsUpdateQuotedPrice = true, |
|||
SchemeGroupId = ps.SchemeGroupId, |
|||
SchemeId = ps.Id, |
|||
SkuId = ps.SkuId, |
|||
SpuOptimizationBargainTeamTaskId = spuOptimizationBargainTeamTask.Id, |
|||
SpuOptimizationTaskId = request.SpuOptimizationTaskId, |
|||
UpdateTime = DateTime.Now |
|||
})); |
|||
} |
|||
|
|||
if (competitiveTenderTaskList.Count() > 0) |
|||
{ |
|||
//updateCompetitiveTenderTaskIdList.AddRange(competitiveTenderTaskList.Select(ct => ct.Id).ToList());
|
|||
foreach (var ctTask in competitiveTenderTaskList) |
|||
{ |
|||
if (ctTask.IsUpdateQuotedPrice == true) |
|||
continue; |
|||
var scheme = relationPurchaseSchemeList.FirstOrDefault(ps => ps.Id == ctTask.SchemeId); |
|||
if (scheme == null) |
|||
continue; |
|||
var pssList = scheme.PurchaseSchemeProductList.SelectMany(psp => psp.PurchaseSchemeProductSkuList); |
|||
if (pssList.Any(pss => request.ItemList.Any(item => item.PurchaseSkuId == pss.PurchaseSkuId))) |
|||
{ |
|||
//ctTask.IsUpdateQuotedPrice = true;
|
|||
updateCompetitiveTenderTaskIdList.Add(ctTask.Id); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
fsql.Transaction(() => |
|||
{ |
|||
if (insertSpuOptimizationCompetitiveTenderTaskList.Count() > 0) |
|||
fsql.Insert(insertSpuOptimizationCompetitiveTenderTaskList).ExecuteAffrows(); |
|||
if (updateCompetitiveTenderTaskIdList.Count() > 0) |
|||
fsql.Update<SpuOptimizationCompetitiveTenderTask>(updateCompetitiveTenderTaskIdList) |
|||
.Set(ct => ct.IsUpdateQuotedPrice, true) |
|||
.Set(ct => ct.UpdateTime, DateTime.Now) |
|||
.ExecuteAffrows(); |
|||
if (insertUpdatePriceList.Count() > 0) |
|||
fsql.Insert(insertUpdatePriceList).ExecuteAffrows(); |
|||
}); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 完成优化
|
|||
/// </summary>
|
|||
/// <param name="taskId"></param>
|
|||
/// <param name="userId"></param>
|
|||
/// <exception cref="BusinessException"></exception>
|
|||
public void CompleteOptimization(long taskId, string userId) |
|||
{ |
|||
#region 获取用户和部门信息
|
|||
var uInfo = userBusiness.GetisBargainTeamByUserId(userId, true); |
|||
#endregion
|
|||
|
|||
#region 业务验证
|
|||
var spuOptimizationTask = fsql.Select<SpuOptimizationTask>(taskId).ToOne(); |
|||
if (spuOptimizationTask == null) |
|||
throw new BusinessException($"待优化任务{taskId}不存在"); |
|||
if (spuOptimizationTask.IsOptimizationCompleted == true) |
|||
throw new BusinessException("待优化任务已完成"); |
|||
|
|||
var spuOptimizationBargainTeamTaskList = fsql.Select<SpuOptimizationBargainTeamTask>() |
|||
.Where(sbt => sbt.SpuOptimizationTaskId == taskId) |
|||
.ToList(); |
|||
var currentspuOptimizationBargainTeamTask = spuOptimizationBargainTeamTaskList.FirstOrDefault(sc => sc.BelongTeamId == uInfo.bargainTeam.Id); |
|||
if (currentspuOptimizationBargainTeamTask == null) |
|||
throw new BusinessException($"未找到议价组{uInfo.bargainTeam.DepartmentName}的议价子任务"); |
|||
if (currentspuOptimizationBargainTeamTask.IsOptimizationCompleted == true) |
|||
throw new BusinessException($"{uInfo.bargainTeam.DepartmentName}的议价子任务已完成"); |
|||
|
|||
var skuIdList = fsql.Select<SkuOptimizationTask>() |
|||
.Where(s => s.SpuOptimizationTaskId == taskId) |
|||
.ToList(s => s.SkuId); |
|||
|
|||
//查询全部竞标任务
|
|||
var allBargainTeamCompetitiveTenderTaskList = fsql.Select<SpuOptimizationCompetitiveTenderTask>() |
|||
.Where(ct => ct.SpuOptimizationTaskId == taskId) |
|||
.ToList(); |
|||
|
|||
//查询当前议价组的竞标任务
|
|||
var currentBargainTeamCompetitiveTenderTaskList = allBargainTeamCompetitiveTenderTaskList.Where(ct => ct.BargainTeamId == uInfo.bargainTeam.Id).ToList(); |
|||
if (currentBargainTeamCompetitiveTenderTaskList.Count() == 0) |
|||
throw new BusinessException($"议价组{uInfo.bargainTeam.DepartmentName}没有参与竞标的采购方案,不能完成优化任务"); |
|||
var currentBargainTeamCompetitiveTenderSchemeIdList = currentBargainTeamCompetitiveTenderTaskList.Select(ct => ct.SchemeId).ToList(); |
|||
|
|||
#region 验证该议价组的符合sku条件的采购方案是否都参与投标
|
|||
var waitCheckPurchaseSchemeIdList = fsql.Select<PurchaseScheme>() |
|||
.Where(ps => ps.BelongBargainTeamId == uInfo.bargainTeam.Id && |
|||
skuIdList.Contains(ps.SkuId)) |
|||
.ToList(ps => ps.Id); |
|||
|
|||
if (waitCheckPurchaseSchemeIdList.Count() == 0) |
|||
throw new BusinessException($"议价组{uInfo.bargainTeam.DepartmentName}没有参与竞标的采购方案,不能完成优化任务"); |
|||
var noJoinCompetitiveTenderSchemeIdList = waitCheckPurchaseSchemeIdList.Except(currentBargainTeamCompetitiveTenderSchemeIdList); |
|||
if (noJoinCompetitiveTenderSchemeIdList.Count() > 0) |
|||
throw new BusinessException($"议价组{uInfo.bargainTeam.DepartmentName}存在{noJoinCompetitiveTenderSchemeIdList.Count()}个符合条件但未参与竞标的采购方案"); |
|||
#endregion
|
|||
|
|||
#region 验证该议价组参与投标的采购方案是否都完成报价
|
|||
if (currentBargainTeamCompetitiveTenderTaskList.Any(ct => ct.IsUpdateQuotedPrice == false)) |
|||
throw new BusinessException($"议价组{uInfo.bargainTeam.DepartmentName}存在未更新报价的投标"); |
|||
#endregion
|
|||
|
|||
currentspuOptimizationBargainTeamTask.IsOptimizationCompleted = true; |
|||
#endregion
|
|||
|
|||
IUpdate<SpuOptimizationBargainTeamTask> updateBargainTask = null; |
|||
IUpdate<SpuOptimizationTask> updateSpuTask = null; |
|||
IUpdate<SpuTotalSaleInfo> updateSpuSaleInfo = null; |
|||
IUpdate<TimeLimitTask> updateTimeLimitTask = null; |
|||
IUpdate<SpuOptimizationCompetitiveTenderTask> updateCompetitiveTenderTask = null; |
|||
|
|||
if (!spuOptimizationBargainTeamTaskList.Any(sc => sc.IsOptimizationCompleted == false)) |
|||
{ |
|||
//全部完成
|
|||
|
|||
#region 更新spu销量表
|
|||
var spuSaleInfo = fsql.Select<SpuTotalSaleInfo>(spuOptimizationTask.ProductId).ToOne(); |
|||
if (spuSaleInfo == null) |
|||
|
|||
throw new BusinessException($"未找到spu{spuOptimizationTask.ProductId}销量"); |
|||
|
|||
updateSpuSaleInfo = fsql.Update<SpuTotalSaleInfo>(spuOptimizationTask.ProductId) |
|||
.SetIf(spuSaleInfo.IsFirstPurchaseCompleted == false, s => s.IsFirstPurchaseCompleted, true) |
|||
.SetIf(spuSaleInfo.IsFirstPurchaseCompleted == false, s => s.FirstPurchaseCompletedItemCount == s.ItemCount) |
|||
.SetIf(spuSaleInfo.IsFirstPurchaseCompleted == true && |
|||
spuSaleInfo.IsFirstOptimizationCompleted == false, s => s.IsFirstOptimizationCompleted, true) |
|||
.SetIf(spuSaleInfo.IsFirstPurchaseCompleted == true && |
|||
spuSaleInfo.IsFirstOptimizationCompleted == false, s => s.FirstOptimizationCompletedItemCount == s.ItemCount) |
|||
.Set(s => s.LastOptimizationItemCount == s.ItemCount) |
|||
.Set(s => s.LastOptimizationTime, DateTime.Now) |
|||
.Set(s => s.UpdateTime, DateTime.Now); |
|||
#endregion
|
|||
|
|||
#region 更新待优化任务
|
|||
updateSpuTask = fsql.Update<SpuOptimizationTask>(spuOptimizationTask.Id) |
|||
.Set(t => t.IsOptimizationCompleted, true) |
|||
.Set(t => t.CompletionTime, DateTime.Now); |
|||
#endregion
|
|||
|
|||
#region 更新待优化限时任务
|
|||
updateTimeLimitTask = fsql.Update<TimeLimitTask>().Set(t => t.CompletionTime, DateTime.Now) |
|||
.Set(t => t.IsTimely == (DateTime.Now < t.ExpirationTime ? true : false)) |
|||
.Where(t => t.TaskId == spuOptimizationTask.Id && |
|||
t.CompletionTime == null && |
|||
t.TaskType == Enums.TimeLimitTaskType.待议价任务); |
|||
#endregion
|
|||
|
|||
#region 评选中标结果
|
|||
var allBargainTeamCompetitiveTenderSchemeIdList = allBargainTeamCompetitiveTenderTaskList.Select(ct => ct.SchemeId).ToList(); |
|||
var allBargainTeamPurchaseSchemeList = purchaseSchemeBusiness.GetPurchaseSchemeList(new QuerySchemeRequest() |
|||
{ |
|||
SchemeIdList = allBargainTeamCompetitiveTenderSchemeIdList, |
|||
IncludePurchaseSkuBasicInfo = 0 |
|||
}); |
|||
var victoryCompetitiveTenderTaskList = VictoryPlanSelection(allBargainTeamCompetitiveTenderTaskList, allBargainTeamPurchaseSchemeList); |
|||
var victoryCompetitiveTenderTaskIdList = victoryCompetitiveTenderTaskList.Select(ct => ct.Id).ToList(); |
|||
updateCompetitiveTenderTask = fsql.Update<SpuOptimizationCompetitiveTenderTask>(victoryCompetitiveTenderTaskIdList) |
|||
.Set(ct => ct.IsWin, true); |
|||
#endregion
|
|||
} |
|||
|
|||
#region 更新待优化议价组任务
|
|||
updateBargainTask = fsql.Update<SpuOptimizationBargainTeamTask>(currentspuOptimizationBargainTeamTask.Id) |
|||
.Set(sc => sc.IsOptimizationCompleted, true) |
|||
.Set(sc => sc.CompletionTime, DateTime.Now); |
|||
#endregion
|
|||
|
|||
fsql.Transaction(() => |
|||
{ |
|||
updateSpuTask?.ExecuteAffrows(); |
|||
updateBargainTask?.ExecuteAffrows(); |
|||
updateSpuSaleInfo?.ExecuteAffrows(); |
|||
updateTimeLimitTask?.ExecuteAffrows(); |
|||
updateCompetitiveTenderTask?.ExecuteAffrows(); |
|||
}); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 查询待优化任务
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
/// <param name="userId"></param>
|
|||
/// <returns></returns>
|
|||
/// <exception cref="BusinessException"></exception>
|
|||
public ListResponse<SpuOptimizationTaskResponse> GetNoCompletionSkuOptimizationTask(QueryNoCompletionOptimizationTaskRequest request, string userId) |
|||
{ |
|||
request.EndTime = request.EndTime.Date.AddDays(1).AddSeconds(-1); |
|||
var uInfo = userBusiness.GetisBargainTeamByUserId(userId); |
|||
|
|||
ISelect<SpuOptimizationTask> select = null; |
|||
if (request.SpuOptimizationTaskId != null && request.SpuOptimizationTaskId != 0) |
|||
{ |
|||
select = fsql.Select<SpuOptimizationTask>(request.SpuOptimizationTaskId); |
|||
} |
|||
else |
|||
{ |
|||
string spuKeyWords = string.Empty, skuKeyWords = string.Empty; |
|||
if (!string.IsNullOrEmpty(request.SpuOrSku)) |
|||
{ |
|||
if (Regex.IsMatch(request.SpuOrSku, @"^\d{2,10}$")) |
|||
spuKeyWords = request.SpuOrSku; |
|||
else if (Regex.IsMatch(request.SpuOrSku, @"^\w{2,20}$")) |
|||
skuKeyWords = request.SpuOrSku; |
|||
} |
|||
|
|||
select = fsql.Select<SpuOptimizationTask>() |
|||
.Where(t => t.IsOptimizationCompleted == false && |
|||
t.CreateTime >= request.StartTime && |
|||
t.CreateTime <= request.EndTime) |
|||
.WhereIf(request.BelongShopId != null && request.BelongShopId != 0, t => t.BelongShopId == request.BelongShopId) |
|||
.WhereIf(!string.IsNullOrEmpty(request.JDSku) || |
|||
!string.IsNullOrEmpty(skuKeyWords), t => fsql.Select<SkuOptimizationTask>() |
|||
.Where(st => st.SpuOptimizationTaskId == t.Id) |
|||
.WhereIf(!string.IsNullOrEmpty(request.JDSku), st => st.JDSkuId == request.JDSku) |
|||
.WhereIf(!string.IsNullOrEmpty(skuKeyWords), st => st.SkuId == skuKeyWords) |
|||
.Any()) |
|||
.WhereIf(!string.IsNullOrEmpty(request.TitleKeywords), t => t.ProductTitle.Contains(request.TitleKeywords)) |
|||
.WhereIf(!string.IsNullOrEmpty(spuKeyWords), t => t.ProductId == spuKeyWords); |
|||
} |
|||
|
|||
var taskList = select.OrderByDescending(t => t.CreateTime) |
|||
.Count(out var total) |
|||
.Page(request.PageIndex, request.PageSize) |
|||
.ToList<SpuOptimizationTaskResponse>(); |
|||
if (taskList.Count() == 0) |
|||
return new ListResponse<SpuOptimizationTaskResponse>() { TotalCount = 0, Items = null }; |
|||
|
|||
var spuTaskIdList = taskList.Select(t => t.Id).ToList(); |
|||
|
|||
#region 获取议价组任务
|
|||
var bargainTeamTaskList = fsql.Select<SpuOptimizationBargainTeamTask>() |
|||
.Where(sbt => spuTaskIdList.Contains(sbt.SpuOptimizationTaskId)) |
|||
.ToList<SpuOptimizationBargainTeamTaskResponse>(); |
|||
var bargainTeamIdList = bargainTeamTaskList.Select(x => x.BelongTeamId).Distinct().ToList(); |
|||
#endregion
|
|||
|
|||
#region 获取SKU优化任务
|
|||
var skuTaskList = fsql.Select<SkuOptimizationTask, Model.Db.ProductSku>() |
|||
.LeftJoin((st, ps) => st.SkuId == ps.Id) |
|||
.Where((st, ps) => spuTaskIdList.Contains(st.SpuOptimizationTaskId)) |
|||
.ToList((st, ps) => new SkuOptimizationTaskResponse |
|||
{ |
|||
CreateTime = st.CreateTime, |
|||
Id = st.Id, |
|||
JDSkuId = st.JDSkuId, |
|||
Logo = ps.Logo, |
|||
PreItemCount = st.PreItemCount, |
|||
PrePurchaseAmount = st.PrePurchaseAmount, |
|||
SkuId = st.SkuId, |
|||
SpuOptimizationTaskId = st.SpuOptimizationTaskId, |
|||
SkuName = ps.SkuName, |
|||
Price = ps.Price |
|||
}); |
|||
var skuIdList = skuTaskList.Select(st => st.SkuId).ToList(); |
|||
#endregion
|
|||
|
|||
#region 限时任务
|
|||
var timelimitTaskList = fsql.Select<TimeLimitTask>() |
|||
.Where(t => t.TaskType == Enums.TimeLimitTaskType.待议价任务 && spuTaskIdList.Contains(t.TaskId)) |
|||
.ToList<TimeLimitTaskResponse>(); |
|||
#endregion
|
|||
|
|||
#region 获取采购方案
|
|||
if (skuIdList.Count() == 0 && bargainTeamIdList.Count() == 0) |
|||
return new ListResponse<SpuOptimizationTaskResponse>() |
|||
{ |
|||
Items = null, |
|||
TotalCount = 0 |
|||
}; |
|||
var purchaseSchemeList = purchaseSchemeBusiness.GetPurchaseSchemeList(new QuerySchemeRequest() |
|||
{ |
|||
SkuIdList = skuIdList, |
|||
BargainTeamIdList = bargainTeamIdList, |
|||
IncludePurchaseSkuBasicInfo = 1, |
|||
IncludePurchaseSkuStatisticsInfo = 1 |
|||
}); |
|||
#endregion
|
|||
|
|||
#region 获取采购方案分组
|
|||
var purchaseSchemeGroupIdList = purchaseSchemeList.Select(ps => ps.SchemeGroupId).Distinct().ToList(); |
|||
var purchaseSchemeGroupList = fsql.Select<PurchaseSchemeGroup>(purchaseSchemeGroupIdList).ToList<PurchaseSchemeGroupResponse>(); |
|||
#endregion
|
|||
|
|||
foreach (var task in taskList) |
|||
{ |
|||
task.BargainTeamTaskList = bargainTeamTaskList.Where(sbt => sbt.SpuOptimizationTaskId == task.Id).ToList(); |
|||
task.TimeLimitTask = timelimitTaskList.FirstOrDefault(t => t.TaskId == task.Id); |
|||
if (task.TimeLimitTask != null) |
|||
task.TimeLimitTask.RemainingTime = timeLimitRules.CalculateLessTimeForWorkHour(task.TimeLimitTask.ExpirationTime.Value); |
|||
task.IsCompletedByCurrentTeam = task.BargainTeamTaskList.FirstOrDefault(sbt => sbt.BelongTeamId == uInfo.bargainTeam?.Id)?.IsOptimizationCompleted == true; |
|||
task.SkuOptimizationTaskList = skuTaskList.Where(st => st.SpuOptimizationTaskId == task.Id).ToList(); |
|||
|
|||
#region 组装sku优化任务的采购方案信息
|
|||
foreach (var skuTask in task.SkuOptimizationTaskList) |
|||
{ |
|||
skuTask.RelationSchemeList = purchaseSchemeList.Where(ps => ps.SkuId == skuTask.SkuId) |
|||
.Select(ps => new SkuOptimizationTaskPurchaseSchemeResponse() |
|||
{ |
|||
SchemeId = ps.Id, |
|||
SchemeGroupId = ps.SchemeGroupId, |
|||
IsFreeFreight = ps.IsFreeFreight, |
|||
LastPurchasePriceCost = ps.LastPurchasePriceCost, |
|||
PurchaseSchemeCost = ps.BargainingCost ?? ps.DefaultCost |
|||
}).ToList(); |
|||
} |
|||
#endregion
|
|||
|
|||
#region 合并分组/采购商/配件
|
|||
var currentTaskSkuIdList = task.SkuOptimizationTaskList.Select(st => st.SkuId).ToList(); |
|||
var currentPurchaseSchemeGroups = purchaseSchemeList.Where(p => currentTaskSkuIdList.Contains(p.SkuId) && |
|||
p.BelongBargainTeamId == uInfo.bargainTeam?.Id) |
|||
.GroupBy(p => p.SchemeGroupId) |
|||
.ToList(); |
|||
task.MergePurchaseScemeGroupList = new List<MergePurchaseSchemeGroupResponse>(); |
|||
foreach (var schemeGroup in currentPurchaseSchemeGroups) |
|||
{ |
|||
var mergeSchemeGroup = new MergePurchaseSchemeGroupResponse() |
|||
{ |
|||
Id = schemeGroup.Key, |
|||
GroupName = purchaseSchemeGroupList.FirstOrDefault(g => g.Id == schemeGroup.Key)?.GroupName |
|||
}; |
|||
task.MergePurchaseScemeGroupList.Add(mergeSchemeGroup); |
|||
|
|||
var schemeList = schemeGroup.ToList(); |
|||
|
|||
foreach (var scheme in schemeList) |
|||
{ |
|||
foreach (var psp in scheme.PurchaseSchemeProductList) |
|||
{ |
|||
var mergePurchaser = mergeSchemeGroup.PurchaserList.FirstOrDefault(p => p.Id == psp.PurchaserId); |
|||
if (mergePurchaser == null) |
|||
{ |
|||
mergePurchaser = scheme.PurchaserList.FirstOrDefault(p => p.Id == psp.PurchaserId)?.Map<MergePurchaserResponse>(); |
|||
if (mergePurchaser == null) |
|||
throw new BusinessException($"匹配采购商异常 schemeId {scheme.Id} pspProductId {psp.ProductId}"); |
|||
mergeSchemeGroup.PurchaserList.Add(mergePurchaser); |
|||
} |
|||
foreach (var pss in psp.PurchaseSchemeProductSkuList) |
|||
{ |
|||
var mergePss = mergePurchaser.MergePurchaseSchemeProductSkuList.FirstOrDefault(mpss => mpss.PurchaseSkuId == pss.PurchaseSkuId); |
|||
if (mergePss == null) |
|||
{ |
|||
mergePss = pss.Map<MergePurchaseSchemeProductSkuResponse>(); |
|||
mergePss.PurchaserId = mergePurchaser.Id; |
|||
mergePss.BelongSkuIdList.Add(pss.SkuId); |
|||
mergePss.PurchaseUrl = psp.PurchaseUrl; |
|||
mergePurchaser.MergePurchaseSchemeProductSkuList.Add(mergePss); |
|||
} |
|||
else if (!mergePss.BelongSkuIdList.Contains(pss.SkuId)) |
|||
mergePss.BelongSkuIdList.Add(pss.SkuId); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
#endregion
|
|||
} |
|||
|
|||
return new ListResponse<SpuOptimizationTaskResponse>() |
|||
{ |
|||
Items = taskList, |
|||
TotalCount = total |
|||
}; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 评选结果
|
|||
/// </summary>
|
|||
/// <param name="competitiveTenderTaskList"></param>
|
|||
/// <param name="purchaseSchemeList"></param>
|
|||
/// <returns></returns>
|
|||
private IList<SpuOptimizationCompetitiveTenderTask> VictoryPlanSelection(IList<SpuOptimizationCompetitiveTenderTask> competitiveTenderTaskList, |
|||
IList<PurchaseSchemeResponse> purchaseSchemeList) |
|||
{ |
|||
var victoryList = new List<SpuOptimizationCompetitiveTenderTask>(); |
|||
var psGroups = purchaseSchemeList.GroupBy(ps => ps.SchemeGroupId); |
|||
var winGroupKey = psGroups.Select(g => new { SchemeGroupId = g.Key, Cost = g.Sum(ps => ps.BargainingCost ?? ps.DefaultCost) }) |
|||
.OrderByDescending(x => x.Cost) |
|||
.FirstOrDefault(); |
|||
victoryList.AddRange(competitiveTenderTaskList.Where(ct => ct.SchemeGroupId == winGroupKey.SchemeGroupId)); |
|||
|
|||
//foreach (var psGroup in psGroups)
|
|||
//{
|
|||
// var psListOrderByCostDescList = psGroup.OrderByDescending(ps => ps.BargainingCost ?? ps.DefaultCost).ToList();
|
|||
// var minCostScheme = psListOrderByCostDescList.FirstOrDefault();
|
|||
// var competitiveTenderTask = competitiveTenderTaskList.FirstOrDefault(ct => ct.SchemeId == minCostScheme.Id);
|
|||
// victoryList.Add(competitiveTenderTask);
|
|||
//}
|
|||
return victoryList; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 限时任务超时回调
|
|||
/// </summary>
|
|||
/// <param name="taskId"></param>
|
|||
public void TimeLimitTaskTimeOutCallBack(long taskId) |
|||
{ |
|||
try |
|||
{ |
|||
var spuOptimizationTask = fsql.Select<SpuOptimizationTask>(taskId).ToOne(); |
|||
if (spuOptimizationTask == null) |
|||
throw new BusinessException($"待优化任务{taskId}不存在"); |
|||
if (spuOptimizationTask.IsOptimizationCompleted == true) |
|||
throw new BusinessException("待优化任务已完成"); |
|||
|
|||
IUpdate<SpuOptimizationTask> updateSpuTask = null; |
|||
IUpdate<SpuTotalSaleInfo> updateSpuSaleInfo = null; |
|||
IUpdate<SpuOptimizationCompetitiveTenderTask> updateCompetitiveTenderTask = null; |
|||
|
|||
var spuOptimizationBargainTeamTaskList = fsql.Select<SpuOptimizationBargainTeamTask>() |
|||
.Where(sbt => sbt.SpuOptimizationTaskId == taskId) |
|||
.ToList(); |
|||
|
|||
if (spuOptimizationBargainTeamTaskList.Any(sc => sc.IsOptimizationCompleted == true)) |
|||
{ |
|||
//任意一个议价组完成任务,该优化任务视为完成
|
|||
|
|||
var compleptionBargainTeamIdList = spuOptimizationBargainTeamTaskList.Where(sbt => sbt.IsOptimizationCompleted == true) |
|||
.Select(sbt => sbt.BelongTeamId) |
|||
.Distinct() |
|||
.ToList(); |
|||
|
|||
//已完成议价任务的竞标任务
|
|||
var compleptionBargainTeamCompetitiveTenderTaskList = fsql.Select<SpuOptimizationCompetitiveTenderTask>() |
|||
.Where(ct => ct.SpuOptimizationTaskId == taskId && |
|||
compleptionBargainTeamIdList.Contains(ct.BargainTeamId)) |
|||
.ToList(); |
|||
|
|||
#region 更新spu销量表
|
|||
var spuSaleInfo = fsql.Select<SpuTotalSaleInfo>(spuOptimizationTask.ProductId).ToOne(); |
|||
if (spuSaleInfo == null) |
|||
|
|||
throw new BusinessException($"未找到spu{spuOptimizationTask.ProductId}销量"); |
|||
|
|||
updateSpuSaleInfo = fsql.Update<SpuTotalSaleInfo>(spuOptimizationTask.ProductId) |
|||
.SetIf(spuSaleInfo.IsFirstPurchaseCompleted == false, s => s.IsFirstPurchaseCompleted, true) |
|||
.SetIf(spuSaleInfo.IsFirstPurchaseCompleted == false, s => s.FirstPurchaseCompletedItemCount == s.ItemCount) |
|||
.SetIf(spuSaleInfo.IsFirstPurchaseCompleted == true && |
|||
spuSaleInfo.IsFirstOptimizationCompleted == false, s => s.IsFirstOptimizationCompleted, true) |
|||
.SetIf(spuSaleInfo.IsFirstPurchaseCompleted == true && |
|||
spuSaleInfo.IsFirstOptimizationCompleted == false, s => s.FirstOptimizationCompletedItemCount == s.ItemCount) |
|||
.Set(s => s.LastOptimizationItemCount == s.ItemCount) |
|||
.Set(s => s.LastOptimizationTime, DateTime.Now) |
|||
.Set(s => s.UpdateTime, DateTime.Now); |
|||
#endregion
|
|||
|
|||
#region 更新待优化任务
|
|||
updateSpuTask = fsql.Update<SpuOptimizationTask>(spuOptimizationTask.Id) |
|||
.Set(t => t.IsOptimizationCompleted, true) |
|||
.Set(t => t.CompletionTime, DateTime.Now); |
|||
#endregion
|
|||
|
|||
#region 评选竞标结果
|
|||
var compleptionBargainTeamPurchaseSchemeIdList = compleptionBargainTeamCompetitiveTenderTaskList.Select(ct => ct.SchemeId).ToList(); |
|||
var compleptionBargainTeamPurchaseSchemeList = purchaseSchemeBusiness.GetPurchaseSchemeList(new QuerySchemeRequest() |
|||
{ |
|||
SchemeIdList = compleptionBargainTeamPurchaseSchemeIdList, |
|||
IncludePurchaseSkuBasicInfo = 0 |
|||
}); |
|||
var victoryCompetitiveTenderTaskList = VictoryPlanSelection(compleptionBargainTeamCompetitiveTenderTaskList, compleptionBargainTeamPurchaseSchemeList); |
|||
var victoryCompetitiveTenderTaskIdList = victoryCompetitiveTenderTaskList.Select(ct => ct.Id).ToList(); |
|||
updateCompetitiveTenderTask = fsql.Update<SpuOptimizationCompetitiveTenderTask>(victoryCompetitiveTenderTaskIdList) |
|||
.Set(ct => ct.IsWin, true); |
|||
#endregion
|
|||
} |
|||
|
|||
fsql.Transaction(() => |
|||
{ |
|||
updateSpuTask?.ExecuteAffrows(); |
|||
updateSpuSaleInfo?.ExecuteAffrows(); |
|||
updateCompetitiveTenderTask?.ExecuteAffrows(); |
|||
}); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
nLogManager.Default().Error(ex, "限时任务超时回调失败"); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 从优化任务模块删除采购方案分组(级联删除采购分组下的其他)
|
|||
/// </summary>
|
|||
/// <param name="request"></param>
|
|||
public void DeleteSchemeGroup(DeleteSchemeGroupFromSpuOptimizationTaskRequest request, string userId) |
|||
{ |
|||
_ = userBusiness.GetisBargainTeamByUserId(userId, true); |
|||
|
|||
var schemeIdList = fsql.Select<PurchaseScheme>().Where(ps => ps.SchemeGroupId == request.SchemeGroupId).ToList(ps => ps.Id); |
|||
|
|||
fsql.Transaction(() => |
|||
{ |
|||
fsql.Delete<PurchaseSchemeGroup>(request.SchemeGroupId).ExecuteAffrows(); |
|||
if (schemeIdList.Count() > 0) |
|||
{ |
|||
fsql.Delete<PurchaseScheme>(schemeIdList).ExecuteAffrows(); |
|||
fsql.Delete<PurchaseSchemeProduct>().Where(psp => schemeIdList.Contains(psp.SkuPurchaseSchemeId)).ExecuteAffrows(); |
|||
fsql.Delete<PurchaseSchemeProductSku>().Where(pss => schemeIdList.Contains(pss.SkuPurchaseSchemeId)).ExecuteAffrows(); |
|||
} |
|||
fsql.Delete<SpuOptimizationCompetitiveTenderTask>() |
|||
.Where(ct => ct.SchemeGroupId == request.SchemeGroupId && |
|||
ct.SpuOptimizationTaskId == request.SpuOptimizationId) |
|||
.ExecuteAffrows(); |
|||
}); |
|||
|
|||
|
|||
//var competitiveTenderTaskList = fsql.Select<SpuOptimizationCompetitiveTenderTask>()
|
|||
// .Where(ct => ct.SpuOptimizationTaskId == request.SpuOptimizationId &&
|
|||
// ct.SchemeGroupId == request.SchemeGroupId)
|
|||
// .ToList();
|
|||
|
|||
//var schemeIdList = competitiveTenderTaskList.Select(ct => ct.SchemeId).ToList();
|
|||
//purchaseSchemeBusiness.DeletePurchaseScheme(schemeIdList);
|
|||
|
|||
//var ctTaskIdList = competitiveTenderTaskList.Select(ct => ct.Id);
|
|||
//fsql.Delete<SpuOptimizationCompetitiveTenderTask>(ctTaskIdList).ExecuteAffrows();
|
|||
} |
|||
|
|||
public long GetNoCompletedSpuOptimizationTaskCount() |
|||
{ |
|||
return fsql.Select<SpuOptimizationTask>().Where(t => t.IsOptimizationCompleted == false).Count(); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,515 @@ |
|||
using BBWYB.Common.Log; |
|||
using BBWYB.Common.Models; |
|||
using BBWYB.Server.Model; |
|||
using BBWYB.Server.Model.Db; |
|||
using BBWYB.Server.Model.Dto; |
|||
using FreeSql; |
|||
using SDKAdapter.OperationPlatform.Models; |
|||
using Yitter.IdGenerator; |
|||
|
|||
namespace BBWYB.Server.Business.Sync |
|||
{ |
|||
public class ProductSyncBusiness : BaseBusiness, IDenpendency |
|||
{ |
|||
private ProductBusiness productBusiness; |
|||
private VenderBusiness venderBusiness; |
|||
private TaskSchedulerManager taskSchedulerManager; |
|||
|
|||
public ProductSyncBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, ProductBusiness productBusiness, VenderBusiness venderBusiness, TaskSchedulerManager taskSchedulerManager) : base(fsql, nLogManager, idGenerator) |
|||
{ |
|||
this.productBusiness = productBusiness; |
|||
this.venderBusiness = venderBusiness; |
|||
this.taskSchedulerManager = taskSchedulerManager; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 同步所有店铺的全部产品
|
|||
/// </summary>
|
|||
public void SyncAllShopAllProduct() |
|||
{ |
|||
var shopList = venderBusiness.GetShopList(platform: Enums.Platform.拳探); |
|||
//var shopList = venderBusiness.GetShopList(shopId: 9);
|
|||
foreach (var shop in shopList) |
|||
{ |
|||
Task.Factory.StartNew(() => SyncProduct(shop, true), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.SyncProductTaskScheduler); |
|||
} |
|||
} |
|||
|
|||
public void SyncAllShopUpdateProduct() |
|||
{ |
|||
var shopList = venderBusiness.GetShopList(platform: Enums.Platform.拳探); |
|||
//var shopList = venderBusiness.GetShopList(shopId: 9);
|
|||
foreach (var shop in shopList) |
|||
{ |
|||
Task.Factory.StartNew(() => SyncUpdateProduct(shop), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.SyncProductTaskScheduler); |
|||
} |
|||
} |
|||
|
|||
public void SyncOneShopUpdateProduct(long shopId) |
|||
{ |
|||
var shopList = venderBusiness.GetShopList(shopId, platform: Enums.Platform.拳探); |
|||
foreach (var shop in shopList) |
|||
{ |
|||
Task.Factory.StartNew(() => SyncUpdateProduct(shop), CancellationToken.None, TaskCreationOptions.LongRunning, taskSchedulerManager.SyncProductTaskScheduler); |
|||
} |
|||
} |
|||
|
|||
|
|||
private void SyncProduct(ShopResponse shop, bool IsSyncAllProduct = false) |
|||
{ |
|||
try |
|||
{ |
|||
var shopId = long.Parse(shop.ShopId); |
|||
var dbProductList = fsql.Select<Product>().Where(p => p.ShopId == shopId).ToList(); |
|||
var dbProductSkuList = fsql.Select<ProductSku>().Where(p => p.ShopId == shopId).ToList(); |
|||
|
|||
List<OP_ProductResponse> productList = new List<OP_ProductResponse>(); |
|||
List<OP_ProductSkuResponse> productSkuList = new List<OP_ProductSkuResponse>(); |
|||
|
|||
List<Product> insertProductList = new List<Product>(); |
|||
List<ProductSku> insertProductSkuList = new List<ProductSku>(); |
|||
|
|||
List<IUpdate<Product>> updateProductList = new List<IUpdate<Product>>(); |
|||
List<IUpdate<ProductSku>> updateProductSkuList = new List<IUpdate<ProductSku>>(); |
|||
|
|||
var request = new OP_QueryProductRequest() |
|||
{ |
|||
PageSize = 50, |
|||
PageIndex = 1, |
|||
AppKey = shop.AppKey, |
|||
AppSecret = shop.AppSecret, |
|||
AppToken = shop.AppToken, |
|||
Platform = SDKAdapter.AdapterEnums.PlatformType.拳探 |
|||
}; |
|||
|
|||
var requestSku = new OP_QueryProductSkuRequest() |
|||
{ |
|||
AppKey = shop.AppKey, |
|||
AppSecret = shop.AppSecret, |
|||
AppToken = shop.AppToken, |
|||
Platform = SDKAdapter.AdapterEnums.PlatformType.拳探, |
|||
//Spu = product.Id,
|
|||
PageSize = 50, |
|||
PageIndex = 1 |
|||
}; |
|||
|
|||
while (true) |
|||
{ |
|||
Console.WriteLine($"{shop.ShopName} 获取第{request.PageIndex}页产品"); |
|||
|
|||
var pListRes = productBusiness.GetProductList(request); |
|||
if (pListRes == null || pListRes.Items == null || pListRes.Items.Count == 0) |
|||
break; |
|||
productList.AddRange(pListRes.Items); |
|||
|
|||
foreach (var product in pListRes.Items) |
|||
{ |
|||
requestSku.Spu = product.Id; |
|||
var psListRes = productBusiness.GetProductSkuList(requestSku); |
|||
if (psListRes == null || psListRes.Items == null || psListRes.Items.Count == 0) |
|||
continue; |
|||
productSkuList.AddRange(psListRes.Items); |
|||
} |
|||
|
|||
if (pListRes.Items.Count < 50 || !IsSyncAllProduct) |
|||
break; |
|||
request.PageIndex++; |
|||
Thread.Sleep(1000); |
|||
} |
|||
|
|||
#region 找出新增的产品
|
|||
var newProductList = productList.Where(p => !dbProductList.Any(dp => dp.Id == p.Id)).ToList(); |
|||
if (newProductList.Count() > 0) |
|||
{ |
|||
insertProductList.AddRange(newProductList.Select(p => new Product() |
|||
{ |
|||
Id = p.Id, |
|||
Logo = p.Logo, |
|||
ProductName = p.Title, |
|||
ShopId = int.Parse(shop.ShopId), |
|||
State = p.State, |
|||
SyncTime = DateTime.Now, |
|||
UpdateTime = DateTime.Now, |
|||
UpperTime = p.CreateTime, |
|||
CategoryId = p.CategoryId, |
|||
CategoryName = p.CategoryName |
|||
})); |
|||
} |
|||
#endregion
|
|||
|
|||
#region 找出变化的产品 (状态,标题)
|
|||
var stateChangeProductList = productList.Where(p => dbProductList.Any(dp => dp.Id == p.Id && |
|||
(dp.State != p.State || |
|||
dp.ProductName != p.Title || |
|||
dp.CategoryId != p.CategoryId))).ToList(); |
|||
if (stateChangeProductList.Count() > 0) |
|||
{ |
|||
foreach (var product in stateChangeProductList) |
|||
{ |
|||
var update = fsql.Update<Product>(product.Id).Set(p => p.State, product.State) |
|||
.Set(p => p.ProductName, product.Title) |
|||
.Set(p => p.CategoryId, product.CategoryId) |
|||
.Set(p => p.CategoryName, product.CategoryName); |
|||
updateProductList.Add(update); |
|||
} |
|||
} |
|||
#endregion
|
|||
|
|||
#region 找出接口查不出的产品
|
|||
var goneProductList = dbProductList.Where(dp => !productList.Any(p => p.Id == dp.Id)).ToList(); |
|||
if (goneProductList.Count() > 0) |
|||
{ |
|||
var goneProductIdList = goneProductList.Select(p => p.Id).ToList(); |
|||
var update = fsql.Update<Product>().Set(p => p.State, 0).Where(p => goneProductIdList.Contains(p.Id)); |
|||
updateProductList.Add(update); |
|||
} |
|||
#endregion
|
|||
|
|||
#region 找出新增的SKU
|
|||
var newProductSkuList = productSkuList.Where(ps => !dbProductSkuList.Any(dps => dps.Id == ps.Id)).ToList(); |
|||
if (newProductSkuList.Count() > 0) |
|||
{ |
|||
insertProductSkuList.AddRange(newProductSkuList.Select(ps => new ProductSku() |
|||
{ |
|||
Id = ps.Id, |
|||
Logo = ps.Logo, |
|||
Price = ps.Price, |
|||
ProductId = ps.ProductId, |
|||
ShopId = int.Parse(shop.ShopId), |
|||
SkuName = ps.Title, |
|||
State = ps.State, |
|||
SyncTime = DateTime.Now, |
|||
UpdateTime = DateTime.Now, |
|||
UpperTime = ps.CreateTime, |
|||
CategoryId = ps.CategoryId, |
|||
CategoryName = ps.CategoryName |
|||
})); |
|||
} |
|||
#endregion
|
|||
|
|||
#region 找出状态变化的SKU
|
|||
var stateChangeProductSkuList = productSkuList.Where(ps => dbProductSkuList.Any(dps => dps.Id == ps.Id && |
|||
(dps.State != ps.State || |
|||
dps.SkuName != ps.Title || |
|||
dps.Price != ps.Price || |
|||
dps.Logo != ps.Logo || |
|||
dps.CategoryId != ps.CategoryId))).ToList(); |
|||
if (stateChangeProductSkuList.Count() > 0) |
|||
{ |
|||
foreach (var productSku in stateChangeProductSkuList) |
|||
{ |
|||
var update = fsql.Update<ProductSku>(productSku.Id).Set(p => p.State, productSku.State) |
|||
.Set(p => p.SkuName, productSku.Title) |
|||
.Set(p => p.Price, productSku.Price) |
|||
.Set(p => p.Logo, productSku.Logo) |
|||
.Set(p => p.CategoryId, productSku.CategoryId) |
|||
.Set(p => p.CategoryName, productSku.CategoryName); |
|||
updateProductSkuList.Add(update); |
|||
} |
|||
} |
|||
#endregion
|
|||
|
|||
#region 找出接口查不出的SKU
|
|||
var goneProductSkuList = dbProductSkuList.Where(dps => !productSkuList.Any(ps => ps.Id == dps.Id)).ToList(); |
|||
if (goneProductSkuList.Count() > 0) |
|||
{ |
|||
var goneProductSkuIdList = goneProductSkuList.Select(ps => ps.Id).ToList(); |
|||
var update = fsql.Update<ProductSku>().Set(ps => ps.State, 0).Where(ps => goneProductSkuIdList.Contains(ps.Id)); |
|||
updateProductSkuList.Add(update); |
|||
} |
|||
#endregion
|
|||
|
|||
|
|||
fsql.Transaction(() => |
|||
{ |
|||
if (insertProductList.Count() > 0) |
|||
fsql.Insert(insertProductList).ExecuteAffrows(); |
|||
if (insertProductSkuList.Count() > 0) |
|||
fsql.Insert(insertProductSkuList).ExecuteAffrows(); |
|||
}); |
|||
|
|||
{ |
|||
var tempUpdateList = new List<IUpdate<Product>>(); |
|||
if (updateProductList.Count() > 0) |
|||
{ |
|||
for (var i = 0; i < updateProductList.Count(); i++) |
|||
{ |
|||
tempUpdateList.Add(updateProductList[i]); |
|||
if (tempUpdateList.Count() == 20) |
|||
{ |
|||
fsql.Transaction(() => |
|||
{ |
|||
foreach (var update in tempUpdateList) |
|||
update.ExecuteAffrows(); |
|||
}); |
|||
tempUpdateList.Clear(); |
|||
} |
|||
} |
|||
if (tempUpdateList.Count() > 0) |
|||
{ |
|||
fsql.Transaction(() => |
|||
{ |
|||
foreach (var update in tempUpdateList) |
|||
update.ExecuteAffrows(); |
|||
}); |
|||
tempUpdateList.Clear(); |
|||
updateProductList.Clear(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
{ |
|||
var tempUpdateList = new List<IUpdate<ProductSku>>(); |
|||
if (updateProductSkuList.Count() > 0) |
|||
{ |
|||
for (var i = 0; i < updateProductSkuList.Count(); i++) |
|||
{ |
|||
tempUpdateList.Add(updateProductSkuList[i]); |
|||
if (tempUpdateList.Count() == 20) |
|||
{ |
|||
fsql.Transaction(() => |
|||
{ |
|||
foreach (var update in tempUpdateList) |
|||
update.ExecuteAffrows(); |
|||
}); |
|||
tempUpdateList.Clear(); |
|||
} |
|||
} |
|||
if (tempUpdateList.Count() > 0) |
|||
{ |
|||
fsql.Transaction(() => |
|||
{ |
|||
foreach (var update in tempUpdateList) |
|||
update.ExecuteAffrows(); |
|||
}); |
|||
tempUpdateList.Clear(); |
|||
updateProductSkuList.Clear(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
Console.WriteLine($"{shop.ShopName}同步完毕,新增spu{insertProductList.Count()}个,新增sku{insertProductSkuList.Count()}个,更新spu{updateProductList.Count()}个,更新sku{updateProductSkuList.Count()}个"); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
nLogManager.Default().Error(ex, $"SyncProduct ShopId:{shop.ShopName}"); |
|||
} |
|||
} |
|||
|
|||
private void SyncUpdateProduct(ShopResponse shop) |
|||
{ |
|||
try |
|||
{ |
|||
List<Product> dbProductList; |
|||
List<ProductSku> dbProductSkuList; |
|||
List<OP_ProductResponse> opProductList = new List<OP_ProductResponse>(); |
|||
List<OP_ProductSkuResponse> opProductSkuList = new List<OP_ProductSkuResponse>(); |
|||
|
|||
List<Product> insertProductList = new List<Product>(); |
|||
List<ProductSku> insertProductSkuList = new List<ProductSku>(); |
|||
List<IUpdate<Product>> updateProductList = new List<IUpdate<Product>>(); |
|||
List<IUpdate<ProductSku>> updateProductSkuList = new List<IUpdate<ProductSku>>(); |
|||
|
|||
#region 查询变化的spu
|
|||
{ |
|||
#region 上架的spu
|
|||
var spuRequest = new OP_QueryProductRequest() |
|||
{ |
|||
PageSize = 50, |
|||
PageIndex = 1, |
|||
AppKey = shop.AppKey, |
|||
AppSecret = shop.AppSecret, |
|||
AppToken = shop.AppToken, |
|||
Platform = SDKAdapter.AdapterEnums.PlatformType.拳探, |
|||
//Spu = "9985",
|
|||
UpdateStartTime = DateTime.Now.AddHours(-1), //DateTime.Parse("2024-04-02 12:00:00") DateTime.Now.AddHours(-1),
|
|||
UpdateEndTime = DateTime.Now //DateTime.Parse("2024-04-02 12:02:00") DateTime.Now
|
|||
}; |
|||
while (true) |
|||
{ |
|||
var response = productBusiness.GetProductList(spuRequest); |
|||
if (response == null || response.Items == null || response.Items.Count == 0) |
|||
break; |
|||
|
|||
opProductList.AddRange(response.Items); |
|||
if (response.Items.Count < spuRequest.PageSize) |
|||
break; |
|||
|
|||
spuRequest.PageIndex++; |
|||
} |
|||
#endregion
|
|||
|
|||
#region 下架的spu
|
|||
spuRequest.PageIndex = 1; |
|||
spuRequest.ProductState = SDKAdapter.AdapterEnums.ProuctState.下架; |
|||
while (true) |
|||
{ |
|||
var response = productBusiness.GetProductList(spuRequest); |
|||
if (response == null || response.Items == null || response.Items.Count == 0) |
|||
break; |
|||
|
|||
opProductList.AddRange(response.Items); |
|||
if (response.Items.Count < spuRequest.PageSize) |
|||
break; |
|||
|
|||
spuRequest.PageIndex++; |
|||
} |
|||
#endregion
|
|||
} |
|||
#endregion
|
|||
|
|||
#region 对比spu
|
|||
|
|||
var spuIdList = opProductList.Select(x => x.Id); |
|||
dbProductList = fsql.Select<Product>(spuIdList).ToList(); |
|||
|
|||
#region 找出新增的产品
|
|||
var newProductList = opProductList.Where(p => !dbProductList.Any(dp => dp.Id == p.Id)).ToList(); |
|||
if (newProductList.Count() > 0) |
|||
{ |
|||
insertProductList.AddRange(newProductList.Select(p => new Product() |
|||
{ |
|||
Id = p.Id, |
|||
Logo = p.Logo, |
|||
ProductName = p.Title, |
|||
ShopId = int.Parse(shop.ShopId), |
|||
State = p.State, |
|||
SyncTime = DateTime.Now, |
|||
UpdateTime = p.UpdateTime, |
|||
UpperTime = p.CreateTime, |
|||
CategoryId = p.CategoryId, |
|||
CategoryName = p.CategoryName |
|||
})); |
|||
} |
|||
#endregion
|
|||
|
|||
#region 找出变化的产品 (状态,标题,类目)
|
|||
var stateChangeProductList = opProductList.Where(p => dbProductList.Any(dp => dp.Id == p.Id && |
|||
(dp.State != p.State || |
|||
dp.ProductName != p.Title || |
|||
dp.CategoryId != p.CategoryId))).ToList(); |
|||
if (stateChangeProductList.Count() > 0) |
|||
{ |
|||
foreach (var product in stateChangeProductList) |
|||
{ |
|||
var update = fsql.Update<Product>(product.Id).Set(p => p.State, product.State) |
|||
.Set(p => p.ProductName, product.Title) |
|||
.Set(p => p.CategoryId, product.CategoryId) |
|||
.Set(p => p.CategoryName, product.CategoryName) |
|||
.Set(p => p.UpdateTime, product.UpdateTime); |
|||
updateProductList.Add(update); |
|||
} |
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
#endregion
|
|||
|
|||
#region 对比sku
|
|||
|
|||
foreach (var product in opProductList) |
|||
{ |
|||
var skuRequest = new OP_QueryProductSkuRequest() |
|||
{ |
|||
AppKey = shop.AppKey, |
|||
AppSecret = shop.AppSecret, |
|||
AppToken = shop.AppToken, |
|||
Platform = SDKAdapter.AdapterEnums.PlatformType.拳探, |
|||
Spu = product.Id, |
|||
PageSize = 50, |
|||
PageIndex = 1, |
|||
}; |
|||
|
|||
var response = productBusiness.GetProductSkuList(skuRequest); |
|||
if (response == null || response.Items == null || response.Items.Count == 0) |
|||
continue; |
|||
opProductSkuList.AddRange(response.Items); |
|||
} |
|||
|
|||
var skuIdList = opProductSkuList.Select(x => x.Id); |
|||
dbProductSkuList = fsql.Select<ProductSku>(skuIdList).ToList(); |
|||
|
|||
#region 找出新增的SKU
|
|||
var newProductSkuList = opProductSkuList.Where(ps => !dbProductSkuList.Any(dps => dps.Id == ps.Id)).ToList(); |
|||
if (newProductSkuList.Count() > 0) |
|||
{ |
|||
insertProductSkuList.AddRange(newProductSkuList.Select(ps => new ProductSku() |
|||
{ |
|||
Id = ps.Id, |
|||
Logo = ps.Logo, |
|||
Price = ps.Price, |
|||
ProductId = ps.ProductId, |
|||
ShopId = int.Parse(shop.ShopId), |
|||
SkuName = ps.Title, |
|||
State = ps.State, |
|||
SyncTime = DateTime.Now, |
|||
UpdateTime = DateTime.Now, |
|||
UpperTime = ps.CreateTime, |
|||
CategoryId = ps.CategoryId, |
|||
CategoryName = ps.CategoryName |
|||
})); |
|||
} |
|||
#endregion
|
|||
|
|||
#region 找出状态变化的SKU
|
|||
var stateChangeProductSkuList = opProductSkuList.Where(ps => dbProductSkuList.Any(dps => dps.Id == ps.Id && |
|||
(dps.State != ps.State || |
|||
dps.SkuName != ps.Title || |
|||
dps.Price != ps.Price || |
|||
dps.Logo != ps.Logo || |
|||
dps.CategoryId != ps.CategoryId))).ToList(); |
|||
if (stateChangeProductSkuList.Count() > 0) |
|||
{ |
|||
foreach (var productSku in stateChangeProductSkuList) |
|||
{ |
|||
var update = fsql.Update<ProductSku>(productSku.Id).Set(p => p.State, productSku.State) |
|||
.Set(p => p.SkuName, productSku.Title) |
|||
.Set(p => p.Price, productSku.Price) |
|||
.Set(p => p.Logo, productSku.Logo) |
|||
.Set(p => p.CategoryId, productSku.CategoryId) |
|||
.Set(p => p.CategoryName, productSku.CategoryName); |
|||
updateProductSkuList.Add(update); |
|||
} |
|||
} |
|||
#endregion
|
|||
|
|||
#region 找出接口查不出的SKU
|
|||
var goneProductSkuList = dbProductSkuList.Where(dps => !opProductSkuList.Any(ps => ps.Id == dps.Id)).ToList(); |
|||
if (goneProductSkuList.Count() > 0) |
|||
{ |
|||
var goneProductSkuIdList = goneProductSkuList.Select(ps => ps.Id).ToList(); |
|||
var update = fsql.Update<ProductSku>().Set(ps => ps.State, 0).Where(ps => goneProductSkuIdList.Contains(ps.Id)); |
|||
updateProductSkuList.Add(update); |
|||
} |
|||
#endregion
|
|||
|
|||
#endregion
|
|||
|
|||
#region 数据库操作
|
|||
fsql.Transaction(() => |
|||
{ |
|||
if (insertProductList.Count() > 0) |
|||
fsql.Insert(insertProductList).ExecuteAffrows(); |
|||
if (insertProductSkuList.Count() > 0) |
|||
fsql.Insert(insertProductSkuList).ExecuteAffrows(); |
|||
if (updateProductList.Count() > 0) |
|||
{ |
|||
foreach (var update in updateProductList) |
|||
update.ExecuteAffrows(); |
|||
} |
|||
if (updateProductSkuList.Count() > 0) |
|||
{ |
|||
foreach (var update in updateProductSkuList) |
|||
update.ExecuteAffrows(); |
|||
} |
|||
}); |
|||
#endregion
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
nLogManager.Default().Error(ex, $"SyncProduct ShopId:{shop.ShopName}"); |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,298 @@ |
|||
using BBWYB.Common.Models; |
|||
using BBWYB.Server.Model; |
|||
|
|||
namespace BBWYB.Server.Business |
|||
{ |
|||
public class TimeLimitRules : IDenpendency |
|||
{ |
|||
/// <summary>
|
|||
/// 计算到期时间算法字典
|
|||
/// </summary>
|
|||
private IDictionary<Enums.TimeLimitTaskType, Func<DateTime, DateTime>> calculateExpirationTimeAlgorithmDictionary; |
|||
|
|||
public TimeLimitRules() |
|||
{ |
|||
calculateExpirationTimeAlgorithmDictionary = new Dictionary<Enums.TimeLimitTaskType, Func<DateTime, DateTime>>() |
|||
{ |
|||
{ Enums.TimeLimitTaskType.采购任务, CalculateExpirationTimeFor5WorkHour }, |
|||
{ Enums.TimeLimitTaskType.合格证拟定任务, CalculateExpirationTimeFor8WorkHour }, |
|||
{ Enums.TimeLimitTaskType.待核算任务, CalculateExpirationTimeFor8WorkHour }, |
|||
{ Enums.TimeLimitTaskType.待议价任务, CalculateExpirationTimeFor8WorkHour }, |
|||
{ Enums.TimeLimitTaskType.合格证补充任务, CalculateExpirationTimeFor2WorkHour } |
|||
}; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 计算到期时间
|
|||
/// </summary>
|
|||
/// <param name="timeLimitTaskType">任务类型</param>
|
|||
/// <param name="startTime">起点计算时间</param>
|
|||
/// <returns></returns>
|
|||
public DateTime CalculateExpirationTime(Enums.TimeLimitTaskType timeLimitTaskType, DateTime startTime) |
|||
{ |
|||
return calculateExpirationTimeAlgorithmDictionary[timeLimitTaskType](startTime); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 计算需要追加的天数,周六追加2天,周日追加1天
|
|||
/// </summary>
|
|||
/// <param name="dayOfWeek"></param>
|
|||
/// <returns></returns>
|
|||
private int CalculateAddDay(DayOfWeek dayOfWeek) |
|||
{ |
|||
if (dayOfWeek == DayOfWeek.Saturday) |
|||
return 2; |
|||
return 1; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 8小时工作时计算到期时间
|
|||
/// </summary>
|
|||
/// <param name="startTime">起点时间</param>
|
|||
/// <returns></returns>
|
|||
private DateTime CalculateExpirationTimeFor8WorkHour(DateTime startTime) |
|||
{ |
|||
int addDay = 0, addHour = 0, addSeconds = 0; |
|||
//先确定是否为周日
|
|||
if (startTime.DayOfWeek == DayOfWeek.Sunday) |
|||
{ |
|||
addDay = 1; |
|||
addHour = 18; |
|||
} |
|||
else |
|||
{ |
|||
if (startTime.Hour < 9) |
|||
addHour = 18; |
|||
else if (startTime.Hour >= 9 && startTime.Hour < 12) |
|||
{ |
|||
//计算从起点时间的9点开始到当前时间的时差
|
|||
var timeSpan = startTime - startTime.Date.AddHours(9); |
|||
if (timeSpan.TotalMinutes <= 5) |
|||
{ |
|||
//从9点开始小于5分钟以内,以当天18点结束
|
|||
addHour = 18; |
|||
} |
|||
else |
|||
{ |
|||
addDay = CalculateAddDay(startTime.DayOfWeek); |
|||
addHour = 9; |
|||
addSeconds = (int)timeSpan.TotalSeconds; |
|||
} |
|||
} |
|||
else if (startTime.Hour >= 12 && startTime.Hour < 13) |
|||
{ |
|||
//下一个工作日的12点结束
|
|||
addDay = CalculateAddDay(startTime.DayOfWeek); |
|||
addHour = 12; |
|||
} |
|||
else if (startTime.Hour >= 13 && startTime.Hour < 18) |
|||
{ |
|||
var timeSpan = startTime - startTime.Date.AddHours(13); |
|||
//到下一个工作日的当前时间结束
|
|||
addDay = CalculateAddDay(startTime.DayOfWeek); |
|||
addHour = 13; |
|||
addSeconds = (int)timeSpan.TotalSeconds; |
|||
|
|||
} |
|||
else if (startTime.Hour >= 18) |
|||
{ |
|||
//下一个工作日的18点结束
|
|||
addDay = CalculateAddDay(startTime.DayOfWeek); |
|||
addHour = 18; |
|||
} |
|||
} |
|||
return startTime.Date.AddDays(addDay).AddHours(addHour).AddSeconds(addSeconds); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 2小时工作时计算到期时间
|
|||
/// </summary>
|
|||
/// <param name="startTime">起点时间</param>
|
|||
/// <returns></returns>
|
|||
private DateTime CalculateExpirationTimeFor2WorkHour(DateTime startTime) |
|||
{ |
|||
int addDay = 0, addHour = 0, addSeconds = 0; |
|||
//先确定是否为周日
|
|||
if (startTime.DayOfWeek == DayOfWeek.Sunday) |
|||
{ |
|||
addDay = 1; |
|||
addHour = 11; |
|||
} |
|||
else |
|||
{ |
|||
if (startTime.Hour < 9) |
|||
addHour = 11; |
|||
else if (startTime.Hour >= 9 && startTime.Hour < 12) |
|||
{ |
|||
//如果在10点钟以前,则加两个小时
|
|||
if (startTime.Hour < 10) |
|||
{ |
|||
addHour = 11; |
|||
addSeconds = Convert.ToInt32((startTime - startTime.Date.AddHours(9)).TotalSeconds); |
|||
} |
|||
else |
|||
{ |
|||
addHour = 13; |
|||
var to12senconds = Convert.ToInt32((startTime.Date.AddHours(12) - startTime).TotalSeconds); |
|||
addSeconds = 7200 - to12senconds; |
|||
} |
|||
} |
|||
else if (startTime.Hour >= 12 && startTime.Hour < 13) |
|||
{ |
|||
addHour = 15; |
|||
} |
|||
else if (startTime.Hour >= 13 && startTime.Hour < 18) |
|||
{ |
|||
if (startTime.Hour < 16) |
|||
{ |
|||
addHour = startTime.Hour + 2; |
|||
addSeconds = startTime.Minute * 60 + startTime.Second; |
|||
} |
|||
else if (startTime.Hour == 16 && startTime.Minute <= 5) |
|||
{ |
|||
//从16点开始小于5分钟以内,以当天18点结束
|
|||
addHour = 18; |
|||
} |
|||
else |
|||
{ |
|||
addDay = CalculateAddDay(startTime.DayOfWeek); |
|||
addHour = 9; |
|||
var to18senconds = Convert.ToInt32((startTime.Date.AddHours(18) - startTime).TotalSeconds); |
|||
addSeconds = 7200 - to18senconds; |
|||
} |
|||
} |
|||
else if (startTime.Hour >= 18) |
|||
{ |
|||
//下一个工作日的18点结束
|
|||
addDay = CalculateAddDay(startTime.DayOfWeek); |
|||
addHour = 11; |
|||
} |
|||
} |
|||
return startTime.Date.AddDays(addDay).AddHours(addHour).AddSeconds(addSeconds); |
|||
} |
|||
|
|||
private DateTime CalculateExpirationTimeFor5WorkHour(DateTime startTime) |
|||
{ |
|||
int addDay = 0, addHour = 0, addSeconds = 0; |
|||
//先确定是否为周日
|
|||
if (startTime.DayOfWeek == DayOfWeek.Sunday) |
|||
{ |
|||
addDay = 1; |
|||
addHour = 15; |
|||
} |
|||
else |
|||
{ |
|||
if (startTime.Hour < 9) |
|||
addHour = 15; |
|||
else if (startTime.Hour >= 9 && startTime.Hour < 12) |
|||
{ |
|||
addHour = 13; |
|||
var to12senconds = Convert.ToInt32((startTime.Date.AddHours(12) - startTime).TotalSeconds); |
|||
addSeconds = 18000 - to12senconds; |
|||
} |
|||
else if (startTime.Hour >= 12 && startTime.Hour < 13) |
|||
{ |
|||
addHour = 18; |
|||
} |
|||
else if (startTime.Hour >= 13 && startTime.Hour < 18) |
|||
{ |
|||
if (startTime.Hour == 13 && startTime.Minute <= 5) |
|||
{ |
|||
//从16点开始小于5分钟以内,以当天18点结束
|
|||
addHour = 18; |
|||
} |
|||
else |
|||
{ |
|||
addDay = CalculateAddDay(startTime.DayOfWeek); |
|||
addHour = 9; |
|||
var to18senconds = Convert.ToInt32((startTime.Date.AddHours(18) - startTime).TotalSeconds); |
|||
addSeconds = 18000 - to18senconds; |
|||
if (addSeconds > 10800) |
|||
{ |
|||
//到第二天9点开始也超过3个小时,就从下午13点开始计算
|
|||
addHour = 13; |
|||
addSeconds -= 10800; |
|||
} |
|||
} |
|||
} |
|||
else if (startTime.Hour >= 18) |
|||
{ |
|||
//下一个工作日的18点结束
|
|||
addDay = CalculateAddDay(startTime.DayOfWeek); |
|||
addHour = 15; |
|||
} |
|||
} |
|||
return startTime.Date.AddDays(addDay).AddHours(addHour).AddSeconds(addSeconds); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 计算剩余任务时间(秒)
|
|||
/// </summary>
|
|||
/// <param name="expirationTime"></param>
|
|||
/// <returns></returns>
|
|||
public long CalculateLessTimeForWorkHour(DateTime expirationTime) |
|||
{ |
|||
if (DateTime.Now >= expirationTime) |
|||
return 0; |
|||
|
|||
//强制过期时间在工作时间点内
|
|||
if (expirationTime.Hour < 9) |
|||
expirationTime = expirationTime.Date.AddHours(9); |
|||
else if (expirationTime.Hour >= 12 && expirationTime.Minute > 0 && expirationTime.Hour < 13) //排除整点结束的到期时间
|
|||
expirationTime = expirationTime.Date.AddHours(12); |
|||
else if (expirationTime.Hour >= 18 && expirationTime.Minute > 0) //排除整点结束的到期时间
|
|||
expirationTime = expirationTime.Date.AddDays(CalculateAddDay(expirationTime.DayOfWeek)).AddHours(9); |
|||
|
|||
var startTime = DateTime.Now; |
|||
long lessTime = 0; |
|||
while (true) |
|||
{ |
|||
//把非工作时间段转换成工作时间段
|
|||
if (startTime.DayOfWeek == DayOfWeek.Sunday) |
|||
{ |
|||
startTime = startTime.Date.AddDays(1).AddHours(9); |
|||
} |
|||
else |
|||
{ |
|||
if (startTime.Hour < 9) |
|||
startTime = startTime.Date.AddHours(9); |
|||
else if (startTime.Hour >= 12 && startTime.Hour < 13) |
|||
startTime = startTime.Date.AddHours(13); |
|||
else if (startTime.Hour >= 18 && startTime.Minute > 0) |
|||
startTime = startTime.Date.AddDays(CalculateAddDay(startTime.DayOfWeek)).AddHours(9); |
|||
} |
|||
|
|||
//计算上午工作时间段
|
|||
if (startTime.Hour >= 9 && startTime.Hour < 12) |
|||
{ |
|||
if (expirationTime <= startTime.Date.AddHours(12)) |
|||
{ |
|||
lessTime += Convert.ToInt32((expirationTime - startTime).TotalSeconds); |
|||
break; |
|||
} |
|||
else |
|||
{ |
|||
lessTime += 10800; |
|||
startTime = startTime.Date.AddHours(13); |
|||
} |
|||
} |
|||
|
|||
//计算下午工作时间段
|
|||
if (startTime.Hour >= 13 && startTime.Hour < 18) |
|||
{ |
|||
if (expirationTime <= startTime.Date.AddHours(18)) |
|||
{ |
|||
lessTime += Convert.ToInt32((expirationTime - startTime).TotalSeconds); |
|||
break; |
|||
} |
|||
else |
|||
{ |
|||
lessTime += 18000; |
|||
startTime = startTime.Date.AddDays(CalculateAddDay(startTime.DayOfWeek)).AddHours(9); |
|||
} |
|||
} |
|||
} |
|||
return lessTime; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,45 @@ |
|||
using BBWYB.Common.Models; |
|||
using BBWYB.Server.Model.Db; |
|||
|
|||
namespace BBWYB.Server.Business |
|||
{ |
|||
public class UserBusiness : IDenpendency |
|||
{ |
|||
private FreeSqlMultiDBManager fsqlManager; |
|||
|
|||
public UserBusiness(FreeSqlMultiDBManager fsqlManager) |
|||
{ |
|||
this.fsqlManager = fsqlManager; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取指定用户的议价组信息
|
|||
/// </summary>
|
|||
/// <param name="userId"></param>
|
|||
/// <param name="throwExWhenUserNotBelongYJ">当用户不属于议价组团队是否抛出错误</param>
|
|||
/// <returns></returns>
|
|||
/// <exception cref="BusinessException"></exception>
|
|||
public (User user, Userdepartment mainTeam, bool isBargainTeam, Userdepartment? bargainTeam) GetisBargainTeamByUserId(string userId, bool throwExWhenUserNotBelongYJ = false) |
|||
{ |
|||
var user = fsqlManager.MDSfsql.Select<User>(userId).ToOne(); |
|||
if (user == null) |
|||
throw new BusinessException("用户不存在"); |
|||
if (string.IsNullOrEmpty(user.DepartmentId)) |
|||
throw new BusinessException("该用户没有归属部门"); |
|||
var queryDeparmentIdList = new List<string>() { user.DepartmentId }; |
|||
if (!string.IsNullOrEmpty(user.SonDepartmentIds)) |
|||
queryDeparmentIdList.AddRange(user.SonDepartmentIds.Split(",", StringSplitOptions.RemoveEmptyEntries)); |
|||
|
|||
var departmentList = fsqlManager.MDSfsql.Select<Userdepartment>(queryDeparmentIdList).ToList(); |
|||
if (departmentList.Count() == 0) |
|||
throw new BusinessException("未获取部门"); |
|||
var mainTeam = departmentList.FirstOrDefault(d => d.Id == user.DepartmentId); |
|||
if (mainTeam == null) |
|||
throw new BusinessException("主部门不存在"); |
|||
var bargainTeam = departmentList.FirstOrDefault(d => d.ParentDepartmentId == "1760971468360912896"); |
|||
if (throwExWhenUserNotBelongYJ && bargainTeam == null) |
|||
throw new BusinessException("子部门不属于议价组"); |
|||
return (user, mainTeam, bargainTeam != null, bargainTeam); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,57 @@ |
|||
using FreeSql.DataAnnotations; |
|||
using System; |
|||
|
|||
namespace BBWYB.Server.Model.Db.BBWY |
|||
{ |
|||
|
|||
[Table(Name = "productsku", DisableSyncStructure = true)] |
|||
public partial class ProductSku |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// SKU
|
|||
/// </summary>
|
|||
[Column(StringLength = 50, IsPrimary = true, IsNullable = false)] |
|||
public string Id { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
|
|||
public string Logo { get; set; } |
|||
|
|||
[Column(DbType = "int(1)", MapType = typeof(int))] |
|||
public Enums.Platform Platform { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 售价
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? Price { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// SPU
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string ProductId { get; set; } |
|||
|
|||
|
|||
public long? ShopId { get; set; } |
|||
|
|||
|
|||
public string Title { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 京东Sku状态【1:上架 2:下架 4:删除】
|
|||
/// </summary>
|
|||
public int? State { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 三级类目Id
|
|||
/// </summary>
|
|||
public int? CategoryId { get; set; } |
|||
|
|||
public string CategoryName { get; set; } |
|||
} |
|||
|
|||
} |
@ -0,0 +1,130 @@ |
|||
using FreeSql.DataAnnotations; |
|||
using Newtonsoft.Json; |
|||
using System; |
|||
|
|||
namespace BBWYB.Server.Model.Db.BBWY |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 采购商品表
|
|||
/// </summary>
|
|||
[Table(Name = "purchaseordersku", DisableSyncStructure = true)] |
|||
public partial class PurchaseOrderSku |
|||
{ |
|||
[Column(IsPrimary = true)] |
|||
public long Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 打包耗材费
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? ConsumableAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 头程运费
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? FirstFreight { get; set; } = 0.00M; |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 入仓费
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? InStorageAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// Sku Logo
|
|||
/// </summary>
|
|||
|
|||
public string Logo { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 单价
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? Price { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 采购货款
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? ProductAmount { get; set; } |
|||
|
|||
[Column(StringLength = 100)] |
|||
public string ProductId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购金额(采购货款+采购运费)
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? PurchaseAmount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购运费
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? PurchaseFreight { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购单Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 100)] |
|||
public string PurchaseOrderId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购方案Id
|
|||
/// </summary>
|
|||
|
|||
public long? PurchaseSchemeId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购SkuId串
|
|||
/// </summary>
|
|||
[Column(StringLength = 500)] |
|||
public string PurchaseSkuIds { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 质检费
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? QualityInspectionAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 采购数量
|
|||
/// </summary>
|
|||
|
|||
public int? Quantity { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 店铺Id
|
|||
/// </summary>
|
|||
|
|||
public long? ShopId { get; set; } |
|||
|
|||
[Column(StringLength = 100)] |
|||
public string SkuId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Sku标题
|
|||
/// </summary>
|
|||
|
|||
public string SkuTitle { get; set; } |
|||
|
|||
[Column(MapType = typeof(int?))] |
|||
public Enums.StockType? StockType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 齐库任务Id
|
|||
/// </summary>
|
|||
public long? QiKuTaskId { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,99 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db.BBWY |
|||
{ |
|||
|
|||
[Table(Name = "skurecentcost", DisableSyncStructure = true)] |
|||
public partial class SkuRecentCost |
|||
{ |
|||
|
|||
[Column(StringLength = 50, IsPrimary = true, IsNullable = false)] |
|||
public string SkuId { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string ProductId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 最近一笔订单来源
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string RecentOrderId { get; set; } |
|||
|
|||
[Column(DbType = "bigint")] |
|||
public long? ShopId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 耗材费(单件)
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(20,2)")] |
|||
public decimal? SingleConsumableAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 发货运费(单件)
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(20,2)")] |
|||
public decimal? SingleDeliveryFreight { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 头程运费(单件)
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(20,2)")] |
|||
public decimal? SingleFirstFreight { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购运费(单件)
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(20,2)")] |
|||
public decimal? SingleFreight { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 入仓操作费(单件)
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(20,2)")] |
|||
public decimal? SingleInStorageAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 操作费(单件)
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(20,2)")] |
|||
public decimal? SingleOperationAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 出仓操作费(单件)
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(20,2)")] |
|||
public decimal? SingleOutStorageAmount { get; set; } = 0.00M; |
|||
|
|||
///// <summary>
|
|||
///// 退货入仓操作费(单件)
|
|||
///// </summary>
|
|||
//[Column(DbType = "decimal(20,2)")]
|
|||
//public decimal? SingleRefundInStorageAmount { get; set; } = 0.00M;
|
|||
|
|||
/// <summary>
|
|||
/// SKU成本(单件)
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(20,2)")] |
|||
public decimal? SingleSkuAmount { get; set; } |
|||
|
|||
///// <summary>
|
|||
///// 仓储费(单件)
|
|||
///// </summary>
|
|||
//[Column(DbType = "decimal(20,2)")]
|
|||
//public decimal? SingleStorageAmount { get; set; } = 0.00M;
|
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? UpdateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 包装人工单价
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(20,2)")] |
|||
public decimal? SinglePackagingLaborAmount { get; set; } = 0.00M; |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,2 @@ |
|||
|
|||
FreeSql.Generator -Razor 1 -NameOptions 1,0,0,0 -NameSpace BBWYB.Server.Model.Db -DB "MySql,data source=rm-bp1508okrh23710yfao.mysql.rds.aliyuncs.com;port=3306;user id=qyroot;password=kaicn1132+-;initial catalog=jdhy;charset=utf8;sslmode=none;" -FileName "{name}.cs" |
@ -0,0 +1,47 @@ |
|||
using FreeSql.DatabaseModel; |
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using System.Threading.Tasks; |
|||
using Newtonsoft.Json; |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db.HY |
|||
{ |
|||
|
|||
[Table(Name = "hycats", DisableSyncStructure = true)] |
|||
public partial class HyCats |
|||
{ |
|||
|
|||
[Column(StringLength = 50, IsPrimary = true, IsNullable = false)] |
|||
public string Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 是否最子级
|
|||
/// </summary>
|
|||
[Column(DbType = "tinyint")] |
|||
public sbyte IsLeaf { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 级别
|
|||
/// </summary>
|
|||
[Column(DbType = "int")] |
|||
public int Level { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 名称
|
|||
/// </summary>
|
|||
[Column(IsNullable = false)] |
|||
public string Name { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 父级ID
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string ParentId { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,67 @@ |
|||
using FreeSql.DatabaseModel;@{ |
|||
var gen = Model as RazorModel; |
|||
|
|||
Func<string, string> GetAttributeString = attr => { |
|||
if (string.IsNullOrEmpty(attr)) return ""; |
|||
return string.Concat(", ", attr.Trim('[', ']')); |
|||
}; |
|||
Func<string, string> GetDefaultValue = defval => { |
|||
if (string.IsNullOrEmpty(defval)) return ""; |
|||
return " = " + defval + ";"; |
|||
}; |
|||
}@{ |
|||
switch (gen.fsql.Ado.DataType) { |
|||
case FreeSql.DataType.PostgreSQL: |
|||
@:using System; |
|||
@:using System.Collections; |
|||
@:using System.Collections.Generic; |
|||
@:using System.Linq; |
|||
@:using System.Reflection; |
|||
@:using System.Threading.Tasks; |
|||
@:using Newtonsoft.Json; |
|||
@:using FreeSql.DataAnnotations; |
|||
@:using System.Net; |
|||
@:using Newtonsoft.Json.Linq; |
|||
@:using System.Net.NetworkInformation; |
|||
@:using NpgsqlTypes; |
|||
@:using Npgsql.LegacyPostgis; |
|||
break; |
|||
case FreeSql.DataType.SqlServer: |
|||
case FreeSql.DataType.MySql: |
|||
default: |
|||
@:using System; |
|||
@:using System.Collections; |
|||
@:using System.Collections.Generic; |
|||
@:using System.Linq; |
|||
@:using System.Reflection; |
|||
@:using System.Threading.Tasks; |
|||
@:using Newtonsoft.Json; |
|||
@:using FreeSql.DataAnnotations; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
namespace @gen.NameSpace { |
|||
|
|||
@if (string.IsNullOrEmpty(gen.table.Comment) == false) { |
|||
@:/// <summary> |
|||
@:/// @gen.table.Comment.Replace("\r\n", "\n").Replace("\n", "\r\n /// ") |
|||
@:/// </summary> |
|||
} |
|||
[JsonObject(MemberSerialization.OptIn)@GetAttributeString(gen.GetTableAttribute())] |
|||
public partial class @gen.GetCsName(gen.FullTableName) { |
|||
|
|||
@foreach (var col in gen.columns) { |
|||
|
|||
if (string.IsNullOrEmpty(col.Comment) == false) { |
|||
@:/// <summary> |
|||
@:/// @col.Comment.Replace("\r\n", "\n").Replace("\n", "\r\n /// ") |
|||
@:/// </summary> |
|||
} |
|||
@:@("[JsonProperty" + GetAttributeString(gen.GetColumnAttribute(col, true)) + "]") |
|||
@:public @gen.GetCsType(col) @gen.GetCsName(col.Name) { get; set; }@GetDefaultValue(gen.GetColumnDefaultValue(col, false)) |
|||
@: |
|||
} |
|||
} |
|||
@gen.GetMySqlEnumSetDefine() |
|||
} |
@ -0,0 +1,2 @@ |
|||
|
|||
FreeSql.Generator -Razor "__razor.cshtml.txt" -NameOptions 1,0,0,0 -NameSpace BBWYB.Server.Model.Db -DB "MySql,data source=rm-bp1508okrh23710yfao.mysql.rds.aliyuncs.com;port=3306;user id=qyroot;password=kaicn1132+-;initial catalog=jdhy;charset=utf8;sslmode=none;" -FileName "{name}.cs" |
@ -0,0 +1,132 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
[Table(Name = "user", DisableSyncStructure = true)] |
|||
public partial class User |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 主键
|
|||
/// </summary>
|
|||
[Column(StringLength = 50, IsPrimary = true, IsNullable = false)] |
|||
public string Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 业务ID列表
|
|||
/// </summary>
|
|||
[Column(StringLength = -2)] |
|||
public string BusinessIds { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建人Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string CreatorId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 否已删除
|
|||
/// </summary>
|
|||
[Column(DbType = "tinyint(4)")] |
|||
public sbyte Deleted { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 主部门ID
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string DepartmentId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 即将过期积分
|
|||
/// </summary>
|
|||
|
|||
public int? FailureIntegral { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 当日冻结积分
|
|||
/// </summary>
|
|||
|
|||
public int? FreezeIntegral { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 是否冻结
|
|||
/// </summary>
|
|||
[Column(DbType = "tinyint(4)")] |
|||
public sbyte? IsFreeze { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 最后积分检测日期
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? LastIntegralDate { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 登录IP
|
|||
/// </summary>
|
|||
|
|||
public string LoginIp { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 最大任务数量
|
|||
/// </summary>
|
|||
|
|||
public int? MaxPriceTaskCount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 角色ID
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string RoleId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 子部门列表
|
|||
/// </summary>
|
|||
[Column(StringLength = -1)] |
|||
public string SonDepartmentIds { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 任务重复检测更新
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? UpdateRepeatDate { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 用户经验值
|
|||
/// </summary>
|
|||
|
|||
public int? UserExp { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 用户积分
|
|||
/// </summary>
|
|||
|
|||
public int? UserIntegral { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 用户名
|
|||
/// </summary>
|
|||
|
|||
public string UserName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 花名
|
|||
/// </summary>
|
|||
|
|||
public string UserNick { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 用户密码
|
|||
/// </summary>
|
|||
|
|||
public string UserPwd { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,56 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 团队
|
|||
/// </summary>
|
|||
[Table(Name = "userdepartment", DisableSyncStructure = true)] |
|||
public partial class Userdepartment |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 主键
|
|||
/// </summary>
|
|||
[Column(StringLength = 50, IsPrimary = true, IsNullable = false)] |
|||
public string Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 管理ID集合
|
|||
/// </summary>
|
|||
[Column(StringLength = -1)] |
|||
public string AdminUserIds { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建人Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string CreatorId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 否已删除
|
|||
/// </summary>
|
|||
[Column(DbType = "tinyint(4)")] |
|||
public sbyte Deleted { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 部门名称
|
|||
/// </summary>
|
|||
public string DepartmentName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 上级部门
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string ParentDepartmentId { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,65 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 商品表(SPU)
|
|||
/// </summary>
|
|||
[Table(Name = "product", DisableSyncStructure = true)] |
|||
public partial class Product |
|||
{ |
|||
|
|||
[Column(StringLength = 50, IsPrimary = true, IsNullable = false)] |
|||
public string Id { get; set; } |
|||
|
|||
|
|||
public string Logo { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 商品名称
|
|||
/// </summary>
|
|||
[Column(StringLength = 200)] |
|||
public string ProductName { get; set; } |
|||
|
|||
[Column(DbType = "bigint")] |
|||
public long? ShopId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 状态(0下架 1上架)
|
|||
/// </summary>
|
|||
[Column(DbType = "int")] |
|||
public int? State { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 同步时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? SyncTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 更新时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? UpdateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 最近上架时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? UpperTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 分类Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? CategoryId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 分类名称
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string CategoryName { get; set; } |
|||
} |
|||
|
|||
} |
@ -0,0 +1,71 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 商品Sku表
|
|||
/// </summary>
|
|||
[ Table(Name = "productsku", DisableSyncStructure = true)] |
|||
public partial class ProductSku { |
|||
|
|||
/// <summary>
|
|||
/// SkuId
|
|||
/// </summary>
|
|||
[Column(StringLength = 50, IsPrimary = true, IsNullable = false)] |
|||
public string Id { get; set; } |
|||
|
|||
|
|||
public string Logo { get; set; } |
|||
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? Price { get; set; } = 0.00M; |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string ProductId { get; set; } |
|||
|
|||
[Column(DbType = "bigint")] |
|||
public long? ShopId { get; set; } |
|||
|
|||
[Column(StringLength = 200)] |
|||
public string SkuName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 0下架 1上架
|
|||
/// </summary>
|
|||
[Column(DbType = "int")] |
|||
public int? State { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 同步时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? SyncTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 更新时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? UpdateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 最近上架时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? UpperTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 分类Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? CategoryId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 分类名称
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string CategoryName { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,48 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Sku总销量表
|
|||
/// </summary>
|
|||
[Table(Name = "skutotalsaleinfo", DisableSyncStructure = true)] |
|||
public partial class SkuTotalSaleInfo |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Sku
|
|||
/// </summary>
|
|||
[Column(StringLength = 50, IsPrimary = true, IsNullable = false)] |
|||
public string SkuId { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 是否有效
|
|||
/// </summary>
|
|||
|
|||
public bool? IsEnabled { get; set; } = false; |
|||
|
|||
/// <summary>
|
|||
/// 销量,销售件数
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? ItemCount { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// Spu
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string ProductId { get; set; } |
|||
|
|||
[Column(DbType = "bigint")] |
|||
public long? ShopId { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? UpdateTime { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,75 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Spu总销量表
|
|||
/// </summary>
|
|||
[Table(Name = "sputotalsaleinfo", DisableSyncStructure = true)] |
|||
public partial class SpuTotalSaleInfo |
|||
{ |
|||
|
|||
[Column(StringLength = 50, IsPrimary = true, IsNullable = false)] |
|||
public string ProductId { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 完成首次优化时的销量
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? FirstOptimizationCompletedItemCount { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// 完成首次采购时的销量
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? FirstPurchaseCompletedItemCount { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// 是否有效
|
|||
/// </summary>
|
|||
|
|||
public bool? IsEnabled { get; set; } = false; |
|||
|
|||
/// <summary>
|
|||
/// 是否完成首次优化
|
|||
/// </summary>
|
|||
|
|||
public bool? IsFirstOptimizationCompleted { get; set; } = false; |
|||
|
|||
/// <summary>
|
|||
/// 是否完成首次采购
|
|||
/// </summary>
|
|||
|
|||
public bool? IsFirstPurchaseCompleted { get; set; } = false; |
|||
|
|||
/// <summary>
|
|||
/// 销量,销售件数
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? ItemCount { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// 上次优化时的销量
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? LastOptimizationItemCount { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// 上次优化时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? LastOptimizationTime { get; set; } |
|||
|
|||
[Column(DbType = "bigint")] |
|||
public long? ShopId { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? UpdateTime { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,42 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
[Table(Name = "purchaseschemeproductskustatistic", DisableSyncStructure = true)] |
|||
public partial class PurchaseSchemeProductSkuStatistic |
|||
{ |
|||
|
|||
[Column(StringLength = 50, IsPrimary = true, IsNullable = false)] |
|||
public string PurchaseSkuId { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 最近采购单价
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? LastPurchasedPrice { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 最近采购时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? LastPurchasedTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购金额
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? PurchasedAmount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购件数
|
|||
/// </summary>
|
|||
[Column(DbType = "int")] |
|||
public int? PurchasedItemCount { get; set; } = 0; |
|||
|
|||
} |
|||
|
|||
} |
@ -1,49 +0,0 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 采购商表
|
|||
/// </summary>
|
|||
[Table(Name = "purchaser", DisableSyncStructure = true)] |
|||
public partial class Purchaser |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 采购商Id (1688 SellerUserId)
|
|||
/// </summary>
|
|||
[Column(StringLength = 20, IsPrimary = true, IsNullable = false)] |
|||
public string Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购商Id2 (1688 SellerLoginId)
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string Id2 { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购商名称
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string Name { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 发货地
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string Location { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购平台
|
|||
/// </summary>
|
|||
[Column(MapType = typeof(int?))] |
|||
public Enums.Platform? Platform { get; set; } |
|||
|
|||
|
|||
[Column(StringLength = 50, IsNullable = true)] |
|||
public string MemberId { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,39 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Sku历史采购商关系表
|
|||
/// </summary>
|
|||
[Table(Name = "skuhistorypurchaserrelation", DisableSyncStructure = true)] |
|||
public partial class SkuHistoryPurchaserRelation |
|||
{ |
|||
|
|||
[Column(DbType = "bigint", IsPrimary = true)] |
|||
public long Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购商Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string PurchaserId { get; set; } |
|||
|
|||
[Column(DbType = "bigint")] |
|||
public long? ShopId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 店铺Sku
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string SkuId { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,136 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 采购商表
|
|||
/// </summary>
|
|||
[Table(Name = "purchaser", DisableSyncStructure = true)] |
|||
public partial class Purchaser |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 采购商Id (1688 SellerUserId)
|
|||
/// </summary>
|
|||
[Column(StringLength = 20, IsPrimary = true, IsNullable = false)] |
|||
public string Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购商Id2 (1688 SellerLoginId)
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string Id2 { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 发货地(产地)
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string Location { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 经营模式 0贸易 1厂家
|
|||
/// </summary>
|
|||
[Column(DbType = "int", MapType = typeof(int))] |
|||
public Enums.ManagmentMode? ManagmentMode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 经营模式(文本)
|
|||
/// </summary>
|
|||
public string ManagmentModeText { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string MemberId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购商名称
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string Name { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购平台
|
|||
/// </summary>
|
|||
[Column(MapType = typeof(int?))] |
|||
public Enums.Platform? Platform { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 商家标签 (超级工厂/实力工厂/实力供应商),可空
|
|||
/// </summary>
|
|||
[Column(StringLength = 20)] |
|||
public string Tag { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 绑定SPU数
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? BindingSpuCount { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// 采购SPU数
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? PurchasedSpuCount { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// 绑定SKU数
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? BindingSkuCount { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// 采购SKU数
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? PurchasedSkuCount { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// 采购次数/采购订单数
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? PurchasedCount { get; set; } = 0; |
|||
|
|||
/// <summary>
|
|||
/// 采购金额
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? PurchasedAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 上次采购时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? LastPurchasedTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 最近90天采购金额
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? Recent90dPurchasedAmount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 最近90天采购次数
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? Recent90dPurchasedCount { get; set; } = 0.00M; |
|||
|
|||
/// <summary>
|
|||
/// 归属议价组Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string BelongBargainTeamId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 归属议价组名称
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string BelongBargainTeamName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 临时=0, 永久=1
|
|||
/// </summary>
|
|||
[Column(MapType = typeof(int?))] |
|||
public Enums.PurchaserBelongType? BelongType { get; set; } |
|||
} |
|||
|
|||
} |
@ -0,0 +1,30 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
[Table(Name = "purchaserextendedinfo", DisableSyncStructure = true)] |
|||
public partial class PurchaserExtendedInfo |
|||
{ |
|||
|
|||
[Column(DbType = "bigint", IsPrimary = true)] |
|||
public long Id { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string Name { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 类型 主营类目=0 标签=1
|
|||
/// </summary>
|
|||
[Column(MapType = typeof(int?))] |
|||
public Enums.PurchaserBasicInfoType? Type { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string ExtendInfo { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,27 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
[Table(Name = "purchaser_extendedInfo_relation", DisableSyncStructure = true)] |
|||
public partial class Purchaser_ExtendedInfo_Relation |
|||
{ |
|||
|
|||
[Column(DbType = "bigint", IsPrimary = true)] |
|||
public long Id { get; set; } |
|||
|
|||
[Column(DbType = "bigint")] |
|||
public long? ExtendedInfoId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 关系类型 主营类目=0 标签=1
|
|||
/// </summary>
|
|||
[Column(DbType = "int",MapType = typeof(int?))] |
|||
public Enums.PurchaserBasicInfoType? ExtendedType { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string PurchaserId { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,57 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Sku历史优化表
|
|||
/// </summary>
|
|||
[Table(Name = "skuoptimizationhistory", DisableSyncStructure = true)] |
|||
public partial class SkuOptimizationHistory |
|||
{ |
|||
|
|||
[Column(DbType = "bigint", IsPrimary = true)] |
|||
public long Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 优化时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 优化率
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? OptimizationRatio { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string ProductId { get; set; } |
|||
|
|||
[Column(DbType = "bigint")] |
|||
public long? ShopId { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string SkuId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 上次采购单价
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)", IsNullable = true)] |
|||
public decimal? LastPurchasePrice { get; set; } = 0.0M; |
|||
|
|||
/// <summary>
|
|||
/// 本次采购单价
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)", IsNullable = true)] |
|||
public decimal? CurrentPurchasePrice { get; set; } = 0.0M; |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 触发优化原因
|
|||
/// </summary>
|
|||
[Column(DbType = "int(1)", MapType = typeof(int?), IsNullable = true)] |
|||
public Enums.TriggerOptimizationReason? TriggerOptimizationReason { get; set; } |
|||
} |
|||
|
|||
} |
@ -0,0 +1,45 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Sku优化任务表
|
|||
/// </summary>
|
|||
[Table(Name = "skuoptimizationtask", DisableSyncStructure = true)] |
|||
public partial class SkuOptimizationTask |
|||
{ |
|||
|
|||
[Column(DbType = "bigint", IsPrimary = true)] |
|||
public long Id { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string JDSkuId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 预估件数
|
|||
/// </summary>
|
|||
[Column(DbType = "int")] |
|||
public int? PreItemCount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 预估采购金额
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? PrePurchaseAmount { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string SkuId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Spu优化任务Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long SpuOptimizationTaskId { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// SPU优化议价组任务表
|
|||
/// </summary>
|
|||
[Table(Name = "spuoptimizationbargainteamtask", DisableSyncStructure = true)] |
|||
public partial class SpuOptimizationBargainTeamTask |
|||
{ |
|||
|
|||
[Column(DbType = "bigint", IsPrimary = true)] |
|||
public long Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 团队Id (议价组Id)
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string BelongTeamId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 议价组名称
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string BelongTeamName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 完成时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CompletionTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 是否优化完成
|
|||
/// </summary>
|
|||
public bool? IsOptimizationCompleted { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Spu优化任务Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long SpuOptimizationTaskId { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,73 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// SPU优化竞标任务表
|
|||
/// </summary>
|
|||
[Table(Name = "spuoptimizationcompetitivetendertask", DisableSyncStructure = true)] |
|||
public partial class SpuOptimizationCompetitiveTenderTask |
|||
{ |
|||
|
|||
[Column(IsPrimary = true, IsNullable = false)] |
|||
public long Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 议价组Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string BargainTeamId { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? UpdateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 是否更新报价
|
|||
/// </summary>
|
|||
public bool? IsUpdateQuotedPrice { get; set; } = false; |
|||
|
|||
/// <summary>
|
|||
/// 采购方案分组Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? SchemeGroupId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购方案Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long SchemeId { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string SkuId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Spu优化议价组任务Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? SpuOptimizationBargainTeamTaskId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Spu优化任务Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long SpuOptimizationTaskId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 是否中标
|
|||
/// </summary>
|
|||
[Column(DbType = "bit")] |
|||
public bool IsWin { get; set; } = false; |
|||
|
|||
/// <summary>
|
|||
/// 运费
|
|||
/// </summary>
|
|||
public decimal? Freight { get; set; } = 0.00M; |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,29 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
[Table(Name = "spuoptimizationproductskuupdatequotedpricerecord", DisableSyncStructure = true)] |
|||
public partial class SpuOptimizationProductSkuUpdateQuotedPriceRecord |
|||
{ |
|||
|
|||
[Column(DbType = "bigint", IsPrimary = true)] |
|||
public long Id { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string BargainTeamId { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string PurchaseSkuId { get; set; } |
|||
|
|||
[Column(DbType = "bigint")] |
|||
public long? SpuOptimizationTaskId { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string UserId { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,60 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db.SpuOptimization |
|||
{ |
|||
|
|||
[Table(Name = "spuoptimizationpurchasercompetitivetendertask", DisableSyncStructure = true)] |
|||
public partial class SpuOptimizationPurchaserCompetitiveTenderTask |
|||
{ |
|||
|
|||
[Column(IsPrimary = true)] |
|||
public long Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 议价组Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string BargainTeamId { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? UpdateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 是否更新报价
|
|||
/// </summary>
|
|||
|
|||
public bool? IsUpdateQuotedPrice { get; set; } = false; |
|||
|
|||
/// <summary>
|
|||
/// 采购商Id
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string PurchaserId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购方案分组Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? SchemeGroupId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购方案Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? SchemeId { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string SkuId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Spu优化任务Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? SpuOptimizationTaskId { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,92 @@ |
|||
using FreeSql.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Db |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// SPU优化任务表
|
|||
/// </summary>
|
|||
[Table(Name = "spuoptimizationtask", DisableSyncStructure = true)] |
|||
public partial class SpuOptimizationTask |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 待优化任务Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint", IsPrimary = true)] |
|||
public long Id { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 需求方店铺Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? BelongShopId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 需求方店铺名称
|
|||
/// </summary>
|
|||
[Column(StringLength = 50)] |
|||
public string BelongShopName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 完成优化时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CompletionTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 创建时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? CreateTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 是否优化完成
|
|||
/// </summary>
|
|||
public bool? IsOptimizationCompleted { get; set; } |
|||
|
|||
[Column(StringLength = 50)] |
|||
public string ProductId { get; set; } |
|||
|
|||
[Column(StringLength = 255)] |
|||
public string ProductTitle { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 上次优化时间
|
|||
/// </summary>
|
|||
[Column(DbType = "datetime")] |
|||
public DateTime? LastOptimizationTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 预估件数
|
|||
/// </summary>
|
|||
[Column(DbType = "int")] |
|||
public int? PreItemCount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 预估采购金额
|
|||
/// </summary>
|
|||
[Column(DbType = "decimal(18,2)")] |
|||
public decimal? PrePurchaseAmount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 预估Sku数
|
|||
/// </summary>
|
|||
[Column(DbType = "int")] |
|||
public int? PreSkuCount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 店铺Id
|
|||
/// </summary>
|
|||
[Column(DbType = "bigint")] |
|||
public long? ShopId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 触发优化原因 首次采购 = 0, 首次优化 = 1, 再次优化 = 2;触发优化原因 首次采购 = 0, 首次优化 = 1, 再次优化 = 2
|
|||
/// </summary>
|
|||
[Column(DbType = "int", MapType = typeof(int?))] |
|||
public Enums.TriggerOptimizationReason? TriggerOptimizationReason { get; set; } |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,30 @@ |
|||
namespace BBWYB.Server.Model.Dto |
|||
{ |
|||
public class BatchLKInventoryAlertRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 需求方店铺
|
|||
/// </summary>
|
|||
public long ShopId { get; set; } |
|||
|
|||
public IList<LKInventoryAlertRequest> Items { get; set; } |
|||
} |
|||
|
|||
public class LKInventoryAlertRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 京东SKU
|
|||
/// </summary>
|
|||
public string Sku { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 预估需求量
|
|||
/// </summary>
|
|||
public int PreItemCount { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 距离安全预警天数
|
|||
/// </summary>
|
|||
public int SafeWarningRemainingDay { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,45 @@ |
|||
namespace BBWYB.Server.Model.Dto |
|||
{ |
|||
public class BatchUpdateCompetitiveTenderQuotationRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 优化任务Id
|
|||
/// </summary>
|
|||
public long SpuOptimizationTaskId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 采购方案分组Id
|
|||
/// </summary>
|
|||
public long SchemeGroupId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 配件列表
|
|||
/// </summary>
|
|||
public IList<BatchUpdateCompetitiveTenderQuotationItemRequest> ItemList { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 运费
|
|||
/// </summary>
|
|||
public decimal Freight { get; set; } |
|||
} |
|||
|
|||
public class BatchUpdateCompetitiveTenderQuotationItemRequest |
|||
{ |
|||
//public string SkuId { get; set; }
|
|||
|
|||
/// <summary>
|
|||
/// 采购SkuId
|
|||
/// </summary>
|
|||
public string PurchaseSkuId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 实际单价
|
|||
/// </summary>
|
|||
public decimal? ActualPrice { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 是否包邮
|
|||
/// </summary>
|
|||
public bool IsFreeFreight { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,44 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace BBWYB.Server.Model.Dto |
|||
{ |
|||
public class QueryNoCompletionOptimizationTaskRequest : PageRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 京东SKU
|
|||
/// </summary>
|
|||
public string JDSku { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 需求方店铺
|
|||
/// </summary>
|
|||
public long? BelongShopId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 开始时间
|
|||
/// </summary>
|
|||
[Required] |
|||
public DateTime StartTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 结束时间
|
|||
/// </summary>
|
|||
[Required] |
|||
public DateTime EndTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// SPU优化任务Id
|
|||
/// </summary>
|
|||
public long? SpuOptimizationTaskId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// Spu或Sku
|
|||
/// </summary>
|
|||
public string SpuOrSku { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 标题关键字
|
|||
/// </summary>
|
|||
public string TitleKeywords { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,19 @@ |
|||
namespace BBWYB.Server.Model.Dto |
|||
{ |
|||
public class CompleteOptimizationRequest |
|||
{ |
|||
//public string OrderId { get; set; }
|
|||
|
|||
public long ShopId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 店铺SkuId
|
|||
/// </summary>
|
|||
public string SkuId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 店铺商品Id
|
|||
/// </summary>
|
|||
public string ProductId { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,9 @@ |
|||
namespace BBWYB.Server.Model.Dto |
|||
{ |
|||
public class PageRequest |
|||
{ |
|||
public int PageIndex { get; set; } |
|||
|
|||
public int PageSize { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,40 @@ |
|||
namespace BBWYB.Server.Model.Dto |
|||
{ |
|||
public class BatchEditPurchaseSkuActualPriceRequest |
|||
{ |
|||
/// <summary>
|
|||
/// 可选条件
|
|||
/// </summary>
|
|||
public string ProductId { get; set; } |
|||
|
|||
public IList<BatchEditPurchaseSkuActualPriceItemRequest> ItemList { get; set; } |
|||
} |
|||
|
|||
public class BatchEditPurchaseSkuActualPriceItemRequest |
|||
{ |
|||
///// <summary>
|
|||
///// 采购方案Id
|
|||
///// </summary>
|
|||
////public long SchemeId { get; set; }
|
|||
|
|||
///// <summary>
|
|||
///// SkuId
|
|||
///// </summary>
|
|||
//public string SkuId { get; set; }
|
|||
|
|||
/// <summary>
|
|||
/// 采购SkuId
|
|||
/// </summary>
|
|||
public string PurchaseSkuId { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 实际单价
|
|||
/// </summary>
|
|||
public decimal? ActualPrice { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 是否包邮
|
|||
/// </summary>
|
|||
public bool? IsFreeFreight { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,9 @@ |
|||
namespace BBWYB.Server.Model.Dto |
|||
{ |
|||
public class DeleteSchemeGroupFromSpuOptimizationTaskRequest |
|||
{ |
|||
public long SchemeGroupId { get; set; } |
|||
|
|||
public long SpuOptimizationId { get; set; } |
|||
} |
|||
} |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue