__('消费抽奖')]; } /** * 活动状态列表 */ public function getStatusList() { return [ '0' => __('草稿'), '1' => __('进行中'), '2' => __('已结束'), '3' => __('已暂停') ]; } /** * 开奖方式列表 */ public function getLotteryTypeList() { return [ '1' => __('即抽即中'), '2' => __('按时间开奖'), '3' => __('按人数开奖') ]; } /** * 适用人群类型列表 */ public function getUserLimitTypeList() { return [ '1' => __('全部会员'), '2' => __('会员等级'), '3' => __('会员标签') ]; } /** * 引导样式列表 */ public function getGuideStyleList() { return [ '1' => __('默认样式'), '2' => __('自定义') ]; } // 获取器 public function getTypeTextAttr($value, $data) { $value = $value ? $value : (isset($data['type']) ? $data['type'] : ''); $list = $this->getTypeList(); return isset($list[$value]) ? $list[$value] : ''; } public function getStatusTextAttr($value, $data) { $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); $list = $this->getStatusList(); return isset($list[$value]) ? $list[$value] : ''; } public function getLotteryTypeTextAttr($value, $data) { $value = $value ? $value : (isset($data['lottery_type']) ? $data['lottery_type'] : ''); $list = $this->getLotteryTypeList(); return isset($list[$value]) ? $list[$value] : ''; } public function getUserLimitTypeTextAttr($value, $data) { $value = $value ? $value : (isset($data['user_limit_type']) ? $data['user_limit_type'] : ''); $list = $this->getUserLimitTypeList(); return isset($list[$value]) ? $list[$value] : ''; } public function getGuideStyleTextAttr($value, $data) { $value = $value ? $value : (isset($data['guide_style']) ? $data['guide_style'] : ''); $list = $this->getGuideStyleList(); return isset($list[$value]) ? $list[$value] : ''; } public function getStartTimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['start_time']) ? $data['start_time'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getEndTimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['end_time']) ? $data['end_time'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getLotteryTimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['lottery_time']) ? $data['lottery_time'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } // 修改器 protected function setStartTimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } protected function setEndTimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } protected function setLotteryTimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } // 关联关系 public function prize() { return $this->hasMany('LotteryPrize', 'activity_id', 'id'); } public function condition() { return $this->hasMany('Condition', 'activity_id', 'id'); } public function drawRecord() { return $this->hasMany('DrawRecord', 'activity_id', 'id'); } public function winRecord() { return $this->hasMany('WinRecord', 'activity_id', 'id'); } public function userChance() { return $this->hasMany('UserChance', 'activity_id', 'id'); } public function statistics() { return $this->hasMany('Statistics', 'activity_id', 'id'); } }