Exemplo n.º 1
0
def doInvestApplyByUserId(id, cursor, db, cnx):
    sys.stdout.write("input loanCode:")
    loanCode = raw_input()
    sys.stdout.write("input investAmount:")
    investAmount = raw_input()

    loan = myfun.getLoanByLoanCode(loanCode, cursor, db)
    investId = str(int(time.time() * 10000))
    investCode = investId
    loanName = loan['LOAN_NAME']
    loanJson = {"loanCode": loanCode, "loanName": loanName}
    investJson = {"investCode": investCode, "investAmount": investAmount}

    #invest
    query = "insert into invest (ID,INVEST_CODE,LOAN_CODE,INVESTMENT_AMOUNT,STATUS,USER_ID) value ('" + investId + "','" + investCode + "','" + loanCode + "','" + investAmount + "','02','" + id + "')"
    cursor.execute(query)

    #paymmentLog
    myfun.insertPaymentLog(id, loanName, investAmount, json.dumps(loanJson),
                           json.dumps(investJson), cursor, db)
    #account
    myfun.updatePaymentAccount(id, investAmount, "-", cursor, db)

    cnx.commit()
    print("success")
Exemplo n.º 2
0
def doLoanRepay(cursor, db, cnx):
    sys.stdout.write("input loanCode:")
    loanCode = raw_input()

    loan = myfun.getLoanByLoanCode(loanCode, cursor, db)
    loanAmount = float(loan['LOAN_AMOUNT'])
    loanInterest = float(loan['LOAN_INTEREST'])
    loanRepayAmount = loanAmount + loanInterest
    userId = loan['APPLY_USER_ID']
    loanCode = loan['LOAN_CODE']
    loanName = loan['LOAN_NAME']
    loanJson = {"loanCode": loanCode, "loanName": loanName}

    #loan
    query = "update loan set LOAN_STATUS='11' where loan_code = '" + loanCode + "'"
    cursor.execute(query)
    #paymmentLog
    myfun.insertPaymentLog(userId, loanName, str(loanRepayAmount),
                           json.dumps(loanJson), "", cursor, db)
    #account
    myfun.updatePaymentAccount(userId, str(loanRepayAmount), "-", cursor, db)

    #invest
    query = "select * from invest where loan_code='" + loanCode + "'"
    cursor.execute(query)
    invests = cursor.fetchall()
    for row in invests:
        investUserId = row['USER_ID']
        investCode = row['INVEST_CODE']
        investPrincipal = float(row['RECEIVABLE_PRINCIPAL'])
        investInterest = float(row['RECEIVABLE_INTEREST'])
        investRepayAmount = investPrincipal + investInterest
        investJson = {
            "investCode": investCode,
            "investAmount": investPrincipal
        }
        query = "update invest set STATUS='09' where invest_code = '" + investCode + "'"
        cursor.execute(query)

        #paymmentLog
        myfun.insertPaymentLog(investUserId, loanName, str(investRepayAmount),
                               json.dumps(loanJson), json.dumps(investJson),
                               cursor, db)
        #account
        myfun.updatePaymentAccount(investUserId, str(investRepayAmount), "+",
                                   cursor, db)

    cnx.commit()
    print("success")
Exemplo n.º 3
0
def doLoanEffect(cursor, db, cnx):
    sys.stdout.write("input loanCode:")
    loanCode = raw_input()

    loan = myfun.getLoanByLoanCode(loanCode, cursor, db)
    loanCode = loan['LOAN_CODE']
    loanName = loan['LOAN_NAME']
    platformFee = float(loan['LOAN_AMOUNT']) * 0.1
    loanEffectAmount = float(loan['LOAN_AMOUNT']) * 0.9
    loanInterest = float(loan['LOAN_AMOUNT']) * 0.1
    userId = loan['APPLY_USER_ID']
    loanJson = {"loanCode": loanCode, "loanName": loanName}

    #loan
    query = "update loan set AMOUNT='" + str(
        loanEffectAmount) + "',LOAN_INTEREST='" + str(
            loanInterest
        ) + "',LOAN_STATUS='10' where loan_code = '" + loanCode + "'"
    cursor.execute(query)

    #invest
    query = "select * from invest where loan_code='" + loanCode + "'"
    cursor.execute(query)
    invests = cursor.fetchall()
    for row in invests:
        investCode = row['INVEST_CODE']
        investPrincipal = float(row['INVESTMENT_AMOUNT'])
        investInterest = float(row['INVESTMENT_AMOUNT']) * 0.1
        query = "update invest set RECEIVABLE_PRINCIPAL='" + str(
            investPrincipal) + "',RECEIVABLE_INTEREST='" + str(
                investInterest
            ) + "',STATUS='07' where invest_code = '" + investCode + "'"
        cursor.execute(query)

    #paymmentLog
    myfun.insertPaymentLog(userId, loanName, str(loanEffectAmount),
                           json.dumps(loanJson), "", cursor, db)
    #account
    myfun.updatePaymentAccount(userId, str(loanEffectAmount), "+", cursor, db)
    myfun.updatePaymentAccount("00", str(platformFee), "+", cursor, db)

    cnx.commit()
    print("success")
Exemplo n.º 4
0
def doLoanRepay(cursor,db,cnx):
    sys.stdout.write("input loanCode:")
    loanCode = raw_input()

    loan = myfun.getLoanByLoanCode(loanCode,cursor,db)    
    loanAmount = float(loan['LOAN_AMOUNT'])
    loanInterest = float(loan['LOAN_INTEREST'])
    loanRepayAmount = loanAmount+loanInterest
    userId = loan['APPLY_USER_ID']    
    loanCode = loan['LOAN_CODE']
    loanName = loan['LOAN_NAME']
    loanJson = {"loanCode":loanCode,"loanName":loanName}

    #loan
    query = "update loan set LOAN_STATUS='11' where loan_code = '"+loanCode+"'"
    cursor.execute(query)
    #paymmentLog
    myfun.insertPaymentLog(userId,loanName,str(loanRepayAmount),json.dumps(loanJson),"",cursor,db)
    #account    
    myfun.updatePaymentAccount(userId,str(loanRepayAmount),"-",cursor,db)
    
    #invest
    query = "select * from invest where loan_code='"+loanCode+"'"
    cursor.execute(query)
    invests = cursor.fetchall()
    for row in invests:
        investUserId  = row['USER_ID']
        investCode  = row['INVEST_CODE']
        investPrincipal = float(row['RECEIVABLE_PRINCIPAL'])
        investInterest  = float(row['RECEIVABLE_INTEREST'])
        investRepayAmount = investPrincipal+investInterest
	investJson = {"investCode":investCode,"investAmount":investPrincipal}
        query = "update invest set STATUS='09' where invest_code = '"+investCode+"'"
        cursor.execute(query)

        #paymmentLog
        myfun.insertPaymentLog(investUserId,loanName,str(investRepayAmount),json.dumps(loanJson),json.dumps(investJson),cursor,db)
        #account    
        myfun.updatePaymentAccount(investUserId,str(investRepayAmount),"+",cursor,db)

    cnx.commit()
    print("success")
Exemplo n.º 5
0
def doInvestApplyByUserId(id,cursor,db,cnx):
    sys.stdout.write("input loanCode:")
    loanCode = raw_input()
    sys.stdout.write("input investAmount:")
    investAmount = raw_input()

    loan = myfun.getLoanByLoanCode(loanCode,cursor,db)
    investId = str(int(time.time()*10000))
    investCode = investId
    loanName = loan['LOAN_NAME']
    loanJson = {"loanCode":loanCode,"loanName":loanName}
    investJson = {"investCode":investCode,"investAmount":investAmount}
    
    #invest
    query = "insert into invest (ID,INVEST_CODE,LOAN_CODE,INVESTMENT_AMOUNT,STATUS,USER_ID) value ('"+investId+"','"+investCode+"','"+loanCode+"','"+investAmount+"','02','"+id+"')"
    cursor.execute(query)

    #paymmentLog
    myfun.insertPaymentLog(id,loanName,investAmount,json.dumps(loanJson),json.dumps(investJson),cursor,db)
    #account
    myfun.updatePaymentAccount(id,investAmount,"-",cursor,db)
    
    cnx.commit()
    print("success")
Exemplo n.º 6
0
def doLoanEffect(cursor,db,cnx):
    sys.stdout.write("input loanCode:")
    loanCode = raw_input()

    loan = myfun.getLoanByLoanCode(loanCode,cursor,db)
    loanCode = loan['LOAN_CODE']
    loanName = loan['LOAN_NAME']
    platformFee = float(loan['LOAN_AMOUNT'])*0.1
    loanEffectAmount = float(loan['LOAN_AMOUNT'])*0.9
    loanInterest = float(loan['LOAN_AMOUNT'])*0.1
    userId = loan['APPLY_USER_ID']    
    loanJson = {"loanCode":loanCode,"loanName":loanName}
    
    #loan
    query = "update loan set AMOUNT='"+str(loanEffectAmount)+"',LOAN_INTEREST='"+str(loanInterest)+"',LOAN_STATUS='10' where loan_code = '"+loanCode+"'"
    cursor.execute(query)
    
    #invest
    query = "select * from invest where loan_code='"+loanCode+"'"
    cursor.execute(query)
    invests = cursor.fetchall()
    for row in invests:
        investCode  = row['INVEST_CODE']
        investPrincipal = float(row['INVESTMENT_AMOUNT'])
        investInterest  = float(row['INVESTMENT_AMOUNT'])*0.1
        query = "update invest set RECEIVABLE_PRINCIPAL='"+str(investPrincipal)+"',RECEIVABLE_INTEREST='"+str(investInterest)+"',STATUS='07' where invest_code = '"+investCode+"'"
        cursor.execute(query)

    #paymmentLog
    myfun.insertPaymentLog(userId,loanName,str(loanEffectAmount),json.dumps(loanJson),"",cursor,db)
    #account
    myfun.updatePaymentAccount(userId,str(loanEffectAmount),"+",cursor,db)
    myfun.updatePaymentAccount("00",str(platformFee),"+",cursor,db)
    
    cnx.commit()
    print("success")