Esempio n. 1
0
    def getTopSellingProducts(self, token):
        user, exception = Validation.validateToken(token)
        if (exception != None):
            return ResponseUtils.returnError(exception)

        productDao = ProductDao()
        result, exception = productDao.getTopSellingProducts(user)
        if exception != None:
            return ResponseUtils.returnError(exception)
        else:
            return ResponseUtils.returnSuccess(result)
Esempio n. 2
0
    def searchProduct(self, token, searchKey):
        user, exception = Validation.validateToken(token)
        if (exception != None):
            return ResponseUtils.returnError(exception)

        productDao = ProductDao()
        result, exception = productDao.searchProduct(user, searchKey)
        if exception != None:
            return ResponseUtils.returnError(exception)
        else:
            return ResponseUtils.returnSuccess(result)
Esempio n. 3
0
    def getProducts(self, token):
        user, exception = Validation.validateToken(token)
        if (exception != None):
            return ResponseUtils.returnError(exception)

        # TODO: add pagination
        productDao = ProductDao()
        products, exception = productDao.getProducts(user)
        if (exception != None):
            return ResponseUtils.returnError(exception)
        else:
            return ResponseUtils.returnSuccess(products)
Esempio n. 4
0
    def updateProductQuantityAndOriginalPrice(self, token, products):
        user, exception = Validation.validateToken(token)
        if (exception != None):
            return ResponseUtils.returnError(exception)

        productDao = ProductDao()
        for product in products:
            exception = productDao.updateQuantityAndOrginalPrice(
                user, product['id'], product['quantity'],
                product['original_price'])
            if (exception != None):
                return ResponseUtils.returnError(exception)

        return ResponseUtils.returnSuccess(None)
    def getAllAccountStatement(self, token):
        user, exception = Validation.validateToken(token)
        if (exception != None):
            return ResponseUtils.returnError(exception)

        accountStatementDao = AccountStatementDao()
        data, exception = accountStatementDao.getAll(user)
        if (exception != None):
            return ResponseUtils.returnError(exception)

        for accountSta in data:
            accountSta['start_date'] = TimestampUtils.getDateFromDatetime(
                accountSta['start_date'])
            accountSta['end_date'] = TimestampUtils.getDateFromDatetime(
                accountSta['end_date'])

        return ResponseUtils.returnSuccess(data)
    def getAccountStatementInfo(self, token, accountStatementId):
        user, exception = Validation.validateToken(token)
        if (exception != None):
            return ResponseUtils.returnError(exception)

        asExceptionDao = AccountStatementExceptionDao()
        asExceptions, exception = asExceptionDao.getAll(
            user, accountStatementId)
        if (exception != None):
            return ResponseUtils.returnError(exception)

        orderItemDao = OrderItemDao()
        orderItems, exception = orderItemDao.getOrderItemByAccountStatement(
            user, accountStatementId)
        if (exception != None):
            return ResponseUtils.returnError(exception)

        result = {"exceptions": asExceptions, "orderItems": orderItems}
        return ResponseUtils.returnSuccess(result)
Esempio n. 7
0
    def createShop(self, token, shop):
        user, exception = Validation.validateToken(token)
        if (exception != None):
            return ResponseUtils.returnError(exception)

        # Test api key
        lazadaStatisticApi = LazadaStatisticApi()
        result, exception = lazadaStatisticApi.getStatistic(user, shop)
        if (exception != None):
            return ResponseUtils.returnError(
                "Lazada email or api-key is incorrect")

        # create shop
        shopDao = ShopDao()
        result, exception = shopDao.insert(user, shop)
        if (exception != None):
            return ResponseUtils.returnError(exception)

        # Start cronjob

        # Done
        return ResponseUtils.returnSuccess(result)