|
@@ -0,0 +1,204 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\admin\model;
|
|
|
+
|
|
|
+use think\Model;
|
|
|
+
|
|
|
+
|
|
|
+class UserPower extends Model
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 表名
|
|
|
+ protected $name = 'user_power';
|
|
|
+
|
|
|
+ // 自动写入时间戳字段
|
|
|
+ protected $autoWriteTimestamp = false;
|
|
|
+
|
|
|
+ // 定义时间戳字段名
|
|
|
+ protected $createTime = false;
|
|
|
+ protected $updateTime = false;
|
|
|
+ protected $deleteTime = false;
|
|
|
+
|
|
|
+ // 追加属性
|
|
|
+ protected $append = [
|
|
|
+ 'private_messages_text',
|
|
|
+ 'barrage_text',
|
|
|
+ 'speak_text',
|
|
|
+ 'speak_time_text',
|
|
|
+ 'recharge_text',
|
|
|
+ 'raffle_text',
|
|
|
+ 'give_gift_text',
|
|
|
+ 'transfer_text',
|
|
|
+ 'payorder_text',
|
|
|
+ 'attire_text',
|
|
|
+ 'noble_text',
|
|
|
+ 'withdraw_text'
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public function getPrivateMessagesList()
|
|
|
+ {
|
|
|
+ return ['0' => __('Private_messages 0'), '1' => __('Private_messages 1')];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getBarrageList()
|
|
|
+ {
|
|
|
+ return ['0' => __('Barrage 0'), '1' => __('Barrage 1')];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getSpeakList()
|
|
|
+ {
|
|
|
+ return ['0' => __('Speak 0')];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getRechargeList()
|
|
|
+ {
|
|
|
+ return ['0' => __('Recharge 0'), '1' => __('Recharge 1')];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getRaffleList()
|
|
|
+ {
|
|
|
+ return ['0' => __('Raffle 0'), '1' => __('Raffle 1')];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getGiveGiftList()
|
|
|
+ {
|
|
|
+ return ['0' => __('Give_gift 0'), '1' => __('Give_gift 1')];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getTransferList()
|
|
|
+ {
|
|
|
+ return ['0' => __('Transfer 0'), '1' => __('Transfer 1')];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPayorderList()
|
|
|
+ {
|
|
|
+ return ['0' => __('Payorder 0'), '1' => __('Payorder 1')];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getAttireList()
|
|
|
+ {
|
|
|
+ return ['0' => __('Attire 0'), '1' => __('Attire 1')];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getNobleList()
|
|
|
+ {
|
|
|
+ return ['0' => __('Noble 0'), '1' => __('Noble 1')];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getWithdrawList()
|
|
|
+ {
|
|
|
+ return ['0' => __('Withdraw 0'), '1' => __('Withdraw 1')];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function getPrivateMessagesTextAttr($value, $data)
|
|
|
+ {
|
|
|
+ $value = $value ? $value : (isset($data['private_messages']) ? $data['private_messages'] : '');
|
|
|
+ $list = $this->getPrivateMessagesList();
|
|
|
+ return isset($list[$value]) ? $list[$value] : '';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function getBarrageTextAttr($value, $data)
|
|
|
+ {
|
|
|
+ $value = $value ? $value : (isset($data['barrage']) ? $data['barrage'] : '');
|
|
|
+ $list = $this->getBarrageList();
|
|
|
+ return isset($list[$value]) ? $list[$value] : '';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function getSpeakTextAttr($value, $data)
|
|
|
+ {
|
|
|
+ $value = $value ? $value : (isset($data['speak']) ? $data['speak'] : '');
|
|
|
+ $list = $this->getSpeakList();
|
|
|
+ return isset($list[$value]) ? $list[$value] : '';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function getSpeakTimeTextAttr($value, $data)
|
|
|
+ {
|
|
|
+ $value = $value ? $value : (isset($data['speak_time']) ? $data['speak_time'] : '');
|
|
|
+ return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function getRechargeTextAttr($value, $data)
|
|
|
+ {
|
|
|
+ $value = $value ? $value : (isset($data['recharge']) ? $data['recharge'] : '');
|
|
|
+ $list = $this->getRechargeList();
|
|
|
+ return isset($list[$value]) ? $list[$value] : '';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function getRaffleTextAttr($value, $data)
|
|
|
+ {
|
|
|
+ $value = $value ? $value : (isset($data['raffle']) ? $data['raffle'] : '');
|
|
|
+ $list = $this->getRaffleList();
|
|
|
+ return isset($list[$value]) ? $list[$value] : '';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function getGiveGiftTextAttr($value, $data)
|
|
|
+ {
|
|
|
+ $value = $value ? $value : (isset($data['give_gift']) ? $data['give_gift'] : '');
|
|
|
+ $list = $this->getGiveGiftList();
|
|
|
+ return isset($list[$value]) ? $list[$value] : '';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function getTransferTextAttr($value, $data)
|
|
|
+ {
|
|
|
+ $value = $value ? $value : (isset($data['transfer']) ? $data['transfer'] : '');
|
|
|
+ $list = $this->getTransferList();
|
|
|
+ return isset($list[$value]) ? $list[$value] : '';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function getPayorderTextAttr($value, $data)
|
|
|
+ {
|
|
|
+ $value = $value ? $value : (isset($data['payorder']) ? $data['payorder'] : '');
|
|
|
+ $list = $this->getPayorderList();
|
|
|
+ return isset($list[$value]) ? $list[$value] : '';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function getAttireTextAttr($value, $data)
|
|
|
+ {
|
|
|
+ $value = $value ? $value : (isset($data['attire']) ? $data['attire'] : '');
|
|
|
+ $list = $this->getAttireList();
|
|
|
+ return isset($list[$value]) ? $list[$value] : '';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function getNobleTextAttr($value, $data)
|
|
|
+ {
|
|
|
+ $value = $value ? $value : (isset($data['noble']) ? $data['noble'] : '');
|
|
|
+ $list = $this->getNobleList();
|
|
|
+ return isset($list[$value]) ? $list[$value] : '';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function getWithdrawTextAttr($value, $data)
|
|
|
+ {
|
|
|
+ $value = $value ? $value : (isset($data['withdraw']) ? $data['withdraw'] : '');
|
|
|
+ $list = $this->getWithdrawList();
|
|
|
+ return isset($list[$value]) ? $list[$value] : '';
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function setSpeakTimeAttr($value)
|
|
|
+ {
|
|
|
+ return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function user()
|
|
|
+ {
|
|
|
+ return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
|
+ }
|
|
|
+}
|