fix:订单优化
This commit is contained in:
parent
c8e63f4a57
commit
2d0ea47c7c
|
@ -1672,13 +1672,6 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
|
|||
}, nil
|
||||
}
|
||||
|
||||
// 购物车快照处理
|
||||
func (d *defaultOrder) OrderShoppingCartSnapshotHandler(ctx context.Context, req *string) (res map[string]interface{}, err error) {
|
||||
var snapshot map[string]interface{}
|
||||
json.Unmarshal([]byte(*req), &snapshot)
|
||||
return snapshot, nil
|
||||
}
|
||||
|
||||
// 详情处理
|
||||
func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel.FsOrder, original int64) (res *DetailRes, err error) {
|
||||
|
||||
|
@ -1772,36 +1765,35 @@ func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel
|
|||
// 购物车对应商品
|
||||
var shoppingCartSnapshotDataMap = make(map[int64]gmodel.FsShoppingCartData, len(shoppingCartSnapshot))
|
||||
for _, shoppingCartSnapshotValue := range shoppingCartSnapshot {
|
||||
var shoppingCartSnapshotData gmodel.FsShoppingCartData
|
||||
snapshot, err := d.OrderShoppingCartSnapshotHandler(ctx, shoppingCartSnapshotValue.Snapshot)
|
||||
var snapshot map[string]interface{}
|
||||
err = json.Unmarshal([]byte(*shoppingCartSnapshotValue.Snapshot), &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
|
||||
shoppingCartSnapshotDataMap[shoppingCartSnapshotValue.Id] = gmodel.FsShoppingCartData{
|
||||
Id: shoppingCartSnapshotValue.Id,
|
||||
UserId: shoppingCartSnapshotValue.UserId,
|
||||
ProductId: shoppingCartSnapshotValue.ProductId,
|
||||
TemplateId: shoppingCartSnapshotValue.TemplateId,
|
||||
ModelId: shoppingCartSnapshotValue.ModelId,
|
||||
SizeId: shoppingCartSnapshotValue.SizeId,
|
||||
LightId: shoppingCartSnapshotValue.LightId,
|
||||
FittingId: shoppingCartSnapshotValue.FittingId,
|
||||
PurchaseQuantity: shoppingCartSnapshotValue.PurchaseQuantity,
|
||||
IsSelected: shoppingCartSnapshotValue.IsSelected,
|
||||
IsHighlyCustomized: shoppingCartSnapshotValue.IsHighlyCustomized,
|
||||
Ctime: shoppingCartSnapshotValue.Ctime,
|
||||
Utime: shoppingCartSnapshotValue.Utime,
|
||||
Snapshot: &snapshot,
|
||||
}
|
||||
}
|
||||
var orderProductList []gmodel.OrderProduct
|
||||
for _, productValue := range orderProduct {
|
||||
var selectColorIndex int64
|
||||
var shoppingCartSnapshotData = shoppingCartSnapshotDataMap[productValue.CartId]
|
||||
var snapshotInfo = shoppingCartSnapshotData.Snapshot
|
||||
if snapshotInfo != nil {
|
||||
var snapshotInfoMap = *snapshotInfo
|
||||
if shoppingCartSnapshotData.Snapshot != nil {
|
||||
var snapshotInfoMap = *shoppingCartSnapshotData.Snapshot
|
||||
selectColorIndexV, selectColorIndexE := snapshotInfoMap["select_color_index"]
|
||||
if selectColorIndexE {
|
||||
selectColorIndex = selectColorIndexV.(int64)
|
||||
|
|
Loading…
Reference in New Issue
Block a user