diff --git a/SQL/site_data.sql b/SQL/site_data.sql index a7653c8..0660565 100644 --- a/SQL/site_data.sql +++ b/SQL/site_data.sql @@ -82,6 +82,44 @@ CREATE TABLE products ( ALTER TABLE products ADD banner VARCHAR(100); UPDATE products set banner = 'p'||id||'.jpg' + + CREATE TABLE products_details ( + id SERIAL, + product_id VARCHAR(25) UNIQUE REFERENCES products(product_id), + details TEXT, + added timestamp without time zone DEFAULT now() + ); + ALTER TABLE ONLY products_details + ADD CONSTRAINT products_details_id_key UNIQUE (id); + +ALTER TABLE products_details OWNER TO merms_panel; + + +INSERT INTO products_details (product_id,details) VALUES( +'A000002', +' +A Professional Website service utilizing AI tools offers a comprehensive solution for individuals and businesses looking to establish a robust online presence. Here are some key features typically included in such a service: + +1. **AI-Powered Design**: The service often employs AI algorithms to help create aesthetically pleasing and user-friendly designs. Users can enter their preferences and the tools will generate layout suggestions, color schemes, and typography that best match their brand identity. + +2. **Content Generation**: With AI-driven content creation tools, users can receive assistance in writing engaging website copy, blog posts, and product descriptions. These tools can analyze successful content in similar industries and generate text that aligns with SEO best practices. + +3. **SEO Optimization**: AI tools can help optimize websites for search engines by analyzing keywords, providing suggestions for improving visibility, and optimizing site architecture. This ensures that the website ranks well and attracts organic traffic. + +4. **Chatbots for Customer Engagement**: Implementing AI chatbots allows businesses to provide instant support to visitors. These bots can answer common questions, guide users through the website, and enhance the overall customer experience. + +5. **Analytics and Insights**: Advanced AI analytics can track user behavior, providing insights into how visitors interact with the site. This data helps businesses make informed decisions on improvements and marketing strategies. + +6. **Personalization**: Using AI, websites can personalize user experiences based on behavior and preferences. This could include tailored recommendations, customized content, and targeted marketing campaigns that increase engagement. + +7. **E-commerce Solutions**: For those looking to sell online, AI tools can optimize the shopping experience by providing product recommendations, personalized discounts, and streamlined check-out processes. + +8. **Maintenance and Support**: Many services offer ongoing support and automatic updates using AI to monitor site performance, ensuring that the website runs smoothly and is protected against threats. By leveraging these AI tools, the Professional Website service can deliver not only visually appealing and functional websites but also enhance user engagement, improve operational efficiency, and drive growth for businesses. +' +); + + + CREATE TABLE members_products ( id SERIAL, uid uuid DEFAULT uuid_generate_v4(), diff --git a/app/api/services/myproduct.py b/app/api/services/myproduct.py index 4665a35..1c95c08 100644 --- a/app/api/services/myproduct.py +++ b/app/api/services/myproduct.py @@ -7,7 +7,7 @@ from marshmallow import ValidationError from app.api.enums import TransactionType from app.api.integrations import SimbrellaIntegration from app.extensions import db -from app.models import MembersProducts, Products, Members +from app.models import MembersProducts, Products, Members, ProductsDetails from app.api.services.offer_analysis import OfferAnalysis from app.api.helpers.response_helper import ResponseHelper @@ -56,16 +56,17 @@ class MyProductsService(BaseService): merms_panel=# - + "Product Description - Commitment is something that comes from understanding that everything has its price and then having the willingness to pay that price. This is important because nobody wants to put significant effort into something, only to find out after the fact that the price was too high.The price is something not necessarily defined as financial. It could be time, effort, sacrifice, money or perhaps, something else.", + ''' product_data = Products.get_product_by_product_id(product_id) - + product_description = ProductsDetails.get_product_desctiption_by_product_id('A000002') # "banner": "banner.jpg", myproduct_data = { "myproudct": { "banner": product_data.banner, - "description": "Product Description - Commitment is something that comes from understanding that everything has its price and then having the willingness to pay that price. This is important because nobody wants to put significant effort into something, only to find out after the fact that the price was too high.The price is something not necessarily defined as financial. It could be time, effort, sacrifice, money or perhaps, something else.", + "description": product_description, "internal_url": "", "price_text": "90 days free and 3.95/Month", "product_id": product_data.product_id, diff --git a/app/api/services/products.py b/app/api/services/products.py index eaa1794..464fc5b 100644 --- a/app/api/services/products.py +++ b/app/api/services/products.py @@ -1,4 +1,7 @@ from flask import session, jsonify + +from app.api.routes.routes import myproduct_url +from app.api.services import MyProductsService from app.models.loan import Loan from app.utils.logger import logger from app.api.services.base_service import BaseService @@ -128,6 +131,7 @@ class ProductsService(BaseService): product_data=[] logger.info(f"Product Data ****** *****: {products}") + for t in products: product_data.append({ 'id': t.id, diff --git a/app/models/__init__.py b/app/models/__init__.py index 083f0a0..4e5bdc6 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -16,9 +16,9 @@ from .products import Products from .members_products import MembersProducts from .members_actions import MembersActions from .members_pending import MembersPending - +from .products_details import ProductsDetails __all__ = ['Members','Customer', 'Account', 'Products', - 'MembersProducts', 'MembersActions', 'MembersPending', 'Loan', 'Transaction', 'Repayment', + 'MembersProducts', 'MembersActions', 'MembersPending', 'ProductsDetails', 'Loan', 'Transaction', 'Repayment', 'LoanCharge', 'Offer', 'Charge', 'RACCheck', 'LoanRepaymentSchedule', 'TransactionOffer', 'RepaymentsData', 'Salary'] \ No newline at end of file diff --git a/app/models/members_products.py b/app/models/members_products.py index a1a1b81..d3f5959 100644 --- a/app/models/members_products.py +++ b/app/models/members_products.py @@ -36,9 +36,8 @@ class MembersProducts(db.Model): @classmethod def get_member_productlist_by_member_id(cls, member_id): member_products = cls.query.filter_by(member_id=str(member_id)) - if not member_products: - raise ValueError(f"Products for member_id = {member_id} not found") + return None return member_products diff --git a/app/models/products_details.py b/app/models/products_details.py new file mode 100644 index 0000000..baf7805 --- /dev/null +++ b/app/models/products_details.py @@ -0,0 +1,54 @@ +from datetime import datetime, timezone, timedelta +from itertools import product +from app.extensions import db +from app.models.customer import Customer +from app.models.account import Account +from sqlalchemy.exc import IntegrityError +from sqlalchemy.orm import relationship +from dateutil.relativedelta import relativedelta +from datetime import timedelta +import logging +from sqlalchemy import and_, or_, not_ +from sqlalchemy.sql import func +import json + +logger = logging.getLogger(__name__) + +class ProductsDetails(db.Model): + __tablename__ = 'products' + + id = db.Column( + db.Integer, + primary_key=True, + autoincrement=True, + ) + + product_id = db.Column(db.String(25), nullable=False) + details = db.Column(db.String(5000), nullable=False) + added = db.Column(db.DateTime(timezone=True), server_default=func.now()) + + + @classmethod + def get_product_details_with_product_id(cls, product_id): + """ + Get customer's active loans by loan_id. + """ + productItem = cls.query.filter_by(product_id = product_id).first() + if not productItem: + raise ValueError(f"pProduct with ID {product_id} does not exist.") + return productItem + + + def to_dict(self): + """ + Convert the Loan object to a dictionary format for JSON serialization. + """ + return { + 'id': self.id, + 'product_id': self.product_id, + 'details': self.details, + 'added': self.added + } + + def __repr__(self): + return f''