1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace app\common\model;
- use think\Config;
- class Orders extends PolarDbModel
- {
- // 表名
- protected $table = 'orders';
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- // 追加属性
- protected $append = [
- 'type_text',
- 'state_text',
- 'finishtime_text'
- ];
- public function __construct(array $data = [])
- {
- if (Config::get('polardb.orders_apply_polardb')) {
- parent::__construct($data);
- } else {
- parent::__construct($data, false);
- }
- }
- public function getTitleAttr($value, $data)
- {
- return __($value);
- }
- public function getTypeList()
- {
- return ['1' => __('书币充值'),'2' => __('VIP充值')];
- }
- public function getStateList()
- {
- return ['0' => __('未支付'),'1' => __('已支付')];
- }
- public function getTypeTextAttr($value, $data)
- {
- $value = $value ? $value : $data['type'];
- $list = $this->getTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- 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;
- }
- }
|