|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
declare(strict_types=1); |
|
|
|
|
|
|
|
|
|
namespace app\common\service; |
|
|
|
@ -8,7 +9,8 @@ namespace app\common\service; |
|
|
|
|
/** |
|
|
|
|
* 京东服务 |
|
|
|
|
*/ |
|
|
|
|
class Jd extends BaseService { |
|
|
|
|
class Jd extends BaseService |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取京东商品库存 |
|
|
|
@ -20,7 +22,8 @@ class Jd extends BaseService { |
|
|
|
|
* @param integer $skuNum [description] |
|
|
|
|
* @return [type] [description] |
|
|
|
|
*/ |
|
|
|
|
public function getGoodsStock($provinceId, $cityId, $countyId,$skuId, $skuNum = 1){ |
|
|
|
|
public function getGoodsStock($provinceId, $cityId, $countyId, $skuId, $skuNum = 1) |
|
|
|
|
{ |
|
|
|
|
$data = [ |
|
|
|
|
'provinceId' => $provinceId, |
|
|
|
|
'cityId' => $cityId, |
|
|
|
@ -33,18 +36,18 @@ class Jd extends BaseService { |
|
|
|
|
//exit(); |
|
|
|
|
$curl = curl_init(); |
|
|
|
|
curl_setopt_array($curl, array( |
|
|
|
|
CURLOPT_URL => 'https://vapi.jd.com/index/sku/getAsynDetail?'.http_build_query($data), |
|
|
|
|
CURLOPT_RETURNTRANSFER => true, |
|
|
|
|
CURLOPT_ENCODING => '', |
|
|
|
|
CURLOPT_MAXREDIRS => 10, |
|
|
|
|
CURLOPT_TIMEOUT => 0, |
|
|
|
|
CURLOPT_FOLLOWLOCATION => true, |
|
|
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
|
|
|
CURLOPT_CUSTOMREQUEST => 'GET', |
|
|
|
|
CURLOPT_HTTPHEADER => array( |
|
|
|
|
'Host: vapi.jd.com', |
|
|
|
|
'Referer: https://bpro.jd.com/' |
|
|
|
|
), |
|
|
|
|
CURLOPT_URL => 'https://vapi.jd.com/index/sku/getAsynDetail?' . http_build_query($data), |
|
|
|
|
CURLOPT_RETURNTRANSFER => true, |
|
|
|
|
CURLOPT_ENCODING => '', |
|
|
|
|
CURLOPT_MAXREDIRS => 10, |
|
|
|
|
CURLOPT_TIMEOUT => 0, |
|
|
|
|
CURLOPT_FOLLOWLOCATION => true, |
|
|
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, |
|
|
|
|
CURLOPT_CUSTOMREQUEST => 'GET', |
|
|
|
|
CURLOPT_HTTPHEADER => array( |
|
|
|
|
'Host: vapi.jd.com', |
|
|
|
|
'Referer: https://bpro.jd.com/' |
|
|
|
|
), |
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
$response = curl_exec($curl); |
|
|
|
@ -65,9 +68,10 @@ class Jd extends BaseService { |
|
|
|
|
* @param [type] $skuId [description] |
|
|
|
|
* @return [type] [description] |
|
|
|
|
*/ |
|
|
|
|
public function getGoodsMainImageAndDetail($skuId){ |
|
|
|
|
public function getGoodsMainImageAndDetail($skuId) |
|
|
|
|
{ |
|
|
|
|
//$url = "http://47.98.251.206:8811/api/goods/info/v2?sku=".$skuId."&areaId="; |
|
|
|
|
$url = "http://8.130.98.31:8811/api/goods/info/v2?sku=".$skuId."&areaId="; |
|
|
|
|
$url = "http://8.130.98.31:8811/api/goods/info/v2?sku=" . $skuId . "&areaId="; |
|
|
|
|
$res = httpRequest($url); |
|
|
|
|
if ($res && $res['code'] == 0 && isset($res['data'])) { |
|
|
|
|
return $res['data']; |
|
|
|
@ -81,9 +85,10 @@ class Jd extends BaseService { |
|
|
|
|
* @param [type] $skuId [description] |
|
|
|
|
* @return [type] [description] |
|
|
|
|
*/ |
|
|
|
|
public function getJdShortLink($skuId){ |
|
|
|
|
public function getJdShortLink($skuId) |
|
|
|
|
{ |
|
|
|
|
//$url = "http://47.98.251.206:8811/api/goods/info/v2?sku=".$skuId."&areaId="; |
|
|
|
|
$url = "http://8.130.98.31:8811/api/link?sku=".$skuId; |
|
|
|
|
$url = "http://8.130.98.31:8811/api/link?sku=" . $skuId; |
|
|
|
|
$res = httpRequest($url); |
|
|
|
|
if ($res && $res['code'] == 0 && isset($res['data'])) { |
|
|
|
|
return $res['data']; |
|
|
|
@ -91,13 +96,25 @@ class Jd extends BaseService { |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取京东短链接 |
|
|
|
|
* [getJdShortLink description] |
|
|
|
|
* @param [type] $skuId [description] |
|
|
|
|
* @return [type] [description] |
|
|
|
|
*/ |
|
|
|
|
public function getJdShortLinks($skuIds) |
|
|
|
|
{ |
|
|
|
|
//$url = "http://47.98.251.206:8811/api/goods/info/v2?sku=".$skuId."&areaId="; |
|
|
|
|
// 确保 $skuData 是一个数组,并且包含 'ids' 键 |
|
|
|
|
// 将数组转换为逗号分隔的字符串 |
|
|
|
|
$skuIdStr = implode(',', $skuIds); |
|
|
|
|
// 构建 URL |
|
|
|
|
$url = "http://8.130.98.31:8811/api/link?sku=" . $skuIdStr; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$res = httpRequest($url, 'GET', null, [], false, 100); |
|
|
|
|
if ($res && $res['code'] == 0 && isset($res['data'])) { |
|
|
|
|
return $res['data']; |
|
|
|
|
} |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|