implement feature 'put to cart ticket installment request'
This commit is contained in:
parent
3fce2c70c2
commit
8de73c0585
162
backend/components/ContractManager.php
Normal file
162
backend/components/ContractManager.php
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by IntelliJ IDEA.
|
||||||
|
* User: rocho
|
||||||
|
* Date: 2019.03.19.
|
||||||
|
* Time: 18:04
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace backend\components;
|
||||||
|
|
||||||
|
|
||||||
|
use common\models\Contract;
|
||||||
|
use common\models\ShoppingCart;
|
||||||
|
use common\models\Ticket;
|
||||||
|
use common\models\TicketInstallmentRequest;
|
||||||
|
use common\models\Transfer;
|
||||||
|
use yii\web\NotFoundHttpException;
|
||||||
|
|
||||||
|
class ContractManager
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $STATUS_PENDING nothing to do
|
||||||
|
* $STATUS_MARKED_TO_SEND nothing to do, automatic purchase in progress
|
||||||
|
* $STATUS_SENT nothing to do , automatic purchase in progress
|
||||||
|
* $STATUS_CANCELED we can mark it as accepted_manual, and put it back to cart. TODO: put it to pending state
|
||||||
|
* $STATUS_REJECTED automatic purchase was rejected, accept manual
|
||||||
|
* $STATUS_ACCEPTED nothing to do, automatic purchase was ok
|
||||||
|
* $STATUS_ACCEPTED_MANUAL this we can put back to cart
|
||||||
|
* @param $id_ticket_installment_request
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
* @throws \Throwable
|
||||||
|
*/
|
||||||
|
public function openRequestAndPutItItoCart($id_ticket_installment_request)
|
||||||
|
{
|
||||||
|
$request = TicketInstallmentRequest::findOne(['id_ticket_installment_request' => $id_ticket_installment_request]);
|
||||||
|
|
||||||
|
if (!isset($request)) {
|
||||||
|
throw new NotFoundHttpException("ticket_installment_request not found #" . $id_ticket_installment_request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if status does not support open, return
|
||||||
|
if (!(
|
||||||
|
$request->status == TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL
|
||||||
|
|| $request->status == TicketInstallmentRequest::$STATUS_CANCELED
|
||||||
|
|| $request->status == TicketInstallmentRequest::$STATUS_REJECTED
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
$this->info("request can't be opened with status " . TicketInstallmentRequest::toStatusName($request->status));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$contract = Contract::findOne($request->id_contract);
|
||||||
|
|
||||||
|
if (!isset($contract)) {
|
||||||
|
throw new NotFoundHttpException("contract not found #" . $id_ticket_installment_request);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->openTicketInstallmentRequest($contract, $request);
|
||||||
|
|
||||||
|
$this->putToCart($contract, $request);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If status is
|
||||||
|
* TicketInstallmentRequest::$STATUS_ACCEPTED: nothing to do, automatic purchase was successful
|
||||||
|
* TicketInstallmentRequest::$STATUS_PENDING: nothing to do, automatic purchase was successful
|
||||||
|
* TicketInstallmentRequest::$STATUS_MARKED_TO_SEND: nothing to do, automatic purchase was successful
|
||||||
|
* TicketInstallmentRequest::$STATUS_SENT: nothing to do, automatic purchase was successful
|
||||||
|
* TicketInstallmentRequest::$STATUS_SENT: nothing to do, automatic purchase was successful
|
||||||
|
*
|
||||||
|
* @param $contract \common\models\Contract
|
||||||
|
* @param $part \common\models\TicketInstallmentRequest
|
||||||
|
* @throws \Exception
|
||||||
|
* @throws \Throwable
|
||||||
|
*/
|
||||||
|
public function openTicketInstallmentRequest($contract, $part)
|
||||||
|
{
|
||||||
|
$statusChanged = false;
|
||||||
|
if ($part->status == TicketInstallmentRequest::$STATUS_CANCELED) {
|
||||||
|
$part->status = TicketInstallmentRequest::$STATUS_PENDING;
|
||||||
|
$part->request_processed_at = null;
|
||||||
|
$statusChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($part->status == TicketInstallmentRequest::$STATUS_REJECTED) {
|
||||||
|
$part->status = TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL;
|
||||||
|
$statusChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($statusChanged) {
|
||||||
|
$part->save(false);
|
||||||
|
if (!$contract->isFlagActive()) {
|
||||||
|
$contract->flag = Contract::$FLAG_ACTIVE;
|
||||||
|
$contract->save(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $contract
|
||||||
|
* @param $part
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
private function putToCart($contract, $part)
|
||||||
|
{
|
||||||
|
/** @var \common\models\Ticket $ticket */
|
||||||
|
$ticket = Ticket::findOne(['id_ticket' => $part->id_ticket]);
|
||||||
|
|
||||||
|
if (isset($ticket)) {
|
||||||
|
$this->info("Ticket found: " . $ticket->id_ticket . "/" . $ticket->ticketType->name);
|
||||||
|
|
||||||
|
// inactivate ticket
|
||||||
|
if ($ticket->status != Ticket::STATUS_INACTIVE) {
|
||||||
|
$ticket->status = Ticket::STATUS_INACTIVE;
|
||||||
|
$ticket->save(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set transfer status to not paid
|
||||||
|
/** @var \common\models\Transfer $transfer */
|
||||||
|
$transfer = $ticket->transfer;
|
||||||
|
if ($transfer->status != Transfer::STATUS_NOT_PAID) {
|
||||||
|
// clean up transfer paid status
|
||||||
|
$statusOriginal = $transfer->status;
|
||||||
|
$transfer->status = Transfer::STATUS_NOT_PAID;
|
||||||
|
$transfer->paid_at = null;
|
||||||
|
$transfer->paid_by = null;
|
||||||
|
$transfer->payment_method = null;
|
||||||
|
$transfer->save(false);
|
||||||
|
|
||||||
|
$this->info("Restore transfer: ");
|
||||||
|
$this->info($transfer->id_transfer);
|
||||||
|
$this->info(Transfer::toStatusName($statusOriginal) . "->" . Ticket::toStatusName($transfer->status));
|
||||||
|
}
|
||||||
|
|
||||||
|
// check shopping cart
|
||||||
|
$cart = ShoppingCart::findOne(['id_transfer' => $transfer->id_transfer]);
|
||||||
|
// put transfer into cart if it is not there
|
||||||
|
if (!isset($cart)) {
|
||||||
|
$cart = new ShoppingCart();
|
||||||
|
$cart->id_customer = $contract->customer->id_customer;
|
||||||
|
$cart->id_transfer = $transfer->id_transfer;
|
||||||
|
if (!$cart->save(false)) {
|
||||||
|
/** @noinspection SpellCheckingInspection */
|
||||||
|
$E_FAILED_TO_SAVE = "Vendég kosár hozzárendelés sikertelen!";
|
||||||
|
\Yii::error($E_FAILED_TO_SAVE);
|
||||||
|
throw new \Exception($E_FAILED_TO_SAVE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function info($message)
|
||||||
|
{
|
||||||
|
\Yii::info($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -2,15 +2,14 @@
|
|||||||
|
|
||||||
namespace backend\controllers;
|
namespace backend\controllers;
|
||||||
|
|
||||||
|
use backend\components\ContractManager;
|
||||||
use Yii;
|
use Yii;
|
||||||
use common\models\Contract;
|
use common\models\Contract;
|
||||||
use backend\models\ContractSearch;
|
use backend\models\ContractSearch;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
use yii\filters\VerbFilter;
|
|
||||||
use backend\models\ContractCustomerSearch;
|
use backend\models\ContractCustomerSearch;
|
||||||
use common\models\Customer;
|
use common\models\Customer;
|
||||||
use yii\db\Query;
|
|
||||||
use backend\models\ContractRequestSearch;
|
use backend\models\ContractRequestSearch;
|
||||||
use common\models\TicketInstallmentRequest;
|
use common\models\TicketInstallmentRequest;
|
||||||
use common\models\Ticket;
|
use common\models\Ticket;
|
||||||
@ -64,6 +63,7 @@ class ContractController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* Lists all Contract models.
|
* Lists all Contract models.
|
||||||
*
|
*
|
||||||
|
* @param $id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws NotFoundHttpException
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
@ -197,10 +197,14 @@ class ContractController extends Controller {
|
|||||||
], [
|
], [
|
||||||
'id_contract' => $model->id_contract
|
'id_contract' => $model->id_contract
|
||||||
] );
|
] );
|
||||||
|
|
||||||
|
/** @var \common\models\Ticket $ticket */
|
||||||
$ticket = Ticket::find ()->andWhere ( [
|
$ticket = Ticket::find ()->andWhere ( [
|
||||||
'id_contract' => $model->id_contract
|
'id_contract' => $model->id_contract
|
||||||
] )->one ();
|
] )->one ();
|
||||||
|
|
||||||
|
|
||||||
|
/** @var \common\models\Transfer $transfer */
|
||||||
$transfer = Transfer::find ()->andWhere ( [
|
$transfer = Transfer::find ()->andWhere ( [
|
||||||
'type' => Transfer::TYPE_TICKET
|
'type' => Transfer::TYPE_TICKET
|
||||||
] )->andWhere ( [
|
] )->andWhere ( [
|
||||||
@ -239,7 +243,6 @@ class ContractController extends Controller {
|
|||||||
'contract' => $contract
|
'contract' => $contract
|
||||||
] );
|
] );
|
||||||
|
|
||||||
// $searchModel->contract = $contract;
|
|
||||||
|
|
||||||
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
|
$dataProvider = $searchModel->search ( Yii::$app->request->queryParams );
|
||||||
|
|
||||||
@ -250,6 +253,16 @@ class ContractController extends Controller {
|
|||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
* @throws \Throwable
|
||||||
|
*/
|
||||||
|
public function actionRequestToCart($id){
|
||||||
|
$contractManager = new ContractManager();
|
||||||
|
$contractManager->openRequestAndPutItItoCart($id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the Contract model based on its primary key value.
|
* Finds the Contract model based on its primary key value.
|
||||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||||
|
|||||||
@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
namespace backend\controllers;
|
namespace backend\controllers;
|
||||||
|
|
||||||
|
use backend\components\ContractManager;
|
||||||
use Yii;
|
use Yii;
|
||||||
use common\models\TicketInstallmentRequest;
|
use common\models\TicketInstallmentRequest;
|
||||||
use backend\models\TicketInstallmentRequestSearch;
|
use backend\models\TicketInstallmentRequestSearch;
|
||||||
|
use yii\helpers\Url;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
@ -58,7 +60,7 @@ class TicketInstallmentRequestController extends Controller
|
|||||||
{
|
{
|
||||||
$searchModel = new TicketInstallmentRequestSearch();
|
$searchModel = new TicketInstallmentRequestSearch();
|
||||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
Url::remember('',"ticket-installment-request/index");
|
||||||
return $this->render('index', [
|
return $this->render('index', [
|
||||||
'searchModel' => $searchModel,
|
'searchModel' => $searchModel,
|
||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
@ -86,6 +88,11 @@ class TicketInstallmentRequestController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return \yii\web\Response
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
*/
|
||||||
public function actionAccept($id )
|
public function actionAccept($id )
|
||||||
{
|
{
|
||||||
$model = $this->findModel($id);
|
$model = $this->findModel($id);
|
||||||
@ -94,19 +101,16 @@ class TicketInstallmentRequestController extends Controller
|
|||||||
$model->applyStatus(TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL,true);
|
$model->applyStatus(TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL,true);
|
||||||
\Yii::$app->session->setFlash('success',"Megbízás teljesítve");
|
\Yii::$app->session->setFlash('success',"Megbízás teljesítve");
|
||||||
}
|
}
|
||||||
// else{
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// echo "asdff";
|
|
||||||
|
|
||||||
return $this->redirect(['ticket-installment-request/view',
|
return $this->redirect(['ticket-installment-request/view',
|
||||||
'id' => $model->id_ticket_installment_request,
|
'id' => $model->id_ticket_installment_request,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists pending TicketInstallmentRequest models.
|
* Lists pending TicketInstallmentRequest models.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function actionDownloadGiro()
|
public function actionDownloadGiro()
|
||||||
{
|
{
|
||||||
@ -132,6 +136,7 @@ class TicketInstallmentRequestController extends Controller
|
|||||||
* Displays a single TicketInstallmentRequest model.
|
* Displays a single TicketInstallmentRequest model.
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function actionView($id)
|
public function actionView($id)
|
||||||
{
|
{
|
||||||
@ -163,6 +168,7 @@ class TicketInstallmentRequestController extends Controller
|
|||||||
* If update is successful, the browser will be redirected to the 'view' page.
|
* If update is successful, the browser will be redirected to the 'view' page.
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function actionUpdate($id)
|
public function actionUpdate($id)
|
||||||
{
|
{
|
||||||
@ -182,6 +188,8 @@ class TicketInstallmentRequestController extends Controller
|
|||||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
* @throws \yii\db\StaleObjectException
|
||||||
*/
|
*/
|
||||||
public function actionDelete($id)
|
public function actionDelete($id)
|
||||||
{
|
{
|
||||||
@ -192,10 +200,23 @@ class TicketInstallmentRequestController extends Controller
|
|||||||
|
|
||||||
public function actionTest( )
|
public function actionTest( )
|
||||||
{
|
{
|
||||||
|
|
||||||
return $this->render('test');
|
return $this->render('test');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return string
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
* @throws \Throwable
|
||||||
|
*/
|
||||||
|
public function actionPutToCart($id )
|
||||||
|
{
|
||||||
|
|
||||||
|
$contractManager = new ContractManager();
|
||||||
|
$contractManager->openRequestAndPutItItoCart($id);
|
||||||
|
return $this->redirect( Url::previous("ticket-installment-request/index"));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the TicketInstallmentRequest model based on its primary key value.
|
* Finds the TicketInstallmentRequest model based on its primary key value.
|
||||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
<?php
|
<?php /** @noinspection PhpUnhandledExceptionInspection */
|
||||||
|
|
||||||
|
|
||||||
use common\models\TicketInstallmentRequest;
|
use common\models\TicketInstallmentRequest;
|
||||||
use common\models\Ticket;
|
use common\models\Ticket;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
@ -17,10 +18,12 @@ use yii\helpers\Html;
|
|||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
<!--suppress CssUnusedSymbol -->
|
||||||
<style>
|
<style>
|
||||||
.accepted table td.status {
|
.accepted table td.status {
|
||||||
background-color: green;
|
background-color: green;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rejected table td.status {
|
.rejected table td.status {
|
||||||
background-color: #dd4b39;
|
background-color: #dd4b39;
|
||||||
}
|
}
|
||||||
@ -174,6 +177,14 @@ use yii\helpers\Html;
|
|||||||
if (!empty($model['ticket_id_ticket'])) {
|
if (!empty($model['ticket_id_ticket'])) {
|
||||||
echo Html::a("Szerződés megbízásai", ['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_contract]' => $model['request_id_contract']], ['class' => 'btn btn-primary']);
|
echo Html::a("Szerződés megbízásai", ['ticket-installment-request/index', 'TicketInstallmentRequestSearch[id_contract]' => $model['request_id_contract']], ['class' => 'btn btn-primary']);
|
||||||
}
|
}
|
||||||
|
if (TicketInstallmentRequest::canBePutToCustomerCart($model['request_status'])) {
|
||||||
|
echo Html::a("Kosárba helyez", ['ticket-installment-request/put-to-cart' , 'id' => $model['request_id_ticket_installment_request']],
|
||||||
|
[
|
||||||
|
'class' => 'btn btn-danger',
|
||||||
|
'data-method' => 'POST'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -64,4 +64,5 @@ return [
|
|||||||
'ticket_type_door_allowed_check_on' => false,
|
'ticket_type_door_allowed_check_on' => false,
|
||||||
'warn_ticket_expire_in_days_count' => 3,
|
'warn_ticket_expire_in_days_count' => 3,
|
||||||
'warn_ticket_expire_in_usage_count' => 3,
|
'warn_ticket_expire_in_usage_count' => 3,
|
||||||
|
'inventory.products.only.active' => true
|
||||||
];
|
];
|
||||||
|
|||||||
@ -71,7 +71,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function validateOnlyClosed($attribute,$params){
|
public function validateOnlyClosed( ){
|
||||||
$opened = Inventory::find()->andWhere(['status' => Inventory::$STATUS_OPEN])->all();
|
$opened = Inventory::find()->andWhere(['status' => Inventory::$STATUS_OPEN])->all();
|
||||||
if ( count($opened) > 0 ){
|
if ( count($opened) > 0 ){
|
||||||
$this->addError("name","Kérem előbb zárjon le minden másik leltárt");
|
$this->addError("name","Kérem előbb zárjon le minden másik leltárt");
|
||||||
@ -94,6 +94,11 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
|
|||||||
], parent::behaviors());
|
], parent::behaviors());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $insert
|
||||||
|
* @param $changedAttributes
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
public function afterSave($insert, $changedAttributes){
|
public function afterSave($insert, $changedAttributes){
|
||||||
if ( $insert ){
|
if ( $insert ){
|
||||||
|
|
||||||
@ -101,11 +106,17 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
|
|||||||
if ( isset($this->id_account) && is_numeric($this->id_account)){
|
if ( isset($this->id_account) && is_numeric($this->id_account)){
|
||||||
$query->andWhere(['id_account' => $this->id_account]);
|
$query->andWhere(['id_account' => $this->id_account]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( \Yii::$app->params['inventory.products.only.active']) {
|
||||||
|
$query->andWhere( ['status' => Product::STATUS_ACTIVE] );
|
||||||
|
}
|
||||||
|
|
||||||
$products = $query->all();
|
$products = $query->all();
|
||||||
|
|
||||||
$inventoryGroups = InventoryGroup::find()->all();
|
$inventoryGroups = InventoryGroup::find()->all();
|
||||||
|
|
||||||
|
|
||||||
|
/** @var \common\models\Product $product */
|
||||||
foreach ($products as $product){
|
foreach ($products as $product){
|
||||||
$form = new InventoryItemForm(
|
$form = new InventoryItemForm(
|
||||||
[
|
[
|
||||||
@ -118,6 +129,7 @@ class Inventory extends \common\models\BaseFitnessActiveRecord
|
|||||||
$form->save();
|
$form->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var \common\models\InventoryGroup $group */
|
||||||
foreach ($inventoryGroups as $group){
|
foreach ($inventoryGroups as $group){
|
||||||
$form = new InventoryItemForm(
|
$form = new InventoryItemForm(
|
||||||
[
|
[
|
||||||
|
|||||||
@ -36,6 +36,8 @@ use common\components\Helper;
|
|||||||
*
|
*
|
||||||
* @property \common\models\Card card
|
* @property \common\models\Card card
|
||||||
* @property \common\models\Ticket transfer
|
* @property \common\models\Ticket transfer
|
||||||
|
* @property \common\models\TicketType ticketType
|
||||||
|
* @property \common\models\Discount discount
|
||||||
*/
|
*/
|
||||||
class Ticket extends \common\models\BaseFitnessActiveRecord
|
class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||||
{
|
{
|
||||||
|
|||||||
@ -343,4 +343,11 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
|||||||
return static::toStatusName($this->status);
|
return static::toStatusName($this->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function canBePutToCustomerCart($status){
|
||||||
|
return $status == TicketInstallmentRequest::$STATUS_CANCELED
|
||||||
|
||
|
||||||
|
$status == TicketInstallmentRequest::$STATUS_REJECTED
|
||||||
|
||
|
||||||
|
$status == TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace console\controllers;
|
namespace console\controllers;
|
||||||
|
|
||||||
|
use backend\components\ContractManager;
|
||||||
use common\models\Card;
|
use common\models\Card;
|
||||||
use common\models\Contract;
|
use common\models\Contract;
|
||||||
use common\models\Customer;
|
use common\models\Customer;
|
||||||
@ -15,6 +16,17 @@ use yii\console\Exception;
|
|||||||
class ContractController extends Controller
|
class ContractController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $requestId
|
||||||
|
* @throws \Throwable
|
||||||
|
* @throws \yii\web\NotFoundHttpException
|
||||||
|
*/
|
||||||
|
public function actionRequestToCart($requestId){
|
||||||
|
$contractManager = new ContractManager();
|
||||||
|
$contractManager->openRequestAndPutItItoCart($requestId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $cardNumber
|
* @param $cardNumber
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
@ -84,15 +96,15 @@ class ContractController extends Controller
|
|||||||
);
|
);
|
||||||
} else if ($part->isStatusAccepted()) {
|
} else if ($part->isStatusAccepted()) {
|
||||||
$this->info("loading ticket: #" .$part->id_ticket);
|
$this->info("loading ticket: #" .$part->id_ticket);
|
||||||
|
/** @var \common\models\Ticket $ticket */
|
||||||
$ticket = null;
|
$ticket = null;
|
||||||
try {
|
try {
|
||||||
/** @var \common\models\Ticket $ticket */
|
$ticket = Ticket::findOne(['id_ticket' => $part->id_ticket]);
|
||||||
// $ticket = Ticket::findOne(['id_ticket' => $part->id_ticket]);
|
|
||||||
}catch (\Throwable $e){
|
}catch (\Throwable $e){
|
||||||
\Yii::info("Failed to load ticket: " . $e->getMessage());
|
\Yii::info("Failed to load ticket: " . $e->getMessage());
|
||||||
}
|
}
|
||||||
if (isset($ticket)) {
|
if (isset($ticket)) {
|
||||||
$this->info("Ticket found: " . $ticket->id_ticket . "/" . $ticket->ticetType->name);
|
$this->info("Ticket found: " . $ticket->id_ticket . "/" . $ticket->ticketType->name);
|
||||||
if ($ticket->status == Ticket::STATUS_DELETED) {
|
if ($ticket->status == Ticket::STATUS_DELETED) {
|
||||||
$ticket->status = Ticket::STATUS_ACTIVE;
|
$ticket->status = Ticket::STATUS_ACTIVE;
|
||||||
$ticket->save(false);
|
$ticket->save(false);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user