public function collectCates() { setTimeLimit(3600); $ccate = FDB::fetchFirst('SELECT * FROM ' . FDB::table('goods_cate_collect') . ' LIMIT 0,1'); if (!$ccate) { return false; } FDB::query('DELETE FROM ' . FDB::table('goods_cate_collect') . " WHERE id = '{$ccate['id']}'"); global $_FANWE; Cache::getInstance()->loadCache('business'); //QQ号 define('PAIPAI_API_UIN', trim($_FANWE['cache']['business']['paipai']['uin'])); //令牌 define('PAIPAI_API_APPOAUTHID', trim($_FANWE['cache']['business']['paipai']['appoauthid'])); //APP_KEY define('PAIPAI_API_APPOAUTHKEY', trim($_FANWE['cache']['business']['paipai']['appoauthkey'])); define('PAIPAI_API_ACCESSTOKEN', trim($_FANWE['cache']['business']['paipai']['accesstoken'])); define('PAIPAI_API_USERID', trim($_FANWE['cache']['business']['paipai']['userid'])); $sdk = new PaiPaiOpenApiOauth(PAIPAI_API_APPOAUTHID, PAIPAI_API_APPOAUTHKEY, PAIPAI_API_ACCESSTOKEN, PAIPAI_API_UIN); $sdk->setApiPath("/attr/getNavigationChildList.xhtml"); $sdk->setMethod("get"); $sdk->setCharset("utf-8"); $sdk->setFormat("json"); $params =& $sdk->getParams(); $params["navigationId"] = $ccate['cid']; //请求数据 $json = $sdk->invoke(); $json = preg_replace("/[\r\n]/", '', $json); preg_match("/getNavigationChildListSuccess\\((.+?)\\);\\}catch\\(/", $json, $list); $list = json_decode($list[1], true); $sort_file = FANWE_ROOT . '/public/records/cate.sort.php'; $sort = (int) @file_get_contents($sort_file); if (isset($list['childList'])) { foreach ($list['childList'] as $item) { $cate = array(); $cate['type'] = 'paipai'; $cate['id'] = (int) $item['navigationId']; if ($cate['id'] > 0) { $cate['pid'] = $ccate['cid'] == 0 ? '' : $ccate['cid']; $cate['name'] = (string) $item['navigationName']; $cate['pids'] = empty($ccate['pids']) ? $cate['pid'] : $ccate['pids'] . ',' . $cate['pid']; $cate['sort'] = ++$sort; FDB::insert('goods_cates', $cate, false, true); if ((int) $item['isClass'] == 0) { FDB::insert('goods_cate_collect', array('id' => 'NULL', 'cid' => $cate['id'], 'pids' => $cate['pids'])); } } } @file_put_contents($sort_file, $sort); } return true; }
$sdk = new PaiPaiOpenApiOauth($appOAuthID, $appOAuthkey, $accessToken, $uin); // 设置开启调试模式。 // true为开启,开启后,在显示页面会打印相关信息;false为关闭,使用者可以将其关闭,关闭不影响结果 $sdk->setDebugOn(true); // Begin参数设置: // 注意 示例中可能的url为 http://api.paipai.com/deal/sellerSearchDealList.xhtml?a=1&b=2&c=3 // 设置 用户需要调用的腾讯开放平台提供的接口。此处,按照上一行中的url,则用户要输入/deal/sellerSearchDealList.xhtml,前面不加hostname。 $sdk->setApiPath("/deal/sellerSearchDealList.xhtml"); //这个是用户需要调用的 接口函数 // 用户使用的提交数据的方法。post 和 get均可;以及字符集 $sdk->setMethod("get"); //post $sdk->setCharset("utf-8"); //gbk // 以下部分用于设置用户在调用相关接口时url中"?"之后的各个参数,如上述描述中的a=1&b=2&c=3 $params =& $sdk->getParams(); //注意,这里使用的是引用,故可以直接使用 $params["sellerUin"] = $uin; $params["zhongwen"] = "cn"; $params["pageSize"] = "30"; $params["tms_op"] = "admin@855006089"; $params["tms_opuin"] = $uin; $params["tms_skey"] = "@WXOgdqq16"; //设置http请求接受的主机名,默认是 api.buy.qq.com。此处用户可不用修改 //$sdk->setHostName("apitest.buy.qq.com"); // End参数设置 //run try { $response = $sdk->invoke(); print_r("<br/>-----------response---------<br/>"); print_r($response);
/** * 同步标记发货 */ function shipping_synchro($order_id) { global $json; // 获取标记发货所需的相关订单参数 if ($_SESSION['role_id'] == 10) { $sql = 'SELECT order_sn,team,' . 'tracking_sn,shipping_id,shipping_name,shipping_code,province,shipping_time FROM ' . $GLOBALS['ecs']->table('ordersyn_info') . " WHERE order_id={$order_id}"; } else { $sql = 'SELECT IF(platform_order_sn,platform_order_sn,order_sn) order_sn,team,' . 'tracking_sn,shipping_id,shipping_name,shipping_code,province,shipping_time FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE order_id={$order_id}"; } $order_info = $GLOBALS['db']->getRow($sql); $tracking_sn = $order_info['tracking_sn']; // 获取快递公司编码 $sql = 'SELECT company_code, company_name FROM ' . $GLOBALS['ecs']->table('shipping') . " WHERE shipping_id='{$order_info['shipping_id']}'"; $logistics = $GLOBALS['db']->getRow($sql); // 同步发货(淘宝) if ($order_info['shipping_time'] && in_array($order_info['team'], array(6, 21, 22, 26, 53))) { $platform_path = array(6 => 'taobao', 21 => 'taobao01', 22 => 'taobao02', 26 => 'taobao03', 53 => 'taobao04'); require_once dirname(__FILE__) . "/taobao/order_synchro.php"; require_once dirname(__FILE__) . "/{$platform_path[$order_info['team']]}/sk.php"; $auth = (require_once dirname(__FILE__) . "/{$platform_path[$order_info['team']]}/config.php"); // 配置淘宝签权参数 $c = new TopClient(); $c->appkey = $auth['appkey']; $c->secretKey = $auth['secretKey']; // 查询订单当前状态是否符合发货条件 $req = new TradeFullinfoGetRequest(); $req->setFields("status"); $req->setTid($order_info['order_sn']); $shipping_able = $c->execute($req, $sk['access_token']); $shipping_able = $json->decode($json->encode($shipping_able), true); // 订单状态符合发货条件 if ($shipping_able['trade']['status'] == 'WAIT_SELLER_SEND_GOODS') { // 构建标记发货的数据格式 $req = new LogisticsOfflineSendRequest(); if ($logistics['company_code'] == 'zjs') { $req->setOutSid($tracking_sn); $req->setTid($order_info['order_sn']); $req->setCompanyCode(strtoupper($logistics['company_code'])); } elseif ('lbex' == $logistics['company_code']) { return true; $req->setOutSid($tracking_sn); $req->setTid($order_info['order_sn']); $req->setCompanyCode('龙邦速递'); } else { $req->setOutSid($tracking_sn); $req->setTid($order_info['order_sn']); $req->setCompanyCode(strtoupper($logistics['company_code'])); } // 发送发货请求 $shipping_resp = $c->execute($req, $sk['access_token']); } elseif ($shipping_able['trade']['status'] == 'WAIT_BUYER_CONFIRM_GOODS') { $req = new LogisticsConsignResendRequest(); $req->setOutSid($tracking_sn); $req->setTid(number_format($order_info['order_sn'], 0, '', '')); $req->setCompanyCode(strtoupper($logistics['company_code'])); $shipping_resp = $c->execute($req, $sk['access_token']); } elseif ($shipping_able['code'] == 27) { $res['message'] = '淘宝授权到期,请联系天猫推广,进行授权后再发货!'; file_put_contents('taobao.txt', 27); } else { $res['message'] = '订单状态已改变,不符合发货条件!【天猫商城提示您】'; $res['shipping_name'] = $order_info['shipping_name']; $res['errMsg'] = 1; } if (!isset($shipping_resp['shipping']['is_success']) || !$shipping_resp['shipping']['is_success']) { $res['message'] = $shipping_resp['sub_msg']; } } // 同步发货(拍拍) if ($order_info['shipping_time'] && $order_info['team'] == 7) { if (in_array($order_info['shipping_id'], array(29, 12))) { return false; } require_once dirname(__FILE__) . '/paipai/PaiPaiOpenApiOauth.php'; // 加载参数 $cfg_paipai = (require_once dirname(__FILE__) . '/paipai/config.php'); // 配置四项签权参数 $uin = $cfg_paipai['account']; $appOAuthID = $cfg_paipai['appkey']; $appOAuthkey = $cfg_paipai['secretKey']; $accessToken = $cfg_paipai['sessionKey']; // 2013-09-17更新,下次更新2014-09-17 // 实例化拍拍接口 $sdk = new PaiPaiOpenApiOauth($appOAuthID, $appOAuthkey, $accessToken, $uin); // 关闭调试模式 $sdk->setDebugOn(false); // 查询订单当前状态是否符合发货条件 $sdk->setApiPath("/deal/getDealDetail.xhtml"); $sdk->setMethod("get"); //post $sdk->setCharset("utf-8"); //gbk $sdk->setFormat('json'); $params =& $sdk->getParams(); //注意,这里使用的是引用,故可以直接使用 $params['sellerUin'] = $uin; $params['dealCode'] = trim($order_info['order_sn']); $params['pureData'] = 1; $shipping_able = $json->decode($sdk->invoke(), true); // 货到付款不需要标记发货 if ($shipping_able['dealState'] == 'STATE_COD_WAIT_SHIP') { return true; } $propertymask = explode('_', $shipping_able['propertymask']); $allow_shipping = array('DS_WAIT_SELLER_DELIVERY'); $need_pay = array('ems', 'sto_express', 'sf', 'emssn'); if (!in_array($shipping_able['dealState'], $allow_shipping)) { $res['message'] = '【QQ商城提示您】订单状态已改变,不符合发货条件!'; $res['shipping_name'] = $order_info['shipping_name']; $res['errMsg'] = 1; } if (($shipping_able['dealState'] == 'STATE_COD_WAIT_SHIP' || end($propertymask) == 2048 && $shipping_able['dealState'] == 'DS_WAIT_BUYER_PAY') && !in_array($order_info['shipping_code'], $need_pay)) { $res['message'] = '该订单须使用货到付款的配送方式!!!'; $res['shipping_name'] = $order_info['shipping_name']; $res['errMsg'] = 1; } // 实例化拍拍接口 $sdk = new PaiPaiOpenApiOauth($appOAuthID, $appOAuthkey, $accessToken, $uin); // 关闭调试模式 $sdk->setDebugOn(false); //需要调用的 接口函数 $sdk->setApiPath("/deal/sellerConsignDealItem.xhtml"); $sdk->setMethod("get"); //post $sdk->setCharset("utf-8"); //gbk $sdk->setFormat('json'); // 处理发货相关数据 if (in_array($order_info['province'], array(6, 3465))) { $params['arriveDays'] = 3; } elseif (in_array($order_info['shipping_code'], array('sto_express', 'ems2', 'sf'))) { $params['arriveDays'] = 7; } else { $params['arriveDays'] = 5; } // 配置标记发货所需的参数 $params =& $sdk->getParams(); //注意,这里使用的是引用,故可以直接使用 $params['sellerUin'] = $uin; $params['dealCode'] = $order_info['order_sn']; $params['pureData'] = 1; $params['logisticsName'] = $logistics['company_name']; $params['logisticsCode'] = $tracking_sn; $response = json_decode($sdk->invoke(), true); if ($response['errorCode']) { $res['message'] = $response['errorMessage']; } } // 同步发货(京东) if ($order_info['shipping_time'] && in_array($order_info['team'], array(10, 54, 55))) { include_once dirname(__FILE__) . '/jingdong/JdClient.php'; include_once dirname(__FILE__) . '/jingdong/JdException.php'; include_once dirname(__FILE__) . '/jingdong/request/order/OrderSopOutstorageRequest.php'; $platform_path = array(10 => 'jingdong', 54 => 'aksojd', 55 => 'jlfjd'); require_once dirname(__FILE__) . "/{$platform_path[$order_info['team']]}/sk.php"; $auth = (require_once dirname(__FILE__) . "/{$platform_path[$order_info['team']]}/config.php"); //include dirname(__FILE__).'/jingdong/sk.php'; //$auth = include dirname(__FILE__).'/jingdong/config.php'; $req = new OrderSopOutstorageRequest(); $req->setOrderId($order_info['order_sn']); $req->setWaybill($tracking_sn); $sql_select = 'SELECT jd_code FROM ' . $GLOBALS['ecs']->table('shipping') . " WHERE shipping_id={$order_info['shipping_id']}"; $req->setLogisticsId($GLOBALS['db']->getOne($sql_select)); $jd = new JdClient(); $jd->appKey = $auth['appkey']; // 京东AppKey $jd->appSecret = $auth['secretKey']; // 京东AppSecret $jd->accessToken = $sk['access_token']; // 京东sessionkey(access_token) $jd->timestamp = date('Y-m-d H:i:s'); $jd->v = '2.0'; $resp = $jd->execute($req); $resp = json_decode(json_encode($resp), true); if ($resp['error_response']['code']) { $res['message'] = $resp['error_response']['zh_desc'] . '【京东商城提示您】'; $res['tracking_sn'] = $order_info['tracking_sn']; } } // 同步发货(1号店) if ($order_info['shipping_time'] && $order_info['team'] == 14) { include_once dirname(__FILE__) . '/yhd/YhdClient.php'; include_once dirname(__FILE__) . '/yhd/sk.php'; include_once dirname(__FILE__) . '/yhd/request/order/OrderLogisticsPushRequest.php'; include_once dirname(__FILE__) . '/yhd/request/logistics/LogisticsOrderShipmentsUpdateRequest.php'; $auth = (include_once dirname(__FILE__) . '/yhd/config.php'); $req = new LogisticsOrderShipmentsUpdateRequest(); // 应用级参数 $req->setOrderCode($order_info['order_sn']); $req->setExpressNbr($tracking_sn); $sql_select = 'SELECT 1mall_code FROM ' . $GLOBALS['ecs']->table('shipping') . " WHERE shipping_id={$order_info['shipping_id']}"; $req->setDeliverySupplierId($GLOBALS['db']->getOne($sql_select)); $yhdClient = new YhdClient(); // 系统级参数 $yhdClient->appkey = $auth['appkey']; $yhdClient->secretKey = $auth['secretKey']; $yhdClient->format = 'json'; $result = $yhdClient->execute($req, $sk['accessToken']); $result = objectsIntoArray($result); if ($result['response']['errInfoList']) { $req = new OrderDetailGetRequest(); $req->setOrderCode($order_info['order_sn']); $yhdClient = new YhdClient(); // 系统级参数 $yhdClient->appkey = $auth['appkey']; $yhdClient->secretKey = $auth['secretKey']; $yhdClient->format = 'json'; $express = $yhdClient->execute($req, $sk['accessToken']); $express = json_decode($express, true); if (isset($express['response']['orderInfo']['orderDetail']['merchantExpressNbr']) && $express['response']['orderInfo']['orderDetail']['merchantExpressNbr'] == $tracking_sn) { } elseif (isset($express['response']['orderInfo']['orderDetail']['merchantExpressNbr']) && $express['response']['orderInfo']['orderDetail']['merchantExpressNbr'] != $tracking_sn) { $res['message'] = '该订单已经在一号店标记发货,所使用的运单号为【' . $express['response']['orderInfo']['orderDetail']['merchantExpressNbr'] . '】'; } else { $res['message'] = $result['response']['errInfoList']['errDetailInfo'][0]['errorDes']; $res['tracking_sn'] = $order_info['tracking_sn']; } } } // 当当同步发货 if ($order_info['shipping_time'] && $order_info['team'] == 16) { require_once 'dangdang/ddClient.php'; $dd = new ddClient(2100001198); // 获取商品列表 $sql_select = 'SELECT IF(platform_order_sn,platform_order_sn,order_sn) order_sn FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE order_id={$order_id}"; $order_sn = $GLOBALS['db']->getOne($sql_select); $params['o'] = $order_sn; $goods_info = $dd->execute('POST', $params, 'dangdang.order.details.get'); $goods_list = array(); if (isset($goods_info['ItemsList']['ItemInfo']['itemID'])) { $goods_list[] = array('goods_sn' => $goods_info['ItemsList']['ItemInfo']['outerItemID'], 'goods_number' => $goods_info['ItemsList']['ItemInfo']['orderCount']); } else { foreach ($goods_info['ItemsList']['ItemInfo'] as $v) { $goods_list[] = array('goods_sn' => $goods_info['ItemsList']['ItemInfo']['outerItemID'], 'goods_number' => $goods_info['ItemsList']['ItemInfo']['orderCount']); } } unset($val); foreach ($goods_list as &$val) { $params['oit'] = $val['goods_sn']; $resp = $dd->execute('POST', $params, 'dangdang.item.itemid.get'); $val['goods_sn'] = $resp['Result']['itemID']; } unset($val); $order_info['shipping_tel'] = 1234567; $order_info['shipping_name'] = mb_strcut($order_info['shipping_name'], 0, 6) . '快递'; $order_info['shipping_name'] = mb_convert_encoding($order_info['shipping_name'], 'GBK', 'UTF-8'); $order_info['tracking_sn'] = trim($order_info['tracking_sn']); global $smarty; $smarty->assign('time', date('Y-m-d H:i:s')); $smarty->assign('method', 'dangdang.order.goods.send'); $smarty->assign('order_info', $order_info); $smarty->assign('goods_list', $goods_list); $send_goods = $smarty->fetch('dangdang_XML.htm'); if (file_exists('ddXML.xml')) { unlink('ddXML.xml'); } $bytes = file_put_contents('ddXML.xml', $send_goods); $params['sendGoods'] = '/var/www/html/crm2/admin/ddXML.xml'; //$dd = new ddClient(2100001198); $resp = $dd->execute('POSTXML', $params, 'dangdang.order.goods.send'); if (isset($resp['Result']['OrdersList']['OrderInfo']['orderOperCode'])) { $res['message'] = '当当网提示您:订单' . $resp['Result']['OrdersList']['OrderInfo']['orderID'] . ',' . $resp['Result']['OrdersList']['OrderInfo']['orderOperation']; } else { $res = true; } $resp = var_export($resp, true); file_put_contents('ddInfo.htm', $resp, FILE_APPEND); } // 国美同步发货 if ($order_info['shipping_time'] && $order_info['team'] == 12) { $auth = (include_once 'gome/config.php'); $url = 'http://api.coo8.com/ApiControl'; $sys_param = array('venderId' => $auth['appkey'], 'timestamp' => date('Y-m-d H:i:s'), 'v' => '2.0', 'signMethod' => 'md5', 'format' => 'json'); // 应用级参数 $sys_param['method'] = 'coo8.orders.send'; $sys_param['orderid'] = $order['order_sn']; $sys_param['logisticsNumber'] = $tracking_sn; // 配送公司编号 $sql_select = 'SELECT gemo_code FROM ' . $GLOBALS['ecs']->table('shipping') . ' s, ' . $GLOBALS['ecs']->table('order_info') . " i WHERE i.shipping_id=s.shipping_id AND i.order_id={$order_id}"; $sys_param['carriersName'] = $GLOBALS['db']->getOne($sql_select); $sys_param['sign'] = makeSign($sys_param, $auth['secretKey']); //$url = $url.'?'.http_build_query($sys_param); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($sys_param)); $data = curl_exec($ch); if (curl_errno($ch)) { throw new Exception(curl_error($ch), 0); } else { $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if (200 !== $httpStatusCode) { throw new Exception($data, $httpStatusCode); } } curl_close($ch); $res = true; } // 苏宁同步发货 if ($order_info['shipping_time'] && $order_info['team'] == 17) { require_once 'suning/SuningSdk.php'; $auth = (require_once 'suning/config.php'); // 配送公司编号 $sql_select = 'SELECT suning_code,company_name FROM ' . $GLOBALS['ecs']->table('shipping') . ' s, ' . $GLOBALS['ecs']->table('order_info') . " i WHERE i.shipping_id=s.shipping_id AND i.order_id={$order_id}"; $logistics = $GLOBALS['db']->getRow($sql_select); $shipping_code = $logistics['suning_code']; $req = new SuningCustomOrderGet(); echo $order_info['order_sn'], PHP_EOL; $req->setOrderCode($order_info['order_sn']); $reqParam = $req->makeReqObject(); $suning = new SuningClient(); $suning->setAppKey($auth['appkey']); $suning->setAppSecret($auth['secretKey']); $suning->setMethod('suning.custom.order.get'); $suning->setAppRequestTime(date('Y-m-d H:i:s')); $resp = $suning->execute($req, $reqParam); $resp = json_decode($resp, true); $orderLineNumbers = array(); foreach ($resp['sn_responseContent']['sn_body']['orderGet']['orderDetail'] as $suningOrderLineNumber) { $orderLineNumbers = $suningOrderLineNumber['orderLineNumber']; } $req = new SuningCustomOrderDeliveryAdd(); $req->setOrderCode($order_info['order_sn']); $req->setExpressNo($tracking_sn); $req->setExpressCompanyCode($shipping_code); $req->setDeliveryTime(date('Y-m-d H:i:s')); $sql_select = 'SELECT goods_sn FROM ' . $GLOBALS['ecs']->table('order_goods') . " WHERE order_sn='{$order_info['order_sn']}'"; $productCode = $GLOBALS['db']->getCol($sql_select); $req->setProductCode($productCode); $req->setOrderLineNumber($orderLineNumbers); $reqParam = $req->makeReqObject(); if ('param_is_null' == $reqParam['error_code']) { $msg = array('req_msg' => true, 'timeout' => 2000, 'message' => $reqParam['error_msg']); die($json->encode($msg)); } $suning = new SuningClient(); $suning->setAppKey($auth['appkey']); $suning->setAppSecret($auth['secretKey']); $suning->setMethod('suning.custom.orderdelivery.add'); $suning->setAppRequestTime(date('Y-m-d H:i:s')); $resp = $suning->execute($req, $reqParam); $resp = json_decode($resp, true); $res = true; } return $res; }
function xt_paipaike_items_search($args) { $app = xt_get_app_paipai(); if (empty($app) || empty($app['appKey']) || empty($app['appSecret'])) { return new WP_Error('系统错误', '尚未配置拍拍开放平台!'); } if (empty($app['token']) || empty($app['uid'])) { return new WP_Error('系统错误', '尚未配置拍拍平台QQ号及ACCESS_TOKEN!'); } if (empty($app['userId'])) { return new WP_Error('系统错误', '尚未配置拍拍客的推广ID!'); } require_once XT_PLUGIN_DIR . '/xt-core/sdks/paipai/src/PaiPaiOpenApiOauth.php'; $sdk = new PaiPaiOpenApiOauth($app['appKey'], $app['appSecret'], $app['token'], $app['uid']); $sdk->setDebugOn(false); $sdk->setMethod("get"); $sdk->setCharset("utf-8"); $sdk->setFormat('json'); $sdk->setApiPath("/cps/cpsCommSearch.xhtml"); //这个是用户需要调用的 接口函数 $params =& $sdk->getParams(); //注意,这里使用的是引用,故可以直接使用 $params = _xt_paipai_search_params($args); $params["pureData"] = 1; $params['userId'] = $app['userId']; $params['outInfo'] = xt_outercode(); $params['pageIndex'] = (intval($params['pageIndex']) - 1) * intval($params['pageSize']) + 1; if (intval($params['payType']) == 0) { unset($params['payType']); } if (intval($params['begPrice']) == 0) { unset($params['begPrice']); } else { $params['begPrice'] = intval($params['begPrice']) * 100; } if (intval($params['endPrice']) == 0) { unset($params['endPrice']); } else { $params['endPrice'] = intval($params['endPrice']) * 100; } if (intval($params['crMin']) == 0) { unset($params['crMin']); } if (intval($params['crMax']) == 0) { unset($params['crMax']); } if (intval($params['classId']) == 0 && empty($params['keyWord'])) { return new WP_Error('业务错误', 'keyWord 和 classId 参数至少有一个设值'); } $resp = $sdk->invoke(); if ($resp) { $resp = json_decode($resp); } if (isset($resp->CpsCommSearchResult)) { $resp = $resp->CpsCommSearchResult; if ($resp->errorCode > 0) { return xt_paipai_api_error($resp); } else { return array('items' => $resp->vecComm, 'total' => $resp->hitNum); } } else { return new WP_Error('系统错误', '未知'); } return array('items' => array(), 'total' => 0); }