CaiWuXiTong/app/Models/Business/CourierSurchargeQuote.php
zhoushengchen 2a756edac7 快递附加费报价正式维护模块 (#97)
## 任务目标
将“快递附加费报价维护”从前端演示改为正式可持久化维护模块,新增、编辑、启停后刷新仍保留。

## 开工范围
- 将写入:`business_courier_surcharge_quotes` 数据表及迁移;`business.courier-surcharge.*` 保存、更新、状态接口;报价维护页的数据读取和维护交互;对应 Feature 测试。
- 预计路径:
  - `app/Business/CourierSurchargeQuoteRepository.php`
  - `app/Http/Controllers/Business/CourierSurchargeQuotes.php`
  - `app/Http/Controllers/Business/Pages.php`
  - `app/Models/Business/CourierSurchargeQuote.php`
  - `database/migrations/2026_09_02_000000_create_courier_surcharge_quotes_table.php`
  - `resources/views/business/pages/courier-payables/courier-surcharge.blade.php`
  - `routes/admin.php`
  - `tests/Feature/Business/CourierSurchargePageTest.php`
- 页面与路由:`courier-payables/courier-surcharge`;新增、编辑、启停使用 POST/PATCH 正式接口。
- 数据源与字段:当前公司报价规则表;快递名称、快递归属、对账人、可多选附加费类型、结算方式、计价标准、生效条件、生效日期、状态、备注。
- 权限与公共契约:复用现有 `business.page:courier-payables,courier-surcharge` 和 `business.pages.show`,不修改全局权限或共享组件。
- 明确不修改:上游数据库、业务镜像、生产配置、七牛、其他业务页面和部署脚本。

## 验证
- `docker exec -u www-data jiangling_app php artisan test tests/Feature/Business/CourierSurchargePageTest.php`
- 3 passed,41 assertions。
- PHP 语法检查及路由检查通过。
- 本地共享模式页面已实际刷新验收;由于迁移尚未在共享系统数据库执行,页面明确显示“数据表尚未就绪”并禁用维护操作。

## 风险与后续
- 新迁移尚未执行。共享系统数据库迁移属于管理员/发布授权范围,普通开发者不得直接执行;管理员完成迁移后页面即可启用正式维护。
- 不自动把旧的六条演示规则写入正式表,待产品决定是否由管理员录入或增加一次性初始化迁移。

Reviewed-on: http://git.1080p.hk/WuYongJie/CaiWuXiTong/pulls/97
2026-09-02 16:53:42 +08:00

52 lines
1.1 KiB
PHP

<?php
namespace App\Models\Business;
use App\Abstracts\Model;
class CourierSurchargeQuote extends Model
{
public const STATUS_ACTIVE = 'active';
public const STATUS_INACTIVE = 'inactive';
protected $table = 'business_courier_surcharge_quotes';
protected $fillable = [
'company_id',
'courier',
'scope',
'reconciler',
'types',
'mode',
'standard',
'condition',
'effective_at',
'status',
'remark',
'created_by',
'updated_by',
];
protected $casts = [
'company_id' => 'integer',
'types' => 'array',
'effective_at' => 'date:Y-m-d',
'created_by' => 'integer',
'updated_by' => 'integer',
];
public function statusLabel(): string
{
return $this->status === self::STATUS_ACTIVE ? '已启用' : '已停用';
}
public function typeLabel(): string
{
return implode('、', array_values(array_filter(array_map(
static fn ($type): string => trim((string) $type),
(array) $this->types,
))));
}
}