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