| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace App\Services\Agent;
- use App\Models\Agent\Agent;
- /** 登录与个人信息共用的代理概要:类型、平台邀请地址、资金构成、合营方案或入股比例。不含实时保证金。 */
- class AgentProfileService
- {
- public function __construct(private AgentDomainService $domains, private AgentWalletService $wallets)
- {
- }
- public function summary(Agent $agent): array
- {
- $agent->loadMissing('profitCommissionProfile');
- $data = [
- 'id' => (int) $agent->id,
- 'username' => $agent->username,
- 'real_name' => $agent->real_name,
- 'language' => $agent->language ?? 'zh',
- 'invitation_code' => $agent->invitation_code,
- 'type' => (int) $agent->type,
- 'type_text' => $agent->type_text,
- 'withdraw_fee_rate' => (string) $agent->withdraw_fee_rate,
- 'has_withdraw_password' => (string) $agent->withdraw_password !== '',
- ] + $this->domains->format($agent) + $this->wallets->funds($agent);
- if ($agent->isJoint()) {
- $profile = $agent->profitCommissionProfile;
- $data['profit_commission_profile_id'] = $agent->profit_commission_profile_id;
- $data['profit_commission_profile'] = $profile;
- $data['required_margin_amount'] = $profile ? (string) $profile->margin_amount : null;
- $data['profit_active'] = (int) $agent->profit_active;
- $data['profit_active_text'] = (int) $agent->profit_active ? '分成中' : ($profile ? '保证金不足,暂停分成' : '未开通方案');
- }
- return $data;
- }
- }
|