lvhao 4 miesięcy temu
rodzic
commit
6fd03a200e

+ 67 - 0
core/CoreApp/models/Model_logic_weight.php

@@ -0,0 +1,67 @@
+<?php
+/**
+ * 此处是设定erp重量的标准   以后获取重量都尽量通过这去获取重量 以前的代码还是通过以前的方案
+ */
+class Model_logic_weight extends Lin_Model {
+   
+    //切记要修改token_120的token真正的token!!!!
+    function __construct(){
+        parent::__construct();
+        $this->load->_model('Model_weight','weight');
+    }
+    /**
+     * $type erp类目 如 126 127 128
+     */
+    public function getWeightByFeature($type,$features){
+        if(empty($type)){
+            return 0;
+        }
+        $sku = []; 
+        if($type == 126){
+            return  100;
+        }
+        //类目 蕾丝尺寸  长度
+        if($type == 127){
+            //发块
+            $flag = true;
+            foreach($features as $v){
+                if($v['classid'] == 26){
+                    $flag = false;
+                }
+            }
+            if($flag){
+                //蕾丝尺寸1
+                $sku = ['16'=>127,'25'=>0,'14'=>0];
+            }else{
+                //蕾丝尺寸2
+                $sku = ['16'=>127,'26'=>0,'14'=>0];
+            }
+        }
+        //类目 头套类型  尺寸   密度
+        if($type == 128){
+            //头套类型
+            $sku = ['16'=>128,'18'=>0,'14'=>0,'10'=>0];
+        }
+        //类目 尺寸
+        if($type == 130){
+            //接发类型
+            $sku = ['16'=>130,'33'=>0,'14'=>0];
+        }
+
+        foreach($features as $k => $v){
+            if(isset($sku[$v['classid']])){
+                $sku[$v['classid']] = $v['id'];
+            }
+
+        }
+
+        $sku_str = implode("-",$sku);
+
+        $weight_info = $this->weight->get_features($sku_str);
+        if(empty($weight_info)){
+            return 0;
+        }else{
+            return $weight_info['weight'];
+        }
+    }
+}

+ 86 - 0
core/CoreApp/models/Model_logic_whlabel.php

@@ -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);
+    }
+}