1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\model;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class Pay extends Model
- {
- protected $createTime="addtime";
- protected $updateTime="updatetime";
- public static $status=["待提交","待买方审核","审核通过","审核驳回","对账单无效"];
- public static function addInv($payNo,$payfee){
- $pay = self::where(["payNo"=>$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();
- }
- }
|