---
# System prepended metadata

title: '#新台北通'

---

#新台北通

``測試機在192.168.51.175``

- ==與舊版的差別就是要先用下面的api查點數跟資格然後還要選擇哪種扣幾點==
==之後在POST /sales的時候多帶一個欄位`upointAmount`代表Upoint要扣幾點原本的`tppassAmount`就代表1500point要扣幾點，以及`qrocde`代表掃到的qrcode內容，可以參考下面的範例==
- 發票列表api多了兩個欄位==isUsport==, ==usport_print==代表是不是台北通發票以及是否印過
- 列印台北通的發票用的api跟重印發票是同一個

- 透過QRCode查使用者資料

PUT http://[北運server ip]:[北運server port]/tppass/query

Body:
```jsonld=
{
    "code": [qrcode]
}
```

前端會使用到的就是:
- detail => level_summary => current_level => level_code
    - level_code = US001 是「未驗證會員」，無法扣除點數、可以累積U幣
    - level_code = US002 是「臺北市民」，則可以扣除點數、可以累積U幣
    - level_code = US003 是「一般會員」，則無法扣除點數、無法累積U幣
- detail => point_summary => current_point
    - point_code = "1500point" 是發的
    - point_code = "Upoint" 是集點的

Response:
```jsonld=
{
    "detail": {
        "coupon_summary": {
            "valid_coupon_amount": 0
        },
        "level_summary": {
            "current_level": {
                "level_code": "US001",
                "level_end_datetime": "2124/02/11 23:59:59",
                "level_id": 1,
                "title": "未驗證會員"
            },
            "next_level": {
                "level_code": "US002",
                "level_id": 2,
                "progress": [],
                "title": "臺北市民"
            },
            "renew_level": {
                "level_code": "US001",
                "level_id": 1,
                "progress": [
                    {
                        "amount": "0",
                        "requirement": "0",
                        "type": "frequency"
                    }
                ],
                "title": "未驗證會員"
            },
            "updated_at": "2024-03-06 15:59:08"
        },
        "point_summary": {
            "current_point": [
                {
                    "amount": "0",
                    "point_code": "1500point",
                    "point_due_to_expire": [],
                    "point_id": 1
                },
                {
                    "amount": "0",
                    "point_code": "Upoint",
                    "point_due_to_expire": [],
                    "point_id": 2
                }
            ]
        },
        "voucher_summary": [
            {
                "valid_voucher_amount": 0,
                "voucher_box": ""
            }
        ]
    },
    "member": {
        "external_member_id": "ym5Dn8xyoMKclhQ41U97fg==",
        "level_code": "US001",
        "member_access_token": "943f4a1f-82b6-41b6-bced-fc7217e84809",
        "mobile": "0912345678",
        "name": "tester"
    },
    "uuid": "USLDFKAWUNAQ"
}
```

- 結帳

POST http://[北運server ip]:[北運server port]/sales

Body:
```jsonld=
{
    "items": [
        {
            // 跟上一版台北通不同的是回歸沒有用台北通之前的樣子
            "type": 0,
            "item": 46,
            "count": 1,
            "price": 80
        }
    ],
    "paymentType": 0,
    "amount": 80, // 總金額
    "print_detail": true, // 有用到台北通點數就一定要true
    "tppassAmount": 40, // 要折多少點抵用金
    "upointAmount": 40, // 要折多少點U幣
    "qrcode": [掃到的qrcode內容]
}
```

- 透過條件查交易紀錄

GET http://[北運server ip]:[北運server port]/tppass/logs

Query:
- start: 開始日期(格式:yyyy-mm-dd)
- end: 結束日期(格式:yyyy-mm-dd)
- key: ["uuid", "user_id", "user_phone", "user_name"] (分別是卡號,身分證字號,電話,帳號名稱)
- value: 就是上面key的值

Response:
```jsonld=
{
   "count":3,
   "rows":[
      {
         "id":87,
         "uuid":"USWMEQXOEAZY",
         "user_id":"A128024438",
         "user_phone":"0972957297",
         "user_name":"mrayrichard",
         "action":"pay",
         "items":"\"[{\\\"type\\\":0,\\\"item\\\":46,\\\"count\\\":1,\\\"price\\\":80}]\"",
         "terminal":"BTPOS01",
         "user":"Richard",
         "amount":40,
         "upoint":40,
         "orderNo":"bei_yC9ADA5zbt1M3I7i,bei_Ug6h7pryAHesqmi3",
         "memo":"\"[{\\\"type\\\":0,\\\"item\\\":46,\\\"count\\\":1,\\\"price\\\":80}]\"",
         "response":"{\"point_results\":{\"point_transaction_information\":{\"mmrm_tid\":520,\"transaction_id\":\"bei_yC9ADA5zbt1M3I7i\"}},\"point_sn\":\"bei_yC9ADA5zbt1M3I7i\",\"upoint_results\":{\"point_transaction_information\":{\"mmrm_tid\":521,\"transaction_id\":\"bei_Ug6h7pryAHesqmi3\"}},\"upoint_sn\":\"bei_Ug6h7pryAHesqmi3\",\"uuid\":\"USWMEQXOEAZY\"}",
         "inv":"NM12340069",
         "createdAt":"2024-04-06T09:41:25.000Z",
         "updatedAt":"2024-04-06T09:41:25.000Z"
      },
      {
         "id":88,
         "uuid":"USWMEQXOEAZY",
         "user_id":"A128024438",
         "user_phone":"0972957297",
         "user_name":"mrayrichard",
         "action":"pay",
         "items":"\"[{\\\"type\\\":0,\\\"item\\\":46,\\\"count\\\":1,\\\"price\\\":80}]\"",
         "terminal":"BTPOS01",
         "user":"Richard",
         "amount":40,
         "upoint":40,
         "orderNo":"bei_3Duu8SrtPYvcm7tg,bei_b9gqCUa5aMwFdgDl",
         "memo":"\"[{\\\"type\\\":0,\\\"item\\\":46,\\\"count\\\":1,\\\"price\\\":80}]\"",
         "response":"{\"point_results\":{\"point_transaction_information\":{\"mmrm_tid\":522,\"transaction_id\":\"bei_3Duu8SrtPYvcm7tg\"}},\"point_sn\":\"bei_3Duu8SrtPYvcm7tg\",\"upoint_results\":{\"point_transaction_information\":{\"mmrm_tid\":523,\"transaction_id\":\"bei_b9gqCUa5aMwFdgDl\"}},\"upoint_sn\":\"bei_b9gqCUa5aMwFdgDl\",\"uuid\":\"USWMEQXOEAZY\"}",
         "inv":"NM12340070",
         "createdAt":"2024-04-06T10:01:30.000Z",
         "updatedAt":"2024-04-06T10:01:30.000Z"
      },
      {
         "id":89,
         "uuid":"USWMEQXOEAZY",
         "user_id":"A128024438",
         "user_phone":"0972957297",
         "user_name":"mrayrichard",
         "action":"pay",
         "items":"\"[{\\\"type\\\":0,\\\"item\\\":46,\\\"count\\\":1,\\\"price\\\":80}]\"",
         "terminal":"BTPOS01",
         "user":"Richard",
         "amount":40,
         "upoint":40,
         "orderNo":"bei_SI6QKhuHH3oYSzXP,bei_AiEvghfLEhf3o9hC",
         "memo":"\"[{\\\"type\\\":0,\\\"item\\\":46,\\\"count\\\":1,\\\"price\\\":80}]\"",
         "response":"{\"point_results\":{\"point_transaction_information\":{\"mmrm_tid\":524,\"transaction_id\":\"bei_SI6QKhuHH3oYSzXP\"}},\"point_sn\":\"bei_SI6QKhuHH3oYSzXP\",\"upoint_results\":{\"point_transaction_information\":{\"mmrm_tid\":525,\"transaction_id\":\"bei_AiEvghfLEhf3o9hC\"}},\"upoint_sn\":\"bei_AiEvghfLEhf3o9hC\",\"uuid\":\"USWMEQXOEAZY\"}",
         "inv":"NM12340071",
         "createdAt":"2024-04-06T10:05:06.000Z",
         "updatedAt":"2024-04-06T10:05:06.000Z"
      }
   ]
}
```

- 透過QRCode扣點(不開發票)

PUT http://[北運server ip]:[北運server port]/tppass/pay

Body:
```jsonld=
{
    "code": [qrcode],
    "amount": [台北通發的1500點要扣多少(int)],
    "upoint": [台北通發Upoint要扣多少(int)],
    "memo": [備註]
}
```

Response:
```jsonld=
{
    "detail": {
        "coupon_summary": {
            "valid_coupon_amount": 0
        },
        "level_summary": {
            "current_level": {
                "level_code": "US001",
                "level_end_datetime": "2124/02/11 23:59:59",
                "level_id": 1,
                "title": "未驗證會員"
            },
            "next_level": {
                "level_code": "US002",
                "level_id": 2,
                "progress": [],
                "title": "臺北市民"
            },
            "renew_level": {
                "level_code": "US001",
                "level_id": 1,
                "progress": [
                    {
                        "amount": "0",
                        "requirement": "0",
                        "type": "frequency"
                    }
                ],
                "title": "未驗證會員"
            },
            "updated_at": "2024-03-06 15:59:08"
        },
        "point_summary": {
            "current_point": [
                {
                    "amount": "0",
                    "point_code": "1500point",
                    "point_due_to_expire": [],
                    "point_id": 1
                },
                {
                    "amount": "0",
                    "point_code": "Upoint",
                    "point_due_to_expire": [],
                    "point_id": 2
                }
            ]
        },
        "voucher_summary": [
            {
                "valid_voucher_amount": 0,
                "voucher_box": ""
            }
        ]
    },
    "member": {
        "external_member_id": "ym5Dn8xyoMKclhQ41U97fg==",
        "level_code": "US001",
        "member_access_token": "943f4a1f-82b6-41b6-bced-fc7217e84809",
        "mobile": "0912345678",
        "name": "tester"
    },
    "uuid": "USLDFKAWUNAQ"
}
```