| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace App\Module\Team\Models;
- use App\Module\Team\Enums\PROFIT_SOURCE_TYPE;
- use App\Module\Team\Enums\REFERRAL_LEVEL;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- use UCore\ModelCore;
- /**
- * 团队收益记录
- *
- * field start
- * @property int $id 主键ID
- * @property int $user_id 获得收益的用户ID
- * @property int $team_member_id 团队成员ID
- * @property int $source_id 收益来源ID
- * @property \App\Module\Team\Enums\PROFIT_SOURCE_TYPE $source_type 收益来源类型
- * @property int $item_id 物品ID
- * @property int $profit_amount 分成收益数量
- * @property float $profit_rate 分成比例
- * @property \App\Module\Team\Enums\REFERRAL_LEVEL $relation_type 关系类型:1直推,2间推
- * @property \Carbon\Carbon $created_at 创建时间
- * field end
- */
- class TeamProfit extends ModelCore
- {
- /**
- * 与模型关联的表名
- *
- * @var string
- */
- protected $table = 'team_profits';
- /**
- * 指示模型是否应该被打上时间戳
- *
- * @var bool
- */
- public $timestamps = false;
- // attrlist start
- protected $fillable = [
- 'id',
- 'user_id',
- 'team_member_id',
- 'source_id',
- 'source_type',
- 'item_id',
- 'profit_amount',
- 'profit_rate',
- 'relation_type',
- ];
- // attrlist end
- /**
- * 应该被转换为原生类型的属性
- *
- * @var array
- */
- protected $casts = [
- 'profit_rate' => 'float',
- 'source_type' => PROFIT_SOURCE_TYPE::class,
- 'relation_type' => REFERRAL_LEVEL::class,
- ];
- /**
- * 获取收益用户信息
- *
- * @return BelongsTo
- */
- public function user()
- {
- return $this->belongsTo('App\Models\User', 'user_id');
- }
- /**
- * 获取团队成员信息
- *
- * @return BelongsTo
- */
- public function teamMember()
- {
- return $this->belongsTo('App\Models\User', 'team_member_id');
- }
- /**
- * 获取物品信息
- *
- * @return BelongsTo
- */
- public function item()
- {
- return $this->belongsTo('App\Module\GameItems\Models\Item', 'item_id');
- }
- }
|