Exemplo n.º 1
0
 def getBlockedMerchants(self, consumerId):
     currTimeMillis = SSUtil.getMillis()
     try:
         return ConsumerMerchant.objects.all().filter(consumerId=consumerId,
                                                      status=0)
     except ConsumerMerchant.DoesNotExist:
         return Array()
Exemplo n.º 2
0
 def getCards(self, consumerId, pk=None):
     try:
         if pk is None:
             cards = ConsumerCard.objects.all().filter(consumerId=consumerId)
             return cards
         else:
             return ConsumerCard.objects.get(id=pk)
     except ConsumerCard.DoesNotExist:
         return Array()
Exemplo n.º 3
0
 def getAllOffers(self, status):
     currTimeMillis = SSUtil.getMillis()
     try:
         offers = MerchantOffer.objects.all().order_by(
             'status', '-updated').filter(endDate__gt=currTimeMillis,
                                          status=status)
         return offers
     except MerchantOffer.DoesNotExist:
         return Array()
Exemplo n.º 4
0
 def getMerchantReviews(self, merchantId, fromDate, limit, start):
     res = None
     try:
         res = TxnReview.objects.all().order_by('-updated').filter(
             merchant_id=merchantId,
             created__gt=fromDate)[start:(start + limit)]
     except:
         res = Array()
     return res
Exemplo n.º 5
0
 def getTxns(self, consumerId, cardId, start, limit, tagIds, searchParams):
     #manipulate the limit for django
     limit = limit + start
     try:
         if not tagIds is None and tagIds != '':
             tidList = [int(x) for x in tagIds.split(',')]
             txnTagIds = TxnTag.objects.values('consumerTxn').filter(
                 cardId=cardId, consumerTag__in=tidList)
             txns = ConsumerTxn.objects.all().order_by('-created').filter(
                 ssApproval='Approve', cardId=cardId,
                 id__in=txnTagIds)[start:limit]
         else:
             txns = ConsumerTxn.objects.all().order_by('-created').filter(
                 ssApproval='Approve', cardId=cardId)[start:limit]
         return txns
     except ConsumerTxn.DoesNotExist:
         return Array()
Exemplo n.º 6
0
 def getTxnTaggedSummary(self, consumerId, cardId, start, limit):
     #manipulate the limit for django
     limit = limit + start
     name_map = {'pk': 'id', 'tagName': 'tagName', 'total': 'total'}
     try:
         summary = ConsumerTag.objects.raw('''
                                 select sum(t.amtSpentSS) as total,
                                 ctag.id as id,ctag.tag as tagName
                                 from ss_consumer_txn t,
                                 ss_consumer_tag ctag, ss_txn_tag tt
                                 where tt.consumerTxn_id=t.id and tt.consumerTag_id=ctag.id
                                 and t.cardId=%s
                                 group by ctag.id;
                                 ''', [cardId],
                                           translations=name_map)
         return summary
     except ConsumerTxn.DoesNotExist:
         return Array()
Exemplo n.º 7
0
 def getAllOffersNearMe(self, consumerId, status):
     currTimeMillis = SSUtil.getMillis()
     try:
         cms = ConsumerMerchant.objects.all().filter(consumerId=consumerId,
                                                     currentDistance__lt=50)
         merchants = ConsumerMerchant.objects.all().filter(
             consumerId=consumerId,
             currentDistance__lt=50).values_list("merchant_id", flat=True)
         print "merchants are " + str(merchants.query)
         offers = MerchantOffer.objects.all().order_by(
             'status', '-updated').filter(status=status,
                                          merchant_id__in=merchants)
         print "offers are " + str(offers.query)
         for offer in offers:
             for cm in cms:
                 if offer.merchant_id == cm.merchant_id:
                     offer.distance = cm.currentDistance
         return offers
     except MerchantOffer.DoesNotExist:
         return Array()