|
@@ -0,0 +1,652 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+ * Created by PhpStorm.
|
|
|
+ * User: LZP
|
|
|
+ * Date: 2022/4/14
|
|
|
+ * Time: 15:21
|
|
|
+ */
|
|
|
+namespace App\Com;
|
|
|
+
|
|
|
+use App\Com\Redis;
|
|
|
+use App\Models\JdConfig;
|
|
|
+use EasySwoole\EasySwoole\Logger;
|
|
|
+
|
|
|
+class JdSdk
|
|
|
+{
|
|
|
+ protected $host = "https://bizapi.jd.com";
|
|
|
+ protected $edition = "";
|
|
|
+
|
|
|
+ protected $grant_type = "access_token";
|
|
|
+ protected $scope = "";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ protected $time_stamp = "";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ protected $client_id = '';
|
|
|
+ protected $client_secret = '';
|
|
|
+
|
|
|
+ protected $username = '';
|
|
|
+ protected $password = '';
|
|
|
+
|
|
|
+
|
|
|
+ protected $access_token = "NIwoLn95BLs0ZdKLyawIiuFPM";
|
|
|
+
|
|
|
+ protected $timeout = 30;
|
|
|
+ protected $connecttimeout = 30;
|
|
|
+ protected $ssl_verifypeer = FALSE;
|
|
|
+ protected $useragent = 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36';
|
|
|
+ protected $format = 'form';
|
|
|
+ protected $decode_json = true;
|
|
|
+ protected $debug = false;
|
|
|
+ protected $params_base = array();
|
|
|
+
|
|
|
+ protected $redis = null;
|
|
|
+
|
|
|
+ protected static $boundary = '';
|
|
|
+
|
|
|
+ function __construct()
|
|
|
+ {
|
|
|
+
|
|
|
+ $this->time_stamp = date('Y-m-d H:i:s', time());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $this->redis = Redis::getInstance()->getConnect();
|
|
|
+
|
|
|
+
|
|
|
+ $key = 'superdesk_jd_vop_' . 'web_jd_vop_configs_manage' . ':' . 17;
|
|
|
+ $api_conf = $this->redis->get($key);
|
|
|
+
|
|
|
+ if (!empty($api_conf)) {
|
|
|
+ $api_conf = json_decode($api_conf, true);
|
|
|
+
|
|
|
+ $this->client_id = $api_conf['client_id'];
|
|
|
+ $this->client_secret = $api_conf['client_secret'];
|
|
|
+ $this->username = $api_conf['username'];
|
|
|
+ $this->password = $api_conf['password'];
|
|
|
+ } else {
|
|
|
+
|
|
|
+ $api_conf = JdConfig::create()->where('is_default',1)->get()->toArray();
|
|
|
+
|
|
|
+ if(!empty($api_conf)){
|
|
|
+ $this->client_id = $api_conf['client_id'];
|
|
|
+ $this->client_secret = $api_conf['client_secret'];
|
|
|
+ $this->username = $api_conf['username'];
|
|
|
+ $this->password = $api_conf['password'];
|
|
|
+ } else {
|
|
|
+
|
|
|
+ $this->client_id = 'nuAeRH1KFlSeiIrfPYTZ';
|
|
|
+ $this->client_secret = 'ioyqcauADf0v3ayE73I5';
|
|
|
+ $this->username = '中航物业员工福利';
|
|
|
+ $this->password = 'avic-s';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ function init_access_token()
|
|
|
+ {
|
|
|
+
|
|
|
+ global $_W;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $table__key = 'superdesk_jd_vop_' . 'sdk_access_token' . ':' . 17;
|
|
|
+ $colunm_key = 'jd_vop_access_token';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $result = $this->redis->hget($table__key, $colunm_key);
|
|
|
+
|
|
|
+ $result = json_decode($result, true);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (empty($result) || empty($result['result'])) {
|
|
|
+ $result = $this->access_token();
|
|
|
+ $this->redis->hset($table__key, $colunm_key, $result);
|
|
|
+ $result = json_decode($result, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (intval(floatval($result['result']['time']) / 1000) + intval($result['result']['expires_in']) <= time()) {
|
|
|
+
|
|
|
+ $result = $this->refresh_token($result['result']['refresh_token']);
|
|
|
+ $this->redis->hset($table__key, $colunm_key, $result);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $result = json_decode($result, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->access_token = $result['result']['access_token'];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 签名,生成规则如下:
|
|
|
+ * 1. 按照以下顺序将字符串拼接起来
|
|
|
+ * client_secret+timestamp+client_id+username+password+grant_type+scope+client_secret
|
|
|
+ * 其中
|
|
|
+ * client_secret的值是京东分配的
|
|
|
+ * username使用原文
|
|
|
+ * password需要md5加密后的
|
|
|
+ * 2. 将上述拼接的字符串使用MD5加密,加密后的值再转为大写
|
|
|
+ */
|
|
|
+ function create_sign()
|
|
|
+ {
|
|
|
+
|
|
|
+ $sign_str =
|
|
|
+ $this->client_secret .
|
|
|
+ $this->time_stamp . $this->client_id . $this->username . md5($this->password) . $this->grant_type . $this->scope .
|
|
|
+ $this->client_secret;
|
|
|
+
|
|
|
+ $sign_md5 = md5($sign_str);
|
|
|
+ $sign_result = strtoupper($sign_md5);
|
|
|
+
|
|
|
+ return $sign_result;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * TODO 已测 1.3 获取Access Token
|
|
|
+ * HTTPS请求方式:POST
|
|
|
+ *
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ function access_token_url()
|
|
|
+ {
|
|
|
+ return $this->host . $this->edition . "/oauth2/accessToken";
|
|
|
+ }
|
|
|
+
|
|
|
+ function access_token()
|
|
|
+ {
|
|
|
+
|
|
|
+ $params = array();
|
|
|
+ $params['grant_type'] = $this->grant_type;
|
|
|
+ $params['client_id'] = $this->client_id;
|
|
|
+ $params['client_secret'] = $this->client_secret;
|
|
|
+ $params['timestamp'] = $this->time_stamp;
|
|
|
+ $params['username'] = $this->username;
|
|
|
+ $params['password'] = md5($this->password);
|
|
|
+ $params['scope'] = $this->scope;
|
|
|
+ $params['sign'] = $this->create_sign();
|
|
|
+
|
|
|
+ $response = $this->post($this->access_token_url(), $params, true);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return $response;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * TODO 已测 1.4 使用Refresh Token 刷新 Access Token
|
|
|
+ * HTTPS请求方式:POST
|
|
|
+ *
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ function refresh_token_url()
|
|
|
+ {
|
|
|
+ return $this->host . $this->edition . "/oauth2/refreshToken";
|
|
|
+ }
|
|
|
+
|
|
|
+ function refresh_token($refresh_token)
|
|
|
+ {
|
|
|
+
|
|
|
+ $params = array();
|
|
|
+ $params['refresh_token'] = $refresh_token;
|
|
|
+ $params['client_id'] = $this->client_id;
|
|
|
+ $params['client_secret'] = $this->client_secret;
|
|
|
+
|
|
|
+
|
|
|
+ $response = $this->post($this->refresh_token_url(), $params, true);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * GET wrappwer for oAuthRequest.
|
|
|
+ *
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ function get($url, $parameters = array())
|
|
|
+ {
|
|
|
+ $response = $this->oAuthRequest($url, 'GET', $parameters);
|
|
|
+ if ($this->format === 'json' && $this->decode_json) {
|
|
|
+ return json_decode($response, true);
|
|
|
+ }
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * POST wreapper for oAuthRequest.
|
|
|
+ *
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ function post($url, $parameters = array(), $multi = false)
|
|
|
+ {
|
|
|
+
|
|
|
+ $response = $this->oAuthRequest($url, 'POST', $parameters, $multi);
|
|
|
+ if ($this->format === 'json' && $this->decode_json) {
|
|
|
+ return json_decode($response, true);
|
|
|
+ }
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * Format and sign an OAuth / API request
|
|
|
+ *
|
|
|
+ * @return string
|
|
|
+ * @ignore
|
|
|
+ */
|
|
|
+ function oAuthRequest($url, $method, $params, $multi = false)
|
|
|
+ {
|
|
|
+ if (strrpos($url, 'http://') !== 0 && strrpos($url, 'https://') !== 0) {
|
|
|
+ $url = "{$this->host}/{$this->edition}/{$url}";
|
|
|
+ } else {
|
|
|
+ $url = $url . '?client_id=' . $this->client_id . '&client_secret=' . $this->client_secret;
|
|
|
+ }
|
|
|
+
|
|
|
+ $parameters = array_merge_recursive($this->params_base, $params);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ switch ($method) {
|
|
|
+ case 'GET' :
|
|
|
+ $url = $url . http_build_query($parameters);
|
|
|
+ return $this->http($url, 'GET');
|
|
|
+ case 'PUT' :
|
|
|
+ $headers = array();
|
|
|
+ if (!$multi && (is_array($parameters) || is_object($parameters))) {
|
|
|
+
|
|
|
+ if ($this->format === 'json' && $this->decode_json) {
|
|
|
+ $body = json_encode($parameters);
|
|
|
+ if ($this->debug) {
|
|
|
+ echo '============= BODY =============';
|
|
|
+ echo '<br/>';
|
|
|
+ echo $body;
|
|
|
+ echo '<br/>';
|
|
|
+ echo '============= BODY =============';
|
|
|
+ echo '<br/>';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $body = http_build_query($parameters);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $body = self::build_http_query_multi($parameters);
|
|
|
+ $headers [] = "Content-Type: multipart/form-data; boundary=" . self::$boundary;
|
|
|
+ }
|
|
|
+ return $this->http($url, 'PUT', $body, $headers);
|
|
|
+ case 'DELETE' :
|
|
|
+ if (!empty($parameters)) {
|
|
|
+ $url = $url . '&' . http_build_query($parameters);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->http($url, 'DELETE');
|
|
|
+ default :
|
|
|
+ $headers = array();
|
|
|
+ if (!$multi && (is_array($parameters) || is_object($parameters))) {
|
|
|
+
|
|
|
+ if ($this->format === 'json' && $this->decode_json) {
|
|
|
+ $body = json_encode($parameters);
|
|
|
+ if ($this->debug) {
|
|
|
+ echo '============= BODY =============';
|
|
|
+ echo '<br/>';
|
|
|
+ echo $body;
|
|
|
+ echo '<br/>';
|
|
|
+ echo '============= BODY =============';
|
|
|
+ echo '<br/>';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $body = http_build_query($parameters);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $body = self::build_http_query_multi($parameters);
|
|
|
+ $headers [] = "Content-Type: multipart/form-data; boundary=" . self::$boundary;
|
|
|
+ }
|
|
|
+ return $this->http($url, $method, $body, $headers);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * Make an HTTP request
|
|
|
+ *
|
|
|
+ * @return string API results
|
|
|
+ * @ignore
|
|
|
+ */
|
|
|
+ function http($url, $method, $postfields = NULL, $headers = array())
|
|
|
+ {
|
|
|
+ $this->http_info = array();
|
|
|
+ $ci = curl_init();
|
|
|
+
|
|
|
+ curl_setopt($ci, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
|
|
|
+ curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
|
|
|
+ curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
|
|
|
+ curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
|
|
|
+ curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
|
|
|
+ curl_setopt($ci, CURLOPT_ENCODING, "");
|
|
|
+ curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
|
|
|
+
|
|
|
+ curl_setopt($ci, CURLOPT_HEADER, FALSE);
|
|
|
+
|
|
|
+ switch ($method) {
|
|
|
+
|
|
|
+ case 'GET':
|
|
|
+
|
|
|
+ curl_setopt($ci, CURLOPT_HTTPGET, TRUE);
|
|
|
+ if (!empty($postfields)) {
|
|
|
+ curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
|
|
|
+ $this->postdata = $postfields;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'POST':
|
|
|
+
|
|
|
+ curl_setopt($ci, CURLOPT_POST, TRUE);
|
|
|
+
|
|
|
+ if ($this->format === 'json') {
|
|
|
+ $headers [] = "Content-Type: application/json;";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($postfields)) {
|
|
|
+ curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
|
|
|
+ $this->postdata = $postfields;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'PUT':
|
|
|
+ curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'PUT');
|
|
|
+ $headers [] = "Content-Type: application/json;";
|
|
|
+ if (!empty($postfields)) {
|
|
|
+ curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
|
|
|
+ $this->postdata = $postfields;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 'DELETE':
|
|
|
+ curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
|
|
|
+ if (!empty($postfields)) {
|
|
|
+ $url = "{$url}?{$postfields}";
|
|
|
+ echo $url;
|
|
|
+ echo '<br/>';
|
|
|
+ } else {
|
|
|
+ $url = $url;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ curl_setopt($ci, CURLOPT_URL, $url);
|
|
|
+ curl_setopt($ci, CURLOPT_HTTPHEADER, $headers);
|
|
|
+ curl_setopt($ci, CURLINFO_HEADER_OUT, TRUE);
|
|
|
+ $response = curl_exec($ci);
|
|
|
+ $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
|
|
|
+ $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
|
|
|
+ $this->url = $url;
|
|
|
+
|
|
|
+ if ($this->debug) {
|
|
|
+ echo "=====post data======\r\n";
|
|
|
+ echo '<br/>';
|
|
|
+ var_dump($postfields);
|
|
|
+ echo '<br/>';
|
|
|
+
|
|
|
+ echo '=====info=====' . "\r\n";
|
|
|
+ echo '<br/>';
|
|
|
+ print_r(curl_getinfo($ci));
|
|
|
+ echo '<br/>';
|
|
|
+
|
|
|
+ echo '=====$response=====' . "\r\n";
|
|
|
+ echo '<br/>';
|
|
|
+ print_r($response);
|
|
|
+ echo '<br/>';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $code = curl_getinfo($ci);
|
|
|
+ $response = json_decode($response, true);
|
|
|
+
|
|
|
+ if (!$response) {
|
|
|
+ $response = array();
|
|
|
+ }
|
|
|
+
|
|
|
+ $response['code'] = $code['http_code'];
|
|
|
+
|
|
|
+ $___url___ = str_replace($this->host . $this->edition, '', $url);
|
|
|
+ $log_data = array();
|
|
|
+ $log_data['url'] = $url;
|
|
|
+ $log_data['api'] = substr($___url___, 0, strpos($___url___, '?'));
|
|
|
+ $log_data['method'] = $method;
|
|
|
+ $log_data['post_fields'] = $postfields;
|
|
|
+ $log_data['curl_info'] = json_encode(curl_getinfo($ci), JSON_UNESCAPED_UNICODE);
|
|
|
+ $log_data['success'] = isset($response['success']) ? $response['success'] : "exit0";
|
|
|
+ $log_data['resultMessage'] = isset($response['resultMessage']) ? $response['resultMessage'] : "exit0";
|
|
|
+ $log_data['resultCode'] = isset($response['resultCode']) ? $response['resultCode'] : "exit0";
|
|
|
+ $log_data['result'] = isset($response['result']) ? json_encode($response['result'], JSON_UNESCAPED_UNICODE) : "";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Logger::getInstance()->info('京东请求日志:' . json_encode($log_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (!empty($response['status']) && $response['status'] == 'Unauthorized.') {
|
|
|
+
|
|
|
+ exit();*/
|
|
|
+ $response['status'] = 'Unauthorized.';
|
|
|
+ }
|
|
|
+
|
|
|
+ $response = json_encode($response);
|
|
|
+
|
|
|
+ curl_close($ci);
|
|
|
+
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 处理多媒体数据内容
|
|
|
+ *
|
|
|
+ * @ignore
|
|
|
+ */
|
|
|
+ public static function build_http_query_multi($params)
|
|
|
+ {
|
|
|
+ if (!$params) return '';
|
|
|
+
|
|
|
+ uksort($params, 'strcmp');
|
|
|
+
|
|
|
+ $pairs = array();
|
|
|
+
|
|
|
+ self::$boundary = $boundary = uniqid('------------------');
|
|
|
+ $MPboundary = '--' . $boundary;
|
|
|
+ $endMPboundary = $MPboundary . '--';
|
|
|
+ $multipartbody = '';
|
|
|
+
|
|
|
+ foreach ($params as $parameter => $value) {
|
|
|
+
|
|
|
+ if (in_array($parameter, array('pic', 'image', 'Filedata')) && $value{0} == '@') {
|
|
|
+ $url = ltrim($value, '@');
|
|
|
+ $content = file_get_contents($url);
|
|
|
+ $array = explode('?', basename($url));
|
|
|
+ $filename = $array[0];
|
|
|
+
|
|
|
+ $multipartbody .= $MPboundary . "\r\n";
|
|
|
+ $multipartbody .= 'Content-Disposition: form-data; name="' . $parameter . '"; filename="' . $filename . '"' . "\r\n";
|
|
|
+ $multipartbody .= "Content-Type: image/unknown\r\n\r\n";
|
|
|
+ $multipartbody .= $content . "\r\n";
|
|
|
+ } else {
|
|
|
+ $multipartbody .= $MPboundary . "\r\n";
|
|
|
+ $multipartbody .= 'content-disposition: form-data; name="' . $parameter . "\"\r\n\r\n";
|
|
|
+ $multipartbody .= $value . "\r\n";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ $multipartbody .= $endMPboundary;
|
|
|
+ return $multipartbody;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * TODO 已测 3.5 商品上下架状态接口
|
|
|
+ * HTTPS请求方式:POST
|
|
|
+ *
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ function api_product_sku_state_url()
|
|
|
+ {
|
|
|
+ return $this->host . $this->edition . "/api/product/skuState";
|
|
|
+ }
|
|
|
+
|
|
|
+ function api_product_sku_state($sku)
|
|
|
+ {
|
|
|
+
|
|
|
+ $params = array();
|
|
|
+ $params['token'] = $this->access_token;
|
|
|
+ $params['sku'] = $sku;
|
|
|
+
|
|
|
+ $response = $this->post($this->api_product_sku_state_url(), $params, true);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * TODO 待测 6.2 批量获取库存接口(建议订单详情页、下单使用)
|
|
|
+ * HTTPS请求方式:POST
|
|
|
+ *
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ function api_stock_get_new_stock_by_id_url()
|
|
|
+ {
|
|
|
+ return $this->host . $this->edition . "/api/stock/getNewStockById";
|
|
|
+ }
|
|
|
+
|
|
|
+ function api_stock_get_new_stock_by_id($skuNums, $area)
|
|
|
+ {
|
|
|
+
|
|
|
+ $params = array();
|
|
|
+ $params['token'] = $this->access_token;
|
|
|
+ $params['skuNums'] = $skuNums;
|
|
|
+ $params['area'] = $area;
|
|
|
+
|
|
|
+
|
|
|
+ $response = $this->post($this->api_stock_get_new_stock_by_id_url(), $params, true);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * TODO 待测 5.2 批量查询协议价价格
|
|
|
+ * HTTPS请求方式:POST
|
|
|
+ *
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ function api_price_get_price_url()
|
|
|
+ {
|
|
|
+ return $this->host . $this->edition . "/api/price/getPrice";
|
|
|
+ }
|
|
|
+
|
|
|
+ function api_price_get_price($sku)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $params = array();
|
|
|
+ $params['token'] = $this->access_token;
|
|
|
+ $params['sku'] = $sku;
|
|
|
+
|
|
|
+ $response = $this->post($this->api_price_get_price_url(), $params, true);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return $response;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|