From d6b426ab2acfecbb3bcf23e6def56fa757d79e67 Mon Sep 17 00:00:00 2001 From: yml2213 Date: Mon, 3 Aug 2026 17:47:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E7=BB=91=E5=AE=9A=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E5=A2=9E=E5=8A=A0=E9=A2=84=E6=9C=9F=E8=B4=A6=E5=8F=B7?= =?UTF-8?q?=E6=AF=94=E5=AF=B9=EF=BC=9Amismatch=20=E6=8F=90=E5=89=8D?= =?UTF-8?q?=E6=8B=A6=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 下单 data 传了 game_account 时,bind-result 返回 expected_game_account 与 mismatch - 绑定账号与预期不一致时 message 提示,配合 submit 已有的一致性校验提前发现 - 对接文档补充 mismatch 字段与说明 --- backend/internal/service/delivery.go | 34 +++++++++++++++++-------- backend/internal/service/fulfillment.go | 8 ++++++ frontend/src/openapi/endpoints.ts | 7 ++++- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/backend/internal/service/delivery.go b/backend/internal/service/delivery.go index 355ffd7..eeee7ea 100644 --- a/backend/internal/service/delivery.go +++ b/backend/internal/service/delivery.go @@ -128,14 +128,16 @@ type DeliveryProduct struct { } type DeliveryBindResult struct { - BindUUID string `json:"bind_uuid"` - BindURL string `json:"bind_url"` - QRURL string `json:"qr_url"` - Bound bool `json:"bound"` - GameAccount string `json:"game_account,omitempty"` - RoleName string `json:"role_name,omitempty"` - GameChannel string `json:"game_channel,omitempty"` - Message string `json:"message,omitempty"` + BindUUID string `json:"bind_uuid"` + BindURL string `json:"bind_url"` + QRURL string `json:"qr_url"` + Bound bool `json:"bound"` + GameAccount string `json:"game_account,omitempty"` + RoleName string `json:"role_name,omitempty"` + GameChannel string `json:"game_channel,omitempty"` + ExpectedGameAccount string `json:"expected_game_account,omitempty"` + Mismatch bool `json:"mismatch,omitempty"` + Message string `json:"message,omitempty"` } type DeliveryLinkResult struct { @@ -220,14 +222,24 @@ func (s *DeliveryService) GetBindResult(merchantID uint, orderNo, bindUUID strin } return nil, err } - return &DeliveryBindResult{ + boundAccount := stringFromMap(account, "game_account") + result := &DeliveryBindResult{ BindUUID: bindUUID, Bound: true, - GameAccount: stringFromMap(account, "game_account"), + GameAccount: boundAccount, RoleName: stringFromMap(account, "game_account_role_name"), GameChannel: gameChannelText(account), Message: "绑定成功", - }, nil + } + // 下单时 data 透传的预期账号:绑定账号与预期不一致时提示,供自建页提前拦截。 + if expected := requestDataString(order.RequestData, "game_account"); expected != "" { + result.ExpectedGameAccount = expected + if boundAccount != expected { + result.Mismatch = true + result.Message = "绑定成功,但绑定账号与下单预期账号不一致,请确认" + } + } + return result, nil } func (s *DeliveryService) bindWithOrder(orderNo, gameAccount string, auth *DeliveryLinkAuth, merchantID uint) (*DeliveryBindResult, error) { diff --git a/backend/internal/service/fulfillment.go b/backend/internal/service/fulfillment.go index 4b01b6d..33beafe 100644 --- a/backend/internal/service/fulfillment.go +++ b/backend/internal/service/fulfillment.go @@ -1322,6 +1322,14 @@ func requestDataMap(raw string) map[string]interface{} { return m } +// requestDataString 读取下单透传 data 中的字符串字段。 +func requestDataString(raw, key string) string { + if v, ok := requestDataMap(raw)[key].(string); ok { + return strings.TrimSpace(v) + } + return "" +} + func resultDataString(raw, key string) string { if v, ok := resultDataMap(raw)[key].(string); ok { return v diff --git a/frontend/src/openapi/endpoints.ts b/frontend/src/openapi/endpoints.ts index 6c5f3ad..ed9a300 100644 --- a/frontend/src/openapi/endpoints.ts +++ b/frontend/src/openapi/endpoints.ts @@ -378,7 +378,9 @@ export const endpoints: EndpointSpec[] = [ "game_account": "4808146277", "role_name": "巫师哈丁12", "game_channel": "IOS-微信", - "message": "绑定成功" + "expected_game_account": "1192083858", + "mismatch": true, + "message": "绑定成功,但绑定账号与下单预期账号不一致,请确认" } }`, responseFields: [ @@ -387,11 +389,14 @@ export const endpoints: EndpointSpec[] = [ { name: 'game_account', type: 'string', desc: '玩家编号(已绑定时返回)' }, { name: 'role_name', type: 'string', desc: '角色名(已绑定时返回)' }, { name: 'game_channel', type: 'string', desc: '区服渠道(已绑定时返回)' }, + { name: 'expected_game_account', type: 'string', desc: '下单时 data 透传的预期账号(有传时才返回)' }, + { name: 'mismatch', type: 'bool', desc: '绑定账号与预期账号不一致(下单传了预期账号时才可能为 true)' }, { name: 'message', type: 'string', desc: '状态说明' }, ], notes: [ '用户扫码绑定完成前返回 bound=false,自建页可定时轮询此接口刷新状态。', '轮询间隔建议 2-3 秒,绑定成功后展示角色信息并引导提交发货。', + '下单时 data 传了 game_account 的情况下,绑定账号不一致会返回 mismatch=true,提交发货也会被拒绝(请让买家绑回预期账号或重新下单)。', ], }, {