Example #1
0
function calcshippingfee($totalweight, $ebay_countryname, $ebayid, $ebay_account, $ebay_total)
{
    global $dbConn, $user, $__liquid_items_postbyhkpost, $__liquid_items_postbyfedex, $__liquid_items_cptohkpost, $__liquid_items_elecsku, $global_countrycn_coutryen, $__elecsku_countrycn_array, $GLOBAL_EBAY_ACCOUNT, $__liquid_items_fenmocsku, $__liquid_items_BuiltinBattery, $__liquid_items_SuperSpecific, $__liquid_items_Paste, $SYSTEM_ACCOUNTS;
    $g_account = str_replace(',', '', $ebay_account);
    $ss = "delete from ebay_lishicalcfee where orderid ='{$ebayid}' ";
    $dbConn->query($ss);
    $shippment_hkpost_directly = false;
    $shippment_fedex_directly = false;
    $shippment_cptohkpost = false;
    //$shippment_elec_directly = false;
    ############single line item order中如果有液体的产品直接设为香港小包###########1/2
    ####added by john 2012-05-16
    $ss = "select ebay_ordersn,ebay_orderid,ebay_couny,ebay_currency from ebay_order where ebay_id ={$ebayid} ";
    $ss = $dbConn->query($ss);
    $ss = $dbConn->fetch_array_all($ss);
    $ebay_ordersn = $ss[0]['ebay_ordersn'];
    $ebay_orderid = $ss[0]['ebay_orderid'];
    $ebay_couny = $ss[0]['ebay_couny'];
    $ebay_currency = $ss[0]['ebay_currency'];
    $ss = "select sku,ebay_itemprice from ebay_orderdetail where ebay_ordersn ='{$ebay_ordersn}'";
    $ss = $dbConn->query($ss);
    $ss = $dbConn->fetch_array_all($ss);
    $sku_arr = array();
    $eub_to_py = false;
    //包含单价小于等于五的料号
    foreach ($ss as $_ss) {
        if (function_exists("get_realskuinfo")) {
            $skus = get_realskuinfo($_ss['sku']);
            foreach ($skus as $k => $n) {
                //支持组合料号
                $sku_arr[] = trim($k);
            }
        } else {
            $sku_arr[] = trim($_ss['sku']);
        }
        /* add by Herman.Xi @2013-07-16 */
        if ($_ss['ebay_itemprice'] <= 5) {
            $eub_to_py = true;
        }
    }
    $array_intersect_elec = array_intersect($sku_arr, $__liquid_items_elecsku);
    $array_intersect_gaoji = array_intersect($sku_arr, $__liquid_items_postbyfedex);
    $array_intersect_zhijiayou = array_intersect($sku_arr, $__liquid_items_cptohkpost);
    $array_intersect_yieti = array_intersect($sku_arr, $__liquid_items_postbyhkpost);
    $array_intersect_fenmocsku = array_intersect($sku_arr, $__liquid_items_fenmocsku);
    $array_intersect_BuiltinBattery = array_intersect($sku_arr, $__liquid_items_BuiltinBattery);
    $array_intersect_SuperSpecific = array_intersect($sku_arr, $__liquid_items_SuperSpecific);
    $array_intersect_Paste = array_intersect($sku_arr, $__liquid_items_Paste);
    /*if(count($array_intersect_elec) > 0 && in_array($global_countrycn_coutryen[$ebay_countryname],$__elecsku_countrycn_array)){
    			$shippment_elec_directly	=	true;
    			echo "料号[ ".join(', ', $array_intersect_elec)." ]为电子类产品,运到[ ".$global_countrycn_coutryen[$ebay_countryname]." ]需要直接走香港小包\n";
    		}else */
    if (count($array_intersect_gaoji) > 0) {
        $shippment_fedex_directly = true;
        echo "料号[ " . join(', ', $array_intersect_gaoji) . " ]为高级产品,需要直接走FedEx\n";
    } else {
        if (count($array_intersect_zhijiayou) > 0) {
            $shippment_cptohkpost = true;
            echo "料号[ " . join(', ', $array_intersect_zhijiayou) . " ]为指甲油产品,需要直接走香港小包\n";
        } else {
            if (count($array_intersect_yieti) > 0) {
                $shippment_hkpost_directly = true;
                echo "料号[ " . join(', ', $array_intersect_yieti) . " ]为液体产品,需要直接走中国邮政\n";
            }
        }
    }
    ############single line item order中如果有液体的产品直接设为香港小包###########1/2
    ############ebay设置特定国家走挂号,包含特殊料号走平邮,超过70走挂号,币种为美元和英镑###########START
    //ADD BY Herman.Xi @ 2013-07-02
    $ecsql = "select countrys from ebay_cpghcalcfee where ebay_user='******' and name in ('第六组','第七组','第八组','第九组','第十组') ";
    $ecresult = $dbConn->query($ecsql);
    $ecarr = $dbConn->fetch_array_all($ecresult);
    $spec_countries = array('Turkey', 'Korea', 'North', 'Russian Federation', 'Spain', 'Armenia', 'Bosnia and Herzegovina', 'Vietnam', 'Palestine');
    $ec_countries = array();
    foreach ($ecarr as $ecline) {
        $strarr = array_filter(explode(',', $ecline['countrys']));
        foreach ($strarr as $line) {
            if (trim($line) != 'Puerto Rico') {
                //波多黎各不挂号,add by herman.Xi @ 20130801
                $ec_countries[] = trim($line);
            }
        }
    }
    $union_countries = array_merge($spec_countries, $ec_countries);
    ############ebay设置特定国家走挂号,包含特殊料号走平邮,超过70走挂号,币种为美元和英镑###########END
    $ss = "select * from ebay_carrier where ebay_user ='******' and country not like '%{$ebay_countryname}%'";
    $ss = $dbConn->query($ss);
    $ss = $dbConn->fetch_array_all($ss);
    $data = array();
    for ($i = 0; $i < count($ss); $i++) {
        $shipfee = 0;
        $name = $ss[$i]['name'];
        $kg = $ss[$i]['kg'];
        $handlefee = $ss[$i]['handlefee'];
        $id = $ss[$i]['id'];
        $rate = $ss[$i]['rate'];
        $min = $ss[$i]['min'];
        // 是否满足挂号条件
        if ($name == '香港小包挂号') {
            $shipfee = calchkghpost($totalweight, $ebay_countryname);
            /*if(($ebay_total >= $min) || (in_array($ebay_couny, array('AR','BR','PE','CL','PY','BO','EC','GF','CO','GY','SR','UY','VE','RU')) && ($shippment_cptohkpost === true || $shippment_hkpost_directly === true || count($array_intersect_BuiltinBattery) > 0 || count($array_intersect_Paste) > 0))){
            			$gg		= "insert into ebay_lishicalcfee(name,value,shippingid,orderid,totalweight)
            					  values('$name','$shipfee','$id','$ebayid','$totalweight')";
            			echo "$name:$shipfee\n";
            			$dbConn->query($gg);
            		}*/
            if ($ebay_total >= $min) {
                $gg = "insert into ebay_lishicalcfee(name,value,shippingid,orderid,totalweight)\n\t\t\t\t\t\t\t  values('{$name}','{$shipfee}','{$id}','{$ebayid}','{$totalweight}')";
                echo "{$name}:{$shipfee}\n";
                $dbConn->query($gg);
            }
        }
        /****************************************************/
        if ($name == '香港小包平邮') {
            $shipfee = calchkpost($totalweight, $ebay_countryname);
            echo "{$name}:{$shipfee}\n";
            $gg = "insert into ebay_lishicalcfee(name,value,shippingid,orderid,totalweight) \n\t\t\t\t\t\t\t\tvalues('{$name}','{$shipfee}','{$id}','{$ebayid}','{$totalweight}')";
            $dbConn->query($gg);
        }
        if ($name == 'EUB' && ($ebay_countryname == 'United States' || $ebay_countryname == 'US')) {
            $discount = $ss[$i]['discount'] ? $ss[$i]['discount'] : 1;
            if ($totalweight <= 0.06) {
                $shipfee = 80 * 0.06 + 7;
            } else {
                $shipfee = 80 * $totalweight + 7;
            }
            $shipfee = $shipfee * $discount;
            $gg = "insert into ebay_lishicalcfee(name,value,shippingid,orderid,totalweight) \n\t\t\t\t\t\t\t\tvalues('{$name}','{$shipfee}','{$id}','{$ebayid}','{$totalweight}')";
            $dbConn->query($gg);
            echo "{$name}:{$shipfee}\n";
        }
        if ($name == '中国邮政平邮') {
            $shipfee = calcchinapostpy($totalweight, $ebay_countryname);
            if ($shipfee !== false) {
                $gg = "insert into ebay_lishicalcfee(name,value,shippingid,orderid,totalweight) \n\t\t\t\t\t\t\t\tvalues('{$name}','{$shipfee}','{$id}','{$ebayid}','{$totalweight}')";
                if ($dbConn->query($gg)) {
                } else {
                    echo "Fail : {$gg}\n";
                }
                echo "{$name} : {$shipfee} 满足重量区间: {$totalweight} 如果有重量区间,则以后面重量计算\n";
            } else {
                echo "{$ebay_countryname} 未开通中国邮政平邮\n";
            }
        }
        if ($name == '中国邮政挂号') {
            $shipfee = calcchinapostgh($totalweight, $ebay_countryname);
            if ($shipfee !== false) {
                $gg = "insert into ebay_lishicalcfee(name,value,shippingid,orderid,totalweight) \n\t\t\t\t\t\t\t\tvalues('{$name}','{$shipfee}','{$id}','{$ebayid}','{$totalweight}')";
                if ($dbConn->query($gg)) {
                } else {
                    echo "Fail : {$gg}\n";
                }
                echo "{$name} : {$shipfee} 满足重量区间: {$totalweight} 如果有重量区间,则以后面重量计算\n";
            } else {
                echo "{$ebay_countryname} 未开通中国邮政挂号\n";
            }
        }
        if ($name == 'EMS') {
            $dd = "SELECT * FROM  `ebay_emscalcfee` where countrys like '%{$ebay_countryname}%' ";
            $dd = $dbConn->query($dd);
            $dd = $dbConn->fetch_array_all($dd);
            $firstweight = $dd[0]['firstweight'];
            $nextweight = $dd[0]['nextweight'];
            $discount = $dd[0]['discount'];
            $firstweight0 = $dd[0]['firstweight0'];
            $files = $dd[0]['files'];
            $declared_value = $dd[0]['declared_value'];
            if ($files == '1' && $totalweight <= 0.5) {
                $firstweight = $firstweight0;
            }
            if ($totalweight <= 0.5) {
                $shipfee = $firstweight;
            } else {
                $shipfee = ceil(($totalweight * 1000 - 500) / 500) * $nextweight + $firstweight;
            }
            $shipfee = $shipfee * $discount + $declared_value;
            if ($totalweight > 0) {
                $gg = "insert into ebay_lishicalcfee(name,value,shippingid,orderid,totalweight) \n\t\t\t\t\t\t\t\tvalues('{$name}','{$shipfee}','{$id}','{$ebayid}','{$totalweight}')";
                $dbConn->query($gg);
            }
            echo "{$name} : {$shipfee} 满足重量区间:{$totalweight} 如果有重量区间,则以后面重量计算\n";
        }
        if ($name == 'FedEx') {
            if ($shippment_cptohkpost === true || count($array_intersect_fenmocsku) > 0 || count($array_intersect_BuiltinBattery) > 0 || count($array_intersect_Paste) > 0) {
                echo "包含特殊料号不走联邦!\n";
                //add by Herman.Xi
            } else {
                $shipfee = calcfedex($totalweight, $ebay_countryname, $ebayid);
                $gg = "insert into ebay_lishicalcfee(name,value,shippingid,orderid,totalweight) \n\t\t\t\t\t\t\t\t\t\tvalues('{$name}','{$shipfee}','{$id}','{$ebayid}','{$totalweight}')";
                $dbConn->query($gg);
                echo "{$name} : {$shipfee} 满足重量区间:{$totalweight} 如果有重量区间,则以后面重量计算\n";
            }
        }
        if ($name == 'Global Mail' && in_array($g_account, $SYSTEM_ACCOUNTS['海外销售平台'])) {
            $shipfee = calcglobalmail($totalweight, $ebay_countryname);
            $gg = "insert into ebay_lishicalcfee(name,value,shippingid,orderid,totalweight) \n\t\t\t\t\t\t\t\t\tvalues('{$name}','{$shipfee}','{$id}','{$ebayid}','{$totalweight}')";
            $dbConn->query($gg);
            echo "{$name} : {$shipfee} 满足重量区间:{$totalweight} 如果有重量区间,则以后面重量计算\n";
        }
        if ($name == 'DHL') {
            $shipfee = calcdhlshippingfee($totalweight, $ebay_countryname);
            $gg = "insert into ebay_lishicalcfee(name,value,shippingid,orderid,totalweight) \n\t\t\t\t\t\t\t\t\tvalues('{$name}','{$shipfee}','{$id}','{$ebayid}','{$totalweight}')";
            $dbConn->query($gg);
            echo "{$name} : {$shipfee} 满足重量区间:{$totalweight} 如果有重量区间,则以后面重量计算\n";
        }
    }
    //sleep(10);//主从同步延时
    $ss = "select * from ebay_carrier where ebay_account like '%{$ebay_account}%'";
    $ss = $dbConn->query($ss);
    $ss = $dbConn->fetch_array_all($ss);
    $ff = 0;
    if (count($ss) > 0) {
        $ff = 1;
    }
    $ss = "select * from ebay_lishicalcfee where orderid ='{$ebayid}' and value != '0' and name !='EUB' order by value asc ";
    $ss = $dbConn->query($ss);
    $ss = $dbConn->fetch_array_all($ss);
    /*##############中国邮政挂号(总价大于40走挂号)#############START
    		if ($ebay_total > 40){
    			$ss = "select * from ebay_lishicalcfee where name = '中国邮政挂号' and orderid ='$ebayid' ";
    			$ss		= $dbConn->query($ss);
    			$ss		= $dbConn->fetch_array_all($ss);
    		}
    		##############Global Mail(海外销售专走)#############START
    		if (in_array($g_account, $SYSTEM_ACCOUNTS['海外销售平台'])){
    			$ss = "select * from ebay_lishicalcfee where name = 'Global Mail' and orderid ='$ebayid' ";
    			$ss		= $dbConn->query($ss);
    			$ss		= $dbConn->fetch_array_all($ss);
    		}else
    		##############(sunwebzone,enjoy24hours,charmday88,betterdeals255,360beauty这5个账号除了以上的设置,还需要额外对US站点进行以下修改:针对第6点,ERP在同步订单的时候,订单金额(不包含运费)小于等于5.00(不限币种),发货国家为美国或者波多黎各时,自动选择一个最便宜的运输方式,不受EUB影响#############START
    		if (in_array($g_account, array('sunwebzone','enjoy24hours','charmday88','betterdeals255','360beauty')) && ($ebay_countryname == 'United States' ||  $ebay_countryname == 'US' || $ebay_countryname == 'Puerto Rico') && $eub_to_py){
    			if($shippment_cptohkpost === true || $shippment_hkpost_directly === true || count($array_intersect_BuiltinBattery) > 0 || count($array_intersect_Paste) > 0){
    				if($ebay_total >= 70 ){
    					$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name ='香港小包挂号' order by value asc ";
    				}else{
    					$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name = '香港小包平邮' order by value asc ";			
    				}	
    			}else{
    				if($ebay_total > 40 ){
    					$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name ='中国邮政挂号' order by value asc ";
    				}else{
    					$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name ='中国邮政平邮' order by value asc ";	
    				}
    			}
    			$ss		= $dbConn->query($ss);
    			$ss		= $dbConn->fetch_array_all($ss);
    		}else
    		##############EUB(EBAY US 站点)#############START
    		if($ff == 1 && ($ebay_countryname == 'United States' ||  $ebay_countryname == 'US' || $ebay_countryname == 'Puerto Rico')){
    			$ss = "select * from ebay_lishicalcfee where name = 'EUB' and orderid ='$ebayid' ";
    			$ss		= $dbConn->query($ss);
    			$ss		= $dbConn->fetch_array_all($ss);
    		}else
    		##############FedEx(包含单个超重料号或者贵重SKU)#############START
    		if ($shippment_fedex_directly===true){
    			$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name = 'FedEx' order by value asc ";			
    			$ss		= $dbConn->query($ss);
    			$ss		= $dbConn->fetch_array_all($ss);
    		}else
    		//modified by Herman.Xi @ 2013-07-08
    		if(in_array($g_account,array('betterdeals255','dealinthebox','easytrade2099','bestinthebox','fiveseason88','befdi','enicer','mysoulfor','newcandy789','estore456','eseasky68','swzeagoo','happyzone80','infourseas','emallzone','unicecho','vobeau','blessedness365'))){
    			if($shippment_cptohkpost === true || $shippment_hkpost_directly === true || count($array_intersect_BuiltinBattery) > 0 || count($array_intersect_Paste) > 0){
    				if($ebay_total >= 70 ){
    					$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name ='香港小包挂号' order by value asc ";
    				}else{
    					$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name = '香港小包平邮' order by value asc ";			
    				}
    			}else{
    				if($ebay_total > 40 ){
    					$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name ='中国邮政挂号' order by value asc ";
    				}else{
    					$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name ='中国邮政平邮' order by value asc ";	
    				}
    			}
    			$ss		= $dbConn->query($ss);
    			$ss		= $dbConn->fetch_array_all($ss);
    		}
    		else
    		//以下这些国家在同步订单的时候,金额大于10才挂号寄出,不管什么币种都行
    		//Japan,Korea, South,Malaysia,Singapore,Portugal,Czech Republic,Italy,Israel,Ireland 
    		if(in_array($ebay_countryname, array('Japan','Korea, South','Malaysia','Singapore','Portugal','Czech Republic','Italy','Israel','Ireland')) && $ebay_total > 10){
    			if($shippment_cptohkpost === true || $shippment_hkpost_directly === true || count($array_intersect_BuiltinBattery) > 0 || count($array_intersect_Paste) > 0){
    				if($ebay_total >= 70 ){
    					$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name ='香港小包挂号' order by value asc ";
    				}else{
    					$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name = '香港小包平邮' order by value asc ";			
    				}
    			}else{
    				$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name ='中国邮政挂号' order by value asc ";	
    			}
    			$ss		= $dbConn->query($ss);
    			$ss		= $dbConn->fetch_array_all($ss);
    		}else
    		//南美洲国家开放走挂号,特殊料号走香港小包挂号
    		//modified by Herman.Xi @ 2013.05.28
    		//if(in_array($ebay_couny, array('AR','BR','PE','CL','PY','BO','EC','GF','CO','GY','SR','UY','VE','RU'))){
    		if(in_array($ebay_countryname, $union_countries) && in_array($ebay_currency, array('GBP','USD'))){//指定的这些国家,并且订单币种为美元和英镑 Modified by Herman.Xi @ 2013-07-02
    			if($shippment_cptohkpost === true || $shippment_hkpost_directly === true || count($array_intersect_BuiltinBattery) > 0 || count($array_intersect_Paste) > 0){
    				if($ebay_total >= 70 ){
    					$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name ='香港小包挂号' order by value asc ";
    				}else{
    					$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name = '香港小包平邮' order by value asc ";			
    				}
    			}else{
    				$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name ='中国邮政挂号' order by value asc ";	
    			}
    			$ss		= $dbConn->query($ss);
    			$ss		= $dbConn->fetch_array_all($ss);
    		}else
    		##############液体(不含指甲油)SKU(中国邮政转香港小包)#############START
    		##############指甲油SKU(中国邮政转香港小包)#############START
    		##############电子类产品SKU(指定国家的订单 走香港小包)#############START
    		##############内置电池SKU(中国邮政转香港小包)#############START
    		##############膏状SKU(中国邮政转香港小包)#############START
    		//add by Herman.Xi 2013-03-14
    		if($shippment_cptohkpost === true || $shippment_hkpost_directly ===true || count($array_intersect_BuiltinBattery) > 0 || count($array_intersect_Paste) > 0){
    			if($ebay_total >= 70 ){
    				$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name ='香港小包挂号' order by value asc ";
    			}else{
    				$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name = '香港小包平邮' order by value asc ";			
    			}
    			$ss		= $dbConn->query($ss);
    			$ss		= $dbConn->fetch_array_all($ss);
    		}*/
    //implode("\n", $dbConn->error)."\n\n";
    //modified by Herman.Xi @ 2013-07-18 23:45 所有订单按照原始逻辑判断最优运输方式计算
    ##############Global Mail(海外销售专走)#############START
    //modified by Herman.Xi @ 2013-07-20 9:44 走意大利和包含特殊料号的订单保留原GM运输方式,非意大利国家订单不包含特殊料号走中国邮政平邮(只限于cndirect55,futurestar99)
    /*if (in_array($g_account, $SYSTEM_ACCOUNTS['海外销售平台'])){
    			//add by Herman.Xi @ 20130725 小语种账号 1 欧元 冲销量 走中国邮政平邮
    			if(in_array($g_account, array('cndirect998','easydealhere','tradekoo','allbestforu','easydeal365','enjoytrade99','freemart21cn','ishop2099')) && $ebay_total == 1 && $ebay_currency == 'EUR'){
    				$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name ='中国邮政平邮' order by value asc ";
    			}else
    			//add by Herman.Xi @ 2013-07-24 eshoppingstar75,ishoppingclub68 两个账号,已经账号easyshopping095 当国家为美国是走联邦
    			if((in_array($g_account, array('eshoppingstar75','ishoppingclub68'))) || (in_array($g_account, array('easyshopping095')) && ($ebay_countryname == 'United States' || $ebay_countryname == 'US'))){
    				if($shippment_cptohkpost === true || count($array_intersect_fenmocsku) > 0 || count($array_intersect_BuiltinBattery) > 0 || count($array_intersect_Paste) > 0 ){
    					$ss = "select * from ebay_lishicalcfee where name = 'Global Mail' and orderid ='$ebayid' ";
    				}else{
    					$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name = 'FedEx' order by value asc ";
    				}
    			}else
    			if ($ebay_countryname!='Italia'){
    				if ($shippment_fedex_directly===true){
    					$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name = 'FedEx' order by value asc ";			
    				}else
    				if(in_array($g_account, array('cndirect55','futurestar99','easydeal365','cndirect998'))){
    					if($shippment_cptohkpost === true || $shippment_hkpost_directly === true || count($array_intersect_BuiltinBattery) > 0 || count($array_intersect_Paste) > 0){
    						$ss = "select * from ebay_lishicalcfee where name = 'Global Mail' and orderid ='$ebayid' ";
    					}else{
    						if($ebay_total > 40 ){
    							$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name ='中国邮政挂号' order by value asc ";
    						}else{
    							$ss 	= "select * from ebay_lishicalcfee where orderid ='$ebayid' and value != '0' and name ='中国邮政平邮' order by value asc ";	
    						}
    					}
    				}else{
    					$ss = "select * from ebay_lishicalcfee where name = 'Global Mail' and orderid ='$ebayid' ";	
    				}
    			}else{
    				$ss = "select * from ebay_lishicalcfee where name = 'Global Mail' and orderid ='$ebayid' ";
    			}
    			$ss		= $dbConn->query($ss);
    			$ss		= $dbConn->fetch_array_all($ss);
    		}*/
    if (in_array($g_account, array('enjoytrade99', 'allbestforu', 'freemart21cn', 'easydealhere')) && in_array($ebay_countryname, array('Deutschland', 'Frankreich', 'Spanien', 'Italien', 'Allemagne', 'France', 'Espagne', 'Italie', 'Alemania', 'Francia', 'España', 'Italia', 'Germania', 'Francia', 'Spagna', 'Italia'))) {
        $ss = "select * from ebay_lishicalcfee where name = 'Global Mail' and orderid ='{$ebayid}' ";
        $ss = $dbConn->query($ss);
        $ss = $dbConn->fetch_array_all($ss);
    } else {
        ##############FedEx(包含单个超重料号或者贵重SKU)#############START
        if ($shippment_fedex_directly === true) {
            $ss = "select * from ebay_lishicalcfee where orderid ='{$ebayid}' and value != '0' and name = 'FedEx' order by value asc ";
            $ss = $dbConn->query($ss);
            $ss = $dbConn->fetch_array_all($ss);
        } else {
            /*
             *(陈小霞)2013-08-31 09:44:11
             *帮忙设置下这两个账号总金额(价格+运费)超过5的,发往美国和波多黎各的,改为EUB发货:mysoulfor,newcandy789
             *雷贤容 加上 estore456
             */
            if (in_array($ebay_countryname, array('United States', 'US', 'Puerto Rico')) && $ebay_total >= 5 && in_array($g_account, array('mysoulfor', 'newcandy789', 'estore456'))) {
                $ss = "select * from ebay_lishicalcfee where name = 'EUB' and orderid ='{$ebayid}' ";
                $ss = $dbConn->query($ss);
                $ss = $dbConn->fetch_array_all($ss);
            } else {
                ##############EUB(EBAY US 站点)#############START
                if ($ff == 1 && ($ebay_countryname == 'United States' || $ebay_countryname == 'US')) {
                    $ss = "select * from ebay_lishicalcfee where name = 'EUB' and orderid ='{$ebayid}' ";
                    $ss = $dbConn->query($ss);
                    $ss = $dbConn->fetch_array_all($ss);
                } else {
                    /*
                     *(陈小霞)2013-09-06 09:44:11
                     *帮忙设置下这些账号的Russian Federation,Russia,Brazil,Brasil,Argentina三个国家总金额超过8的,设置挂号发货,其他账号或者其他国家仍然跟以前一样,中国邮政超过40挂号,香港小包超过70挂号
                     */
                    if (in_array($ebay_countryname, array('Russian Federation', 'Russia', 'Brazil', 'Brasil', 'Argentina')) && $ebay_total >= 8 && in_array($g_account, array('365digital', 'digitalzone88', 'itshotsale77', 'cndirect998', 'cndirect55', 'befdi', 'easydeal365', 'enicer', 'doeon', 'starangle88', 'zealdora', '360beauty', 'befashion', 'charmday88', 'dresslink', 'easebon', 'work4best', 'eshop2098', 'happydeal88', 'easytrade2099', 'easyshopping678', 'futurestar99', 'wellchange', 'voguebase55')) && in_array($ebay_currency, array('GBP', 'USD', 'EUR'))) {
                        if ($shippment_cptohkpost === true || $shippment_hkpost_directly === true || count($array_intersect_Paste) > 0) {
                            //if($shippment_cptohkpost === true || $shippment_hkpost_directly === true || count($array_intersect_BuiltinBattery) > 0 || count($array_intersect_Paste) > 0){ //20130905内置电池不走香港小包
                            if ($ebay_total >= 70) {
                                $ss = "select * from ebay_lishicalcfee where orderid ='{$ebayid}' and value != '0' and name ='香港小包挂号' order by value asc ";
                            } else {
                                $ss = "select * from ebay_lishicalcfee where orderid ='{$ebayid}' and value != '0' and name = '香港小包平邮' order by value asc ";
                            }
                        } else {
                            $ss = "select * from ebay_lishicalcfee where orderid ='{$ebayid}' and value != '0' and name ='中国邮政挂号' order by value asc ";
                        }
                        $ss = $dbConn->query($ss);
                        $ss = $dbConn->fetch_array_all($ss);
                    } else {
                        if ($shippment_cptohkpost === true || $shippment_hkpost_directly === true || count($array_intersect_Paste) > 0) {
                            //if($shippment_cptohkpost === true || $shippment_hkpost_directly === true || count($array_intersect_BuiltinBattery) > 0 || count($array_intersect_Paste) > 0){ //20130905内置电池不走香港小包
                            if ($ebay_total >= 70) {
                                $ss = "select * from ebay_lishicalcfee where orderid ='{$ebayid}' and value != '0' and name ='香港小包挂号' order by value asc ";
                            } else {
                                $ss = "select * from ebay_lishicalcfee where orderid ='{$ebayid}' and value != '0' and name = '香港小包平邮' order by value asc ";
                            }
                        } else {
                            if ($ebay_total > 40) {
                                $ss = "select * from ebay_lishicalcfee where orderid ='{$ebayid}' and value != '0' and name ='中国邮政挂号' order by value asc ";
                            } else {
                                $ss = "select * from ebay_lishicalcfee where orderid ='{$ebayid}' and value != '0' and name ='中国邮政平邮' order by value asc ";
                            }
                        }
                        $ss = $dbConn->query($ss);
                        $ss = $dbConn->fetch_array_all($ss);
                    }
                }
            }
        }
    }
    $ssname = $ss[0]['name'];
    $value = $ss[0]['value'];
    echo "最终使用:{$ssname}---{$value}\n";
    $totalweight = $ss[0]['totalweight'];
    if ($totalweight == 0) {
        $ssname = "中国邮政平邮";
    }
    //当可能出现总重量为零的情况下将运输方式设置为中国邮政平邮 add by Herman.Xi 2012-11-01
    $data = array();
    $data[0] = $ssname;
    $data[1] = $value;
    $data[2] = $totalweight;
    return $data;
}
Example #2
0
function calctrueshippingfee($carrier, $totalweight, $countryname, $orderid)
{
    switch ($carrier) {
        case '香港小包平邮':
            $ordershipfee = calchkpost($totalweight, $countryname);
            break;
        case '香港小包挂号':
            $ordershipfee = calchkghpost($totalweight, $countryname);
            break;
        case '中国邮政平邮':
            $ordershipfee = calcchinapostpy($totalweight, $countryname, false);
            break;
        case '中国邮政挂号':
            $ordershipfee = calcchinapostgh($totalweight, $countryname, false);
            break;
        case 'EUB':
            $ordershipfee = calceub($totalweight, $countryname, false);
            break;
        case 'EMS':
            $ordershipfee = calcems($totalweight, $countryname);
            break;
        case 'FedEx':
            $ordershipfee = calcfedex($totalweight, $countryname, $orderid);
            break;
        case 'Global Mail':
            $ordershipfee = calcglobalmail($totalweight, $countryname);
            break;
        case 'DHL':
            $ordershipfee = calcdhlshippingfee($totalweight, $countryname);
            break;
        default:
            $ordershipfee = 0;
    }
    return $ordershipfee;
}
Example #3
0
function calctrueshippingfee($carrier, $totalweight, $countryname, $orderid)
{
    switch ($carrier) {
        case '香港小包平邮':
            $ordershipfee = calchkpost($totalweight, $countryname);
            break;
        case '香港小包挂号':
            $ordershipfee = calchkghpost($totalweight, $countryname);
            break;
        case '中国邮政平邮':
            $ordershipfee = calcchinapostpy($totalweight, $countryname, false);
            break;
        case '中国邮政挂号':
            $ordershipfee = calcchinapostgh($totalweight, $countryname, false);
            break;
        case 'EUB':
            $ordershipfee = calceub($totalweight, $countryname, false);
            break;
        case 'EMS':
            $ordershipfee = calcems($totalweight, $countryname);
            break;
            /*case 'FedEx' : $ordershipfee = calcfedex($totalweight,$countryname,$orderid);
            		break;*/
        /*case 'FedEx' : $ordershipfee = calcfedex($totalweight,$countryname,$orderid);
        		break;*/
        case 'Global Mail':
            $ordershipfee = calcglobalmail($totalweight, $countryname);
            break;
        case 'DHL':
            $ordershipfee = calcdhlshippingfee($totalweight, $countryname);
            break;
        case 'UPS美国专线':
            $ordershipfee = calcupsus($totalweight, $countryname);
            break;
        case 'USPS FirstClass':
        case 'UPS SurePost':
        case 'UPS Ground Commercia':
            $ordershipfee = trans_carriers_fix_get($carrier, $totalweight, $countryname, $zipCode, $transitId);
            break;
        case 'FedEx':
        case '俄速通挂号':
        case '俄速通平邮':
        case '新加坡DHL GM平邮':
        case '新加坡DHL GM挂号':
        case '俄速通大包':
        case '瑞士小包平邮':
        case '瑞士小包挂号':
            $ordershipfee = trans_carriers_fix_get($carrier, $totalweight, $countryname);
            break;
        default:
            $ordershipfee = 0;
    }
    if (in_array($carrier, array('瑞士小包平邮', '瑞士小包挂号', 'USPS FirstClass', 'UPS SurePost', 'UPS Ground Commercia', '俄速通大包', '新加坡DHL GM平邮', '新加坡DHL GM挂号', 'FedEx', '俄速通挂号', '俄速通平邮'))) {
        $ordershipfee = $ordershipfee['totalFee'];
    }
    return $ordershipfee;
}