WIP 2023-12-15
This commit is contained in:
@@ -13,12 +13,53 @@ class Cif extends Modules\ApiControllerModule {
|
||||
public function init() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* GET /preorder/:code/clientInstallationFinished
|
||||
*/
|
||||
public function providerSetCif($code) {
|
||||
return \mfResponse::InternalServerError();
|
||||
//return \mfResponse::Ok(["message" => "in providerSetCif($code)"]);
|
||||
$code = trim($code);
|
||||
if(!$code) {
|
||||
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
|
||||
$preorder = \PreorderModel::getFirst(['ucode' => strtoupper($code), 'partner_id' => $this->me->address_id]);
|
||||
if(!$preorder) {
|
||||
// try oaid
|
||||
$preorder = \PreorderModel::getFirst(['oaid' => strtolower($code), 'partner_id' => $this->me->address_id], "`create` DESC");
|
||||
}
|
||||
if(!$preorder) {
|
||||
// try as extref
|
||||
$preorder = \PreorderModel::getFirst(['extref' => $code, 'partner_id' => $this->me->address_id]);
|
||||
}
|
||||
|
||||
if(!$preorder) {
|
||||
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
|
||||
|
||||
if($preorder->partner_id != $this->me->address_id) {
|
||||
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
|
||||
|
||||
// set status to 200
|
||||
if($preorder->status->code < 200) {
|
||||
$new_status = \PreorderstatusModel::getFirst(["code" => 200]);
|
||||
if(!$new_status) {
|
||||
return \mfResponse::InternalServerError();
|
||||
}
|
||||
$preorder->status_id = $new_status->id;
|
||||
$preorder->save();
|
||||
}
|
||||
|
||||
return \mfResponse::Ok(["message" => "Status successfully updated."]);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* GET /preorder/customerInstallationFeedback
|
||||
*/
|
||||
public function getCifData() {
|
||||
|
||||
if(!array_key_exists("ciftoken", $this->get) || !$this->get['ciftoken']) {
|
||||
@@ -35,10 +76,13 @@ class Cif extends Modules\ApiControllerModule {
|
||||
return \mfResponse::Ok($return);
|
||||
}
|
||||
|
||||
/*
|
||||
* POST /preorder/customerInstallationFeedback
|
||||
*/
|
||||
public function userSetCif() {
|
||||
return \mfResponse::InternalServerError();
|
||||
|
||||
if(!array_key_exists("ciftoken", $this->get) || !$this->get['ciftoken']) {
|
||||
if(!array_key_exists("ciftoken", $this->post) || !$this->post['ciftoken']) {
|
||||
return \mfResponse::BadRequest(["message" => "ciftoken missing"]);
|
||||
}
|
||||
|
||||
@@ -47,6 +91,18 @@ class Cif extends Modules\ApiControllerModule {
|
||||
return \mfResponse::NotFound(["message" => "Invalid ciftoken"]);
|
||||
}
|
||||
|
||||
// set status to 200
|
||||
if($preorder->status->code < 200) {
|
||||
$new_status = \PreorderstatusModel::getFirst(["code" => 200]);
|
||||
if(!$new_status) {
|
||||
return \mfResponse::InternalServerError();
|
||||
}
|
||||
$preorder->status_id = $new_status->id;
|
||||
$preorder->save();
|
||||
}
|
||||
|
||||
return \mfResponse::Ok(["message" => "Status successfully updated."]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user