def get_finished_list(self, request, cld): business_orders = Orders.filter_finished_orders_list(request, **cld) verify_orders = VerifyOrders.filter_finished_orders_list( request, set_payment_mode=ORDERS_PAYMENT_MODE['yspay'], **cld) orders_list = business_orders + verify_orders return sorted(orders_list, key=lambda key: key['created'], reverse=True)
def get_verfify_orders_detail(self, request, **cld): # 吟食支付订单 instance = YinshiPayCode.get_object(code=cld['random_string']) if isinstance(instance, Exception): return instance instances = VerifyOrders.filter_finished_orders_list( request, orders_id=instance.consume_orders_id) if isinstance(instances, Exception): return instances elif not instances: return Exception('Can not perform this action.') return instances[0]
def get_verfify_orders_detail(self, request, **cld): # 待核销订单 if 'gateway' not in cld or cld['gateway'] == 'confirm_consume': instance = ConfirmConsume.get_object( random_string=cld['random_string']) if isinstance(instance, Exception): return instance return self.get_verify_orders_list(request, consumer_id=instance.user_id) # 吟食支付订单 else: instance = YinshiPayCode.get_object(code=cld['random_string']) if isinstance(instance, Exception): return instance return VerifyOrders.filter_finished_orders_list( request, orders_id=instance.consume_orders_id)
def get_verify_orders_list(self, request, cld): random_kwargs = {'random_string': cld['random_string']} random_instance = ConfirmConsume.get_object(**random_kwargs) if isinstance(random_instance, Exception): return random_instance orders_kwargs = {'consumer_id': random_instance.user_id} orders_list = VerifyOrders.filter_consuming_orders_list( request=request, is_detail=False, gateway='verify', **orders_kwargs) # orders_ids_all = [orders.orders_id for orders in orders_list] # for orders_id in cld['orders_ids']: # if orders_id not in orders_ids_all: # return Exception('Params [orders_ids] data error') verify_orders = [] for orders in orders_list: if orders.orders_id in cld['orders_ids']: verify_orders.append(orders) return verify_orders
def get_orders_detail(self, instances): return VerifyOrders.make_instances_to_dict(instances)
def get_verify_orders_list(self, request, consumer_id): kwargs = {'consumer_id': consumer_id} return VerifyOrders.filter_consuming_orders_list(request=request, gateway='verify', **kwargs)
def get_consume_list(self, request, cld): return VerifyOrders.filter_consuming_orders_list( request, set_payment_mode=ORDERS_PAYMENT_MODE['yspay'], **cld)
def get_detail(self, **kwargs): if kwargs['orders_id'].startswith('Z'): return VerifyOrders.get_detail(**kwargs) else: return Orders.get_detail(**kwargs)