87 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			87 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace app\manystore\model\school\activity\order;
 | 
						|
 | 
						|
use app\common\model\BaseModel;
 | 
						|
use app\manystore\model\school\activity\Activity;
 | 
						|
use think\Model;
 | 
						|
use traits\model\SoftDelete;
 | 
						|
 | 
						|
class OrderCode extends BaseModel
 | 
						|
{
 | 
						|
 | 
						|
    use SoftDelete;
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    // 表名
 | 
						|
    protected $name = 'school_activity_order_code';
 | 
						|
    
 | 
						|
    // 自动写入时间戳字段
 | 
						|
    protected $autoWriteTimestamp = 'int';
 | 
						|
 | 
						|
    // 定义时间戳字段名
 | 
						|
    protected $createTime = 'createtime';
 | 
						|
    protected $updateTime = 'updatetime';
 | 
						|
    protected $deleteTime = 'deletetime';
 | 
						|
 | 
						|
    // 追加属性
 | 
						|
    protected $append = [
 | 
						|
        'status_text',
 | 
						|
        'verificationtime_text'
 | 
						|
    ];
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
    public function getStatusList()
 | 
						|
    {
 | 
						|
        return ['3' => __('Status 3'), '6' => __('Status 6')];
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getStatusTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
 | 
						|
        $list = $this->getStatusList();
 | 
						|
        return isset($list[$value]) ? $list[$value] : '';
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getVerificationtimeTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['verificationtime']) ? $data['verificationtime'] : '');
 | 
						|
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
 | 
						|
    }
 | 
						|
 | 
						|
    protected function setVerificationtimeAttr($value)
 | 
						|
    {
 | 
						|
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function schoolactivityorder()
 | 
						|
    {
 | 
						|
        return $this->belongsTo(Order::class, 'activity_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function user()
 | 
						|
    {
 | 
						|
        return $this->belongsTo('app\manystore\model\User', 'verification_user_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function schoolactivity()
 | 
						|
    {
 | 
						|
        return $this->belongsTo(Activity::class, 'activity_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function orderuser()
 | 
						|
    {
 | 
						|
        return $this->belongsTo('app\manystore\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
}
 |