新增查询绑定结果接口(自建发货页轮询角色信息)
- GET /api/client/v1/orders/{order_no}/delivery/bind-result?bind_uuid=xxx
- 返回 bound/game_account/role_name/game_channel;未绑定返回 bound=false(不报错,供轮询)
- 对接文档自建发货页模式新增该接口,注明轮询建议间隔
This commit is contained in:
@@ -128,9 +128,14 @@ type DeliveryProduct struct {
|
||||
}
|
||||
|
||||
type DeliveryBindResult struct {
|
||||
BindUUID string `json:"bind_uuid"`
|
||||
BindURL string `json:"bind_url"`
|
||||
QRURL string `json:"qr_url"`
|
||||
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"`
|
||||
}
|
||||
|
||||
type DeliveryLinkResult struct {
|
||||
@@ -194,6 +199,37 @@ func (s *DeliveryService) BindForMerchant(merchantID uint, orderNo, gameAccount
|
||||
return s.bindWithOrder(orderNo, gameAccount, nil, merchantID)
|
||||
}
|
||||
|
||||
// GetBindResult 查询绑定结果(自建发货页轮询用)。
|
||||
// 绑定未完成时返回 bound=false(不报错),由前端提示继续扫码。
|
||||
func (s *DeliveryService) GetBindResult(merchantID uint, orderNo, bindUUID string) (*DeliveryBindResult, error) {
|
||||
bindUUID = strings.TrimSpace(bindUUID)
|
||||
if bindUUID == "" {
|
||||
return nil, errors.New("bind_uuid 不能为空")
|
||||
}
|
||||
openOrder, order, goodID, err := s.loadMerchantOrder(merchantID, orderNo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, _, _, err := s.buildDeliveryState(openOrder, order, goodID, false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
account, err := s.accountBound(bindUUID, goodID)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "尚未绑定") || strings.Contains(err.Error(), "未绑定") {
|
||||
return &DeliveryBindResult{BindUUID: bindUUID, Bound: false, Message: "尚未绑定,请先完成扫码绑定"}, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
return &DeliveryBindResult{
|
||||
BindUUID: bindUUID,
|
||||
Bound: true,
|
||||
GameAccount: stringFromMap(account, "game_account"),
|
||||
RoleName: stringFromMap(account, "game_account_role_name"),
|
||||
GameChannel: gameChannelText(account),
|
||||
Message: "绑定成功",
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *DeliveryService) bindWithOrder(orderNo, gameAccount string, auth *DeliveryLinkAuth, merchantID uint) (*DeliveryBindResult, error) {
|
||||
gameAccount = strings.TrimSpace(gameAccount)
|
||||
if gameAccount == "" {
|
||||
|
||||
Reference in New Issue
Block a user