商品列表
方法概览
| 项目 | 内容 |
|---|---|
| 文档类型 | PHP 类方法 |
| 方法标识 | app\common\model\ProductModel::productList |
| 所属业务 | 商品管理 |
| 来源模块/系统 | 商品模型 |
功能说明
商品列表
调用示例
$param = ['keywords' => '示例关键字', 'product_group_id' => 1, 'page' => 1, 'limit' => 1, 'orderby' => 'id', 'sort' => 'string', 'exclusive' => true];
$result = (new \app\common\model\ProductModel())->productList($param);参数
| 参数 | 类型 | 必填 | 默认值 | 校验规则 | 说明 |
|---|---|---|---|---|---|
param.keywords | string | 否 | — | — | 关键字,搜索范围:商品ID,商品名,描述 |
param.product_group_id | int | 否 | — | — | 商品分组ID |
param.page | int | 否 | — | — | 页数 |
param.limit | int | 否 | — | — | 每页条数 |
param.orderby | string | 否 | — | — | 排序 id,name,description |
param.sort | string | 否 | — | — | 升/降序 asc,desc |
param.exclusive | bool | 否 | — | — | 是否只返回专属商品 |
返回值
| 返回项 | 类型 | 说明 |
|---|---|---|
list | array | 商品列表 |
list[].id | int | ID |
list[].name | int | 商品名 |
list[].description | int | 描述 |
list[].pay_type | string | 付款类型(免费free,一次onetime,周期先付recurring_prepayment,周期后付recurring_postpaid |
list[].stock_control | int | 是否开启库存控制:1开启,0关闭 |
list[].qty | int | 库存 |
list[].hidden | int | 是否隐藏:1隐藏,0显示 |
list[].product_group_name_second | int | 二级分组名称 |
list[].product_group_id_second | int | 二级分组ID |
list[].product_group_name_first | int | 一级分组名称 |
list[].product_group_id_first | int | 一级分组ID |
list[].price | string | 商品最低价格 |
list[].mode | string | 代理模式:only_api仅调用接口,sync同步商品 |
list[].client_level_name | string | 用户等级名称,这个字段在没有用户等级插件时不存在,所以需要注意判断 |
count | int | 商品总数 |
正常返回
{
"list": [
{
"id": 1,
"name": 1,
"description": 1,
"pay_type": "string",
"stock_control": 1,
"qty": 1,
"hidden": 1,
"product_group_name_second": 1,
"product_group_id_second": 1,
"product_group_name_first": 1,
"product_group_id_first": 1,
"price": "string",
"mode": "string",
"client_level_name": "示例名称"
}
],
"count": 1
}异常情况
| 异常类型 | 说明 |
|---|---|
Throwable | 调用失败时由具体实现抛出异常,异常信息以运行时结果为准。 |