Browse Source

添加美仓的替换功能

lvhao 2 days ago
parent
commit
d3c46ecc23

+ 20 - 0
core/CoreApp/controllers/Ck.php

@@ -8,6 +8,8 @@ class Ck extends Start_Controller {
 		$this->load->_model('Model_whlabel','whlabel');
 		$this->load->_model('Model_typeclass','typeclass');
 		$this->load->_model('Model_whlabel_fc','whlabel_fc');
+		$this->load->_model("Model_logic_goods_replace","logic_goods_replace");
+		$this->load->_model("Model_logic_tools","logic_tools");
 	}
 	//定义方法的调用规则 获取URI第二段值
     public function _remap($arg,$arg_array)
@@ -16,11 +18,29 @@ class Ck extends Start_Controller {
         {
              $this->_kcyz();
         }
+		elseif($arg == 'mcth'){
+			$this->_mcth();
+		}
 		else
 		{
 			 $this->_index();
 		}
     }
+	private function _index(){
+		exit('No direct script access allowed');
+	}
+
+	private function _mcth(){
+		$post = $this->input->post(NULL, TRUE);
+		if(empty($post['number'])){
+			exit($this->logic_tools->ret_json(-1,'订单编码不能为空'));
+		}
+		if(empty($post['fpdata'])){
+			exit($this->logic_tools->ret_json(-1,'订单产品信息为传递'));
+		}
+		$res = $this->logic_goods_replace->do_replace($post['number'],$post['fpdata']);
+		exit(json_encode($res));
+	}
 
 	public function _kcyz()
 	{

+ 192 - 0
core/CoreApp/models/Model_logic_goods_replace.php

@@ -0,0 +1,192 @@
+<?php
+/**
+ * 对接crm接口
+ */
+class Model_logic_goods_replace extends Lin_Model {
+    function __construct(){
+        parent::__construct();
+        $this->load->_model("Model_whlabel","logic_whlabel");
+        $this->load->_model("Model_logic_u9tools","logic_u9tools");
+        $this->load->_model("Model_logic_zhlp","logic_zhlp");
+    }
+    private $goods_replace_rules = [
+        "-1253-","-1255-","-1323-","-1257-"
+    ];
+    /**
+     * 获取真人发类型   如果编码存在真人发类型 那么会将字段加入到第3   没有就放到了第2
+     */
+    private function getHairType($type = 0){
+        if($type == 1){
+            return [
+                163,164,165,166,2090,2469,1620,2480,2526
+            ];
+        }else{
+            return [
+                '-163-','-164-','-165-','-166-','-2090-','-2469-','-1620-','-2480-','-2526-'
+            ];
+        }
+       
+       
+    }
+    public function do_replace($number,$fpdata){
+        $fpdata = trim($fpdata);
+        if(empty($fpdata)){
+            return [
+                "code"=>-1,
+                "msg"=>"没有检测到商品信息"
+            ];
+        }
+        $fpdata_date = explode(";",trim($fpdata,";"));
+        $fpdata_final_arr = [];
+        //先查询是否占单了  如果占单了 那么就 不处理  如果不存在那么就处理
+        foreach($fpdata_date as $k => $v){
+           $r = $this->checkAbleToReplace($v);
+           if($r){
+                $detail_arr = explode("|",$v);
+                $sku_str = $this->transferFeatures($detail_arr[0]);
+                //因为美仓是全占模式 所以不用逐个分析那几个产品是否占库存,有就是全站不处理  没有就替换 等保存的时候在进行处理
+                $ret_list = $this->whlabel->find_all(" state = 0 and zd = '".$number."' and features = '".$sku_str."' ");
+                if(count($ret_list) > 0){
+                    $fpdata_final_arr[] = $v;
+                }else{
+                    // $sku_list = [
+                    //     'sku2'=> $sku_str ,
+                    // ];
+                    // $goods_info = $this->logic_u9tools->getU9bm($sku_list,'sku2');
+                    $replace_sku_str = $this->replaceSku($detail_arr[0]);
+                    $l_sku_arr = explode("-",trim($replace_sku_str,'-'));
+                    $sku_sort_arr = $this->logic_zhlp->transferSku($l_sku_arr);
+                    if(empty($sku_sort_arr)){
+                        return [
+                            "code"=>-1,
+                            "msg"=>$detail_arr[1]."转换异常",
+                        ];
+                    }
+                    $res = $this->logic_zhlp->sortByClass($sku_sort_arr);
+                    if($res['code'] != 1){
+                        return $res ;
+                    }
+                   
+                    $final_sortsku_arr = $res['data'];
+                  
+                    $class_list = $this->logic_u9tools->getTypeClass();
+                    $en_title = "";
+                    foreach($final_sortsku_arr as $k => $v){
+                        if(isset($class_list[$v])){
+                            $en_title.= $class_list[$v]['title']." ";
+                        }
+                    }
+                    $en_title = trim($en_title);
+                    $cc = $final_sortsku_arr[14];
+                    unset($final_sortsku_arr[14]);
+                    $final_sku_str = $cc.",-".implode('-',$final_sortsku_arr)."-";
+                    $detail_arr[0] = $final_sku_str;
+                    $detail_arr[1] = $en_title;
+                    $v = implode("|",$detail_arr);
+                    $fpdata_final_arr[] = $v;
+                }
+           }else{
+                $fpdata_final_arr[] = $v;
+           }
+          
+        }
+        $fpdata_final_arr = array_filter($fpdata_final_arr);
+        return [
+            'code'=>1,
+            "msg"=>"ok",
+            'data'=>(implode(";",$fpdata_final_arr).";")
+       ];
+    }
+
+    public function replaceSku($str){
+       
+        foreach($this->goods_replace_rules as $rule){
+            if(strpos($str,$rule)!== false){
+                $replace_id = trim($rule,"-");
+                $do_replace_id = $this->replaceRule($replace_id);
+                $str = str_replace($rule,"-".$do_replace_id[0]."-",$str);
+            }
+        }
+        return $str;
+    }
+  
+       
+
+    //将erp带点的规格字符串 转化为 不带点的且将长度写的没问题的规格字符串
+    public function transferFeatures($str){
+        if(strpos($str,",") === false){
+            return $str;
+        }
+        $hair_type = $this->getHairType(1);
+        $tmp_arr = explode(",",trim($str,","));
+        $do_tmp_arr = explode("-",trim($tmp_arr[1],"-"));
+        $is_hair_type = false;
+        if(in_array($hair_type,$do_tmp_arr)){
+            $is_hair_type = true;
+        }
+        $final_fea_arr = [];
+        foreach($do_tmp_arr as $item => $value) {
+            if(!$is_hair_type && $item == 1){
+                $final_fea_arr[] = $value;
+                $final_fea_arr[] = $tmp_arr[0];
+            }else if($is_hair_type && $item == 2){
+                $final_fea_arr[] = $value;
+                $final_fea_arr[] = $tmp_arr[0];
+            }else{
+                $final_fea_arr[] = $value;
+            }
+             
+        }
+        $final_fea_arr = array_unique($final_fea_arr);
+        return "-".implode("-",$final_fea_arr)."-";
+    }
+
+    /**
+     * 检测是否有可以替换的商品
+     */
+    private function checkAbleToReplace($str){
+        $flag = false;
+        foreach($this->goods_replace_rules as $rule){
+            if(strpos($str,$rule)!== false){
+                $flag = true;
+            }
+        }
+        return $flag;
+    }
+
+
+
+
+
+
+
+
+
+    /**
+     * 规则1  4*7 Closure Wig  =》  5*7 Closure Wig           1253   =>    2062
+     * 规则2  HD 4*7 Closure Wig =》  HD 5*7 Closure Wig      1255   =>    2147
+     * 规则3  4*7 Bob Wig =》  5*7 Bob Wig                    1323   =>    2167
+     * 规则4  HD 4*7 Bob Wig =》  HD 5*7 Bob Wig              1257   =>    2434 
+     */
+
+     private function replaceRule($class_id){
+        $replace_arr = [
+            1253 => [
+                2062
+            ],
+            1255 => [
+                2147
+            ],
+            1323 => [
+                2167
+            ],
+            1257 => [
+                2434
+            ]
+        ];
+        if(isset($replace_arr[$class_id])){
+            return $replace_arr[$class_id];
+        }
+        return false;
+     }
+}

+ 20 - 0
core/CoreApp/models/Model_logic_u9tools.php

@@ -480,4 +480,24 @@ class Model_logic_u9tools extends Lin_Model {
         $post['type'] = 0;
         return $this->logic_tools->ret_arr(1,"ok",$post);
     }
+    //获取erp转化u9需要classid和typeclassid
+    public function getClass(){
+        $classid = $this->classid->sku();
+        return $classid;
+       
+    }
+    public function getTypeClass(){
+        $typeclass = [];
+        $tcall = $this->typeclass->find_all();
+        foreach ($tcall as $v)
+        {
+            //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
+            $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
+        }
+        return $typeclass;
+    }
+    //只针对创建u9料号 不牵扯到erp的sku组合
+    public function getU9Lp(){
+
+    }
 }

+ 340 - 0
core/CoreApp/models/Model_logic_zhlp.php

@@ -0,0 +1,340 @@
+<?php
+/**
+ * 此类就是为了针对erp的料品组合,以后都用这个类进行组合排序  将来后边需要转化erp的sku相关信息的时候 都调用这个类 到时间方便统一管理
+ * 前边已有的代码都不动了 稳定压倒一切!!!
+ * 目前erp有两种排序的方案  1 按照名称排序  2 按照规格的classid    
+ * 此类仅用于排序 后续的u9编写等 请到logic_u9tools中找对应的方法
+ * 其实如果真要搞成erp的那种插入长度排序的话 就记住 长度跟在等级后边
+ */
+class Model_logic_zhlp extends Lin_Model {
+    function __construct(){
+        parent::__construct();
+    }
+
+    public function sortByName($arr){
+        return $this->doAction(1,$arr);
+    }
+
+    public function sortByClass($arr){
+        return $this->doAction(2,$arr);
+    }
+    //根据已有的规格id 获取到对应主类id  转化为需要的规格序列
+    public function transferSku($arr){
+        $sku_list = $this->db->select('id,classid,classtitle,title')->from('typeclass')->where_in('id ',$arr)->get()->result_array();
+        $ret_final_list  = [];
+        foreach ($sku_list as $k => $v){
+            $ret_final_list[$v['classid']] = $v['id'];
+        }
+        return $ret_final_list;
+    }
+    //几种处理 排序的各种要求
+
+    private function doAction($type,$arr){
+        //1 除去真人发类型中的
+        if($type == 1){
+            if(isset($arr['hairtype']) && in_array($arr['hairtype'],[163,164,165,166])){
+                $arr['hairtype'] = 0;
+            }
+        }else{
+            if(isset($arr[22]) && in_array($arr[22],[163,164,165,166])){
+                $arr[22] = 0;
+            }
+        }
+        $ret_list = $this->chooseCate($type,$arr);
+        if(empty($ret_list)){
+           return [
+                'code'=>-1,
+                "msg"=>'没有找到对应的料品分类,请通知技术设置',
+           ];
+        }
+        $final_list = [];
+        foreach ($ret_list as $k => $v){
+            if(empty($v)){
+                continue;
+            }
+            $final_list[$k] = $v; 
+        }
+        return [
+            'code'=>1,
+            "msg"=>'ok',
+            'data'=>$final_list
+        ];
+    }
+
+    private function chooseCate($type,$arr){
+        if($type == 1){
+            $cate = $arr['category'];
+        }else{
+            $cate = $arr[16];
+        }
+        //发条
+        if($cate == 126){
+            return $this->fatiao($type,$arr);
+        }
+        //发块前头
+        if($cate == 127){
+            return $this->fakuai($type,$arr);
+        }
+        //头套
+        if($cate == 128){
+            return $this->toutao($type,$arr);
+        }   
+        //Hair Extension - 接发
+        if($cate == 130){
+            return $this->jiefa($type,$arr);
+        }
+        //Gift - 礼物
+        if($cate == 131){
+            return $this->liwu($type,$arr);
+        }
+        //Accessories - 配件
+        if($cate == 133){
+            return $this->peijian($type,$arr);
+        }
+        //Synthetic Wig - 化纤头套
+        if($cate == 1297){
+            return $this->huaqiantoutao($type,$arr);
+        }
+        //Synthetic Hair - 化纤其它
+        if($cate == 1702){
+            return $this->huaqianqita($type,$arr);
+        }
+
+        return [];
+
+    }
+    /*******************$type 1 代表名称  2 代表classid**************************/
+    //发条
+    private function fatiao($type,$arr){
+        if($type == 1){
+            return [
+                "category"=>empty($arr['category'])?0:$arr['category'],
+                "hairtype"=>empty($arr['hairtype'])?0:$arr['hairtype'],
+                "grade"=>empty($arr['grade'])?0:$arr['grade'],
+                "color"=>empty($arr['color'])?0:$arr['color'],
+                "lowe"=>empty($arr['lowe'])?0:$arr['lowe'],
+                "size"=>empty($arr['size'])?0:$arr['size'],
+            ];
+        }else{
+            return [
+                16=>empty($arr[16])?0:$arr[16],//类目
+                22=>empty($arr[22])?0:$arr[22],//真人发类型
+                13=>empty($arr[13])?0:$arr[13],//等 级
+                8=>empty($arr[8])?0:$arr[8],//头发颜色
+                15=>empty($arr[15])?0:$arr[15],//曲 度
+                14=>empty($arr[14])?0:$arr[14],//长 度
+            ];
+        }
+
+    }
+    //发块
+    private function fakuai($type,$arr){
+        //类型27 如果是195  Lace Closure - 发块  则类似尺寸 需要对应25   如果是197  Lace Frontal - 蕾丝前头  需要对应26
+        //都对应25 26 到时间过滤空
+        if($type == 1){
+            return [
+                "category"=>empty($arr['category'])?0:$arr['category'],
+                "hairtype"=>empty($arr['hairtype'])?0:$arr['hairtype'],
+                "grade"=>empty($arr['grade'])?0:$arr['grade'],
+                "color"=>empty($arr['color'])?0:$arr['color'],
+                "lowe"=>empty($arr['lowe'])?0:$arr['lowe'],
+                "type"=>empty($arr['type'])?0:$arr['type'],
+                "headroad"=>empty($arr['headroad'])?0:$arr['headroad'],
+                "density"=>empty($arr['density'])?0:$arr['density'],
+                'lacesize'=>empty($arr['lacesize'])?0:$arr['lacesize'],
+                'lacecolor'=>empty($arr['lacecolor'])?0:$arr['lacecolor'],
+                "lacetypes"=>empty($arr['lacetypes'])?0:$arr['lacetypes'],
+                "size"=>empty($arr['size'])?0:$arr['size'],
+            ];
+        }else{
+            return [
+                16=>empty($arr[16])?0:$arr[16],//类目
+                22=>empty($arr[22])?0:$arr[22],//真人发类型
+                13=>empty($arr[13])?0:$arr[13],//等 级
+                8=>empty($arr[8])?0:$arr[8],//头发颜色
+                15=>empty($arr[15])?0:$arr[15],//曲 度
+                27=>empty($arr[27])?0:$arr[27],//类 型
+                12=>empty($arr[12])?0:$arr[12],//头路设计
+                10=>empty($arr[10])?0:$arr[10],//密 度
+                //到时间会去重处理
+                25=>empty($arr[25])?0:$arr[25],//蕾丝尺寸
+                26=>empty($arr[26])?0:$arr[26],//蕾丝尺寸
+
+                9=>empty($arr[9])?0:$arr[9],//蕾丝颜色
+                44=>empty($arr[44])?0:$arr[44],//蕾丝类型
+                14=>empty($arr[14])?0:$arr[14],//长 度
+            ];
+        }
+
+    }
+    //头套
+    private function toutao($type,$arr){
+        if($type == 1){
+            return [
+                "category"=>empty($arr['category'])?0:$arr['category'],
+                "hairtype"=>empty($arr['hairtype'])?0:$arr['hairtype'],
+                "grade"=>empty($arr['grade'])?0:$arr['grade'],
+                "hairnumber"=>empty($arr['hairnumber'])?0:$arr['hairnumber'],
+                "color"=>empty($arr['color'])?0:$arr['color'],
+                "lowe"=>empty($arr['lowe'])?0:$arr['lowe'],
+                "lacetype"=>empty($arr['lacetype'])?0:$arr['lacetype'],
+                "haircap"=>empty($arr['haircap'])?0:$arr['haircap'],
+                "density"=>empty($arr['density'])?0:$arr['density'],
+                "lacecolor"=>empty($arr['lacecolor'])?0:$arr['lacecolor'],
+                "lacetypes"=>empty($arr['lacetypes'])?0:$arr['lacetypes'],
+                "wigother"=>empty($arr['wigother'])?0:$arr['wigother'],
+                "wigother1"=>empty($arr['wigother1'])?0:$arr['wigother1'],
+                "wigother2"=>empty($arr['wigother2'])?0:$arr['wigother2'],
+                "size"=>empty($arr['size'])?0:$arr['size'],
+            ];
+        }else{
+            return [
+                16=>empty($arr[16])?0:$arr[16],//类目
+                22=>empty($arr[22])?0:$arr[22],//真人发类型
+                13=>empty($arr[13])?0:$arr[13],//等 级
+                43=>empty($arr[43])?0:$arr[43],//人发头套编号
+                8=>empty($arr[8])?0:$arr[8],//头发颜色
+                15=>empty($arr[15])?0:$arr[15],//曲 度
+                18=>empty($arr[18])?0:$arr[18],//头套种类
+                6=>empty($arr[6])?0:$arr[6],//发帽大小
+                10=>empty($arr[10])?0:$arr[10],//密 度
+                9=>empty($arr[9])?0:$arr[9],//蕾丝颜色
+                44=>empty($arr[44])?0:$arr[44],//蕾丝类型
+                39=>empty($arr[39])?0:$arr[39],//分缝及刘海
+                50=>empty($arr[50])?0:$arr[50],//头套其它1
+                51=>empty($arr[51])?0:$arr[51],//头套其它2
+                14=>empty($arr[14])?0:$arr[14],//长 度
+            ];
+        }
+    }
+    //接发
+    private function jiefa($type,$arr){
+        if($type == 1){
+            return [
+                "category"=>empty($arr['category'])?0:$arr['category'],
+                "hairtype"=>empty($arr['hairtype'])?0:$arr['hairtype'],
+                "grade"=>empty($arr['grade'])?0:$arr['grade'],
+                "extension"=>empty($arr['extension'])?0:$arr['extension'],
+                "color"=>empty($arr['color'])?0:$arr['color'],
+                "lowe"=>empty($arr['lowe'])?0:$arr['lowe'],
+                "items"=>empty($arr['items'])?0:$arr['items'],
+                "weight"=>empty($arr['weight'])?0:$arr['weight'],
+                "size"=>empty($arr['size'])?0:$arr['size'],
+            ];
+        }else{
+            return [
+                16=>empty($arr[16])?0:$arr[16],//类目
+                22=>empty($arr[22])?0:$arr[22],//真人发类型
+                13=>empty($arr[13])?0:$arr[13],//等 级
+                33=>empty($arr[33])?0:$arr[33],//Extension类型
+                8=>empty($arr[8])?0:$arr[8],//头发颜色
+                15=>empty($arr[15])?0:$arr[15],//曲 度
+                38=>empty($arr[38])?0:$arr[38],//单片片数
+                7=>empty($arr[7])?0:$arr[7],//重量
+                14=>empty($arr[14])?0:$arr[14],//长 度
+            ];
+        }
+    }
+    //礼物
+    private function liwu($type,$arr){
+        if($type == 1){
+            return [
+                "category"=>empty($arr['category'])?0:$arr['category'],
+                "gifttype"=>empty($arr['gifttype'])?0:$arr['gifttype'],
+                "giftother"=>empty($arr['giftother'])?0:$arr['giftother'],
+            ];
+        }else{
+            return [
+                16=>empty($arr[16])?0:$arr[16],//类目
+                34=>empty($arr[34])?0:$arr[34],//礼物类型
+                49=>empty($arr[49])?0:$arr[49],//礼物其它
+            ];
+        }
+
+    }
+    //配件
+    private function peijian($type,$arr){
+        if($type == 1){
+            return [
+                "category"=>empty($arr['category'])?0:$arr['category'],
+                "grade"=>empty($arr['grade'])?0:$arr['grade'],
+                "fittype"=>empty($arr['fittype'])?0:$arr['fittype'],
+                "acother"=>empty($arr['acother'])?0:$arr['acother'],
+                "color"=>empty($arr['color'])?0:$arr['color'],
+                "lowe"=>empty($arr['lowe'])?0:$arr['lowe'],
+                "items"=>empty($arr['items'])?0:$arr['items'],
+                "weight"=>empty($arr['weight'])?0:$arr['weight'],
+                'size'=>empty($arr['size'])?0:$arr['size'],
+            ];
+        }else{
+            return [
+                16=>empty($arr[16])?0:$arr[16],//类目
+                13=>empty($arr[13])?0:$arr[13],//等 级
+                35=>empty($arr[35])?0:$arr[35],//配件类型
+                45=>empty($arr[45])?0:$arr[45],//配件其它
+                8=>empty($arr[8])?0:$arr[8],//头发颜色
+                15=>empty($arr[15])?0:$arr[15],//曲 度
+                38=>empty($arr[38])?0:$arr[38],//单片片数
+                7=>empty($arr[7])?0:$arr[7],//重量
+                14=>empty($arr[14])?0:$arr[14],//长 度
+            ];
+        }
+    }
+
+    //化纤头套
+    private function huaqiantoutao($type,$arr){
+        if($type == 1){
+            return [
+                "category"=>empty($arr['category'])?0:$arr['category'],
+                "grade"=>empty($arr['grade'])?0:$arr['grade'],
+                "sywignumber"=>empty($arr['sywignumber'])?0:$arr['sywignumber'],
+                "color"=>empty($arr['color'])?0:$arr['color'],
+                "lowe"=>empty($arr['lowe'])?0:$arr['lowe'],
+                "synthetictype"=>empty($arr['synthetictype'])?0:$arr['synthetictype'],
+                "sywigother"=>empty($arr['sywigother'])?0:$arr['sywigother'],
+                "size"=>empty($arr['size'])?0:$arr['size'],
+            ];
+        }else{
+            return [
+                16=>empty($arr[16])?0:$arr[16],//类目
+                13=>empty($arr[13])?0:$arr[13],//等 级
+                40=>empty($arr[40])?0:$arr[40],//化纤头套编号
+                8=>empty($arr[8])?0:$arr[8],//头发颜色
+                15=>empty($arr[15])?0:$arr[15],//曲 度
+                41=>empty($arr[41])?0:$arr[41],//化纤头套类型
+                42=>empty($arr[42])?0:$arr[42],//化纤头套其它
+                14=>empty($arr[14])?0:$arr[14],//长 度
+            ];
+        }
+
+    }
+    //化纤其它
+    private function huaqianqita($type,$arr){
+        if($type == 1){
+            return [
+                "category"=>empty($arr['category'])?0:$arr['category'],
+                "grade"=>empty($arr['grade'])?0:$arr['grade'],
+                "sywignumber"=>empty($arr['sywignumber'])?0:$arr['sywignumber'],
+                "syother"=>empty($arr['syother'])?0:$arr['syother'],
+                "color"=>empty($arr['color'])?0:$arr['color'],
+                "lowe"=>empty($arr['lowe'])?0:$arr['lowe'],
+                "items"=>empty($arr['items'])?0:$arr['items'],
+                "syother"=>empty($arr['syother'])?0:$arr['syother'],
+                "size"=>empty($arr['size'])?0:$arr['size'],
+            ];
+        }else{
+            return [
+                16=>empty($arr[16])?0:$arr[16],//类目
+                13=>empty($arr[13])?0:$arr[13],//等 级
+                47=>empty($arr[47])?0:$arr[47],//化纤发编号
+                46=>empty($arr[46])?0:$arr[46],//化纤其它分类
+                8=>empty($arr[8])?0:$arr[8],//头发颜色
+                15=>empty($arr[15])?0:$arr[15],//曲 度
+                38=>empty($arr[38])?0:$arr[38],//单包片数
+                48=>empty($arr[48])?0:$arr[48],//化纤发其它
+                14=>empty($arr[14])?0:$arr[14],//长 度
+            ];
+        }
+
+    }
+}

+ 4 - 1
template/erp/fullorder_edit.html

@@ -28,6 +28,9 @@
 <a href="javascript:void(0);" class="exptj">添 加</a>
 <a href="javascript:void(0);" class="expxg">修 改</a>
 <a href="javascript:void(0);" class="expsc">删 除</a>
+
+<a href="javascript:void(0);" class="ly_mcth">美仓替换</a>
+
 <!-- {if $thfpdata != ''}
 <a href="javascript:void(0);" class="ckthfpdata">查看替换内容</a>
 {/if} -->
@@ -1277,6 +1280,6 @@ $("#is_jiaji_id").on('change',function(){
 });
 
 </script>
-<script src="{$theme}js/fullorder-addedit.js?v=20250916"></script>
+<script src="{$theme}js/fullorder-addedit.js?v=20250919"></script>
 <script type="text/javascript" src="{$theme}js/time.js"></script>
 {Template footer}

+ 180 - 0
template/erp/js/fullorder-addedit.js

@@ -1887,4 +1887,184 @@ function showExpressTiShi(msg){
 		mTips.c.x = 0;
 		mTips.c.y = 0;
 	});
+}
+
+$(".ly_mcth").on('click',function(){
+	let warehouse = $("select[name='warehouse']").find("option:selected").val();
+	if(warehouse != 5){
+		layx.confirm('提示',"该仓库不支持此操作!",null,{
+			buttons:[
+				{
+					label:'确定',
+					callback:function(id, button, event){
+					   
+						   
+						layx.destroy(id);
+					}
+				}
+			],dialogIcon:'error',shadable:0.6
+		})
+		return false;
+	}
+
+	let obj = getTrabltr();
+	$.post("/ck/mcth",{
+		number:$("input[name='number']").val(),
+		fpdata:obj.fpadta,
+	},function(res){
+		if(res.code == 1){
+			doLymcth(res.data)
+		}else{
+			layx.confirm('提示',res.msg,null,{
+				buttons:[
+					{
+						label:'确定',
+						callback:function(id, button, event){
+						
+							
+							layx.destroy(id);
+						}
+					}
+				],dialogIcon:'error',shadable:0.6
+			})
+		}
+	},'json')
+})
+//获取table表单的相关信息
+function getTrabltr(){
+	let e = "",tdweight=0,w='',fpcount=''; 
+	$(".datatext tr").each(function() {
+		var cc = "";var listqc = "";var data = "";var t = "";var fpdg = "";
+		var td0 = $(this).find("td:eq(0)").text().replace(/\+/g,"%2B");
+		var td0 = td0.replace(/&/g,"%26");
+		var td8 = '';
+		if($(this).find("td:eq(8)").length > 0)
+		{
+			if($(this).find("td:eq(8)").text() == '')
+			{
+				td8 = '0';
+			}
+			else
+			{
+		       td8 = $(this).find("td:eq(8)").text();
+			}
+		}
+		else
+		{
+			td8 = '0';
+		}
+        e = e + $(this).attr("data-list")+ "|" + td0 + "|" + $(this).find("td:eq(1)").text() + "|" + $(this).find("td:eq(2)").text() + "|" + $(this).find("td:eq(3)").text() + "|" + $(this).find("td:eq(5)").text() + "|" + $(this).find("td:eq(6)").text() + "|" + $(this).find("td:eq(7)").text() + "|" + td8 + "|" + $(this).find("td:eq(9)").text() + ";";
+		tdweight = tdweight + td8*1;
+		var list = $(this).attr("data-list").replace(/\-(0|163|164|165|166)\-/,'-');
+		cc = list.split(",");
+		listqc = list.replace(/\d{1,3}\,/,'');
+		listqc = listqc.substring(0,listqc.length-1);
+		data = listqc.split("-");
+	    var zrflx = 0;//是否有真人发类型
+	        for(i=1;i<data.length;i++)
+	        {
+			    if(i == 2)
+			    {
+					//if(data[i] == 2090)
+					if ((data[i] == 2090) || (data[i] == 1620)  || (data[i] == 2480) || (data[i] == 2469)) 
+					{
+						zrflx++;
+						t = t +data[i];
+				        fpdg  = fpdg + '-' + data[i];
+					}
+					else
+					{
+				        if(cc[0] != list)
+				        {
+				            t = t +data[i] + cc[0];
+				            fpdg  = fpdg + '-' + data[i] + '-' + cc[0];
+				        }
+				        else
+				        {
+					        t = t +data[i];
+				            fpdg  = fpdg + '-' + data[i];
+				        }
+					}
+			    }
+				else if(i == 3 && zrflx > 0)
+			    {
+					if(cc[0] != list)
+				        {
+				            t = t +data[i] + cc[0];
+				            fpdg  = fpdg + '-' + data[i] + '-' + cc[0];
+				        }
+				        else
+				        {
+					        t = t +data[i];
+				            fpdg  = fpdg + '-' + data[i];
+				        }
+				}
+			    else
+			    {
+				    t = t +data[i];
+				    fpdg  = fpdg + '-' + data[i];
+			    }
+	        }
+		w = w + t + '-' + $(this).find("td:eq(1)").text() + '-' + $(this).find("td:eq(9)").text() + '|';
+		fpcount = fpcount + fpdg + '-|';
+    });
+	
+	e = e.replace(/(有可用特殊库存|已选择特殊库存|有可用现货库存|已选择现货库存|已选择库存)/g,'');
+	return {
+		fpadta:e,
+		whlabel:w,
+	};
+}
+//执行上边的返回结果拼接 以及界面操作
+function doLymcth(fpdata){
+	let table_tr = "";
+	let good_list = fpdata.split(";");
+	let detail_str = "";
+	let detail_arr = [];
+	let tmp_str = "";
+	for(var i in good_list){
+		tmp_str = "";
+		if(good_list[i].length > 0){
+			let detail_arr = good_list[i].split("|");
+			tmp_str += "<tr data-list='"+detail_arr[0]+"'><td>"+detail_arr[1]+"</td><td>"+detail_arr[2]+"</td><td class='none'>"+detail_arr[3]+"</td><td class='none'>"+detail_arr[4]+"</td><td class='none'>"+detail_arr[5]+"</td><td class='none'>"+detail_arr[6]+"</td><td class='none'>"+detail_arr[7]+"</td><td class='none'>"+detail_arr[8]+"</td><td class='none'>"+detail_arr[9]+"</td><td class='none val9'>0</td><td></td><td><font class='jzzd'>禁止占单</font></td></tr>";
+		}
+		table_tr += tmp_str;
+	}
+	$(".datatext ").html(table_tr);
+	checkKcyz()
+	custom();
+}
+
+function checkKcyz(){
+	let obj = getTrabltr();
+	var yzdata = {
+		warehouse: $("select[name=warehouse]").find("option:selected").val(),
+		shop: $("input[name=shop]").val(),
+		id: $("input[name=id]").val(),
+		number: $("input[name=number]").val(),
+		state: $("select[name=state]").find("option:selected").val(),
+		whlabel: "|" + obj.whlabel,
+	
+	};
+
+	$.post("/ck/kcyz/", yzdata,function(a){
+		console.log(a);
+		  if (a && a.success) {
+			
+		  } 
+		  else {
+			  if(a.t == 1)
+			  {
+				   layx.alert('错误',a.msg,function(id,button){},{dialogIcon:'error'});
+			  }
+			  else
+			  {
+				  layx.alert('错误',a.msg,function(id,button){},{dialogIcon:'error'});
+				  for(i=0;i<a.error.length;i++)
+				{
+					$(".datatext tr:eq("+a.error[i]+") td:eq(0)").css("color","red");
+				}
+			  }
+		  }
+	},'json')
 }