Subversion Repositories SmartDukaan

Rev

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

Rev 11592 Rev 11606
Line 18... Line 18...
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, \
23
    SourcePercentageMaster, SourceItemPercentage, FlipkartItem, MarketPlaceUpdateHistory, \
24
    MarketPlaceUpdateHistory, SourceCategoryPercentage, MarketPlaceHistory, \
24
    SourceCategoryPercentage, MarketPlaceHistory, PrivateDeals
25
    PrivateDeals
-
 
26
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
25
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
27
    ItemType, PremiumType, FreebieItem as t_FreebieItem, \
26
    ItemType, PremiumType, FreebieItem as t_FreebieItem, \
28
    StorePricing as tStorePricing, CatalogServiceException, BannerType, InsurerType, \
27
    StorePricing as tStorePricing, CatalogServiceException, \
29
    Banner as t_banner
28
    BannerType, InsurerType, Banner as t_banner
30
from shop2020.thriftpy.model.v1.inventory.ttypes import \
29
from shop2020.thriftpy.model.v1.inventory.ttypes import \
31
    InventoryServiceException, IgnoredInventoryUpdateItems, SnapdealInventoryItem
30
    InventoryServiceException, IgnoredInventoryUpdateItems,SnapdealInventoryItem
32
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
31
from shop2020.thriftpy.model.v1.order.ttypes import OrderSource
33
from shop2020.utils import EmailAttachmentSender
32
from shop2020.utils import EmailAttachmentSender
34
from shop2020.utils.EmailAttachmentSender import mail
33
from shop2020.utils.EmailAttachmentSender import mail
35
from shop2020.utils.Utils import to_py_date, log_risky_flag
34
from shop2020.utils.Utils import to_py_date, log_risky_flag
36
from sqlalchemy import desc, asc
35
from sqlalchemy import desc, asc
37
from sqlalchemy.sql.expression import or_, distinct, func, and_
36
from sqlalchemy.sql.expression import or_, distinct, func, and_
38
from sqlalchemy.sql.functions import now
-
 
39
from string import Template
37
from string import Template
40
import datetime
38
import datetime
41
import math
39
import math
42
import sys
40
import sys
43
import threading
41
import threading
Line 2659... Line 2657...
2659
            for active_private_deal in all_active_private_deals:
2657
            for active_private_deal in all_active_private_deals:
2660
                dealsMap[active_private_deal.item_id] = to_t_private_deal(active_private_deal)
2658
                dealsMap[active_private_deal.item_id] = to_t_private_deal(active_private_deal)
2661
        return dealsMap 
2659
        return dealsMap 
2662
 
2660
 
2663
def add_or_update_private_deal(privatedeal):
2661
def add_or_update_private_deal(privatedeal):
-
 
2662
    print 'Inside update private deals'
2664
    try:
2663
    try:
2665
        deal =  PrivateDeals.get_by(item_id=privatedeal.item_id)
2664
        deal =  PrivateDeals.get_by(item_id=privatedeal.item_id)
2666
        if deal is None:
2665
        if deal is None:
2667
            deal = PrivateDeals()
2666
            deal = PrivateDeals()
2668
            deal.item_id = privatedeal.item_id
2667
            deal.item_id = privatedeal.item_id
Line 2673... Line 2672...
2673
            deal.dealTextOption = privatedeal.dealTextOption
2672
            deal.dealTextOption = privatedeal.dealTextOption
2674
            deal.dealText = privatedeal.dealText
2673
            deal.dealText = privatedeal.dealText
2675
            deal.isCod =  privatedeal.isCod
2674
            deal.isCod =  privatedeal.isCod
2676
            deal.rank = privatedeal.rank
2675
            deal.rank = privatedeal.rank
2677
            deal.dealFreebieOption = privatedeal.dealFreebieOption
2676
            deal.dealFreebieOption = privatedeal.dealFreebieOption
-
 
2677
            deal.isActive = privatedeal.isActive  
2678
        else:
2678
        else:
2679
            deal.dealFreebieItemId = privatedeal.dealFreebieItemId  
2679
            deal.dealFreebieItemId = privatedeal.dealFreebieItemId  
2680
            deal.dealPrice = privatedeal.dealPrice
2680
            deal.dealPrice = privatedeal.dealPrice
2681
            deal.startDate =  to_py_date(privatedeal.startDate)
2681
            deal.startDate =  to_py_date(privatedeal.startDate)
2682
            deal.endDate = to_py_date(privatedeal.endDate)
2682
            deal.endDate = to_py_date(privatedeal.endDate)
2683
            deal.isDealTextIdentical = privatedeal.isDealTextIdentical
2683
            deal.dealTextOption = privatedeal.dealTextOption
2684
            deal.dealText = privatedeal.dealText
2684
            deal.dealText = privatedeal.dealText
2685
            deal.isCod =  privatedeal.isCod
2685
            deal.isCod =  privatedeal.isCod
2686
            deal.rank = privatedeal.rank
2686
            deal.rank = privatedeal.rank
2687
            deal.dealFreebieOption = privatedeal.dealFreebieOption
2687
            deal.dealFreebieOption = privatedeal.dealFreebieOption
-
 
2688
            deal.isActive = privatedeal.isActive
2688
        session.commit()
2689
        session.commit()
2689
        return True
2690
        return True
2690
    except Exception as e:
2691
    except Exception as e:
-
 
2692
        print 'Exception in updating private deals'
2691
        print e
2693
        print e
2692
        return False
-
 
2693
2694
        return False
-
 
2695