# 外部结算接口

## 外部系统调额

> 1：当用户在一个平台内进行下单，平台会发送这个请求到外部系统。这个请求必须在3秒内回复，否则平台判定为超时而取消该项操作，同时也会发送 "取消外部系统划账调额" 到外部系统，以便外部系统保持数据的一致性。\
> 2：特殊说明，调用 “取消外部系统调额”接口，如果发生异常或者没有收到正确响应，会重试指定次数后，中止后续操作。\
> \
> !\[]\(<https://www.processon.com/view/link/64a4e5122383dc0d3e2b982c>)

```json
{"openapi":"3.0.1","info":{"title":"默认模块","version":"1.0.0"},"tags":[{"name":"外部结算接口"}],"servers":[{"url":"https://prewppc-3.cmfbl.com/api","description":"PRE测试公司439"}],"security":[],"paths":{"/":{"post":{"summary":"外部系统调额","deprecated":false,"description":"1：当用户在一个平台内进行下单，平台会发送这个请求到外部系统。这个请求必须在3秒内回复，否则平台判定为超时而取消该项操作，同时也会发送 \"取消外部系统划账调额\" 到外部系统，以便外部系统保持数据的一致性。\n2：特殊说明，调用 “取消外部系统调额”接口，如果发生异常或者没有收到正确响应，会重试指定次数后，中止后续操作。\n\n![](https://www.processon.com/view/link/64a4e5122383dc0d3e2b982c)","tags":["外部结算接口"],"parameters":[{"name":"trace","in":"header","description":"全局链路标志","required":true,"schema":{"type":"string"}},{"name":"companyId","in":"header","description":"Company Id，用户所在国家","required":false,"schema":{"type":"integer"}},{"name":"timestamp","in":"header","description":"请求发起时间戳，精确到毫秒，13位","required":true,"schema":{"type":"number"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"thirdServerCode":{"type":"string","description":"第三方系统客户唯一编号"},"userName":{"type":"string","description":"TradeBoss 用户身份唯一编号","title":"","maxLength":48},"currency":{"type":"string","description":"账户货币code，标准ISO 3字元货币单位","title":"","maxLength":16},"bizType":{"type":"integer","description":"业务类型，1-市价开；2-市价平；10-限价预埋单；11-停损预埋单；12-限价开"},"operationType":{"type":"string","description":"操作类型，OPEN_POSITION=开仓，NORMAL_CLOSE=正常平仓，ABNORMAL_OVERTRADING=异常穿仓，当为NORMAL_CLOSE，OPEN_POSITION时，amount只能为正数；当为ABNORMAL_OVERTRADING时，amount为负数，外部系统可自主决定是否继续扣除额度，来完结此交易，也可以忽略此请求。"},"amount":{"type":"string","description":"金额，结合operationType使用"},"amountDigits":{"type":"integer","description":"金额小数位"},"orderId":{"type":"integer","format":"long","description":"订单id"},"requestUniqueNo":{"type":"string","description":"请求唯一编号，多次请求需要保持业务幂等","maxLength":48},"requestTime":{"type":"integer","format":"long","description":"请求发起时间戳，精确到毫秒，13位"},"ip":{"type":"string","description":"用户ip"},"metadata":{"type":"string","description":"备注信息，json格式","maxLength":200}},"required":["currency","userName","amount","requestUniqueNo","ip","requestTime","amountDigits","bizType","operationType","orderId","thirdServerCode"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"bizCode":{"type":"string","description":"模块标识码，当前请求最终处理的服务模块，可为空"},"code":{"type":"string","description":"状态返回码，code=0，标识当前请求操作成功，其他code标识操作失败"},"msg":{"type":"string","description":"状态描述"},"tm":{"type":"integer","format":"int64","description":"处理时长（毫秒）"},"trace":{"type":"string","description":"全局链路标志，与请求头中的trace保持一致，便于定位问题"},"msgParams":{"type":"string","description":"返回状态描述中占位符参数串，多个参数间以,分割，用于处理状态描述中的变参信息，给用户友好的交互体验"},"data":{"type":"object","properties":{},"description":"响应结果体"},"ok":{"type":"boolean","description":"操作是否成功，成功=true，失败=false"},"fail":{"type":"boolean","description":"操作是否失败，成功=false，失败=true"}}}}},"headers":{}}}}}}}
```

## 取消操作

> 当请求超时或者第三方系统返回错误信息，就会发出此请求，来取消对应操作。

```json
{"openapi":"3.0.1","info":{"title":"默认模块","version":"1.0.0"},"tags":[{"name":"外部结算接口"}],"servers":[{"url":"https://prewppc-3.cmfbl.com/api","description":"PRE测试公司439"}],"security":[],"paths":{"/global/tradeapi.app.OrderApiService.queryPBOOrderPage":{"post":{"summary":"取消操作","deprecated":true,"description":"当请求超时或者第三方系统返回错误信息，就会发出此请求，来取消对应操作。","tags":["外部结算接口"],"parameters":[{"name":"companyId","in":"header","description":"","required":false,"schema":{"type":"string"}},{"name":"token","in":"header","description":"","required":false,"schema":{"type":"string"}},{"name":"lang","in":"header","description":"","required":false,"schema":{"type":"string"}},{"name":"group","in":"header","description":"","required":false,"schema":{"type":"string"}},{"name":"trace","in":"header","description":"","required":false,"schema":{"type":"string"}},{"name":"version","in":"header","description":"","required":false,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"username":{"type":"string","description":"客户身份唯一编号","title":"","maxLength":48},"tx_reverse_id":{"type":"string","description":"回退唯一交易编号，这个编号是对应之前请求时的 txid，与reverse_type配合使用，第三方系统需要检查这个tx_reverse_id是否有处理过，如果已经被正确处理过，则返回成功即可","maxLength":48},"reverse_type":{"type":"integer","description":"回退类型，1下单，2平仓"},"txid":{"type":"string","description":"唯一交易编号，多次请求需要保持业务幂等","maxLength":48},"requesttime":{"type":"integer","format":"long","description":"请求发起时间戳，精确到毫秒，13位"},"ip":{"type":"string","description":"用户ip"},"cancel_remark":{"type":"string","description":"取消原因简述 ","maxLength":200}},"required":["username","txid","ip","requesttime","cancel_remark","tx_reverse_id","reverse_type"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"bizCode":{"type":"string","description":"模块标识码"},"code":{"type":"string","description":"状态返回码，code=0标识当前请求操作成功，其他code处理异常"},"msg":{"type":"string","description":"状态描述"},"tm":{"type":"integer","format":"int64","description":"处理时长（毫秒）"},"trace":{"type":"string","description":"跟踪码"},"msgParams":{"type":"string","description":"返回描述中占位符参数串，多个参数间以,分割"},"data":{"type":"object","properties":{},"description":"消息体"},"ok":{"type":"boolean"},"fail":{"type":"boolean"}}}}},"headers":{}}}}}}}
```

## 取消外部系统调额

> 当“外部系统调额”，请求超时或者外部系统返回错误信息，平台就会发出此请求到外部系统，以便外部系统保持数据的一致性。

```json
{"openapi":"3.0.1","info":{"title":"默认模块","version":"1.0.0"},"tags":[{"name":"外部结算接口"}],"servers":[{"url":"https://prewppc-3.cmfbl.com/api","description":"PRE测试公司439"}],"security":[],"paths":{"/get-user-amount":{"post":{"summary":"取消外部系统调额","deprecated":false,"description":"当“外部系统调额”，请求超时或者外部系统返回错误信息，平台就会发出此请求到外部系统，以便外部系统保持数据的一致性。","tags":["外部结算接口"],"parameters":[{"name":"trace","in":"header","description":"全局链路标志","required":true,"schema":{"type":"string"}},{"name":"companyId","in":"header","description":"Company Id，用户所在国家","required":false,"schema":{"type":"integer"}},{"name":"timestamp","in":"header","description":"请求发起时间戳，精确到毫秒，13位","required":true,"schema":{"type":"number"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"thirdServerCode":{"type":"string","description":"第三方系统客户唯一编号"},"userName":{"type":"string","description":"TradeBoss 用户身份唯一编号","title":"","maxLength":48},"currency":{"type":"string","description":"账户货币code，标准ISO 3字元货币单位","title":"","maxLength":16},"bizType":{"type":"integer","description":"业务类型，1-市价开；2-市价平；10-限价预埋单；11-停损预埋单；12-限价开"},"amount":{"type":"string","description":"金额，只能为正数"},"amountDigits":{"type":"integer","description":"金额小数位"},"orderId":{"type":"integer","format":"long","description":"订单id"},"requestUniqueNo":{"type":"string","description":"请求唯一编号，多次请求需要保持业务幂等","maxLength":48},"reverseRequestUniqueNo":{"type":"string","description":"这个编号是对应之前“外部系统调额”请求时的requestUniqueNo。外部系统需要检查这个编号是否有处理过，如果正确处理，则需要返还正确的额度给客户；如果接受到请求但没有正确处理需返回code=US_0000001，没有接收到此编号的请求，否则返回code=US_0000002"},"requestTime":{"type":"integer","format":"long","description":"请求发起时间戳，精确到毫秒，13位"},"ip":{"type":"string","description":"用户ip"},"cancelRemark":{"type":"string","description":"取消原因","maxLength":200},"metadata":{"type":"string","description":"备注信息，json格式","maxLength":200}},"required":["currency","userName","amount","requestUniqueNo","ip","requestTime","amountDigits","bizType","cancelRemark","reverseRequestUniqueNo"]}}}},"responses":{"200":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"bizCode":{"type":"string","description":"模块标识码，当前请求最终处理的服务模块，可为空"},"code":{"type":"string","description":"状态返回码，code=0，标识当前请求操作成功，其他code标识操作失败"},"msg":{"type":"string","description":"状态描述"},"tm":{"type":"integer","format":"int64","description":"处理时长（毫秒）"},"trace":{"type":"string","description":"全局链路标志，与请求头中的trace保持一致，便于定位问题"},"msgParams":{"type":"string","description":"返回状态描述中占位符参数串，多个参数间以,分割，用于处理状态描述中的变参信息，给用户友好的交互体验"},"data":{"type":"object","properties":{},"description":"响应结果体"},"ok":{"type":"boolean","description":"操作是否成功，成功=true，失败=false"},"fail":{"type":"boolean","description":"操作是否失败，成功=false，失败=true"}}}}},"headers":{}}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-cn.multimarkets.org/client-api/geng-duo-.../wai-bu-jie-suan-jie-kou.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
