$payNo,"status"=>2,"is_del"=>0])->findOrEmpty(); if($pay->isEmpty())throw new \Exception("对账单{$payNo}不存在"); if($pay->winv_fee<$payfee)throw new \Exception("对账单{$payNo}未开票金额不足"); $pay->winv_fee=$pay->winv_fee-$payfee; $pay->inv_fee=$pay->inv_fee+$payfee; $pay->inv_status= 2; $pay->save(); } public static function addAinv($payNo,$payfee){ $pay = self::where(["payNo"=>$payNo,"status"=>2,"is_del"=>0])->findOrEmpty(); if($pay->isEmpty())throw new \Exception("对账单{$payNo}不存在"); if($pay->inv_fee<$payfee)throw new \Exception("对账单{$payNo}开票中金额不足"); $pay->inv_fee=$pay->inv_fee-$payfee; $pay->ainv_fee=$pay->ainv_fee+$payfee; $pay->inv_status= $pay->winv_fee==0 && $pay->inv_fee==0 ? 3 : 2; $pay->save(); } public static function subAinv($payNo,$payfee){ $pay = self::where(["payNo"=>$payNo,"status"=>2,"is_del"=>0])->findOrEmpty(); if($pay->isEmpty())throw new \Exception("对账单{$payNo}不存在"); if($pay->ainv_fee<$payfee)throw new \Exception("对账单{$payNo}开票金额不足"); $pay->ainv_fee=$pay->ainv_fee-$payfee; $pay->winv_fee=$pay->winv_fee+$payfee; $pay->inv_status= $pay->ainv_fee==0 && $pay->inv_fee==0 ? 1 : 2; $pay->save(); } public static function subInv($payNo,$payfee){ $pay = self::where(["payNo"=>$payNo,"status"=>2,"is_del"=>0])->findOrEmpty(); if($pay->isEmpty())throw new \Exception("对账单{$payNo}不存在"); if($pay->inv_fee<$payfee)throw new \Exception("对账单{$payNo}开票中金额不足"); $pay->inv_fee=$pay->inv_fee-$payfee; $pay->winv_fee=$pay->winv_fee+$payfee; $pay->inv_status= $pay->ainv_fee==0 && $pay->inv_fee==0 ? 1 : 2; $pay->save(); } }