|
@@ -0,0 +1,86 @@
|
|
|
+<?php
|
|
|
+/**
|
|
|
+ * 协助处理库存相关的数据处理小工具类
|
|
|
+ */
|
|
|
+class Model_logic_whlabel extends Lin_Model {
|
|
|
+ function __construct(){
|
|
|
+ parent::__construct();
|
|
|
+ $this->load->_model('Model_typeclass','typeclass');
|
|
|
+ $this->load->_model('Model_classid','classid');
|
|
|
+ $this->load->_model('Model_logic_weight','logic_weight');
|
|
|
+ }
|
|
|
+
|
|
|
+ protected $pmList = [];//品名匹配的数据
|
|
|
+ protected $pm = [];
|
|
|
+ protected $weightList = [];//重量匹配的数据
|
|
|
+ //转化数组中需要变动的参数
|
|
|
+
|
|
|
+ /**
|
|
|
+ * $list 要转化的数组
|
|
|
+ * $condition 要处理的条件 $column 要转化的字段 $zhinfo 要转化字段的处理方法
|
|
|
+ */
|
|
|
+ public function dataTran($list,$condition){
|
|
|
+ foreach($condition as $v){
|
|
|
+ if($v['zhinfo'] == 'pm'){
|
|
|
+ $this->pmData();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach($list as $k=>$v){
|
|
|
+ if($v['zhinfo'] == 'pm'){
|
|
|
+ $list[$k]['pm'] = $this->getPm($v['features']);
|
|
|
+ }
|
|
|
+ if($v['zhinfo'] == 'weight'){
|
|
|
+ $list[$k]['weight'] = $this->getPm($v['features']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ protected function pmData(){
|
|
|
+ $typeclass = $this->typeclass->find_all();
|
|
|
+ $t = [];
|
|
|
+ foreach ($typeclass as $v)
|
|
|
+ {
|
|
|
+ $t[$v['id']] = $v;
|
|
|
+ }
|
|
|
+ $this->pmList = $t;
|
|
|
+ $this->pm = $this->classid->sku();
|
|
|
+ }
|
|
|
+ protected function getPm($features){
|
|
|
+ $t = $this->pmList;
|
|
|
+ $pm = $this->pm;
|
|
|
+ $features = explode('-',trim($features,'-'));
|
|
|
+ foreach($features as $v)
|
|
|
+ {
|
|
|
+ $zh = explode('|',trim($t[$v]['zh'],'|'));
|
|
|
+ $pm[$t[$v]['classid']] = $zh[0];
|
|
|
+ }
|
|
|
+ $zh = implode(" ",$pm);
|
|
|
+ $zh = str_replace('自然色 ','',rtrim($zh,' '));
|
|
|
+ $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
|
|
|
+
|
|
|
+ return $zh;
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function getWeight($features){
|
|
|
+ $features = explode("-",trim($features,"-"));
|
|
|
+
|
|
|
+ $type = 0;
|
|
|
+ if(in_array(126,$features)){
|
|
|
+ $type = 126;
|
|
|
+ }
|
|
|
+ if(in_array(127,$features)){
|
|
|
+ $type = 127;
|
|
|
+ }
|
|
|
+ if(in_array(128,$features)){
|
|
|
+ $type = 128;
|
|
|
+ }
|
|
|
+ if(in_array(130,$features)){
|
|
|
+ $type = 130;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->logic_weight->getWeightByFeature($type,$features);
|
|
|
+ }
|
|
|
+}
|