添加用户购买车加载与存储操作

This commit is contained in:
gazebo
2019-10-21 14:17:30 +08:00
parent 73feffcac2
commit d24b8ea53d
4 changed files with 86 additions and 3 deletions

View File

@@ -324,3 +324,37 @@ func (c *User2Controller) QueryMyDeliveryAddress() {
return retVal, "", err
})
}
// @Title 得到用户指定门店的购物车信息
// @Description 得到用户指定门店的购物车信息
// @Param token header string true "认证token"
// @Param storeID query int true "门店ID"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /LoadMyCart [get]
func (c *User2Controller) LoadMyCart() {
c.callLoadMyCart(func(params *tUser2LoadMyCartParams) (retVal interface{}, errCode string, err error) {
_, userID := params.Ctx.GetMobileAndUserID()
retVal, err = cms.LoadUserCart(params.Ctx, userID, params.StoreID)
return retVal, "", err
})
}
// @Title 存储用户指定门店的购物车信息
// @Description 存储用户指定门店的购物车信息
// @Param token header string true "认证token"
// @Param storeID formData int true "门店ID"
// @Param payload formData string true "完整的购物车商品列表"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /SaveMyCart [post]
func (c *User2Controller) SaveMyCart() {
c.callSaveMyCart(func(params *tUser2SaveMyCartParams) (retVal interface{}, errCode string, err error) {
var cartItems []*model.UserCartItem
_, userID := params.Ctx.GetMobileAndUserID()
if err = jxutils.Strings2Objs(params.Payload, &cartItems); err == nil {
err = cms.SaveUserCart(params.Ctx, userID, params.StoreID, cartItems)
}
return retVal, "", err
})
}