1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace app\common\model;
- use app\common\library\Redis;
- use think\Model;
- class SpecialRechargeTpl extends Model
- {
- // 表名
- protected $table = 'special_recharge_tpl';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
-
- // 追加属性
- protected $append = [
- 'status_text'
- ];
-
-
- public function getStatusList()
- {
- return ['normal' => __('Status normal'),'hidden' => __('Status hidden')];
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : $data['status'];
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getOne($id)
- {
- $redisKey = 'SUT:'.$id;
- if (Redis::instance()->exists($redisKey)) {
- return json_decode(Redis::instance()->get($redisKey), true);
- }
- $row = $this->get($id);
- $result = $row ? $row->toArray() : [];
- Redis::instance()->set($redisKey, json_encode($result), 86400);
- return $result;
- }
- }
|