Properties

$error

$error : 

Type

$user

$user : 

Type

$user_id

$user_id : 

Type

$wxapp_id

$wxapp_id : 

Type

$cart

$cart : 

Type

$clear

$clear : 

Type

Methods

getList()

getList(string  $cartIds) : array

购物车列表 (含商品信息)

Parameters

string $cartIds

请求参数

Throws

\think\Exception
\think\db\exception\DataNotFoundException
\think\db\exception\ModelNotFoundException
\think\exception\DbException

Returns

array

getCartList()

getCartList(string|null  $cartIds = null) : array

获取购物车列表

Parameters

string|null $cartIds

购物车索引集 (为null时则获取全部)

Returns

array

add()

add(integer  $goodsId, integer  $goodsNum, string  $goodsSkuId) : boolean

加入购物车

Parameters

integer $goodsId

商品id

integer $goodsNum

加入购物车的数量

string $goodsSkuId

商品sku索引

Throws

\app\common\exception\BaseException
\think\exception\DbException

Returns

boolean

sub()

sub(integer  $goodsId, string  $goodsSkuId) 

减少购物车中某商品数量

Parameters

integer $goodsId
string $goodsSkuId

delete()

delete(string  $cartIds) 

删除购物车中指定商品

Parameters

string $cartIds

(支持字符串ID集)

getTotalNum()

getTotalNum() : integer

获取当前用户购物车商品总数量(含件数)

Returns

integer

getGoodsNum()

getGoodsNum() : integer

获取当前用户购物车商品总数量(不含件数)

Returns

integer

__destruct()

__destruct() 

析构方法 将cart数据保存到缓存文件

clearAll()

clearAll(null  $cartIds = null) 

清空当前用户购物车

Parameters

null $cartIds

getError()

getError() : string

获取错误信息

Returns

string

getOrderGoodsList()

getOrderGoodsList(  $cartIds) : array|boolean

获取购物车中的商品列表

Parameters

$cartIds

Throws

\think\Exception
\think\db\exception\DataNotFoundException
\think\db\exception\ModelNotFoundException
\think\exception\DbException

Returns

array|boolean

isExistGoodsId()

isExistGoodsId(  $goodsId) : boolean

验证购物车中是否存在某商品

Parameters

$goodsId

Returns

boolean

checkGoods()

checkGoods(\app\api\model\Goods  $goods, string  $goodsSkuId,   $cartGoodsNum) : boolean

验证商品是否可以购买

Parameters

\app\api\model\Goods $goods

商品信息

string $goodsSkuId

商品sku索引

$cartGoodsNum

Returns

boolean

setError()

setError(  $error) 

设置错误信息

Parameters

$error