_domain = $config['domain'] ?? $this->_domain; $this->_app_key = $config['app_key'] ?? $this->_app_key; $this->_app_secrect = $config['app_secrect'] ?? $this->_app_secrect; $this->_channel_code = $config['channel_code'] ?? $this->_channel_code; $this->_client = new \DefaultSuningClient($this->_domain, $this->_app_key,$this->_app_secrect,'json'); } /** * 商品池 * [goodsPoolQuery description] * @param [type] $page [description] * @param [type] $limit [description] * @return [type] [description] */ public function goodsPoolQuery($page, $limit){ $req = new \ProdpoolQueryRequest(); $req -> setChannelCode($this->_channel_code); $req -> setPageNo($page); $req -> setPageSize($limit); //$req -> setStartTime("2024-01-11 01:01:01"); //$req -> setEndTime("2022-01-11 23:59:59"); //$req -> setCheckParam('true');//api入参校验逻辑开关,当测试稳定之后建议设置为 false 或者删除该行 $resp = $this->_client->execute($req); $data = json_decode($resp, true); // echo "
"; // print_r($data); if (isset($data['sn_responseContent']['sn_body']['queryProdpool']) && $data['sn_responseContent']['sn_body']['queryProdpool']) { return $data['sn_responseContent']['sn_body']['queryProdpool']; } return []; } /** * 商品基本信息 * [goodsPoolQuery description] * @param [type] $supplier_code [description] * @param [type] $sku_id [description] * @return [type] [description] */ public function goodsBasicInfo($supplier_code, $sku_id){ $req = new \ProdbasicdetailGetRequest(); $req -> setSkuId($sku_id); $req -> setSupplierCode($supplier_code); //$req -> setCheckParam('true');//api入参校验逻辑开关,当测试稳定之后建议设置为 false 或者删除该行 $resp = $this->_client->execute($req); $data = json_decode($resp, true); // echo ""; // print_r($data); // exit(); if (isset($data['sn_responseContent']['sn_body']['getProdbasicdetail']) && $data['sn_responseContent']['sn_body']['getProdbasicdetail']) { return $data['sn_responseContent']['sn_body']['getProdbasicdetail']; } return []; } /** * 商品详细信息 * [goodsPoolQuery description] * @param [type] $supplier_code [description] * @param [type] $sku_id [description] * @return [type] [description] */ public function goodsDetail($supplier_code, $sku_id){ $req = new \ProddetailGetRequest(); $req -> setSkuId($sku_id); $req -> setSupplierCode($supplier_code); //$req -> setCheckParam('true');//api入参校验逻辑开关,当测试稳定之后建议设置为 false 或者删除该行 $client = new \DefaultSuningClient($this->_domain, $this->_app_key,$this->_app_secrect,'json'); $resp = $this->_client->execute($req); $data = json_decode($resp, true); // echo ""; // print_r($data); // exit(); if (isset($data['sn_responseContent']['sn_body']['getProddetail']) && $data['sn_responseContent']['sn_body']['getProddetail']) { return $data['sn_responseContent']['sn_body']['getProddetail']; } return []; } /** * 商品详细信息 * [goodsPoolQuery description] * @param [type] $supplier_code [description] * @param [type] $sku_id [description] * @return [type] [description] */ public function goodsImage($supplier_code, $sku_id){ $req = new \ProdimageQueryRequest(); $req -> setSkuId($sku_id); $req -> setSupplierCode($supplier_code); //$req -> setCheckParam('true');//api入参校验逻辑开关,当测试稳定之后建议设置为 false 或者删除该行 $client = new \DefaultSuningClient($this->_domain, $this->_app_key,$this->_app_secrect,'json'); $resp = $this->_client->execute($req); $data = json_decode($resp, true); // echo ""; // print_r($data); // exit(); if (isset($data['sn_responseContent']['sn_body']['queryProdimage']) && $data['sn_responseContent']['sn_body']['queryProdimage']) { return $data['sn_responseContent']['sn_body']['queryProdimage']; } return []; } /** * 获取通子码商品信息接口 * [passpartproductinfo description] * @param [type] $supplier_code [description] * @param string $spu_id [description] * @return [type] [description] */ public function passpartproductinfo($supplier_code, $spu_id = ""){ $req = new \PasspartproductinfoQueryRequest(); $req -> setSpuId($spu_id); $req -> setSupplierCode($supplier_code); //$req -> setCheckParam('true');//api入参校验逻辑开关,当测试稳定之后建议设置为 false 或者删除该行 $client = new \DefaultSuningClient($this->_domain, $this->_app_key,$this->_app_secrect,'json'); $resp = $this->_client->execute($req); $data = json_decode($resp, true); echo ""; print_r($data); //exit(); if (isset($data['sn_responseContent']['sn_body']['queryProdimage']) && $data['sn_responseContent']['sn_body']['queryProdimage']) { return $data['sn_responseContent']['sn_body']['queryProdimage']; } return []; } /** * 列表页城市维度查询价格及库存状态 * [passpartproductinfo description] * @param [type] $supplier_code [description] * @param string $spu_id [description] * @return [type] [description] */ public function listPagePrice($skus, $city_code = "025"){ $req = new \ListpagepriceQueryRequest(); $req -> setChannelCode($this->_channel_code); $req -> setCityCode("025"); $arr = []; foreach ($skus as &$sku) { list($channel, $supplier_code, $sku_id) = explode("-", $sku['unicode']); $cmmdtyInfoList= new \CmmdtyInfoList(); $cmmdtyInfoList->setSkuId($sku_id); $cmmdtyInfoList->setSupplierCode($supplier_code); $arr[] = $cmmdtyInfoList; } $req -> setCmmdtyInfoList($arr); //$req -> setCheckParam('true');//api入参校验逻辑开关,当测试稳定之后建议设置为 false 或者删除该行 $client = new \DefaultSuningClient($this->_domain, $this->_app_key,$this->_app_secrect,'json'); $resp = $this->_client->execute($req); $data = json_decode($resp, true); // echo ""; // print_r($data); // exit(); if (isset($data['sn_responseContent']['sn_body']['queryListpageprice']['data']) && $data['sn_responseContent']['sn_body']['queryListpageprice']['data']) { return $data['sn_responseContent']['sn_body']['queryListpageprice']['data']; } return []; } /** * 确定到省市区纬度且有明确购买数量的场景查询价格及库存状态 * [passpartproductinfo description] * @param [type] $supplier_code [description] * @param string $spu_id [description] * @return [type] [description] */ public function shoppingCartPrice($skus, $city_code = "025", $region_code = "01"){ $req = new \ShoppingcartpriceQueryRequest(); $req -> setChannelCode($this->_channel_code); $req -> setCityCode($city_code); $req -> setRegionCode($region_code); $arr = []; foreach ($skus as &$sku) { list($channel, $supplier_code, $sku_id) = explode("-", $sku['unicode']); $cmmdtyInfoList= new \CmmdtyInfoList1(); $cmmdtyInfoList->setSkuId($sku_id); $cmmdtyInfoList->setSupplierCode($supplier_code); $cmmdtyInfoList->setNum($sku['num'] ?? 1); $arr[] = $cmmdtyInfoList; } $req ->setCmmdtyInfoList1($arr); //$req -> setCheckParam('true');//api入参校验逻辑开关,当测试稳定之后建议设置为 false 或者删除该行 $client = new \DefaultSuningClient($this->_domain, $this->_app_key,$this->_app_secrect,'json'); $resp = $this->_client->execute($req); $data = json_decode($resp, true); if (isset($data['sn_responseContent']['sn_body']['queryShoppingcartprice']['data']) && $data['sn_responseContent']['sn_body']['queryShoppingcartprice']['data']) { $arr = []; $data = $data['sn_responseContent']['sn_body']['queryShoppingcartprice']['data']; foreach ($data as $key => &$value) { //$goods = GoodsModel::where('goods_id', $sku['goods_id'])->find(); $arr = [ 'state'=> $value['state'] == 1 ? "有货" : "无货", //'goods_name'=> $goods['goods_name'], //'goods_id'=> $goods['goods_id'], ]; } return $arr; } return []; } /** * 全量地址接口 * [passpartproductinfo description] * @param [type] $supplier_code [description] * @param string $spu_id [description] * @return [type] [description] */ public function fulladdress(){ $req = new \FulladdressGetRequest(); //$req -> setCheckParam('true');//api入参校验逻辑开关,当测试稳定之后建议设置为 false 或者删除该行 $client = new \DefaultSuningClient($this->_domain, $this->_app_key,$this->_app_secrect,'json'); $resp = $this->_client->execute($req); $data = json_decode($resp, true); // echo ""; // print_r($data); //exit(); if (isset($data['sn_responseContent']['sn_body']['getFulladdress']['addressList']) && $data['sn_responseContent']['sn_body']['getFulladdress']['addressList']) { return $data['sn_responseContent']['sn_body']['getFulladdress']['addressList']; } return []; } }