Browse Source

修复采购商查询bug

liangku_skuoptimazation
shanji 1 year ago
parent
commit
50ec08b313
  1. 9
      BBWYB.PurchaserCapture/App.xaml
  2. 22
      BBWYB.PurchaserCapture/App.xaml.cs
  3. 10
      BBWYB.PurchaserCapture/AssemblyInfo.cs
  4. 17
      BBWYB.PurchaserCapture/BBWYB.PurchaserCapture.csproj
  5. 12
      BBWYB.PurchaserCapture/MainWindow.xaml
  6. 24
      BBWYB.PurchaserCapture/MainWindow.xaml.cs
  7. 29
      BBWYB.Server.Business/Purchaser/PurchaserBusiness.cs
  8. 57
      BBWYB.Server.Model/Db/BBWY/ProductSku.cs
  9. 1
      BBWYB.Server.Model/Dto/Request/Purchaser/QueryPurchaserRequest.cs
  10. 9
      bbwyb.sln

9
BBWYB.PurchaserCapture/App.xaml

@ -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>

22
BBWYB.PurchaserCapture/App.xaml.cs

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

10
BBWYB.PurchaserCapture/AssemblyInfo.cs

@ -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)
)]

17
BBWYB.PurchaserCapture/BBWYB.PurchaserCapture.csproj

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<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" />
</ItemGroup>
</Project>

12
BBWYB.PurchaserCapture/MainWindow.xaml

@ -0,0 +1,12 @@
<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>
</Grid>
</Window>

24
BBWYB.PurchaserCapture/MainWindow.xaml.cs

@ -0,0 +1,24 @@
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace BBWYB.PurchaserCapture
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

29
BBWYB.Server.Business/Purchaser/PurchaserBusiness.cs

@ -10,9 +10,11 @@ namespace BBWYB.Server.Business
{
public class PurchaserBusiness : BaseBusiness, IDenpendency
{
public PurchaserBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator) : base(fsql, nLogManager, idGenerator)
{
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)
@ -164,8 +166,7 @@ namespace BBWYB.Server.Business
var poList = fsql.Select<OrderPurchaseInfo, Order>()
.InnerJoin((opi, o) => opi.OrderId == o.Id)
.WhereIf(request.ShopId != null && request.ShopId > 0, (opi, o) => opi.ShopId == request.ShopId)
.Where((opi, o) => opi.ShopId == request.ShopId &&
opi.IsEnabled == true &&
.Where((opi, o) => opi.IsEnabled == true &&
o.OrderState != Enums.OrderState. &&
purchaserIdList.Contains(opi.PurchaserId))
.GroupBy((opi, o) => opi.PurchaserId)
@ -191,7 +192,7 @@ namespace BBWYB.Server.Business
.ToList(g => new
{
PurchaserId = g.Key,
PurchaseAmount = g.Sum(g.Value.Item1.SkuAmount) + g.Sum(g.Value.Item1.PurchaseFreight)
PurchaseAmount = g.Sum(g.Value.Item1.SkuAmount + g.Value.Item1.PurchaseFreight)
});
#endregion
@ -227,7 +228,7 @@ namespace BBWYB.Server.Business
#endregion
#region 最近采购的店铺商品
var recent30d = DateTime.Now.AddDays(-00);
var recent30d = DateTime.Now.AddDays(-90);
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)
@ -253,6 +254,8 @@ namespace BBWYB.Server.Business
g.Key.SkuName,
g.Key.SourceSkuId
});
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
@ -303,12 +306,16 @@ namespace BBWYB.Server.Business
#endregion
#region 最近采购店铺商品
purchaser.Recent30dProductSku = bePurchasedProductSkuList.Where(x => x.PurchaserId == purchaser.Id).Take(10).Select(x => new RecentPurchasedSkuResponse()
purchaser.Recent30dProductSku = bePurchasedProductSkuList.Where(x => x.PurchaserId == purchaser.Id).Take(10).Select(x =>
{
Id = x.Id,
Logo = x.Logo,
SkuName = x.SkuName,
BelongSku = x.SourceSkuId
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
};
}).ToList();
#endregion

57
BBWYB.Server.Model/Db/BBWY/ProductSku.cs

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

1
BBWYB.Server.Model/Dto/Request/Purchaser/QueryPurchaserRequest.cs

@ -4,7 +4,6 @@ namespace BBWYB.Server.Model.Dto
{
public class QueryPurchaserRequest
{
[Required]
public long? ShopId { get; set; }
public string Spu { get; set; }

9
bbwyb.sln

@ -46,10 +46,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "U", "U", "{D34B0974-D525-4B
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "U", "U\U.csproj", "{FE3D9812-2D75-4850-8AEA-CE88BAF2F17A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebTest", "WebTest\WebTest.csproj", "{EFCA7129-3069-4F92-A0BD-663D014B82AD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebTest", "WebTest\WebTest.csproj", "{EFCA7129-3069-4F92-A0BD-663D014B82AD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{97653DB2-605C-4582-AC6E-2A09D2E8EB44}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BBWYB.PurchaserCapture", "BBWYB.PurchaserCapture\BBWYB.PurchaserCapture.csproj", "{736D1C5D-4B7A-45C4-863A-6EFF6DCAE1E1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -104,6 +106,10 @@ Global
{EFCA7129-3069-4F92-A0BD-663D014B82AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EFCA7129-3069-4F92-A0BD-663D014B82AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EFCA7129-3069-4F92-A0BD-663D014B82AD}.Release|Any CPU.Build.0 = Release|Any CPU
{736D1C5D-4B7A-45C4-863A-6EFF6DCAE1E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{736D1C5D-4B7A-45C4-863A-6EFF6DCAE1E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{736D1C5D-4B7A-45C4-863A-6EFF6DCAE1E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{736D1C5D-4B7A-45C4-863A-6EFF6DCAE1E1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -125,6 +131,7 @@ Global
{FE3D9812-2D75-4850-8AEA-CE88BAF2F17A} = {D34B0974-D525-4BD1-90DE-B2CF5FE47AA4}
{EFCA7129-3069-4F92-A0BD-663D014B82AD} = {97653DB2-605C-4582-AC6E-2A09D2E8EB44}
{97653DB2-605C-4582-AC6E-2A09D2E8EB44} = {878D0106-F55F-4813-9158-F2729D460F9C}
{736D1C5D-4B7A-45C4-863A-6EFF6DCAE1E1} = {1E7D36DB-A817-4208-8FC6-36A66FAB17E5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0D069898-04B7-4D24-A6A4-D7C703B8BFFC}

Loading…
Cancel
Save