| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace App\Module\Game\Models;
- use App\Module\Game\Enums\REWARD_TYPE;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use UCore\ModelCore;
- /**
- * 奖励项
- *
- * field start
- * @property int $id 主键
- * @property int $group_id 奖励组ID,外键关联game_reward_groups表
- * @property int $reward_type 奖励类型(1:物品, 2:货币, 3:宠物经验, 4:宠物体力, 5:其他)
- * @property int $target_id 目标ID(物品ID、货币ID等,根据reward_type解释)
- * @property int $param1 参数1(根据reward_type不同含义,如物品的品质、货币的来源等)
- * @property int $param2 参数2(根据reward_type不同含义,如物品的绑定状态、货币的类型等)
- * @property int $quantity 数量
- * @property int $min_quantity 最小数量(NULL表示使用quantity字段)
- * @property int $max_quantity 最大数量(NULL表示使用quantity字段)
- * @property float $weight 权重(随机发放时使用)
- * @property float $probability 获得概率(百分比,0-100,NULL表示使用权重机制)
- * @property bool $is_guaranteed 是否必中(0:非必中, 1:必中)
- * @property array $extra_data 额外数据(JSON格式,可存储特定奖励类型的额外参数)
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * field end
- */
- class GameRewardItem extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'game_reward_items';
- // attrlist start
- protected $fillable = [
- 'id',
- 'group_id',
- 'reward_type',
- 'target_id',
- 'param1',
- 'param2',
- 'quantity',
- 'min_quantity',
- 'max_quantity',
- 'weight',
- 'probability',
- 'is_guaranteed',
- 'extra_data',
- ];
- // attrlist end
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'reward_type' => 'integer',
- 'target_id' => 'integer',
- 'param1' => 'integer',
- 'param2' => 'integer',
- 'quantity' => 'integer',
- 'weight' => 'float',
- 'probability' => 'float',
- 'min_quantity' => 'integer',
- 'max_quantity' => 'integer',
- 'is_guaranteed' => 'boolean',
- 'extra_data' => 'json',
- ];
- /**
- * 获取奖励项所属的奖励组
- *
- * @return BelongsTo
- */
- public function rewardGroup(): BelongsTo
- {
- return $this->belongsTo(GameRewardGroup::class, 'group_id', 'id');
- }
- }
|