多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 商品详情 >[danger]接口认证:**需要认证** ##### 响应说明 | 字段名 | 字段类型 | 字段说明 | | --- | --- | --- | | id | int | 商品id | | goods_name | string | 商品名 | | click_count | int | 点击数 | | goods_image | string | 商品主图 | | pay_type | int | 付款方式,0:现金支付,当前只有0 | | cash_rate | float | 现金比例(%) | | shipping_price | int | 邮费(分) | | lucy_score | int | 幸运积分 | | activity_type | int | 商品活动类型,另外列出 | | stock_number | int | 库存 | | sales | int | 销量 | | unpublished_at | string(datetime) | 下架时间,未设置为“”,设置后为“2022-01-01 00:00:00” | | is_recommend | int | 是否推荐,1:是,0:否 | | created_at | string(datetime) | 创建时间 | | shipping_price_format | string | 邮费价(已格式化) | | send_province_name | string | 发货省 | | send_city_name | string | 发货市 | | goods_ext | object | 商品额外信息 | | goods_ext.desc | string | 描述 | | goods_ext.contant | string | 详情内容 | | goods_ext.slide_images | array[string] | 轮播图 | | goods_skus | object | 商品规格细则 | | goods_skus.sku_id | string | 规格的id串 | | goods_skus.sku_name | string | 规格的名字串 | | goods_skus.sku_full_name | string | 已组合好的商品名 规格名,也可以自己组 | | goods_skus.shop_price | int | 本店价(分) | | goods_skus.shop_price_format | string | 本店价(已格式化) | | goods_skus.group_price | int | 团购价(分) | | goods_skus.group_price_format | string | 团购价(已格式化) | | goods_skus.market_price | int | 市场价(分) | | goods_skus.market_price_format | string | 市场价(已格式化) | | goods_skus.sales | int | 销量 | | goods_skus.stock_number | int | 库存 | | goods_skus.withdrawal_score | int | 消耗配额 | | goods_skus.goods_sku_ref_id | int | 商品的规格id,下单时用这个id下单不要用商品id下单 | | goods_skus.activity_info.activity_score_rate | float | 收益积分(批发积分)(%) | | goods_skus.activity_info.withdrawal_quota_rate | float | 收益积分(提现配额)(%) | | goods_skus.activity_info.activity_score_format | float | 赠送批发积分 | | goods_skus.activity_info.withdrawal_quota_format | float | 赠送提现配额 | | goods_skus.activity_info.wholesale_limit | int | 批发限购 | | goods_skus.activity_info.group_buying_limit| int | 团购限购 | | goods_skus.activity_info.group_buying_scale| int | 团购参团人数 | | goods_skus.activity_info.gold_vip_score| int | 养老积分抵扣 | | goods_skus.group_buy_info |array[object]|团购信息| | goods_skus.group_buy_info.group_buying_start |string|团购开始时间| | goods_skus.group_buy_info.group_buying_countdown|int|团购倒计时(分)| | goods_skus.group_buy_info.group_buying_count|int|当前参团人数| | goods_skus.group_buy_info.group_buying_scale|int|成团人数| | goods_skus.group_buy_info.group_buying_left|int|剩余成团人数| | goods_skus.group_buy_info.group_buying_id|int|拼团id| | goods_skus.group_buy_info.goods_sku_id|int|商品规格id| | goods_skus.group_buy_info.group_buying_time_left|int|剩余成团时间(秒)| | goods_skus.group_buy_info.group_buying_user_list|array[object]|当前拼团用户列表| | goods_skus.group_buy_info.group_buying_user_list.user_id|int|用户id| | goods_skus.group_buy_info.group_buying_user_list.avatar|string|用户头像| | goods_attrs | array[object] | 商品属性 | | goods_attrs.name | string | 属性名 | | goods_attrs.value | string | 属性值 | | activity_info | object | 活动信息 | | sku_list | array[object] | 规格选项信息 | | sku_list.sku_group_name | string | 规格大类名字 | | sku_list.sku_list | array[object] | 规格大类的选项 | | sku_list.sku_list.sku_id | int | 规格的id | | sku_list.sku_list.sku_name | string | 规格的名字 | ##### 商品活动类型 ```php public const ACTIVITY_TYPE_TRANS = [ 0 => "普通", 1 => '活动', 2 => '批发', 3 => '团购', 4 => '黄金会员专区', 5 => '提现配额专区', 6 => '0元体验', ]; ``` ##### api说明 ~~~[api] get:/goods/detail?id=30 *int:id=30#商品id <<< success { "code": 200, "msg": "成功", "data": { "id": 29, "goods_name": "团购-衣服-规格", "click_count": 4, "goods_image": "http://noobcoder.oss-cn-hangzhou.aliyuncs.com/letao/20220112/goods_image-61de3872655d3.jpg", "pay_type": 0, "cash_rate": "100", "shipping_price": 0, "lucy_score": 0, "activity_type": 3, "stock_number": 80, "sales": 0, "unpublished_at": "", "is_recommend": 1, "created_at": "2022-01-12 10:09:58", "goods_ext": { "desc": "", "content": "", "slide_images": [ "http://noobcoder.oss-cn-hangzhou.aliyuncs.com/letao/20220112/goodsExt.slide_images-61de387470146.jpg" ] }, "goods_skus": [ { "sku_id": "", "sku_name": "", "sku_full_name": "团购-衣服-规格 ", "shop_price": 100000, "group_price": 90000, "sales": 0, "stock_number": 80, "withdrawal_score": 0, "goods_sku_ref_id": 26, "shop_price_format": 1000, "group_price_format": 900, "market_price": 0, "market_price_format": 0, "activity_info": { "wholesale_limit": 0, "group_buying_limit": 5, "group_buying_scale": 2, "gold_vip_score": 0, "activity_score_rate": 20, "withdrawal_quota_rate": 100, "activity_score_format": 200, "withdrawal_quota_format": 1000 }, "group_buy_info": [ { "group_buying_id": 5, "goods_sku_id": 26, "group_buying_start": "2022-02-18 16:00:44", "group_buying_countdown": 1800000, "group_buying_count": 2, "group_buying_scale": 2, "group_buying_left": 0, "group_buying_time_left": 1543366, "group_buying_user_list": [ { "user_id": 20, "avatar": "http://noobcoder.oss-cn-hangzhou.aliyuncs.com/letao/app/user/updateAvatar/61ef9247d6597.png" }, { "user_id": 21, "avatar": "http://noobcoder.oss-cn-hangzhou.aliyuncs.com/letao/20220120/avatar-61e8f49481d2f.png" } ] } ] } ], "goods_attrs": [ { "name": "品牌", "value": "耐不克" }, { "name": "材质", "value": "纯棉" } ], "sku_list": [], "shipping_price_format": 0, "send_province_name": "天津市", "send_city_name": "天津市" } } ~~~ ## 额外说明 1. 请求接口的id和下单的id并不是一个id,请求商品的id`goods_id`是这个商品的集合,下单的商品id`goods_sku_ref_id`是这个商品的某一个单位的id,类似于查看一件衣服的详情和购买一件红色L号的衣服的关系 2. 在未设置规格(sku_list为空数组的情况下)应该取出`goods_skus`中的第一个规格提交订单 3. 在设置了规格的情况下,可以通循环过`goods_skus[]`的方式寻找规格,`goods_skus`中的每一项的属性名都是由一个或多个`sku_id`组成,规律为先将`sku_id`数组`由小到大排列`,然后用`,,`连接,前后加上`,`,类似于`sku_ids = "," + sku_id_arr.sort()join(',,') + ","` 4. `goods_attrs`是一个商品的属性列表,参考淘宝等购物软件中商品详情中的参数 ## 可能出现的错误码 > 不包含常见的请求方式错误,参数丢失,用户权限验证失败 ~~~ const GOODS_NOT_FOUND = [ 'code' => 111001, 'msg' => '商品不存在' ]; ~~~ ~~~ const GOODS_EMPTY_SKU = [ 'code' => 111002, 'msg' => '商品规格信息不存在' ]; ~~~