Subversion Repositories SmartDukaan

Rev

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

Rev 8733 Rev 8734
Line 4492... Line 4492...
4492
    if amount == 0:
4492
    if amount == 0:
4493
        return
4493
        return
4494
    
4494
    
4495
    history = None
4495
    history = None
4496
    if updateType == 1 and amount > 0 :
4496
    if updateType == 1 and amount > 0 :
4497
        history = UserWalletHistory.query.filter_by(orderId = orderId).filter_by(amount = -amount).first()
4497
        history = UserWalletHistory.query.filter_by(orderId = orderId).filter_by(amount = -amount).order_by(UserWalletHistory.id.desc()).first()
4498
        if history is None:
4498
        if history is None:
4499
            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)
4500
            return
4500
            return
-
 
4501
 
4501
        
4502
    """
4502
        histories = UserWalletHistory.query.filter_by(orderId = orderId).filter_by(amount = amount).all()
-
 
4503
        if len(histories) > 0:
4503
    TODO check if successful payment available or Not
4504
            print 'Already credited to wallet for recharge Id : ' + str(orderId)
-
 
4505
            return
-
 
4506
    
-
 
4507
    elif updateType == 0 :
4504
    elif updateType == 0 :
4508
        baseorder = BaseOrder.query.filter_by(id = orderId).first()
4505
        baseorder = BaseOrder.query.filter_by(id = orderId).first()
4509
        if baseorder :
4506
        if baseorder :
4510
            try :
4507
            try :
4511
                pc = PaymentClient().get_client()
4508
                pc = PaymentClient().get_client()
4512
                payment = pc.getPaymentForRechargeTxnId(baseorder.transaction.id)
4509
                payments = pc.getPaymentForRechargeTxnId(baseorder.transaction.id)
4513
            except Exception as e:
4510
            except Exception as e:
4514
                print e
4511
                print e
4515
                return
4512
                return
-
 
4513
            for payment in payments :
4516
            if payment.status != 2 :
4514
                if payment.status == 2 :
4517
                return
4515
                    break
4518
        else :
4516
        else :
4519
            return
4517
            return
4520
        
4518
      """  
4521
    wallet = get_user_wallet(userId)
4519
    wallet = get_user_wallet(userId)
4522
    wallet.amount = wallet.amount + amount
4520
    wallet.amount = wallet.amount + amount
4523
    
4521
    
4524
    history = UserWalletHistory()
4522
    history = UserWalletHistory()
4525
    history.amount = amount
4523
    history.amount = amount