Subversion Repositories SmartDukaan

Rev

Rev 11577 | Rev 11606 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 11577 Rev 11592
Line 10... Line 10...
10
from shop2020.clients.InventoryClient import InventoryClient
10
from shop2020.clients.InventoryClient import InventoryClient
11
from shop2020.config.client.ConfigClient import ConfigClient
11
from shop2020.config.client.ConfigClient import ConfigClient
12
from shop2020.model.v1.catalog.impl import DataService
12
from shop2020.model.v1.catalog.impl import DataService
13
from shop2020.model.v1.catalog.impl.CategoryManager import CategoryManager
13
from shop2020.model.v1.catalog.impl.CategoryManager import CategoryManager
14
from shop2020.model.v1.catalog.impl.Convertors import to_t_item, to_t_source, \
14
from shop2020.model.v1.catalog.impl.Convertors import to_t_item, to_t_source, \
15
    to_t_brand_info
15
    to_t_brand_info, to_t_private_deal
16
from shop2020.model.v1.catalog.impl.DataService import Item, ItemChangeLog, \
16
from shop2020.model.v1.catalog.impl.DataService import Item, ItemChangeLog, \
17
    Category, EntityIDGenerator, SimilarItems, ProductNotification, Source, \
17
    Category, EntityIDGenerator, SimilarItems, ProductNotification, Source, \
18
    SourceItemPricing, AuthorizationLog, VoucherItemMapping, CategoryVatMaster, \
18
    SourceItemPricing, AuthorizationLog, VoucherItemMapping, CategoryVatMaster, \
19
    OOSTracker, EntityTag, ItemInsurerMapping, Insurer, Banner, BannerMap, \
19
    OOSTracker, EntityTag, ItemInsurerMapping, Insurer, Banner, BannerMap, \
20
    FreebieItem, BrandInfo, Amazonlisted, StorePricing, ItemVatMaster, \
20
    FreebieItem, BrandInfo, Amazonlisted, StorePricing, ItemVatMaster, \
21
    PageViewEvents, CartEvents, EbayItem, BannerUriMapping, Campaign, SnapdealItem, \
21
    PageViewEvents, CartEvents, EbayItem, BannerUriMapping, Campaign, SnapdealItem, \
22
    ProductFeedSubmit, MarketplaceItems, MarketPlaceItemPrice, \
22
    ProductFeedSubmit, MarketplaceItems, MarketPlaceItemPrice, \
23
    SourcePercentageMaster, SourceItemPercentage, FlipkartItem, MarketPlaceUpdateHistory, \
23
    SourcePercentageMaster, SourceItemPercentage, FlipkartItem, \
24
    SourceCategoryPercentage, MarketPlaceHistory, PrivateDeals
24
    MarketPlaceUpdateHistory, SourceCategoryPercentage, MarketPlaceHistory, \
-
 
25
    PrivateDeals
25
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
26
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
26
    ItemType, PremiumType, FreebieItem as t_FreebieItem, \
27
    ItemType, PremiumType, FreebieItem as t_FreebieItem, \
27
    StorePricing as tStorePricing, CatalogServiceException, \
28
    StorePricing as tStorePricing, CatalogServiceException, BannerType, InsurerType, \
28
    BannerType, InsurerType, Banner as t_banner
29
    Banner as t_banner
29
from shop2020.thriftpy.model.v1.inventory.ttypes import \
30
from shop2020.thriftpy.model.v1.inventory.ttypes import \
30
    InventoryServiceException, IgnoredInventoryUpdateItems,SnapdealInventoryItem
31
    InventoryServiceException, IgnoredInventoryUpdateItems, SnapdealInventoryItem
31
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
32
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
32
from shop2020.utils import EmailAttachmentSender
33
from shop2020.utils import EmailAttachmentSender
33
from shop2020.utils.EmailAttachmentSender import mail
34
from shop2020.utils.EmailAttachmentSender import mail
34
from shop2020.utils.Utils import to_py_date, log_risky_flag
35
from shop2020.utils.Utils import to_py_date, log_risky_flag
35
from sqlalchemy import desc, asc
36
from sqlalchemy import desc, asc
36
from sqlalchemy.sql.expression import or_, distinct, func, and_
37
from sqlalchemy.sql.expression import or_, distinct, func, and_
-
 
38
from sqlalchemy.sql.functions import now
37
from string import Template
39
from string import Template
38
import datetime
40
import datetime
39
import math
41
import math
40
import sys
42
import sys
41
import threading
43
import threading
Line 2648... Line 2650...
2648
 
2650
 
2649
def get_private_deal_items(offset,limit):
2651
def get_private_deal_items(offset,limit):
2650
    print session.query(Item).join((PrivateDeals,Item.id==PrivateDeals.item_id)).offset(offset).limit(limit).all()
2652
    print session.query(Item).join((PrivateDeals,Item.id==PrivateDeals.item_id)).offset(offset).limit(limit).all()
2651
    return session.query(Item).join((PrivateDeals,Item.id==PrivateDeals.item_id)).offset(offset).limit(limit).all()
2653
    return session.query(Item).join((PrivateDeals,Item.id==PrivateDeals.item_id)).offset(offset).limit(limit).all()
2652
 
2654
 
-
 
2655
def get_all_active_private_deals():
-
 
2656
        dealsMap = dict() 
-
 
2657
        all_active_private_deals = session.query(PrivateDeals).filter(now().between(PrivateDeals.startDate, PrivateDeals.endDate + datetime.timedelta(days=1))).all()
-
 
2658
        if all_active_private_deals is not None:
-
 
2659
            for active_private_deal in all_active_private_deals:
-
 
2660
                dealsMap[active_private_deal.item_id] = to_t_private_deal(active_private_deal)
-
 
2661
        return dealsMap 
-
 
2662
 
2653
def add_or_update_private_deal(privatedeal):
2663
def add_or_update_private_deal(privatedeal):
2654
    try:
2664
    try:
2655
        deal =  PrivateDeals.get_by(item_id=privatedeal.item_id)
2665
        deal =  PrivateDeals.get_by(item_id=privatedeal.item_id)
2656
        if deal is None:
2666
        if deal is None:
2657
            deal = PrivateDeals()
2667
            deal = PrivateDeals()