6
0
Fork 0

等级图标

release
李静 2022-02-28 10:49:59 +08:00
parent ccafcc5801
commit 8dada477a4
8 changed files with 40 additions and 10 deletions

View File

@ -42,7 +42,7 @@ class DealerController extends AdminController
$lvlTexts = DealerLvl::texts();
$grid->column('lvl')->display(function () {
return $this->lvl_text;
return $this->lvl->text();
})->filter(Grid\Column\Filter\In::make($lvlTexts));
$grid->column('wallet.balance')->display(function ($value) {
return $value ?? 0;
@ -111,7 +111,7 @@ class DealerController extends AdminController
// $show->field('id');
$show->field('user.phone');
$show->field('lvl')->as(function () {
return $this->lvl_text;
return $this->lvl->text();
});
$show->field('is_sale')->as(function ($val) {
return $val ? '是' : '否';

View File

@ -57,7 +57,6 @@ class DealerEarningController extends AdminController
// $grid->column('earningable_id');
$grid->column('lvl')->display(function () {
return $this->lvl->text();
// return $this->lvl_text;
});
$grid->column('is_manager')->bool();
$grid->column('total_amount')->prepend('¥');

View File

@ -275,7 +275,6 @@ HTML;
$grid->column('user.phone', '手机号');
$grid->column('lvl', '等级')->display(function () {
return $this->lvl->text();
// return $this->lvl_text;
});
$grid->column('total_amount', '补贴金额');
$grid->column('remark', '备注');

View File

@ -27,7 +27,7 @@ class DealerFansResource extends JsonResource
return $this->dealer->team_sales_value;
}, 0),
'lvl_name' => (string) $this->whenLoaded('dealer', function () {
return $this->dealer->lvl_text;
return $this->dealer->lvl->text();
}, '未知'),
];
}

View File

@ -16,7 +16,8 @@ class DealerResource extends JsonResource
{
return [
'lvl' => $this->lvl,
'lvl_name'=> $this->lvl_text,
'lvl_icon' => $this->lvl->icon(),
'lvl_name'=> $this->lvl->text(),
'is_sale' => $this->is_sale,
'guanli_values'=> bcdiv($this->calculate_total_amount, '1', 2), //预计管理津贴
'team_sales_value' => $this->team_sales_value, // 团队业绩

View File

@ -23,6 +23,7 @@ class UserInfoResource extends JsonResource
'points' => (int) $this->points,
'quota_v2' => $this->quota_v2,
'quota_v1' => $this->quota_v1,
'agent_level_icon' => $this->agent_level_icon,
'agent_level_name' => $this->agent_level_name,
];
}

View File

@ -25,6 +25,18 @@ enum DealerLvl: int {
};
}
/**
* @return string
*/
public function icon()
{
return match ($this) {
static::Secondary => 'https://cdn.zichunsheng.cn/statics/icons/dealer_lvl_5.png',
static::Top => 'https://cdn.zichunsheng.cn/statics/icons/dealer_lvl_6.png',
default => '',
};
}
/**
* @return string
*/
@ -35,8 +47,8 @@ enum DealerLvl: int {
static::Gold => '金牌经销商',
static::Special => '特邀经销商',
static::Contracted => '签约经销商',
static::Secondary => '二级经销商',
static::Top => '一级经销商',
static::Secondary => '签约经销商II',
static::Top => '签约经销商I',
};
}
@ -50,8 +62,8 @@ enum DealerLvl: int {
static::Gold->value => '金牌经销商',
static::Special->value => '特邀经销商',
static::Contracted->value => '签约经销商',
static::Secondary->value => '二级经销商',
static::Top->value => '一级经销商',
static::Secondary->value => '签约经销商II',
static::Top->value => '签约经销商I',
];
}
}

View File

@ -125,6 +125,19 @@ class UserInfo extends Model
self::AGENT_LEVEL_DIRECTOR => '默认用户',
];
/**
* 代理等级图标
*
* @var array
*/
public static $agentLevelIcons = [
self::AGENT_LEVEL_COMMUNITY => 'https://cdn.zichunsheng.cn/statics/icons/lvl_2.png',
self::AGENT_LEVEL_DISTRICT => 'https://cdn.zichunsheng.cn/statics/icons/lvl_3.png',
self::AGENT_LEVEL_CITY => 'https://cdn.zichunsheng.cn/statics/icons/lvl_4.png',
self::AGENT_LEVEL_PROVINCE => 'https://cdn.zichunsheng.cn/statics/icons/lvl_5.png',
self::AGENT_LEVEL_BRANCH => 'https://cdn.zichunsheng.cn/statics/icons/lvl_6.png',
];
/**
* {@inheritdoc}
*/
@ -458,6 +471,11 @@ class UserInfo extends Model
return static::$agentLevelTexts[$this->agent_level] ?? '未知';
}
public function getAgentLevelIconAttribute(): string
{
return static::$agentLevelIcons[$this->agent_level] ?? '';
}
/**
* 获取完整的邀请路径
*