Example #1
0
function check_blacklist($order)
{
    global $dbConn;
    $ebay_userid = $order['ebay_userid'];
    $ebay_username = $order['ebay_username'];
    $ebay_usermail = $order['ebay_usermail'];
    $ebay_street = $order['ebay_street'];
    $ebay_phone = $order['ebay_phone'];
    $ebay_account = $order['ebay_account'];
    $sql = "select count(*)  as totalnum from ebay_blacklist ";
    $blackcondition = array();
    if ($ebay_userid != "") {
        $blackcondition[] = "ebay_userid='{$ebay_userid}'";
    }
    if ($ebay_username != "") {
        $blackcondition[] = "ebay_username='******'";
    }
    if ($ebay_usermail != "") {
        $blackcondition[] = "ebay_usermail='{$ebay_usermail}'";
    }
    if ($ebay_street != "") {
        $blackcondition[] = "ebay_street='{$ebay_street}'";
    }
    if ($ebay_phone != "") {
        $blackcondition[] = "ebay_phone='{$ebay_phone}'";
    }
    $bconditon = implode(' OR ', $blackcondition);
    $blackwhere = count($blackcondition) > 0 ? " where {$bconditon} and ebay_accounts like '%[{$ebay_account}]%' " : 'where 0';
    $sql = $sql . $blackwhere;
    $sql = $dbConn->query($sql);
    $black_list = $dbConn->fetch_one($sql);
    if ($black_list['totalnum'] > 0) {
        $ss = "update ebay_order set ebay_status=684 where ebay_id={$order['ebay_id']}";
        if ($dbConn->query($ss)) {
            insert_mark_shipping($order['ebay_id']);
            echo "订单id{$order['ebay_id']}进入黑名单文件夹";
        } else {
            echo "订单id{$order['ebay_id']}移动进黑名单文件夹失败";
        }
    }
}
Example #2
0
    if ($ebay_username != "") {
        $blackcondition[] = "ebay_username='******'";
    }
    if ($ebay_usermail != "") {
        $blackcondition[] = "ebay_usermail='{$ebay_usermail}'";
    }
    if ($ebay_street != "") {
        $blackcondition[] = "ebay_street='{$ebay_street}'";
    }
    if ($ebay_phone != "") {
        $blackcondition[] = "ebay_phone='{$ebay_phone}'";
    }
    $bconditon = implode(' OR ', $blackcondition);
    $blackwhere = count($blackcondition) > 0 ? " where ({$bconditon}) and ebay_accounts like '%[{$ebay_account}]%' " : 'where 0';
    $sql = $sql . $blackwhere;
    $log_sql = $sql;
    $sql = $dbConn->query($sql);
    $black_list = $dbConn->fetch_first($sql);
    if ($black_list['totalnum'] > 0) {
        $ss = "update ebay_order set ebay_status=684 where ebay_id={$order['ebay_id']}";
        if ($dbConn->query($ss)) {
            insert_mark_shipping($order['ebay_id']);
            echo "订单id{$order['ebay_id']}进入黑名单文件夹\n.{$log_sql}\n";
        } else {
            echo "订单id{$order['ebay_id']}移动进黑名单文件夹失败\n";
        }
    }
}
$time_end = time();
echo "\n=====[耗时:" . ceil(($time_end - $time_start) / 60) . "分钟]====\n";
echo "\n<====[" . date('Y-m-d H:i:s', $time_end) . "]系统【结束】同步账号【 {$account} 】订单\n";
Example #3
0
function auto_contrast_intercept($ebay_orders)
{
    //订单自动拦截完整版 支持虚拟料号
    //add Herman.Xi 2012-12-20
    /*
    * 订单进入系统首先判断 是否为超大订单,如果为超大订单,文件夹为640;
    * B2B 抓取超大订单自动进入 超大订单待确认 modified by Herman.Xi @ 2013.05.20
    * 判断订单下,料号是否全部有货,部分有货,全部没货:
         如果部分有货,判断其运输方式,如果为快递,文件夹为659;非快递则为660;(订单自动部分包货)
    	 如果全部没货,判断其运输方式,如果为快递,文件夹为658;非快递则为661;(订单自动拦截)
    	 如果全部有货:
    	 	先判断如果为组合订单,文件夹为606;
    		如果超重订单,文件夹为608;
    		如果快递订单,文件夹为639;
    		全部不满足则为导入状态
      自动拦截时,判断自动拦截快递,非快递,自动部分包货快递,非快递里面的订单,自动每隔十五分钟执行一次
      //支持 速卖通导入,敦煌导入,ebay线下导入,dresslink导入,快递导入,出口通导入
    */
    global $dbcon, $defaultstoreid, $SYSTEM_ACCOUNTS, $order_statistics, $__liquid_items_fenmocsku, $__liquid_items_SuperSpecific, $__liquid_items_postbyhkpost, $__liquid_items_cptohkpost, $__liquid_items_BuiltinBattery, $__liquid_items_Paste;
    $log_data = "";
    $express_delivery = array('UPS', 'DHL', 'TNT', 'EMS', 'FedEx');
    $no_express_delivery = array('中国邮政平邮', '中国邮政挂号', '香港小包平邮', '香港小包挂号', 'EUB', 'Global Mail');
    foreach ($ebay_orders as $ebay_order) {
        //$import_status = now_order_status_log($osn, false);
        $ebay_id = $ebay_order['ebay_id'];
        $ebay_status = $ebay_order['ebay_status'];
        //$ebay_orderid = $ebay_order['ebay_orderid'];
        $ebay_note = $ebay_order['ebay_note'];
        $order_sn = $ebay_order['ebay_ordersn'];
        $ebay_carrier = $ebay_order['ebay_carrier'];
        $ebay_countryname = $ebay_order['ebay_countryname'];
        $ebay_account = $ebay_order['ebay_account'];
        $ebay_username = $ebay_order['ebay_username'];
        $totalweight = $ebay_order['orderweight'];
        $ebay_total = $ebay_order['ebay_total'];
        $recal_weight = recalcorderweight($order_sn, $ebay_packingmaterial);
        //modified by Herman.Xi 2012-10-17
        if (empty($totalweight)) {
            //按照如果没有重量的即默认为
            $totalweight = $recal_weight;
        }
        $sql = "SELECT sku,ebay_amount FROM ebay_orderdetail WHERE ebay_ordersn='{$order_sn}'";
        $result = $dbcon->execute($sql);
        $orderdetaillist = $dbcon->getResultArray($result);
        $contain_special_item = false;
        $shippment_cptohkpost = false;
        foreach ($orderdetaillist as $orderdetail) {
            $sku_arr = get_realskuinfo($orderdetail['sku']);
            foreach ($sku_arr as $or_sku => $or_nums) {
                if (in_array($or_sku, $__liquid_items_fenmocsku) || in_array($or_sku, $__liquid_items_SuperSpecific)) {
                    //粉末状,超规格产品 走福建邮局
                    $contain_special_item = true;
                }
                if (in_array($or_sku, $__liquid_items_postbyhkpost) || in_array($or_sku, $__liquid_items_cptohkpost) || in_array($or_sku, $__liquid_items_BuiltinBattery) || in_array($or_sku, $__liquid_items_Paste)) {
                    //包含特殊料号,中国邮政转香港小包
                    $shippment_cptohkpost = true;
                }
            }
        }
        if (!empty($ebay_carrier)) {
            //$fees			    = calcshippingfee($totalweight,$ebay_countryname,$ebay_id,$ebay_account,$ebay_total);
            if ($shippment_cptohkpost && strpos($ebay_carrier, '中国邮政') !== false) {
                if (count($orderdetaillist) == 1) {
                    $ebay_carrier = '香港小包挂号';
                } else {
                    $ebay_carrier = '';
                    $aliexpress_ebay_noteb = "系统提示:包含特殊料号不走中国邮政,请重新选择运输方式或者拆包!";
                }
                //$fee			= $fees[1];
                //$totalweight	= $fees[2];
                $bb = "update ebay_order set ebay_carrier = '{$ebay_carrier}', orderweight ='{$totalweight}', packingtype ='{$ebay_packingmaterial}', ebay_noteb = '{$aliexpress_ebay_noteb}' where ebay_id ='{$ebay_id}' ";
            } else {
                //$ebay_carrier	= $fees[0];
                //$fee			= $fees[1];
                //$totalweight	= $fees[2];
                $shipfee = calctrueshippingfee($ebay_carrier, $totalweight, $ebay_countryname, $ebay_id);
                $bb = "update ebay_order set ebay_carrier = '{$ebay_carrier}', ordershipfee='{$shipfee}', orderweight ='{$totalweight}', packingtype ='{$ebay_packingmaterial}' where ebay_id ='{$ebay_id}' ";
            }
            $dbcon->execute($bb);
        }
        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";
        }
        $record_details = array();
        $is_640 = false;
        foreach ($orderdetaillist as $orderdetail) {
            $sku_arr = get_realskuinfo($orderdetail['sku']);
            $hava_goodscount = true;
            foreach ($sku_arr as $or_sku => $or_nums) {
                $allnums = $or_nums * $orderdetail['ebay_amount'];
                if (!check_sku($or_sku, $allnums, $ebay_id)) {
                    //超大订单状态
                    if (in_array($ebay_account, $SYSTEM_ACCOUNTS['aliexpress']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['B2B外单']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['DHgate']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['出口通']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['线下结算客户'])) {
                        $sql = "UPDATE ebay_order SET ebay_status='698' WHERE ebay_id ='{$ebay_id}' ";
                        $log_data .= "[" . date("Y-m-d H:i:s") . "]\t自动跳转---{$ebay_id}---的状态为---698!\n\n";
                    } else {
                        $sql = "UPDATE ebay_order SET ebay_status='640' WHERE ebay_id ='{$ebay_id}' ";
                        $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);
                    write_log('contrast_intercept_' . date("Ymd") . '/' . date("H") . '.txt', $log_data . "\n\n");
                    $is_640 = true;
                    break;
                } else {
                    $skuinfo = get_sku_info($or_sku);
                    $salensend = getsaleandnosendall($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";
                    if ($skuinfo['realnums'] - $salensend < 0) {
                        $hava_goodscount = false;
                        break;
                    }
                }
            }
            if ($hava_goodscount) {
                $record_details[] = $orderdetail;
            }
        }
        if ($is_640) {
            continue;
        }
        $count_record_details = count($record_details);
        $count_orderdetaillist = count($orderdetaillist);
        $final_status = $ebay_status;
        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}' ";
            $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_log('contrast_intercept_' . date("Ymd") . '/' . date("H") . '.txt', $log_data . "\n\n");
            continue;
        } else {
            if ($count_record_details < $count_orderdetaillist) {
                //更新至自动部分发货状态
                if (!in_array($ebay_carrier, $no_express_delivery)) {
                    //$final_status = 659;
                    $final_status = 640;
                    //modified by Herman.Xi @ 20130401
                } else {
                    $final_status = 660;
                }
                $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' ";
                $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_log('contrast_intercept_' . date("Ymd") . '/' . date("H") . '.txt', $log_data . "\n\n");
                continue;
            } else {
                if ($count_record_details == $count_orderdetaillist) {
                    //正常发货状态
                    if (in_array($ebay_account, $SYSTEM_ACCOUNTS['ebay平台'])) {
                        if ($ebay_note != '') {
                            $final_status = 593;
                        } else {
                            $final_status = 1;
                        }
                    } else {
                        if (in_array($ebay_account, $SYSTEM_ACCOUNTS['海外销售平台'])) {
                            $final_status = 629;
                            //德国订单
                            $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' ";
                            $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_log('contrast_intercept_' . date("Ymd") . '/' . date("H") . '.txt', $log_data . "\n\n");
                            continue;
                        } else {
                            if (in_array($ebay_account, $SYSTEM_ACCOUNTS['aliexpress']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['B2B外单'])) {
                                if ($ebay_note != '') {
                                    $final_status = 593;
                                } else {
                                    $final_status = 595;
                                }
                                if (in_array($ebay_countryname, array('Russian Federation', 'Russia')) && strpos($ebay_carrier, '中国邮政') !== false && str_word_count($ebay_username) < 2) {
                                    $final_status = 683;
                                    $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' ";
                                    $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_log('contrast_intercept_' . date("Ymd") . '/' . date("H") . '.txt', $log_data . "\n\n");
                                    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 {
                                            $final_status = 1;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (judge_contain_combinesku($order_sn)) {
                        $final_status = 606;
                    }
                    if ($totalweight > 2) {
                        $final_status = 608;
                    }
                    if (!in_array($ebay_carrier, $no_express_delivery)) {
                        if (in_array($ebay_account, $SYSTEM_ACCOUNTS['ebay平台']) || in_array($ebay_account, $SYSTEM_ACCOUNTS['海外销售平台'])) {
                            $final_status = 641;
                            //ebay和海外都跳转到 待打印线下和异常订单
                        } else {
                            $final_status = 639;
                        }
                    }
                    $sql = "UPDATE ebay_order SET ebay_status='{$final_status}' WHERE ebay_id ='{$ebay_id}' ";
                    $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_log('contrast_intercept_' . date("Ymd") . '/' . date("H") . '.txt', $log_data . "\n\n");
                } else {
                    $log_data .= "[" . date("Y-m-d H:i:s") . "]\t订单{$ebay_id同步状态有误,请联系IT解决!}";
                }
            }
        }
    }
    if (!empty($log_data)) {
        write_log('contrast_intercept_' . date("Ymd") . '/' . date("H") . '.txt', $log_data . "\n\n");
    }
}
Example #4
0
function usCalcShipCost($ebayid)
{
    global $dbcon;
    $shipCost = '';
    $carrier = '';
    $getInfo = "SELECT ebay_id,ebay_ordersn,orderweight, ebay_postcode FROM ebay_order where ebay_id = '{$ebayid}' AND ebay_countryname = 'United States' ";
    $getInfo = $dbcon->execute($getInfo);
    $getInfo = $dbcon->fetch_one($getInfo);
    $weight = $getInfo['orderweight'];
    //订单重量
    $zipCode = $getInfo['ebay_postcode'];
    //目的地邮编
    $zipCode = substr($zipCode, 0, 3);
    //只需取邮编前3位数字
    $ebayid = $getInfo["ebay_id"];
    $getZone = "SELECT zone FROM ow_zone_postcode WHERE zip_code like '%{$zipCode}%'";
    $getZone = $dbcon->execute($getZone);
    $getZone = $dbcon->fetch_one($getZone);
    $zone = $getZone['zone'];
    //邮编所属分区
    $weight_g = $weight * 1000;
    //kg转换成g;
    $weight_oz = ceil($weight_g / 28.35);
    //g转换成盎司
    $weight_lbs = ceil($weight / 0.4536);
    //kg转换成磅
    include_once 'ow_common.php';
    //海外仓公用函数
    include_once 'OverseaShipfeeCul.php';
    //海外仓运费计算类
    /*------------- 运输方式选择   ---------------*/
    $culModel = new OverseaShipfeeCul();
    $shipsetting = $culModel->getShipSettings();
    $rate = $shipsetting['firerate'];
    $home = $shipsetting['homeshipfee'];
    $exchange = $shipsetting['usdexchange'];
    $splitedSkuList = generateSkuList($getInfo['ebay_ordersn']);
    // 	print_r($splitedSkuList);exit;
    $packageLWH = culPackageLWH($splitedSkuList);
    //包裹的长宽高
    // 	print_r($packageLWH);
    $length = $packageLWH['L'];
    $width = $packageLWH['W'];
    $hight = $packageLWH['H'];
    $weidht = $weight;
    $sitesing = 0.39370078740157;
    $lwh = array('L' => $length * $sitesing, 'W' => $width * $sitesing, 'H' => $hight * $sitesing);
    // 	echo $weidht, "===\n";
    $result = array();
    //可成立的运输方式列表    格式 array(运输方式名称=>运费)
    /*
     $usps_fix   = $culModel->uspsShipfee_fix($length,$width, $hight, 'fix', 'inside');                     //usps 固定运费
    if ($usps_fix) {
    $result['usps_fix']    = $usps_fix;
    }
    
    $usps_A     = $culModel->usps_serviceA($length,$width, $hight,$weidht);
    if ($usps_A) {                                                                                         //usps 套餐A
    $result['usps_A']    = $usps_A;
    }
    
    $usps_B     = $culModel->usps_serviceB($length,$width, $hight, $weidht);                               //usps 套餐B
    if ($usps_B) {
    $result['usps_B']    = $usps_B;
    }
    
    $usps_C     = $culModel->usps_serviceC($length,$width, $hight, $weidht);
    if ($usps_C) {
    $result['usps_C']    = $usps_C;
    }
    */
    $ground_re = $culModel->ground_re($weidht, $zone, $lwh);
    //GROUND RESIDENTIAL
    if ($ground_re) {
        $result['ground_re'] = $ground_re + $ground_re * $rate;
        //运费加燃油附加费 + 住宅运送费
    }
    $ground_co = $culModel->ground_co($weidht, $zone, $lwh);
    //GROUND COMMERCIAL
    if ($ground_co) {
        $result['ground_co'] = $ground_co + $ground_co * $rate + $home;
        //运费加燃油附加费
    }
    $SurePost = $culModel->SurePost($length, $width, $hight, $weidht, $zone);
    //SurePost运费
    if ($SurePost) {
        $result['SurePost'] = $SurePost + $SurePost * $rate;
        //运费加燃油附加费
    }
    /*
     $ups        = $culModel->upsShipfee($weidht);                                                          //ups运费计算
    if ($ups) {
    $result['UPS Ground']    = $ups + ($ups*$rate) + $home;
    }
    */
    $usps_gel = $culModel->uspsGeneral($weidht, $zone, $lwh);
    //usps通用运费计算
    if ($usps_gel) {
        $result['USPS'] = $usps_gel;
    }
    // 	print_r($result);
    $mini = array('ship' => '', 'fee' => 10000);
    foreach ($result as $key => $fee) {
        if ($fee < $mini['fee']) {
            $mini['ship'] = $key;
            $mini['fee'] = $fee;
        }
    }
    $carrier = carrerMap($mini['ship']);
    $shipCost = $mini['fee'];
    // 	echo $carrier, "++", $shipCost;
    /*
    	if($weight_oz <= 13){//重量小于13盎司直接选USPS运输方式
    		$getUspsCost = "SELECT cost FROM ow_usps_calcfree WHERE weight = '{$weight_oz}' AND unit = 'oz'";
    		
    		$getUspsCost = $dbcon->execute($getUspsCost);
    		$getUspsCost = $dbcon->fetch_one($getUspsCost);
    		$shipCost    = $getUspsCost['cost'];
    		$carrier     = 'USPS';
    	}else{
    		$getUspsCost = "SELECT cost FROM ow_usps_calcfree WHERE weight = '{$weight_lbs}' AND zone = '{$zone}' AND unit = 'lbs'";
    		$getUspsCost = $dbcon->execute($getUspsCost);
    		$getUspsCost = $dbcon->fetch_one($getUspsCost);
    		$uspsCost    = $getUspsCost['cost'];//USPS运费
    		
    		$getUpsCost  = "SELECT cost FROM ow_ups_calcfree WHERE weight = '{$weight_lbs}' AND zone = '{$zone}' AND unit = 'lbs'";
    		$getUpsCost  = $dbcon->execute($getUpsCost);
    		$getUpsCost  = $dbcon->fetch_one($getUpsCost);
    		$upsCost     = $getUpsCost['cost'];//UPS运费
    		$upsCost     = $upsCost*(1+0.07); //添加 燃油附加费
    		if($uspsCost <= $upsCost){//运费对比
    			$shipCost = $uspsCost;
    			$carrier  = 'USPS';
    		}else{
    			$shipCost = $upsCost;
    			$carrier  = 'UPS Ground';
    		}
    	}*/
    /*------------- 运输方式选择   ---------------*/
    if ($shipCost != '' && $carrier != '') {
        $update = "UPDATE ebay_order SET ebay_carrier = '{$carrier}', ordershipfee = '{$shipCost}',\tebay_status = 706 WHERE ebay_id = '{$ebayid}'";
        if ($dbcon->execute($update)) {
            insert_mark_shipping($ebayid);
            return 1;
        } else {
            return 0;
        }
    }
}