up
This commit is contained in:
@@ -684,16 +684,16 @@ func SaveUserCart(ctx *jxcontext.Context, userID string, storeID int, cartItems
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadUserCart(ctx *jxcontext.Context, userID string, storeID int) (cartItems []*model.UserCartItem, err error) {
|
func LoadUserCart(ctx *jxcontext.Context, userID string, storeIDs []int) (cartItems []*model.UserCartItem, err error) {
|
||||||
if userID == "" || storeID == 0 {
|
if userID == "" || len(storeIDs) == 0 {
|
||||||
return nil, fmt.Errorf("用户与门店必须要指定")
|
return nil, fmt.Errorf("用户与门店必须要指定")
|
||||||
}
|
}
|
||||||
sql := `
|
sql := `
|
||||||
SELECT t1.*
|
SELECT t1.*
|
||||||
FROM user_cart_item t1
|
FROM user_cart_item t1
|
||||||
WHERE t1.user_id = ? AND t1.store_id = ?
|
WHERE t1.user_id = ? AND t1.store_id IN (` + dao.GenQuestionMarks(len(storeIDs)) + `)
|
||||||
ORDER BY t1.sku_id
|
ORDER BY t1.sku_id
|
||||||
`
|
`
|
||||||
err = dao.GetRows(dao.GetDB(), &cartItems, sql, userID, storeID)
|
err = dao.GetRows(dao.GetDB(), &cartItems, sql, userID, storeIDs)
|
||||||
return cartItems, err
|
return cartItems, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -328,14 +328,17 @@ func (c *User2Controller) QueryMyDeliveryAddress() {
|
|||||||
// @Title 得到用户指定门店的购物车信息
|
// @Title 得到用户指定门店的购物车信息
|
||||||
// @Description 得到用户指定门店的购物车信息
|
// @Description 得到用户指定门店的购物车信息
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param storeID query int true "门店ID"
|
// @Param storeIDs query string true "门店ID"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /LoadMyCart [get]
|
// @router /LoadMyCart [get]
|
||||||
func (c *User2Controller) LoadMyCart() {
|
func (c *User2Controller) LoadMyCart() {
|
||||||
c.callLoadMyCart(func(params *tUser2LoadMyCartParams) (retVal interface{}, errCode string, err error) {
|
c.callLoadMyCart(func(params *tUser2LoadMyCartParams) (retVal interface{}, errCode string, err error) {
|
||||||
_, userID := params.Ctx.GetMobileAndUserID()
|
_, userID := params.Ctx.GetMobileAndUserID()
|
||||||
retVal, err = cms.LoadUserCart(params.Ctx, userID, params.StoreID)
|
var storeIDs []int
|
||||||
|
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err == nil {
|
||||||
|
retVal, err = cms.LoadUserCart(params.Ctx, userID, storeIDs)
|
||||||
|
}
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -344,7 +347,7 @@ func (c *User2Controller) LoadMyCart() {
|
|||||||
// @Description 存储用户指定门店的购物车信息
|
// @Description 存储用户指定门店的购物车信息
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param storeID formData int true "门店ID"
|
// @Param storeID formData int true "门店ID"
|
||||||
// @Param payload formData string true "完整的购物车商品列表"
|
// @Param payload formData string false "完整的购物车商品列表"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /SaveMyCart [post]
|
// @router /SaveMyCart [post]
|
||||||
|
|||||||
Reference in New Issue
Block a user