同步代理等级
parent
2987b097d8
commit
f22a9a7cc5
|
|
@ -10,6 +10,21 @@ enum DealerLvl: int {
|
|||
case Secondary = 5;
|
||||
case Top = 6;
|
||||
|
||||
/**
|
||||
* 代理等级
|
||||
*/
|
||||
public function agentLvl()
|
||||
{
|
||||
return match ($this) {
|
||||
static::None => 1,
|
||||
static::Gold => 3,
|
||||
static::Special => 4,
|
||||
static::Contracted => 5,
|
||||
static::Secondary => 6,
|
||||
static::Top => 7,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -34,18 +34,6 @@ class Dealer extends Model
|
|||
'contracted_lvl_at',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function ($dealer) {
|
||||
if ($dealer->last_upgrade_at === null) {
|
||||
$dealer->last_upgrade_at = now();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
|
|
@ -179,5 +167,13 @@ class Dealer extends Model
|
|||
'change_lvl' => $lvl,
|
||||
'remark' => $remark,
|
||||
]);
|
||||
|
||||
// 变更代理等级
|
||||
$mapAgentLvl = $this->lvl->agentLvl();
|
||||
|
||||
if ($this->userInfo->agent_level < $mapAgentLvl) {
|
||||
$this->userInfo->agent_level = $mapAgentLvl;
|
||||
$this->userInfo->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue