示例#1
0
def processTxn(request):
    data = json.loads(request.body)
    print data
    try:
        validate(data)
    except Exception as e:
        return JSONResponse(SSUtil.err(e.message),
                            status=status.HTTP_412_PRECONDITION_FAILED)
    tvServ = TxnValidatorService()
    txnApprovalVO = tvServ.getApproval(data['cardNum'], data['amount'],
                            data['merchantUuid'], data['merchantName'],
                            data['txType'], data['mccCode'])
    delayed = True
    millisStart = SSUtil.getMillis()
    if delayed:
        asyncRecordTransaction.delay(data['cardNum'], data['amount'],
                            data['merchantUuid'], data['merchantName'],
                            data['txType'], data['mccCode'], txnApprovalVO, request.user)
    else:
        asyncRecordTransaction(data['cardNum'], data['amount'],
                            data['merchantUuid'], data['merchantName'],
                            data['txType'], data['mccCode'], txnApprovalVO, request.user)
    millisEnd = SSUtil.getMillis()
    timeTaken = millisEnd - millisStart
    res={ "flag":txnApprovalVO.immediateApproval,
           "msg":txnApprovalVO.remarks,
           "time":timeTaken
        }
    return JSONResponse(SSUtil.success(res), status=status.HTTP_200_OK)
示例#2
0
    def deletePref(self, consumerId, cardId, categoryKey, periodKey):
        pref = None
        millis = SSUtil.getMillis()
        cacheService = CacheService()
        txnService = TxnService()
        try:
            pref = ConsumerPrefs.objects.get(consumerId=consumerId,
                                             cardId=cardId,
                                             periodKey=periodKey,
                                             categoryKey=categoryKey)
            pref.delete()
        except ConsumerPrefs.DoesNotExist:
            pass

        try:
            agg = ConsumerAgg.objects.get(consumerId=consumerId,
                                          cardId=cardId,
                                          periodKey=periodKey,
                                          categoryKey=categoryKey)
            agg.delete()
        except ConsumerAgg.DoesNotExist:
            pass
        cacheService.setConsumerPrefs(consumerId)
        txnService.recalculateAgg(consumerId, None, None)
        cacheService.setConsumerAggs(consumerId)
        return True
示例#3
0
 def getBlockedMerchants(self, consumerId):
     currTimeMillis = SSUtil.getMillis()
     try:
         return ConsumerMerchant.objects.all().filter(consumerId=consumerId,
                                                      status=0)
     except ConsumerMerchant.DoesNotExist:
         return Array()
示例#4
0
    def getOnDemandConsumerOffersByMerchant(self, consumerId, merchantId):
        ssConst = SSConst()
        txnService = TxnService()
        currTimeMillis = SSUtil.getMillis()
        merchantOffers = MerchantOffer.objects.filter(
            status=ssConst.OFFER_STATUSES[0][0], merchant_id=merchantId)
        miscDetails = txnService.getConsumerMerchantMiscDetails(
            consumerId, merchantId)
        for offer in merchantOffers:
            targettings = MerchantOfferTargetting.objects\
                                                 .all()\
                                                 .filter(offer_id=offer.id,
                                                         targetType = ssConst.OFFER_TARGET_TYPES[4][0])
            for targetting in targettings:
                if (int(miscDetails["totalOnMerchant"]) >= int(
                        targetting.minTotalSpend)
                        or int(miscDetails["visitsOnMerchant"]) >= int(
                            targetting.minVisits)):
                    self.addConsumerOfferIfRequired(consumerId, offer,
                                                    offer.merchant_id)


        consumerOffers = ConsumerOffer.objects \
                                     .filter(Q(status=ssConst.CONSUMER_OFFER_STATUSES[0][0])
                                      | Q(status=ssConst.CONSUMER_OFFER_STATUSES[1][0]),
                                      consumerId=consumerId, merchantId = merchantId
                                      , endDate__gt=currTimeMillis
                                      ).order_by("-updated")
        return consumerOffers
示例#5
0
 def manageTags(self, txnId, selected, newOne):
     millis = SSUtil.getMillis()
     txn = ConsumerTxn.objects.get(id=txnId)
     if not selected is None:
         txnTags = TxnTag.objects.all().filter(consumerTxn_id=txnId)
         for txnTag in txnTags:
             if not SSUtil.isIdinList(selected, txnTag.consumerTag_id):
                 self.removeTag(txnId, txnTag.consumerTag_id)
             else:
                 selected = SSUtil.removeIdFromList(selected,
                                                    txnTag.consumerTag_id)
         # Now check what remains, and tag to them
         if not selected is None and selected != '':
             lst = selected.split(",")
             for tagId in lst:
                 txnTag = TxnTag()
                 txnTag.cardId = txn.cardId
                 txnTag.consumerTag_id = tagId
                 txnTag.consumerTxn_id = txnId
                 txnTag.created = millis
                 txnTag.updated = millis
                 txnTag.save()
     else:  #Remove all
         txnTags = TxnTag.objects.filter(consumerTxn_id=txnId)
         for txnTag in txnTags:
             self.removeTag(txnId, txnTag.consumerTag_id)
     #Create new one if sent
     if not newOne is None and newOne != '':
         consumerTag = self.addTag(txnId, newOne)
示例#6
0
    def createMerchant(self, merchantUuid, merchantName, accessCode,
                       deviceRegistrationId, mccCode):
        currTimeMillis = SSUtil.getMillis()
        ssConst = SSConst()
        merchant = Merchant()
        if merchantName is None:
            merchantName = ''
        merchant.name = merchantName
        merchant.uuid = merchantUuid
        merchant.phone = ssConst.MERCHANT_DEFAULT_CONTACT_NUM
        merchant.address = ssConst.MERCHANT_DEFAULT_ADDRESS
        merchant.reviewStatus = ssConst.TXN_REVIEW_STATUSES[0][0]
        merchant.status = 1
        merchant.created = currTimeMillis
        merchant.updated = currTimeMillis
        merchant.installed = 1
        merchant.mccCode = mccCode
        if not accessCode is None:
            merchant.accessCode = accessCode
        if not deviceRegistrationId is None:
            merchant.deviceRegistrationId = deviceRegistrationId
            merchant.deviceType = 1
            merchant.deviceSubType = 1
        merchant.save()

        reviewTemplate = ReviewTemplate()
        reviewTemplate.criteria1 = "Overall Rating"
        reviewTemplate.merchant_id = merchant.id
        reviewTemplate.commentRequired = 1
        reviewTemplate.version = 1
        reviewTemplate.created = currTimeMillis
        reviewTemplate.updated = currTimeMillis
        reviewTemplate.save()

        return merchant
示例#7
0
 def addTag(self, txnId, tag):
     #first check if consumer has that tag
     consumerTag = None
     millis = SSUtil.getMillis()
     txn = ConsumerTxn.objects.get(id=txnId)
     try:
         consumerTag = ConsumerTag.objects.get(consumerId=txn.consumerId,
                                               tag=tag)
     except ConsumerTag.DoesNotExist:
         consumerTag = ConsumerTag()
         consumerTag.consumerId = txn.consumerId
         consumerTag.tag = tag
         consumerTag.created = millis
         consumerTag.updated = millis
         consumerTag.save()
     ## Now make mapping in txnTag
     try:
         txnTag = TxnTag.objects.get(cardId=txn.cardId,
                                     consumerTag_id=consumerTag.id,
                                     consumerTxn_id=txnId)
     except TxnTag.DoesNotExist:
         txnTag = TxnTag()
         txnTag.cardId = txn.cardId
         txnTag.consumerTag_id = consumerTag.id
         txnTag.consumerTxn_id = txnId
         txnTag.created = millis
         txnTag.updated = millis
         txnTag.save()
     txn = ConsumerTxn.objects.get(id=txnId)
     searchServ = SearchService()
     txnSerializer = ConsumerTxnSerializer(txn, many=False)
     searchServ.upload("txn", txn.id, txnSerializer.data)
     return consumerTag
示例#8
0
 def savePref(self, consumerId, cardId, categoryKey, periodKey, action,
              userLimit):
     pref = None
     millis = SSUtil.getMillis()
     cacheService = CacheService()
     txnService = TxnService()
     try:
         if categoryKey is None:
             pref = ConsumerPrefs.objects.get(consumerId=consumerId,
                                              cardId=cardId,
                                              periodKey=periodKey,
                                              categoryKey='Any')
         else:
             pref = ConsumerPrefs.objects.get(consumerId=consumerId,
                                              cardId=cardId,
                                              periodKey=periodKey,
                                              categoryKey=categoryKey)
     except ConsumerPrefs.DoesNotExist:
         pref = ConsumerPrefs()
         pref.consumerId = consumerId
         pref.cardId = cardId
         pref.periodKey = periodKey
         pref.categoryKey = categoryKey
         pref.created = millis
         pref.txType = "Any"
         pref.merchantId = -1
     pref.ssApproval = action
     pref.limit = userLimit
     pref.updated = millis
     pref.save()
     cacheService.setConsumerPrefs(consumerId)
     txnService.recalculateAgg(consumerId, None, None)
     cacheService.setConsumerAggs(consumerId)
     return pref
示例#9
0
    def toggleCardLockStatus(self, cardId, consumerId):
        millis = SSUtil.getMillis()
        cacheService = CacheService()
        statusFlag = 0
        try:
            consumer = Consumer.objects.get(id=consumerId)
            consumerCard = ConsumerCard.objects.get(id=cardId)

            if SSUtil.isIdinList(consumer.blockedCards, cardId):
                consumer.blockedCards = SSUtil.removeIdFromList(
                    consumer.blockedCards, cardId)
                statusFlag = 1
                consumerCard.status = 1
            else:
                consumer.blockedCards = SSUtil.addIdToList(
                    consumer.blockedCards, cardId)
                statusFlag = 0
                consumerCard.status = 0

            consumer.updated = millis
            consumerCard.updated = millis
            consumer.save()
            cacheService.setConsumer(consumer.id)
            consumerCard.save()
            cacheService.setCard(consumerCard.id)
            return statusFlag
        except:
            raise Exception(SSException.PROCESSING_FAILED)
示例#10
0
 def markConsumerOffersRead(self, consumerId):
     millis = SSUtil.getMillis()
     ssConst = SSConst()
     consumerOffer = ConsumerOffer.objects \
                                  .filter(status = ssConst.CONSUMER_OFFER_STATUSES[0][0],
                                   consumerId=consumerId) \
                                   .update(status = ssConst.CONSUMER_OFFER_STATUSES[1][0])
     return True
示例#11
0
 def getConsumerOffers(self, consumerId):
     currTimeMillis = SSUtil.getMillis()
     ssConst = SSConst()
     consumerOffers = ConsumerOffer.objects \
                                   .filter(Q(status=ssConst.CONSUMER_OFFER_STATUSES[0][0])
                                    | Q(status=ssConst.CONSUMER_OFFER_STATUSES[1][0]),
                                    consumerId=consumerId, endDate__gt=currTimeMillis
                                    ).order_by("-updated")
     return consumerOffers
示例#12
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()
示例#13
0
    def recordTxn(self, cardNum, txType, amount, mccCode, merchantUuid,
                  merchantName, txnApprovalVO):
        currTimeMillis = SSUtil.getMillis()
        ssConst = SSConst()
        cacheService = CacheService()
        merchServ = MerchantService()
        merchant = None
        print "inside record txn " + merchantUuid
        try:
            consumerCard = cacheService.getCardByNum(cardNum)
            category = cacheService.getCategoryByMccCode(mccCode)
            approvalTypeJson = ssConst.getJson(ssConst.APPROVAL_TYPES)
            try:
                merchant = cacheService.getMerchantByUuid(str(merchantUuid))
            except:
                merchant = merchServ.createMerchant(merchantUuid, merchantName,
                                                    None, None, mccCode)
            # Record transaction
            txn = ConsumerTxn()
            txn.consumerId = consumerCard.consumerId
            txn.cardId = consumerCard.id
            txn.txType = txType
            txn.txDate = currTimeMillis
            txn.amtSpentSS = amount
            txn.category_id = category.id
            txn.merchant_id = merchant.id
            txn.reviewStatus = merchant.reviewStatus
            txn.ssApproval = txnApprovalVO.approval
            # decide over the status
            if (txnApprovalVO.approval == 'Approve'
                    or txnApprovalVO.approval == 'Warn'):
                txn.ssApprovalStatus = ssConst.APPROVAL_STATUSES[0][0]
            if (txnApprovalVO.approval == 'Block'):
                txn.ssApprovalStatus = ssConst.APPROVAL_STATUSES[1][0]
            if (txnApprovalVO.approval == 'AskMe'):
                txn.ssApprovalStatus = ssConst.APPROVAL_STATUSES[2][0]

            txn.created = currTimeMillis
            txn.updated = currTimeMillis
            txn.save()

            #Establish relation with consumer and merchant
            merchServ.addConsumerRelation(merchant.id, consumerCard.consumerId)
            searchServ = SearchService()
            txnSerializer = ConsumerTxnSerializer(txn, many=False)
            if (txnApprovalVO.approval == 'Approve'
                    or txnApprovalVO.approval == 'Warn'):
                searchServ.upload("txn", txn.id, txnSerializer.data)
            return txn

        except Exception as e:
            print "Exception while recording txn " + e.message
            # actually log the fact that it has gone wrong
            pass
示例#14
0
 def registerDeviceGCMRegistrationId(self, registrationId, consumerId):
     millis = SSUtil.getMillis()
     cacheService = CacheService()
     try:
         consumerDevice = ConsumerDevice.objects.get(consumerId=consumerId)
         consumerDevice.deviceRegistrationId = registrationId
         consumerDevice.updated = millis
         consumerDevice.save()
         cacheService.setDevice(consumerDevice.id)
         return 1
     except:
         raise Exception(SSException.PROCESSING_FAILED)
示例#15
0
 def updateOfferTargetting(self, targettingId, targetType, minVisits,
                           minTotalSpend):
     currTimeMillis = SSUtil.getMillis()
     mot = None
     try:
         mot = MerchantOfferTargetting.objects.get(id=targettingId)
     except:
         return mot
     mot.targetType = targetType
     mot.minVisits = minVisits
     mot.minTotalSpend = minTotalSpend
     mot.updated = currTimeMillis
     mot.save()
     return mot
示例#16
0
 def addOfferTargetting(self, offerId, targetType, minVisits,
                        minTotalSpend):
     currTimeMillis = SSUtil.getMillis()
     ssConst = SSConst()
     merchantOfferTargetting = None
     mot = MerchantOfferTargetting()
     mot.offer_id = offerId
     mot.targetType = targetType
     mot.minVisits = minVisits
     mot.minTotalSpend = minTotalSpend
     mot.created = currTimeMillis
     mot.updated = currTimeMillis
     mot.save()
     return mot
示例#17
0
 def addConsumerRelation(self, merchantId, consumerId):
     currTimeMillis = SSUtil.getMillis()
     try:
         cm = ConsumerMerchant.objects.get(merchant_id=merchantId,
                                           consumerId=consumerId)
     except ConsumerMerchant.DoesNotExist:
         cm = ConsumerMerchant()
         cm.created = currTimeMillis
         cm.updated = currTimeMillis
         cm.consumerId = consumerId
         cm.merchant_id = merchantId
         cm.status = 1
         cm.currentDistance = 100
         cm.save()
示例#18
0
 def toggleStatus(self, merchantId, consumerId, statusFlag):
     currTimeMillis = SSUtil.getMillis()
     try:
         cm = ConsumerMerchant.objects.get(merchant_id=merchantId,
                                           consumerId=consumerId)
     except ConsumerMerchant.DoesNotExist:
         cm = ConsumerMerchant()
         cm.created = currTimeMillis
         cm.consumerId = consumerId
         cm.merchant_id = merchantId
         cm.currentDistance = 100
     cm.status = statusFlag
     cm.updated = currTimeMillis
     cm.save()
示例#19
0
    def removeTag(self, txnId, tagId):
        #first check if consumer has that tag
        consumerTag = None
        millis = SSUtil.getMillis()
        txn = ConsumerTxn.objects.get(id=txnId)
        ## Now make mapping in txnTag
        try:
            txnTag = TxnTag.objects.get(cardId=txn.cardId,
                                        consumerTag_id=tagId,
                                        consumerTxn_id=txnId)
            txnTag.delete()
        except TxnTag.DoesNotExist:
            pass

        return True
示例#20
0
    def unlockTxTypeStatus(self, cardId, txType):
        millis = SSUtil.getMillis()
        statusFlag = 1
        cacheService = CacheService()
        try:
            consumerCard = ConsumerCard.objects.get(id=cardId)

            if SSUtil.isIdinList(consumerCard.blockedTxTypes,txType):
                consumerCard.blockedTxTypes = SSUtil.removeIdFromList(consumerCard.blockedTxTypes,txType)
                statusFlag = 1

            consumerCard.updated = millis
            consumerCard.save()
            cacheService.setCard(cardId)
            return statusFlag
        except:
           raise Exception(SSException.PROCESSING_FAILED)
示例#21
0
 def registerMerchant(self, merchantUuid, accessCode):
     currTimeMillis = SSUtil.getMillis()
     ssConst = SSConst()
     merchant = None
     try:
         merchant = Merchant.objects.get(uuid=merchantUuid,
                                         accessCode=accessCode)
         if merchant is None:
             raise Exception("Invalid combination of ID and Access Code")
         elif merchant.installed is 0:
             merchant.installed = 1
             merchant.save()
         else:
             pass
     except Merchant.DoesNotExist:
         raise Exception("Invalid combination of ID and Access Code")
     return merchant
示例#22
0
 def updateMerchant(self, merchantId, name, description, businessHours):
     currTimeMillis = SSUtil.getMillis()
     ssConst = SSConst()
     merchant = None
     try:
         merchant = Merchant.objects.get(id=merchantId)
         if not name is None:
             merchant.name = name
         if not description is None:
             merchant.description = description
         if not businessHours is None:
             merchant.businessHours = businessHours
         merchant.uodated = currTimeMillis
         merchant.save()
     except Merchant.DoesNotExist:
         raise Exception("Invalid merchant")
     return merchant
示例#23
0
    def createDefaultPrefsAndAggs(self, card):
        agg = None
        pref = None
        defPeriodKeys = {"Daily","Monthly"}
        defAction = "Approve"
        millis = SSUtil.getMillis()
        cacheService = CacheService()
        for periodKey in defPeriodKeys:
            try:
                pref = ConsumerPrefs.objects.get(consumerId=card.consumerId,
                                    cardId = card.id, periodKey=periodKey,
                                    categoryKey='Any')
            except:
                pref = ConsumerPrefs()
                pref.consumerId = card.consumerId
                pref.cardId = card.id
                pref.periodKey = periodKey
                pref.categoryKey = 'Any'
                pref.created = millis
                pref.txType = "Any"
                pref.merchantId = -1
                pref.ssApproval = defAction
            pref.limit = card.limit
            pref.updated = millis
            pref.save()

            try:
                agg = ConsumerAgg.objects.get(consumerId=card.consumerId,
                                    cardId = card.id, periodKey=periodKey,
                                    categoryKey='Any')
            except:
                agg = ConsumerAgg()
                agg.consumerId = card.consumerId
                agg.cardId = card.id
                agg.periodKey = periodKey
                agg.categoryKey = 'Any'
                agg.created = millis
                agg.txType = "Any"
                agg.merchantId = -1
                agg.ssApproval = defAction
            agg.amtSpentSS = 0.00
            agg.updated = millis
            agg.save()
        cacheService.setConsumerPrefs(card.consumerId)
        cacheService.setConsumerAggs(card.consumerId)
示例#24
0
 def updateOffer(self, offerId, title, description, code, codeType,
                 endDate):
     currTimeMillis = SSUtil.getMillis()
     ssConst = SSConst()
     merchantOffer = None
     try:
         merchantOffer = MerchantOffer.objects.get(id=offerId)
     except:
         msg = "Offer does not exist for id " + offerId
         raise Exception(msg)
     merchantOffer.title = title
     merchantOffer.description = description
     merchantOffer.endDate = endDate
     merchantOffer.codeType = codeType
     merchantOffer.code = code
     merchantOffer.updated = currTimeMillis
     merchantOffer.save()
     return merchantOffer
示例#25
0
 def saveReviewTemplate(self, merchantId, criteria1Value, criteria2Value,
                        criteria3Value):
     millis = SSUtil.getMillis()
     reviewTemplate = None
     try:
         reviewTemplate = ReviewTemplate.objects.get(merchant_id=merchantId)
     except reviewTemplate.DoesNotExist:
         reviewTemplate = ReviewTemplate()
         reviewTemplate.version = 0
         reviewTemplate.commentRequired = 1
         reviewTemplate.created = millis
     reviewTemplate.merchant_id = merchantId
     reviewTemplate.criteria1 = criteria1Value
     reviewTemplate.criteria2 = criteria2Value
     reviewTemplate.criteria3 = criteria3Value
     reviewTemplate.version = reviewTemplate.version + 1
     reviewTemplate.updated = millis
     reviewTemplate.save()
     return reviewTemplate
示例#26
0
 def addConsumerOfferIfRequired(self, consumerId, offer, merchantId):
     millis = SSUtil.getMillis()
     ssConst = SSConst()
     consumerOffer = None
     try:
         consumerOffer = ConsumerOffer.objects.get(consumerId=consumerId,
                                                   offer_id=offer.id)
     except ConsumerOffer.DoesNotExist:
         if consumerOffer is None:
             consumerOffer = ConsumerOffer()
             consumerOffer.created = millis
             consumerOffer.updated = millis
             consumerOffer.offer_id = offer.id
             consumerOffer.merchantId = merchantId
             consumerOffer.consumerId = consumerId
             consumerOffer.status = ssConst.CONSUMER_OFFER_STATUSES[0][0]
             consumerOffer.startDate = offer.startDate
             consumerOffer.endDate = offer.endDate
             consumerOffer.save()
示例#27
0
    def processOfferNotification(self, txnId, targetType,
                                 deviceRegistrationId):
        millis = SSUtil.getMillis()
        ssConst = SSConst()
        txnService = TxnService()
        android = Android()
        consumerServ = ConsumerService()

        txn = ConsumerTxn.objects.get(id=txnId)
        if deviceRegistrationId is None:
            consumerDevice = consumerServ.getConsumerDevice(txn.consumerId)
            deviceRegistrationId = consumerDevice.deviceRegistrationId
        miscDetails = txnService.getTxnMiscDetails(txn.consumerId, txn.cardId,
                                                   txn.id)
        # Get the merchant
        merchant = Merchant.objects.get(id=txn.merchant_id)

        # Get the offers for that merchant
        offers = MerchantOffer.objects.all().filter(
            merchant_id=txn.merchant_id, status=ssConst.OFFER_STATUSES[0][0])

        # Check targetting for these offers
        notificationSent = False
        for offer in offers:
            targettings = MerchantOfferTargetting.objects.all().filter(
                offer_id=offer.id)
            for targetting in targettings:
                if targetting.targetType == targetType:
                    # check if consumer qualifies for the offer
                    if (int(miscDetails["totalOnMerchant"]) >= int(
                            targetting.minTotalSpend)
                            or int(miscDetails["visitsOnMerchant"]) >= int(
                                targetting.minVisits)):
                        self.addConsumerOfferIfRequired(
                            txn.consumerId, offer, merchant.id)
                        # Send only one notification
                        if not notificationSent:
                            android.sendOfferNotification(
                                deviceRegistrationId, offer.title,
                                "Offer from " + merchant.name,
                                ssConst.DEVICE_NOTIFICATION_TYPES["Offer"],
                                offer.id, merchant.id)
                            notificationSent = True
示例#28
0
 def markOfferStatus(self, offerId, status):
     currTimeMillis = SSUtil.getMillis()
     ssConst = SSConst()
     merchantOffer = None
     try:
         merchantOffer = MerchantOffer.objects.get(id=offerId)
     except:
         msg = "Offer does not exist for id " + offerId
         raise Exception(msg)
     merchantOffer.status = status
     merchantOffer.updated = currTimeMillis
     merchantOffer.save()
     # if status is archived or suspended then mark them so
     # in consumer offer
     if status != ssConst.OFFER_STATUSES[0][0]:
         ConsumerOffer.objects\
                      .filter(offer_id=offerId)\
                      .update(status=ssConst.CONSUMER_OFFER_STATUSES[2][0])
     return merchantOffer
示例#29
0
 def registerDevice(self, deviceToken):
     # first check if device exists
     try:
         cc = ConsumerDevice.objects.get(deviceToken=deviceToken)
         raise Exception(SSException.DEVICE_TOKEN_EXISTS)
     except ConsumerDevice.DoesNotExist:
         t = SSUtil.getMillis()
         firstName = 'Vijay'
         lastName = 'Kalra'
         c = Consumer(created=t, updated=t)
         c.save()
         cc = ConsumerDevice(firstname=firstName,
                             lastname=lastName,
                             deviceToken=deviceToken,
                             consumerId=c.id,
                             created=t,
                             updated=t)
         cc.save()
         return cc.id
示例#30
0
    def lockMerchantStatus(self, merchantId, consumerId):
        millis = SSUtil.getMillis()
        statusFlag = 0
        cacheService = CacheService()
        try:
            consumer = Consumer.objects.get(id=consumerId)

            if not SSUtil.isIdinList(consumer.blockedMerchants, merchantId):
                consumer.blockedMerchants = SSUtil.addIdToList(
                    consumer.blockedMerchants, merchantId)
                statusFlag = 0

            consumer.updated = millis
            consumer.save()
            cacheService.setConsumer(consumer.id)
            merchServ = MerchantService()
            merchServ.toggleStatus(merchantId, consumerId, statusFlag)
            return statusFlag
        except:
            raise Exception(SSException.PROCESSING_FAILED)