[add]: loan status
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from flask import request, jsonify
|
||||
from marshmallow import ValidationError
|
||||
from app.models import Customer
|
||||
from app.utils.logger import logger
|
||||
from app.api.schemas.loan_status import LoanStatusSchema
|
||||
from app.api.services.base_service import BaseService
|
||||
@@ -25,6 +26,15 @@ class LoanStatusService(BaseService):
|
||||
with db.session.begin():
|
||||
validated_data = LoanStatusService.validate_data(data, LoanStatusSchema())
|
||||
customer_id = validated_data.get('customerId')
|
||||
customer = Customer.get_customer(customer_id)
|
||||
transactionId = validated_data.get('transactionId')
|
||||
|
||||
loans = customer.loans
|
||||
|
||||
db.session.flush()
|
||||
|
||||
validated_data['refId'] = customer.id
|
||||
validated_data['refModel'] = "customer"
|
||||
|
||||
transaction = LoanStatusService.log_transaction(validated_data = validated_data)
|
||||
|
||||
@@ -35,23 +45,23 @@ class LoanStatusService(BaseService):
|
||||
}), 400
|
||||
|
||||
|
||||
loans = [
|
||||
{
|
||||
"debtId": "123456789",
|
||||
"loanDate": "2019-10-18 14:26:21.063",
|
||||
"dueDate": "2019-11-20 14:26:21.063",
|
||||
"currentLoanAmount": 8500,
|
||||
"initialLoanAmount": 10000,
|
||||
"defaultPenaltyFee": 0,
|
||||
"continuousFee": 0,
|
||||
"productId": "101"
|
||||
}
|
||||
]
|
||||
# loans = [
|
||||
# {
|
||||
# "debtId": "123456789",
|
||||
# "loanDate": "2019-10-18 14:26:21.063",
|
||||
# "dueDate": "2019-11-20 14:26:21.063",
|
||||
# "currentLoanAmount": 8500,
|
||||
# "initialLoanAmount": 10000,
|
||||
# "defaultPenaltyFee": 0,
|
||||
# "continuousFee": 0,
|
||||
# "productId": "101"
|
||||
# }
|
||||
# ]
|
||||
|
||||
# Simulated processing logic
|
||||
response_data = {
|
||||
"customerId": "CN621868",
|
||||
"transactionId": "Tr201712RK9232P115",
|
||||
"customerId": customer_id,
|
||||
"transactionId": transactionId,
|
||||
"loans": loans,
|
||||
"totalDebtAmount": 8500,
|
||||
"resultCode": "00",
|
||||
|
||||
Reference in New Issue
Block a user