兼容前端逻辑

main
RogerWork 11 months ago
parent 087f20dc10
commit de7f4b382b
  1. 34
      mock/cinema_sql.py
  2. 6
      mock/mock_templates/get_overtime_ticket_status_tmp.py
  3. 5
      mock/urls.py
  4. 58
      mock/views.py

@ -1,37 +1,28 @@
FROM_SELL_ADD_GET_SHOW_SQL = ''' FROM_SELL_ADD_GET_SHOW_SQL = '''SELECT csa.cinema_sell_add_showid AS show_id,
SELECT csa.cinema_sell_add_showid 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_sell_add csa
LEFT JOIN cinema_hall_info chi ON csa.cinema_sell_add_hall = chi.cinema_hall_id LEFT JOIN cinema_hall_info chi ON csa.cinema_sell_add_hall = chi.cinema_hall_id
LEFT JOIN cinema_movie_show cms ON csa.cinema_sell_add_showid = cms.cinema_movie_show_id LEFT JOIN cinema_movie_show cms ON csa.cinema_sell_add_showid = cms.cinema_movie_show_id
GROUP BY csa.cinema_sell_add_showid ORDER BY cms.cinema_movie_show_start_time DESC; GROUP BY csa.cinema_sell_add_showid ORDER BY cms.cinema_movie_show_start_time DESC;'''
'''
FROM_REFUND_GET_SHOW_SQL = ''' FROM_REFUND_GET_SHOW_SQL = '''SELECT csl.cinema_movie_show_id AS show_id,
SELECT csl.cinema_movie_show_id AS show_id,
csl.cinema_movie_name AS name, csl.cinema_movie_name AS name,
csl.cinema_movie_show_start_time AS start_time, csl.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_sell_log csl
LEFT JOIN cinema_hall_info chi ON csl.cinema_hall_id = chi.cinema_hall_id LEFT JOIN cinema_hall_info chi ON csl.cinema_hall_id = chi.cinema_hall_id
WHERE csl.cinema_sell_id IN (SELECT cinema_sell_id FROM cinema_refund_order_detail) WHERE csl.cinema_sell_id IN (SELECT cinema_sell_id FROM cinema_refund_order_detail)
GROUP BY cinema_movie_id ORDER BY csl.cinema_movie_show_start_time DESC; GROUP BY cinema_movie_id ORDER BY csl.cinema_movie_show_start_time DESC;'''
'''
UPDATE_ZZ_PLATFORM_HOST_SQL = ''' UPDATE_ZZ_PLATFORM_HOST_SQL = '''UPDATE cine.cinema_common_info
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';
'''
GET_ZZ_PLATFORM_HOST_SQL = ''' GET_ZZ_PLATFORM_HOST_SQL = '''SELECT * FROM cine.cinema_common_info WHERE cinema_common_info_key = 'zz_platform_host';'''
SELECT * FROM cine.cinema_common_info WHERE cinema_common_info_key = 'zz_platform_host';
'''
GET_OVERTIME_SELL_TICKET_SQL = """ GET_OVERTIME_SELL_TICKET_SQL = """SELECT csad.id,
SELECT csad.id,
csad.ticket_no AS ticket_no, csad.ticket_no AS ticket_no,
csa.cinema_sell_add_status AS add_status, csa.cinema_sell_add_status AS add_status,
csa.zz_audit_status AS audit_status, csa.zz_audit_status AS audit_status,
@ -40,13 +31,10 @@ GET_OVERTIME_SELL_TICKET_SQL = """
LEFT JOIN cinema_sell_add csa ON csad.cinema_sell_add_id = csa.cinema_sell_add_id LEFT JOIN cinema_sell_add csa ON csad.cinema_sell_add_id = csa.cinema_sell_add_id
WHERE csad.ticket_no <> '' WHERE csad.ticket_no <> ''
AND csa.cinema_sell_add_showid = %s AND csa.cinema_sell_add_showid = %s
ORDER BY csad.id DESC; ORDER BY csad.id DESC;"""
"""
GET_OVERTIME_REFUND_TICKET_SQL = """ GET_OVERTIME_REFUND_TICKET_SQL = """SELECT crod.id, crod.cinema_sell_id, crod.refund_status, cslei.ticket_no
SELECT crod.id, crod.cinema_sell_id, crod.refund_status, cslei.ticket_no
FROM cinema_refund_order_detail crod FROM cinema_refund_order_detail crod
LEFT JOIN cinema_sell_log_ext_info cslei ON crod.cinema_sell_id = cslei.cinema_sell_id LEFT JOIN cinema_sell_log_ext_info cslei ON crod.cinema_sell_id = cslei.cinema_sell_id
WHERE refund_order_id IN (SELECT cinema_refund_order.refund_order_id FROM cinema_refund_order WHERE show_id = %s) WHERE refund_order_id IN (SELECT cinema_refund_order.refund_order_id FROM cinema_refund_order WHERE show_id = %s)
ORDER BY id DESC; ORDER BY id DESC;"""
"""

@ -41,10 +41,10 @@ def get(cinema_data, request):
target_status = audit_config.auditStatus target_status = audit_config.auditStatus
# 获取请求数据 # 获取请求数据
session_code = request.query_params.get('sessionCode') session_code = request.GET.get('sessionCode')
overtime_type = request.query_params.get('overtimeType') overtime_type = request.GET.get('overtimeType')
# session_codeshow_id # session_codeshow_id
request_show_id = handle_session_code(session_code) request_show_id = handle_session_code(session_code)
# 如果不是要测试的场次直接返回None, 从而执行bypass # 如果不是要测试的场次直接返回None, 从而执行bypass

@ -28,6 +28,7 @@ urlpatterns = [
path('data/downloadFilmInfo', download_film_info), path('data/downloadFilmInfo', download_film_info),
path('query/validError', valid_error), path('query/validError', valid_error),
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_response_json', get_response),
path('api/set_overtime_config', set_overtime_config)
] ]

@ -1,3 +1,5 @@
import datetime
import requests import requests
from django.shortcuts import render from django.shortcuts import render
from django.http.response import JsonResponse from django.http.response import JsonResponse
@ -14,6 +16,18 @@ from mock.cinema_sql import *
ZZ_URL = 'https://zzcs.yinghezhong.com' ZZ_URL = 'https://zzcs.yinghezhong.com'
# 用于将前端的接口名转换成后端的
api_dict = {
'download_film_info': 'downloadFilmInfo',
'get_cinema_info': 'getCinemaInfo',
'get_screen_info': 'getScreenInfo',
'report_ticket': 'reportTicket',
'report_film_schedule': 'reportFilmSchedule',
'upload_screen_seat_info': 'uploadScreenSeatInfo',
'get_overtime_ticket_status': 'getOvertimeTicketStatus',
'valid_error': 'validError'
}
# 数据上报 # 数据上报
# 1、票房数据上报接口 POST /report/reportTicket # 1、票房数据上报接口 POST /report/reportTicket
@ -134,15 +148,16 @@ def db(ip, sql, params=None):
# 获取过场信息 # 获取过场信息
def get_overtime_show(request): def get_overtime_show(request):
ip = request.query_params.dict().get('ip') ip = request.GET.dict().get('ip')
# 获取过场售票 # 获取过场售票
db_result = db(ip, FROM_SELL_ADD_GET_SHOW_SQL) db_result = db(ip, FROM_SELL_ADD_GET_SHOW_SQL)
sell_show_data = db_result['data'] sell_show_data = db_result['data']
sell_show_list = [] sell_show_list = []
for show in sell_show_data: for show in sell_show_data:
show_time = datetime.datetime.strftime(show['start_time'], '%Y-%m-%d %H:%M:%S')
hall = show['hall_name'] if show['hall_name'] is not None else '影厅信息缺失'
sell_show_list.append({'id': show['show_id'], sell_show_list.append({'id': show['show_id'],
'show': show['name'] + ' ' + show['start_time'] + ' ' + show[ 'show': show['name'] + ' ' + show_time + ' ' + hall
'hall_name'] if show['hall_name'] is not None else ''
}) })
# 获取过场退票场次 # 获取过场退票场次
@ -150,17 +165,28 @@ def get_overtime_show(request):
refund_show_data = db_result['data'] refund_show_data = db_result['data']
refund_show_list = [] refund_show_list = []
for show in refund_show_data: for show in refund_show_data:
show_time = datetime.datetime.strftime(show['start_time'], '%Y-%m-%d %H:%M:%S')
hall = show['hall_name'] if show['hall_name'] is not None else '影厅信息缺失'
refund_show_list.append({'id': show['show_id'], refund_show_list.append({'id': show['show_id'],
'show': show['name'] + ' ' + show['start_time'] + ' ' + show[ 'show': show['name'] + ' ' + show_time + ' ' + hall
'hall_name'] if show['hall_name'] is not None else ''
}) })
return JsonResponse({'sell': sell_show_list, 'refund': refund_show_list}, json_dumps_params={'ensure_ascii': False}) # 专资接口 # operation 1售票 2退票 # status 0不通过 1通过 2待审核 99待提交
audit_status = [{'key': '0', 'status': '不通过'}, {'key': '1', 'status': '通过'}, {'key': '2', 'status': '待审核'},
{'key': '99', 'status': '待提交'}]
return JsonResponse({'sell': sell_show_list, 'refund': refund_show_list, 'status': audit_status},
json_dumps_params={'ensure_ascii': False})
# 获取mock数据的json # 获取mock数据的json
def get_response(request, _api): def get_response(request):
_ip = request.query_params.dict().get('ip') _ip = request.GET.dict().get('ip')
return mock_service.mock(_ip, _api) _api = request.GET.dict().get('api')
_api = api_dict[_api]
if _api == 'getOvertimeTicketStatus':
req = mock_service.mock(_ip, _api, request=request)
else:
req = mock_service.mock(_ip, _api)
return req
# 获取本机 IP 地址: # 获取本机 IP 地址:
@ -184,10 +210,20 @@ def get_local_ip():
# 'auditStatus': '' # 'auditStatus': ''
# } # }
# 设置超时售退票设置
def set_overtime_config(request):
ip = request.GET.dict().get('ip')
cinema = ZZMockModel.objects.filter(ip=ip).first()
cinema.auditShowId = request.GET.dict().get('show_id')
cinema.auditStatus = request.GET.dict().get('audit_status')
cinema.save()
return JsonResponse({'success': True})
# 启动mock # 启动mock
def enable_mock(request): def enable_mock(request):
ip = request.query_params.dict().get('ip') ip = request.GET.dict().get('ip')
mock_config = request.query_params.dict().get('mock_config') mock_config = request.POST.dict().get('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':

Loading…
Cancel
Save