100 lines
2.3 KiB
PHP
100 lines
2.3 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace app\admin\model\school\classes\order;
|
||
|
|
||
|
use think\Model;
|
||
|
use traits\model\SoftDelete;
|
||
|
|
||
|
class OrderDetail extends Model
|
||
|
{
|
||
|
|
||
|
use SoftDelete;
|
||
|
|
||
|
|
||
|
|
||
|
// 表名
|
||
|
protected $name = 'school_classes_order_detail';
|
||
|
|
||
|
// 自动写入时间戳字段
|
||
|
protected $autoWriteTimestamp = 'integer';
|
||
|
|
||
|
// 定义时间戳字段名
|
||
|
protected $createTime = 'createtime';
|
||
|
protected $updateTime = 'updatetime';
|
||
|
protected $deleteTime = 'deletetime';
|
||
|
|
||
|
// 追加属性
|
||
|
protected $append = [
|
||
|
'add_type_text',
|
||
|
'type_text',
|
||
|
'address_type_text'
|
||
|
];
|
||
|
|
||
|
|
||
|
|
||
|
public function getAddTypeList()
|
||
|
{
|
||
|
return ['1' => __('Add_type 1'), '2' => __('Add_type 2')];
|
||
|
}
|
||
|
|
||
|
public function getTypeList()
|
||
|
{
|
||
|
return ['out' => __('Type out'), 'in' => __('Type in')];
|
||
|
}
|
||
|
|
||
|
public function getAddressTypeList()
|
||
|
{
|
||
|
return ['1' => __('Address_type 1'), '2' => __('Address_type 2')];
|
||
|
}
|
||
|
|
||
|
|
||
|
public function getAddTypeTextAttr($value, $data)
|
||
|
{
|
||
|
$value = $value ? $value : (isset($data['add_type']) ? $data['add_type'] : '');
|
||
|
$list = $this->getAddTypeList();
|
||
|
return isset($list[$value]) ? $list[$value] : '';
|
||
|
}
|
||
|
|
||
|
|
||
|
public function getTypeTextAttr($value, $data)
|
||
|
{
|
||
|
$value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
|
||
|
$list = $this->getTypeList();
|
||
|
return isset($list[$value]) ? $list[$value] : '';
|
||
|
}
|
||
|
|
||
|
|
||
|
public function getAddressTypeTextAttr($value, $data)
|
||
|
{
|
||
|
$value = $value ? $value : (isset($data['address_type']) ? $data['address_type'] : '');
|
||
|
$list = $this->getAddressTypeList();
|
||
|
return isset($list[$value]) ? $list[$value] : '';
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
public function order()
|
||
|
{
|
||
|
return $this->belongsTo('app\admin\model\school\classes\Order', 'classes_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||
|
}
|
||
|
|
||
|
|
||
|
public function manystore()
|
||
|
{
|
||
|
return $this->belongsTo('app\admin\model\Manystore', 'manystore_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||
|
}
|
||
|
|
||
|
|
||
|
public function shop()
|
||
|
{
|
||
|
return $this->belongsTo('app\admin\model\manystore\Shop', 'shop_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||
|
}
|
||
|
|
||
|
|
||
|
public function user()
|
||
|
{
|
||
|
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
||
|
}
|
||
|
}
|