Changed Citycom order flow to new estmk activation workflow
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -736,19 +736,27 @@ class Preorder extends mfBaseModel {
|
||||
$first_ctag = $search_ctag - ($search_ctag % $ctags_per_home);
|
||||
$last_ctag = $first_ctag + $ctags_per_home - 1;
|
||||
|
||||
$mgmt_ctag_exists = false;
|
||||
|
||||
$mgmt_ctag = null;
|
||||
$ctag_range = [];
|
||||
for($i = $first_ctag; $i <= $last_ctag; $i++) {
|
||||
if(!PreorderCtag::getFirstActive(["stag" => $stag, "ctag" => $i, "network" => $network_name])) {
|
||||
if($i == $last_ctag) {
|
||||
$ctag = PreorderCtag::getFirstActive(["stag" => $stag, "ctag" => $i, "network" => $network_name]);
|
||||
if(!$ctag) {
|
||||
if($i == $last_ctag && !$mgmt_ctag_exists) {
|
||||
// mgmt ctag should be the last in range
|
||||
$mgmt_ctag = $i;
|
||||
continue;
|
||||
}
|
||||
$ctag_range[] = $i;
|
||||
|
||||
} else {
|
||||
if($ctag->service_type == "mgmt") {
|
||||
$this->log->debug(__METHOD__.": mgmt ctag ($i / stag $stag) exists already\n");
|
||||
$mgmt_ctag_exists = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [$ctag_range, $mgmt_ctag];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
|
||||
class PreorderCtag extends mfBaseModel {
|
||||
protected $forcestr = ["product_name","product_info","matchcode"];
|
||||
protected $forcestr = ["network","ext_id","ext_name"];
|
||||
private $preorder;
|
||||
private $invoice;
|
||||
private $adb_wohneinheit;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
@@ -153,7 +151,7 @@ class PreorderCtag extends mfBaseModel {
|
||||
$model = new PreorderCtag();
|
||||
|
||||
$table_fields = [
|
||||
"preorder_id", "network", "stag", "ctag", "service_type", "ext_id", "ext_status", "deleted",
|
||||
"preorder_id", "network", "stag", "ctag", "service_type", "ext_id", "ext_name", "ext_status", "deleted",
|
||||
"create_by","edit_by","create","edit"
|
||||
];
|
||||
|
||||
@@ -203,7 +201,7 @@ class PreorderCtag extends mfBaseModel {
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT PreorderCtag.* FROM PreorderCtag
|
||||
WHERE $where
|
||||
ORDER BY preorder_id,stag,ctag LIMIT 1";
|
||||
ORDER BY ctag LIMIT 1";
|
||||
//var_dump($sql);exit;
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
$res = $db->query($sql);
|
||||
@@ -230,7 +228,7 @@ class PreorderCtag extends mfBaseModel {
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT PreorderCtag.* FROM PreorderCtag
|
||||
WHERE $where
|
||||
ORDER BY preorder_id DESC,stag DESC,ctag DESC LIMIT 1";
|
||||
ORDER BY ctag DESC LIMIT 1";
|
||||
//var_dump($sql);exit;
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
$res = $db->query($sql);
|
||||
|
||||
Reference in New Issue
Block a user