Model_logic_whlabel.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * 协助处理库存相关的数据处理小工具类
  4. */
  5. class Model_logic_whlabel extends Lin_Model {
  6. function __construct(){
  7. parent::__construct();
  8. $this->load->_model('Model_typeclass','typeclass');
  9. $this->load->_model('Model_classid','classid');
  10. $this->load->_model('Model_logic_weight','logic_weight');
  11. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  12. }
  13. protected $pmList = [];//品名匹配的数据
  14. protected $pm = [];
  15. protected $weightList = [];//重量匹配的数据
  16. //转化数组中需要变动的参数
  17. /**
  18. * $list 要转化的数组
  19. * $condition 要处理的条件 $column 要转化的字段 $zhinfo 要转化字段的处理方法
  20. */
  21. public function dataTran($list,$condition){
  22. foreach($condition as $v){
  23. if($v == 'pm' ){
  24. $this->pmData();
  25. }
  26. }
  27. if(in_array('pm',$condition)){
  28. $classid = $this->pm;
  29. $typeclass = $this->pmList;
  30. }
  31. foreach($list as $k=>$v){
  32. if(in_array('pm',$condition)){
  33. $r = $this->logic_u9tools->getOneU9bmHasGift($v['features'],$classid,$typeclass);
  34. $list[$k]['pm'] = $r['zh'];
  35. $list[$k]['jm'] = $r['jm'];
  36. $list[$k]['bm'] = $r['bm'];
  37. }
  38. if(in_array('weight',$condition)){
  39. $list[$k]['weight'] = $this->getWeight($v['features']);
  40. }
  41. }
  42. return $list;
  43. }
  44. protected function pmData(){
  45. $typeclass = $this->typeclass->find_all();
  46. $t = [];
  47. foreach ($typeclass as $v)
  48. {
  49. $t[$v['id']] = $v;
  50. }
  51. $this->pmList = $t;
  52. $this->pm = $this->classid->sku();
  53. }
  54. protected function getPm($features){
  55. $t = $this->pmList;
  56. $pm = $this->pm;
  57. $features = explode('-',trim($features,'-'));
  58. foreach($features as $v)
  59. {
  60. $zh = explode('|',trim($t[$v]['zh'],'|'));
  61. $pm[$t[$v]['classid']] = $zh[0];
  62. }
  63. $zh = implode(" ",$pm);
  64. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  65. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  66. return $zh;
  67. }
  68. protected function getWeight($features){
  69. $features = explode("-",trim($features,"-"));
  70. $type = 0;
  71. if(in_array(126,$features)){
  72. $type = 126;
  73. }
  74. if(in_array(127,$features)){
  75. $type = 127;
  76. }
  77. if(in_array(128,$features)){
  78. $type = 128;
  79. }
  80. if(in_array(130,$features)){
  81. $type = 130;
  82. }
  83. $tmp_features = [];
  84. $t = $this->pmList;
  85. foreach($features as $v){
  86. if(isset($t[$v])){
  87. $tmp_features[] = $t[$v];
  88. }
  89. }
  90. return $this->logic_weight->getWeightByFeature($type,$tmp_features);
  91. }
  92. }