190 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			190 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace app\manystore\model\school\classes\order;
 | 
						|
 | 
						|
use think\Model;
 | 
						|
use traits\model\SoftDelete;
 | 
						|
 | 
						|
class Order extends Model
 | 
						|
{
 | 
						|
 | 
						|
    use SoftDelete;
 | 
						|
 | 
						|
    
 | 
						|
 | 
						|
    // 表名
 | 
						|
    protected $name = 'school_classes_order';
 | 
						|
    
 | 
						|
    // 自动写入时间戳字段
 | 
						|
    protected $autoWriteTimestamp = 'int';
 | 
						|
 | 
						|
    // 定义时间戳字段名
 | 
						|
    protected $createTime = 'createtime';
 | 
						|
    protected $updateTime = 'updatetime';
 | 
						|
    protected $deleteTime = 'deletetime';
 | 
						|
 | 
						|
    // 追加属性
 | 
						|
    protected $append = [
 | 
						|
        'pay_type_text',
 | 
						|
        'status_text',
 | 
						|
        'before_status_text',
 | 
						|
        'server_status_text',
 | 
						|
        'result_status_text',
 | 
						|
        'canceltime_text',
 | 
						|
        'paytime_text',
 | 
						|
        'finishtime_text',
 | 
						|
        'refundtime_text'
 | 
						|
    ];
 | 
						|
    
 | 
						|
 | 
						|
    
 | 
						|
    public function getPayTypeList()
 | 
						|
    {
 | 
						|
        return ['yue' => __('Pay_type yue'), 'wechat' => __('Pay_type wechat')];
 | 
						|
    }
 | 
						|
 | 
						|
    public function getStatusList()
 | 
						|
    {
 | 
						|
        return ['-3' => __('Status -3'), '0' => __('Status 0'), '3' => __('Status 3'),'4' => __('Status 4'), '6' => __('Status 6'), '9' => __('Status 9')];
 | 
						|
    }
 | 
						|
 | 
						|
    public function getBeforeStatusList()
 | 
						|
    {
 | 
						|
        return ['-3' => __('Before_status -3'), '0' => __('Before_status 0'), '3' => __('Before_status 3'), '6' => __('Before_status 6'), '9' => __('Before_status 9')];
 | 
						|
    }
 | 
						|
 | 
						|
    public function getServerStatusList()
 | 
						|
    {
 | 
						|
        return ['0' => __('Server_status 0'), '3' => __('Server_status 3'), '6' => __('Server_status 6')];
 | 
						|
    }
 | 
						|
 | 
						|
    public function getResultStatusList()
 | 
						|
    {
 | 
						|
        return ['0' => __('Result_status 0'), '3' => __('Result_status 3'), '6' => __('Result_status 6')];
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getPayTypeTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['pay_type']) ? $data['pay_type'] : '');
 | 
						|
        $list = $this->getPayTypeList();
 | 
						|
        return isset($list[$value]) ? $list[$value] : '';
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getStatusTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
 | 
						|
        $list = $this->getStatusList();
 | 
						|
        return isset($list[$value]) ? $list[$value] : '';
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getBeforeStatusTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['before_status']) ? $data['before_status'] : '');
 | 
						|
        $list = $this->getBeforeStatusList();
 | 
						|
        return isset($list[$value]) ? $list[$value] : '';
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getServerStatusTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['server_status']) ? $data['server_status'] : '');
 | 
						|
        $list = $this->getServerStatusList();
 | 
						|
        return isset($list[$value]) ? $list[$value] : '';
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getResultStatusTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['result_status']) ? $data['result_status'] : '');
 | 
						|
        $list = $this->getResultStatusList();
 | 
						|
        return isset($list[$value]) ? $list[$value] : '';
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getCanceltimeTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['canceltime']) ? $data['canceltime'] : '');
 | 
						|
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getPaytimeTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['paytime']) ? $data['paytime'] : '');
 | 
						|
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getFinishtimeTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['finishtime']) ? $data['finishtime'] : '');
 | 
						|
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function getRefundtimeTextAttr($value, $data)
 | 
						|
    {
 | 
						|
        $value = $value ? $value : (isset($data['refundtime']) ? $data['refundtime'] : '');
 | 
						|
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
 | 
						|
    }
 | 
						|
 | 
						|
    protected function setCanceltimeAttr($value)
 | 
						|
    {
 | 
						|
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
 | 
						|
    }
 | 
						|
 | 
						|
    protected function setPaytimeAttr($value)
 | 
						|
    {
 | 
						|
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
 | 
						|
    }
 | 
						|
 | 
						|
    protected function setFinishtimeAttr($value)
 | 
						|
    {
 | 
						|
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
 | 
						|
    }
 | 
						|
 | 
						|
    protected function setRefundtimeAttr($value)
 | 
						|
    {
 | 
						|
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function manystore()
 | 
						|
    {
 | 
						|
        return $this->belongsTo('app\manystore\model\Manystore', 'manystore_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function user()
 | 
						|
    {
 | 
						|
        return $this->belongsTo('app\manystore\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function manystoreshop()
 | 
						|
    {
 | 
						|
        return $this->belongsTo('app\manystore\model\ManystoreShop', 'shop_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function schoolclasseslib()
 | 
						|
    {
 | 
						|
        return $this->belongsTo('app\manystore\model\SchoolClassesLib', 'classes_lib_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function schoolclassesorderdetail()
 | 
						|
    {
 | 
						|
        return $this->belongsTo('app\manystore\model\SchoolClassesOrderDetail', 'classes_order_detail_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    public function admin()
 | 
						|
    {
 | 
						|
        return $this->belongsTo('app\manystore\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
 | 
						|
    }
 | 
						|
}
 |