add non cash money display to account state
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use /** @noinspection PhpMethodOrClassCallIsNotCaseSensitiveInspection */
|
||||
Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
@@ -18,6 +19,7 @@ use yii\helpers\ArrayHelper;
|
||||
* @property integer $ticket_enabled
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property mixed id_discount
|
||||
*/
|
||||
class Discount extends \yii\db\ActiveRecord
|
||||
{
|
||||
@@ -86,7 +88,7 @@ class Discount extends \yii\db\ActiveRecord
|
||||
|
||||
public function getStatusHuman(){
|
||||
$result = null;
|
||||
$s = self::statuses($this->status);
|
||||
$s = self::statuses();
|
||||
if ( array_key_exists($this->status, $s)){
|
||||
$result = $s[$this->status];
|
||||
}
|
||||
@@ -101,41 +103,59 @@ class Discount extends \yii\db\ActiveRecord
|
||||
|
||||
public function getTypeHuman(){
|
||||
$result = null;
|
||||
$s = self::types($this->type);
|
||||
$s = self::types();
|
||||
if ( array_key_exists($this->type, $s)){
|
||||
$result = $s[$this->type];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getProcutEnabledHuman(){
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getProcutEnabledHuman(){
|
||||
return $this->product_enabled == 1 ? 'Igen' : 'Nem';
|
||||
}
|
||||
|
||||
public function getTicketEnabledHuman(){
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTicketEnabledHuman(){
|
||||
return $this->ticket_enabled == 1 ? 'Igen' : 'Nem';
|
||||
}
|
||||
|
||||
public static function read(){
|
||||
|
||||
/**
|
||||
* @return array|\yii\db\ActiveRecord[]
|
||||
*/
|
||||
public static function read(){
|
||||
return Discount::find()->andWhere([ 'status' => self::STATUS_ACTIVE ])->all();
|
||||
}
|
||||
|
||||
|
||||
public static function readProductDiscounts(){
|
||||
|
||||
|
||||
/**
|
||||
* @return array|\yii\db\ActiveRecord[]
|
||||
*/
|
||||
public static function readProductDiscounts(){
|
||||
return Discount::find()->andWhere([ 'status' => self::STATUS_ACTIVE , 'product_enabled' => 1 ])->all();
|
||||
}
|
||||
|
||||
|
||||
public static function readTicketDiscounts(){
|
||||
|
||||
/**
|
||||
* @return array|\yii\db\ActiveRecord[]
|
||||
*/
|
||||
public static function readTicketDiscounts(){
|
||||
return Discount::find()->andWhere([ 'status' => self::STATUS_ACTIVE , 'ticket_enabled' => 1 ])->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $money
|
||||
* @param common\models\Discount $discount
|
||||
* */
|
||||
|
||||
/**
|
||||
* @param integer $money
|
||||
* @param \common\models\Discount $discount
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function applyDiscount($money,$discount){
|
||||
$result = $money;
|
||||
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||
$result = $money;
|
||||
$valueOfDiscount = floor( $money * $discount->value / 100 );
|
||||
$result = $money - $valueOfDiscount;
|
||||
return $result;
|
||||
|
||||
Reference in New Issue
Block a user