update card after activate
This commit is contained in:
@@ -33,32 +33,29 @@ class CustomerActivateForm extends Model{
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function activate(){
|
||||
if ( !$this->validate()){
|
||||
if (!$this->validate()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$tx = \Yii::$app->db->beginTransaction();
|
||||
assert(isset($tx));
|
||||
try{
|
||||
Yii::$app->db->createCommand(Ticket::$SQL_UPDATE_TICKETS_END_DATE_ON_CARD_ACTIVATION )->execute();
|
||||
Card::updateAll(
|
||||
[
|
||||
'status' => Card::STATUS_ACTIVE,
|
||||
],
|
||||
[
|
||||
'status' => Card::STATUS_INACTIVE
|
||||
]
|
||||
);
|
||||
try {
|
||||
// update ticket end dates
|
||||
Yii::$app->db->createCommand(Ticket::$SQL_UPDATE_TICKETS_END_DATE_ON_CARD_ACTIVATION)->execute();
|
||||
// update card.status
|
||||
Card::updateAll([ 'status' => Card::STATUS_ACTIVE, ], [ 'status' => Card::STATUS_INACTIVE ] );
|
||||
// update card.flag
|
||||
Card::updateFlagStatus();
|
||||
// update ticket
|
||||
\Yii::$app->db->createCommand(Ticket::$SQL_UPDATE)->execute();
|
||||
|
||||
|
||||
Card::updateFlagStatus();
|
||||
$tx->commit();
|
||||
}catch (\Exception $exception){
|
||||
$tx->commit();
|
||||
} catch (\Exception $exception) {
|
||||
$tx->rollBack();
|
||||
throw $exception;
|
||||
}
|
||||
$this->message = $this->inactiveCardCount ." kártya aktiválva" ;
|
||||
return true;
|
||||
$this->message = $this->inactiveCardCount . " kártya aktiválva";
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user