From 79589809da486130792a3bf7c976be2b6001c747 Mon Sep 17 00:00:00 2001 From: shanji <18996038927@163.com> Date: Mon, 8 Jan 2024 01:35:33 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=95=86=E4=B8=BB=E8=90=A5?= =?UTF-8?q?=E7=B1=BB=E7=9B=AE=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataRepair/DataRepairBusiness.cs | 40 ++++++++++++++++--- .../Purchaser/PurchaserBusiness.cs | 11 +++-- .../Client/Impl/OP_QuanTanClient.cs | 37 ++++++++--------- .../Product/OP_QueryProductCategoryRequest.cs | 5 +++ 4 files changed, 62 insertions(+), 31 deletions(-) diff --git a/BBWYB.Server.Business/DataRepair/DataRepairBusiness.cs b/BBWYB.Server.Business/DataRepair/DataRepairBusiness.cs index 770fec1..12ffe46 100644 --- a/BBWYB.Server.Business/DataRepair/DataRepairBusiness.cs +++ b/BBWYB.Server.Business/DataRepair/DataRepairBusiness.cs @@ -976,20 +976,48 @@ namespace BBWYB.Server.Business PageSize = 500, AppKey = "BBWYB2023022501", AppSecret = "3a1521deccc6819d61788a0d6baae49e9", - AppToken = "9" + AppToken = "9", + Level = 0 }; - var qtCategoryList = new List(); - var response = client.GetProductCategoryList(request); - if (response.Items != null) - qtCategoryList.AddRange(response.Items); + var L1_qtCategoryList = new List(); + var L1_response = client.GetProductCategoryList(request); + if (L1_response.Items != null) + L1_qtCategoryList.AddRange(L1_response.Items); + + request.Level = 1; + var L2_qtCategoryList = new List(); + var L2_response = client.GetProductCategoryList(request); + if (L2_response.Items != null) + L2_qtCategoryList.AddRange(L2_response.Items); + + request.Level = 2; + var L3_qtCategoryList = new List(); + var L3_response = client.GetProductCategoryList(request); + if (L3_response.Items != null) + L3_qtCategoryList.AddRange(L3_response.Items); + + foreach (var l3Category in L3_qtCategoryList) + { + var parentPathIdArray = l3Category.CategoryPath.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + if (parentPathIdArray.Length != 3) + continue; + var l2Category = L2_qtCategoryList.FirstOrDefault(x => x.CategoryId == parentPathIdArray[1]); + if (l2Category == null) + continue; + var l1Category = L1_qtCategoryList.FirstOrDefault(x => x.CategoryId == parentPathIdArray[0]); + if (l1Category == null) + continue; + + l3Category.CategoryPath = $"{l1Category.CategoryName},{l2Category.CategoryName}"; + } //找出新增的类目 //var newCategoryList = qtCategoryList.Where(c => !dbCategoryList.Any(dc => dc.Id == long.Parse(c.CategoryId))).ToList(); //if (newCategoryList.Count() > 0) //{ - insertList.AddRange(qtCategoryList.Select(c => new PurchaserExtendedInfo() + insertList.AddRange(L3_qtCategoryList.Select(c => new PurchaserExtendedInfo() { Id = long.Parse(c.CategoryId), Name = c.CategoryName, diff --git a/BBWYB.Server.Business/Purchaser/PurchaserBusiness.cs b/BBWYB.Server.Business/Purchaser/PurchaserBusiness.cs index 4deb6ae..6958777 100644 --- a/BBWYB.Server.Business/Purchaser/PurchaserBusiness.cs +++ b/BBWYB.Server.Business/Purchaser/PurchaserBusiness.cs @@ -150,7 +150,7 @@ namespace BBWYB.Server.Business #region 查询SPU采购数/SKU采购数 var purchasedList = fsql.Select() .InnerJoin((ps, ori, opi, o) => ps.Id == ori.BelongSkuId) - .InnerJoin((ps, ori, opi, o) => ori.PurchaseOrderId == opi.PurchaseOrderId && + .InnerJoin((ps, ori, opi, o) => ori.PurchaseOrderId == opi.PurchaseOrderId && ori.OrderId == opi.OrderId) .InnerJoin((ps, ori, opi, o) => opi.OrderId == o.Id) .WhereIf(request.ShopId != null && request.ShopId > 0, (ps, ori, opi, o) => o.ShopId == request.ShopId) @@ -228,7 +228,8 @@ namespace BBWYB.Server.Business pei.Id, pei.Name, pei.Type, - per.PurchaserId + per.PurchaserId, + pei.ExtendInfo }); #endregion @@ -298,7 +299,8 @@ namespace BBWYB.Server.Business { Id = x.Id, Name = x.Name, - Type = x.Type + Type = x.Type, + ExtendInfo = x.ExtendInfo }).ToList(); purchaser.TagList = currentExtendInfoList.Where(x => x.Type == Enums.PurchaserBasicInfoType.标签) @@ -306,7 +308,8 @@ namespace BBWYB.Server.Business { Id = x.Id, Name = x.Name, - Type = x.Type + Type = x.Type, + ExtendInfo = x.ExtendInfo }).ToList(); #endregion diff --git a/SDKAdapter/OperationPlatform/Client/Impl/OP_QuanTanClient.cs b/SDKAdapter/OperationPlatform/Client/Impl/OP_QuanTanClient.cs index de41b19..5eba23d 100644 --- a/SDKAdapter/OperationPlatform/Client/Impl/OP_QuanTanClient.cs +++ b/SDKAdapter/OperationPlatform/Client/Impl/OP_QuanTanClient.cs @@ -4,6 +4,7 @@ using com.alibaba.openapi.client; using QuanTan.SDK.Client.Supplier; using QuanTan.SDK.Models.Supplier; using SDKAdapter.OperationPlatform.Models; +using System.Reflection.Emit; using static System.Net.WebRequestMethods; namespace SDKAdapter.OperationPlatform.Client @@ -250,31 +251,25 @@ namespace SDKAdapter.OperationPlatform.Client public override OP_ListResponse GetProductCategoryList(OP_QueryProductCategoryRequest request) { - var levels = new List() { 0, 1, 2 }; - var items = new List(); - foreach (var level in levels) + var qtResponse = supplier_ProductClient.GetProductCategoryList(new QuanTan_Supplier_SearchProductCategoryRequest() { - var qtResponse = supplier_ProductClient.GetProductCategoryList(new QuanTan_Supplier_SearchProductCategoryRequest() - { - page = request.PageIndex, - pageSize = request.PageSize, - categoryLevel = level - }, request.AppKey, request.AppSecret); - if (qtResponse.Data.List != null && qtResponse.Data.List.Count() > 0) - { - items.AddRange(qtResponse.Data.List.Select(x => new OP_ProductCategoryResponse() - { - CategoryId = x.CategoryId, - CategoryName = x.CategoryName, - CategoryPath = x.CategoryPath - }).ToList()); - } - } + page = request.PageIndex, + pageSize = request.PageSize, + categoryLevel = request.Level + }, request.AppKey, request.AppSecret); + + if (qtResponse.Status != 200) + throw new BusinessException(qtResponse.Message); return new OP_ListResponse() { - Count = items.Count, - Items = items + Count = qtResponse.Data?.Count ?? 0, + Items = qtResponse.Data?.List?.Select(x => new OP_ProductCategoryResponse() + { + CategoryId = x.CategoryId, + CategoryName = x.CategoryName, + CategoryPath = x.CategoryPath + }).ToList() }; } } diff --git a/SDKAdapter/OperationPlatform/Models/Request/Product/OP_QueryProductCategoryRequest.cs b/SDKAdapter/OperationPlatform/Models/Request/Product/OP_QueryProductCategoryRequest.cs index ebed883..f2edc56 100644 --- a/SDKAdapter/OperationPlatform/Models/Request/Product/OP_QueryProductCategoryRequest.cs +++ b/SDKAdapter/OperationPlatform/Models/Request/Product/OP_QueryProductCategoryRequest.cs @@ -5,5 +5,10 @@ public int PageIndex { get; set; } public int PageSize { get; set; } + + /// + /// 分类层级 0/1/2 + /// + public int Level { get; set; } = 2; } }