Exemple #1
0
def edit_dkfk(id):
    try:
        #保存SC_Approval_Decision剩余信息
        approval_decision = SC_Approval_Decision.query.filter_by(loan_apply_id=id).first()
        approval_decision.loan_date = request.form['loan_date']
        approval_decision.first_repayment_date = request.form['first_repayment_date']
        #approval_decision.management_coats = request.form['management_coats']
        #approval_decision.agency_coats = request.form['agency_coats']
        approval_decision.contract_date = request.form['contract_date']
        approval_decision.loan_account = request.form['loan_account']
        #approval_decision.bank_customer_no = request.form['bank_customer_no']
        approval_decision.loan_contract_number = request.form['loan_contract_number']
        approval_decision.guarantee_contract_number = request.form['guarantee_contract_number']
        approval_decision.collateral_contract_number = request.form['collateral_contract_number']

        #保存还款计划
        repayment_plan_id = 0
        repayment_plan = SC_Repayment_Plan.query.filter_by(loan_apply_id=id).first()
        if repayment_plan:
            repayment_plan_id = repayment_plan.id
            repayment_plan.repayment_type=request.form['repayment_type']
            repayment_plan.amount=request.form['amount']
            repayment_plan.lending_date=request.form['loan_date']
            repayment_plan.first_repayment_date=request.form['first_repayment_date']
            repayment_plan.ratio=request.form['rates']
            repayment_plan.installmenst=request.form['deadline']
            repayment_plan.modify_user=current_user.id
            repayment_plan.modify_date=datetime.datetime.now()
        else:
            repayment_plan_new = SC_Repayment_Plan(id,request.form['repayment_type'],request.form['amount'],
                request.form['loan_date'],request.form['loan_date'],request.form['rates'],
                request.form['deadline'])
            repayment_plan_new.add()
            db.session.flush()
            repayment_plan_id = repayment_plan_new.id

        #保存还款细则
        SC_Repayment_plan_detail.query.filter_by(loan_apply_id=id,change_record=1).delete()
        db.session.flush()
        for i in range(1,int(request.form['deadline'])+1):
            SC_Repayment_plan_detail(repayment_plan_id,id,None,request.form['rates'],
                request.form['mybj%d' % i],request.form['mylx%d' % i],
                request.form['mybx%d' % i],i,request.form['myrq%d' % i],None,1).add() 

        loan_apply = SC_Loan_Apply.query.filter_by(id=id).first()
        loan_apply.process_status = PROCESS_STATUS_DKFKJH

        # 事务提交
        db.session.commit()
        #计算绩效
        reckonIncome(id)
        # 消息闪现
        flash('保存成功','success')
    except:
        # 回滚
        db.session.rollback()
        logger.exception('exception')
        # 消息闪现 
        flash('保存失败','error')
    return redirect("Process/dkfk/dkfk")    
Exemple #2
0
def do_excel_import(id):
    try:
        # A岗 B岗 运营岗
        A_loan_officer = request.form["A_loan_officer"]
        B_loan_officer = request.form["B_loan_officer"]
        yunying_loan_officer = request.form["yunying_loan_officer"]

        # 贷审会
        examiner_1 = request.form["examiner_1"]
        examiner_2 = request.form["examiner_2"]
        approver = request.form["approver"]

        # 读文件 存DB
        localexcel = SC_Local_Excel.query.filter_by(id=id).first()
        file = os.path.join(LOCALEXCEL_FOLDER_ABS, "%d\\%s" % (current_user.id, localexcel.attachment))
        loan_apply_id = record.read_file(
            file, A_loan_officer, B_loan_officer, yunying_loan_officer, examiner_1, examiner_2, approver
        )

        # 保存SC_Approval_Decision剩余信息
        approval_decision = SC_Approval_Decision(
            loan_apply_id,
            None,
            1,
            request.form["amount"],
            request.form["deadline"],
            request.form["rates"],
            request.form["repayment_type"],
            5000,
            1,
            1,
            1,
            "",
            "",
            "",
        )
        approval_decision.add()
        db.session.flush()

        # approval_decision = SC_Approval_Decision.query.filter_by(loan_apply_id=loan_apply_id).first()
        approval_decision.loan_date = request.form["loan_date"]
        approval_decision.first_repayment_date = request.form["first_repayment_date"]
        # approval_decision.management_coats = request.form['management_coats']
        # approval_decision.agency_coats = request.form['agency_coats']
        approval_decision.contract_date = request.form["contract_date"]
        approval_decision.loan_account = request.form["loan_account"]
        # approval_decision.bank_customer_no = request.form['bank_customer_no']
        approval_decision.loan_contract_number = request.form["loan_contract_number"]
        approval_decision.guarantee_contract_number = request.form["guarantee_contract_number"]
        approval_decision.collateral_contract_number = request.form["collateral_contract_number"]

        # 保存还款计划
        repayment_plan_id = 0
        repayment_plan = SC_Repayment_Plan(
            id,
            request.form["repayment_type"],
            request.form["amount"],
            request.form["loan_date"],
            request.form["loan_date"],
            request.form["rates"],
            request.form["deadline"],
        )
        repayment_plan.add()
        db.session.flush()
        repayment_plan.create_user = current_user.id
        repayment_plan.create_date = datetime.datetime.now()
        repayment_plan.modify_user = current_user.id
        repayment_plan.modify_date = datetime.datetime.now()

        repayment_plan_id = repayment_plan.id

        # 保存还款细则
        SC_Repayment_plan_detail.query.filter_by(loan_apply_id=loan_apply_id, change_record=1).delete()
        db.session.flush()
        for i in range(1, int(request.form["deadline"]) + 1):
            SC_Repayment_plan_detail(
                repayment_plan_id,
                id,
                None,
                request.form["rates"],
                request.form["mybj%d" % i],
                request.form["mylx%d" % i],
                request.form["mybx%d" % i],
                i,
                request.form["myrq%d" % i],
                None,
                1,
            ).add()

        # 是否已同步
        localexcel.is_sync = 1

        # 事务提交
        db.session.commit()
        # 消息闪现
        flash("保存成功", "success")
    except:
        # 回滚
        db.session.rollback()
        logger.exception("exception")
        # 消息闪现
        flash("保存失败", "error")

    return redirect("Data/data_excel")