示例#1
0
 public function addOrder($account)
 {
     if (!defined('WEB_PATH')) {
         define("WEB_PATH", "/data/web/order.valsun.cn/");
     }
     require_once WEB_PATH . "crontab/scripts.comm.php";
     require_once WEB_PATH_CONF_SCRIPTS . "script.ebay.config.php";
     require_once WEB_PATH_LIB_SDK_EBAY . "GetCertainOrder.php";
     require_once WEB_PATH_LIB_SCRIPTS_EBAY . "ebay_order_cron_func.php";
     $rmq_config = C("RMQ_CONFIG");
     $rabbitMQClass = new RabbitMQClass($rmq_config['fetchOrder'][1], $rmq_config['fetchOrder'][2], $rmq_config['fetchOrder'][4], $rmq_config['fetchOrder'][0]);
     //队列对象
     $omAvailableAct = new OmAvailableAct();
     $where = 'WHERE is_delete=0 ';
     $where .= 'AND platformId in(1,5) ';
     $GLOBAL_EBAY_ACCOUNT = $omAvailableAct->act_getTNameList2arrById('om_account', 'id', 'account', $where);
     $FLIP_GLOBAL_EBAY_ACCOUNT = array_flip($GLOBAL_EBAY_ACCOUNT);
     if (!preg_match('#^[\\da-zA-Z]+$#i', $account)) {
         $message .= "<font color='red'>Invalid ebay account: {$account}!</font><br>";
         self::$errCode = 101;
         self::$errMsg = $mesage;
         return false;
     }
     if (!in_array($account, $GLOBAL_EBAY_ACCOUNT)) {
         //exit("$account is not support now !\n");
         $message .= "<font color='red'>{$account} is not support now !</font><br>";
         self::$errCode = 102;
         self::$errMsg = $mesage;
         return false;
     }
     //预先判断ebaytoken文件
     $__token_file = WEB_PATH_CONF_SCRIPTS_KEYS_EBAY . 'keys_' . $account . '.php';
     if (!file_exists($__token_file)) {
         //exit($__token_file." does not exists!!!");
         $message .= "<font color='red'>{$__token_file} does not exists!!!</font><br>";
         self::$errCode = 103;
         self::$errMsg = $mesage;
         return false;
     }
     $express_delivery = array();
     $express_delivery_value = array();
     $no_express_delivery = array();
     $no_express_delivery_value = array();
     $express_delivery_arr = CommonModel::getTransCarrierInfo(1);
     foreach ($express_delivery_arr['data'] as $value) {
         $express_delivery_value[$value['id']] = $value['carrierNameCn'];
     }
     $express_delivery = array_keys($express_delivery_value);
     //var_dump($express_delivery);
     $no_express_delivery_arr = CommonModel::getTransCarrierInfo();
     foreach ($no_express_delivery_arr['data'] as $value) {
         $no_express_delivery_value[$value['id']] = $value['carrierNameCn'];
     }
     $no_express_delivery = array_keys($no_express_delivery_value);
     //var_dump($no_express_delivery); exit;
     #########全局变量设置########
     date_default_timezone_set('Asia/Chongqing');
     $detailLevel = 0;
     $Sordersn = "eBay";
     $mctime = time();
     $cc = $mctime;
     $nowtime = date("Y-m-d H:i:s", $cc);
     $nowd = date("Y-m-d", $cc);
     #################以下账号用于测试#############
     //$account= $__ebayaccount;
     #############类或API 实例化##############
     $api_gco = new GetCertainOrderAPI($account);
     //$oa	=new OrderAction();
     //程序计时器
     $time_start = $cc;
     //echo "\n=====[".date('Y-m-d H:i:s',$time_start)."] 系统【开始】抓取账号【 $account 】订单 ====>\n\n";
     $message = $api_gco->GetCertainOrder($account);
     //监听获取队列信息
     if ($message === true) {
         self::$errCode = 200;
         self::$errMsg = "成功抓取订单!";
         return true;
     } elseif ($message === false) {
         self::$errCode = 104;
         self::$errMsg = "抓取订单失败!";
         return false;
     } else {
         self::$errCode = 105;
         self::$errMsg = $message;
         return;
     }
     //return $message;
 }
示例#2
0
    $no_express_delivery_value[$value['id']] = $value['carrierNameCn'];
}
$no_express_delivery = array_keys($no_express_delivery_value);
//var_dump($no_express_delivery); exit;
#########全局变量设置########
date_default_timezone_set('Asia/Chongqing');
$detailLevel = 0;
$Sordersn = "eBay";
$mctime = time();
$cc = $mctime;
$nowtime = date("Y-m-d H:i:s", $cc);
$nowd = date("Y-m-d", $cc);
#################以下账号用于测试#############
$account = $__ebayaccount;
#############类或API 实例化##############
$api_gco = new GetCertainOrderAPI($__ebayaccount);
//$oa	=new OrderAction();
//程序计时器
$time_start = $cc;
echo "\n=====[" . date('Y-m-d H:i:s', $time_start) . "] 系统【开始】抓取账号【 {$account} 】订单 ====>\n\n";
$api_gco->GetCertainOrder($account);
//监听获取队列信息
exit;
//echo implode("\n", $dbConn->error)."\n\n";
echo " =====[" . date('Y-m-d H:i:s') . "]系统【开始】计算【 {$account} 】\n ";
//echo " 订单[".implode("\t",$_orderids)."]运费 ====>\n";
echo " 等待计算运输方式的数量" . count($orders) . "\n";
//auto_contrast_intercept($orders);//自动缺货拦截全部上线
foreach ($orders as $order) {
    // 判断 是否在黑名单里面
    $ebay_userid = $order['ebay_userid'];
示例#3
0
 public function view_addMissingOrder()
 {
     $OmAccountAct = new OmAccountAct();
     $message = isset($_GET['message']) ? trim($_GET['message']) : '';
     $aliexpressmessage = isset($_GET['aliexpressmessage']) ? trim($_GET['aliexpressmessage']) : '';
     //echo $message;
     $amazonAccountList = $OmAccountAct->act_getAccountListByPid(11);
     //print_r($amazonAccountList);
     $amazonAccountList = json_decode($amazonAccountList, true);
     $ebayAccountList = $OmAccountAct->act_getEbayAccountList();
     //print_r($ebayAccountList); exit;
     if (isset($_POST['addOrder']) && !empty($_POST)) {
         $addorder = isset($_POST['addOrder']) ? $_POST['addOrder'] : "";
         if ($addorder == "ebay") {
             //$message = "";
             $accountId = isset($_POST['ebay_account']) ? $_POST['ebay_account'] : "";
             $account = OmAvailableModel::getTNameList("om_account", "*", " where id={$accountId}");
             $account = $account[0]['account'];
             //echo $account;
             include WEB_PATH . "conf/scripts/script.ebay.config.php";
             include WEB_PATH . "conf/scripts/script.config.php";
             require_once WEB_PATH . "crontab/scripts.comm.php";
             require_once WEB_PATH_LIB_SCRIPTS_EBAY . "ebay_order_cron_func.php";
             $rmq_config = C("RMQ_CONFIG");
             //echo "<pre>"; var_dump($rmq_config); exit;
             $rabbitMQClass = new RabbitMQClass($rmq_config['fetchOrder'][1], $rmq_config['fetchOrder'][2], $rmq_config['fetchOrder'][4], $rmq_config['fetchOrder'][0]);
             //队列对象
             include WEB_PATH . "lib/sdk/ebay/GetCertainOrder.php";
             require_once WEB_PATH . "lib/PHPExcel.php";
             if (isset($_FILES) && !empty($_FILES['ebay_id']['tmp_name'])) {
                 $ftype1 = $_FILES['ebay_id']['type'];
                 $tmp_name = $_FILES['ebay_id']['tmp_name'];
                 $fsize = $_FILES['ebay_id']['size'];
                 define("MAX_UPLOAD_SIZE", 128 * 1024 * 1024);
                 if ($fsize <= MAX_UPLOAD_SIZE) {
                     //判断文件头2字节
                     $allow_excel_type = array('application/vnd.ms-excel', 'application/octet-stream', 'text/comma-separated-values', 'application/ww-plugin', 'application/npalicdo', 'application/qscall-plugin', 'application/octet-stream', 'text/csv');
                     $allow_excel_ftypecode = array('8397', '349', '983');
                     //csv
                     $f = fopen($tmp_name, 'rb');
                     $bin = fread($f, 2);
                     fclose($f);
                     $strInfo = @unpack('c2chars', $bin);
                     $ftype2 = intval($strInfo['chars1'] . $strInfo['chars2']);
                     if (in_array($ftype1, $allow_excel_type) && in_array($ftype2, $allow_excel_ftypecode)) {
                         $upload_fname = $_FILES['ebay_id']['name'];
                         $ext = 'csv';
                         $f_order = fopen($tmp_name, 'r');
                         $EXCEL_ROW_CNT = 0;
                         $excel_order_cnt = 0;
                         $OrderMatch = array();
                         $OrderMissed = array();
                         //漏单
                         $OrderIDWrong = array();
                         //excel中订单号格式不对
                         $OrderDuplicate = array();
                         //重复的订单号
                         $OrderException = array();
                         //异常订单
                         while ($order_line = fgetcsv($f_order, 1024, ',')) {
                             if ($EXCEL_ROW_CNT == 0) {
                                 $EXCEL_ROW_CNT++;
                                 continue;
                                 //ignore the first line
                             }
                             $ebay_recordnumber = $order_line[0];
                             $ebay_orderid = scientific_convert_digital(trim($order_line[1]));
                             $ebay_itemid = scientific_convert_digital(trim($order_line[2]));
                             $ebay_tranid = scientific_convert_digital(trim($order_line[3]));
                             $EXCEL_ROW_CNT++;
                             $order_line = NULL;
                             unset($order_line);
                             if (empty($ebay_orderid)) {
                                 //column orderid is empty
                                 if (preg_match('#^\\d{12}$#i', $ebay_itemid) && (preg_match('#^\\d{12,14}$#i', $ebay_tranid) || $ebay_tranid == '0')) {
                                     $ebay_orderid = $ebay_itemid . '-' . $ebay_tranid;
                                 } else {
                                     //echo "$ebay_recordnumber 不满足生成orderid的条件,请检查itemid(要求12位),tranid要求(12-14位)<br>";
                                     continue;
                                 }
                             } else {
                                 //wrong format orderid
                                 if (!preg_match('#^\\d{12}$#i', $ebay_orderid)) {
                                     continue;
                                 }
                                 //if all the 3 columns has value,then this is one transaction of a multiple line item order
                                 if (!empty($ebay_itemid) && !empty($ebay_tranid) && !empty($ebay_orderid)) {
                                     continue;
                                 }
                             }
                             $order_info = array('record_no' => $ebay_recordnumber, 'order_id' => $ebay_orderid);
                             $compare_res = fetchEbayOrderModel::checkEbayOrder($ebay_orderid, $ebay_recordnumber, $accountId);
                             //echo "sdg";
                             if ($compare_res == '001') {
                                 $OrderIDWrong[] = $order_info;
                             } else {
                                 if ($compare_res == '002') {
                                     $OrderMissed[] = $order_info;
                                 } else {
                                     if ($compare_res == '100' || $compare_res == '003') {
                                         $OrderDuplicate[] = $order_info;
                                     } else {
                                         if ($compare_res === FALSE) {
                                             $OrderException[] = $order_info;
                                         } else {
                                             //$OrderMatch[]=$order_info;
                                         }
                                     }
                                 }
                             }
                         }
                         fclose($f_order);
                         if (count($OrderIDWrong) != 0) {
                             $message .= "<br><font >以下订单格式错误</font><br>";
                             $i = 0;
                             foreach ($OrderIDWrong as $k => $v) {
                                 $message .= "&nbsp;<font color='red'>{$v['record_no']}</font>&nbsp;";
                                 if ($i >= 3) {
                                     $message .= "<br>";
                                     $i = 0;
                                 }
                                 $i++;
                             }
                         }
                         if (count($OrderMissed) != 0) {
                             $message .= "<br><font>以下为漏单情况</font><br>";
                             $i = 0;
                             foreach ($OrderMissed as $k => $v) {
                                 //$message .= "&nbsp;<font color='red'>{$v['order_id']}</font>&nbsp;";
                                 $message .= "<font color='green'>{$v['order_id']}</font><br>";
                                 /*if($i>=3){
                                 			$message .= "<br>";
                                 			$i = 0;
                                 		}
                                 		$i++;*/
                             }
                         }
                         if (count($OrderDuplicate) != 0) {
                             $message .= "<br><font>以下为重复订单</font><br>";
                             $i = 0;
                             foreach ($OrderDuplicate as $k => $v) {
                                 $message .= "&nbsp;<font color='red'>{$v['record_no']}</font>&nbsp;";
                                 if ($i >= 3) {
                                     $message .= "<br>";
                                     $i = 0;
                                 }
                                 $i++;
                             }
                         }
                         if (count($OrderException) != 0) {
                             $message .= "<br><font >以下为异常订单</font><br>";
                             $i = 0;
                             foreach ($OrderException as $k => $v) {
                                 $message .= "&nbsp;<font color='red'>{$v['record_no']}</font>&nbsp;";
                                 if ($i >= 3) {
                                     $message .= "<br>";
                                     $i = 0;
                                 }
                                 $i++;
                             }
                         }
                     } else {
                         $message .= "[{$ftype1}][{$ftype2}]此处只能上传CSV文件!!!<br/>";
                     }
                 } else {
                     $message .= '你上传的文件有' . $fsize / (1024 * 1024) . 'M,已超过限制' . MAX_UPLOAD_SIZE / (1024 * 1024) . 'M!';
                 }
             }
             //$ebay_id = isset($_POST['ebay_id'])?$_POST['ebay_id']:"";
             $tip = false;
             //echo "<pre>"; print_r($OrderMissed); exit;
             if (count($OrderMissed) == 0) {
                 $message .= "<font color='green'>没有漏单</font><br>";
                 echo $message;
                 exit;
             } else {
                 $ebay_ids = array();
                 foreach ($OrderMissed as $k => $v) {
                     $where = "where orderId='{$v['order_id']}'";
                     //echo $where;
                     $msg = OmAvailableModel::getTNameList("om_unshipped_order_extension_ebay", "*", $where);
                     //print_r($msg);
                     if ($msg) {
                         $message .= "<font color='red'>订单{$id}已存在!</font><br>";
                         continue;
                     }
                     $ebay_ids[] = $v['order_id'];
                 }
                 if (empty($ebay_ids)) {
                     $message .= "<font color='green'>不存在漏单</font><br>";
                 } else {
                     //echo "<pre>"; print_r($ebay_ids); exit;
                     //$ebay_ids = explode(",",$ebay_id);
                     $api_gco = new GetCertainOrderAPI($account);
                     //ob_start();
                     $api_gco->GetCertainOrder($account, $ebay_ids);
                     //监听获取队列信息
                     //ob_end_clean();
                 }
                 /*foreach($ebay_ids as $key=>$id){
                 			$where = "where orderId='{$id}'";
                 			//echo $where;
                 			$msg = OmAvailableModel::getTNameList("om_unshipped_order_extension_ebay","*",$where);
                 			//print_r($msg);
                 			if($msg){
                 				$message .= "<font color='red'>订单{$id}已存在!</font><br>";
                 				continue;
                 			}
                 			$info = $ebay_api->push_ebay_orderid_queue($id,$account,$rabbitMQClass);
                 			$tip=true;
                 		}*/
                 //$info = $ebay_api->
             }
             //ob_start();
             //$message = fetchEbayOrderModel::addOrder($account);
             //ob_end_clean();
             //echo fetchEbayOrderModel::$errMsg;
         } elseif ($addorder == "amazon") {
             $fetch_amazon_order = new fetchAmazonOrderAct();
             $aliexpressmessage = $fetch_amazon_order->act_fetchOrder();
             //header("Location:index.php?mod=missingOrderAdd&act=addMissingOrder&aliexpressmessage={$aliexpressmessage}");
         }
     }
     //print_r($ebayAccountList);
     $this->smarty->assign("ebayAccountList", $ebayAccountList);
     $this->smarty->assign("amazonAccountList", $amazonAccountList);
     $this->smarty->assign('message', $message);
     $this->smarty->assign('aliexpressmessage', $aliexpressmessage);
     $this->smarty->assign('toptitle', '漏单添加');
     $this->smarty->assign('toplevel', 2);
     $this->smarty->assign('secondlevel', '280');
     $this->smarty->display("missingOrderAdd.htm");
 }