12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\model;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class InvoicePool extends Model
- {
- // 1 财务审核 2 待财务上传发票 3 金税开票中/验票中 4 开票成功 5 开票失败 6发票退票/废弃 7取消申请 8 财务驳回 9验票失败
- // 10 待发票关联订单 11 发票关联订单完毕待财务审核 12 发票关联订单财务驳回
- public static $statusCn = [
- 0=>"待开票",
- 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]);
- }
- }
- }
- }
|