62 lines
1.9 KiB
Python
62 lines
1.9 KiB
Python
from flask import request, jsonify
|
|
from marshmallow import ValidationError
|
|
from app.utils.logger import logger
|
|
from app.api.helpers.response_helper import ResponseHelper
|
|
from app.api.schemas.collect_loan import CollectLoanSchema
|
|
|
|
class CollectLoanService:
|
|
@staticmethod
|
|
def process_request(data):
|
|
"""
|
|
Process the CollectLoan request.
|
|
|
|
Args:
|
|
data (dict): The request data.
|
|
|
|
Returns:
|
|
dict: A standardized response.
|
|
"""
|
|
try:
|
|
logger.info("Processing CollectLoan request")
|
|
|
|
# Validate input data using CollectLoanSchema
|
|
schema = CollectLoanSchema()
|
|
validated_data = schema.load(data)
|
|
|
|
# Simulated processing logic
|
|
response_data = {
|
|
"transactionId": "T002",
|
|
"debtId": "273194670",
|
|
"customerId": "CN621868",
|
|
"accountId": "2017821799",
|
|
"productId": "101",
|
|
"collectAmount": 60000.00,
|
|
"penalCharge": 0,
|
|
"lienAmount": 20000,
|
|
"countryId": "01",
|
|
"comment": "Testing CollectionLoanRequest",
|
|
"resultCode": "00",
|
|
"resultDescription": "Loan Collection Successful"
|
|
}
|
|
|
|
|
|
# return ResponseHelper.success(
|
|
# data=response_data,
|
|
# message="Loan collection completed successfully"
|
|
# )
|
|
|
|
return response_data
|
|
|
|
except ValidationError as err:
|
|
logger.error(f"Validation Error: {err.messages}")
|
|
return jsonify({
|
|
"message": "Validation exception"
|
|
}) , 422
|
|
|
|
|
|
except Exception as e:
|
|
logger.error(f"An error occurred: {str(e)}", exc_info=True)
|
|
return jsonify({
|
|
"message": "Internal Server Error"
|
|
}) , 500
|