| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 | 
							- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
 
- class Model_weight extends Lin_Model 
 
- {
 
- 	function __construct(){
 
- 	parent::__construct();
 
- 	$this->load->database();
 
- 	$this->table = 'weight';
 
-     $this->load_table('weight');
 
- }
 
-     /** 通过类目查找 */
 
- 	public function get_category($category)
 
- 	{
 
- 		return  $this->find("category = '$category'");	
 
- 	}
 
- 	/** 通过长度查找 */
 
- 	public function get_size($size)
 
- 	{
 
- 		return  $this->find("size = '$size'");	
 
- 	}
 
- 	/** 通过等级查找 */
 
- 	public function get_grade($grade)
 
- 	{
 
- 		return  $this->find("grade = '$grade'");	
 
- 	}
 
- 	/** 通过花型查找 */
 
- 	public function get_lowe($lowe)
 
- 	{
 
- 		return  $this->find("lowe = '$lowe'");	
 
- 	}
 
- 	/** 通过颜色查找 */
 
- 	public function get_color($color)
 
- 	{
 
- 		return  $this->find("color = '$color'");	
 
- 	}
 
- 	/** 通过重量查找 */
 
- 	public function get_weight($weight)
 
- 	{
 
- 		return  $this->find("weight = '$weight'");	
 
- 	}
 
- 	/** 通过等级查找 */
 
- 	public function get_sku($sku)
 
- 	{
 
- 		return  $this->find("sku = '$sku'");
 
- 	}
 
- 	 /** 通过拼接的数据ID查找 */
 
- 	public function get_features($features)
 
- 	{
 
- 		return  $this->find("features = '$features'");	
 
- 	}
 
- 	public function get_title($title)
 
- 	{
 
- 		return  $this->find("title = '$title'");	
 
- 	}
 
- 	
 
- 	public function get_weightcx($fpdata)
 
- 	{
 
- 		$weight = 0;
 
- 		$fpdataweight = str_replace(array('-163-','-164-','-165-','-166-'),'-',$fpdata);
 
-         $list = $fpdataweight;
 
- 		$list = explode(';',trim($list,';'));
 
- 		foreach ($list as $vv)
 
- 		{
 
- 			$asd = explode('|',trim($vv,'|'));
 
- 			$c = explode(',',trim($asd[0],','));
 
- 			if(!isset($c[1]))
 
- 			{
 
- 				continue;
 
- 			}
 
- 			else
 
- 			{
 
- 				$dweight = $this->get_cc($c);
 
- 				$weight += $dweight*$asd[2];
 
- 			}
 
- 		}
 
- 		return  $weight;
 
-    }
 
-    
 
-    public function get_cc($c)
 
- 	{
 
- 		$weight = 0;
 
- 		$sj = explode('-',trim($c[1],'-'));
 
- 		$tc = array();
 
- 		$typeclass = $this->typeclass->find_all();
 
- 		foreach ($typeclass as $v)
 
- 		{
 
- 			$tc[$v['id']] = $v;
 
-         }
 
- 		foreach ($sj as $k=>$v)
 
- 		{
 
- 			if(isset($tc[$v]))
 
- 			{
 
- 				if($tc[$v]['classid'] == 40 || $tc[$v]['classid'] == 43 || $tc[$v]['classid'] == 47)
 
- 				{
 
- 					unset($sj[$k]);
 
- 				}
 
- 			}
 
-         }
 
- 		$ttpx = array('128'=>'','18'=>'','14'=>'','10'=>'');
 
- 		if(($sj[0] == 127 && !isset($sj[7])) || ($sj[0] == 128 && !isset($sj[6])))
 
- 		{
 
- 			
 
- 		}
 
- 		else
 
- 		{
 
- 			$features = '';
 
- 		    if($sj[0] == 126)
 
-             {
 
- 			    $features = $sj[0];
 
- 		    }
 
- 		    else if($sj[0] == 127)
 
-             {
 
- 			    $features = $sj[0].'-'.$sj[7].'-'.$c[0];
 
- 		    }
 
- 		    else if($sj[0] == 128)
 
-             {
 
- 				$sj[] = $c[0];
 
- 			    foreach ($sj as $v)
 
- 				{
 
- 					if(isset($tc[$v]) && isset($ttpx[$tc[$v]['classid']]))
 
- 					{
 
- 						$ttpx[$tc[$v]['classid']] = $v;
 
- 					}
 
-         		}
 
- 				$features = '128'.implode("-",$ttpx);
 
- 		    }
 
- 		    else if($sj[0] == 133)
 
-             {
 
- 			    $features = $sj[0].'-'.$sj[4].'-'.$c[0];
 
- 		    }
 
- 			else if($sj[0] == 130)
 
-             {
 
- 			    $features = $sj[0].'-'.$sj[2].'-'.$c[0];
 
- 		    }
 
- 			if($features)
 
- 			{
 
- 		        $data = $this->get_features($features);
 
- 		        if($data)
 
- 		        {
 
- 			        $weight = $data['weight'];
 
- 		        }
 
- 			}
 
- 		}
 
- 		return  $weight;
 
- 	}
 
- 	
 
- 	
 
- 	public function get_cx($c)
 
- 	{
 
- 		$weight = 0;
 
- 		$sj = explode('-',trim($c[1],'-'));
 
- 		$tc = array();
 
- 		$typeclass = $this->typeclass->find_all();
 
- 		foreach ($typeclass as $v)
 
- 		{
 
- 			$tc[$v['id']] = $v;
 
-         }
 
- 		foreach ($sj as $k=>$v)
 
- 		{
 
- 			if($tc[$v]['classid'] == 43)
 
- 			{
 
- 				unset($sj[$k]);
 
- 			}
 
-         }
 
- 		if(($sj[0] == 127 && !isset($sj[7])) || ($sj[0] == 128 && !isset($sj[6])))
 
- 		{
 
- 			
 
- 		}
 
- 		else
 
- 		{
 
- 			$features = '';
 
- 		    if($sj[0] == 126)
 
-             {
 
- 			    $features = $sj[0];
 
- 		    }
 
- 		    else if($sj[0] == 127)
 
-             {
 
- 			    $features = $sj[0].'-'.$sj[7].'-'.$c[0];
 
- 		    }
 
- 		    else if($sj[0] == 128)
 
-             {
 
- 			    $features = $sj[0].'-'.$sj[4].'-'.$c[0].'-'.$sj[6];
 
- 		    }
 
- 		    else if($sj[0] == 133)
 
-             {
 
- 			    $features = $sj[0].'-'.$sj[4].'-'.$c[0];
 
- 		    }
 
- 			else if($sj[0] == 130)
 
-             {
 
- 			    $features = $sj[0].'-'.$sj[2].'-'.$c[0];
 
- 		    }
 
- 			if($features)
 
- 			{
 
- 		        $data = $this->weight->get_features($features);
 
- 		        if($data)
 
- 		        {
 
- 			        $weight = $data['weight'];
 
- 		        }
 
- 			}
 
- 		}
 
- 		return  $weight;
 
- 	}
 
- }  //end class
 
 
  |