Subversion Repositories SmartDukaan

Rev

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

Rev 8729 Rev 8733
Line 4489... Line 4489...
4489
    UpdateType 1 is for wallet amounts
4489
    UpdateType 1 is for wallet amounts
4490
    and 0 is for payment amounts
4490
    and 0 is for payment amounts
4491
    """
4491
    """
4492
    if amount == 0:
4492
    if amount == 0:
4493
        return
4493
        return
4494
    wallet = get_user_wallet(userId)
-
 
4495
    wallet.amount = wallet.amount + amount
-
 
4496
    
4494
    
4497
    history = None
4495
    history = None
4498
    if updateType == 1 and amount > 0 :
4496
    if updateType == 1 and amount > 0 :
4499
        history = UserWalletHistory.query.filter_by(orderId = orderId).filter_by(amount = -amount).first()
4497
        history = UserWalletHistory.query.filter_by(orderId = orderId).filter_by(amount = -amount).first()
4500
        if history is None:
4498
        if history is None:
4501
            print 'No amount was debited from wallet for recharge Id : ' + str(orderId)
4499
            print 'No amount was debited from wallet for recharge Id : ' + str(orderId)
4502
            return
4500
            return
-
 
4501
        
-
 
4502
        histories = UserWalletHistory.query.filter_by(orderId = orderId).filter_by(amount = amount).all()
-
 
4503
        if len(histories) > 0:
-
 
4504
            print 'Already credited to wallet for recharge Id : ' + str(orderId)
-
 
4505
            return
-
 
4506
    
-
 
4507
    elif updateType == 0 :
-
 
4508
        baseorder = BaseOrder.query.filter_by(id = orderId).first()
-
 
4509
        if baseorder :
-
 
4510
            try :
-
 
4511
                pc = PaymentClient().get_client()
-
 
4512
                payment = pc.getPaymentForRechargeTxnId(baseorder.transaction.id)
-
 
4513
            except Exception as e:
-
 
4514
                print e
-
 
4515
                return
-
 
4516
            if payment.status != 2 :
-
 
4517
                return
-
 
4518
        else :
-
 
4519
            return
-
 
4520
        
-
 
4521
    wallet = get_user_wallet(userId)
-
 
4522
    wallet.amount = wallet.amount + amount
4503
    
4523
    
4504
    history = UserWalletHistory()
4524
    history = UserWalletHistory()
4505
    history.amount = amount
4525
    history.amount = amount
4506
    history.orderId = orderId
4526
    history.orderId = orderId
4507
    history.wallet = wallet
4527
    history.wallet = wallet