From 4c82cc155933d880046b8c467acf315e6af2f6a1 Mon Sep 17 00:00:00 2001 From: RogerWork Date: Tue, 31 Dec 2024 14:52:46 +0800 Subject: [PATCH] debug --- .../util/{ => general}/insert_api_to_db.py | 0 dspt_api/util/general/suggest_params.py | 19 ++++++- dspt_api/util/mapi/play_seat_status.py | 49 +++++++++++++++++++ dspt_api/views.py | 3 ++ 4 files changed, 70 insertions(+), 1 deletion(-) rename dspt_api/util/{ => general}/insert_api_to_db.py (100%) create mode 100644 dspt_api/util/mapi/play_seat_status.py diff --git a/dspt_api/util/insert_api_to_db.py b/dspt_api/util/general/insert_api_to_db.py similarity index 100% rename from dspt_api/util/insert_api_to_db.py rename to dspt_api/util/general/insert_api_to_db.py diff --git a/dspt_api/util/general/suggest_params.py b/dspt_api/util/general/suggest_params.py index d69c5ba..955ddde 100644 --- a/dspt_api/util/general/suggest_params.py +++ b/dspt_api/util/general/suggest_params.py @@ -25,6 +25,7 @@ from dspt_api.util.api.order_ticket_flag import ApiOrderTicketFlag from dspt_api.util.api.order_status import ApiOrderStatus from dspt_api.util.api.order_info import ApiOrderInfo from dspt_api.util.api.goods_deduct import ApiGoodsDeduct +from dspt_api.util.mapi.play_seat_status import MapiPlaySeatStatus # 通过api来匹配不同的接口文件获取推荐 @@ -150,6 +151,13 @@ def suggest_params(member_type, api, env, cid, pid, ip, **kwargs): print("kwargs['sale_type']", kwargs['sale_type']) data['sale_type'] = kwargs['sale_type'] params = ApiSeatCheckCoupon(**data).get_suggestion() + + # 会员 + # 3.2.6 获取场次座位状态 + if api == 'play/seat-status' and member_type == 'member': + print('play/seat-status') + params = MapiPlaySeatStatus(**data).get_suggestion() + return params def suggest_params_timestamp(member_type, api, env, cid, pid, ip, **kwargs): @@ -268,4 +276,13 @@ def suggest_params_timestamp(member_type, api, env, cid, pid, ip, **kwargs): print("kwargs['sale_type']", kwargs['sale_type']) data['sale_type'] = kwargs['sale_type'] _timestamps = ApiSeatCheckCoupon(**data).get_timestamp() - return _timestamps \ No newline at end of file + + # 会员 + # 3.2.6 获取场次座位状态 + if api == 'play/seat-status' and member_type == 'member': + print('play/seat-status') + _timestamps = MapiPlaySeatStatus(**data).get_timestamp() + + return _timestamps + + diff --git a/dspt_api/util/mapi/play_seat_status.py b/dspt_api/util/mapi/play_seat_status.py new file mode 100644 index 0000000..756ac67 --- /dev/null +++ b/dspt_api/util/mapi/play_seat_status.py @@ -0,0 +1,49 @@ +from dspt_api.util.general.handle_redis import get_data_from_redis +import time + + +class MapiPlaySeatStatus: + def __init__(self, **kwargs): + self.member_type = kwargs.get('member_type') + self.api = kwargs.get('api') + self.ip = kwargs.get('ip') + self.env = kwargs.get('env') + self.cid = kwargs.get('cid') + self.pid = kwargs.get('pid') + self.user_data = { + 'ip': self.ip, + 'env': self.env, + 'member_type': self.member_type, + 'pid': self.pid, + 'cid': self.cid, + } + self.return_data = [] + + def get_suggestion(self): + # play_id play_update_time + print('get_suggestion', self.user_data) + self.handle() + return self.return_data + + def get_timestamp(self): + # play_id play_update_time + redis_key_prefix = f'dspt_api_{self.ip}_{self.env}_{self.member_type}_{self.pid}_{self.cid}' + request_api_play_seat_status = {'name': '3.2.3 获取放映计划列表', 'path': 'cinema/plays'} + redis_key_api_play_seat_status = f'{redis_key_prefix}_{request_api_play_seat_status["path"]}' + result, _format, play_data, _timestamp = get_data_from_redis(redis_key_api_play_seat_status) + return _timestamp if result else 0 + + def handle(self): + redis_key_prefix = f'dspt_api_{self.ip}_{self.env}_{self.member_type}_{self.pid}_{self.cid}' + request_api_play_seat_status = {'name': '3.2.3 获取放映计划列表', 'path': 'cinema/plays'} + redis_key_api_play_seat_status = f'{redis_key_prefix}_{request_api_play_seat_status["path"]}' + result, _format, play_data, _timestamp = get_data_from_redis(redis_key_api_play_seat_status) + if not result: + self.add_param('play_id', '请手动输入参数,或先请求接口:3.2.3 获取放映计划列表') + self.add_param('play_update_time', '请手动输入参数,或先请求接口:3.2.3 获取放映计划列表') + self.add_param('play_id', play_data['id']) + self.add_param('play_update_time', play_data['cineUpdateTime']) + + def add_param(self, field, value, is_checked=True, result=True, timestamp=int(time.time() * 1000)): + self.return_data.append( + {'param': field, 'value': value, 'is_checked': is_checked, 'result': result, 'timestamp': timestamp}) diff --git a/dspt_api/views.py b/dspt_api/views.py index 374d978..604da10 100644 --- a/dspt_api/views.py +++ b/dspt_api/views.py @@ -308,6 +308,9 @@ def set_user_select_data(request): member_type = req.get('member_type') resp_format = 'xml' if req.get('format') == 'html' else req.get('format') user_data = req.get('user_data') + print('request.META', request.META) + print('request.body', request.body) + print('request', request) user_ip = request.META.get('REMOTE_ADDR') env = req.get('env') pid = req.get('pid')