toArray())); $pay = Pay::where(["payNo"=>$model->payNo])->findOrEmpty(); if(!$pay->isEmpty() && $pay->is_comon!=1){ if($model->status==1 && !empty($model->item_list)){ (new InvoiceItem)->saveAll(array_map(function ($item)use($model) { return [ 'invoiceCode'=>$model->hpNo, 'order_type'=>2, 'good_name'=>$item['name'], 'unit'=>$item['unit'], 'num'=>$item['quantity'], 'unit_price'=>$item['unit_price'], 'amount'=>$item['amount'], 'tax_amount'=>$item['tax'], 'tax'=>$item['tax_rate'], 'cat_code'=>$item['license_plate_number'], 'total_amount'=>bcadd($item['amount'],$item['tax'],2), 'balance_amount'=>bcadd($item['amount'],$item['tax'],2), ]; },$model->item_list)); } } } }