'已上架', (string) self::COMMON_OFF => '已下架', ]; } /** * 正常商品列表查询字段 * * @return string[] */ public static function spuListFields(): array { return [ 'id', 'name', 'price', 'original_price', 'cover', 'stock', 'amount', 'is_activity', 'activity_type', 'activity_id' ]; } /** * 积分商品列表查询字段 * * @return string[] */ public static function scoreListFields(): array { return self::spuListFields(); } /** * 活动类型 * * @return string[] */ public static function activityList(): array { return [ self::TYPE_LIMIT_TIME, ]; } /** * 活动列表 * * @return array */ public static function activity(): array { $list = []; foreach (self::activityList() as $item) { $arr = []; $arr['value'] = $item; $arr['name'] = self::activityTextList()[$item]; $list[] = $arr; } return $list; } /** * 活动类型说明 * * @return string[] */ public static function activityTextList(): array { return [ self::TYPE_LIMIT_TIME => '限时折扣', ]; } /** * 商品类型 * * @return string[] */ public static function spuTypeTextList(): array { return [ self::SPU_TYPE_ENTITY => '实体物品', self::SPU_TYPE_VIRTUAL => '虚拟物品', ]; } /** * 限购周期 单位-天 * * @return string[] */ public static function limitList(): array { return [ '0' => '不限', '1' => '每天', '7' => '每周', '30' => '每月', '365' => '每年', '9999999' => '终身', ]; } /** * @return HasOne */ public function limitTime(): HasOne { return $this->hasOne(SpuActivity::class, 'id', 'activity_id'); } }