def print_ticket(self): '''取票接口''' orderno = request.params['orderno'] ticket_flag = request.params['ticket_flag'] seats = request.params['sid'] order = Order.getby_orderno(orderno) if not order: return Code.order_does_not_exist, {'orderno': orderno} if order.status == OrderStatus.printed.value: return Code.ticket_printed_already, {} if order.status != OrderStatus.paid.value: return Code.order_not_paid_yet, {} if not order.validate(ticket_flag): return Code.ticket_flag_error, {'ticket_flag': ticket_flag} # 修改座位状态为已取票 printed_num = PlaySeat.print_tickets(orderno, order.pid, seats) if not printed_num: return Code.ticket_print_failed, {} # 设置订单状态为已取票 order.status = OrderStatus.printed.value # 设置取票时间 order.printed_time = datetime.now() order.save() return {'printed_num': printed_num}
def print_ticket(self): orderno = request.params['orderno'] ticket_flag = request.params['ticket_flag'] seats = request.params['sid'] order = Order.getby_orderno(orderno) if not order: return Code.order_does_not_exist, {'orderno': orderno} # 订单是否已打印 if order.status == OrderStatus.printed.value: return Code.ticket_printed_already, {} # 订单是否支付 if order.status != OrderStatus.paid.value: return Code.order_not_paid_yet, {} # 核对订单码 if not order.validate(ticket_flag): return Code.ticket_flag_error, {'ticket_flag': ticket_flag} printed_num = PlaySeat.print_tickets(order.seller_order_no, order.pid, seats) if not printed_num: return Code.ticket_print_failed.value, {} order.status = OrderStatus.printed.value order.printed_time = datetime.now() order.save() return {'printed_num': printed_num}