123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\admin\model\lottery;
- use think\Model;
- class WinRecord extends Model
- {
- // 表名
- protected $table = 'shop_lottery_win_record';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'integer';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- // 追加属性
- protected $append = [
- 'deliver_status_text',
- 'deliver_time_text'
- ];
- /**
- * 发放状态列表
- */
- public function getDeliverStatusList()
- {
- return [
- '0' => __('待发放'),
- '1' => __('已发放'),
- '2' => __('发放失败'),
- '3' => __('已取消')
- ];
- }
- // 获取器
- public function getDeliverStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['deliver_status']) ? $data['deliver_status'] : '');
- $list = $this->getDeliverStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getDeliverTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['deliver_time']) ? $data['deliver_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- // 关联关系
- public function activity()
- {
- return $this->belongsTo('Activity', 'activity_id', 'id');
- }
- public function user()
- {
- return $this->belongsTo('app\\common\\model\\User', 'user_id', 'id');
- }
- public function prize()
- {
- return $this->belongsTo('LotteryPrize', 'prize_id', 'id');
- }
- public function drawRecord()
- {
- return $this->belongsTo('DrawRecord', 'draw_record_id', 'id');
- }
- }
|