fix
This commit is contained in:
parent
bea1fd230a
commit
2054b9ec97
|
@ -41,32 +41,23 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo
|
|||
if !userinfo.IsUser() {
|
||||
return resp.SetStatusWithMessage(basic.CodeUnAuth, "please sign in")
|
||||
}
|
||||
if req.CurrentPage <= 0 {
|
||||
req.CurrentPage = constants.DEFAULT_PAGE
|
||||
}
|
||||
currentPage := constants.DEFAULT_PAGE
|
||||
limit := 300
|
||||
if len(req.CartIds) > limit {
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "err param:request cart item is too much")
|
||||
}
|
||||
//获取用户购物车列表
|
||||
carts, total, err := l.svcCtx.AllModels.FsShoppingCart.GetAllCartsByParam(l.ctx, gmodel.GetAllCartsByParamReq{
|
||||
Ids: req.CartIds,
|
||||
UserId: userinfo.UserId,
|
||||
Sort: "id DESC",
|
||||
Page: req.CurrentPage,
|
||||
Page: currentPage,
|
||||
Limit: limit,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "system err:failed to get your shopping carts")
|
||||
}
|
||||
if len(carts) == 0 {
|
||||
return resp.SetStatusWithMessage(basic.CodeOK, "success", types.GetCartsRsp{
|
||||
Meta: types.Meta{
|
||||
TotalCount: total,
|
||||
PageCount: int64(math.Ceil(float64(total) / float64(limit))),
|
||||
CurrentPage: req.CurrentPage,
|
||||
PerPage: limit,
|
||||
},
|
||||
CartList: nil,
|
||||
})
|
||||
}
|
||||
var (
|
||||
mapSize = make(map[int64]gmodel.FsProductSize)
|
||||
mapModel = make(map[int64]gmodel.FsProductModel3d)
|
||||
|
@ -201,7 +192,7 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo
|
|||
Meta: types.Meta{
|
||||
TotalCount: total,
|
||||
PageCount: int64(math.Ceil(float64(total) / float64(limit))),
|
||||
CurrentPage: req.CurrentPage,
|
||||
CurrentPage: currentPage,
|
||||
PerPage: limit,
|
||||
},
|
||||
CartList: list,
|
||||
|
|
|
@ -30,7 +30,7 @@ type DeleteCartReq struct {
|
|||
}
|
||||
|
||||
type GetCartsReq struct {
|
||||
CurrentPage int `form:"current_page"` //当前页
|
||||
CartIds []int64 `json:"cart_id,optional"` //购物车ids可选
|
||||
}
|
||||
|
||||
type GetCartsRsp struct {
|
||||
|
|
|
@ -49,7 +49,7 @@ type DeleteCartReq {
|
|||
|
||||
//获取购物车列表
|
||||
type GetCartsReq {
|
||||
CurrentPage int `form:"current_page"` //当前页
|
||||
CartIds []int64 `json:"cart_id,optional"` //购物车ids可选
|
||||
}
|
||||
type GetCartsRsp {
|
||||
Meta Meta `json:"meta"` //分页信息
|
||||
|
|
Loading…
Reference in New Issue
Block a user