improve detsta
This commit is contained in:
parent
3b7f42014b
commit
6efbfa7d9b
@ -16,6 +16,10 @@ use common\models\Customer;
|
|||||||
use common\models\Card;
|
use common\models\Card;
|
||||||
use backend\models\TicketSearchStatisitcs;
|
use backend\models\TicketSearchStatisitcs;
|
||||||
use backend\models\TicketSearchCustomer;
|
use backend\models\TicketSearchCustomer;
|
||||||
|
use common\components\TicketSale;
|
||||||
|
use common\models\Contract;
|
||||||
|
use common\components\giro\GiroDETSTATetel;
|
||||||
|
use common\components\DetStatTetelProcessor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TicketController implements the CRUD actions for Ticket model.
|
* TicketController implements the CRUD actions for Ticket model.
|
||||||
@ -34,7 +38,8 @@ class TicketController extends \backend\controllers\BackendController {
|
|||||||
'view',
|
'view',
|
||||||
'update',
|
'update',
|
||||||
'index-customer',
|
'index-customer',
|
||||||
'statistics'
|
'statistics' ,
|
||||||
|
'test'
|
||||||
],
|
],
|
||||||
'allow' => true,
|
'allow' => true,
|
||||||
'roles' => [
|
'roles' => [
|
||||||
@ -223,6 +228,58 @@ class TicketController extends \backend\controllers\BackendController {
|
|||||||
] );
|
] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function actionTest(){
|
||||||
|
|
||||||
|
// $this->doTestTicketSale();
|
||||||
|
|
||||||
|
$this->doTestDetstaProcess();
|
||||||
|
|
||||||
|
return $this->render('test');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function doTestDetstaProcess(){
|
||||||
|
$contract = Contract::findOne(19);
|
||||||
|
$megbizas = $contract->requests[0];
|
||||||
|
|
||||||
|
$tetel = new GiroDETSTATetel();
|
||||||
|
$tetel->visszajelzesInformacio = "02";
|
||||||
|
|
||||||
|
$tp = new DetStatTetelProcessor([
|
||||||
|
'megbizas' => $megbizas,
|
||||||
|
'tetel' => $tetel
|
||||||
|
]);
|
||||||
|
|
||||||
|
$tp->run();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function doTestTicketSale(){
|
||||||
|
$ticketType = TicketType::findOne(1);
|
||||||
|
$customer = Customer::findOne(1);
|
||||||
|
$account = Account::findOne(1);
|
||||||
|
$card = $customer->card;
|
||||||
|
$discount = null;
|
||||||
|
$contract = Contract::findOne(19);
|
||||||
|
$megbizas = $contract->requests[0];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$ticketSale = new TicketSale(
|
||||||
|
[
|
||||||
|
'ticketType'=> $ticketType,
|
||||||
|
'customer'=> $customer,
|
||||||
|
'account'=> $account,
|
||||||
|
'card'=> $card,
|
||||||
|
'discount'=> $discount,
|
||||||
|
'contract'=> $contract,
|
||||||
|
'ticketInstallmentRequest' => $megbizas
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$ticketSale->doSale();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the Ticket model based on its primary key value.
|
* Finds the Ticket 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
backend/views/ticket/test.php
Normal file
1
backend/views/ticket/test.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
test
|
||||||
@ -65,7 +65,7 @@ class DetStatProcessor extends Object{
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
$processor->run();
|
$processor->run();
|
||||||
$this->errors = $this->errors + $processor->errors;
|
// $this->errors = $this->errors + $processor->errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,21 +129,21 @@ class DetStatProcessor extends Object{
|
|||||||
$this->megbizasok = $this->koteg->requests;
|
$this->megbizasok = $this->koteg->requests;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyNewMegbizasState(){
|
// public function applyNewMegbizasState(){
|
||||||
$kod = $this->tetel->valaszHivatkozasiKod;
|
// $kod = $this->tetel->valaszHivatkozasiKod;
|
||||||
|
|
||||||
if ( $kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT){
|
// if ( $kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT){
|
||||||
$this->megbizas->status = TicketInstallmentRequest::$STATUS_ACCEPTED;
|
// $this->megbizas->status = TicketInstallmentRequest::$STATUS_ACCEPTED;
|
||||||
}else{
|
// }else{
|
||||||
$this->megbizas->status = TicketInstallmentRequest::$STATUS_REJECTED;
|
// $this->megbizas->status = TicketInstallmentRequest::$STATUS_REJECTED;
|
||||||
}
|
// }
|
||||||
$this->megbizas->save(false);
|
// $this->megbizas->save(false);
|
||||||
}
|
// }
|
||||||
|
|
||||||
public function applyNewTicketState(){
|
// public function applyNewTicketState(){
|
||||||
$this->ticket->applyTicketInstallmentRequest($this->megbizas);
|
// $this->ticket->applyTicketInstallmentRequest($this->megbizas);
|
||||||
$this->ticket->save(false);
|
// $this->ticket->save(false);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
public function hasError(){
|
public function hasError(){
|
||||||
|
|||||||
@ -5,10 +5,8 @@ namespace common\components;
|
|||||||
use yii\base\Object;
|
use yii\base\Object;
|
||||||
use common\models\TicketInstallmentRequest;
|
use common\models\TicketInstallmentRequest;
|
||||||
use common\components\giro\GiroDETSTATetel;
|
use common\components\giro\GiroDETSTATetel;
|
||||||
use backend\models\TicketInstallmentMarkForSendForm;
|
|
||||||
use common\models\Transfer;
|
|
||||||
use common\models\Account;
|
use common\models\Account;
|
||||||
use common\models\Discount;
|
use common\models\Contract;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the model class for table "ticket".
|
* This is the model class for table "ticket".
|
||||||
@ -16,114 +14,265 @@ use common\models\Discount;
|
|||||||
* @property common\components\giro\GiroDETSTATetel $tetel
|
* @property common\components\giro\GiroDETSTATetel $tetel
|
||||||
* @property common\models\TicketInstallmentRequest $megbizas
|
* @property common\models\TicketInstallmentRequest $megbizas
|
||||||
* @property common\models\Ticket $ticket
|
* @property common\models\Ticket $ticket
|
||||||
|
* @property common\models\Contract $contract
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class DetStatTetelProcessor extends Object {
|
class DetStatTetelProcessor extends Object {
|
||||||
|
/**
|
||||||
|
* A válasz tétel . Ha nincs megadva, automatikus visszautasítjuk a megbízást
|
||||||
|
* */
|
||||||
public $tetel; // config
|
public $tetel; // config
|
||||||
|
/**
|
||||||
|
* A megbízás. Ha a megbízás már el van fogadva, megszakítjuk a feldolgozást
|
||||||
|
* */
|
||||||
public $megbizas; // config
|
public $megbizas; // config
|
||||||
public $ticket;
|
/**
|
||||||
public $errors = [ ];
|
* A szerződés. A megbízás hoz tartozó szerződés
|
||||||
public $dryRun = false; // for testing, to not to persist the changes
|
* */
|
||||||
|
public $contract;
|
||||||
|
/**
|
||||||
|
* a tételből kiolvasott kód. Lásd extractKodAndStatus
|
||||||
|
* */
|
||||||
|
protected $kod;
|
||||||
|
/**
|
||||||
|
* Státusz. Az új státusza a megbízásnak a tétel alapján
|
||||||
|
* */
|
||||||
|
protected $status;
|
||||||
|
/**
|
||||||
|
* A komment. Lásd fillComment metódus
|
||||||
|
* */
|
||||||
|
protected $comment;
|
||||||
|
/**
|
||||||
|
* A bérlet objectkum, amit elmentettünk
|
||||||
|
* */
|
||||||
|
protected $ticket;
|
||||||
|
/**
|
||||||
|
* A tranzakció, amit mentettünk
|
||||||
|
* */
|
||||||
|
protected $transfer;
|
||||||
|
|
||||||
|
protected $eredetiMegbizasStatus;
|
||||||
|
|
||||||
public function run() {
|
public function run() {
|
||||||
// $this->readMegbizas();
|
|
||||||
if ($this->megbizas->isStatusAccepted()) {
|
\Yii::info('Megbízás feldolgozása: megbízás azonosító=' .$this->megbizas->id_ticket_installment_request);
|
||||||
|
|
||||||
|
if ($this->isAlreadeyAccepted ()) {
|
||||||
|
// \Yii::info('A megbízás feldolgozásának megszakítása. A megbízás már elfogadott: megbízás azonosító=' .$this->megbizas->id_ticket_installment_request);
|
||||||
// return;
|
// return;
|
||||||
}
|
}
|
||||||
$status = TicketInstallmentRequest::$STATUS_REJECTED;
|
|
||||||
$kod = 'xx';
|
$this->rememberEredetiMegbizasStatus();
|
||||||
$comment = "";
|
$this->readContract();
|
||||||
if (isset ( $this->tetel )) {
|
$this->extractKodAndStatus ();
|
||||||
$kod = $this->tetel->visszajelzesInformacio;
|
$this->fillComment();
|
||||||
|
|
||||||
|
if ( $this->status == TicketInstallmentRequest::$STATUS_ACCEPTED ){
|
||||||
|
$this->buyNewTicket();
|
||||||
|
}else{
|
||||||
|
$this->doRejectRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT) {
|
}
|
||||||
$status = TicketInstallmentRequest::$STATUS_ACCEPTED;
|
|
||||||
} else {
|
|
||||||
$status = TicketInstallmentRequest::$STATUS_REJECTED;
|
|
||||||
|
|
||||||
if ( $kod == "xx"){
|
|
||||||
$comment = "Nem található a detsta fájlban a tétel válasza";
|
protected function rememberEredetiMegbizasStatus(){
|
||||||
}else{
|
$this->eredetiMegbizasStatus = $this->megbizas->status;
|
||||||
if ( array_key_exists($kod, GiroDETSTATetel::$INFORMACIOK)){
|
}
|
||||||
$comment = "Hiba kód: ".$kod ." - " .GiroDETSTATetel::$INFORMACIOK[$kod];
|
|
||||||
}else{
|
protected function isEredetiMegbizasStatusFinished(){
|
||||||
$comment = "Ismeretlen hiba kód: " .$kod;
|
return $this->eredetiMegbizasStatus == TicketInstallmentRequest::$STATUS_ACCEPTED ||
|
||||||
|
$this->eredetiMegbizasStatus == TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL ||
|
||||||
|
$this->eredetiMegbizasStatus == TicketInstallmentRequest::$STATUS_REJECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buyNewTicket(){
|
||||||
|
\Yii::info('Új bérlet vásárlás folyamant indítása' );
|
||||||
|
|
||||||
|
$megbizas = $this->megbizas;
|
||||||
|
$customer = $this->contract->customer;
|
||||||
|
$card = $customer->card;
|
||||||
|
$account = Account::findOne(1);
|
||||||
|
$ticketType = $this->contract->ticketType;
|
||||||
|
$discount = $this->contract->discount;
|
||||||
|
|
||||||
|
$ticketSale = new TicketSale(
|
||||||
|
[
|
||||||
|
'ticketType'=> $ticketType,
|
||||||
|
'customer'=> $customer,
|
||||||
|
'account'=> $account,
|
||||||
|
'card'=> $card,
|
||||||
|
'discount'=> $discount,
|
||||||
|
'contract'=> $this->contract,
|
||||||
|
'ticketInstallmentRequest' => $megbizas
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$ticketSale->doSale();
|
||||||
|
\Yii::info('Bérlet és tranzakció elmentve' );
|
||||||
|
|
||||||
|
$this->transfer = $ticketSale->transfer;
|
||||||
|
$this->ticket = $ticketSale->ticket;
|
||||||
|
|
||||||
|
$this->updateContractOnSuccess();
|
||||||
|
$this->updateMegbizasOnSuccess();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A szerződés betöltése
|
||||||
|
* */
|
||||||
|
protected function readContract(){
|
||||||
|
$this->contract = $this->megbizas->contract;
|
||||||
|
\Yii::info('Szerződés betöltve. Id:' .$this->contract->id_contract);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A megbízás módosítása sikeres detsta üzenet esetén
|
||||||
|
* */
|
||||||
|
protected function updateMegbizasOnSuccess(){
|
||||||
|
|
||||||
|
\Yii::info('Megbízás frissítése - megbizás elfogadva ' );
|
||||||
|
|
||||||
|
$this->megbizas->status = $this->status;
|
||||||
|
$this->megbizas->id_transfer = $this->transfer->id_transfer;
|
||||||
|
$this->megbizas->id_ticket = $this->ticket->id_ticket;
|
||||||
|
$this->megbizas->request_processed_at = Helper::getDateTimeString();
|
||||||
|
$this->megbizas->detsta_answer = $this->kod;
|
||||||
|
$this->megbizas->comment = $this->comment;
|
||||||
|
|
||||||
|
if ( !$this->megbizas->save(false) ){
|
||||||
|
\Yii::error("Nem sikerült menteni a megbízást!");
|
||||||
|
throw new \Exception("Nem sikerült menteni a megbízást!");
|
||||||
|
}
|
||||||
|
\Yii::info("A megbízás elmentve!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Megbízás módosítása , ha a detsta üzenetben a megbízás vissza lett utasítva
|
||||||
|
* */
|
||||||
|
protected function updateMegbizasOnFail(){
|
||||||
|
|
||||||
|
\Yii::info('Megbázás frissítése - megbízás visszautasítva ' );
|
||||||
|
|
||||||
|
$this->megbizas->status = $this->status;
|
||||||
|
$this->megbizas->detsta_answer = $this->kod;
|
||||||
|
$this->megbizas->comment = $this->comment;
|
||||||
|
$this->megbizas->request_processed_at = Helper::getDateTimeString();
|
||||||
|
|
||||||
|
if ( !$this->megbizas->save(false) ){
|
||||||
|
\Yii::error("Nem sikerült menteni a megbízást!");
|
||||||
|
throw new \Exception("Nem sikerült menteni a megbízást!");
|
||||||
|
}
|
||||||
|
\Yii::info("A megbízás elmentve!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Szerződés módosítása, ha a detsta üzenetben a megbízás el lett fogadva
|
||||||
|
* */
|
||||||
|
protected function updateContractOnSuccess(){
|
||||||
|
\Yii::info('Szerződés frissítése - megbizás elfogadva ' );
|
||||||
|
$this->incRequiredParts();
|
||||||
|
$this->contract->part_paid = $this->contract->part_paid +1;
|
||||||
|
$this->updateContractPaidStatus();
|
||||||
|
|
||||||
|
if ( !$this->contract->save(false) ){
|
||||||
|
\Yii::error("Nem sikerült menteni a szerződést!");
|
||||||
|
throw new \Exception("Nem sikerült menteni a szerződést!");
|
||||||
|
}
|
||||||
|
\Yii::info("A szerződés elmentve!");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function updateContractOnFail(){
|
||||||
|
\Yii::info('Szerződés frissítése - megbizás visszautasítva ' );
|
||||||
|
$this->incRequiredParts();
|
||||||
|
$this->updateContractPaidStatus();
|
||||||
|
// $this->contract->status = Contract::$STATUS_NOT_PAID;
|
||||||
|
if ( !$this->contract->save(false) ){
|
||||||
|
\Yii::error("Nem sikerült menteni a szerződést!");
|
||||||
|
throw new \Exception("Nem sikerült menteni a szerződést!");
|
||||||
|
}
|
||||||
|
\Yii::info("A szerződés elmentve!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Szerződés
|
||||||
|
* */
|
||||||
|
protected function incRequiredParts(){
|
||||||
|
if ( !$this->isEredetiMegbizasStatusFinished() ){
|
||||||
|
$this->contract->part_required = $this->contract->part_required +1;
|
||||||
|
\Yii::info("Szerződés szükséges megbizások száma növelve");
|
||||||
|
}else{
|
||||||
|
\Yii::info("Szerződés szükséges megbizások száma nem lett növelve az eredeti státusz miatt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function updateContractPaidStatus(){
|
||||||
|
$required = $this->contract->part_required;
|
||||||
|
$paid = $this->contract->part_paid;
|
||||||
|
$ok = $required <= $paid;
|
||||||
|
if ($ok ){
|
||||||
|
$this->contract->status = Contract::$STATUS_PAID;
|
||||||
|
}else{
|
||||||
|
$this->contract->status = Contract::$STATUS_NOT_PAID;
|
||||||
|
}
|
||||||
|
\Yii::info("Szerződés új státusza id= " .$this->contract->id_contract . ", Státusz: " . $this->contract->status . " (" . Contract::toStatusName($this->contract->status) . ")");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Szerződés és megbízás frissítése , ha a detsta üzenet visszautásításra került
|
||||||
|
* */
|
||||||
|
protected function doRejectRequest(){
|
||||||
|
$this->updateContractOnFail();
|
||||||
|
$this->updateMegbizasOnFail();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Komment összeállítás a status mező alapján
|
||||||
|
* */
|
||||||
|
protected function fillComment() {
|
||||||
|
$this->comment = "Megbízás teljesítve";
|
||||||
|
if ($this->status != TicketInstallmentRequest::$STATUS_ACCEPTED) {
|
||||||
|
if ($this->kod == "xx") {
|
||||||
|
$this->comment = "Nem található a detsta fájlban a tétel válasza";
|
||||||
|
} else {
|
||||||
|
if (array_key_exists ( $this->kod, GiroDETSTATetel::$INFORMACIOK )) {
|
||||||
|
$this->comment = "Hiba kód: " . $this->kod . " - " . GiroDETSTATetel::$INFORMACIOK [$this->kod];
|
||||||
|
} else {
|
||||||
|
$this->comment = "Ismeretlen hiba kód: " . $this->kod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->megbizas->applyStatus($status,true,$kod,$comment);
|
|
||||||
|
|
||||||
|
|
||||||
// $this->readTicket();
|
|
||||||
// if ( !$this->hasError() ){
|
|
||||||
// $this->applyNewMegbizasState();
|
|
||||||
// $this->applyNewTicketState();
|
|
||||||
// $this->addTransfer();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public function readMegbizas(){
|
/**
|
||||||
// $this->megbizas = TicketInstallmentRequest::findOne($this->tetel->ugyfelAzonosito);
|
* Visszajelző kód kiolvasása a detsta tételből.
|
||||||
// if ( !isset($this->megbizas) ){
|
* Status beállítása a kód alapján
|
||||||
// $this->errors [] = "Válaszban jelölt megbízás nem található! (".$this->tetel->ugyfelAzonosito." )";
|
* */
|
||||||
// }
|
protected function extractKodAndStatus() {
|
||||||
// }
|
\Yii::info('Visszajelző kód kiolvasása' );
|
||||||
// public function readTicket(){
|
$this->status = TicketInstallmentRequest::$STATUS_REJECTED;
|
||||||
// $this->ticket = $this->megbizas->ticket;
|
$this->kod = 'xx';
|
||||||
// if ( !isset($this->ticket) ){
|
if (isset ( $this->tetel )) {
|
||||||
// $this->errors [] = "Válaszban jelölt bérlet nem található! (".$this->megbizas->id_ticket." )";
|
$this->kod = $this->tetel->visszajelzesInformacio;
|
||||||
// }
|
}
|
||||||
// }
|
if ($this->kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT) {
|
||||||
|
$this->status = TicketInstallmentRequest::$STATUS_ACCEPTED;
|
||||||
// public function applyNewMegbizasState(){
|
} else {
|
||||||
// $kod = 'xx';
|
$this->status = TicketInstallmentRequest::$STATUS_REJECTED;
|
||||||
// if ( isset($this->tetel ) ) {
|
}
|
||||||
// $kod = $this->tetel->visszajelzesInformacio;
|
\Yii::info('Visszajelző kód kiolvasva: kod=' .$this->kod);
|
||||||
// }
|
\Yii::info('Visszajelző kód kiolvasva: statusz=' .$this->status. " (" . TicketInstallmentRequest::toStatusName($this->status) .")");
|
||||||
|
}
|
||||||
// if ( $kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT){
|
protected function isAlreadeyAccepted() {
|
||||||
// $this->megbizas->status = TicketInstallmentRequest::$STATUS_ACCEPTED;
|
return $this->megbizas->isStatusAccepted ();
|
||||||
// }else{
|
}
|
||||||
// $this->megbizas->status = TicketInstallmentRequest::$STATUS_REJECTED;
|
|
||||||
// }
|
|
||||||
// if ( !$this->isDryRun() ){
|
|
||||||
// $this->megbizas->save(false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public function applyNewTicketState(){
|
|
||||||
// $this->ticket->applyTicketInstallmentRequest($this->megbizas);
|
|
||||||
// if ( !$this->isDryRun() ){
|
|
||||||
// $this->ticket->save(false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// protected function addTransfer(){
|
|
||||||
|
|
||||||
// $account = Account::findOne($this->ticket->id_account);
|
|
||||||
// $discount = null;
|
|
||||||
// if ( isset($this->ticket->id_account)){
|
|
||||||
// $discount = Discount::findOne( $this->ticket->id_discount );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $transfer = Transfer::createTicketTransfer($account, $discount, null, 1, $this->ticket);
|
|
||||||
|
|
||||||
// $transfer->status = Transfer::STATUS_PAID;
|
|
||||||
// $transfer->paid_at = date('Y-m-d H:i:s' ) ;
|
|
||||||
// $transfer->paid_by = \Yii::$app->user->id;
|
|
||||||
// $transfer->payment_method = Transfer::PAYMENT_METHOD_TRANSFER;
|
|
||||||
// $transfer->money = $this->megbizas->money;
|
|
||||||
// $transfer->comment = "Csoportos beszedes";
|
|
||||||
// $transfer->id_user = \Yii::$app->user->id;
|
|
||||||
// $transfer->id_customer = $this->ticket->id_customer;
|
|
||||||
// $transfer->save(false);
|
|
||||||
// }
|
|
||||||
public function hasError() {
|
public function hasError() {
|
||||||
return count ( $this->errors ) > 0;
|
return false;
|
||||||
}
|
|
||||||
public function isDryRun() {
|
|
||||||
return $this->dryRun;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,6 +92,10 @@ class Helper {
|
|||||||
|
|
||||||
return date("Y-m-d H:i:s");
|
return date("Y-m-d H:i:s");
|
||||||
}
|
}
|
||||||
|
public static function getDateString( ){
|
||||||
|
|
||||||
|
return date("Y-m-d");
|
||||||
|
}
|
||||||
|
|
||||||
public static function getArrayValue($arr,$key,$def){
|
public static function getArrayValue($arr,$key,$def){
|
||||||
$result = $def;
|
$result = $def;
|
||||||
|
|||||||
7
common/components/TicketSale.php
Normal file
7
common/components/TicketSale.php
Normal file
File diff suppressed because one or more lines are too long
@ -122,6 +122,11 @@ class Contract extends \yii\db\ActiveRecord
|
|||||||
public function getRequests(){
|
public function getRequests(){
|
||||||
return $this->hasMany(TicketInstallmentRequest::className(), ['id_contract' => 'id_contract']);
|
return $this->hasMany(TicketInstallmentRequest::className(), ['id_contract' => 'id_contract']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDiscount(){
|
||||||
|
return $this->hasOne(Discount::className(), ['id_discount' => 'id_discount']);
|
||||||
|
}
|
||||||
|
|
||||||
// public static $STATUS_PAID = 10;
|
// public static $STATUS_PAID = 10;
|
||||||
// public static $STATUS_NOT_PAID = 20;
|
// public static $STATUS_NOT_PAID = 20;
|
||||||
|
|
||||||
|
|||||||
@ -243,7 +243,7 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
|
|||||||
$count = $type->installment_count;
|
$count = $type->installment_count;
|
||||||
$discount = $ticket->discount;
|
$discount = $ticket->discount;
|
||||||
$money = $type->installment_money;
|
$money = $type->installment_money;
|
||||||
if ( isset($discount ) ){
|
if ( isset( $discount ) ){
|
||||||
$money = Discount::applyDiscount($money, $discount);
|
$money = Discount::applyDiscount($money, $discount);
|
||||||
}
|
}
|
||||||
$ticketCreatedAt = time();
|
$ticketCreatedAt = time();
|
||||||
|
|||||||
@ -23,8 +23,17 @@ class Ugiro extends \yii\db\ActiveRecord
|
|||||||
|
|
||||||
public static $PATH_MEGBIZAS = "giro/megbizas";
|
public static $PATH_MEGBIZAS = "giro/megbizas";
|
||||||
public static $PATH_VALASZ = "giro/valasz";
|
public static $PATH_VALASZ = "giro/valasz";
|
||||||
|
/**
|
||||||
|
* beszed fájl kész
|
||||||
|
* */
|
||||||
public static $STATUS_SENT = 0;
|
public static $STATUS_SENT = 0;
|
||||||
|
/**
|
||||||
|
* detsta fájl felöltve
|
||||||
|
* */
|
||||||
public static $STATUS_RECIEVED = 10;
|
public static $STATUS_RECIEVED = 10;
|
||||||
|
/**
|
||||||
|
* detsta fájl feldolgozva
|
||||||
|
* */
|
||||||
public static $STATUS_FINISHED = 20;
|
public static $STATUS_FINISHED = 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m160131_102226_alter__table__contract__add__column__id_discount extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn("contract", "id_discount", "int");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m160131_102226_alter__table__contract__add__column__id_discount cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -176,6 +176,7 @@ class TicketCreate extends Ticket{
|
|||||||
$contract->part_required = 0;
|
$contract->part_required = 0;
|
||||||
$contract->expired_at = date('Y-m-d', strtotime("today +12 month -1 day"));
|
$contract->expired_at = date('Y-m-d', strtotime("today +12 month -1 day"));
|
||||||
$contract->id_ticket_type = $this->id_ticket_type;
|
$contract->id_ticket_type = $this->id_ticket_type;
|
||||||
|
$contract->id_discount = $this->id_discount;
|
||||||
$contract->save();
|
$contract->save();
|
||||||
|
|
||||||
$requests = TicketInstallmentRequest::createInstallments($this, $ticketType, $this->customer,$contract);
|
$requests = TicketInstallmentRequest::createInstallments($this, $ticketType, $this->customer,$contract);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user