Model_weight.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. class Model_weight extends Lin_Model
  3. {
  4. function __construct(){
  5. parent::__construct();
  6. $this->load->database();
  7. $this->table = 'weight';
  8. $this->load_table('weight');
  9. }
  10. /** 通过类目查找 */
  11. public function get_category($category)
  12. {
  13. return $this->find("category = '$category'");
  14. }
  15. /** 通过长度查找 */
  16. public function get_size($size)
  17. {
  18. return $this->find("size = '$size'");
  19. }
  20. /** 通过等级查找 */
  21. public function get_grade($grade)
  22. {
  23. return $this->find("grade = '$grade'");
  24. }
  25. /** 通过花型查找 */
  26. public function get_lowe($lowe)
  27. {
  28. return $this->find("lowe = '$lowe'");
  29. }
  30. /** 通过颜色查找 */
  31. public function get_color($color)
  32. {
  33. return $this->find("color = '$color'");
  34. }
  35. /** 通过重量查找 */
  36. public function get_weight($weight)
  37. {
  38. return $this->find("weight = '$weight'");
  39. }
  40. /** 通过等级查找 */
  41. public function get_sku($sku)
  42. {
  43. return $this->find("sku = '$sku'");
  44. }
  45. /** 通过拼接的数据ID查找 */
  46. public function get_features($features)
  47. {
  48. return $this->find("features = '$features'");
  49. }
  50. public function get_title($title)
  51. {
  52. return $this->find("title = '$title'");
  53. }
  54. public function get_weightcx($fpdata)
  55. {
  56. $weight = 0;
  57. $fpdataweight = str_replace(array('-163-','-164-','-165-','-166-'),'-',$fpdata);
  58. $list = $fpdataweight;
  59. $list = explode(';',trim($list,';'));
  60. foreach ($list as $vv)
  61. {
  62. $asd = explode('|',trim($vv,'|'));
  63. $c = explode(',',trim($asd[0],','));
  64. if(!isset($c[1]))
  65. {
  66. continue;
  67. }
  68. else
  69. {
  70. $dweight = $this->get_cc($c);
  71. $weight += $dweight*$asd[2];
  72. }
  73. }
  74. return $weight;
  75. }
  76. public function get_cc($c)
  77. {
  78. $weight = 0;
  79. $sj = explode('-',trim($c[1],'-'));
  80. $tc = array();
  81. $typeclass = $this->typeclass->find_all();
  82. foreach ($typeclass as $v)
  83. {
  84. $tc[$v['id']] = $v;
  85. }
  86. foreach ($sj as $k=>$v)
  87. {
  88. if(isset($tc[$v]))
  89. {
  90. if($tc[$v]['classid'] == 40 || $tc[$v]['classid'] == 43 || $tc[$v]['classid'] == 47)
  91. {
  92. unset($sj[$k]);
  93. }
  94. }
  95. }
  96. $ttpx = array('128'=>'','18'=>'','14'=>'','10'=>'');
  97. if(($sj[0] == 127 && !isset($sj[7])) || ($sj[0] == 128 && !isset($sj[6])))
  98. {
  99. }
  100. else
  101. {
  102. $features = '';
  103. if($sj[0] == 126)
  104. {
  105. $features = $sj[0];
  106. }
  107. else if($sj[0] == 127)
  108. {
  109. $features = $sj[0].'-'.$sj[7].'-'.$c[0];
  110. }
  111. else if($sj[0] == 128)
  112. {
  113. $sj[] = $c[0];
  114. foreach ($sj as $v)
  115. {
  116. if(isset($tc[$v]) && isset($ttpx[$tc[$v]['classid']]))
  117. {
  118. $ttpx[$tc[$v]['classid']] = $v;
  119. }
  120. }
  121. $features = '128'.implode("-",$ttpx);
  122. }
  123. else if($sj[0] == 133)
  124. {
  125. $features = $sj[0].'-'.$sj[4].'-'.$c[0];
  126. }
  127. else if($sj[0] == 130)
  128. {
  129. $features = $sj[0].'-'.$sj[2].'-'.$c[0];
  130. }
  131. if($features)
  132. {
  133. $data = $this->get_features($features);
  134. if($data)
  135. {
  136. $weight = $data['weight'];
  137. }
  138. }
  139. }
  140. return $weight;
  141. }
  142. public function get_cx($c)
  143. {
  144. $weight = 0;
  145. $sj = explode('-',trim($c[1],'-'));
  146. $tc = array();
  147. $typeclass = $this->typeclass->find_all();
  148. foreach ($typeclass as $v)
  149. {
  150. $tc[$v['id']] = $v;
  151. }
  152. foreach ($sj as $k=>$v)
  153. {
  154. if($tc[$v]['classid'] == 43)
  155. {
  156. unset($sj[$k]);
  157. }
  158. }
  159. if(($sj[0] == 127 && !isset($sj[7])) || ($sj[0] == 128 && !isset($sj[6])))
  160. {
  161. }
  162. else
  163. {
  164. $features = '';
  165. if($sj[0] == 126)
  166. {
  167. $features = $sj[0];
  168. }
  169. else if($sj[0] == 127)
  170. {
  171. $features = $sj[0].'-'.$sj[7].'-'.$c[0];
  172. }
  173. else if($sj[0] == 128)
  174. {
  175. $features = $sj[0].'-'.$sj[4].'-'.$c[0].'-'.$sj[6];
  176. }
  177. else if($sj[0] == 133)
  178. {
  179. $features = $sj[0].'-'.$sj[4].'-'.$c[0];
  180. }
  181. else if($sj[0] == 130)
  182. {
  183. $features = $sj[0].'-'.$sj[2].'-'.$c[0];
  184. }
  185. if($features)
  186. {
  187. $data = $this->weight->get_features($features);
  188. if($data)
  189. {
  190. $weight = $data['weight'];
  191. }
  192. }
  193. }
  194. return $weight;
  195. }
  196. } //end class