diff --git a/BBWYB.PurchaserCapture/MainWindow.xaml.cs b/BBWYB.PurchaserCapture/MainWindow.xaml.cs index 3d259d3..b3fea3d 100644 --- a/BBWYB.PurchaserCapture/MainWindow.xaml.cs +++ b/BBWYB.PurchaserCapture/MainWindow.xaml.cs @@ -40,6 +40,7 @@ namespace BBWYB.PurchaserCapture 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) @@ -65,30 +66,39 @@ namespace BBWYB.PurchaserCapture Console.WriteLine($"HttpCode {e.Response.StatusCode},已忽略 {e.Request.Uri}"); return; } - 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) + try { - Console.WriteLine($"bizTypeName解析失败,已忽略 {e.Request.Uri}"); - return; - } - var bizTypeName = match.Groups[1].Value; - Console.WriteLine(bizTypeName); - if (!string.IsNullOrEmpty(purchaserId)) - { - if (!string.IsNullOrEmpty(purchaserMemberId)) + 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 (!content.Contains(purchaserMemberId)) + if (!string.IsNullOrEmpty(purchaserMemberId)) { - Console.WriteLine($"memberId验证失败,已忽略 {e.Request.Uri}"); - return; + if (!content.Contains(purchaserMemberId)) + { + Console.WriteLine($"memberId验证失败,已忽略 {e.Request.Uri}"); + return; + } } + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine($"更新采购商{purchaserId}"); + Console.ResetColor(); + fsql.Update(purchaserId).Set(p => p.ManagmentModeText, bizTypeName).ExecuteAffrows(); } - Console.WriteLine($"更新采购商{purchaserId}"); - fsql.Update(purchaserId).Set(p => p.ManagmentModeText, bizTypeName).ExecuteAffrows(); + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); } } @@ -123,20 +133,39 @@ namespace BBWYB.PurchaserCapture { var sk = "order"; //var sk = "consign"; - var pspList = fsql.Select() - .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() - .InnerJoin((psp2, psp1) => psp2.MaxId == psp1.Id) - .OrderByDescending((psp2, psp1) => Guid.NewGuid()) - .ToList((psp2, psp1) => new - { - psp1.PurchaserId, - psp2.MemberId, - psp1.PurchaseProductId - }); + + var pspList = fsql.Select() + .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() + .InnerJoin((opi1, ops) => opi1.MaxPoId == ops.PurchaseOrderId) + .GroupBy((opi1, ops) => new { opi1.PurchaserId, opi1.MemberId, opi1.MaxPoId, ops.PurchaseProductId }) + .ToList(g => new { g.Key.PurchaserId, g.Key.MemberId, g.Key.MaxPoId, g.Key.PurchaseProductId }); + + + + + //var pspList = fsql.Select() + // .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() + // .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++) { diff --git a/BBWYB.PurchaserCapture/Model/Db/OrderPurchaseInfo.cs b/BBWYB.PurchaserCapture/Model/Db/OrderPurchaseInfo.cs new file mode 100644 index 0000000..112db0e --- /dev/null +++ b/BBWYB.PurchaserCapture/Model/Db/OrderPurchaseInfo.cs @@ -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; } + + /// + /// ɹ˺Id + /// + [Column(StringLength = 100)] + public string PurchaseAccountId { get; set; } + + /// + /// ɹ˺ + /// + [Column(StringLength = 100)] + public string PurchaseAccountName { get; set; } + + [Column(MapType = typeof(int?))] + public Enums.PurchaseMethod? PurchaseMethod { get; set; } + + /// + /// ɹId + /// + [Column(StringLength = 100)] + public string PurchaseOrderId { get; set; } + + [Column(MapType = typeof(int?))] + public Enums.Platform? PurchasePlatform { get; set; } + + /// + /// ɹId + /// + [Column(StringLength = 100)] + public string PurchaserId { get; set; } + + /// + /// ɹ + /// + [Column(StringLength = 100)] + public string PurchaserName { get; set; } + + /// + /// Id + /// + public long? ShopId { get; set; } + + + /// + /// Sku + /// + [Column(StringLength = 500)] + public string BelongSkuIds { get; set; } + + [Column(DbType = "bit")] + public bool IsEnabled { get; set; } = true; + + /// + /// ɹע + /// + [Column(StringLength = 500)] + public string Remark { get; set; } + + /// + /// ʷɹʱ + /// + [Column(DbType = "datetime", IsNullable = true)] + public DateTime HistorySettingTime { get; set; } + + /// + /// ɹ״̬ + /// + [Column(MapType = typeof(int?))] + public Enums.PurchaseOrderState? OrderState { get; set; } + + /// + /// Ƿƽ + /// + [Column(MapType = typeof(int?))] + public Enums.AutoEditOrderPriceType? IsAutoEditOrderPrice { get; set; } + } + +} diff --git a/BBWYB.PurchaserCapture/Model/Db/OrderPurchaseSkuInfo.cs b/BBWYB.PurchaserCapture/Model/Db/OrderPurchaseSkuInfo.cs new file mode 100644 index 0000000..f95cf3d --- /dev/null +++ b/BBWYB.PurchaserCapture/Model/Db/OrderPurchaseSkuInfo.cs @@ -0,0 +1,67 @@ +using FreeSql.DataAnnotations; + +namespace BBWYB.Server.Model.Db +{ + + /// + /// 采购单Sku表 + /// + [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; } + + ///// + ///// 物流变更时间 + ///// + //[Column(DbType = "datetime")] + //public DateTime? ExpressChangeTime { get; set; } + + ///// + ///// 物流状态 + ///// + //[Column(StringLength = 100)] + //public string ExpressState { get; set; } + + /// + /// 店铺订单Id + /// + [Column(StringLength = 100)] + public string OrderId { get; set; } + + /// + /// 采购订单Id + /// + [Column(StringLength = 100)] + public string PurchaseOrderId { get; set; } + + /// + /// 采购商品Id(spu) + /// + [Column(StringLength = 100)] + public string PurchaseProductId { get; set; } + + /// + /// 采购Sku + /// + [Column(StringLength = 100)] + public string PurchaseSkuId { get; set; } + + /// + /// 店铺Id + /// + public long? ShopId { get; set; } + + /// + /// 快递单 + /// + [Column(StringLength = 100)] + public string WaybillNo { get; set; } + } + +}