123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Packageorder extends Model
- {
-
-
- // 表名
- protected $table = 'package_order';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'integer';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'starttime_text',
- 'endtime_text',
- 'order_status_text',
- 'use_status_text',
- 'paytime_text',
- 'pay_type_text',
- 'is_gift_text',
- 'notice_status_text',
- 'buy_notice_status_text'
- ];
-
-
- public function getOrderStatusList()
- {
- return ['0' => __('Order_status 0'), '1' => __('Order_status 1'), '10' => __('Order_status 10')];
- }
- public function getUseStatusList()
- {
- return ['0' => __('Use_status 0'), '1' => __('Use_status 1')];
- }
- public function getPayTypeList()
- {
- return ['1' => __('Pay_type 1'), '2' => __('Pay_type 2')];
- }
- public function getIsGiftList()
- {
- return ['0' => __('Is_gift 0'), '1' => __('Is_gift 1')];
- }
- public function getNoticeStatusList()
- {
- return ['0' => __('Notice_status 0'), '1' => __('Notice_status 1'), '2' => __('Notice_status 2'), '3' => __('Notice_status 3')];
- }
- public function getBuyNoticeStatusList()
- {
- return ['0' => __('Buy_notice_status 0'), '1' => __('Buy_notice_status 1')];
- }
- public function getStarttimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['starttime']) ? $data['starttime'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getEndtimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['endtime']) ? $data['endtime'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- 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 getUseStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['use_status']) ? $data['use_status'] : '');
- $list = $this->getUseStatusList();
- 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 getPayTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['pay_type']) ? $data['pay_type'] : '');
- $list = $this->getPayTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsGiftTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_gift']) ? $data['is_gift'] : '');
- $list = $this->getIsGiftList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getNoticeStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['notice_status']) ? $data['notice_status'] : '');
- $list = $this->getNoticeStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getBuyNoticeStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['buy_notice_status']) ? $data['buy_notice_status'] : '');
- $list = $this->getBuyNoticeStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- protected function setStarttimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setEndtimeAttr($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);
- }
- public function user()
- {
- return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function package()
- {
- return $this->belongsTo('Lessonpackage', 'package_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|