Example #1
0
/**
 * API接口返回函数封装
 * @param int|array $message 信息编码 匹配表---om_prompt_msg
 * @param array $data
 * @author lzx
 */
function json_return($message, $data = '')
{
    if (is_array($message)) {
        $msgNo = array_shift(array_keys($message));
        $msg = implode('<br>', $message);
    } else {
        $msgNo = intval($message);
        $numargs = func_num_args();
        if ($numargs < 3) {
            $msg = get_promptmsg($msgNo);
        } else {
            $arg_list = func_get_args();
            $varlist = array_slice($arg_list, 2);
            $varstr = implode(',', array2strarray(array_map('addslashes', array_map('htmlspecialchars', $varlist))));
            eval("\$msg = get_promptmsg({$msgNo}, {$varstr});");
        }
    }
    echo json_encode(array("errCode" => $msgNo, "errMsg" => $msg, "status" => $msg == 'Success' ? true : false, "data" => $data));
    exit;
}
function get_surface_trackno($ebayid, $packingstatus)
{
    global $dbConn;
    global $transportData;
    //运输方式
    //ebay_account 为新系统的 accountId;
    //ebay_userid  为新系统的 platformUsername
    //$sql = "SELECT ebay_countryname,ebay_state,ebay_city,ebay_postcode,ebay_carrier,ebay_account,ebay_userid,ebay_usermail FROM ebay_order WHERE ebay_id='{$ebayid}'";
    //$sql = "SELECT ebay_countryname,ebay_state,ebay_city,ebay_postcode,ebay_carrier,ebay_account,ebay_userid,ebay_usermail FROM ebay_order WHERE ebay_id='{$ebayid}'";	//查询订单的地址信息
    $sql = 'SELECT sou.`countryName`,sou.`state`,sou.`city`,sou.`zipCode`,so.`transportId`,so.`accountId`,sou.`platformUsername`,sou.`email` 
			FROM `om_shipped_order` AS so
			LEFT JOIN `om_account` AS ea ON so.`accountId` = ea.`id`
			LEFT JOIN `om_shipped_order_userInfo` AS sou ON so.`id` = sou.`omOrderId`
			WHERE so.id = \'' . $ebayid . '\'';
    //获取订单的运输方式等信息
    $query = $dbConn->query($sql);
    $orderinfo = $dbConn->fetch_one($query);
    $uesrid = $orderinfo['platformUsername'];
    $uesremail = $orderinfo['email'];
    $ebay_carrier = str_replace('平邮', '挂号', $transportData[$orderinfo['transportId']]);
    $starttime = time() - 3 * 24 * 3600;
    $endtime = time();
    /*$sql = "SELECT ebay_account,ebay_tracknumber,ebay_carrier,ebay_userid,ebay_usermail FROM ebay_order WHERE ebay_combine!='1' AND scantime>'{$starttime}' AND scantime<'{$endtime}' AND ebay_carrier='$ebay_carrier' AND ebay_postcode='{$orderinfo['ebay_postcode']}' ORDER BY scantime DESC LIMIT 10";*/
    $sql = 'SELECT so.`id`,so.`recordNumber`,so.`accountId`,so.`ShippedTime`,so.`transportId`,so.`marketTime`,so.`orderStatus`,ea.`account`,
				sou.`countrySn`,sou.`countryName`,sou.`city`,sou.`email`,sou.`platformUsername`,sou.`zipCode`,sow.`weighTime`,sow.`weighStaffId`,ot.`tracknumber` 
			FROM `om_shipped_order` AS so
			LEFT JOIN `om_account` AS ea ON so.`accountId` = ea.`id`
			LEFT JOIN `om_shipped_order_userInfo` AS sou ON so.`id` = sou.`omOrderId` 
			LEFT JOIN `om_shipped_order_warehouse` AS sow ON so.`id` = sow.`omOrderId` 
			LEFT JOIN `om_order_tracknumber` AS ot ON so.`id` = ot.`omOrderId` 
			WHERE so.combineOrder != 1 AND sow.`weighTime` >= ' . $starttime . ' AND sow.`weighTime` <= ' . $endtime . '
			AND so.`transportId` = \'' . $orderinfo['transportId'] . '\'
			AND sou.`zipCode` = \'' . $orderinfo['zipCode'] . '\' ORDER BY sow.`weighTime` DESC LIMIT 10';
    //获取订单的运输方式等信息
    //echo $sql."\n\n";
    $query = $dbConn->query($sql);
    $orders = $dbConn->fetch_array_all($query);
    //print_r($orders);exit;
    if (empty($orders)) {
        $_orderinfo = $orderinfo;
        unset($_orderinfo['zipCode'], $_orderinfo['transportId'], $_orderinfo['platformUsername'], $_orderinfo['email']);
        //$_orderinfo['accountId']
        //ebay_countryname,ebay_state,ebay_city
        $wheres = array();
        while (!empty($_orderinfo)) {
            $wheres[] = $_orderinfo;
            array_pop($_orderinfo);
        }
        //print_r($wheres);exit;
        foreach ($wheres as $where) {
            $where = array2strarray($where);
            $sql_where = array();
            foreach ($where as $_k => $_v) {
                if (empty($_k)) {
                    continue;
                }
                $_v = trim($_v);
                $sql_where[] = "{$_k}={$_v}";
            }
            //$sql = "SELECT ebay_account,ebay_tracknumber,ebay_carrier,ebay_userid,ebay_usermail FROM ebay_order WHERE ebay_combine!='1' AND scantime>'{$starttime}' AND scantime<'{$endtime}' AND ebay_carrier='$ebay_carrier' AND ".implode(' AND ', $sql_where)." ORDER BY scantime DESC LIMIT 10";
            $sql = 'SELECT so.`id`,so.`recordNumber`,so.`accountId`,so.`ShippedTime`,so.`transportId`,so.`marketTime`,so.`orderStatus`,ea.`account`,
						sou.`countrySn`,sou.`countryName`,sou.`city`,sou.`email`,sou.`platformUsername`,sou.`zipCode`,sow.`weighTime`,sow.`weighStaffId`,ot.`tracknumber`
					FROM `om_shipped_order` AS so 
					LEFT JOIN `om_account` AS ea ON so.`accountId` = ea.`id` 
					LEFT JOIN `om_shipped_order_userInfo` AS sou ON so.`id` = sou.`omOrderId` 
					LEFT JOIN `om_shipped_order_warehouse` AS sow ON so.`id` = sow.`omOrderId` 
					LEFT JOIN `om_order_tracknumber` AS ot ON so.`id` = ot.`omOrderId` 
					WHERE so.combineOrder != 1 AND sow.`weighTime` >= ' . $starttime . ' AND sow.`weighTime` <= ' . $endtime . '  
					AND so.`transportId` = \'' . $orderinfo['transportId'] . '\' AND ' . implode(' AND ', $sql_where) . ' ORDER BY sow.`weighTime` DESC LIMIT 10	';
            //echo "$sql\n\n";exit;
            $sql = $dbConn->query($sql);
            $orders = $dbConn->fetch_array_all($sql);
            if (!empty($orders)) {
                break;
            }
        }
    }
    foreach ($orders as $order) {
        if ($uesrid != $order['id'] && $uesremail != $order['email'] && !check_is_useful($order['tracknumber'], $orderinfo['accountId'], $orderinfo['platformUsername'], $orderinfo['email'])) {
            $surfacedata = array();
            $surfacedata['order_id'] = $ebayid;
            $surfacedata['account'] = $order['accountId'];
            //被使用的账号
            $surfacedata['use_account'] = $orderinfo['accountId'];
            //当前上传跟踪号的账号
            $surfacedata['shippingstatus'] = 1;
            $surfacedata['packingstatus'] = $packingstatus;
            $surfacedata['trackno'] = $order['tracknumber'];
            $surfacedata['carrier'] = $transportData[$order['transportId']];
            //$order['ebay_carrier'];
            $surfacedata['saleuser'] = $orderinfo['platformUsername'];
            $surfacedata['saleemail'] = $orderinfo['email'];
            backup_surfaceid($surfacedata);
            unset($order['ebay_userid'], $order['email']);
            return $order;
        }
    }
    $trackno = 'WD' . str_pad($ebayid, 9, "0", STR_PAD_LEFT) . "CN";
    if (!check_is_useful($trackno, $orderinfo['accountId'], $orderinfo['platformUsername'], $orderinfo['email'])) {
        $surfacedata = array();
        $surfacedata['order_id'] = $ebayid;
        $surfacedata['account'] = 'wedo';
        //被使用的账号
        $surfacedata['use_account'] = $orderinfo['accountId'];
        //当前上传跟踪号的账号
        $surfacedata['shippingstatus'] = 1;
        $surfacedata['packingstatus'] = $packingstatus;
        $surfacedata['trackno'] = $trackno;
        $surfacedata['carrier'] = 'wedo';
        $surfacedata['saleuser'] = $orderinfo['platformUsername'];
        $surfacedata['saleemail'] = $orderinfo['email'];
        backup_surfaceid($surfacedata);
    }
    //print_r(array('ebay_account'=>'wedo', 'ebay_tracknumber'=>$trackno, 'ebay_carrier'=>'61'));exit;
    return array('ebay_account' => 'wedo', 'ebay_tracknumber' => $trackno, 'ebay_carrier' => '61');
    //'ebay_carrier'=>'wedo'
}
Example #3
0
function getaccountsale($sku, $accounts)
{
    global $dbcon;
    $totalnums = 0;
    $combineskus = get_combinesku($sku);
    $mouthtime = strtotime(date("Y-m") . '-1 00:00:01');
    $skus = empty($combineskus) ? array() : array_keys($combineskus);
    array_push($skus, $sku);
    $account_sql = implode(',', array2strarray($accounts));
    foreach ($skus as $_sku) {
        $realtimes = 1;
        if ($_sku != $sku && $combineskus[$_sku]) {
            $skulist = explode(',', $combineskus[$_sku]);
            foreach ($skulist as $sku_info) {
                list($_s, $times) = explode('*', $sku_info);
                if ($_s == $sku) {
                    $realtimes = $times;
                }
            }
        } else {
            $realtimes = 1;
        }
        $sql = "SELECT sum(b.ebay_amount) AS qty \n\t\t\t\t\tFROM ebay_order AS a \n\t\t\t\t\tLEFT JOIN ebay_orderdetail AS b ON a.ebay_ordersn = b.ebay_ordersn \n\t\t\t\t\tWHERE a.ebay_status=2\n\t\t\t\t\tAND b.sku='{$_sku}'\n\t\t\t\t\tAND a.ebay_account IN ({$account_sql})\n\t\t\t\t\tAND a.scantime>{$mouthtime}\n\t\t\t\t\tLIMIT 1";
        $sql = $dbcon->execute($sql);
        $skunums = $dbcon->getResultArray($sql);
        if (!empty($skunums)) {
            $totalnums += $skunums[0]['qty'] * $realtimes;
        }
    }
    return $totalnums;
}
Example #4
0
 private function act_getOrderCondition()
 {
     #########################################################################
     #########					 查询条件 start			 			#########
     #########################################################################
     $nowtime = time();
     $starttime = $endtime = 0;
     $searcherrs = $ordercd = $userinfo = array();
     if (isset($_GET['KeywordsType']) && $_GET['KeywordsType'] != '*' && !empty($_GET['KeywordsType'])) {
         $field = trim($_GET['KeywordsType']);
         if (isset($_GET['Keywords']) && !empty($_GET['Keywords'])) {
             $Keywords = trim($_GET['Keywords']);
             if (in_array($field, array('platformId'))) {
                 $Keywords = getPlatformIdFromName($Keywords);
             } elseif (in_array($field, array('accountId'))) {
                 $Keywords = getAccountIdFromName($Keywords);
             }
             $keycond = strpos($Keywords, ',') !== false ? array('$in' => array2strarray(explode(',', $Keywords))) : array('$e' => $Keywords);
             if (in_array($field, array('id', 'recordNumber', 'platformId', 'accountId'))) {
                 $ordercd[$field] = $keycond;
             } else {
                 if (in_array($field, array('email', 'platformUsername'))) {
                     $userinfo[$field] = $keycond;
                 } else {
                     if (in_array($field, array('tracknumber'))) {
                         $trackcd[$field] = $keycond;
                     } else {
                         if (in_array($field, array('PayPalPaymentId'))) {
                             $orderextcd[$field] = $keycond;
                         }
                     }
                 }
             }
         }
     }
     if (isset($_GET['status']) && $_GET['status'] != '*' && !empty($_GET['status'])) {
         $ordercd['status'] = array('$e' => intval($_GET['status']));
         $ordercd['menu'] = array('$e' => intval($_GET['menu']));
     }
     if (isset($_GET['platformId']) && $_GET['platformId'] != '*' && !empty($_GET['platformId'])) {
         $ordercd['platformId'] = array('$e' => intval($_GET['platformId']));
     }
     if (isset($_GET['accountId']) && $_GET['accountId'] != '*' && !empty($_GET['accountId'])) {
         $ordercd['accountId'] = array('$e' => intval($_GET['accountId']));
     }
     if (isset($_GET['transportationType']) && $_GET['transportationType'] != '*' && !empty($_GET['transportationType'])) {
         $ordercd['transportationType'] = array('$e' => intval($_GET['transportationType']));
     }
     if (isset($_GET['transportation']) && $_GET['transportation'] != '*' && !empty($_GET['transportation'])) {
         $ordercd['transportId'] = array('$e' => intval($_GET['transportation']));
     }
     if (isset($_GET['isNote']) && $_GET['isNote'] != '*' && !empty($_GET['isNote'])) {
         $ordercd['isNote'] = array('$e' => intval($_GET['isNote']));
     }
     if (isset($_GET['ostatus']) && !empty($_GET['ostatus']) && $_GET['ostatus'] != '*') {
         $ordercd['orderStatus'] = array('$e' => intval($_GET['ostatus']));
     }
     if (isset($_GET['isexpressdelivery']) && !empty($_GET['isexpressdelivery']) && $_GET['isexpressdelivery'] != '*') {
         $ordercd['isExpressDelivery'] = array('$e' => intval($_GET['isexpressdelivery']));
     }
     if (isset($_GET['otype']) && !empty($_GET['otype']) && $_GET['otype'] != '*') {
         $ordercd['orderType'] = array('$e' => intval($_GET['otype']));
     }
     if (isset($_GET['countrySn']) && !empty($_GET['countrySn'])) {
         $countrySn = trim($_GET['countrySn']);
         if ($this->act_checkCountryCode($countrySn) !== false) {
             $userinfo['countrySn'] = array('$e' => $countrySn);
         } else {
             $searcherrs[$this->errCode] = get_promptmsg($this->errCode, $countrySn);
         }
     }
     $sTimeType = isset($_GET['searchTimeType']) && !empty($_GET['searchTimeType']) ? trim($_GET['searchTimeType']) : 'paymentTime';
     if (isset($_GET['OrderTime1']) && !empty($_GET['OrderTime1'])) {
         $OrderTime1 = trim($_GET['OrderTime1']);
         if (validate_datetime($OrderTime1)) {
             $starttime = strtotime($OrderTime1);
         } else {
             $searcherrs[10005] = get_promptmsg(10005, $OrderTime1);
         }
     }
     if (isset($_GET['OrderTime2']) && !empty($_GET['OrderTime2'])) {
         $OrderTime2 = trim($_GET['OrderTime2']);
         if (validate_datetime($OrderTime2)) {
             $endtime = strtotime($OrderTime2);
         } else {
             $searcherrs[10006] = get_promptmsg(10006, $OrderTime2);
         }
     }
     if ($starttime > 0 && $endtime === 0 && $nowtime) {
         $ordercd[$sTimeType] = array('$gt' => $starttime);
     } else {
         if ($starttime === 0 && $endtime > 0) {
             $ordercd[$sTimeType] = array('$lt' => $endtime);
         } else {
             if ($starttime < $endtime) {
                 $ordercd[$sTimeType] = array('$b' => "{$starttime}-{$endtime}");
             } else {
                 if ($starttime > $endtime) {
                     $searcherrs[10007] = get_promptmsg(10007, $OrderTime1, $OrderTime2);
                 } else {
                     if ($starttime > 0 && ($starttime = $endtime)) {
                         $searcherrs[10008] = get_promptmsg(10008, $OrderTime1, $OrderTime2);
                     }
                 }
             }
         }
     }
     if (isset($this->orderpower) && !empty($this->orderpower)) {
         foreach ($this->orderpower as $name => $plist) {
             $ordercds[] = "{$name} IN (" . implode(',', $plist) . ")";
         }
     }
     //分表相关
     $ordercd['is_delete'] = array('$e' => 0);
     //查询条件合并
     $conditions = array();
     $conditions['order'] = $ordercd;
     //主表必须在前面
     if (!empty($userinfo)) {
         $conditions['userinfo'] = $userinfo;
     }
     if (!empty($trackcd)) {
         $conditions['trackcd'] = $trackcd;
     }
     if (!empty($orderextcd)) {
         $conditions['orderextcd'] = $orderextcd;
     }
     #########################################################################
     #########					 查询条件 end			 				#########
     #########################################################################
     return $conditions;
 }
function get_surface_trackno($ebayid, $packingstatus)
{
    global $dbcon;
    $sql = "SELECT ebay_countryname,ebay_state,ebay_city,ebay_postcode,ebay_carrier,ebay_account,ebay_userid,ebay_usermail FROM ebay_order WHERE ebay_id='{$ebayid}'";
    $sql = $dbcon->query($sql);
    $orderinfo = $dbcon->fetch_one($sql);
    $ebay_carrier = str_replace('平邮', '挂号', $orderinfo['ebay_carrier']);
    $starttime = time() - 3 * 24 * 3600;
    $endtime = time();
    $sql = "SELECT ebay_account,ebay_tracknumber,ebay_carrier FROM ebay_order WHERE ebay_combine!='1' AND ebay_carrier='{$ebay_carrier}' AND scantime BETWEEN '{$starttime}' AND '{$endtime}' AND ebay_postcode='{$orderinfo['ebay_postcode']}' AND ebay_countryname='{$orderinfo['ebay_countryname']}' ORDER BY ebay_id DESC";
    //$sql = "SELECT * FROM ebay_order as eo WHERE eo.ebay_combine!='1' AND eo.scantime > '1390320000' AND eo.scantime < '1390492799' AND eo.ebay_carrier='中国邮政挂号' AND eo.ebay_countryname = 'Brazil' AND eo.ebay_state = 'Parana' AND eo.ebay_city = 'Nova Esperanca'";
    $sql = "SELECT ebay_account,ebay_tracknumber,ebay_carrier FROM ebay_order WHERE ebay_combine!='1' AND scantime>'{$starttime}' AND scantime<'{$endtime}' AND ebay_carrier='{$ebay_carrier}' AND ebay_postcode='{$orderinfo['ebay_postcode']}' ORDER BY scantime DESC LIMIT 10";
    echo "{$sql}\n\n";
    $sql = $dbcon->query($sql);
    $orders = $dbcon->getResultArray($sql);
    if (empty($orders)) {
        $_orderinfo = $orderinfo;
        unset($_orderinfo['ebay_postcode'], $_orderinfo['ebay_carrier'], $_orderinfo['ebay_account'], $_orderinfo['ebay_userid'], $_orderinfo['ebay_usermail']);
        $wheres = array();
        /*while (!empty($_orderinfo)){
        			$wheres[] = $_orderinfo;
        			array_pop($_orderinfo);
        		}*/
        $wheres[] = $_orderinfo;
        foreach ($wheres as $where) {
            $where = array2strarray($where);
            $sql_where = array();
            foreach ($where as $_k => $_v) {
                if (empty($_k)) {
                    continue;
                }
                $_v = trim($_v);
                $sql_where[] = "{$_k}={$_v}";
            }
            $sql = "SELECT ebay_account,ebay_tracknumber,ebay_carrier FROM ebay_order WHERE ebay_combine!='1' AND scantime>'{$starttime}' AND scantime<'{$endtime}' AND ebay_carrier='{$ebay_carrier}' AND " . implode(' AND ', $sql_where) . " ORDER BY scantime DESC LIMIT 10";
            echo "{$sql}\n\n";
            $sql = $dbcon->query($sql);
            $orders = $dbcon->getResultArray($sql);
            if (!empty($orders)) {
                break;
            }
        }
    }
    foreach ($orders as $order) {
        if (!check_is_useful($order['ebay_tracknumber'], $orderinfo['ebay_account'], $orderinfo['ebay_userid'], $orderinfo['ebay_usermail'])) {
            $surfacedata = array();
            $surfacedata['order_id'] = $ebayid;
            $surfacedata['account'] = $order['ebay_account'];
            $surfacedata['use_account'] = $orderinfo['ebay_account'];
            $surfacedata['shippingstatus'] = 1;
            $surfacedata['packingstatus'] = $packingstatus;
            $surfacedata['trackno'] = $order['ebay_tracknumber'];
            $surfacedata['carrier'] = $order['ebay_carrier'];
            $surfacedata['saleuser'] = $orderinfo['ebay_userid'];
            $surfacedata['saleemail'] = $orderinfo['ebay_usermail'];
            backup_surfaceid($surfacedata);
            return $order;
        }
    }
    $trackno = 'WD' . str_pad($ebayid, 9, "0", STR_PAD_LEFT) . "CN";
    if (!check_is_useful($trackno, $orderinfo['ebay_account'], $orderinfo['ebay_userid'], $orderinfo['ebay_usermail'])) {
        $surfacedata = array();
        $surfacedata['order_id'] = $ebayid;
        $surfacedata['account'] = 'wedo';
        $surfacedata['use_account'] = $orderinfo['ebay_account'];
        $surfacedata['shippingstatus'] = 1;
        $surfacedata['packingstatus'] = $packingstatus;
        $surfacedata['trackno'] = $trackno;
        $surfacedata['carrier'] = 'wedo';
        $surfacedata['saleuser'] = $orderinfo['ebay_userid'];
        $surfacedata['saleemail'] = $orderinfo['ebay_usermail'];
        backup_surfaceid($surfacedata);
    }
    return array('ebay_account' => 'wedo', 'ebay_tracknumber' => $trackno, 'ebay_carrier' => 'wedo');
}
Example #6
0
function getaccountsaleow($sku, $accounts, $wheretime = array())
{
    global $dbcon;
    $totalnums = 0;
    $combineskus = get_combinesku($sku);
    $skus = empty($combineskus) ? array() : array_keys($combineskus);
    array_push($skus, $sku);
    $account_sql = implode(',', array2strarray($accounts));
    $scantime = "";
    if (count($wheretime) == 2) {
        list($starttime, $endtime) = $wheretime;
        $scantime = "AND a.scantime BETWEEN {$starttime} AND {$endtime}";
    }
    foreach ($skus as $_sku) {
        $realtimes = 1;
        if ($_sku != $sku && $combineskus[$_sku]) {
            $skulist = explode(',', $combineskus[$_sku]);
            foreach ($skulist as $sku_info) {
                list($_s, $times) = explode('*', $sku_info);
                if ($_s == $sku) {
                    $realtimes = $times;
                }
            }
        } else {
            $realtimes = 1;
        }
        $sql = "SELECT sum(b.ebay_amount) AS qty \n\t\t\t\t\tFROM ebay_order AS a \n\t\t\t\t\tLEFT JOIN ebay_orderdetail AS b ON a.ebay_ordersn = b.ebay_ordersn \n\t\t\t\t\tWHERE a.ebay_status=709\n\t\t\t\t\tAND b.sku='{$_sku}'\n\t\t\t\t\tAND a.ebay_account IN ({$account_sql})\n\t\t\t\t\t{$scantime}";
        //echo "==={$_sku}==={$realtimes}===".$sql."\n\n"; //注释掉防止生成的日志文件过大打不开 add by guanyongjun 2013-09-04
        $sql = $dbcon->execute($sql);
        $skunums = $dbcon->getResultArray($sql);
        if (!empty($skunums)) {
            $totalnums += $skunums[0]['qty'] * $realtimes;
        }
        //echo "==={$_sku}=销售数量=".$totalnums."\n";
    }
    return $totalnums;
}