"待开票", 1=>"待财务审核", 2=>"待财务上传发票", 3=>"验票中", 10=>'待发票关联订单', 11=>'发票关联订单完毕待财务审核', 4=>"开票完成",//待发票关联订单审核通过 5=>"开票失败", 6=>"发票退票", 7=>"取消申请", 8=>"财务驳回", 9=>"验票失败", 12=>"发票关联订单财务驳回" ]; public function PoolInfo(){ return $this->belongsTo(InvoicePoolInfo::class,'invNo','invNo')->bind(["buyer_code","seller_code"]); } public static function onAfterUpdate(Model $model) : void{ if($model->status==4 && $model->buyer_check==0 && $model->seller_check==0){ $ticket = InvoiceTicket::where(["invNo"=>$model->invNo,"status"=>1,"is_del"=>0,"type"=>0])->findOrEmpty(); if(!$ticket->isEmpty()){ $buyer_check = $model->PoolInfo->buyer_code == $ticket->buyer_id?1:2; $seller_check = $model->PoolInfo->seller_code == $ticket->seller_id?1:2; $model->save(["buyer_check"=>$buyer_check,"seller_check"=>$seller_check]); } } } }