where(['is_settlement'=>0]) ->andWhere(['<','settlement_at',time()]) ->all(); if(!empty($logs)){ foreach($logs as $log){ $trans = \Yii::$app->db->beginTransaction(); try{ $log->is_settlement = 1; if(!$log->save()){ throw new \Exception('门店订单结算异常,id:'.$log->id); } //结算货款 Store::settlementStoreCommission($log['order_id'], $log['store_id'], $log['order_no']); $trans->commit(); }catch(\Exception $e){ $trans->rollBack(); throw new \Exception($e->getMessage()); } } } return ExitCode::OK; } catch (\Exception $e) { return ExitCode::UNSPECIFIED_ERROR; } } public function actionTest() { OrderPaidListener::async_handle(['id' => 1092]); } }