Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop
This commit is contained in:
commit
0a4368ba7f
|
@ -41,32 +41,24 @@ 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
|
||||
//获取用户购物车列表
|
||||
var cartIds []int64
|
||||
if req.CartId > 0 {
|
||||
cartIds = append(cartIds, req.CartId)
|
||||
}
|
||||
carts, total, err := l.svcCtx.AllModels.FsShoppingCart.GetAllCartsByParam(l.ctx, gmodel.GetAllCartsByParamReq{
|
||||
Ids: 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 +193,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"` //当前页
|
||||
CartId int64 `form:"cart_id,optional"` //购物车ids可选
|
||||
}
|
||||
|
||||
type GetCartsRsp struct {
|
||||
|
|
|
@ -49,7 +49,7 @@ type DeleteCartReq {
|
|||
|
||||
//获取购物车列表
|
||||
type GetCartsReq {
|
||||
CurrentPage int `form:"current_page"` //当前页
|
||||
CartId int64 `form:"cart_id,optional"` //购物车ids可选
|
||||
}
|
||||
type GetCartsRsp {
|
||||
Meta Meta `json:"meta"` //分页信息
|
||||
|
|
Loading…
Reference in New Issue
Block a user