&$item){ isset($item['id'])?:$item['id']=null; if(isset($item['spuCode'])==false){ $item['spuCode']= substr(makeNo("SPU"), 0, -2) . str_pad(strval($key), 2, '0', STR_PAD_LEFT); } if(empty($item['specinfo'])==false){ foreach ($item['specinfo'] as &$v){ $v['spec_name'] = Specs::where("id",$v['spec_id'])->value("spec_name",''); $v['spec_value_name'] = SpecValue::where("id",$v['spec_value_id'])->value("spec_value",''); } } $item = array_merge($item,$merage); } self::saveAll($list); } public function Brand(){ return $this->belongsTo(Brand::class,"brand_id")->bind(["brand_name"]); } public function Unit(){ return $this->belongsTo(Unit::class,'unit_id')->bind(['unit_name'=>"unit"]); } public function Cat(){ return $this->belongsTo(Cat::class,'cat_id')->bind(["cat_name"=>'search']); } public function GetSpecinfoAttr($v){ return json_decode($v,true); } public function SetSpecinfoAttr($v){ return json_encode($v,JSON_UNESCAPED_UNICODE); } public function GetGoodImgAttr($v){ return json_decode($v,true); } public function SetGoodImgAttr($v){ return json_encode($v,JSON_UNESCAPED_UNICODE); } public function CreateGood($bidNo,$marage){ $list =$this->where(["bidNo"=>$bidNo])->hidden(["id"])->select(); if($list->isEmpty()==false){ $addGood=[]; $combind =[]; foreach ($list as $item){ $item['good_unit'] = $item['unit_id']; $item['specinfo'] = json_encode($item['specinfo'],JSON_UNESCAPED_UNICODE); $item['good_img'] = implode(",",$item['good_img']); $item['customized'] = $item['work_day']; $item['craft_desc'] = $item['good_name']; $item['noble_metal'] = $item['metal_id']; $item['isChild'] = 1; $item['creater'] = $item['cgder']; $item['createrid'] = $item['cgderid']; $addGood[] = array_merge($item->toArray(),$marage); $combind[]=[ "spuCode"=>$marage["parent_code"], "good_name"=>$marage["parent_name"], "childCode"=>$item["spuCode"], "child_name"=>$item["good_name"], "child_num"=>$item["good_num"], ]; } if(empty($addGood)==false)(new GoodZixun())->strict(false)->insertAll($addGood); if(empty($combind)==false)(new GoodCombind())->insertAll($combind); } } }