fix:调整订单列表
This commit is contained in:
parent
9a82b28377
commit
b45645edc3
|
@ -1282,7 +1282,8 @@ func (d *defaultOrder) List(ctx context.Context, in *ListReq) (res *ListRes, err
|
|||
}
|
||||
}
|
||||
var count int64
|
||||
resultCount := model.Count(&count)
|
||||
var modelTotal = model
|
||||
resultCount := modelTotal.Count(&count)
|
||||
if resultCount.Error != nil {
|
||||
logc.Errorf(ctx, "order count failed, err: %v", err)
|
||||
return nil, resultCount.Error
|
||||
|
@ -1307,11 +1308,19 @@ func (d *defaultOrder) List(ctx context.Context, in *ListReq) (res *ListRes, err
|
|||
orderDetailList = make([]gmodel.OrderDetail, 0)
|
||||
}
|
||||
|
||||
var pageCount int64 = 1
|
||||
if count > in.PerPage {
|
||||
var float64Count = float64(count)
|
||||
var float64PerPage = float64(in.PerPage)
|
||||
pageCountFloat := math.Ceil(float64Count / float64PerPage)
|
||||
pageCount = int64(pageCountFloat)
|
||||
}
|
||||
|
||||
return &ListRes{
|
||||
OrderDetailList: orderDetailList,
|
||||
Meta: map[string]int64{
|
||||
"total_count": count,
|
||||
"page_count": count / in.PerPage,
|
||||
"page_count": pageCount,
|
||||
"current_page": in.CurrentPage,
|
||||
"per_page": in.PerPage,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user