You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.4 KiB
49 lines
1.4 KiB
import random |
|
from urllib.parse import urljoin |
|
from lib.http_req import req |
|
from lib.redis_util import redis_get_key |
|
from config import global_data |
|
|
|
SUB_URL = '?m=web&a=getSeatRate' |
|
|
|
|
|
class GetSeatRate: |
|
def __init__(self, data): |
|
self.api_name = 'get_seat_rate' |
|
self.url = urljoin(data['basic_data']['url_http'], SUB_URL) |
|
self.user_name = data['basic_data']['user_name'] # 固定写死的参数 |
|
self.password = data['basic_data']['password'] # 固定写死的参数 |
|
self.cinema_id = data['basic_data']['cinema_id'] |
|
self.req_method = data['http_req_method'] # http接口请求方法POST或GET |
|
self.show_code = None |
|
|
|
def prepare(self): |
|
self.show_code = redis_get_key('json_req_show_info')['performId'] |
|
|
|
def request(self): |
|
# 准备请求数据 |
|
self.prepare() |
|
|
|
params = { |
|
'user': self.user_name, # 授权用户名 |
|
'pass': self.password, # 授权密码 |
|
'cinema': self.cinema_id, # 影院三位编码 |
|
} |
|
data = { |
|
'showCode': self.show_code, # 核心系统场次编码 |
|
} |
|
|
|
resp_params, resp_data, response = req(self.api_name, self.url, self.req_method, params, data) |
|
|
|
# 处理返回的数据 |
|
self.handle() |
|
|
|
return resp_params, resp_data, response |
|
|
|
def handle(self): |
|
pass |
|
|
|
|
|
if __name__ == "__main__": |
|
api = GetSeatRate(global_data) |
|
api.request()
|
|
|