InvoicePool.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\admin\model;
  4. use think\Model;
  5. /**
  6. * @mixin \think\Model
  7. */
  8. class InvoicePool extends Model
  9. {
  10. // 1 财务审核 2 待财务上传发票 3 金税开票中/验票中 4 开票成功 5 开票失败 6发票退票/废弃 7取消申请 8 财务驳回 9验票失败
  11. // 10 待发票关联订单 11 发票关联订单完毕待财务审核 12 发票关联订单财务驳回
  12. public static $statusCn = [
  13. 0=>"待开票",
  14. 1=>"待财务审核",
  15. 2=>"待财务上传发票",
  16. 3=>"验票中",
  17. 10=>'待发票关联订单',
  18. 11=>'发票关联订单完毕待财务审核',
  19. 4=>"开票完成",//待发票关联订单审核通过
  20. 5=>"开票失败",
  21. 6=>"发票退票",
  22. 7=>"取消申请",
  23. 8=>"财务驳回",
  24. 9=>"验票失败",
  25. 12=>"发票关联订单财务驳回"
  26. ];
  27. public function PoolInfo(){
  28. return $this->belongsTo(InvoicePoolInfo::class,'invNo','invNo')->bind(["buyer_code","seller_code"]);
  29. }
  30. public static function onAfterUpdate(Model $model) : void{
  31. if($model->status==4 && $model->buyer_check==0 && $model->seller_check==0){
  32. $ticket = InvoiceTicket::where(["invNo"=>$model->invNo,"status"=>1,"is_del"=>0,"type"=>0])->findOrEmpty();
  33. if(!$ticket->isEmpty()){
  34. $buyer_check = $model->PoolInfo->buyer_code == $ticket->buyer_id?1:2;
  35. $seller_check = $model->PoolInfo->seller_code == $ticket->seller_id?1:2;
  36. $model->save(["buyer_check"=>$buyer_check,"seller_check"=>$seller_check]);
  37. }
  38. }
  39. }
  40. }