diff --git a/app/Admin/Controllers/DealerController.php b/app/Admin/Controllers/DealerController.php index 3bc35c43..3b46a5c1 100644 --- a/app/Admin/Controllers/DealerController.php +++ b/app/Admin/Controllers/DealerController.php @@ -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 ? '是' : '否'; diff --git a/app/Admin/Controllers/DealerEarningController.php b/app/Admin/Controllers/DealerEarningController.php index ab4dac17..c7a32e39 100644 --- a/app/Admin/Controllers/DealerEarningController.php +++ b/app/Admin/Controllers/DealerEarningController.php @@ -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('¥'); diff --git a/app/Admin/Controllers/DealerOrderController.php b/app/Admin/Controllers/DealerOrderController.php index 19f123e9..5c004b67 100644 --- a/app/Admin/Controllers/DealerOrderController.php +++ b/app/Admin/Controllers/DealerOrderController.php @@ -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', '备注'); diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerFansResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerFansResource.php index 09450b61..3c8b9ab7 100644 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerFansResource.php +++ b/app/Endpoint/Api/Http/Resources/Dealer/DealerFansResource.php @@ -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(); }, '未知'), ]; } diff --git a/app/Endpoint/Api/Http/Resources/Dealer/DealerResource.php b/app/Endpoint/Api/Http/Resources/Dealer/DealerResource.php index f6c3b74e..b1bce8f2 100644 --- a/app/Endpoint/Api/Http/Resources/Dealer/DealerResource.php +++ b/app/Endpoint/Api/Http/Resources/Dealer/DealerResource.php @@ -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, // 团队业绩 diff --git a/app/Endpoint/Api/Http/Resources/Merchant/UserInfoResource.php b/app/Endpoint/Api/Http/Resources/Merchant/UserInfoResource.php index 8eff3b9d..300e20f5 100644 --- a/app/Endpoint/Api/Http/Resources/Merchant/UserInfoResource.php +++ b/app/Endpoint/Api/Http/Resources/Merchant/UserInfoResource.php @@ -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, ]; } diff --git a/app/Enums/DealerLvl.php b/app/Enums/DealerLvl.php index 9570ce7f..69f8424d 100644 --- a/app/Enums/DealerLvl.php +++ b/app/Enums/DealerLvl.php @@ -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', ]; } } diff --git a/app/Models/UserInfo.php b/app/Models/UserInfo.php index 059f1ae5..7e443486 100644 --- a/app/Models/UserInfo.php +++ b/app/Models/UserInfo.php @@ -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] ?? ''; + } + /** * 获取完整的邀请路径 *