Changed Citycom order flow to new estmk activation workflow

This commit is contained in:
Frank Schubert
2026-01-15 14:16:22 +01:00
parent 6bbf023b85
commit 76be480f7b
9 changed files with 195 additions and 33 deletions
@@ -85,13 +85,13 @@ class SnoppCitycom extends Modules\ApiControllerModule
$bb_down = $this->post["bb_down"];
$execution_date = false;
if($this->post["execution_date"]) {
/*if($this->post["execution_date"]) {
try {
$execution_date = new \DateTime($this->post["execution_date"]);
} catch(\Exception $e) {
return \mfResponse::BadRequest(["message" => "Invalid Timestamp format"]);
}
}
}*/
if(!is_numeric($bb_down) || !$bb_down || !is_numeric($bb_up) || !$bb_up || !$bb_down > 10000 || $bb_up > 10000) {
@@ -118,6 +118,10 @@ class SnoppCitycom extends Modules\ApiControllerModule
// if all services are ordered and active, finish order and return active
$ctag = PreorderCtag::getFirstActive(["preorder_id" => $preorder->id, "service_type" => "inet"]);
if(!$ctag) {
return \mfResponse::NotFound(["message" => "Home not found"]);
}
if($ctag->ext_id && $ctag->ext_status == "finished") {
if($preorder->status->code < 500) {
$preorder->setNewStatusCode(500);
@@ -132,7 +136,7 @@ class SnoppCitycom extends Modules\ApiControllerModule
return \mfResponse::Ok(["message" => "ONT not yet installed. Deferred", "activation_status" => "deferred"]);
}
/*
$cc_home_id = \Citycom_OanApiHelper::hausnummerExtrefToCitycomId($wohneinheit->extref);
$data["up"] = $bb_up;
$data["down"] = $bb_down;
@@ -159,10 +163,30 @@ class SnoppCitycom extends Modules\ApiControllerModule
// order Service at Citycom and set Preorder to 500 Finished
if(!$cc_api->orderServices($preorder, $cc_home_id, $data)) {
return \mfResponse::InternalServerError(["message" => "Error activating service"]);
}*/
// update product at citycom
//$cc_home_id = \Citycom_OanApiHelper::hausnummerExtrefToCitycomId($wohneinheit->extref);
$data["up"] = $bb_up;
$data["down"] = $bb_down;
$data["product_name"] = false;
if($preorder->campaign->fulfillment == "citycom_oan") {
$data["product_name"] = "Estmk Greenstream OAN $bb_down/$bb_up";
}
// live check if service is active, if not return deferred
$ctag = PreorderCtag::getFirstActive(["preorder_id" => $preorder->id, "service_type" => "inet"]);
$cc_api_client = new \Citycom_OanApiClient(CITYCOM_OAN_API_USER, CITYCOM_OAN_API_PASS);
$cc_api = new \Citycom_OanApiHelper($cc_api_client);
// try to update product with bandwidth provided by snopp.
// updateService() only updates if values are changed.
if(!$cc_api->updateService($ctag->ext_id, $data)) {
$this->log->error(__METHOD__.": Error updating service {$ctag->ext_id} for preorder {$preorder->id}");
//return \mfResponse::InternalServerError(["message" => "Error activating service"]);
}
// check if service is active, if not return deferred
//$ctag = PreorderCtag::getFirstActive(["preorder_id" => $preorder->id, "service_type" => "inet"]);
if($ctag->ext_id && $ctag->ext_status == "finished") {
if($preorder->status->code < 500) {
$preorder->setNewStatusCode(500);