fix:基础信息
This commit is contained in:
parent
e01884cce6
commit
1605da27bf
|
@ -47,7 +47,7 @@ func (l *OrderDetailLogic) OrderDetail(req *types.OrderDetailReq, userinfo *auth
|
|||
}
|
||||
|
||||
return resp.SetStatus(basic.CodeOK, map[string]interface{}{
|
||||
"order_detail": res,
|
||||
"order_detail": res.OrderDetail,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
// 下单
|
||||
|
|
|
@ -18,7 +18,7 @@ func CentitoDollar(price int64, remainFloatPoint ...uint) float64 {
|
|||
}
|
||||
|
||||
// 厘转美元
|
||||
func CentitoDollarStr(price int64) string {
|
||||
func CentitoDollarStr(price float64) string {
|
||||
s := "%.2f"
|
||||
return fmt.Sprintf(s, float64(price)/float64(1000))
|
||||
return fmt.Sprintf(s, price/float64(1000))
|
||||
}
|
||||
|
|
|
@ -91,9 +91,9 @@ type GetAmountCurrencyUSDReq struct {
|
|||
// 处理金额(元)
|
||||
func GetAmountCurrencyFormat(req *gmodel.AmountCurrency) (res gmodel.AmountCurrency) {
|
||||
return gmodel.AmountCurrency{
|
||||
ExchangeRate: format.CentitoDollarStr(req.ExchangeRate.(int64)),
|
||||
CurrentAmount: format.CentitoDollarStr(req.CurrentAmount.(int64)),
|
||||
OriginalAmount: format.CentitoDollarStr(req.OriginalAmount.(int64)),
|
||||
ExchangeRate: format.CentitoDollarStr(req.ExchangeRate.(float64)),
|
||||
CurrentAmount: format.CentitoDollarStr(req.CurrentAmount.(float64)),
|
||||
OriginalAmount: format.CentitoDollarStr(req.OriginalAmount.(float64)),
|
||||
CurrentCurrency: req.CurrentCurrency,
|
||||
OriginalCurrency: req.OriginalCurrency,
|
||||
}
|
||||
|
@ -101,6 +101,8 @@ func GetAmountCurrencyFormat(req *gmodel.AmountCurrency) (res gmodel.AmountCurre
|
|||
|
||||
// 处理金额(元)
|
||||
func GetAmountInfoFormat(req *gmodel.AmountInfo) gmodel.AmountInfo {
|
||||
Current := GetAmountCurrencyFormat(&req.Current)
|
||||
fmt.Println(Current)
|
||||
return gmodel.AmountInfo{
|
||||
Change: GetAmountCurrencyFormat(&req.Change),
|
||||
ChangeRemark: req.ChangeRemark,
|
||||
|
|
Loading…
Reference in New Issue
Block a user