108 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			108 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace app\manystore\model\user\invoice;
 | 
						|
 | 
						|
use app\common\model\BaseModel;
 | 
						|
use think\Model;
 | 
						|
 | 
						|
 | 
						|
class Apply extends BaseModel
 | 
						|
{
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    // 表名
 | 
						|
    protected $name = 'user_invoice_apply';
 | 
						|
    
 | 
						|
    // 自动写入时间戳字段
 | 
						|
    protected $autoWriteTimestamp = 'int';
 | 
						|
 | 
						|
    // 定义时间戳字段名
 | 
						|
    protected $createTime = 'createtime';
 | 
						|
    protected $updateTime = 'updatetime';
 | 
						|
    protected $deleteTime = false;
 | 
						|
 | 
						|
    // 追加属性
 | 
						|
    protected $append = [
 | 
						|
        'status_text',
 | 
						|
        'apply_type_text',
 | 
						|
        'head_type_text',
 | 
						|
        'invoice_type_text',
 | 
						|
        'invoicingtime_text'
 | 
						|
    ];
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
    public function getStatusList()
 | 
						|
    {
 | 
						|
        return ['1' => __('Status 1'), '2' => __('Status 2'), '-3' => __('Status -3')];
 | 
						|
    }
 | 
						|
 | 
						|
    public function getApplyTypeList()
 | 
						|
    {
 | 
						|
        return ['1' => __('Apply_type 1'), '2' => __('Apply_type 2')];
 | 
						|
    }
 | 
						|
 | 
						|
    public function getHeadTypeList()
 | 
						|
    {
 | 
						|
        return ['personal' => __('Head_type personal'), 'corporate' => __('Head_type corporate')];
 | 
						|
    }
 | 
						|
 | 
						|
    public function getInvoiceTypeList()
 | 
						|
    {
 | 
						|
        return ['ordinary' => __('Invoice_type ordinary'), 'special' => __('Invoice_type special')];
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getStatusTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
 | 
						|
        $list = $this->getStatusList();
 | 
						|
        return isset($list[$value]) ? $list[$value] : '';
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getApplyTypeTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['apply_type']) ? $data['apply_type'] : '');
 | 
						|
        $list = $this->getApplyTypeList();
 | 
						|
        return isset($list[$value]) ? $list[$value] : '';
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getHeadTypeTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['head_type']) ? $data['head_type'] : '');
 | 
						|
        $list = $this->getHeadTypeList();
 | 
						|
        return isset($list[$value]) ? $list[$value] : '';
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getInvoiceTypeTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['invoice_type']) ? $data['invoice_type'] : '');
 | 
						|
        $list = $this->getInvoiceTypeList();
 | 
						|
        return isset($list[$value]) ? $list[$value] : '';
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getInvoicingtimeTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['invoicingtime']) ? $data['invoicingtime'] : '');
 | 
						|
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
 | 
						|
    }
 | 
						|
 | 
						|
    protected function setInvoicingtimeAttr($value)
 | 
						|
    {
 | 
						|
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function user()
 | 
						|
    {
 | 
						|
        return $this->belongsTo('app\manystore\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
						|
    }
 | 
						|
}
 |