예제 #1
0
파일: order.php 프로젝트: 554119220/kjrscrm
function batch_flushing_order_out($order_info, $tracking_sn, $logistics)
{
    if (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 dirname(__FILE__) . "/taobao/order_synchro.php";
        require dirname(__FILE__) . "/{$platform_path[$order_info['team']]}/sk.php";
        $auth = (require 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']);
            return false;
        } 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']);
            return false;
        } else {
            return $tracking_sn;
        }
    }
}
예제 #2
0
/**
 * 刷单标记发货:天猫
 */
function shipping_sync_6($order_info)
{
    $platform_path = array(6 => 'taobao', 21 => 'taobao01', 22 => 'taobao02');
    require '../admin/taobao/order_synchro.php';
    require "../admin/{$platform_path[$order_info['team']]}/sk.php";
    $auth = (require "../admin/{$platform_path[$order_info['team']]}/config.php");
    $logistics = logistics_code($order_info['shipping_id']);
    // 配置淘宝签权参数
    $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']));
        } 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'];
    }
}