select('id,store_name,logo_img,praise') ->where( ['mall_id' => $mall_id,'status' => StatusEnum::ENABLED, 'check_status' => MchEnum::CHECK_ADOPT]) ->andWhere(['<', 'expire_time', time()]) ->andWhere(['>', 'expire_time', 0]) ->all(); $mch_ids = array_column($mch_list,'id'); Mch::updateAll(['status'=>StatusEnum::DISABLED],['id'=>$mch_ids]); Goods::updateAll(['is_on_sale'=>0],['mch_id'=>$mch_ids]); } return ExitCode::OK; } catch (\Exception $e) { return ExitCode::UNSPECIFIED_ERROR; } } public function actionSettlementLog() { try { $logs = SettlementLog::find() ->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); } //结算货款 Mch::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; } } }