Esempio n. 1
0
    def retrive_and_insert_to_db(self, serial_count, sku_start, serialCode, skuCode, reference):
        reddisHelper = RedisHelper()

        # get serial list
        serial_list = reddisHelper.redis_spop_str(self.giftcard_prefix + serialCode + self.giftcard_list, serial_count)

        denomination_id = self.get_denomination_id(serialCode)

        sku_prefix = Utils.generate_skuCode_prefix(skuCode)

        current_time = datetime.datetime.utcnow()
        sku_count = 0
        for i in range(len(serial_list)):
            giftcard = CardGiftCard()
            giftcard.gfSerial = serial_list[i]
            giftcard.gfPin = self.generate_pin()
            giftcard.gfConsumed_dt = '0000-00-00 00:00:00'
            giftcard.gfCreate_dt = current_time
            giftcard.gfReference = reference
            giftcard.gfStatus = 'X'
            giftcard.gfSKU = sku_prefix + str(sku_start + sku_count).zfill(6)
            giftcard.gfDenom_id = denomination_id
            sku_count += 1
            db.session.add(giftcard)

        db.session.commit()
        db.session.close()
Esempio n. 2
0
    def test_query_demonation(self):
        for i in range(10):
            print(Utils.getCardDenomination('UP500'))

        tempvalue = '27'
        giftcard = CardGiftCard()
        giftcard.gfSerial = tempvalue
        giftcard.gfPin = tempvalue
        giftcard.gfConsumed_dt = datetime.datetime.utcnow()
        giftcard.gfCreate_dt = datetime.datetime.utcnow()
        giftcard.gfReference = tempvalue
        giftcard.gfStatus = 'X'
        giftcard.gfSKU = tempvalue
        giftcard.gfDenom_id = 6
        db.session.add(giftcard)

        db.session.commit()
        # db.session.close()

        for i in range(100):
            print(Utils.getCardDenomination('UP500'))
Esempio n. 3
0
    def test_mode_giftcard(self):
        giftcard = CardGiftCard()
        giftcard.gfSerial = 'serial1'
        giftcard.gfPin = 'pin1'
        giftcard.gfConsumed_dt = datetime.datetime.now()
        giftcard.gfConsumed_dt = datetime.datetime.now()
        giftcard.gfReference = 'reference1'
        giftcard.gfStatus = 'X'
        giftcard.gfSKU = 'SKU1'
        giftcard.gfDenom_id = 1

        giftcard2 = CardGiftCard()
        giftcard2.gfSerial = 'serial2'
        giftcard2.gfPin = 'pin2'
        giftcard2.gfConsumed_dt = datetime.datetime.now()
        giftcard2.gfConsumed_dt = datetime.datetime.now()
        giftcard2.gfReference = 'reference2'
        giftcard2.gfStatus = 'X'
        giftcard2.gfSKU = 'SKU2'
        giftcard2.gfDenom_id = 1
        db.session().add(giftcard)
        db.session().add(giftcard2)
        db.session().commit()