diff --git a/application/Api/v1/PreorderApicontroller.php b/application/Api/v1/PreorderApicontroller.php index 0ef1cb2be..aa18e62e5 100644 --- a/application/Api/v1/PreorderApicontroller.php +++ b/application/Api/v1/PreorderApicontroller.php @@ -37,7 +37,7 @@ class PreorderApicontroller extends mfBaseApicontroller { foreach($campaignApiusers as $campaignApiuser) { $campaign = new Preordercampaign($campaignApiuser->preordercampaign_id); - if($campaign) { + if($campaign->id) { foreach(PreordercampaignSalesclusterModel::search(['preordercampaign_id' => $campaign->id]) as $campain_scluster) { if(!in_array($campain_scluster->salescluster_id, $this->filter_salescluster_ids)) { $this->filter_salescluster_ids[] = $campain_scluster->salescluster_id; @@ -70,7 +70,9 @@ class PreorderApicontroller extends mfBaseApicontroller { if($campaign->allow_unit_update == 1) { $this->allow_unit_update = true; } - + } else { + $this->log->debug(__METHOD__.": campaign not found (PreordercampaignApiuser::preordercampaign_id ".$campaignApiuser->preordercampaign_id.")"); + $this->log->debug(print_r($campaignApiuser, true)); } @@ -555,6 +557,17 @@ class PreorderApicontroller extends mfBaseApicontroller { $campaign_id = $this->campaigns_by_scluster[$address->netzgebiet_id]; $this->campaign = new Preordercampaign($campaign_id); + if(!$this->campaign->id) { + $this->log->debug("================================================================="); + $this->log->debug(__METHOD__.": Campaign not found"); + $this->log->debug(print_r($address, true)); + $this->log->debug(print_r($this->campaigns_by_scluster, true)); + $this->log->debug("campaign id: $campaign_id"); + $this->log->debug(print_r($this->campaign, true)); + $this->log->debug("================================================================="); + return mfResponse::InternalServerError(['message' => "Ein Interner Fehler ist aufgetreten"]); + } + if($this->campaign->from > date('U') || $this->campaign->to < date('U')) { return mfResponse::Forbidden(['message' => "Bestellung in diesem Netzgebiet/Cluster nicht erlaubt"]); }