# feat(agency): 支付配置加 name + appId 字段, 编辑表单不再空

**日期**: 2026-05-06 16:55
**通知对象**: @mmg (前端)
**关联 PR**: wx/HL #1719 (已 merge dev + 测试服部署完成 + round-trip 通过)
**前序**: PR #1717 (字典) + PR #1718 (nacos full sync)

---

## 一、用户反馈解决

PR #1718 部署后, 用户截图反馈「编辑支付配置」对话框仍有 2 个字段为空:
- 「配置名称」: 空 (placeholder "如: 微信支付-主商户号")
- 「AppId」: 空 (placeholder "请输入 AppId")

根因: `TravelAgencyPaymentDO` entity / SaveReqVO / RespVO 完全没有 `name` + `appId` 字段。

---

## 二、本 PR 修复

| 类型 | 改动 |
|---|---|
| DDL V20260506_008 | `travel_agency_payment` ADD `name VARCHAR(64)` + `app_id VARCHAR(64)` |
| Entity TravelAgencyPaymentDO | 加 `name` + `appId` 字段 |
| AgencyPaymentSaveReqVO | 加 `name` (@NotBlank @Size 64) + `appId` (@NotBlank @Size 64) |
| AgencyPaymentRespVO | 加 `name` + `appId` |
| Service `toRespVO` | 同步 set name/appId |
| `AgencyDataInitializer.initPaymentForAgency` | INSERT 默认 `name="微信支付-{code}"` + `appId=wechat.pay.app-id` (三家共用 `wx4711a76772deff36`); SYNC existing 字段空时回填 |

---

## 三、API 改动

### `POST /admin/travel-agency/{agencyId}/payment` + `PUT .../payment/{paymentId}`

`AgencyPaymentSaveReqVO` 新增 2 个 **必填字段**:

```json
{
  "name": "微信支付-主商户号",       // ← 新增, @NotBlank, max 64
  "mchId": "1106110439",
  "appId": "wx4711a76772deff36",     // ← 新增, @NotBlank, max 64
  "apiV3Key": "...",
  "mchSerialNo": "...",
  "publicKeyId": "PUB_KEY_ID_...",
  "isDefault": 1,
  "status": "ENABLED",
  "remark": ""
}
```

### `GET /admin/travel-agency/{agencyId}/payment` 响应

```json
{
  "paymentId": 5001,
  "agencyId": 2051922156798779394,
  "name": "微信支付-hulai",            // ← 新增
  "mchId": "1106110439",
  "appId": "wx4711a76772deff36",       // ← 新增
  "apiV3Key": "2XxC4RHqyipPMwpVoAhXsvj1hvrwgbAJ",
  "mchSerialNo": "60508F77...",
  "publicKeyId": "PUB_KEY_ID_0111061104392026020200181614001205",
  "isDefault": 1,
  "status": "ENABLED",
  "statusLabel": "启用",
  ...
}
```

---

## 四、测试服 round-trip 验证 (2026-05-06 16:55)

```bash
TOK=$(curl -sk -X POST "https://api.test.1814.love:9443/admin/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"username":"admin","password":"Admin@123456"}' \
  | python -c "import json,sys; print(json.load(sys.stdin)['data']['token'])")

curl -sk "https://api.test.1814.love:9443/admin/travel-agency/2051922156798779394/payment" \
  -H "Authorization: Bearer $TOK"
```

| 公司 | name | appId | mchId |
|---|---|---|---|
| hulai | 微信支付-hulai | wx4711a76772deff36 | 1106110439 |
| qianshou | 微信支付-qianshou | wx4711a76772deff36 | 1246532201 |
| hulai-wenlu | 微信支付-hulai-wenlu | wx4711a76772deff36 | 1684769133 |

---

## 五、前端

- 新建表单: `name` + `appId` 必填, 已存在 `mchId` / `apiV3Key` / `mchSerialNo` / `publicKeyId` 字段保持
- 编辑表单: 后端返回字段已填默认值 (`微信支付-{code}` / 三家共用 `wx4711a76772deff36`), admin 可改 name 为更友好命名
- 刷新页面即可看到字段全部填充

---

## 六、agency 模块 4 个 PR 全闭环

| PR | 内容 |
|---|---|
| #1715 | admin path 纠回 `/admin/travel-agency` (设计冻结) |
| #1717 | 资质附件 qualificationType + 字典 (agency_qualification_type / agency_contract_platform) |
| #1718 | nacos 完整字段同步 (teamReportAppId/SignKey/supportedPlatforms + payment 加密字段) |
| **#1719** | **payment name + appId 字段(本 PR)** |

---

cc @mmg
