doAction(1,$arr); } public function sortByClass($arr){ return $this->doAction(2,$arr); } //只有id 然后转化为字段名 + 值 public function sortByColume($arr){ return $this->doAction(3,$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; } }elseif($type == 3){ if(isset($arr[22]) && in_array($arr[22],[163,164,165,166])){ $arr[22] = 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']; }elseif($type == 3){ $cate = $arr[16]; }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'], ]; }elseif($type == 3){ return [ "category"=>empty($arr[16])?0:$arr[16],//类目 "hairtype"=>empty($arr[22])?0:$arr[22],//真人发类型 "grade"=>empty($arr[13])?0:$arr[13],//等 级 "color"=>empty($arr[8])?0:$arr[8],//头发颜色 "lowe"=>empty($arr[15])?0:$arr[15],//曲 度 "size"=>empty($arr[14])?0:$arr[14],//长 度 ]; }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'], ]; }elseif($type == 3){ $lacesize = 0; if(!empty($arr[25])){ $lacesize = $arr[25]; } if(!empty($arr[26])){ $lacesize = $arr[26]; } return [ "category"=>empty($arr[16])?0:$arr[16],//类目 "hairtype"=>empty($arr[22])?0:$arr[22],//真人发类型 "grade"=>empty($arr[13])?0:$arr[13],//等 级 "color"=>empty($arr[8])?0:$arr[8],//头发颜色 "lowe"=>empty($arr[15])?0:$arr[15],//曲 度 "type"=>empty($arr[27])?0:$arr[27],//类 型 "headroad"=>empty($arr[12])?0:$arr[12],//头路设计 "density"=>empty($arr[10])?0:$arr[10],//密 度 //到时间会去重处理 'lacesize'=> $lacesize, 'lacecolor'=>empty($arr[9])?0:$arr[9],//蕾丝颜色 "lacetypes"=>empty($arr[44])?0:$arr[44],//蕾丝类型 "size"=>empty($arr[14])?0:$arr[14],//长 度 ]; }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'], ]; }elseif($type == 3){ return [ "category"=>empty($arr[16])?0:$arr[16],//类目 "hairtype"=>empty($arr[22])?0:$arr[22],//真人发类型 "grade"=>empty($arr[13])?0:$arr[13],//等 级 "hairnumber"=>empty($arr[43])?0:$arr[43],//人发头套编号 "color"=>empty($arr[8])?0:$arr[8],//头发颜色 "lowe"=>empty($arr[15])?0:$arr[15],//曲 度 "lacetype"=>empty($arr[18])?0:$arr[18],//头套种类 "haircap"=>empty($arr[6])?0:$arr[6],//发帽大小 "density"=>empty($arr[10])?0:$arr[10],//密 度 "lacecolor"=>empty($arr[9])?0:$arr[9],//蕾丝颜色 "lacetypes"=>empty($arr[44])?0:$arr[44],//蕾丝类型 "wigother"=>empty($arr[39])?0:$arr[39],//分缝及刘海 "wigother1"=>empty($arr[50])?0:$arr[50],//头套其它1 "wigother2"=>empty($arr[51])?0:$arr[51],//头套其它2 "size"=>empty($arr[14])?0:$arr[14],//长 度 ]; }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'], 'jfother'=>(empty($arr['jfother'])?0:$arr['jfother']), "size"=>empty($arr['size'])?0:$arr['size'], ]; }elseif($type == 3){ return [ "category"=>empty($arr[16])?0:$arr[16],//类目 "hairtype"=>empty($arr[22])?0:$arr[22],//真人发类型 "grade"=>empty($arr[13])?0:$arr[13],//等 级 "extension"=>empty($arr[33])?0:$arr[33],//Extension类型 "color"=>empty($arr[8])?0:$arr[8],//头发颜色 "lowe"=>empty($arr[15])?0:$arr[15],//曲 度 "items"=>empty($arr[38])?0:$arr[38],//单片片数 "weight"=>empty($arr[7])?0:$arr[7],//重量 "jfother"=>(empty($arr[52])?0:$arr[52]),//接发其它 "size"=>empty($arr[14])?0:$arr[14],//长 度 ]; }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],//重量 52=>empty($arr[52])?0:$arr[52],//接发其它 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'], ]; }elseif($type == 3){ return [ "category"=>empty($arr[16])?0:$arr[16],//类目 "gifttype"=>empty($arr[34])?0:$arr[34],//礼物类型 "giftother"=>empty($arr[49])?0:$arr[49],//礼物其它 ]; }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'], ]; }elseif($type == 3){ return [ "category"=>empty($arr[16])?0:$arr[16],//类目 "grade"=>empty($arr[13])?0:$arr[13],//等 级 "fittype"=>empty($arr[35])?0:$arr[35],//配件类型 "acother"=>empty($arr[45])?0:$arr[45],//配件其它 "color"=>empty($arr[8])?0:$arr[8],//头发颜色 "lowe"=>empty($arr[15])?0:$arr[15],//曲 度 "items"=>empty($arr[38])?0:$arr[38],//单片片数 "weight"=>empty($arr[7])?0:$arr[7],//重量 'size'=>empty($arr[14])?0:$arr[14],//长 度 ]; }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'], ]; }elseif($type == 3){ return [ "category"=>empty($arr[16])?0:$arr[16],//类目 "grade"=>empty($arr[13])?0:$arr[13],//等 级 "sywignumber"=>empty($arr[40])?0:$arr[40],//化纤头套编号 "color"=>empty($arr[8])?0:$arr[8],//头发颜色 "lowe"=>empty($arr[15])?0:$arr[15],//曲 度 "synthetictype"=>empty($arr[41])?0:$arr[41],//化纤头套类型 "sywigother"=>empty($arr[42])?0:$arr[42],//化纤头套其它 "size"=>empty($arr[14])?0:$arr[14],//长 度 ]; }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'], ]; }elseif($type == 3){ return [ "category"=>empty($arr[16])?0:$arr[16],//类目 "grade"=>empty($arr[13])?0:$arr[13],//等 级 "sywignumber"=>empty($arr[47])?0:$arr[47],//化纤发编号 "syother"=>empty($arr[46])?0:$arr[46],//化纤其它分类 "color"=>empty($arr[8])?0:$arr[8],//头发颜色 "lowe"=>empty($arr[15])?0:$arr[15],//曲 度 "items"=>empty($arr[38])?0:$arr[38],//单包片数 "syother"=>empty($arr[48])?0:$arr[48],//化纤发其它 "size"=>empty($arr[14])?0:$arr[14],//长 度 ]; }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],//长 度 ]; } } /** * 功能:将特征数组转换 */ public function featureTransferColumn($post,$classid){ $list = []; $category = $post['category']; $list['category'] = $category; $list['hairtype'] = empty($post['hairtype'])?'':$post['hairtype']; $list['grade'] = empty($post['grade'])?'':$post['grade']; $list['size'] = empty($post['size'])?'':$post['size']; $list['hairnumber'] = empty($post['hairnumber'])?'':$post['hairnumber']; $list['extension'] = empty($post['extension'])?'':$post['extension']; if ($category == 1297) { $list['sywignumber'] = empty($post['sywignumber'])?'':$post['sywignumber']; } if ($category == 1702) { $list['syhairnumber'] = empty($post['syhairnumber'])?'':$post['syhairnumber']; $list['syother'] = empty($post['syother'])?'':$post['syother']; } if ($category == 133) { $list['fittype'] = empty($post['fittype'])?'':$post['fittype']; $list['acother'] = empty($post['acother'])?'':$post['acother']; } $list['color'] = empty($post['color'])?'':$post['color']; $list['lowe'] = empty($post['lowe'])?'':$post['lowe']; if ($category == 127) { $list['type'] = empty($post['type'])?'':$post['type']; $list['headroad'] = empty($post['headroad'])?'':$post['headroad']; $list['density'] =empty($post['density'])?'':$post['density']; if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) { $list['lacesize'] = empty($post['lacesize'])?'':$post['lacesize']; } $list['lacecolor'] = empty($post['lacecolor'])?'':$post['lacecolor']; $list['lacetypes'] = empty($post['lacetypes'])?'':$post['lacetypes']; } if ($category == 128) { $list['lacetype'] =empty($post['lacetype'])?'':$post['lacetype']; $list['haircap'] = empty($post['haircap'])?'':$post['haircap']; $list['density'] = empty($post['density'])?'':$post['density']; $list['lacecolor'] = empty($post['lacecolor'])?'':$post['lacecolor']; $list['lacetypes'] = empty($post['lacetypes'])?'':$post['lacetypes']; $list['wigother'] = empty($post['wigother'])?'':$post['wigother']; $list['wigother1'] = empty($post['wigother1'])?'':$post['wigother1']; $list['wigother2'] = empty($post['wigother2'])?'':$post['wigother2']; } if ($category == 129) { $list['wide'] = empty($post['wide'])?'':$post['wide']; } if ($category == 131) { $list['gifttype'] = empty($post['gifttype'])?'':$post['gifttype']; $list['giftother'] = empty($post['giftother'])?'':$post['giftother']; } if ($category == 134) { $list['pieceweight'] = empty($post['pieceweight'])?'':$post['pieceweight']; } if ($category == 1297) { $list['synthetictype'] = empty($post['synthetictype'])?'':$post['synthetictype']; $list['sywigother'] = empty($post['sywigother'])?'':$post['sywigother']; } if ($category == 130 || $category == 133 || $category == 1702) { $list['items'] = empty($post['items'])?'':$post['items']; $list['weight'] = empty($post['weight'])?'':$post['weight']; } if ($category == 130 ) { $list['jfother'] = empty($post['jfother'])?'':$post['jfother']; } if ($category == 1702) { $list['syhairther'] = empty($post['syhairther'])?'':$post['syhairther']; } $pm = $scsku = $classid; $number = $features = $title = ""; foreach ($list as $k => $v) { if ($v != 0) { $number .= $v; $features .= $v . '-'; $typeclass = $this->typeclass->read($v); if (isset($pm[$typeclass['classid']])) { if (stripos($typeclass['zh'], '|') !== false) { $exzh = explode('|', $typeclass['zh']); $pm[$typeclass['classid']] = $exzh[0]; } else { $pm[$typeclass['classid']] = $typeclass['zh']; } } $scsku[$typeclass['classid']] = $typeclass['bqsku']; if ($k != 'size') { $title .= $typeclass['title'] . " "; } } } $typeclass = $this->typeclass->read($list['size']); $title .= $typeclass['title']; $scsku = implode("-", $scsku); $pm = array_filter($pm); $zh = implode(" ", $pm); $scsku = str_replace('- ', '-', trim($scsku, '-')); $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku); $bqsku = $scsku; return [ 'sku'=>$bqsku, 'title'=>$title, 'zh'=>$zh, ]; } }