belongsTo(Good::class,"spuCode","spuCode")->bind(["good_name"]); } public static function checkInfo($code,$orderType,$info){ if(!empty($info)){ $save=[]; foreach ($info as $key=>$value){ $ist = self::where(["code"=>$code,"order_type"=>$orderType,"spuCode"=>$value['spuCode']])->findOrEmpty(); if($ist->isEmpty() || $ist->cat_code==''){ $Temp=[ "id"=>$ist->id??null, "code"=>$code, "order_type"=>$orderType, "spuCode"=>$value['spuCode'], "cat_code"=>$value['cat_code']??"", "cat_name"=>$value['cat_name']??"", "short_name"=>$value['short_name']??"", "merge_code"=>$value['merge_code']??"", "tax"=>$value['tax']??"", "inv_good_name"=>$value['inv_good_name'] ]; $save[]=$Temp; } } if(!empty($save)){ (new OrderCategory)->saveAll($save); } } } public static function GetTaxInfoByCode($code){ $info=self::with(['GoodInfo'])->where(["code"=>$code])->field(["code","spuCode","cat_code","cat_name","merge_code","short_name","tax","inv_good_name"])->select(); $temp=[]; if(!empty($info)){ if (is_array($code)){ foreach ($info as $value){ $temp[$value['code']][]=$value; } }else $temp= $info->toArray(); } return $temp; } }