Beispiel #1
0
/**
 * 同步标记发货
 */
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;
}
Beispiel #2
0
function signVerify($array)
{
    foreach ($array as $k => $v) {
        if ('sign' == $k) {
            $inValue = $v;
        } else {
            $data[$k] = $v;
        }
    }
    $outValue = makeSign($data, KEY);
    if ($outValue == $inValue) {
        return true;
    } else {
        return false;
    }
}
Beispiel #3
0
 //    mylog(getArrayInf($_SERVER));
 $query = pdoQuery('order_tbl', null, array('id' => $_POST['order_id'], 'stu' => '0'), ' limit 1');
 if ($inf = $query->fetch()) {
     if (0 == $inf['stu']) {
         $date = array();
         $date['appid'] = APP_ID;
         $date['mch_id'] = MCH_ID;
         $date['nonce_str'] = getRandStr(32);
         $date['body'] = 'gshopPay';
         $date['spbill_create_ip'] = $_SERVER['REMOTE_ADDR'];
         $date['out_trade_no'] = $_POST['order_id'];
         $date['total_fee'] = $inf['total_fee'] * 100;
         $date['notify_url'] = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
         $date['trade_type'] = 'JSAPI';
         $date['openid'] = $inf['c_id'];
         $sign = makeSign($date, KEY);
         $date['sign'] = $sign;
         $xml = toXml($date);
         $handler = new interfaceHandler(WEIXIN_ID);
         $data = $handler->postByCurl('https://api.mch.weixin.qq.com/pay/unifiedorder', $xml);
         //            mylog('prePayInf:' . $data);
         $dataArray = xmlToArray($data);
         $dataJson = json_encode($dataArray, JSON_UNESCAPED_UNICODE);
         //            mylog('formated payInf' . getArrayInf($dataArray));
     }
     if ('SUCCESS' == $dataArray['return_code']) {
         if ('SUCCESS' == $dataArray['result_code']) {
             if (signVerify($dataArray)) {
                 $_SESSION['userKey']['package'] = 'prepay_id=' . $dataArray['prepay_id'];
                 echo 'ok';
                 exit;
Beispiel #4
0
     } else {
         header('location:controller.php?editAddress=1&from=' . $to);
     }
     exit;
 }
 if (isset($_GET['pay_order'])) {
     $orderId = $_GET['order_id'];
     $orderStu = $_GET['order_stu'];
     include 'view/order_inf.html.php';
     exit;
 }
 if (isset($_GET['preOrderOK'])) {
     if (isset($_SESSION['userKey']['package'])) {
         //            mylog($_SESSION['userKey']['package']);
         $preSign = array('appId' => APP_ID, 'timeStamp' => time(), 'nonceStr' => getRandStr(32), 'package' => $_SESSION['userKey']['package'], 'signType' => 'MD5');
         $sign = makeSign($preSign, KEY);
         $preSign['paySign'] = $sign;
         //            mylog('jsAPiPry:'.toXml($preSign));
         $orderId = (include 'view/wxpay.html.php');
     } else {
         header('location:index.php');
     }
     exit;
 }
 if (isset($_GET['review'])) {
     //        mylog('haha');
     $reviewedQuery = pdoQuery('review_tbl', array('d_id'), array('order_id' => $_GET['order_id']), null);
     foreach ($reviewedQuery as $row) {
         $reviewed[] = $row['d_id'];
     }
     //        mylog('hh2');
Beispiel #5
0
function addGemoOrderIntoDB($start, $end, $page_no = 1)
{
    $auth = (include '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');
    $sys_param['signMethod'] = 'md5';
    $sys_param['format'] = 'json';
    // 应用级参数
    $sys_param['method'] = 'coo8.orders.get';
    $sys_param['startDate'] = $start;
    $sys_param['endDate'] = $end;
    $sys_param['pageSize'] = 100;
    $sys_param['pageNo'] = $page_no;
    $sys_param['sign'] = makeSign($sys_param, $auth['secretKey']);
    $url_param = array();
    foreach ($sys_param as $key => $val) {
        $url_param[] = $key . '=' . $val;
    }
    //$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);
    $data = json_decode($data, true);
    echo '<pre>';
    print_r($data);
    $now_time = time();
    $order_list = $resp['orders_get_response'];
    if (is_array($order_list) && $order_list['total_result'] > 0) {
        foreach ($order_list['orders'] as $val) {
            $order_info = array();
            $user_info = array();
            /* 如果订单状态不是 等待卖家发货,则跳过该订单 */
            if ($val['status'] != 'PR') {
                continue;
            }
            $tmp_order_sn = number_format($val['order_id'], 0, '', '');
            // 查询临时订单表中  该订单是否已经存在
            $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('ordersyn_info') . " WHERE order_sn='{$tmp_order_sn}'";
            /* 如果订单已经存在,则跳过该订单 */
            if ($GLOBALS['db']->getOne($sql)) {
                continue;
            }
            // 查询正式订单表中 该订单是否已经存在
            $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE order_sn='{$tmp_order_sn}' OR platform_order_sn='{$tmp_order_sn}'";
            if ($GLOBALS['db']->getOne($sql)) {
                continue;
            }
            /* 顾客信息 */
            $user_info = array('consignee' => trim($val['consignee']['name']), 'country' => 1, 'tel' => trim($val['consignee']['telephone']), 'mobile' => trim($val['consignee']['mobilephone']), 'email' => trim($val['consignee']['email']));
            $pcd = getProCitDis($val['consignee']['province'], $val['consignee']['city'], $val['consignee']['county']);
            if ($pcd === false) {
                $user_info['province'] = 0;
                $user_info['city'] = 0;
                $user_info['district'] = 0;
                $user_info['address'] = $val['consignee']['province'] . $val['consignee']['city'] . $val['consignee']['county'] . $val['consignee']['address'];
            } else {
                $user_info['province'] = $pcd['state'];
                $user_info['city'] = $pcd['city'];
                $user_info['district'] = $pcd['district'];
                $user_info['address'] = $val['consignee']['address'];
            }
            $remarks = array();
            if (!empty($val['buyer_message'])) {
                $remarks[] = '买家留言:' . $val['consignee']['want_send_time'];
            }
            if (!empty($val['buyer_memo'])) {
                $remarks[] = '买家备注:' . $val['buyer_memo'];
            }
            if (!empty($val['seller_memo'])) {
                $remarks[] = '卖家备注:' . $val['seller_memo'];
            }
            /* 订单信息 */
            $order_info = array('goods_amount' => $val['payment'], 'shipping_fee' => 0, bcadd($val['post_fee'], $val['cod_fee'], 2), 'final_amount' => $val['payment'], 'add_time' => strtotime($val['order_time']), 'confirm_time' => strtotime($val['order_change_time']), 'remarks' => implode('<br>', $remarks), 'to_seller' => trim(strstr($val['seller_memo'], '#')), 'inv_type' => trim($val['consignee']['invoice_title']), 'order_sn' => number_format($val['order_id'], 0, '', ''), 'team' => 12, 'syn_time' => $now_time, 'pay_id' => 17, 'pay_name' => '国美在线支付', 'platform' => 12, 'discount_amount' => '', 'discount_explain' => '');
            if ($val['type'] != 'cod') {
                $region = array('state' => $val['consignee']['province'], 'city' => $val['consignee']['city'], 'district' => $val['consignee']['county']);
                $shipping = get_shipping($region);
                $order_info['shipping_id'] = $shipping['id'];
                $order_info['shipping_name'] = $shipping['name'];
                $order_info['shipping_code'] = $shipping['code'];
            }
            /* 判断顾客是否已存在 */
            $user = userIsExist($user_info);
            if ($user) {
                /* 如果顾客已存在,将订单归到该顾客名下 */
                $user_info['user_id'] = $user['user_id'];
                $order_info['admin_id'] = $user['admin_id'];
                $order_info['platform'] = $user['role_id'];
                $order_info['group_id'] = $user['group_id'];
                /* 分配订单 */
                if ($order_info['admin_id']) {
                    $order_info['operator'] = $order_info['admin_id'];
                } else {
                    $sql = 'SELECT operator FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE user_id={$user_info['user_id']} AND operator<>0";
                    $order_info['operator'] = $GLOBALS['db']->getOne($sql);
                }
            } else {
                /* 如果顾客不存在,将顾客信息录入数据库  */
                $sql = 'INSERT INTO ' . $GLOBALS['ecs']->table('userssyn') . '(user_name,home_phone,mobile_phone,email,from_where,add_time,customer_type,role_id)VALUES(' . "'{$user_info['consignee']}','{$user_info['tel']}','{$user_info['mobile']}','{$user_info['email']}',\n                    3, {$order_info['add_time']}, 2,6)";
                $GLOBALS['db']->query($sql);
                $user_info['user_id'] = $GLOBALS['db']->insert_id();
                //$order_info['operator'] = orderAssign();
            }
            unset($user_info['aliww']);
            $goods_info = array();
            foreach ($val['order_details']['order_detail'] as $v) {
                $goods_info[] = array('outer_iid' => $v['outId'], 'price' => bcsub($v['price'], $v['part_discount_price'] / $v['count'], 2), 'num' => $v['count'], 'title' => $v['item_name']);
            }
            /* 生成订单SQL */
            $sql = createOrderSql($user_info, $order_info, $goods_info);
            if (submitSql($sql) === false) {
            } elseif ($val['seller_flag'] === 0) {
            }
        }
    }
    $page = ceil($val['total_result'] / $sys_param['pageSize']);
    if ($page > 1) {
        return addGemoOrderIntoDB($start, $end, ++$page_no);
    }
}