@ -9,11 +9,11 @@
先从seat_lock接口获取座位价格
先从seat_lock接口获取座位价格
如果seat_lock没有获取到座位价格就到
如果seat_lock没有获取到座位价格就到
返回 结果 , seat , ticket_cash , play_id , play_update_time , lock_flag , timestamp
返回 结果 , seat , ticket_cash , play_id , play_update_time , lock_flag , quan , timestamp
"""
"""
import random
import random
from decimal import Decimal , ROUND_HALF_UP
from dspt_api . util . general . handle_float import f2
from dspt_api . util . general . handle_redis import get_data_from_redis
from dspt_api . util . general . handle_redis import get_data_from_redis , get_param_from_redis
def general_seat_params ( pay_type , data ) :
def general_seat_params ( pay_type , data ) :
@ -23,6 +23,8 @@ def general_seat_params(pay_type, data):
request_api_lock = { ' name ' : ' 3.3.1 座位锁定 ' , ' path ' : ' seat/lock ' }
request_api_lock = { ' name ' : ' 3.3.1 座位锁定 ' , ' path ' : ' seat/lock ' }
redis_key_api_lock = f ' { redis_key_prefix } _ { request_api_lock [ " path " ] } '
redis_key_api_lock = f ' { redis_key_prefix } _ { request_api_lock [ " path " ] } '
result_lock , _format_lock , seat_price_from_lock , _timestamp_lock = get_data_from_redis ( redis_key_api_lock )
result_lock , _format_lock , seat_price_from_lock , _timestamp_lock = get_data_from_redis ( redis_key_api_lock )
if not result_lock :
return False , None , None , None , None , None , None , None
area_info = seat_price_from_lock [ ' areaInfo ' ] if len ( seat_price_from_lock [ ' areaInfo ' ] ) > 0 else False
area_info = seat_price_from_lock [ ' areaInfo ' ] if len ( seat_price_from_lock [ ' areaInfo ' ] ) > 0 else False
lock_flag = seat_price_from_lock [ ' lockFlag ' ]
lock_flag = seat_price_from_lock [ ' lockFlag ' ]
# partner_price = seat_price_from_lock['partnerPrice'] if seat_price_from_lock['partnerPrice'] is not None else False
# partner_price = seat_price_from_lock['partnerPrice'] if seat_price_from_lock['partnerPrice'] is not None else False
@ -31,6 +33,8 @@ def general_seat_params(pay_type, data):
request_api_play = { ' name ' : ' 3.1.5 获取放映计划列表 ' , ' path ' : ' cinema/plays ' }
request_api_play = { ' name ' : ' 3.1.5 获取放映计划列表 ' , ' path ' : ' cinema/plays ' }
redis_key_api_play = f ' { redis_key_prefix } _ { request_api_play [ " path " ] } '
redis_key_api_play = f ' { redis_key_prefix } _ { request_api_play [ " path " ] } '
result_play , _format_play , seat_price_from_play , _timestamp_play = get_data_from_redis ( redis_key_api_play )
result_play , _format_play , seat_price_from_play , _timestamp_play = get_data_from_redis ( redis_key_api_play )
if not result_play :
return False , None , None , None , None , None , None , None
market_price = seat_price_from_play [ ' marketPrice ' ]
market_price = seat_price_from_play [ ' marketPrice ' ]
play_id = seat_price_from_play [ ' id ' ]
play_id = seat_price_from_play [ ' id ' ]
play_update_time = seat_price_from_play [ ' cineUpdateTime ' ]
play_update_time = seat_price_from_play [ ' cineUpdateTime ' ]
@ -39,6 +43,8 @@ def general_seat_params(pay_type, data):
request_api_config = { ' name ' : ' 3.1.2 获取单个影院配置信息 ' , ' path ' : ' cinema/config ' }
request_api_config = { ' name ' : ' 3.1.2 获取单个影院配置信息 ' , ' path ' : ' cinema/config ' }
redis_key_api_config = f ' { redis_key_prefix } _ { request_api_config [ " path " ] } '
redis_key_api_config = f ' { redis_key_prefix } _ { request_api_config [ " path " ] } '
result_config , _format_config , seat_price_from_config , _timestamp_config = get_data_from_redis ( redis_key_api_config )
result_config , _format_config , seat_price_from_config , _timestamp_config = get_data_from_redis ( redis_key_api_config )
if not result_config :
return False , None , None , None , None , None , None , None
handle_fee = seat_price_from_config [ ' handleFee ' ]
handle_fee = seat_price_from_config [ ' handleFee ' ]
partner_type = seat_price_from_config [ ' partnerSubsidyType ' ] # 1:电商平台补贴;2:合作商补贴
partner_type = seat_price_from_config [ ' partnerSubsidyType ' ] # 1:电商平台补贴;2:合作商补贴
@ -46,7 +52,8 @@ def general_seat_params(pay_type, data):
request_api_seat = { ' name ' : ' 3.1.8 获取某场次座位状态 ' , ' path ' : ' play/seat-status ' }
request_api_seat = { ' name ' : ' 3.1.8 获取某场次座位状态 ' , ' path ' : ' play/seat-status ' }
redis_key_api_seat = f ' { redis_key_prefix } _ { request_api_seat [ " path " ] } '
redis_key_api_seat = f ' { redis_key_prefix } _ { request_api_seat [ " path " ] } '
result_seat , _format_seat , seat_price_from_seat , _timestamp_seat = get_data_from_redis ( redis_key_api_seat )
result_seat , _format_seat , seat_price_from_seat , _timestamp_seat = get_data_from_redis ( redis_key_api_seat )
print ( ' seat_price_from_seat ' , seat_price_from_seat )
if not result_seat :
return False , None , None , None , None , None , None , None
seat_id_list = [ { ' seat_id ' : seat [ ' cineSeatId ' ] , ' ticket_discount ' : seat . get ( ' ticketDiscount ' , 0 ) ,
seat_id_list = [ { ' seat_id ' : seat [ ' cineSeatId ' ] , ' ticket_discount ' : seat . get ( ' ticketDiscount ' , 0 ) ,
' service_discount ' : seat . get ( ' serviceDiscount ' , 0 ) } for seat in seat_price_from_seat ]
' service_discount ' : seat . get ( ' serviceDiscount ' , 0 ) } for seat in seat_price_from_seat ]
@ -56,7 +63,7 @@ def general_seat_params(pay_type, data):
# 判断获取到了全部接口数据,就继续,否则报错
# 判断获取到了全部接口数据,就继续,否则报错
if not ( result_lock and result_play and result_config and result_seat ) :
if not ( result_lock and result_play and result_config and result_seat ) :
return_str = ' 请手动输入参数,检查相关接口返回值:3.3.1 座位锁定、3.1.5 获取放映计划列表、3.1.8 获取某场次座位状态、3.1.2 获取单个影院配置信息 '
return_str = ' 请手动输入参数,检查相关接口返回值:3.3.1 座位锁定、3.1.5 获取放映计划列表、3.1.8 获取某场次座位状态、3.1.2 获取单个影院配置信息 '
return False , return_str , 0 , return_str , return_str , return_str , last_timestamp
return False , return_str , 0 , return_str , return_str , return_str , return_str , last_timestamp
if pay_type == ' cash ' :
if pay_type == ' cash ' :
"""
"""
@ -80,6 +87,7 @@ def general_seat_params(pay_type, data):
测试影院3 .166 合作商补贴 合作商补贴 是否允许传递优惠金额 否 影票价格控制 否 卖品价格控制 否
测试影院3 .166 合作商补贴 合作商补贴 是否允许传递优惠金额 否 影票价格控制 否 卖品价格控制 否
"""
"""
quan = ' '
seat_list = [ ]
seat_list = [ ]
ticket_cash = 0 # 统计cash字段用
ticket_cash = 0 # 统计cash字段用
for seat_info in seat_id_list :
for seat_info in seat_id_list :
@ -89,24 +97,24 @@ def general_seat_params(pay_type, data):
if area_info is not False :
if area_info is not False :
# 查找座位对应的区域价格
# 查找座位对应的区域价格
for area_seat_info in area_info :
for area_seat_info in area_info :
if area_seat_info [ ' seatId ' ] == int ( seat_info [ ' seat_id ' ] ) :
if int ( area_seat_info [ ' seatId ' ] ) == int ( seat_info [ ' seat_id ' ] ) :
# 获取price字段值
# 获取price字段值
price = Decimal ( area_seat_info [ " areaPrice " ] ) . quantize ( Decimal ( ' 0.00 ' ) , ROUND_HALF_UP )
price = f2 ( area_seat_info [ " areaPrice " ] )
seat . append ( price )
seat . append ( str ( price ) )
seat . append ( ' 0 ' )
seat . append ( ' 0 ' )
seat . append ( area_seat_info [ " areaServiceFee " ] )
seat . append ( area_seat_info [ " areaServiceFee " ] )
# if partner_type == '2': # 合作商定价
# if partner_type == '2': # 合作商定价
# price -= Decimal(area_seat_info["areaServiceFee"]).quantize(Decimal('0.00'), ROUND_HALF_UP)
# price -= Decimal(area_seat_info["areaServiceFee"]).quantize(Decimal('0.00'), ROUND_HALF_UP)
# 计算用户实际支付的值
# 计算用户实际支付的值
real_pay = Decimal ( area_seat_info [ " areaPrice " ] ) . quantize ( Decimal ( ' 0.00 ' ) , ROUND_HALF_UP )
real_pay = f2 ( area_seat_info [ " areaPrice " ] )
real_pay - = Decimal ( area_seat_info [ " areaServiceFee " ] ) . quantize ( Decimal ( ' 0.00 ' ) , ROUND_HALF_UP )
real_pay - = f2 ( area_seat_info [ " areaServiceFee " ] )
# 处理影票和服务费折扣
# 处理影票和服务费折扣
if ticket_discount != 0 :
if ticket_discount != 0 :
real_pay - = Decimal ( ticket_discount )
real_pay - = f2 ( ticket_discount )
seat . append ( str ( ticket_discount ) )
seat . append ( str ( ticket_discount ) )
if service_discount != 0 :
if service_discount != 0 :
if partner_type == ' 2 ' :
if partner_type == ' 2 ' :
real_pay - = Decimal ( service_discount )
real_pay - = f2 ( service_discount )
seat . append ( str ( service_discount ) )
seat . append ( str ( service_discount ) )
else :
else :
seat . append ( str ( service_discount ) )
seat . append ( str ( service_discount ) )
@ -118,24 +126,106 @@ def general_seat_params(pay_type, data):
seat . append ( market_price )
seat . append ( market_price )
seat . append ( ' 0 ' )
seat . append ( ' 0 ' )
seat . append ( ' 0.00 ' )
seat . append ( ' 0.00 ' )
real_pay = Decimal ( market_price ) . quantize ( Decimal ( ' 0.00 ' ) , ROUND_HALF_UP )
real_pay = f2 ( market_price )
if ticket_discount != 0 :
if ticket_discount != 0 :
real_pay - = Decimal ( ticket_discount )
real_pay - = f2 ( ticket_discount )
seat . append ( str ( ticket_discount ) )
seat . append ( str ( ticket_discount ) )
if service_discount != 0 :
if service_discount != 0 :
real_pay - = Decimal ( service_discount )
real_pay - = f2 ( service_discount )
seat . append ( str ( service_discount ) )
seat . append ( str ( service_discount ) )
seat [ 3 ] = str ( real_pay )
seat [ 3 ] = str ( real_pay )
# seat = f'{seat_info["seat_id"]}-{handle_fee}-{market_price}-{str(real_pay)}-0{f"-{str(ticket_discount)}" if ticket_discount != 0 else ""}{f"-{str(service_discount)}" if service_discount != 0 else ""}'
# seat = f'{seat_info["seat_id"]}-{handle_fee}-{market_price}-{str(real_pay)}-0{f"-{str(ticket_discount)}" if ticket_discount != 0 else ""}{f"-{str(service_discount)}" if service_discount != 0 else ""}'
seat_list . append ( ' - ' . join ( seat ) )
seat_list . append ( ' - ' . join ( seat ) )
ticket_cash + = real_pay
ticket_cash + = real_pay
return True , ' , ' . join ( seat_list ) , ticket_cash , play_id , play_update_time , lock_flag , last_timestamp
return True , ' , ' . join ( seat_list ) , ticket_cash , play_id , play_update_time , lock_flag , quan , last_timestamp
elif pay_type == ' ecard ' :
elif pay_type == ' ecard ' :
pass
quan = ' '
elif pay_type == ' yushouquan ' :
# 获取联名卡价格
pass
request_api_ecard = { ' name ' : ' 3.4.6 获取座位的联名卡价格 ' , ' path ' : ' ecard/seat-price ' }
elif pay_type == ' equan ' :
redis_key_api_ecard = f ' { redis_key_prefix } _ { request_api_ecard [ " path " ] } '
pass
result_ecard , _format_ecard , seat_price_from_ecard , _timestamp_ecard = get_data_from_redis (
redis_key_api_ecard )
if not result_ecard :
return False , None , None , None , None , None , None , None
ecard_info = seat_price_from_ecard [ ' seatPrices ' ] if len ( seat_price_from_ecard [ ' seatPrices ' ] ) > 0 else False
# 错误判断
if ecard_info is False :
return_str = ' 请手动输入参数,检查相关接口返回值:3.4.6 获取座位的联名卡价格 '
return False , return_str , 0 , return_str , return_str , return_str , last_timestamp
# 处理价格
seat_list = [ ]
ticket_cash = 0 # 统计cash字段用
for seat_info in seat_id_list :
seat = [ seat_info [ " seat_id " ] , handle_fee ]
ticket_discount = seat_info [ " ticket_discount " ]
service_discount = seat_info [ " service_discount " ]
for ecard_seat_info in ecard_info :
if int ( ecard_seat_info [ ' seatId ' ] ) == int ( seat_info [ ' seat_id ' ] ) :
# 获取price字段值
price = f2 ( ecard_seat_info [ " price " ] )
seat . append ( str ( price ) )
seat . append ( ' 0 ' )
seat . append ( ecard_seat_info [ " serviceFee " ] )
# if partner_type == '2': # 合作商定价
# price -= Decimal(area_seat_info["areaServiceFee"]).quantize(Decimal('0.00'), ROUND_HALF_UP)
# 计算用户实际支付的值
real_pay = f2 ( ecard_seat_info [ " price " ] )
real_pay - = f2 ( ecard_seat_info [ " serviceFee " ] )
# 处理影票和服务费折扣
if ticket_discount != 0 :
real_pay - = f2 ( ticket_discount )
seat . append ( str ( ticket_discount ) )
if service_discount != 0 :
if partner_type == ' 2 ' :
real_pay - = f2 ( service_discount )
seat . append ( str ( service_discount ) )
else :
seat . append ( str ( service_discount ) )
seat [ 3 ] = str ( real_pay )
# seat = f'{seat_info["seat_id"]}-{handle_fee}-{str(price)}-{str(real_pay)}-{area_seat_info["areaServiceFee"]}{f"-{str(ticket_discount)}" if ticket_discount != 0 else ""}{f"-{str(service_discount)}" if service_discount != 0 else ""}'
seat_list . append ( ' - ' . join ( seat ) )
ticket_cash + = real_pay
return True , ' , ' . join ( seat_list ) , ticket_cash , play_id , play_update_time , lock_flag , quan , last_timestamp
elif pay_type in [ ' yushouquan ' , ' equan ' ] :
# 获取券价格
request_api_yushouquan = { ' name ' : ' 3.6.1 添加券 ' , ' path ' : ' seat/check-coupon ' }
redis_key_api_yushouquan = f ' { redis_key_prefix } _ { request_api_yushouquan [ " path " ] } '
result_yushouquan , _format_yushouquan , seat_price_from_yushouquan , _timestamp_yushouquan = get_data_from_redis (
redis_key_api_yushouquan )
if not result_yushouquan :
return False , None , None , None , None , None , None , None
# 获取券码
req_params = get_param_from_redis ( redis_key_api_yushouquan )
if pay_type == ' yushouquan ' :
quan = req_params [ ' coupons ' ] if req_params . get ( ' coupons ' , False ) else ' 3.6.1添加券接口中选择的券类型为会员卡赠券,与当前设置不符合 '
elif pay_type == ' equan ' :
quan = req_params [ ' card_coupons ' ] if req_params . get ( ' equan ' , False ) else ' 3.6.1添加券接口中选择的券类型为扫码券,与当前设置不符合 '
else :
quan = ' 请检查3.6.1添加券接口 '
# 获取座位参数
seat_list = [ ]
ticket_cash = 0 # 统计cash字段用
for seat_info in seat_id_list :
seat = [ seat_info [ " seat_id " ] , handle_fee ]
ticket_discount = seat_info [ " ticket_discount " ]
service_discount = seat_info [ " service_discount " ]
seat . append ( market_price )
seat . append ( ' 0 ' )
seat . append ( ' 0.00 ' )
real_pay = f2 ( market_price )
if ticket_discount != 0 :
real_pay - = f2 ( ticket_discount )
seat . append ( str ( ticket_discount ) )
if service_discount != 0 :
real_pay - = f2 ( service_discount )
seat . append ( str ( service_discount ) )
seat [ 3 ] = str ( real_pay )
# seat = f'{seat_info["seat_id"]}-{handle_fee}-{market_price}-{str(real_pay)}-0{f"-{str(ticket_discount)}" if ticket_discount != 0 else ""}{f"-{str(service_discount)}" if service_discount != 0 else ""}'
seat_list . append ( ' - ' . join ( seat ) )
ticket_cash + = real_pay
ticket_cash = seat_price_from_yushouquan [ ' balance ' ]
return True , ' , ' . join ( seat_list ) , ticket_cash , play_id , play_update_time , lock_flag , quan , last_timestamp
else :
else :
pass
pass