From bc7037f1fac72f73d533ac829ca9cb0e544b8c23 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Thu, 2 Nov 2023 14:53:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=E8=AE=A2=E5=8D=95=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/repositories/order.go | 65 ++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/service/repositories/order.go b/service/repositories/order.go index 32472a4a..faffca77 100644 --- a/service/repositories/order.go +++ b/service/repositories/order.go @@ -1769,42 +1769,45 @@ func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel StatusLink: order.GetOrderStatusLinkUser(*orderInfo.DeliveryMethod, statusLink), Metadata: orderMetadata, } - + // 购物车对应商品 + var shoppingCartSnapshotDataMap = make(map[int64]gmodel.FsShoppingCartData) + for _, shoppingCartSnapshotValue := range shoppingCartSnapshot { + var shoppingCartSnapshotData gmodel.FsShoppingCartData + snapshot, err := d.OrderShoppingCartSnapshotHandler(ctx, shoppingCartSnapshotValue.Snapshot) + if err != nil { + logc.Errorf(ctx, "OrderDetailHandler OrderShoppingCartSnapshotHandler failed, err: %v", err) + return nil, err + } + shoppingCartSnapshotData.Id = shoppingCartSnapshotValue.Id + shoppingCartSnapshotData.UserId = shoppingCartSnapshotValue.UserId + shoppingCartSnapshotData.ProductId = shoppingCartSnapshotValue.ProductId + shoppingCartSnapshotData.TemplateId = shoppingCartSnapshotValue.TemplateId + shoppingCartSnapshotData.ModelId = shoppingCartSnapshotValue.ModelId + shoppingCartSnapshotData.SizeId = shoppingCartSnapshotValue.SizeId + shoppingCartSnapshotData.LightId = shoppingCartSnapshotValue.LightId + shoppingCartSnapshotData.FittingId = shoppingCartSnapshotValue.FittingId + shoppingCartSnapshotData.PurchaseQuantity = shoppingCartSnapshotValue.PurchaseQuantity + shoppingCartSnapshotData.IsSelected = shoppingCartSnapshotValue.IsSelected + shoppingCartSnapshotData.IsSelected = shoppingCartSnapshotValue.IsSelected + shoppingCartSnapshotData.IsHighlyCustomized = shoppingCartSnapshotValue.IsHighlyCustomized + shoppingCartSnapshotData.Ctime = shoppingCartSnapshotValue.Ctime + shoppingCartSnapshotData.Utime = shoppingCartSnapshotValue.Utime + shoppingCartSnapshotData.Snapshot = &snapshot + shoppingCartSnapshotDataMap[shoppingCartSnapshotValue.Id] = shoppingCartSnapshotData + } var orderProductList []gmodel.OrderProduct for _, productValue := range orderProduct { var selectColorIndex int64 - var shoppingCartSnapshotData gmodel.FsShoppingCartData - for _, shoppingCartSnapshotValue := range shoppingCartSnapshot { - if productValue.CartId == shoppingCartSnapshotValue.Id { - - snapshot, err := d.OrderShoppingCartSnapshotHandler(ctx, shoppingCartSnapshotValue.Snapshot) - if err != nil { - logc.Errorf(ctx, "OrderDetailHandler OrderShoppingCartSnapshotHandler failed, err: %v", err) - return nil, err - } - shoppingCartSnapshotData.Id = shoppingCartSnapshotValue.Id - shoppingCartSnapshotData.UserId = shoppingCartSnapshotValue.UserId - shoppingCartSnapshotData.ProductId = shoppingCartSnapshotValue.ProductId - shoppingCartSnapshotData.TemplateId = shoppingCartSnapshotValue.TemplateId - shoppingCartSnapshotData.ModelId = shoppingCartSnapshotValue.ModelId - shoppingCartSnapshotData.SizeId = shoppingCartSnapshotValue.SizeId - shoppingCartSnapshotData.LightId = shoppingCartSnapshotValue.LightId - shoppingCartSnapshotData.FittingId = shoppingCartSnapshotValue.FittingId - shoppingCartSnapshotData.PurchaseQuantity = shoppingCartSnapshotValue.PurchaseQuantity - shoppingCartSnapshotData.IsSelected = shoppingCartSnapshotValue.IsSelected - shoppingCartSnapshotData.IsSelected = shoppingCartSnapshotValue.IsSelected - shoppingCartSnapshotData.IsHighlyCustomized = shoppingCartSnapshotValue.IsHighlyCustomized - shoppingCartSnapshotData.Ctime = shoppingCartSnapshotValue.Ctime - shoppingCartSnapshotData.Utime = shoppingCartSnapshotValue.Utime - shoppingCartSnapshotData.Snapshot = &snapshot - - selectColorIndexV, selectColorIndexE := snapshot["select_color_index"] - if selectColorIndexE { - selectColorIndex = selectColorIndexV.(int64) - } - + var shoppingCartSnapshotData = shoppingCartSnapshotDataMap[productValue.CartId] + var snapshotInfo = shoppingCartSnapshotData.Snapshot + if snapshotInfo != nil { + var snapshotInfoMap = *snapshotInfo + selectColorIndexV, selectColorIndexE := snapshotInfoMap["select_color_index"] + if selectColorIndexE { + selectColorIndex = selectColorIndexV.(int64) } } + var expectedDeliveryTime time.Time if productValue.ExpectedDeliveryTime == nil { expectedDeliveryTime = expectedTime From c8e63f4a57c225f1ee6117186ee08a075e0b9741 Mon Sep 17 00:00:00 2001 From: momo <1012651275@qq.com> Date: Thu, 2 Nov 2023 15:00:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=E8=AE=A2=E5=8D=95=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/repositories/order.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/repositories/order.go b/service/repositories/order.go index faffca77..9d16f295 100644 --- a/service/repositories/order.go +++ b/service/repositories/order.go @@ -1770,7 +1770,7 @@ func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel Metadata: orderMetadata, } // 购物车对应商品 - var shoppingCartSnapshotDataMap = make(map[int64]gmodel.FsShoppingCartData) + var shoppingCartSnapshotDataMap = make(map[int64]gmodel.FsShoppingCartData, len(shoppingCartSnapshot)) for _, shoppingCartSnapshotValue := range shoppingCartSnapshot { var shoppingCartSnapshotData gmodel.FsShoppingCartData snapshot, err := d.OrderShoppingCartSnapshotHandler(ctx, shoppingCartSnapshotValue.Snapshot)