1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Activeorder extends Model
- {
-
-
- // 表名
- protected $name = 'active_order';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'paytype_text',
- 'status_text',
- 'refundstatus_text',
- 'refundtime_text'
- ];
-
-
- public function getPaytypeList()
- {
- return ['0' => __('Paytype 0'), '1' => __('Paytype 1')];
- }
- public function getStatusList()
- {
- return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3')];
- }
- public function getRefundstatusList()
- {
- return ['0' => __('Refundstatus 0'), '1' => __('Refundstatus 1'), '2' => __('Refundstatus 2')];
- }
- public function getPaytypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['paytype']) ? $data['paytype'] : '');
- $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 getRefundstatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['refundstatus']) ? $data['refundstatus'] : '');
- $list = $this->getRefundstatusList();
- return isset($list[$value]) ? $list[$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 setRefundtimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- public function active()
- {
- return $this->belongsTo('Active', 'active_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function user()
- {
- return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|