You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
2.5 KiB
100 lines
2.5 KiB
<?php
|
|
|
|
namespace common\models;
|
|
|
|
use Yii;
|
|
|
|
/**
|
|
* This is the model class for table "gift_ticket_t_use".
|
|
*
|
|
* @property int $id
|
|
* @property string $code
|
|
* @property int $type_id
|
|
* @property int $group_id
|
|
* @property string $car_no
|
|
* @property string $input_date
|
|
* @property string $use_date
|
|
* @property string $end_date 有效期
|
|
* @property int $status
|
|
* @property int $op_id
|
|
* @property string $created_at
|
|
* @property string $updated_at
|
|
*/
|
|
class GiftTicketTUse extends \common\models\Base
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public static function tableName()
|
|
{
|
|
return 'gift_ticket_t_use';
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['type_id'], 'required'],
|
|
[['type_id','status', 'op_id','gift_shuzi','order_id'], 'integer'],
|
|
[['input_date', 'use_date', 'end_date', 'created_at', 'updated_at'], 'safe'],
|
|
[['code'], 'string', 'max' => 100],
|
|
[['car_no'], 'string', 'max' => 50],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'id' => 'ID',
|
|
'code' => 'Code',
|
|
'type_id' => 'Type ID',
|
|
'group_id' => 'Group ID',
|
|
'car_no' => 'Car No',
|
|
'input_date' => 'Input Date',
|
|
'use_date' => 'Use Date',
|
|
'end_date' => 'End Date',
|
|
'status' => 'Status',
|
|
'op_id' => 'Op ID',
|
|
'created_at' => 'Created At',
|
|
'updated_at' => 'Updated At',
|
|
];
|
|
}
|
|
public function getStatus() {
|
|
$type_id = $this->typeNew->type_id;
|
|
$status = $this->status;
|
|
|
|
if($type_id == 1 && $status == 1) {
|
|
return '未出库';
|
|
}elseif($type_id == 1 && $status == 3) {
|
|
return '已出库';
|
|
}elseif($type_id == 2 && $status == 1){
|
|
return '未使用';
|
|
}elseif ($type_id == 2 && $status == 2){
|
|
return '使用中';
|
|
}elseif ($type_id == 2 && $status == 3){
|
|
return '使用完';
|
|
}else{
|
|
return '未定义';
|
|
}
|
|
}
|
|
public function getTypeNew() {
|
|
return $this->hasOne(GiftT::className(),['id'=>'type_id']);
|
|
}
|
|
|
|
|
|
public function getUser() {
|
|
return $this->hasOne(UserT::className(),['id'=>'user_id']);
|
|
}
|
|
public function getOp() {
|
|
return $this->hasOne(UserT::className(),['id'=>'op_id']);
|
|
}
|
|
|
|
public function getOrder(){
|
|
return $this->hasOne(OrderT::className(),['id'=>'order_id']);
|
|
}
|
|
}
|
|
|