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