Subversion Repositories SmartDukaan

Rev

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

Rev 13941 Rev 14134
Line 10... Line 10...
10
from shop2020.model.v1.order.impl.Convertors import to_t_transaction, to_t_alert, \
10
from shop2020.model.v1.order.impl.Convertors import to_t_transaction, to_t_alert, \
11
    to_t_order, to_t_lineitem, to_t_payment_settlement, to_t_verification_agent, \
11
    to_t_order, to_t_lineitem, to_t_payment_settlement, to_t_verification_agent, \
12
    to_t_attribute, to_t_rechargeTransaction, to_t_frc, to_t_hotspot, \
12
    to_t_attribute, to_t_rechargeTransaction, to_t_frc, to_t_hotspot, \
13
    to_t_sourcedetail, to_t_amazonorder, to_t_storeOrderDetail, \
13
    to_t_sourcedetail, to_t_amazonorder, to_t_storeOrderDetail, \
14
    to_t_storeOrderCollection, to_t_hotspotServiceMatrix, to_t_ebayOrder, \
14
    to_t_storeOrderCollection, to_t_hotspotServiceMatrix, to_t_ebayOrder, \
15
    to_t_amazonFbaSalesSnapshot, to_t_snapdealOrder, to_t_flipkartOrder,  \
15
    to_t_amazonFbaSalesSnapshot, to_t_snapdealOrder, to_t_flipkartOrder, \
16
    to_t_amazonFbaOrderReturn, to_t_flipkartAdvantageOrder, to_t_hsOrder
16
    to_t_amazonFbaOrderReturn, to_t_flipkartAdvantageOrder, to_t_hsOrder
17
from shop2020.model.v1.order.impl.DataAccessors import create_transaction, \
17
from shop2020.model.v1.order.impl.DataAccessors import create_transaction, \
18
    get_transactions_for_customer, get_transaction_status, get_line_items_for_order, \
18
    get_transactions_for_customer, get_transaction_status, get_line_items_for_order, \
19
    get_transaction, get_transactions_for_shopping_cart_id, \
19
    get_transaction, get_transactions_for_shopping_cart_id, \
20
    change_transaction_status, get_orders_for_customer, get_orders_for_transaction, \
20
    change_transaction_status, get_orders_for_customer, get_orders_for_transaction, \
Line 106... Line 106...
106
    flipkart_fa_order_exists, get_recharge_order_status, \
106
    flipkart_fa_order_exists, get_recharge_order_status, \
107
    get_recharge_transaction_status, accept_package_orders, \
107
    get_recharge_transaction_status, accept_package_orders, \
108
    get_group_orders_by_logistics_txn_id, add_billing_details_for_groupped_orders, \
108
    get_group_orders_by_logistics_txn_id, add_billing_details_for_groupped_orders, \
109
    get_invoice_format_logistics_txn_id, homeshop_order_exists, \
109
    get_invoice_format_logistics_txn_id, homeshop_order_exists, \
110
    create_homeshop_order, get_homeshop_order
110
    create_homeshop_order, get_homeshop_order
111
    
-
 
-
 
111
from shop2020.model.v1.order.impl.DataService import DtrBatchCreditTracker
112
from shop2020.model.v1.order.impl.model.DTHRechargeOrder import DTHRechargeOrder
112
from shop2020.model.v1.order.impl.model.DTHRechargeOrder import DTHRechargeOrder
113
from shop2020.model.v1.order.impl.model.DigitalTransaction import \
113
from shop2020.model.v1.order.impl.model.DigitalTransaction import \
114
    DigitalTransaction
114
    DigitalTransaction
115
from shop2020.model.v1.order.impl.model.MobileRechargeOrder import \
115
from shop2020.model.v1.order.impl.model.MobileRechargeOrder import \
116
    MobileRechargeOrder
116
    MobileRechargeOrder
-
 
117
from shop2020.model.v1.order.impl.model.UserWalletHistory import \
-
 
118
    UserWalletHistory
117
from shop2020.model.v1.user.impl.Converters import to_t_address
119
from shop2020.model.v1.user.impl.Converters import to_t_address
118
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
120
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException, \
119
    RechargeType, AmazonOrdersToAcknowledge
121
    RechargeType, AmazonOrdersToAcknowledge
120
from shop2020.utils.Utils import to_py_date, get_fdate_tdate, to_java_date
122
from shop2020.utils.Utils import to_py_date, get_fdate_tdate, to_java_date
121
import datetime
123
import datetime
122
import json
124
import json
123
    
125
    
124
    
126
    
-
 
127
    
125
 
128
 
126
 
129
 
127
 
130
 
128
 
131
 
129
class OrderServiceHandler:
132
class OrderServiceHandler:
Line 2602... Line 2605...
2602
            return is_alive()
2605
            return is_alive()
2603
        finally:
2606
        finally:
2604
            close_session()
2607
            close_session()
2605
    
2608
    
2606
    def creditBatch(self, batchId, userAmount):
2609
    def creditBatch(self, batchId, userAmount):
2607
        for key, amount in json.loads(userAmount).iteritems():
-
 
2608
            userId = int(key)
-
 
2609
            print userId
-
 
2610
            print amount
-
 
2611
            
-
 
2612
2610
        try:
-
 
2611
            now = datetime.datetime.now()
-
 
2612
            sum = 0
-
 
2613
            for key, amount in json.loads(userAmount).iteritems():
-
 
2614
                userId = int(key)
-
 
2615
                wallet = get_user_wallet(userId)
-
 
2616
                wallet.amount = wallet.amount + amount
-
 
2617
                history = UserWalletHistory()
-
 
2618
                history.amount = amount
-
 
2619
                history.orderId = batchId
-
 
2620
                history.wallet = wallet
-
 
2621
                history.timestamp = now
-
 
2622
                sum += amount
-
 
2623
                
-
 
2624
            batchCreditTracker = DtrBatchCreditTracker()
-
 
2625
            batchCreditTracker.id = batchId
-
 
2626
            batchCreditTracker.amount = sum
-
 
2627
            batchCreditTracker.creditedOn = now
-
 
2628
                 
-
 
2629
            session.commit()
-
 
2630
        finally:
-
 
2631
            close_session()
-
 
2632
          
-
 
2633
def main():
-
 
2634
    OrderServiceHandler().creditBatch(2, '{"483649":100.0, "8021773":23, "123213":10}')
-
 
2635
            
-
 
2636
if __name__ == '__main__':
-
 
2637
    main()
-
 
2638
2613
2639