update card after activate
This commit is contained in:
parent
9d861a9194
commit
806501fbd6
@ -33,32 +33,29 @@ class CustomerActivateForm extends Model{
|
|||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function activate(){
|
public function activate(){
|
||||||
if ( !$this->validate()){
|
if (!$this->validate()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tx = \Yii::$app->db->beginTransaction();
|
$tx = \Yii::$app->db->beginTransaction();
|
||||||
assert(isset($tx));
|
assert(isset($tx));
|
||||||
try{
|
try {
|
||||||
Yii::$app->db->createCommand(Ticket::$SQL_UPDATE_TICKETS_END_DATE_ON_CARD_ACTIVATION )->execute();
|
// update ticket end dates
|
||||||
Card::updateAll(
|
Yii::$app->db->createCommand(Ticket::$SQL_UPDATE_TICKETS_END_DATE_ON_CARD_ACTIVATION)->execute();
|
||||||
[
|
// update card.status
|
||||||
'status' => Card::STATUS_ACTIVE,
|
Card::updateAll([ 'status' => Card::STATUS_ACTIVE, ], [ 'status' => Card::STATUS_INACTIVE ] );
|
||||||
],
|
// update card.flag
|
||||||
[
|
Card::updateFlagStatus();
|
||||||
'status' => Card::STATUS_INACTIVE
|
// update ticket
|
||||||
]
|
\Yii::$app->db->createCommand(Ticket::$SQL_UPDATE)->execute();
|
||||||
);
|
|
||||||
|
|
||||||
|
$tx->commit();
|
||||||
Card::updateFlagStatus();
|
} catch (\Exception $exception) {
|
||||||
$tx->commit();
|
|
||||||
}catch (\Exception $exception){
|
|
||||||
$tx->rollBack();
|
$tx->rollBack();
|
||||||
throw $exception;
|
throw $exception;
|
||||||
}
|
}
|
||||||
$this->message = $this->inactiveCardCount ." kártya aktiválva" ;
|
$this->message = $this->inactiveCardCount . " kártya aktiválva";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ namespace frontend\models;
|
|||||||
|
|
||||||
use common\models\Card;
|
use common\models\Card;
|
||||||
use common\models\Ticket;
|
use common\models\Ticket;
|
||||||
|
use Exception;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
use yii\data\ArrayDataProvider;
|
use yii\data\ArrayDataProvider;
|
||||||
@ -98,7 +99,7 @@ class SingleCustomerActivateForm extends Model{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws \Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function activate()
|
public function activate()
|
||||||
{
|
{
|
||||||
@ -106,7 +107,7 @@ class SingleCustomerActivateForm extends Model{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tx = \Yii::$app->db->beginTransaction();
|
$tx = Yii::$app->db->beginTransaction();
|
||||||
assert(isset($tx));
|
assert(isset($tx));
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -122,8 +123,11 @@ class SingleCustomerActivateForm extends Model{
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
Card::updateFlagStatus();
|
Card::updateFlagStatus();
|
||||||
|
|
||||||
|
Card::updateCardFlagTicket( $this->card->id_card);
|
||||||
|
|
||||||
$tx->commit();
|
$tx->commit();
|
||||||
} catch (\Exception $exception) {
|
} catch (Exception $exception) {
|
||||||
$tx->rollBack();
|
$tx->rollBack();
|
||||||
throw $exception;
|
throw $exception;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user