临时代码

main
RogerWork 11 months ago
parent c380bf10b4
commit 13601fddbf
  1. 43
      mock/cinema_sql.py
  2. 52
      mock/mock_templates/get_overtime_ticket_status_tmp.py
  3. 4
      mock/urls.py
  4. 7
      mock/utils/mock_service.py
  5. 17
      mock/views.py
  6. 1
      update/utils/get_version.py

@ -1,20 +1,31 @@
FROM_SELL_ADD_GET_SHOW_SQL = '''SELECT csa.cinema_sell_add_showid AS show_id, FROM_SELL_ADD_GET_SHOW_SQL = '''SELECT cms.cinema_movie_show_id AS show_id,
cms.cinema_movie_name AS name, cms.cinema_movie_name AS name,
cms.cinema_movie_show_start_time AS start_time, cms.cinema_movie_show_start_time AS start_time,
chi.cinema_hall_name AS hall_name chi.cinema_hall_name AS hall_name
FROM cinema_sell_add csa FROM cinema_movie_show cms
LEFT JOIN cinema_hall_info chi ON csa.cinema_sell_add_hall = chi.cinema_hall_id LEFT JOIN cinema_hall_info chi ON cms.cinema_hall_id = chi.cinema_hall_id
LEFT JOIN cinema_movie_show cms ON csa.cinema_sell_add_showid = cms.cinema_movie_show_id WHERE cms.cinema_movie_show_id IN
GROUP BY csa.cinema_sell_add_showid ORDER BY cms.cinema_movie_show_start_time DESC;''' (SELECT csa.cinema_sell_add_showid
FROM cinema_sell_add csa
WHERE csa.type = 2
AND zz_audit_status IN (3, 5)
GROUP BY cinema_sell_add_showid)
ORDER BY cms.cinema_movie_show_id;
'''
FROM_REFUND_GET_SHOW_SQL = '''SELECT csl.cinema_movie_show_id AS show_id, FROM_REFUND_GET_SHOW_SQL = '''SELECT cms.cinema_movie_show_id AS show_id,
csl.cinema_movie_name AS name, cms.cinema_movie_name AS name,
csl.cinema_movie_show_start_time AS start_time, cms.cinema_movie_show_start_time AS start_time,
chi.cinema_hall_name AS hall_name chi.cinema_hall_name AS hall_name
FROM cinema_sell_log csl FROM cinema_movie_show cms
LEFT JOIN cinema_hall_info chi ON csl.cinema_hall_id = chi.cinema_hall_id LEFT JOIN cinema_hall_info chi ON cms.cinema_hall_id = chi.cinema_hall_id
WHERE csl.cinema_sell_id IN (SELECT cinema_sell_id FROM cinema_refund_order_detail) WHERE cms.cinema_movie_show_id IN (SELECT cro.show_id
GROUP BY cinema_movie_id ORDER BY csl.cinema_movie_show_start_time DESC;''' FROM cine.cinema_refund_order cro
WHERE cro.refund_order_id in (SELECT crod.refund_order_id
FROM cinema_refund_order_detail crod
WHERE crod.refund_status IN (0, 1, 2))
GROUP BY cro.show_id)
ORDER BY cms.cinema_movie_show_id DESC;'''
UPDATE_ZZ_PLATFORM_HOST_SQL = '''UPDATE cine.cinema_common_info UPDATE_ZZ_PLATFORM_HOST_SQL = '''UPDATE cine.cinema_common_info
SET cinema_common_info_val = %s WHERE cinema_common_info_key = 'zz_platform_host';''' SET cinema_common_info_val = %s WHERE cinema_common_info_key = 'zz_platform_host';'''

@ -12,6 +12,34 @@ def handle_session_code(session_code):
def get(cinema_data, request): def get(cinema_data, request):
# 获取审核状态
audit_config = ZZMockModel.objects.filter(ip=cinema_data.ip).first()
target_show_id = audit_config.auditShowId
target_status = audit_config.auditStatus
# 获取请求数据
session_code = request.GET.get('sessionCode')
overtime_type = request.GET.get('overtimeType')
req_show_id = handle_session_code(session_code)
print(target_show_id, target_status, session_code, overtime_type)
return handler(cinema_data, target_show_id, target_status, req_show_id, overtime_type)
def get_json(cinema_data, request):
# type_dict = {
# '1':
# '2':
# }
# 获取请求参数
target_show_id = req_show_id = request.GET.get('show')
overtime_type = request.GET.get('type')
target_status = request.GET.get('status')
print(target_show_id, target_status, req_show_id, overtime_type)
return handler(cinema_data, target_show_id, target_status, req_show_id, overtime_type)
def handler(cinema_data, target_show_id, target_status, req_show_id, overtime_type):
# 审核状态映射 # 审核状态映射
# 退票状态 1-未提交 2-审核中 3-审核通过 4-审核失败 # 退票状态 1-未提交 2-审核中 3-审核通过 4-审核失败
# 售票状态 1-已审核 2-已驳回 3-审核中 4-已补登 5-未提交 6-提交失败 # 售票状态 1-已审核 2-已驳回 3-审核中 4-已补登 5-未提交 6-提交失败
@ -35,31 +63,15 @@ def get(cinema_data, request):
'connect_timeout': 5, 'connect_timeout': 5,
} }
# 获取审核状态
audit_config = ZZMockModel.objects.filter(ip=cinema_data.ip).first()
target_show_id = audit_config.auditShowId
target_status = audit_config.auditStatus
# 获取请求数据
session_code = request.GET.get('sessionCode')
overtime_type = request.GET.get('overtimeType')
print(target_show_id, target_status, session_code, overtime_type)
# session_code转show_id
if len(session_code) == 16:
request_show_id = handle_session_code(session_code)
else:
request_show_id = session_code
# 如果不是要测试的场次直接返回None, 从而执行bypass # 如果不是要测试的场次直接返回None, 从而执行bypass
if request_show_id != target_show_id: if req_show_id != target_show_id:
print('不相同')
return None return None
db_conn = pymysql.Connect(**db_config) db_conn = pymysql.Connect(**db_config)
db_cursor = db_conn.cursor(cursor=DictCursor) db_cursor = db_conn.cursor(cursor=DictCursor)
ticket_list = [] ticket_list = []
# 处理过场 # 处理过场售票
if overtime_type == '0': if overtime_type == '0':
# zz_audit_status 专资审核状态 1-已审核 2-已驳回 3-审核中 4-已补登 5-未提交 6-提交失败 # zz_audit_status 专资审核状态 1-已审核 2-已驳回 3-审核中 4-已补登 5-未提交 6-提交失败
@ -104,7 +116,7 @@ def get(cinema_data, request):
'operation': 2, 'operation': 2,
'status': refund_status_dict[refund_status] 'status': refund_status_dict[refund_status]
}) })
print(ticket_list) print('ticket_list', ticket_list)
mock_data = {'message': '操作成功', mock_data = {'message': '操作成功',
'data': {'ticketList': ticket_list}, 'data': {'ticketList': ticket_list},
'code': '200', 'code': '200',

@ -30,5 +30,7 @@ urlpatterns = [
path('data/getOvertimeTicketStatus', get_overtime_ticket_status), path('data/getOvertimeTicketStatus', get_overtime_ticket_status),
path('api/get_overtime_show', get_overtime_show), path('api/get_overtime_show', get_overtime_show),
path('api/get_response_json', get_response), path('api/get_response_json', get_response),
path('api/set_overtime_config', set_overtime_config) path('api/set_overtime_config', set_overtime_config),
path('api/start_mock', enable_mock),
path('api/end_mock', disable_mock)
] ]

@ -28,8 +28,13 @@ def mock(_ip, _api, **kwargs):
mock_data = download_film_info_tmp.get() mock_data = download_film_info_tmp.get()
return JsonResponse(mock_data, json_dumps_params={'ensure_ascii': False}) return JsonResponse(mock_data, json_dumps_params={'ensure_ascii': False})
if _api == 'getOvertimeTicketStatus': if _api == 'getOvertimeTicketStatus':
mock_data = get_overtime_ticket_status_tmp.get(cinema_obj, kwargs.get('request')) if kwargs.get('type') == 'getJson':
mock_data = get_overtime_ticket_status_tmp.get_json(cinema_obj, kwargs.get('request'))
else:
mock_data = get_overtime_ticket_status_tmp.get(cinema_obj, kwargs.get('request'))
print('mock_data', mock_data)
if mock_data is not None: if mock_data is not None:
print("this is none")
return JsonResponse(mock_data, json_dumps_params={'ensure_ascii': False}) return JsonResponse(mock_data, json_dumps_params={'ensure_ascii': False})
else: else:
bypass(kwargs.get('request')) bypass(kwargs.get('request'))

@ -1,4 +1,5 @@
import datetime import datetime
import json
import requests import requests
from django.shortcuts import render from django.shortcuts import render
@ -33,6 +34,7 @@ api_dict = {
# 1、票房数据上报接口 POST /report/reportTicket # 1、票房数据上报接口 POST /report/reportTicket
@csrf_exempt @csrf_exempt
def report_ticket(request): def report_ticket(request):
print(request.GET)
ip = request.META.get('REMOTE_ADDR') ip = request.META.get('REMOTE_ADDR')
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() mock_service_switch = ZZMockModel.objects.filter(ip=ip).first()
if mock_service_switch.reportTicket is True: if mock_service_switch.reportTicket is True:
@ -104,6 +106,8 @@ def get_overtime_ticket_status(request):
ip = request.META.get('REMOTE_ADDR') ip = request.META.get('REMOTE_ADDR')
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() mock_service_switch = ZZMockModel.objects.filter(ip=ip).first()
if mock_service_switch.getOvertimeTicketStatus is True: if mock_service_switch.getOvertimeTicketStatus is True:
r = mock_service.mock(ip, 'getOvertimeTicketStatus', request=request)
print('r', r)
return mock_service.mock(ip, 'getOvertimeTicketStatus', request=request) return mock_service.mock(ip, 'getOvertimeTicketStatus', request=request)
else: else:
return mock_service.bypass(request) return mock_service.bypass(request)
@ -183,7 +187,7 @@ def get_response(request):
_api = request.GET.dict().get('api') _api = request.GET.dict().get('api')
_api = api_dict[_api] _api = api_dict[_api]
if _api == 'getOvertimeTicketStatus': if _api == 'getOvertimeTicketStatus':
req = mock_service.mock(_ip, _api, request=request) req = mock_service.mock(_ip, _api, request=request, type='getJson')
else: else:
req = mock_service.mock(_ip, _api) req = mock_service.mock(_ip, _api)
return req return req
@ -221,9 +225,14 @@ def set_overtime_config(request):
# 启动mock # 启动mock
@csrf_exempt
def enable_mock(request): def enable_mock(request):
ip = request.GET.dict().get('ip') ip = request.GET.get('ip')
mock_config = request.POST.dict().get('mock_config') req_mock_config = json.loads(request.body)['mock_config']
mock_config = dict()
for k, v in req_mock_config.items():
mock_config[api_dict[k]] = v
print(mock_config)
server_ip = get_local_ip() server_ip = get_local_ip()
current_host = db(ip, GET_ZZ_PLATFORM_HOST_SQL)['data'][0]['cinema_common_info_val'] current_host = db(ip, GET_ZZ_PLATFORM_HOST_SQL)['data'][0]['cinema_common_info_val']
if current_host == 'https://zzcs.yinghezhong.com' or current_host == 'https://dy.yinghezhong.com': if current_host == 'https://zzcs.yinghezhong.com' or current_host == 'https://dy.yinghezhong.com':
@ -239,7 +248,7 @@ def enable_mock(request):
# 停用mock服务 # 停用mock服务
def disable_mock(request): def disable_mock(request):
ip = request.query_params.dict().get('ip') ip = request.GET.get('ip')
server_ip = get_local_ip() server_ip = get_local_ip()
current_host = db(ip, GET_ZZ_PLATFORM_HOST_SQL)['data'][0]['cinema_common_info_val'] current_host = db(ip, GET_ZZ_PLATFORM_HOST_SQL)['data'][0]['cinema_common_info_val']
if current_host == 'https://zzcs.yinghezhong.com' or current_host == 'https://dy.yinghezhong.com': if current_host == 'https://zzcs.yinghezhong.com' or current_host == 'https://dy.yinghezhong.com':

@ -47,7 +47,6 @@ class GetVersion(object):
@staticmethod @staticmethod
def get_cinema_ver(q): def get_cinema_ver(q):
print('get_cinema_ver')
if q.empty(): if q.empty():
return return
else: else:

Loading…
Cancel
Save