1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace app\common\model;
- use think\Config;
- use think\Model;
- class Withdraw extends Model
- {
- // 表名
- protected $table = 'withdraw';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
-
- // 追加属性
- protected $append = [
- 'state_text',
- 'finishtime_text'
- ];
-
-
- public function getStateList()
- {
- return ['1' => __('提现中'),'2' => __('打款中'),'3' => __('已打款')];
- }
- public function getStateTextAttr($value, $data)
- {
- $value = $value ? $value : $data['state'];
- $list = $this->getStateList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getFinishtimeTextAttr($value, $data)
- {
- $value = $value ? $value : $data['finishtime'];
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- protected function setFinishtimeAttr($value)
- {
- return $value && !is_numeric($value) ? strtotime($value) : $value;
- }
- /**
- * 连接主库
- * @return $this
- */
- public function setConnect()
- {
- $config = Config::get('database');
- $config['admin_rw_separate'] = false;
- $this->connect($config);
- return $this;
- }
- }
|