'int', 'dzNo'=>'string', 'cgdNo'=>'string', 'rela_fee'=>'decimal', 'status'=>'tinyint', 'createTime'=>'datetime', 'updateTime'=>'datetime', 'delete_time'=>'datetime' ]; //状态 0 关联中 1 已付款 2 解除付款 3 取消付款', public static function onAfterWrite(Model $model) : void{ $cgdNo = $model->cgdNo; $status = $model->status; Log::info("PaymentOrder::onAfterWrite:".$model->cgdNo."-".$model->status); $cgdinfo = CgdInfo::where(["sequenceNo"=>$cgdNo,"is_del"=>0,"status"=>1])->findOrEmpty(); if($cgdinfo->isEmpty()) return; switch ($status){ case 0: $cgdinfo->wpay_fee= $cgdinfo->wpay_fee-$model->rela_fee; $cgdinfo->pay_status= 2; break; case 1: $cgdinfo->apay_fee= $cgdinfo->apay_fee+$model->rela_fee; $cgdinfo->pay_status= $cgdinfo->wpay_fee==0 && $cgdinfo->apay_fee==$cgdinfo->totalPrice-$cgdinfo->pay_tag_fee?3:2; break; case 2: $cgdinfo->apay_fee= $cgdinfo->apay_fee-$model->rela_fee; $cgdinfo->wpay_fee= $cgdinfo->wpay_fee+$model->rela_fee; $cgdinfo->pay_status= $cgdinfo->apay_fee==0 && $cgdinfo->wpay_fee==$cgdinfo->totalPrice-$cgdinfo->pay_tag_fee?1:2; break; case 3: $cgdinfo->wpay_fee= $cgdinfo->wpay_fee+$model->rela_fee; $cgdinfo->pay_status= $cgdinfo->apay_fee==0 && $cgdinfo->wpay_fee==$cgdinfo->totalPrice-$cgdinfo->pay_tag_fee?1:2; break; default: return; } $cgdinfo->save(); Log::info("PaymentOrder::onAfterWrite-update:".self::getLastSql()); } //状态 0 关联中 1 已付款 2 解除付款 3 取消付款', public static function checkOrder($dzNo,$status){ $list = self::where(['dzNo'=>$dzNo,'status'=>$status==2?1:0])->field("id,cgdNo,status,rela_fee")->select(); Log::info("PaymentOrder::checkOrder:dzNo-{$dzNo},status-{$status}"); if($list->isEmpty()) return; Log::info(array_map(function($item)use($status){ return [ 'id'=>$item['id'], 'cgdNo'=>$item['cgdNo'], 'rela_fee'=>$item['rela_fee'], 'status'=>$status ]; },$list->toArray())); (new PaymentOrder)->saveAll(array_map(function($item)use($status){ return [ 'id'=>$item['id'], 'cgdNo'=>$item['cgdNo'], 'rela_fee'=>$item['rela_fee'], 'status'=>$status ]; },$list->toArray())); Log::info("PaymentOrder::checkOrder-update:".self::getLastSql()); } }