|
|
@ -2,6 +2,7 @@ |
|
|
|
using BBWYB.Common.Models; |
|
|
|
using BBWYB.Server.Model; |
|
|
|
using BBWYB.Server.Model.Dto; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using SDKAdapter.OperationPlatform.Client; |
|
|
|
using SDKAdapter.OperationPlatform.Models; |
|
|
|
using Yitter.IdGenerator; |
|
|
@ -11,10 +12,13 @@ namespace BBWYB.Server.Business |
|
|
|
public class ProductBusiness : BaseBusiness, IDenpendency |
|
|
|
{ |
|
|
|
private OP_PlatformClientFactory opPlatformClientFactory; |
|
|
|
private Lazy<PurchaseSchemeBusiness> purchaseSchemeBusinessLazy; |
|
|
|
private PurchaseSchemeBusiness purchaseSchemeBusiness => purchaseSchemeBusinessLazy.Value; |
|
|
|
|
|
|
|
public ProductBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, OP_PlatformClientFactory opPlatformClientFactory) : base(fsql, nLogManager, idGenerator) |
|
|
|
public ProductBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, OP_PlatformClientFactory opPlatformClientFactory, IServiceProvider serviceProvider) : base(fsql, nLogManager, idGenerator) |
|
|
|
{ |
|
|
|
this.opPlatformClientFactory = opPlatformClientFactory; |
|
|
|
this.purchaseSchemeBusinessLazy = new Lazy<PurchaseSchemeBusiness>(() => serviceProvider.GetService<PurchaseSchemeBusiness>()); |
|
|
|
} |
|
|
|
|
|
|
|
public OP_ProductListResponse GetProductList(OP_QueryProductRequest request) |
|
|
@ -62,6 +66,7 @@ namespace BBWYB.Server.Business |
|
|
|
Spu = request.Spu |
|
|
|
}); |
|
|
|
|
|
|
|
var skuIdList = new List<string>(); |
|
|
|
if (spuResponse.Items.Count() > 0) |
|
|
|
{ |
|
|
|
foreach (var op_product in spuResponse.Items) |
|
|
@ -89,11 +94,31 @@ namespace BBWYB.Server.Business |
|
|
|
}); |
|
|
|
if (skuResponse.Count > 0) |
|
|
|
{ |
|
|
|
bproduct.SkuList = skuResponse.Items; |
|
|
|
bproduct.SkuList = skuResponse.Items.Select(x => new BProductSkuResponse() |
|
|
|
{ |
|
|
|
CreateTime = x.CreateTime, |
|
|
|
Id = x.Id, |
|
|
|
Logo = x.Logo, |
|
|
|
Price = x.Price, |
|
|
|
ProductId = x.ProductId, |
|
|
|
State = x.State, |
|
|
|
Title = x.Title |
|
|
|
}).ToList(); |
|
|
|
skuIdList.AddRange(skuResponse.Items.Select(s => s.Id)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var schemeCountRes = purchaseSchemeBusiness.GetPurchaseSchemeCountList(new QuerySchemeCountRequest() |
|
|
|
{ |
|
|
|
SkuIdList = skuIdList |
|
|
|
}); |
|
|
|
foreach (var bproduct in list) |
|
|
|
{ |
|
|
|
foreach (var bsku in bproduct.SkuList) |
|
|
|
bsku.SchemeCount = schemeCountRes.FirstOrDefault(ps => ps.SkuId == bsku.Id)?.SchemeCount ?? 0; |
|
|
|
} |
|
|
|
|
|
|
|
return new BProductListResponse() |
|
|
|
{ |
|
|
|
Count = spuResponse.Count, |
|
|
|