CaiWuXiTong/app/Models/Business/CourierOnboardingFile.php
limeng 588ddb9404 feat(快递入驻): 去掉重量取整和每票固定加收,个人入驻对公必填、对私选填 (#1001)
- 扫码入驻表单去掉「重量取整」「每票固定加收」(公司、个人都去掉);未提交这两项时不改动已有值,后台变价以隐藏字段沿用当前规则,避免清空已开通快递的计费规则
- 个人入驻:对公账户(户名/开户行/账号)改为必填;对私账户改为选填,填了仍须为本人;对私银行卡照片随之选填
- 公司入驻:对公、对私仍都必填
涉及:入驻表单与提交校验;不涉及迁移、权限和上游写入。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VANWYsNUbu2piMtCKymoyd
2026-11-09 09:57:25 +08:00

82 lines
2.8 KiB
PHP

<?php
namespace App\Models\Business;
use App\Abstracts\Model;
class CourierOnboardingFile extends Model
{
public const KINDS = [
'business_license' => '营业执照',
'legal_id_card_front' => '法人身份证 · 人像面',
'legal_id_card_back' => '法人身份证 · 国徽面',
'bank_card_front' => '对私银行卡 · 正面',
'bank_card_back' => '对私银行卡 · 反面',
];
/** 计费方式选「其他」时上传的报价表,单独显示在报价区块里。 */
public const QUOTE_SHEET_KIND = 'quote_sheet';
/** @return array<string,string> */
public static function allKinds(): array
{
return self::KINDS + [self::QUOTE_SHEET_KIND => '报价表'];
}
/** 个人入驻时的资料名称。 */
public const PERSON_KINDS = [
'business_license' => '营业执照(有就上传,选填)',
'legal_id_card_front' => '身份证 · 人像面',
'legal_id_card_back' => '身份证 · 国徽面',
'bank_card_front' => '对私银行卡 · 正面(选填)',
'bank_card_back' => '对私银行卡 · 反面(选填)',
];
/** 提交审核前必须上传的资料(每项一张,重新上传会替换)。 */
public const REQUIRED_KINDS = ['business_license', 'legal_id_card_front', 'legal_id_card_back', 'bank_card_front', 'bank_card_back'];
/** 个人入驻对私账户选填,银行卡照片随之选填。 */
public const PERSON_REQUIRED_KINDS = ['legal_id_card_front', 'legal_id_card_back'];
/** @return list<string> */
public static function requiredKindsFor(?string $entityType): array
{
return $entityType === CourierOnboarding::ENTITY_PERSON ? self::PERSON_REQUIRED_KINDS : self::REQUIRED_KINDS;
}
public static function labelFor(string $kind, ?string $entityType): string
{
return ($entityType === CourierOnboarding::ENTITY_PERSON ? (self::PERSON_KINDS[$kind] ?? null) : null)
?? self::allKinds()[$kind]
?? $kind;
}
protected $table = 'business_courier_onboarding_files';
protected $fillable = ['company_id', 'onboarding_id', 'kind', 'original_name', 'path', 'mime', 'size'];
protected $casts = [
'company_id' => 'integer',
'onboarding_id' => 'integer',
'size' => 'integer',
'deleted_at' => 'datetime',
];
public function kindLabel(): string
{
return self::KINDS[$this->kind] ?? $this->kind;
}
public function isImage(): bool
{
return str_starts_with((string) $this->mime, 'image/');
}
public function sizeLabel(): string
{
$size = (int) $this->size;
return $size >= 1048576 ? sprintf('%.1f MB', $size / 1048576) : sprintf('%d KB', max(1, (int) ceil($size / 1024)));
}
}