# GamePool API
:::info
Author : Scott
Version : 1.0.0
Data : 2019-06-27
:::
[TOC]
###### tags: `gamepool`
## 測試資訊
### 測試網址
外部IP : http://devh5.lianfa.co/api
### 測試GSToken
放置在Header 之中:
```
Authorization :
```
## 時間格式
時區: `UTC+0`
格式: `RFC3339`
Example:
```shell
1996-12-19T16:39:57Z
```
## Header
每個 Request 必帶 Header 項目
| Parameter | Type | Value |Description|
| --- | --- | --- | --- |
| Authorization | string | 給予的token |遊戲商token|
| Content-Type | string | application/json | 除 GET 方法外都需要 |
## Response
統一規範輸出格式
| Parameter | Type |Description|
| --- | --- | --- |
| data | string |資料給予的地方|
| status | string | 狀態欄 |
| code | int | 狀態碼 |
| message | string | 狀態訊息 |
| datatime | string | 回應時間 |
```json
{
"data":{
},
"status":{
"code" : 0,
"message" : "success",
"datatime" : "2017-01-20T01:44:33-04:00"
}
}
```
## API
### 即時在線玩家
功能: 取得即時在線玩家
URI: `/session/list`
Method : `GET`
Request :
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| page | int | page |
| pagesize | int | pagesize |
| parentAccount | string | parentAccount |
Response:
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| data | []object | data |
| totalPage | int | totalPage |
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| id | string | id |
| uid | int64 | uid |
| gameID | int | gameID |
| account | string | account |
| parentID | string | parentID |
| gatewayID | string | gatewayID |
| level | string | level |
| ip | string | ip |
Example:
```json
{
"data":{
"data":[
{
"id": "test001_21",
"uid": "CNY",
"gameID": 3,
"account": "test001",
"parentID": "bbin",
"gatewayID": "gateway-1-1",
"level": 1,
"ip": "127.0.0.1",
},
{
"id": "test002_22",
"uid": "CNY",
"gameID": 3,
"account": "test002",
"parentID": "bbin",
"gatewayID": "gateway-1-2",
"level": 3,
"ip": "127.0.0.1",
}
],
"totalPage": 1
},
"status":{
"code" : 0,
"message" : "success",
"datatime" : "2017-01-20T01:44:33-04:00"
}
}
```
### 取得所有卡單資料
功能 : 取得所有卡單資料
URI : `/rollinfailed/list`
Method : `GET`
Request :
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
Response:
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| id | int | userid |
| mtCode | string | 交易單號 |
| round | string | 局號 |
| amount | float64 | 結算後餘額 |
| bet | float64 | 投注額 |
| win | float64 | 派獎 |
| validAmount | float64 | 有效投注額(百家樂類) |
| backAmount | float64 | 開和時退還款項(庄閒兩格總下注額)(百家樂類) |
| tax | float64 | 稅收 |
| gameType | int32 | 遊戲類型 1:一般牌類 2:百家樂類 |
| jackpot | float64 | jackpot |
| dateTime | int64 | 時間 |
| gameCode | string | 遊戲代碼 |
| level | int32 | 房間level |
Example:
```json
{
"data": {
"rollInData": [
{
"id":"test_1",
"mtCode": "2TIF1230000999",
"round": "2T1230000999",
"amount": 3993,
"bet": 100,
"win": 200,
"validAmount": 0,
"backAmount": 0,
"tax": 10,
"gameType": 1,
"jackpot": 0,
"dateTime": 12345678,
"gameCode": "G2",
"level": 1,
}
]
},
"status": {
"code": 0,
"message": "Success",
"datetime": "2017-03-31T01:39:27-04:00"
}
}
```
### 清除卡單資料
功能 : 清除卡單資料
URI : `/rollinfailed/clean`
Method : `POST`
Request :
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| users | []Users | |
Users
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| id | int | 玩家id |
| account | string | 玩家帳號 |
| round | string | 局號 |
Response:
Example:
```json
{
"data": { },
"status": {
"code": 0,
"message": "Success",
"datetime": "2017-03-31T01:39:27-04:00"
}
}
```
### 棋牌注單明細
功能 : 棋牌注單明細
URI : `/table/order`
Method : `GET`
Request :
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| roundID | string | roundID |
Response:
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| gameCode | string | gameCode |
| gamePlaySerial | string | 局號 |
| startTime | int64 | startTime |
| endTime | int64 | endTime |
| level | string | level |
| currency | string | currency |
| roomUsers | []RoomUser | |
| flopCards | []FlopCards | |
RoomUser
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| userID | string | |
| isBot | bool | |
| isBanker | bool | |
| betMultiple | int | |
| bet | float64 | |
| pay | float64 | |
| tax | float64 | |
| beforeBalance | float64 | |
| afterBalance | float64 | |
| deck | object | |
FlopCards
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| number | int | |
| suit | int | |
Deck
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| cards | []Card | |
| cardType | int | |
Card
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| number | int | |
| suit | int | |
Example:
```json
{
"data": {
"gameCode": 4,
"gamePlaySerial": "4T2019072300007152",
"startTime": "2019-07-23T06:14:31Z",
"endTime": "2019-07-23T06:14:39Z",
"level": 2,
"currency": "CNY",
"roomUsers": [
{
"userID": "guest-c3a63feb-0eda",
"isBot": false,
"isBanker": false,
"lastStatus": 0,
"betMultiple": 0,
"bet": 100,
"pay": -100,
"tax": 0,
"beforeBalance": 100,
"afterBalance": 0,
"deck": {
"cards": [
{
"number": 8,
"suit": 3
},
{
"number": 10,
"suit": 3
}
],
"cardType": 2
}
},
{
"userID": "1OOxW22u3Lv",
"isBot": true,
"isBanker": false,
"lastStatus": 0,
"betMultiple": 0,
"bet": 0,
"pay": 839.8,
"tax": 44.2,
"beforeBalance": 752,
"afterBalance": 1591.8,
"deck": {
"cards": [
{
"number": 2,
"suit": 1
},
{
"number": 7,
"suit": 1
}
],
"cardType": 6
}
},
{
"userID": "1OOxVvEZ9kB",
"isBot": true,
"isBanker": false,
"lastStatus": 0,
"betMultiple": 0,
"bet": 20,
"pay": -20,
"tax": 0,
"beforeBalance": 732,
"afterBalance": 712,
"deck": {
"cards": [
{
"number": 5,
"suit": 1
},
{
"number": 4,
"suit": 2
}
],
"cardType": 3
}
},
{
"userID": "1OOxW0tC01g",
"isBot": true,
"isBanker": false,
"lastStatus": 0,
"betMultiple": 0,
"bet": 758,
"pay": -758,
"tax": 0,
"beforeBalance": 738,
"afterBalance": -20,
"deck": {
"cards": [
{
"number": 2,
"suit": 3
},
{
"number": 13,
"suit": 1
}
],
"cardType": 2
}
},
{
"userID": "1OOxVxkNBEH",
"isBot": true,
"isBanker": false,
"lastStatus": 0,
"betMultiple": 0,
"bet": 22,
"pay": -22,
"tax": 0,
"beforeBalance": 764,
"afterBalance": 742,
"deck": {
"cards": [
{
"number": 6,
"suit": 2
},
{
"number": 1,
"suit": 2
}
],
"cardType": 3
}
},
{
"userID": "1OOxVwrH688",
"isBot": true,
"isBanker": false,
"lastStatus": 0,
"betMultiple": 0,
"bet": 24,
"pay": -24,
"tax": 0,
"beforeBalance": 756,
"afterBalance": 732,
"deck": {
"cards": [
{
"number": 9,
"suit": 2
},
{
"number": 5,
"suit": 2
}
],
"cardType": 2
}
}
],
"flopCards": [
{
"number": 12,
"suit": 2
},
{
"number": 11,
"suit": 4
},
{
"number": 6,
"suit": 1
},
{
"number": 4,
"suit": 1
},
{
"number": 11,
"suit": 1
}
]
},
"status": {
"code": 0,
"message": "Success",
"datatime": "2019-07-23T06:57:24Z"
}
}
```
### 棋牌注單明細(百家樂類)
功能 : 棋牌注單明細(百家樂類)
URI : `/table/order/baccarat`
Method : `GET`
Request :
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| roundID | string | roundID |
| userID | string | userID |
Response:
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| gameCode | string | gameCode |
| gamePlaySerial | string | 局號 |
| startTime | int64 | 開始時間 |
| endTime | int64 | 結束時間 |
| level | int32 | 房間等級 |
| currency | string | 幣別 |
| bet | float64 | 總投注 |
| win | float64 | 總派獎 |
| validAmount | float64 | 總有效投注 |
| pay | float64 | 總損益 |
| result | BaccarratResult | 開牌結果 |
| zoneBet | map[string]int64 | 各區投注 |
| betRecord | []BetRecord | 投注紀錄 |
| players | []BaccarratUser | 同局玩家 |
*(zoneBet key為各個投注區域代碼)*
BaccarratResult
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| dealerhand | Deck | 莊家手牌 |
| playerhand | []Deck | 閒家手牌 |
| type | int | 開牌結果類型 |
Deck
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| zone | int | 區域代碼 |
| cards | []Card | |
| cardType | int | |
BetRecord
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| amount | float64 | 投注金額 |
| zone | string | 投注區域代碼 |
| time | int64 | 投注時間 |
BaccarratUser
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| userID | int64 | 投注金額 |
| bet | float64 | 投注 |
| win | float64 | 派獎 |
| validAmount | float64 | 有效投注 |
| pay | float64 | 損益 |
Example:
```json
{
"data": {
"gameCode": "G10",
"gamePlaySerial": "10T2019112900002df8",
"startTime": 1574999779,
"endTime": 1574999805,
"level": 1,
"currency": "CNY",
"bet": 14,
"win": 28,
"validAmount": 14,
"pay": -14,
"players": [
{
"userID": "guest-8719a54b-6b07",
"bet": 14,
"validAmount": 14,
"win": 28,
"pay": 14
}
],
"result": {
"dealerhand": {
"cards": [
{
"number": 2,
"suit": 3
},
{
"number": 8,
"suit": 2
},
{
"number": 3,
"suit": 2
}
],
"cardtype": 0
},
"playerhand": {
"4": {
"cards": [
{
"number": 6,
"suit": 2
},
{
"number": 6,
"suit": 2
},
{
"number": 4,
"suit": 4
}
],
"cardtype": 0
}
},
"type": 28
},
"zoneBet": {
"4": 14
},
"betRecord": [
{
"amount": 14,
"zone": "4",
"time": 1575017428
}
]
},
"status": {
"code": 0,
"message": "Success",
"datatime": "2019-11-29T09:09:30Z"
}
}
```
### 新增代理
功能 : 新增代理
URI : `/agent`
Method : `POST`
Request :
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| account | string | |
| name | string | |
Response:
Example:
```json
{
"data": "ok",
"status": {
"code": 0,
"message": "Success",
"datatime": "2019-07-23T07:12:24Z"
}
}
```
### 新增遊戲
功能 : 新增遊戲
URI : `/game`
Method : `POST`
Request :
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| gameCode | string | |
Response:
Example:
```json
{
"data": "ok",
"status": {
"code": 0,
"message": "Success",
"datatime": "2019-07-23T07:12:24Z"
}
}
```
### 踢除線上玩家
功能 : 踢除線上玩家
URI : `/kick`
Method : `POST`
Note :`踢全部玩家uid=-1 gatewayID=all`
Request :
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| uid | int | |
| gatewayID | string | |
Response:
Example:
```json
{
"data": "ok",
"status": {
"code": 0,
"message": "Success",
"datatime": "2019-07-23T07:12:24Z"
}
}
```
### 遊戲開關設定
功能 : 遊戲開關設定. agent指定代理商開關, agent留白等於全域開關.
URI : `/game/enable`
Method : `POST`
Request :
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| gameCode | string | |
| isOpen | bool | |
| agent | string | 指定代理商(空值: 全域) |
Response:
| 參數 | 參數類型 | 參數名稱 |
| --- | --- | --- |
| gameCode | string | |
| isOpen | bool | |
Example:
```json
{
"data": {
"gameCode": "G4",
"isOpen": true
},
"status": {
"code": 0,
"message": "Success",
"datatime": "2019-07-23T07:28:33Z"
}
}
```
## Error Code
| code | message |
| --- | --- |
| 0 | success |
| 1 | Params Error |
| 2 | Round Data Not Found |
| 3 | User Not Found |
| 4 | Invalid Game Code |
| 5 | Duplicate Account |
| 6 | Update Failed |
| 100 | success |
## Game Level Map
### G2炸金花
| level | name |
| --- | --- |
| 1 | 體驗房 |
| 2 | 初級房 |
| 3 | 中級房 |
| 4 | 高級房 |
### G3搶莊牛牛
| level | name |
| --- | --- |
| 1 | 體驗房 |
| 2 | 初級房 |
| 3 | 中級房 |
| 4 | 高級房 |
| 5 | 至尊房 |
| 6 | 王者房 |
### G4德州撲克
| level | name |
| --- | --- |
| 1 | 財大氣粗 |
| 2 | 腰纏萬貫 |
| 3 | 揮金如土 |
| 4 | 富貴逼人 |
| 5 | 新手房 |
| 6 | 初級房 |
| 7 | 中級房 |
| 8 | 高級房 |
### G5二八槓
| level | name |
| --- | --- |
| 1 | 體驗房 |
| 2 | 初級房 |
| 3 | 中級房 |
| 4 | 高級房 |
| 5 | 至尊房 |
| 6 | 王者房 |
### G6通比牛牛
| level | name |
| --- | --- |
| 1 | 體驗房 |
| 2 | 初級房 |
| 3 | 中級房 |
| 4 | 高級房 |
| 5 | 至尊房 |
| 6 | 王者房 |
### G7搶莊牌九
| level | name |
| --- | --- |
| 1 | 體驗房 |
| 2 | 初級房 |
| 3 | 中級房 |
| 4 | 高級房 |
| 5 | 至尊房 |
| 6 | 王者房 |
### G8三公
| level | name |
| --- | --- |
| 1 | 體驗房 |
| 2 | 初級房 |
| 3 | 中級房 |
| 4 | 高級房 |
| 5 | 至尊房 |
| 6 | 王者房 |
### G9極速炸金花
| level | name |
| --- | --- |
| 1 | 體驗房 |
| 2 | 初級房 |
| 3 | 中級房 |
| 4 | 高級房 |
### G10百家樂
| level | name |
| --- | --- |
| 1 | 體驗房 |
| 2 | 初級房 |
| 3 | 中級房 |
| 4 | 高級房 |
## 其他列舉
### 撲克牌花色
* number 1~13 代表A~K
| suit | mean |
| --- | --- |
| 1 | 方塊 |
| 2 | 梅花 |
| 3 | 紅心 |
| 4 | 黑桃 |
### 二八槓(無花色)
| number | mean |
| --- | --- |
| 1 | 一筒 |
| 2 | 二筒 |
| 3 | 三筒 |
| 4 | 四筒 |
| 5 | 五筒 |
| 6 | 六筒 |
| 7 | 七筒 |
| 8 | 八筒 |
| 9 | 九筒 |
| 10 | 白板 |
### 牌九(無花色)
| number | mean |
| --- | --- |
| 1 | 丁三 |
| 2 | 二四 |
| 3 | 雜五(全紅) |
| 4 | 雜五(全白) |
| 5 | 雜七(全白) |
| 6 | 雜七(白三紅四) |
| 7 | 雜八(上二下六) |
| 8 | 雜八(上三下五) |
| 9 | 雜九(紅四白五) |
| 10 | 雜九(上三下六) |
| 11 | 零霖六 |
| 12 | 高腳七 |
| 13 | 紅頭十 |
| 14 | 斧頭 |
| 15 | 板凳 |
| 16 | 長三 |
| 17 | 梅牌 |
| 18 | 鵝牌 |
| 19 | 人牌 |
| 20 | 地牌 |
| 21 | 天牌 |
### 百家樂類型下注區域
| number | mean |
| --- | --- |
| 1 | 庄 |
| 2 | 庄對 |
| 4 | 閒 |
| 8 | 閒對 |
| 16 | 大牌(補牌至少一張) |
| 32 | 小牌(沒有補牌) |
| 64 | 和 |
開牌結果舉例:
| 開牌 | 計算 | 結果 |
| --- | --- | --- |
| 庄對, 和 | 2 OR 64 | 66 |
| 庄對, 閒對, 和 | 2 OR 8 OR 64 | 74 |
驗算: 假設牌型 = 74, AND 運算所有列舉, 大小牌目前沒使用可跳過
| 牌型 | 列舉 | 計算結果 | 開 |
| --- | --- | --- | --- |
| 74 | 1(庄) | 0 | X |
| 74 | 2(庄對) | >0 | O |
| 74 | 4(閒) | 0 | X |
| 74 | 8(閒對) | >0 | O |
| 74 | 16(大牌) | 0 | X |
| 74 | 32(小牌) | 0 | X |
| 74 | 64(和) | >0 | O |