## 接口情況
作者:ncgis
時間:20150506
作用:獲取商品詳細信息(主要是圖片價格快遞信息)
提交方法:GET
提交參數
~~~
good_id:商品id
~~~
所在文件:product
接口地址:http://test.lingsq.com/index.php/api?method=lingsqapi.api.product.getProductdDetail&good_id=[good\_id]
返回數據樣式:
~~~
## 格式一
{
"data": {
"login": {
"member_lv_id": "1",
"status": true
},
"goods": {
"name": "黃綠豆芽",
"price": "2.700",
"store": "10000.00",
"weight": "500.000",
"units": "g",
"appcontent": "",
"mktprice": "2.700",
"pic": [
{
"l": "http://test.lingsq.com/public/images/store76/03/d1/0a/cbfdef9850527859a279380a23424552.jpg?1435113666#h",
"m": "http://test.lingsq.com/public/images/store76/47/0b/30/f43a468bd0772ebe711af660380be760.jpg?1435113666#h",
"s": "http://test.lingsq.com/public/images/store76/96/bc/b2/e0dce8acf1fe359bc9ec1b1383475540.jpg?1435113666#h",
"image_id": "10f4c63be7867e13e624d57b657c8257"
},
{
"l": "http://test.lingsq.com/public/images/store76/9c/bd/77/bfa3d7838f7c370b1169c51f92d78d72.jpg?1435113669#h",
"m": "http://test.lingsq.com/public/images/store76/74/40/d5/8e6a02599d775244efe9eb274cab108a.jpg?1435113669#h",
"s": "http://test.lingsq.com/public/images/store76/74/0f/51/a7be1d03f7684ece168a9b31aa4b9207.jpg?1435113669#h",
"image_id": "eb1b4d5e09950b44493281944f2674a0"
},
{
"l": "http://test.lingsq.com/public/images/store76/29/7e/de/bf02603eecef99e06b71c13ce3800531.jpg?1435113672#h",
"m": "http://test.lingsq.com/public/images/store76/77/dc/0d/00e7a6a94113d819b6be660b61dfc073.jpg?1435113672#h",
"s": "http://test.lingsq.com/public/images/store76/76/27/fd/60bb65621ed15e3c0f4b2a4a977125f1.jpg?1435113672#h",
"image_id": "646be59d70cc8e626ef09cd26c0556dc"
},
{
"l": "http://test.lingsq.com/public/images/store76/78/af/28/d38f948065f0c91981ca4cc495e15486.jpg?1435113675#h",
"m": "http://test.lingsq.com/public/images/store76/b5/77/5b/112e37856a3427ce7f559d933243d342.jpg?1435113675#h",
"s": "http://test.lingsq.com/public/images/store76/1c/b6/51/941f787f8b0c4a30233bcb1e1f05f52c.jpg?1435113675#h",
"image_id": "195cd9b852f0b8bf841af42c75a8c6e8"
}
],
"description": "<img src=\"http://www.lingsq.com/public/images/store76/ea/92/19/80d9ea7a38b3538c28122ae073c93897.jpg?1427452930#h\">"
}
},
"errNo": 1,
"errMsg": "ok",
"res": ""
}
## 格式二
{
"data": {
"login": {
"member_lv_id": "1",
"status": true
},
"goods": {
"name": "test",
"price": "10.000",
"store": "400.00",
"weight": "0.000",
"units": "g",
"appcontent": "4345343",
"mktprice": "12.000",
"product": [
{
"mktprice": "12.000",
"price": "10.000",
"product_id": "721",
"spec_info": "size:m",
"store": "100.00",
"unit": "間",
"pic": [
{
"l": "http://test.lingsq.com/public/images/store76/b7/a0/7f/839a7ec639545a9de86c63ae6ef085ae.jpg?1435113148#h",
"m": "http://test.lingsq.com/public/images/store76/f9/89/c6/bea538ab23cc7cb14fa88cd3b2e35ad4.jpg?1435113148#h",
"s": "http://test.lingsq.com/public/images/store76/50/29/88/901a5126f399b6d87d72d31d4e7dae1f.jpg?1435113148#h",
"image_id": "9b03b050cb7ad236e5a43f59c754d1a8"
},
{
"l": "http://test.lingsq.com/public/images/store76/3f/94/2b/5af467fc939309774262e07b8c52dc09.jpg?1435113151#h",
"m": "http://test.lingsq.com/public/images/store76/37/7a/32/663ed4738371dba8a7123c8f7c1ea354.jpg?1435113151#h",
"s": "http://test.lingsq.com/public/images/store76/c2/70/8a/ac1900ab8291ad397702018b96a86acc.jpg?1435113151#h",
"image_id": "ad031281c07b5b8e477bd8779de91336"
}
],
"lvpric": [
{
"goods_id": "393",
"product_id": "721",
"level_id": "1",
"price": "9.000"
},
{
"goods_id": "393",
"product_id": "721",
"level_id": "2",
"price": "8.000"
},
{
"goods_id": "393",
"product_id": "721",
"level_id": "3",
"price": "7.000"
}
]
},
{
"mktprice": "13.200",
"price": "11.000",
"product_id": "722",
"spec_info": "size:l",
"store": "100.00",
"unit": "間",
"pic": [
{
"l": "http://test.lingsq.com/public/images/store76/3f/94/2b/5af467fc939309774262e07b8c52dc09.jpg?1435113151#h",
"m": "http://test.lingsq.com/public/images/store76/37/7a/32/663ed4738371dba8a7123c8f7c1ea354.jpg?1435113151#h",
"s": "http://test.lingsq.com/public/images/store76/c2/70/8a/ac1900ab8291ad397702018b96a86acc.jpg?1435113151#h",
"image_id": "ad031281c07b5b8e477bd8779de91336"
}
],
"lvpric": [
{
"goods_id": "393",
"product_id": "722",
"level_id": "1",
"price": "9.000"
},
{
"goods_id": "393",
"product_id": "722",
"level_id": "2",
"price": "8.000"
},
{
"goods_id": "393",
"product_id": "722",
"level_id": "3",
"price": "7.000"
}
]
},
{
"mktprice": "134.400",
"price": "112.000",
"product_id": "723",
"spec_info": "size:xl",
"store": "100.00",
"unit": "間",
"pic": [
{
"l": "http://test.lingsq.com/public/images/store76/b7/a0/7f/839a7ec639545a9de86c63ae6ef085ae.jpg?1435113148#h",
"m": "http://test.lingsq.com/public/images/store76/f9/89/c6/bea538ab23cc7cb14fa88cd3b2e35ad4.jpg?1435113148#h",
"s": "http://test.lingsq.com/public/images/store76/50/29/88/901a5126f399b6d87d72d31d4e7dae1f.jpg?1435113148#h",
"image_id": "9b03b050cb7ad236e5a43f59c754d1a8"
}
],
"lvpric": [
{
"goods_id": "393",
"product_id": "723",
"level_id": "1",
"price": "115.000"
},
{
"goods_id": "393",
"product_id": "723",
"level_id": "2",
"price": "114.000"
},
{
"goods_id": "393",
"product_id": "723",
"level_id": "3",
"price": "113.000"
}
]
},
{
"mktprice": "135.600",
"price": "113.000",
"product_id": "724",
"spec_info": "size:xxl",
"store": "100.00",
"unit": "間",
"pic": [
{
"l": "http://test.lingsq.com/public/images/store76/3f/94/2b/5af467fc939309774262e07b8c52dc09.jpg?1435113151#h",
"m": "http://test.lingsq.com/public/images/store76/37/7a/32/663ed4738371dba8a7123c8f7c1ea354.jpg?1435113151#h",
"s": "http://test.lingsq.com/public/images/store76/c2/70/8a/ac1900ab8291ad397702018b96a86acc.jpg?1435113151#h",
"image_id": "ad031281c07b5b8e477bd8779de91336"
}
],
"lvpric": [
{
"goods_id": "393",
"product_id": "724",
"level_id": "1",
"price": "11.000"
},
{
"goods_id": "393",
"product_id": "724",
"level_id": "2",
"price": "11.000"
},
{
"goods_id": "393",
"product_id": "724",
"level_id": "3",
"price": "11.000"
}
]
}
],
"description": "adsfsdfasdfasdfsdfa\n<img src=\"http://test.lingsq.com/public/images/store76/b5/bf/91/adbc2448d14d9055b78a6b5c9710bf4b.jpg?1430902823#h\">"
}
},
"errNo": 1,
"errMsg": "ok",
"res": ""
}
~~~
參數說明
~~~
~~~
## 實現代碼
~~~
/**
* @作者 ncgis
* @作用 主要是獲取商品的詳細信息
* @時間 20150506
* @請求方式 GET
* @提交參數 good_id 必選
* @返回數據格式:見文檔
* */
public function getProductdDetail()
{
if (empty($_GET["good_id"])) {
$back["errNo"] = 20005;
$back["errMsg"] = $this->errMsg($back["errNo"]);
return $back;
}
$gid = $_GET["good_id"];
$goodtable = app::get('b2c')->model('goods'); //最大產品
$productstable = app::get('b2c')->model('products'); //產品
$image_attachtable = app::get('image')->model('image_attach');
$goods_lv_pricetable = app::get('b2c')->model('goods_lv_price'); //價格
$filter["goods_id"] = $gid;
$goods = $goodtable->getList("name,price,store,weight,units,appcontent,mktprice,spec_desc",$filter);
unset($filter);
if (empty($goods)) {
$pagedata["errNo"] = 20009;
$pagedata["errMsg"] = $this->errMsg($pagedata["errNo"]);
return $pagedata;
}
$goods[0]["units"] = empty($goods[0]["units"]) ? "g" : $goods[0]["units"];
$filter["goods_id"] = $gid;
//
$product = $productstable->getList("mktprice,price,product_id,spec_info,store,unit,spec_desc",$filter);
unset($filter);
$filter["target_id"] = $gid;
$filter["target_type"] = "goods";
$images = $image_attachtable->getList("*", $filter);
$siteMember = $this->libProduct->get_current_member();
$login['member_lv_id'] = $siteMember['member_lv'];
$login['status'] = $siteMember['member_id'] ? true : false;
$back["data"]["login"] = $login;
unset($filter);
if (!empty($goods["0"]["spec_desc"]))
{
foreach ($product as $key => $v)
{
$spec_private_value_idarray = array_keys($v["spec_desc"]["spec_private_value_id"]);
$spec_private_value = array_values($v["spec_desc"]["spec_private_value_id"]);
array_push($spec_private_value_idarray, $spec_private_value["0"]);
$picid = explode(",", $goods["0"]["spec_desc"][$spec_private_value_idarray["0"]][$spec_private_value_idarray["1"]]["spec_goods_images"]);
$filter["image_id|in"] = $picid;
$images = $image_attachtable->getList("*", $filter);
$product[$key]["pic"] = $this->libProduct->getImageUrl($images);
unset($filter);
$filter["goods_id"] = $gid;
$filter["product_id"] = $v["product_id"];
$lvpric = $goods_lv_pricetable->getList("*", $filter);
if (!empty($lvpric)) {
$product[$key]["lvpric"] = $lvpric;
}
unset($product[$key]["spec_desc"]);
}
unset($goods["0"]["spec_desc"]);
$goods["0"]["product"] = $product;
$back["data"]["goods"] = $goods["0"];
$back["data"]["goods"]["description"] = $this->getProductNewsDetail($gid);
}
else
{
unset($goods["0"]["spec_desc"]);
$goods["0"]["pic"] = $this->libProduct->getImageUrl($images);
$filter["goods_id"] = $gid;
$lvpric = $goods_lv_pricetable->getList("*", $filter);
if (!empty($lvpric)) {
$goods["0"]["lvpric"] = $lvpric;
}
$goods["0"]["description"] = $this->getProductNewsDetail($gid);
$back["data"]["goods"] = $goods["0"];
//$back["data"]["goods"] = $goods["0"];
}
$back["errNo"] = 1;
$back["errMsg"] = $this->errMsg($back["errNo"]);
return $back;
}
/**
* @作用 主要是獲取商品的詳細信息 完
* */
public function getProductNewsDetail($goods_id)
{
$org_aGoods = kernel::single('b2c_goods_model')->getGoods($goods_id);
return $org_aGoods['description'];
}
~~~
- 手機是否使用驗證接口
- 返回碼所代表的含義
- 發送手機驗證碼接口
- 用戶注冊接口
- 獲取商品所有分類
- 獲取商品列表
- 用戶登陸接口
- 獲取商品詳細信息
- 獲取產品圖文詳情
- 獲取商品評論列表
- 獲取推薦商品
- 獲取找回密碼短信
- 重置密碼
- 獲取每日特惠商品
- 獲取輪播圖
- 用戶中心首頁
- 獲取用戶收藏商品
- 刪除用戶收藏商品
- 獲取所有訂單(所有訂單、代付款訂單、待收貨訂單、退換貨訂單)
- 加入購物車
- 獲取購物車商品
- 刪除購物車商品
- 購物車商品移入收藏夾
- 添加收貨地址
- 獲取用戶收貨地址
- 添加用戶收藏
- 提交訂單
- 填寫訂單
- 退出登錄
- 確認支付成功(正在驗證支付狀態)
- 驗證自動登陸
- 獲取訂單詳情
- 設置默認收貨地址
- 刪除收貨地址
- 修改收貨地址