fix:基础信息

This commit is contained in:
momo
2023-09-21 14:26:14 +08:00
parent e01884cce6
commit 1605da27bf
4 changed files with 29 additions and 14 deletions

View File

@@ -63,6 +63,7 @@ type (
OrderSn string `json:"order_sn"`
}
DetailRes struct {
OrderDetail gmodel.OrderDetail
}
/* 详情 */
)
@@ -72,10 +73,16 @@ func (d *defaultOrder) Detail(ctx context.Context, in *DetailReq) (res *DetailRe
var order gmodel.FsOrder
result := d.MysqlConn.Where("order_sn = ?", in.OrderSn).Where("user_id = ?", in.UserId).Take(&order)
if result.Error != nil {
logx.Errorf("detail failed, err: %v", err)
return nil, result.Error
}
d.OrderDetailHandler(ctx, &order)
return &DetailRes{}, nil
ress, err := d.OrderDetailHandler(ctx, &order)
if err != nil {
return nil, err
}
return &DetailRes{
ress.OrderDetail,
}, nil
}
func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel.FsOrder) (res *DetailRes, err error) {
@@ -83,17 +90,23 @@ func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel
err = json.Unmarshal(*orderInfo.Metadata, &orderDetail)
if err != nil {
logx.Errorf("create handler unmarshal metadata failed, err: %v", err)
logx.Errorf("detail handler unmarshal metadata failed, err: %v", err)
return nil, err
}
for _, orderProduct := range orderDetail.OrderProduct {
orderProduct.TotalPrice = order.GetAmountInfoFormat(&orderProduct.TotalPrice)
orderProduct.ItemPrice = order.GetAmountInfoFormat(&orderProduct.ItemPrice)
orderProduct.ShoppingCartSnapshot = nil
for orderProductKey, orderProduct := range orderDetail.OrderProduct {
orderDetail.OrderProduct[orderProductKey].TotalPrice = order.GetAmountInfoFormat(&orderProduct.TotalPrice)
orderDetail.OrderProduct[orderProductKey].ItemPrice = order.GetAmountInfoFormat(&orderProduct.ItemPrice)
orderDetail.OrderProduct[orderProductKey].ShoppingCartSnapshot = nil
orderDetail.OrderProduct[orderProductKey].ProductSnapshot = nil
}
orderDetail.OrderInfo.StatusLink = order.GetOrderStatusLinkUser(orderDetail.OrderInfo.DeliveryMethod, orderDetail.OrderInfo.StatusLink)
orderDetail.OrderAmount.Deposit.PayAmount = order.GetAmountInfoFormat(&orderDetail.OrderAmount.Deposit.PayAmount)
return nil, nil
orderDetail.OrderAmount.RemainingBalance.PayAmount = order.GetAmountInfoFormat(&orderDetail.OrderAmount.RemainingBalance.PayAmount)
orderDetail.OrderAmount.Subtotal = order.GetAmountInfoFormat(&orderDetail.OrderAmount.Subtotal)
orderDetail.OrderAmount.Total = order.GetAmountInfoFormat(&orderDetail.OrderAmount.Total)
return &DetailRes{
OrderDetail: orderDetail,
}, nil
}
// 下单