123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Lessonorder extends Model
- {
-
-
- // 表名
- protected $table = 'lesson_order';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'integer';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'order_status_text',
- 'paytype_text',
- 'paytime_text',
- 'finishtime_text',
- 'cancel_time_text'
- ];
-
-
- public function getOrderStatusList()
- {
- return ['0' => __('Order_status 0'), '10' => __('Order_status 10'), '20' => __('Order_status 20'), '30' => __('Order_status 30'), '40' => __('Order_status 40')];
- }
- public function getPaytypeList()
- {
- return ['1' => __('Paytype 1'), '2' => __('Paytype 2'), '3' => __('Paytype 3'), '4' => __('Paytype 4'), '5' => __('Paytype 5')];
- }
- public function getOrderStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['order_status']) ? $data['order_status'] : '');
- $list = $this->getOrderStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getPaytypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['paytype']) ? $data['paytype'] : '');
- $list = $this->getPaytypeList();
- return isset($list[$value]) ? $list[$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 getCancelTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['cancel_time']) ? $data['cancel_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $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 setCancelTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- public function user()
- {
- return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function slot()
- {
- return $this->belongsTo('Lessonslot', 'slot_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function lesson()
- {
- return $this->belongsTo('Lesson', 'lesson_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function coach()
- {
- return $this->belongsTo('Coach', 'slot.coach_ids', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function packageorder()
- {
- return $this->belongsTo('Packageorder', 'package_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function lessonpackage()
- {
- return $this->belongsTo('Lessonpackage', 'packageorder.package_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function trylessonorder()
- {
- return $this->belongsTo('Trylessonorder', 'trylesson_order_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function trylesson()
- {
- return $this->belongsTo('Trylesson', 'trylessonorder.trylesson_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|