购票部分先提交一版

main
RogerWork 4 months ago
parent b786e0ddc1
commit b873d44561
  1. 38
      dspt_api/util/general/handle_seat.py

@ -46,8 +46,9 @@ def general_seat_params(pay_type, data):
request_api_seat = {'name': '3.1.8 获取某场次座位状态', 'path': 'play/seat-status'}
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)
seat_id_list = [{'seat_id': seat['cineSeatId'], 'ticket_discount': seat['ticketDiscount'],
'service_discount': seat['serviceDiscount']} for seat in seat_price_from_seat]
print('seat_price_from_seat', seat_price_from_seat)
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]
# 计算最大时间戳
last_timestamp = max([_timestamp_lock, _timestamp_play, _timestamp_config, _timestamp_seat])
@ -68,46 +69,65 @@ def general_seat_params(pay_type, data):
-- 当影院合作商是合作商自主定价时partner_type = 2
price真实的票价[不含服务费不含手续费]
user_real_pay_price用户真实支付影票金额[不含手续费服务费] 需要扣减 ticket_discount_price
service_fee真实的服务费 需要扣减 service_fee_discount_price
service_fee真实的服务费
ticket_discount_price影票优惠金额仅做记录
service_fee_discount_price服务费优惠金额仅做记录
测试影院
测试影院3.166 乐影网 电商平台补贴 是否允许传递优惠金额 影票价格控制 卖品价格控制
测试影院3.166 淘票票 电商平台补贴 是否允许传递优惠金额 影票价格控制 卖品价格控制
测试影院3.166 美团猫眼 电商平台补贴 是否允许传递优惠金额 影票价格控制 卖品价格控制
测试影院3.166 美团猫眼 电商平台补贴 是否允许传递优惠金额 影票价格控制 卖品价格控制
测试影院3.166 合作商补贴 合作商补贴 是否允许传递优惠金额 影票价格控制 卖品价格控制
"""
seat_list = []
ticket_cash = 0
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"]
if area_info is not False:
# 查找座位对应的区域价格
for area_seat_info in area_info:
if area_seat_info['seatId'] == int(seat_info['seat_id']):
# 获取price字段值
price = Decimal(area_seat_info["areaPrice"]).quantize(Decimal('0.00'), ROUND_HALF_UP)
seat.append(price)
seat.append('0')
seat.append(area_seat_info["areaServiceFee"])
# if partner_type == '2': # 合作商定价
# 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 -= Decimal(area_seat_info["areaServiceFee"]).quantize(Decimal('0.00'), ROUND_HALF_UP)
# 处理影票和服务费折扣
if ticket_discount != 0:
real_pay -= Decimal(ticket_discount)
seat.append(str(ticket_discount))
if service_discount != 0:
if partner_type == '2':
real_pay -= Decimal(service_discount)
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(seat)
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
else:
seat.append(market_price)
seat.append('0')
seat.append('0.00')
real_pay = Decimal(market_price).quantize(Decimal('0.00'), ROUND_HALF_UP)
if ticket_discount != 0:
real_pay -= Decimal(ticket_discount)
seat.append(str(ticket_discount))
if service_discount != 0:
real_pay -= Decimal(service_discount)
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(seat)
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
return True, ','.join(seat_list), ticket_cash, play_id, play_update_time, lock_flag, last_timestamp

Loading…
Cancel
Save