/** * 标记订单是否包括海外仓料号,0为国内订单、1为包含海外料号和国内料号订单、2为美国A仓订单(先考虑手动拆分,如果业务部门OK考虑自动拆分) * 预留数字3、4、5、6.....扩展到多个海外仓订单 * 该功能关联到后面的缺货拦截和超大订单拦截 */ public function MarkOverSeaOrder() { $contain_os_item = false; //$ow_status = array(); $allskuinfo = array(); $orderDetail = $this->orderData['detail']; foreach ($orderDetail as $detail) { $sku = $detail['base']['sku']; $skuinfo = M("InterfacePc")->getSkuinfo($sku); foreach ($skuinfo['skuInfo'] as $or_sku => $skuinfoDetailValue) { $amount = $skuinfoDetailValue['amount']; $or_sku = $skuinfoDetailValue['skuDetail']['sku']; $allskuinfo[] = $or_sku; if (preg_match("/^US01\\+.*/", $or_sku, $matchArr) || preg_match("/^US1\\+.*/", $or_sku, $matchArr)) { //$log_data .= "[".date("Y-m-d H:i:s")."]\t包含海外仓料号订单---{$ebay_id}-----料号:{$or_sku}--!\n\n"; $contain_os_item = true; if (strpos($or_sku, "US01+") !== false) { $matchStr = substr($matchArr[0], 5); //去除前面 //$matchStr = str_replace("US1+", "", $or_sku); } else { //$matchStr=substr($matchArr[0],5);//去除前面 $matchStr = str_replace("US1+", "", $or_sku); } $n = strpos($matchStr, ':'); //寻找位置 if ($n) { $matchStr = substr($matchStr, 0, $n); } //删除后面 if (preg_match("/^0+(\\w+)/", $matchStr, $matchArr)) { $matchStr = $matchArr[1]; } $sql = "update ebay_orderdetail set sku ='{$matchStr}' where ebay_id = {$orderdetail['ebay_id']} "; //add by Herman.Xi 替换海外仓料号为正确料号 $dbcon->execute($sql); $virtualnum = check_oversea_stock($matchStr); //检查海外仓虚拟库存 预留接口 //insert_mark_shipping($ebay_id); /*if($virtualnum >= 0){ $ow_status[] = 705; }else{ $ow_status[] = 714; //海外仓缺货 }*/ } /*if(!$contain_os_item && empty($ebay_note) && $totalweight <=2){ //如果不是海外仓的,就去检查是否为B仓的料号 $location = get_sku_location($or_sku); if(strpos($location,'WH') === 0 || strpos($location,'HW') === 0){ $contain_wh_item = true; } }*/ } } if ($contain_os_item) { //$orderType = C('STATEPENDING_OVERSEA'); //$log_data .= "[".date("Y-m-d H:i:s")."]\t更新海外仓料号订单状态为{$orderType}---{$ebay_id}--{$sql}-!\n\n"; //if($orderType == 705){ $totalweight = calcWeight($ebay_id); //预留接口 $skunums = checkSkuNum($ebay_id); //预留接口 if ($skunums === true) { continue; } else { if ($totalweight > 20) { if ($skunums == 1) { usCalcShipCost($ebay_id); //预留接口 } } else { usCalcShipCost($ebay_id); //预留接口 } } //} return $orderType = C('STATEPENDING_OVERSEA'); } return false; }
function auto_contrast_intercept($ebay_orders) { //订单自动拦截完整版 支持虚拟料号 //add Herman.Xi 2012-12-20 /* * 订单进入系统首先判断 是否为超大订单,如果为超大订单,文件夹为640; * 判断订单下,料号是否全部有货,部分有货,全部没货: 如果部分有货,判断其运输方式,如果为快递,文件夹为659;非快递则为660;(订单自动部分包货) 如果全部没货,判断其运输方式,如果为快递,文件夹为658;非快递则为661;(订单自动拦截) 如果全部有货: 先判断如果为组合订单,文件夹为606; 如果超重订单,文件夹为608; 如果快递订单,文件夹为639; 全部不满足则为导入状态 自动拦截时,判断自动拦截快递,非快递,自动部分包货快递,非快递里面的订单,自动每隔十五分钟执行一次 添加缺货和合并包裹缺货处理 增加俄速通运输方式 - 俄罗斯 add by zhiqiang.chen */ global $dbcon, $defaultstoreid, $order_statistics, $SYSTEM_ACCOUNTS, $__liquid_items_fenmocsku, $__liquid_items_BuiltinBattery, $__liquid_items_SuperSpecific, $__liquid_items_Paste, $__liquid_items_postbyhkpost, $__liquid_items_cptohkpost, $__liquid_items_Wristwatch, $__liquid_items_TempModifySZ, $__liquid_items_TempModifyRU; //$__liquid_items_TempIntercept = get_TempIntercept(4); $express_delivery = array('UPS', 'DHL', 'TNT', 'EMS', 'FedEx'); $no_express_delivery = array('中国邮政平邮', '中国邮政挂号', '香港小包平邮', '香港小包挂号', '德国邮政挂号', '新加坡小包挂号', 'EUB', 'Global Mail', '俄速通平邮', '俄速通挂号'); mysql_ping(); foreach ($ebay_orders as $ebay_order) { /*if(!$dbcon->link){ include_once 'config_row/config_database_row_master.php'; unset($dbcon); $dbcon = new DBClass(); }*/ $contain_DGMPY = false; $contain_DGMGH = false; $log_data = ""; $ebay_total0 = 0; //该订单实际总数 //$import_status = now_order_status_log($osn, false); $ebay_id = $ebay_order['ebay_id']; $order_sn = $ebay_order['ebay_ordersn']; $ebay_status = $ebay_order['ebay_status']; $ebay_note = $ebay_order['ebay_note']; $ebay_carrier = @$ebay_order['ebay_carrier']; $ebay_countryname = $ebay_order['ebay_countryname']; $ebay_account = $ebay_order['ebay_account']; $ebay_total = $ebay_order['ebay_total']; $ebay_username = $ebay_order['ebay_username']; $ebay_orderid = $ebay_order['ebay_orderid']; $ebay_usermail = $ebay_order['ebay_usermail']; $PayPalEmailAddress = @$ebay_order['PayPalEmailAddress']; $shipfee = @$ebay_order['ordershipfee']; $ebay_street = $ebay_order['ebay_street']; $ebay_postcode = $ebay_order['ebay_postcode']; $ebay_state = $ebay_order['ebay_state']; $ebay_city = $ebay_order['ebay_city']; $ebay_phone = $ebay_order['ebay_phone']; $ebay_phone1 = $ebay_order['ebay_phone1']; echo "------ebayid:{$ebay_id}----{$ebay_countryname}-----\n"; echo "订单号:{$order_sn}\t\n"; $sql = "SELECT ebay_id,sku,ebay_amount,ebay_itemprice,shipingfee FROM ebay_orderdetail WHERE ebay_ordersn='{$order_sn}'"; $result = $dbcon->execute($sql); $orderdetaillist = $dbcon->getResultArray($result); if (in_array($ebay_account, array('edealsmart', 'eshoppingstar75', 'easyshopping095', 'beromantic520', 'happyforu19', 'ishoppingclub68', 'lantomall', 'estore2099'))) { //海外仓订单同步调试 var_dump($orderdetaillist); } $contain_special_item = false; $contain_sz_item = false; $contain_os_item = false; $contain_wh_item = false; $contain_hold131103 = false; //add by herman.xi @20131103 $ow_status = array(); $allskuinfo = array(); foreach ($orderdetaillist as $orderdetail) { $sku_arr = get_realskuinfo($orderdetail['sku']); $ebay_total0 += $orderdetail['ebay_itemprice'] * $orderdetail['ebay_amount'] + $orderdetail['shipingfee']; foreach ($sku_arr as $or_sku => $or_nums) { $allskuinfo[] = $or_sku; //if(in_array($or_sku,$__liquid_items_fenmocsku) || in_array($or_sku,$__liquid_items_SuperSpecific) || in_array($or_sku,$__liquid_items_BuiltinBattery)){ //粉末状,超规格产品 走福建邮局 if (in_array($or_sku, $__liquid_items_SuperSpecific)) { //超规格产品 $contain_special_item = true; } if (in_array($or_sku, $__liquid_items_TempModifySZ)) { $contain_sz_item = true; } if (preg_match("/^US01\\+.*/", $or_sku, $matchArr) || preg_match("/^US1\\+.*/", $or_sku, $matchArr)) { $log_data .= "[" . date("Y-m-d H:i:s") . "]\t包含海外仓料号订单---{$ebay_id}-----料号:{$or_sku}--!\n\n"; $contain_os_item = true; if (strpos($or_sku, "US01+") !== false) { $matchStr = substr($matchArr[0], 5); //去除前面 //$matchStr = str_replace("US1+", "", $or_sku); } else { //$matchStr=substr($matchArr[0],5);//去除前面 $matchStr = str_replace("US1+", "", $or_sku); } $n = strpos($matchStr, ':'); //寻找位置 if ($n) { $matchStr = substr($matchStr, 0, $n); } //删除后面 if (preg_match("/^0+(\\w+)/", $matchStr, $matchArr)) { $matchStr = $matchArr[1]; } echo $sql = "update ebay_orderdetail set sku ='{$matchStr}' where ebay_id = {$orderdetail['ebay_id']} "; //add by Herman.Xi 替换海外仓料号为正确料号 echo "\n"; $dbcon->execute($sql); $virtualnum = check_oversea_stock($matchStr); //检查海外仓虚拟库存 echo $virtualnum; echo "\n"; insert_mark_shipping($ebay_id); if ($virtualnum >= 0) { $ow_status[] = 705; } else { $ow_status[] = 714; //海外仓缺货 } } /*if(!$contain_os_item && empty($ebay_note) && $totalweight <=2){ //如果不是海外仓的,就去检查是否为B仓的料号 $location = get_sku_location($or_sku); if(strpos($location,'WH') === 0 || strpos($location,'HW') === 0){ $contain_wh_item = true; } }*/ } } /*if(in_array($ebay_account, array('edealsmart','eshoppingstar75','easyshopping095','beromantic520','happyforu19','ishoppingclub68','lantomall','estore2099'))){ //海外仓订单同步调试 var_dump($ow_status,$contain_os_item); }*/ #################################START################################################## $array_intersect_zhijiayou = array_intersect($allskuinfo, $__liquid_items_cptohkpost); $array_intersect_yieti = array_intersect($allskuinfo, $__liquid_items_postbyhkpost); $array_intersect_fenmocsku = array_intersect($allskuinfo, $__liquid_items_fenmocsku); $array_intersect_BuiltinBattery = array_intersect($allskuinfo, $__liquid_items_BuiltinBattery); $array_intersect_Paste = array_intersect($allskuinfo, $__liquid_items_Paste); $array_intersect_Wristwatch = array_intersect($allskuinfo, $__liquid_items_Wristwatch); //add by Herman.Xi @ 20131103 $array_intersect_TempModifyRU = array_intersect($allskuinfo, $__liquid_items_TempModifyRU); //$array_intersect_TempIntercept = array_intersect($allskuinfo, $__liquid_items_TempIntercept);//add by Herman.Xi @ 20131105 /*if(count($array_intersect_zhijiayou) > 0 || count($array_intersect_yieti) > 0 || count($array_intersect_fenmocsku) > 0 || count($array_intersect_Paste) > 0 || (count($array_intersect_BuiltinBattery) > 0 && count($array_intersect_Wristwatch) == 0)){ if(count($array_intersect_TempIntercept) > 0){*/ if (count($array_intersect_zhijiayou) > 0 || count($array_intersect_yieti) > 0 || count($array_intersect_fenmocsku) > 0 || count($array_intersect_Paste) > 0 || count($array_intersect_BuiltinBattery) > 0) { $contain_hold131103 = true; } #################################END################################################## if ($contain_special_item) { $sql = "update ebay_order set ebay_carrierstyle ='1' where ebay_id ={$ebay_id}"; //add by Herman.Xi 记录该订单含有特殊料号 $dbcon->execute($sql); $log_data .= "[" . date("Y-m-d H:i:s") . "]\t包含粉末状超规格产品---{$ebay_id}---!\n\n"; } if ($contain_sz_item) { $sql = "update ebay_order set ebay_carrierstyle ='4' where ebay_id ={$ebay_id}"; //add by Herman.Xi 记录该订单含有临时改深圳的料号 $dbcon->execute($sql); $log_data .= "[" . date("Y-m-d H:i:s") . "]\t记录该订单含有临时改深圳的料号---{$ebay_id}---!\n\n"; } if ($contain_os_item) { $final_status = 705; echo $sql = "update ebay_order set ebay_status ='{$final_status}' where ebay_id ={$ebay_id} and ebay_status = '{$ebay_status}'"; //add by Herman.Xi 记录该订单含有海外仓料号 20130927 echo "\n"; $dbcon->execute($sql); $log_data .= "[" . date("Y-m-d H:i:s") . "]\t更新海外仓料号订单状态为{$final_status}---{$ebay_id}--{$sql}-!\n\n"; if ($final_status == 705) { $totalweight = calcWeight($ebay_id); echo "calcWeight=>" . $totalweight; echo "\n"; $skunums = checkSkuNum($ebay_id); echo "checkSkuNum=>" . $skunums; echo "\n"; if ($skunums === true) { continue; } else { if ($totalweight > 20) { if ($skunums == 1) { usCalcShipCost($ebay_id); echo "1_usCalcShipCost=>" . $skunums; echo "\n"; } } else { usCalcShipCost($ebay_id); echo "2_usCalcShipCost=>" . $skunums; echo "\n"; } } } $log_data .= "[" . date("Y-m-d H:i:s") . "]\t包含海外仓料号---自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); //$totalweight = recalcorderweight($order_sn, $ebay_packingmaterial); //modified by Herman.Xi 2012-10-17 unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } $totalweight = recalcorderweight($order_sn, $ebay_packingmaterial); //modified by Herman.Xi 2012-10-17 echo "计算重量:{$totalweight}\t\n"; echo "ebay_orderid:{$ebay_orderid}\t\n"; if (in_array($ebay_account, $SYSTEM_ACCOUNTS['亚马逊'])) { //非线下amazon账号订单 //ebay 平台可以重新计算运输方式 @ 20130301 if (empty($ebay_countryname)) { $ebay_carrier = ''; $shipfee = 0; echo "\n该订单的国家为空{$ebay_id}\n"; $final_status = 692; //移动到同步异常订单中 $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } } /*if(in_array($ebay_account,$SYSTEM_ACCOUNTS['cndirect'])){//CN暂时处理的单 if (in_array($ebay_usermail, array('*****@*****.**','*****@*****.**'))){ $final_status = 612;//移动到暂时不寄 $sql = "UPDATE ebay_order SET ebay_status='$final_status' WHERE ebay_id ='$ebay_id' and ebay_status = '{$ebay_status}' "; $log_data .= "[".date("Y-m-d H:i:s")."]\t自动跳转---{$ebay_id}---的状态为---$final_status!\n\n"; $dbcon->execute($sql) or die("Fail : $sql"); write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); continue; } }*/ $contain_eub = false; if ((in_array($ebay_account, $SYSTEM_ACCOUNTS['ebay平台']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['海外销售平台'])) && !empty($ebay_orderid)) { //非线下ebay账号订单 //ebay 平台可以重新计算运输方式 @ 20130301 if (empty($ebay_countryname)) { $ebay_carrier = ''; $shipfee = 0; echo "\n该订单的国家为空{$ebay_id}\n"; $final_status = 692; //移动到同步异常订单中 $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } else { $fees = calcshippingfee($totalweight, $ebay_countryname, $ebay_id, $ebay_account, $ebay_total); $ebay_carrier = $fees[0]; $shipfee = $fees[1]; if (empty($shipfee)) { $logfile = "/home/ebay_order_cronjob_logs/empty_shippfee/sync_order_" . date("Y-m-d") . ".log"; $emptyshippfee_log = "Date: " . date("Y-m-d H:i:s") . " 订单号 " . $ebay_id . " 计算重量 " . $totalweight . " 原运输方式 " . $ebay_carrier . " 原运费为空 大于UPS 运费 \n"; @file_put_contents($logfile, $emptyshippfee_log, FILE_APPEND); } $totalweight = isset($fees[2]) ? $fees[2] : $totalweight; echo "\n经计算 运费 {$shipfee} 重量 {$totalweight} 包装材料 {$ebay_packingmaterial}\n"; } $bb = "update ebay_order set ebay_carrier='{$ebay_carrier}',ordershipfee='{$shipfee}',\n\t\t\t\t\t\t orderweight ='{$totalweight}',packingtype ='{$ebay_packingmaterial}' \n\t\t\t\t where ebay_id ='{$ebay_id}' "; $dbcon->execute($bb); if ($ebay_total != $ebay_total0) { //var_dump($ebay_total); //var_dump($ebay_total0); $ebay_total0 = (string) $ebay_total0; //var_dump($ebay_total); //var_dump($ebay_total0); /*if($ebay_total != $ebay_total0){ echo "不相等"; echo "\n"; }*/ } if ($ebay_carrier == 'EUB' && empty($ebay_note)) { $contain_eub = true; } if ($ebay_carrier == '新加坡DHL GM平邮' && empty($ebay_note)) { $contain_DGMPY = true; } echo "[" . date("Y-m-d H:i:s") . "]\t总价记录---{$ebay_id}---系统总价{$ebay_total}---计算总价{$ebay_total0}\n"; if (in_array($ebay_usermail, array("", "Invalid Request")) && $ebay_carrier == 'EUB') { $final_status = 692; //移动到同步异常订单中 $sql = "UPDATE ebay_order SET ebay_status='{$final_status}',ebay_noteb = '未获取买家邮箱' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } else { if ($ebay_total != $ebay_total0 && $ebay_status == 1) { //ebay total 和单价数量不一致问题移动异常订单 $final_status = 692; //移动到同步异常订单中 $sql = "UPDATE ebay_order SET ebay_status='{$final_status}',ebay_noteb = '{$ebay_total}--{$ebay_total0}总价计算和单价相加不一致' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n{$sql}\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); $relation_sql = "insert into ebay_splitorder (recordnumber, main_order_id, split_order_id, mode, create_date) values ('{$ebay_id}', '{$ebay_id}', '{$ebay_id}', 7, '" . date("Y-m-d H:i:s") . "')"; $dbcon->execute($relation_sql); //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } else { if (!empty($PayPalEmailAddress) && !in_array(strtolower($PayPalEmailAddress), get_account_paypalemails($ebay_account)) && $ebay_status == 1) { $final_status = 696; //付款邮箱如果不在对应邮箱中 $sql = "UPDATE ebay_order SET ebay_status='{$final_status}',ebay_noteb = '{$PayPalEmailAddress}不属于该账号的收款邮箱,请确认!' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } } } } else { if (in_array($ebay_account, $SYSTEM_ACCOUNTS['dresslink']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['cndirect'])) { $shipfee = calctrueshippingfee($ebay_carrier, $totalweight, $ebay_countryname, $ebay_id); $bb = "update ebay_order set ordershipfee='{$shipfee}',orderweight ='{$totalweight}',packingtype ='{$ebay_packingmaterial}' where ebay_id ='{$ebay_id}' "; $dbcon->execute($bb); echo "\n经计算 独立商城 运费 {$shipfee} 重量 {$totalweight} 包装材料 {$ebay_packingmaterial}\n"; } } $judage_ups = true; if ((in_array($ebay_account, $SYSTEM_ACCOUNTS['ebay平台']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['海外销售平台'])) && $ebay_carrier == 'EUB') { $judage_ups = false; } if (in_array($ebay_account, $SYSTEM_ACCOUNTS['国内销售部'])) { $judage_ups = false; } if ((in_array($ebay_account, $SYSTEM_ACCOUNTS['dresslink']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['cndirect'])) && in_array($ebay_carrier, $express_delivery)) { $judage_ups = false; } $contain_ups = false; if ($judage_ups && !$contain_hold131103) { //特殊料号不走UPS @add by Herman.Xi 20140317 $containsku = polling_type_of_goods($allskuinfo); if ($containsku) { $oshipfee = calctrueshippingfee2($ebay_carrier, $totalweight, $ebay_countryname, $ebay_id); $UPSshipfee = calctrueshippingfee("UPS美国专线", $totalweight, $ebay_countryname, $ebay_id); if ($UPSshipfee < $oshipfee && !empty($UPSshipfee) && !empty($oshipfee)) { $bb = "update ebay_order set ordershipfee='{$UPSshipfee}',ebay_carrier ='UPS美国专线' where ebay_id ='{$ebay_id}' "; $dbcon->execute($bb); echo "\n经计算 UPS美国专线 运费 {$UPSshipfee} 重量 {$totalweight} \n"; $logfile = "/home/ebay_order_cronjob_logs/ups/sync_order_" . date("Y-m-d") . ".log"; $ups_log = "Date: " . date("Y-m-d H:i:s") . " 订单号 " . $ebay_id . " 计算重量 " . $totalweight . " 原运输方式 " . $ebay_carrier . " 原运费 " . $oshipfee . " 大于UPS 运费 " . $UPSshipfee . " 选择走UPS \n"; @file_put_contents($logfile, $ups_log, FILE_APPEND); $contain_ups = true; } } } if (in_array($ebay_account, $SYSTEM_ACCOUNTS['dresslink']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['cndirect'])) { if (in_array($ebay_countryname, array('United States', 'US')) && $ebay_carrier == '中国邮政挂号') { $oshipfee = calctrueshippingfee2($ebay_carrier, $totalweight, $ebay_countryname, $ebay_id); $EUBshipfee = calctrueshippingfee("EUB", $totalweight, $ebay_countryname, $ebay_id); if ($EUBshipfee < $oshipfee && !empty($EUBshipfee) && !empty($oshipfee)) { $bb = "update ebay_order set ordershipfee='{$EUBshipfee}',ebay_carrier ='EUB' where ebay_id ='{$ebay_id}' "; $dbcon->execute($bb); echo "\n经计算 EUB 运费 {$EUBshipfee} 重量 {$totalweight} \n"; $logfile = "/home/ebay_order_cronjob_logs/ups/eub_order_" . date("Y-m-d") . ".log"; $ups_log = "Date: " . date("Y-m-d H:i:s") . " 订单号 " . $ebay_id . " 计算重量 " . $totalweight . " 原运输方式 " . $ebay_carrier . " 原运费 " . $oshipfee . " 大于EUB 运费 " . $EUBshipfee . " 选择走EUB \n"; @file_put_contents($logfile, $ups_log, FILE_APPEND); if (empty($ebay_note)) { $contain_eub = true; } } } } //增加俄速通运输方式,跟邮政运输方式做比较,选择最优。目前国内销售平台暂时未用 $contain_xru_track = false; $contain_xru_notrack = false; $xru_compare = true; if (empty($ebay_street) || empty($ebay_username) || empty($ebay_state) || empty($ebay_city) || $ebay_phone == '' && $ebay_phone1 == '' && strtolower($ebay_phone) == 'invalid request' || $ebay_postcode == '' && $ebay_postcode == 'none') { $xru_compare = false; } if (!in_array($ebay_account, $SYSTEM_ACCOUNTS['国内销售部']) && in_array($ebay_countryname, array('Russische Föderation', 'Russie', 'Russian Federation', 'Russian', 'Russia', 'Russian Federatuon'))) { //服装配饰及鞋子箱包类且总价在200以下 //$is_contain = polling_type_of_goods($allskuinfo,array(1,2)); if ($ebay_total <= 200 && count($array_intersect_TempModifyRU) == 0 && $totalweight <= 2 && empty($ebay_note) && ($xru_compare && strlen($ebay_username) < 45 && strlen($ebay_postcode) == 6)) { if ($ebay_carrier == '中国邮政平邮' || $ebay_carrier == '中国邮政挂号') { $oshipfee = calctrueshippingfee2($ebay_carrier, $totalweight, $ebay_countryname, $ebay_id); //调用开放借口获得固定运输方式的运费 $XRU_carrier = '俄速通挂号'; if ($ebay_carrier == '中国邮政平邮') { $XRU_carrier = '俄速通平邮'; } $XRUshipfee = trans_carriers_fix_get($XRU_carrier, $totalweight, $ebay_countryname); $XRUshipfee = $XRUshipfee['fee']; if ($XRUshipfee && !empty($oshipfee) && $XRUshipfee < $oshipfee) { $sql = "UPDATE ebay_order SET ordershipfee = '{$XRUshipfee}', ebay_carrier = '{$XRU_carrier}' WHERE ebay_id = '{$ebay_id}' "; $dbcon->execute($sql); echo "\n经计算 {$XRU_carrier} 运费 {$XRUshipfee} 重量 {$totalweight} \n"; $logfile = "/home/ebay_order_cronjob_logs/ups/xru_order_" . date("Y-m-d") . ".log"; $xru_log = "Date: " . date("Y-m-d H:i:s") . " 订单号 " . $ebay_id . " 计算重量 " . $totalweight . " 原运输方式 " . $ebay_carrier . " 原运费 " . $oshipfee . " 大于 " . $XRU_carrier . " 运费 " . $XRUshipfee . " 选择走" . $XRU_carrier . " \n"; @file_put_contents($logfile, $xru_log, FILE_APPEND); if ($XRU_carrier == '俄速通挂号') { $contain_xru_track = true; } else { if ($XRU_carrier == '俄速通平邮') { $contain_xru_notrack = true; } } } } } } //增加瑞士小包 $contain_swtch_track = false; if (strpos($ebay_carrier, '瑞士小包') !== false) { $contain_swtch_track = true; } if (empty($ebay_note) && $ebay_status == 1 && count($allskuinfo) == 1 && $xru_compare && !in_array($ebay_account, $SYSTEM_ACCOUNTS['国内销售部']) && in_array($ebay_carrier, array('香港小包挂号', '新加坡小包挂号', '中国邮政挂号'))) { if ((in_array($ebay_account, $SYSTEM_ACCOUNTS['ebay平台']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['海外销售平台'])) && in_array($ebay_countryname, array('USA', 'United States'))) { } else { //if(count($array_intersect_zhijiayou) == 0 && count($array_intersect_yieti) == 0 && count($array_intersect_fenmocsku) == 0 && count($array_intersect_Paste) == 0 && count($array_intersect_BuiltinBattery) > 0){ $oshipfee = calctrueshippingfee2($ebay_carrier, $totalweight, $ebay_countryname, $ebay_id); //调用开放借口获得固定运输方式的运费 //if(strpos($ebay_carrier,'挂号') !== false){ $XRU_carrier = '瑞士小包挂号'; //}else{ // $XRU_carrier = '瑞士小包平邮'; // } $XRUshipfee = trans_carriers_fix_get($XRU_carrier, $totalweight, $ebay_countryname); $XRUshipfee = $XRUshipfee['fee']; $logfile = "/home/ebay_order_cronjob_logs/ups/switch_order_test_" . date("Y-m-d") . ".log"; $xru_log = "ebay: Date: " . date("Y-m-d H:i:s") . " 订单号 " . $ebay_id . " 计算重量 " . $totalweight . " 原运输方式 " . $ebay_carrier . " 原运费 " . $oshipfee . " 对比运输方式 " . $XRU_carrier . " 运费 " . $XRUshipfee . " \n"; @file_put_contents($logfile, $xru_log, FILE_APPEND); if ($XRUshipfee && !empty($oshipfee) && $XRUshipfee < $oshipfee) { $sql = "UPDATE ebay_order SET ordershipfee = '{$XRUshipfee}', ebay_carrier = '{$XRU_carrier}' WHERE ebay_id = '{$ebay_id}' "; $dbcon->execute($sql); echo "\n经计算 {$XRU_carrier} 运费 {$XRUshipfee} 重量 {$totalweight} \n"; $logfile = "/home/ebay_order_cronjob_logs/ups/switch_order_" . date("Y-m-d") . ".log"; $xru_log = "Date: " . date("Y-m-d H:i:s") . " 订单号 " . $ebay_id . " 计算重量 " . $totalweight . " 原运输方式 " . $ebay_carrier . " 原运费 " . $oshipfee . " 大于 " . $XRU_carrier . " 运费 " . $XRUshipfee . " 选择走" . $XRU_carrier . " \n"; @file_put_contents($logfile, $xru_log, FILE_APPEND); $contain_swtch_track = true; } //} } } if (in_array($ebay_status, array('614', '637', '658', '661', '660', '659'))) { //ebay 线上订单EUB大于5天,平邮和挂号大于7天不发货,不包括快递 //海外销售十天 $timeout = false; $ebay_orderid = isset($ebay_order['ebay_orderid']) ? $ebay_order['ebay_orderid'] : ''; $ebay_paidtime = isset($ebay_order['ebay_paidtime']) ? $ebay_order['ebay_paidtime'] : ''; if (!empty($ebay_paidtime)) { //线上订单,付款时间不能为空 $diff_time = ceil((time() - $ebay_paidtime) / (3600 * 24)); if (in_array($ebay_account, $SYSTEM_ACCOUNTS['ebay平台']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['海外销售平台']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['dresslink']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['cndirect'])) { if ($ebay_carrier == 'EUB' && $diff_time > 7) { $timeout = true; } else { if ((strpos($ebay_carrier, '平邮') !== false || strpos($ebay_carrier, '挂号') !== false) && $diff_time > 7) { $timeout = true; } else { if ($ebay_carrier == 'Global Mail' && $diff_time > 10) { $timeout = true; } } } } else { if (in_array($ebay_account, $SYSTEM_ACCOUNTS['亚马逊'])) { if ($diff_time > 7) { $timeout = true; } } } /*else if(in_array($ebay_account,$SYSTEM_ACCOUNTS['海外销售平台'])){ if((strpos($ebay_carrier, '中国邮政平邮')!==false && $diff_time > 5) || $diff_time > 10){ $timeout = true; } }*/ } if ($timeout) { $log_data .= "\n缺货订单={$ebay_id}======移动到缺货需退款中======\n"; $final_status = 617; //移动到缺货需退款中 $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); //$order_statistics->replaceData($order_sn, array('mask'=>1), array('mask'=>1)); //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } } if (in_array($ebay_status, array('614', '637'))) { //缺货处理\合并包裹处理 $have_goodscount = true; foreach ($orderdetaillist as $orderdetail) { $sku_arr = get_realskuinfo($orderdetail['sku']); foreach ($sku_arr as $or_sku => $or_nums) { $allnums = $or_nums * $orderdetail['ebay_amount']; $skuinfo = get_sku_info($or_sku); $salensend = getpartsaleandnosendall($or_sku, $defaultstoreid); $sql = "UPDATE ebay_sku_statistics SET salensend = {$salensend} WHERE sku = '{$or_sku}' "; $dbcon->execute($sql); $log_data .= "[" . date("Y-m-d H:i:s") . "]\t---{$sql}\n\n"; $log_data .= "订单==={$ebay_id}===料号=={$or_sku}===实际库存为{$skuinfo['realnums']}===B仓库库存为{$skuinfo['secondCount']}===需求量为{$allnums}===待发货数量为{$salensend}===\n"; $realnums = isset($skuinfo['realnums']) ? $skuinfo['realnums'] : 0; $secondCount = isset($skuinfo['secondCount']) ? $skuinfo['secondCount'] : 0; if (in_array($ebay_status, array('658', '661', '660', '659'))) { $remainNum = $realnums + $secondCount - $allnums - $salensend; } else { $remainNum = $realnums + $secondCount - $salensend; } if ($remainNum < 0) { //if((!isset($skuinfo['realnums']) && !isset($skuinfo['secondCount'])) || ((($skuinfo['realnums']+$skuinfo['secondCount']) - $allnums - $salensend) < 0)){//缺货本身算待发货,不能重复扣除 $have_goodscount = false; break; } } } if ($have_goodscount) { $log_data .= "\n缺货订单={$ebay_id}======有货至待打印======\n"; $final_status = 618; $anomalous_sql = "SELECT count(*) as anomalous_num FROM ebay_splitorder WHERE split_order_id = '{$ebay_id}' AND mode = 2"; $anomalous_sql = $dbcon->execute($anomalous_sql); $anomalous_sql = $dbcon->fetch_one($anomalous_sql); if ($anomalous_sql['anomalous_num'] != 0) { $final_status = 686; //调到异常缺货需打印 add by chenwei 2013.3.27 } /*if($contain_wh_item && in_array($ebay_carrier,$no_express_delivery)){ $final_status = 712; }else */ if ($contain_ups) { $final_status = 731; } else { if ($contain_xru_track) { // add by zhiqiang.chen 2014-5-2 $final_status = 743; //俄速通小包挂号 } else { if ($contain_xru_notrack) { $final_status = 744; //俄速通小包平邮 } else { if ($contain_eub) { $final_status = 725; //移到EUB跟踪号申请异常订单 } else { if ($contain_swtch_track) { $final_status = 750; } else { if ($contain_DGMPY) { $final_status = 745; //移到新加坡DGM } } } } } } $stock_sql = "SELECT nums FROM repeat_stock_statistics WHERE ebay_id = '{$ebay_id}' "; $stock_sql = $dbcon->execute($stock_sql); $stock_sql = $dbcon->fetch_one($stock_sql); if (!isset($stock_sql['nums'])) { $stock_data = array('ebay_id' => $ebay_id, 'nums' => 1, 'startTime' => time()); $sql = "INSERT INTO repeat_stock_statistics SET " . array2sql($stock_data); $dbcon->execute($sql); } else { if ($stock_sql['nums'] <= 2) { $stock_data = array('nums' => $stock_sql['nums'] + 1, 'endTime' => time()); $sql = "UPDATE repeat_stock_statistics SET " . array2sql($stock_data) . " WHERE ebay_id = " . $ebay_id; $dbcon->execute($sql); } else { $final_status = 735; $stock_data = array('nums' => 0, 'startTime' => 0, 'endTime' => 0); $sql = "UPDATE repeat_stock_statistics SET " . array2sql($stock_data) . " WHERE ebay_id = " . $ebay_id; $dbcon->execute($sql); } } //缺货需打印 $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); //$order_statistics->replaceData($order_sn, array('mask'=>1), array('mask'=>1)); //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); unset($stock_data); continue; } } else { $record_details = array(); $is_640 = false; $is_no_location = false; foreach ($orderdetaillist as $orderdetail) { $sku_arr = get_realskuinfo($orderdetail['sku']); $hava_goodscount = true; /***筛选订单中的超大订单料号 Start ***/ foreach ($sku_arr as $t_sku => $t_num) { $t_allnums = $t_num * $orderdetail['ebay_amount']; if (!check_sku($t_sku, $t_allnums)) { $bigSkuPath = '/home/html_include/exportfile/bigOrderSkuLog/' . date('Y-m-d') . '.txt'; $bigSkuLog = '主订单号' . $ebay_id . '细订单号' . $orderdetail['ebay_id'] . '料号' . $t_sku . '订单数量' . $t_allnums . "\r\n"; writeBigOrderSkuLog($bigSkuPath, $bigSkuLog); //日志记录 addBigOrderSkuLog($ebay_id, $orderdetail['ebay_id'], $t_sku, $t_allnums); //添加超大订单料号日志 add by wangminwei 2014-04-16 } } /***筛选订单中的超大订单料号 End ***/ foreach ($sku_arr as $or_sku => $or_nums) { $allnums = $or_nums * $orderdetail['ebay_amount']; if (!check_sku($or_sku, $allnums)) { //超大订单状态 $sql = "UPDATE ebay_order SET ebay_status='640' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---640!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); //$order_statistics->replaceData($order_sn, array('mask'=>1), array('mask'=>1)); insert_mark_shipping($ebay_id); $is_640 = true; break; } else { $skuinfo = get_sku_info($or_sku); if (empty($skuinfo['goods_location'])) { $is_no_location = true; } $salensend = getpartsaleandnosendall($or_sku, $defaultstoreid); $sql = "UPDATE ebay_sku_statistics SET salensend = {$salensend} WHERE sku = '{$or_sku}' "; $dbcon->execute($sql); $log_data .= "[" . date("Y-m-d H:i:s") . "]\t---{$sql}\n\n"; $log_data .= "订单==={$ebay_id}===料号=={$or_sku}===实际库存为{$skuinfo['realnums']}===B仓库库存为{$skuinfo['secondCount']}===需求量为{$allnums}===待发货数量为{$salensend}===\n"; $realnums = isset($skuinfo['realnums']) ? $skuinfo['realnums'] : 0; $secondCount = isset($skuinfo['secondCount']) ? $skuinfo['secondCount'] : 0; if (in_array($ebay_status, array('658', '661', '660', '659'))) { $remainNum = $realnums + $secondCount - $allnums - $salensend; } else { $remainNum = $realnums + $secondCount - $salensend; } if ($remainNum < 0) { //if((!isset($skuinfo['realnums']) && !isset($skuinfo['secondCount'])) || ((($skuinfo['realnums']+$skuinfo['secondCount']) - $allnums - $salensend) < 0)){//缺货本身算待发货,不能重复扣除 //if(!isset($skuinfo['realnums']) || empty($skuinfo['realnums']) || ($skuinfo['realnums'] - $salensend - $allnums) < 0){ $hava_goodscount = false; break; } } } if ($hava_goodscount) { $record_details[] = $orderdetail; } } if ($is_640) { //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } $count_record_details = count($record_details); $count_orderdetaillist = count($orderdetaillist); $final_status = $ebay_status; //原始状态 if ($is_no_location) { $final_status = 720; //无仓位订单移动到同步异常订单 add by Herman.Xi @20131129 $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); insert_mark_shipping($ebay_id); //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } if ($count_record_details == 0) { //更新至自动拦截发货状态 if (!in_array($ebay_carrier, $no_express_delivery)) { $final_status = 658; } else { $final_status = 661; } $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); //$order_statistics->replaceData($order_sn, array('mask'=>1), array('mask'=>1)); insert_mark_shipping($ebay_id); //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } else { if ($count_record_details < $count_orderdetaillist) { //更新至自动部分发货状态 if (!in_array($ebay_carrier, $no_express_delivery)) { $final_status = 640; if (in_array($ebay_account, $SYSTEM_ACCOUNTS['cndirect']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['dresslink'])) { $final_status = 659; //add by Herman.Xi@20131202 部分包货料号订单进入 } } else { $final_status = 660; } $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); //$order_statistics->replaceData($order_sn, array('mask'=>1), array('mask'=>1)); insert_mark_shipping($ebay_id); //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } else { if ($count_record_details == $count_orderdetaillist) { //正常发货状态 if (in_array($ebay_account, $SYSTEM_ACCOUNTS['ebay平台'])) { $status683 = false; if (in_array($ebay_countryname, array('Belarus', 'Brazil', 'Brasil', 'Argentina', 'Ukraine')) && str_word_count($ebay_username) < 2) { $status683 = true; } if ($status683) { $final_status = 683; $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); //$order_statistics->replaceData($order_sn, array('mask'=>1), array('mask'=>1)); //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } if (in_array($ebay_status, array(658, 659, 660, 661, 720))) { //$final_status = 618;//ebay订单自动拦截有货不能移动到待处理和有留言 modified by Herman.Xi @ 20130325(移动到缺货需打印中) /*if($ebay_note != ''){ echo "有留言\t"; $final_status = 593; }else{*/ $final_status = 618; //} } else { /*if($ebay_note != ''){ echo "有留言\t"; $final_status = 593; }else{*/ $final_status = 1; //} } } else { if (in_array($ebay_account, $SYSTEM_ACCOUNTS['海外销售平台'])) { $status683 = false; if (in_array($ebay_countryname, array('Belarus', 'Brazil', 'Brasil', 'Argentina', 'Ukraine')) && str_word_count($ebay_username) < 2) { $status683 = true; } if ($status683) { $final_status = 683; $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); //$order_statistics->replaceData($order_sn, array('mask'=>1), array('mask'=>1)); //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } if (in_array($ebay_status, array(658, 659, 660, 661, 720))) { //$final_status = 629; //德国订单区别于正常订单 $final_status = 618; //modified by Herman.Xi @20130823 雷贤容需要修改成缺货需打印中 $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); //$order_statistics->replaceData($order_sn, array('mask'=>1), array('mask'=>1)); //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } else { /*if($ebay_note != ''){ echo "德国订单有留言\t"; $final_status = 593; }else{*/ $final_status = 1; //} //德国订单进入正常订单流程 } } else { if (in_array($ebay_account, $SYSTEM_ACCOUNTS['aliexpress'])) { $final_status = 595; $status683 = false; if (in_array($ebay_countryname, array('Russian Federation', 'Russia')) && strpos($ebay_carrier, '中国邮政') !== false && str_word_count($ebay_username) < 2) { $status683 = true; } if (in_array($ebay_countryname, array('Belarus', 'Brazil', 'Brasil', 'Argentina', 'Ukraine')) && str_word_count($ebay_username) < 2) { $status683 = true; } if ($status683) { $final_status = 683; $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); //$order_statistics->replaceData($order_sn, array('mask'=>1), array('mask'=>1)); //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } } else { if (in_array($ebay_account, $SYSTEM_ACCOUNTS['DHgate'])) { $final_status = 620; } else { if (in_array($ebay_account, $SYSTEM_ACCOUNTS['dresslink'])) { $final_status = 1; } else { if (in_array($ebay_account, $SYSTEM_ACCOUNTS['cndirect'])) { $final_status = 1; } else { if (in_array($ebay_account, $SYSTEM_ACCOUNTS['亚马逊'])) { if (in_array($ebay_status, array(658, 659, 660, 661, 720))) { if (in_array($ebay_carrier, $no_express_delivery)) { $final_status = 618; //modified by Herman.Xi @20131106 刘丽需要修改成缺货需打印中 } else { if ($ebay_carrier == 'FedEx') { $final_status = 639; //modified by Herman.Xi @20131213 刘丽需要修改线下订单导入 } else { $final_status = 641; //modified by Herman.Xi @20131119 刘丽需要修改成待打印线下和异常订单 } } $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); continue; } else { $final_status = 1; } } else { $final_status = 1; } } } } } } } /*if(judge_contain_combinesku($order_sn)){ $final_status = 606; }*/ if (in_array($ebay_account, $SYSTEM_ACCOUNTS['ebay平台']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['海外销售平台'])) { if ($ebay_note != '') { //echo "有留言\t"; $final_status = 593; } } if ($totalweight > 2) { //echo "\t 超重订单"; $final_status = 608; } if (!in_array($ebay_carrier, $no_express_delivery) && !empty($ebay_carrier)) { if (in_array($ebay_account, $SYSTEM_ACCOUNTS['ebay平台']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['海外销售平台'])) { $final_status = 641; //ebay和海外都跳转到 待打印线下和异常订单 } else { $final_status = 639; } } /*add by Herman.Xi @20131103 *包含粉末,膏状,液体,指甲油,内置电池(除手表外)非快递先临时拦截下来。 */ /*if(in_array($ebay_carrier,array('中国邮政平邮','中国邮政挂号','香港小包平邮','香港小包挂号','德国邮政挂号','新加坡小包挂号')) && $contain_hold131103){ $final_status = 704; insert_mark_shipping($ebay_id); }*/ /*if($contain_wh_item && in_array($ebay_carrier,$no_express_delivery)){ $final_status = 712; insert_mark_shipping($ebay_id); }else */ if ($contain_ups) { // add by Herman.Xi @20140317 $final_status = 731; insert_mark_shipping($ebay_id); } else { if ($contain_xru_track) { // add by zhiqiang.chen 2014-5-2 $final_status = 743; //俄速通小包挂号 insert_mark_shipping($ebay_id); } else { if ($contain_xru_notrack) { $final_status = 744; //俄速通小包平邮 insert_mark_shipping($ebay_id); } else { if ($contain_eub) { $final_status = 725; //移到EUB跟踪号申请异常订单 insert_mark_shipping($ebay_id); } else { if ($contain_swtch_track) { $final_status = 750; insert_mark_shipping($ebay_id); } else { if ($contain_DGMPY) { $final_status = 745; //移到新加坡DGM insert_mark_shipping($ebay_id); } } } } } } $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' and ebay_status = '{$ebay_status}' "; $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---{$final_status}!\n\n"; $dbcon->execute($sql) or die("Fail : {$sql}"); //$order_statistics->replaceData($order_sn, array('mask'=>1), array('mask'=>1)); $log_data .= "\n-------------------end ----------------------\n"; } else { $log_data .= "[" . date("Y-m-d H:i:s") . "]\t订单{$ebay_id同步状态有误},请联系IT解决!"; } } } } //write_scripts_log('auto_contrast_intercept', $ebay_account, $log_data); unset($log_data); unset($ebay_total0); unset($ebay_id); unset($order_sn); unset($ebay_status); unset($ebay_note); unset($ebay_carrier); unset($ebay_countryname); unset($ebay_account); unset($ebay_total); unset($ebay_username); unset($ebay_orderid); unset($ebay_usermail); unset($PayPalEmailAddress); } unset($ebay_orders); }