detsta processing -> move to cart if not successfull, transfer/paymentLater changes

This commit is contained in:
2016-07-27 07:20:47 +02:00
parent b52cc1a438
commit fdbd39b059
29 changed files with 700 additions and 124 deletions

View File

@@ -52,8 +52,6 @@ class DetStaDBSave extends Object
/**
*
* @param common\models\Ugiro;
* @param common\models\giro\GiroDETSTA $giroDETSTA
* */
protected function saveMessageDetsta( ) {
$this->message = new MessageDetsta();

View File

@@ -3,20 +3,15 @@ namespace common\components;
use yii\base\Object;
use common\models\TicketInstallmentRequest;
use common\components\giro\GiroDETSTATetel;
use common\models\Ugiro;
use common\components\giro\GiroDETSTA;
use common\components\giro\GiroDETSTAFej;
use common\components\giro\GiroDETSTALab;
use common\components\DetStaDBSave;
/**
* This is the model class for table "ticket".
*
* @property common\components\giro\GiroDETSTA $detstatUzenet
* @property common\models\UGiro $koteg
* @property \common\components\giro\GiroDETSTA $detstatUzenet
* @property \common\models\UGiro $koteg
*
* */
class DetStatProcessor extends Object{
@@ -120,14 +115,19 @@ class DetStatProcessor extends Object{
}
/**
*
*/
public function readKoteg(){
$this->koteg = Ugiro::findOne($this->idKoteg );
if ( !isset($this->koteg) ){
$this->errors [] = "Kötege nem található! (".$this->detstatUzenet->fej." )";
/** @var DetStatProcessor $this */
$this->errors [] = "Köteg nem található! (".$this->detstatUzenet->fej ." )";
}
}
public function readKotegMegbizasok(){
$this->megbizasok = $this->koteg->requests;
}

View File

@@ -2,6 +2,7 @@
namespace common\components;
use common\models\Transfer;
use yii\base\Object;
use common\models\TicketInstallmentRequest;
use common\components\giro\GiroDETSTATetel;
@@ -11,10 +12,10 @@ use common\models\Contract;
/**
* This is the model class for table "ticket".
*
* @property common\components\giro\GiroDETSTATetel $tetel
* @property common\models\TicketInstallmentRequest $megbizas
* @property common\models\Ticket $ticket
* @property common\models\Contract $contract
* @property \common\components\giro\GiroDETSTATetel $tetel
* @property \common\models\TicketInstallmentRequest $megbizas
* @property \common\models\Ticket $ticket
* @property \common\models\Contract $contract
*
*
*/
@@ -44,7 +45,7 @@ class DetStatTetelProcessor extends Object {
* */
protected $comment;
/**
* A bérlet objectkum, amit elmentettünk
* A bérlet objektum, amit elmentettünk
* */
protected $ticket;
/**
@@ -58,13 +59,13 @@ class DetStatTetelProcessor extends Object {
\Yii::info('Megbízás feldolgozása: megbízás azonosító=' .$this->megbizas->id_ticket_installment_request);
if ($this->isAlreadeyAccepted ()) {
if ($this->isAlreadyAccepted ()) {
\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;
}
if ( !isset($this->tetel)){
\Yii::info('A megbízás feldolgozásának megszakítása. Nincs valaszsor a detsta üzenetben');
\Yii::info('A megbízás feldolgozásának megszakítása. Nincs válasz sor a detsta üzenetben');
return;
}
@@ -75,6 +76,8 @@ class DetStatTetelProcessor extends Object {
if ( $this->status == TicketInstallmentRequest::$STATUS_ACCEPTED ){
$this->buyNewTicket();
}else if ( $this->status == TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL ){
$this->putTicketToCustomerCart();
}else{
$this->doRejectRequest();
}
@@ -85,23 +88,26 @@ class DetStatTetelProcessor extends Object {
protected function rememberEredetiMegbizasStatus(){
$this->eredetiMegbizasStatus = $this->megbizas->status;
}
protected function isEredetiMegbizasStatusFinished(){
return $this->eredetiMegbizasStatus == TicketInstallmentRequest::$STATUS_ACCEPTED ||
$this->eredetiMegbizasStatus == TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL ||
$this->eredetiMegbizasStatus == TicketInstallmentRequest::$STATUS_REJECTED;
/**
* @return bool
*/
protected function isEredetiMegbizasStatusFinished(){
return TicketInstallmentRequest::$STATUS_ACCEPTED == $this->eredetiMegbizasStatus ||
TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL == $this->eredetiMegbizasStatus ||
TicketInstallmentRequest::$STATUS_REJECTED == $this->eredetiMegbizasStatus;
}
protected function buyNewTicket(){
\Yii::info('Új bérlet vásárlás folyamant indítása' );
\Yii::info('Új bérlet vásárlás folyamat 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,
@@ -111,20 +117,53 @@ class DetStatTetelProcessor extends Object {
'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();
}
protected function putTicketToCustomerCart(){
\Yii::info('Új bérlet vásárló kosarába helyezés folyamat 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,
'transferStatus' => Transfer::STATUS_NOT_PAID
]
);
$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
* */
@@ -139,7 +178,7 @@ class DetStatTetelProcessor extends Object {
* */
protected function updateMegbizasOnSuccess(){
\Yii::info('Megbízás frissítése - megbizás elfogadva ' );
\Yii::info('Megbízás frissítése - megbízás elfogadva ' );
$this->megbizas->status = $this->status;
$this->megbizas->id_transfer = $this->transfer->id_transfer;
@@ -161,7 +200,7 @@ class DetStatTetelProcessor extends Object {
* */
protected function updateMegbizasOnFail(){
\Yii::info('Megbázás frissítése - megbízás visszautasítva ' );
\Yii::info('Megbízás frissítése - megbízás visszautasítva ' );
$this->megbizas->status = $this->status;
$this->megbizas->detsta_answer = $this->kod;
@@ -269,12 +308,12 @@ class DetStatTetelProcessor extends Object {
if ($this->kod == GiroDETSTATetel::$INFORMACIO_TELJESITETT) {
$this->status = TicketInstallmentRequest::$STATUS_ACCEPTED;
} else {
$this->status = TicketInstallmentRequest::$STATUS_REJECTED;
$this->status = TicketInstallmentRequest::$STATUS_ACCEPTED_MANUAL;
}
\Yii::info('Visszajelző kód kiolvasva: kod=' .$this->kod);
\Yii::info('Visszajelző kód kiolvasva: statusz=' .$this->status. " (" . TicketInstallmentRequest::toStatusName($this->status) .")");
}
protected function isAlreadeyAccepted() {
protected function isAlreadyAccepted() {
return $this->megbizas->isStatusAccepted ();
}
public function hasError() {

File diff suppressed because one or more lines are too long

View File

@@ -75,10 +75,11 @@ class TransferPayout extends \yii\base\Object{
public function isTransferCountMatchWithRequestesTransferCount(){
return count($this->transfers) == count($this->idTransfers);
}
/**
* @param common\models\Transfer $transfer the transfer to payout
* */
* @param \common\models\Transfer $transfer the transfer to payout
* @throws Exception
*/
protected function payoutTransfer($transfer){
$transfer->paid_by = $this->idUser;

View File

@@ -1,7 +1,7 @@
<?php
namespace common\components\giro;
use common\components\giro\GiroBase;
use \common\components\giro\GiroBase;
class GiroBankszamla extends GiroBase{

View File

@@ -5,18 +5,43 @@ namespace common\components\giro;
use backend\models\GiroKotegForm;
class GiroBase {
/**
* @param $input
* @param $hossz
* @param string $pad_string
* @return string
*/
public function mezoKitolt($input, $hossz, $pad_string = "") {
return str_pad($input, $hossz, $pad_string, STR_PAD_LEFT);
}
/**
* @param $input
* @param $hossz
* @param string $pad_string
* @return string
*/
public function szamKitolt($input, $hossz, $pad_string = "0") {
return str_pad($input, $hossz, $pad_string, STR_PAD_LEFT);
}
/**
* @param $input
* @param $hossz
* @param string $pad_string
* @return string
*/
public function szamKitoltJobb($input, $hossz, $pad_string = "0") {
return str_pad($input, $hossz, $pad_string, STR_PAD_RIGHT);
}
/**
* @param $input
* @param $hossz
* @param string $pad_string
* @return mixed|string
*/
public function szovegKitolt($input, $hossz, $pad_string = " ") {
$data = $input;
$data = GiroKotegForm::transliterate($data);
@@ -28,15 +53,32 @@ class GiroBase {
// echo strlen($data);
return $data;
}
public static function szovegOlvas($row,$start,$length, $padchar = " "){
/**
* @param $row
* @param $start
* @param $length
* @param string $padchar
* @return string
*/
public static function szovegOlvas($row, $start, $length, $padchar = " "){
return rtrim(substr($row, $start,$length),$padchar);
}
public static function szamOlvas($row,$start,$length, $padchar = "0"){
/**
* @param $row
* @param $start
* @param $length
* @param string $padchar
* @return string
*/
public static function szamOlvas($row, $start, $length, $padchar = "0"){
return ltrim(substr($row, $start,$length),$padchar);
}
/**
* @return string
*/
public function rekordVege(){
return "\r\n";
}

View File

@@ -2,12 +2,11 @@
namespace common\components\giro;
use common\components\giro\GiroBase;
/**
*@property common\components\giro\GiroBeszedFej $fej
*@property common\components\giro\GiroBeszedLab $lab
*@property common\components\giro\GiroBeszedTetel[] $tetelek
*@property \common\components\giro\GiroBeszedFej $fej
*@property \common\components\giro\GiroBeszedLab $lab
*@property \common\components\giro\GiroBeszedTetel[] $tetelek
*
*/
class GiroBeszed extends GiroBase {
@@ -18,9 +17,16 @@ class GiroBeszed extends GiroBase {
public function __construct() {
}
public static function createFileContent($number,$datum /**összeállítás dátum*/, $requests, $terhelesiDatum = null) {
/**
* @param $number
* @param $datum
* @param $requests
* @param null $terhelesiDatum
* @return string
*/
public static function createFileContent($number, $datum /**összeállítás dátum*/, $requests, $terhelesiDatum = null) {
if ( !isset($terhelesiDatum)){
$terhelesiDatum = date('Ymd' ,strtotime("+5 day"));
}
@@ -30,7 +36,12 @@ class GiroBeszed extends GiroBase {
$s .= self::createLab($requests);
return $s;
}
/**
* @param $number
* @param $daturm
* @return string
*/
public static function createFej($number, $daturm) {
$fej = new GiroBeszedFej ();
$fej->duplumKod = \Yii::$app->params['ugiro_duplom_kod'];
@@ -44,8 +55,13 @@ class GiroBeszed extends GiroBase {
return $fej->toString ();
}
public static function createTetelek($requests,$terhelesiDatum){
/**
* @param $requests
* @param $terhelesiDatum
* @return string
*/
public static function createTetelek($requests, $terhelesiDatum){
$s = "";
$i = 0;
foreach ($requests as $request){
@@ -54,10 +70,12 @@ class GiroBeszed extends GiroBase {
}
return $s;
}
/**
* @param common\models\TicketInstallmentRequest $request
* */
* @param \common\models\TicketInstallmentRequest $request
*
* @return string
*/
public static function createTetel($request,$sorszam,$terhelesiDatum) {
$tetel = new GiroBeszedTetel ();
$customer = $request->customer;
@@ -74,7 +92,11 @@ class GiroBeszed extends GiroBase {
return $tetel->toString();
}
/**
* @param $requests
* @return string
*/
public static function createLab($requests) {
$lab = new GiroBeszedLab ();
@@ -88,8 +110,11 @@ class GiroBeszed extends GiroBase {
return $lab->toString ();
}
/**
* @return string
*/
public function toString( ) {
$s = "";
$s .= $this->fej->toString();

View File

@@ -2,13 +2,12 @@
namespace common\components\giro;
use common\components\giro\GiroBase;
/**
*
* @property common\components\giro\GiroDETSTAFej $fej
* @property common\components\giro\GiroDETSTALab $lab
* @property common\components\giro\GiroDETSTATetel $tetelek
* @property \common\components\giro\GiroDETSTAFej $fej
* @property \common\components\giro\GiroDETSTALab $lab
* @property \common\components\giro\GiroDETSTATetel $tetelek
*
*/
class GiroDETSTA extends GiroBase {
@@ -48,11 +47,11 @@ class GiroDETSTA extends GiroBase {
}
/**
* @param common\components\giro\GiroBeszed $beszed
* @param \common\components\giro\GiroBeszed $beszed
* */
public static function createBeszedAnswer($beszed){
// /**@var common\components\giro\GiroBeszed $beszed*/
$beszed = new GiroBeszed();
//$beszed = new GiroBeszed();
$detsta = new GiroDETSTA();
$detsta->fej = new GiroDETSTAFej();

View File

@@ -3,8 +3,8 @@ namespace common\components\giro;
/**
* @property common\components\giro\GiroUzenetsorszam $csoportosUzenetSorszam
* @property common\components\giro\GiroBankszamla $kezdemenyezoBankszamla
* @property \common\components\giro\GiroUzenetsorszam $csoportosUzenetSorszam
* @property \common\components\giro\GiroBankszamla $kezdemenyezoBankszamla
* */
class GiroDETSTAFej extends GiroBase{
@@ -34,7 +34,11 @@ class GiroDETSTAFej extends GiroBase{
. $this->rekordVege()
;
}
/**
* @param $row
* @return GiroDETSTAFej
*/
public static function parse($row){
$fej = new GiroDETSTAFej();

View File

@@ -4,8 +4,8 @@ namespace common\components\giro;
/**
*
* @property common\components\giro\GiroUzenetsorszam $csoportosUzenetSorszam
* @property common\components\giro\GiroBankszamla $kezdemenyezoBankszamla
* @property \common\components\giro\GiroUzenetsorszam $csoportosUzenetSorszam
* @property \common\components\giro\GiroBankszamla $kezdemenyezoBankszamla
*
*/
class GiroDETSTATetel extends GiroBase {
@@ -23,7 +23,7 @@ class GiroDETSTATetel extends GiroBase {
'99' => "egyéb hiba"
];
public $recordTipus = "01";
public $recordTipus = "02";
public $tetelSorszam = "0";
public $osszeg = "0";
public $eredetiTetelElszamolasiDatuma = "";

View File

@@ -5,7 +5,7 @@ return [
'supportEmail' => 'rocho02@gmail.com',
'infoEmail' => 'info@rocho-net.hu',
'user.passwordResetTokenExpire' => 3600,
'version' => 'v0.0.79',
'version' => 'v0.0.80',
'company' => 'movar',//gyor
'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global

View File

@@ -23,6 +23,9 @@ use common\components\Helper;
* @property string $created_at
* @property string $updated_at
* @property string $started_at
* @property \common\models\Discount discount
* @property \common\models\Customer customer
* @property \common\models\TicketType ticketType
*/
class Contract extends \yii\db\ActiveRecord
{

View File

@@ -1,9 +1,7 @@
<?php
namespace common\models;
use Yii;
use common\models\BaseFitnessActiveRecord;
/**
* This is the model class for table "customer".
@@ -29,6 +27,10 @@ use common\models\BaseFitnessActiveRecord;
* @property string $address
* @property string $created_at
* @property string $updated_at
* @property \common\models\Card card
* @property integer status
* @property \common\models\User user
* @property mixed bank_account
*/
class Customer extends BaseFitnessActiveRecord
{
@@ -116,7 +118,7 @@ class Customer extends BaseFitnessActiveRecord
public function getStatusHuman(){
$result = null;
$s = self::statuses($this->status);
$s = self::statuses( );
if ( array_key_exists($this->status, $s)){
$result = $s[$this->status];
}

View File

@@ -28,8 +28,10 @@ use common\components\Helper;
* @property string $updated_at
* @property string $detsta_answer
* @property string $comment
* @property string $updated_at
* @property common\components\giro\GiroDETSTATetel $detstaTetel GiroDetstaTetel record a DetSta fájlból
* @property \common\components\giro\GiroDETSTATetel $detstaTetel GiroDetstaTetel record a DetSta fájlból
* @property \common\models\Contract contract
* @property \common\models\Customer customer
* @property string number
*/
class TicketInstallmentRequest extends \yii\db\ActiveRecord
{
@@ -242,9 +244,9 @@ class TicketInstallmentRequest extends \yii\db\ActiveRecord
/**
* @param common\models\Ticket $ticket
* @param common\models\TicketType $type
* @return common\models\TicketInstallmentRequest[]
* @param \common\models\Ticket $ticket
* @param \common\models\TicketType $type
* @return \common\models\TicketInstallmentRequest[]
* */
public static function createInstallments($ticket,$type,$customer,$contract){
$result = [];

View File

@@ -18,6 +18,8 @@ use yii\helpers\ArrayHelper;
* @property string $created_at
* @property string $updated_at
* @property string $terhelesi_datum
* @property mixed requests
* @property int status
*/
class Ugiro extends \yii\db\ActiveRecord
{