Пример #1
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)
Пример #2
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)