2024-11-07 18:11:08 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\common\model\school\classes\order;
|
|
|
|
|
2024-11-08 18:18:06 +08:00
|
|
|
use app\common\model\dyqc\ManystoreShop;
|
2024-11-07 18:11:08 +08:00
|
|
|
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] : '';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-08 18:18:06 +08:00
|
|
|
public function classorder()
|
2024-11-07 18:11:08 +08:00
|
|
|
{
|
2024-11-08 18:18:06 +08:00
|
|
|
return $this->belongsTo(Order::class, 'classes_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
2024-11-07 18:11:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function manystore()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('app\admin\model\Manystore', 'manystore_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function shop()
|
|
|
|
{
|
2024-11-08 18:18:06 +08:00
|
|
|
return $this->belongsTo(ManystoreShop::class, 'shop_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
2024-11-07 18:11:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function user()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
|
|
}
|
2024-11-08 18:18:06 +08:00
|
|
|
|
|
|
|
public function teacher()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('app\common\model\school\classes\Teacher', 'teacher_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
|
|
}
|
2024-11-07 18:11:08 +08:00
|
|
|
}
|