Subversion Repositories SmartDukaan

Rev

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

Rev 7084 Rev 7096
Line 4519... Line 4519...
4519
    return query.all()
4519
    return query.all()
4520
 
4520
 
4521
def create_recharge_transaction(t_recharge):
4521
def create_recharge_transaction(t_recharge):
4522
    rechargeTransaction = RechargeTransaction()
4522
    rechargeTransaction = RechargeTransaction()
4523
    rechargeTransaction.amount = t_recharge.amount
4523
    rechargeTransaction.amount = t_recharge.amount
4524
    ##################################
-
 
4525
    #############TODO    rechargeTransaction.circleId = 
4524
    rechargeTransaction.circleId = t_recharge.circleId
4526
    rechargeTransaction.deviceNum = t_recharge.deviceNum
4525
    rechargeTransaction.deviceNum = t_recharge.deviceNum
4527
    rechargeTransaction.deviceType = t_recharge.deviceType
4526
    rechargeTransaction.deviceType = t_recharge.deviceType
4528
    rechargeTransaction.discount = t_recharge.discount
4527
    rechargeTransaction.discount = t_recharge.discount
4529
    rechargeTransaction.email = t_recharge.email
4528
    rechargeTransaction.email = t_recharge.email
4530
    rechargeTransaction.name = t_recharge.name
4529
    rechargeTransaction.name = t_recharge.name
Line 4535... Line 4534...
4535
    rechargeTransaction.storeId = t_recharge.storeId
4534
    rechargeTransaction.storeId = t_recharge.storeId
4536
    rechargeTransaction.transactionTime = datetime.datetime.now()
4535
    rechargeTransaction.transactionTime = datetime.datetime.now()
4537
    rechargeTransaction.operatorId = t_recharge.operatorId
4536
    rechargeTransaction.operatorId = t_recharge.operatorId
4538
    rechargeTransaction.plan = t_recharge.plan
4537
    rechargeTransaction.plan = t_recharge.plan
4539
    rechargeTransaction.ipAddress = t_recharge.ipAddress
4538
    rechargeTransaction.ipAddress = t_recharge.ipAddress
-
 
4539
    rechargeTransaction.paymentAmount = t_recharge.paymentAmount
4540
    session.commit()
4540
    session.commit()
4541
    
4541
    
4542
    store = HotspotStore.get_by(id=rechargeTransaction.storeId)
4542
    store = HotspotStore.get_by(id=rechargeTransaction.storeId)
4543
    wallet = WalletForCompany.get_by(companyId=store.companyId)
4543
    wallet = WalletForCompany.get_by(companyId=store.companyId)
4544
    if store.availableLimit < rechargeTransaction.amount or wallet.amount < rechargeTransaction.amount:
4544
    if store.availableLimit < rechargeTransaction.amount or wallet.amount < rechargeTransaction.amount:
Line 4562... Line 4562...
4562
    rechargeTransaction.spiceTID = spiceTID
4562
    rechargeTransaction.spiceTID = spiceTID
4563
    rechargeTransaction.responseTime = datetime.datetime.now()
4563
    rechargeTransaction.responseTime = datetime.datetime.now()
4564
    rechargeTransaction.description = description
4564
    rechargeTransaction.description = description
4565
    if retCode == '00' and retStatus == 'S':
4565
    if retCode == '00' and retStatus == 'S':
4566
        rechargeTransaction.status = RechargeOrderStatus.RECHARGE_SUCCESSFUL
4566
        rechargeTransaction.status = RechargeOrderStatus.RECHARGE_SUCCESSFUL
-
 
4567
        rechargeTransaction.invoiceNumber = get_next_invoice_number(OrderType.RCH4HOTSPOT)
4567
 
4568
 
4568
    elif retCode in ('STO', 'US', 'UP') and retStatus == 'S':
4569
    elif retCode in ('STO', 'US', 'UP') and retStatus == 'S':
4569
        rechargeTransaction.status = RechargeOrderStatus.RECHARGE_UNKNOWN
4570
        rechargeTransaction.status = RechargeOrderStatus.RECHARGE_UNKNOWN
4570
    else:
4571
    else:
4571
        rechargeTransaction.status = RechargeOrderStatus.RECHARGE_FAILED
4572
        rechargeTransaction.status = RechargeOrderStatus.RECHARGE_FAILED
Line 4594... Line 4595...
4594
    session.commit()
4595
    session.commit()
4595
 
4596
 
4596
    return rechargeTransaction
4597
    return rechargeTransaction
4597
 
4598
 
4598
def get_frcs(circleId, operatorId):
4599
def get_frcs(circleId, operatorId):
4599
    return FRC.query.filter(circleId == circleId).filter(operatorId == operatorId).all()
4600
    frcs = FRC.query.filter(FRC.circleId == circleId).filter(FRC.operatorId == operatorId).all()
-
 
4601
    if frcs is None:
-
 
4602
        return []
-
 
4603
    return frcs
4600
 
4604
 
4601
def get_recharge_transaction(rechargeId):
4605
def get_recharge_transaction(rechargeId):
4602
    recharge = RechargeTransaction.get_by(id = rechargeId)
4606
    recharge = RechargeTransaction.get_by(id = rechargeId)
4603
    if not recharge:
4607
    if not recharge:
4604
        raise TransactionServiceException(108, "no such transaction")
4608
        raise TransactionServiceException(108, "no such transaction")
4605
    return recharge
4609
    return recharge
4606
 
4610
 
-
 
4611
def get_hotspot_store(id, hotspotid):
-
 
4612
    store = None
-
 
4613
    if id > 0:
-
 
4614
        store = HotspotStore.query.filter(HotspotStore.id == id).first()
-
 
4615
    elif len(hotspotid) > 0:
-
 
4616
        store = HotspotStore.query.filter(HotspotStore.hotspotId == hotspotid).first()
-
 
4617
    else:
-
 
4618
        raise TransactionServiceException(119, 'No such store')
-
 
4619
    if store:
-
 
4620
        return store
-
 
4621
    else:
-
 
4622
        raise TransactionServiceException(119, 'No such store')
-
 
4623
 
-
 
4624
def get_circle(id, code):
-
 
4625
    circle = None
-
 
4626
    if id > 0:
-
 
4627
        circle = TelecomCircle.get_by(id = id)
-
 
4628
    elif len(code) > 0:
-
 
4629
        circle = TelecomCircle.get_by(code = code)
-
 
4630
    else:
-
 
4631
        raise TransactionServiceException(119, 'No such circle')
-
 
4632
    if circle:
-
 
4633
        return circle
-
 
4634
    else:
-
 
4635
        raise TransactionServiceException(119, 'No such circle')
-
 
4636
    
-
 
4637
    
-
 
4638
 
4607
if __name__ == '__main__':
4639
if __name__ == '__main__':
4608
    print 'helllo'
4640
    print 'helllo'
4609
4641