CREATE TABLE IF NOT EXISTS `#__marketplace_sellerprofile` (
  `seller_id` int(11) NOT NULL,
  `is_seller` int(1) NOT NULL DEFAULT '0',
  `screenname` varchar(255) NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `gender` varchar(255) NOT NULL,
  `phone` varchar(32) NOT NULL,
  `address` varchar(255) NOT NULL,
  `companybanner` varchar(255) NOT NULL,
  `companylogo` varchar(255) NOT NULL,
  `companylocality` varchar(255) NOT NULL,
  `companyname` varchar(255) NOT NULL,
  `companydescription` text NOT NULL,
  `countrylogo` varchar(255) NOT NULL,
  `state_vm` varchar(255) NOT NULL,
  `zip` varchar(25) NOT NULL,
  `descriptioninhtml` text NOT NULL,
  `commission` decimal(10,2) NOT NULL DEFAULT '20.00',
  `payment_mode` varchar(255) NOT NULL,
  `payment_desc` text NOT NULL,
  `shop_location` varchar(200) NOT NULL,
  `social_mode` varchar(100) NOT NULL,
  `social_id` varchar(100) NOT NULL,
  PRIMARY KEY (`seller_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

CREATE TABLE IF NOT EXISTS `#__marketplace_category_request` (
  `id` int(5) NOT NULL AUTO_INCREMENT,
  `category_name` varchar(255) DEFAULT NULL,
  `category_desc` text,
  `requested_by` varchar(255) DEFAULT NULL,
  `requested_date` datetime DEFAULT NULL,
  `additional_info` text,
  `status` tinyint(4) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `#__marketplace_payments` (
  `id` int(50) NOT NULL AUTO_INCREMENT,
  `seller_id` int(50) NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `remain_amount` decimal(10,2) NOT NULL,
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `currency` int(5) NOT NULL,
  `payment_mode` varchar(20) DEFAULT 'standard',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


CREATE TABLE IF NOT EXISTS `#__marketplace_seller_follower` (
  `f_id` int(20) NOT NULL AUTO_INCREMENT,
  `seller_id` int(20) NOT NULL,
  `follower_email` varchar(100) NOT NULL,
  `date_follow` varchar(500) NOT NULL,
  PRIMARY KEY (`f_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


CREATE TABLE IF NOT EXISTS `#__marketplace_favourite_products` (
  `id` int(20) NOT NULL AUTO_INCREMENT,
  `product_id` int(20) NOT NULL,
  `seller_id` int(20) NOT NULL,
  `buyer_id` int(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `#__marketplace_commision` (
  `commision_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `commision` decimal(10,2) NOT NULL,
  `seller_id` int(11) unsigned NOT NULL,
  `total_sales` decimal(10,2) NOT NULL DEFAULT '0.00',
  `amount_recieved` decimal(10,2) NOT NULL DEFAULT '0.00',
  `amount_remain` decimal(10,2) NOT NULL DEFAULT '0.00',
  `amount_paid` decimal(10,2) NOT NULL DEFAULT '0.00',
  `currency` int(20) NOT NULL,
  `commision_type` varchar(10) NOT NULL DEFAULT 'r',
  PRIMARY KEY (`commision_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `#__marketplace_feedback` (
  `feed_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `buyer_id` smallint(6) NOT NULL DEFAULT '0',
  `buyer_email` varchar(255) NOT NULL DEFAULT '',
  `status` smallint(6) NOT NULL DEFAULT '0',
  `seller_id` smallint(6) NOT NULL DEFAULT '0',
  `feed_price` smallint(6) NOT NULL DEFAULT '0',
  `feed_value` smallint(6) NOT NULL DEFAULT '0',
  `feed_quality` smallint(6) NOT NULL DEFAULT '0',
  `feed_nickname` varchar(255) NOT NULL DEFAULT '',
  `feed_summary` text NOT NULL,
  `feed_review` text NOT NULL,
  `create_date` text NOT NULL,
  PRIMARY KEY (`feed_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `#__marketplace_orderlist` (
  `orderlist_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `virtuemart_product_id` varchar(255) NOT NULL,
  `virtuemart_order_id` varchar(255) NOT NULL,
  `virtuemart_commision_id` decimal(10,0) NOT NULL,
  `virtuemart_real_order_id` varchar(255) NOT NULL,
  `virtuemart_product_quantity` varchar(255) NOT NULL,
  `virtuemart_seller_id` varchar(255) NOT NULL,
  `virtuemart_product_order_status` varchar(255) NOT NULL,
  `virtuemart_buyerid` varchar(255) NOT NULL,
  `virtuemart_product_price` varchar(255) NOT NULL,
  `virtuemart_product_name` varchar(255) NOT NULL,
  `virtuemart_product_total_amount` varchar(255) NOT NULL,
  `virtuemart_seller_commision_rate` decimal(10,0) NOT NULL,
  `virtuemart_seller_total_commision` varchar(255) NOT NULL,
  `actual_parter_product_cost` varchar(255) NOT NULL,
  `cleared_at` datetime NOT NULL,
  `modified_on` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `update_status` smallint(6) NOT NULL DEFAULT '0',
  PRIMARY KEY (`orderlist_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `#__marketplace_orderstatus` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `virtuemart_order_id` int(11) NOT NULL,
  `seller_id` int(11) NOT NULL,
  `order_status` varchar(30) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS `#__marketplace_product` (
  `created_by` int(11) unsigned NOT NULL,
  `virtuemart_product_id` int(11) PRIMARY KEY,
  `block`     tinyint(1) NULL DEFAULT '0',
  `viewed`     int(5) NOT NULL DEFAULT 0
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE `#__marketplace_ask_admin` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `subject` varchar(255) NOT NULL,
  `message` varchar(2000) NOT NULL,
  `seller_id` int(11) NOT NULL,
  `time` datetime NOT NULL,
  `reply` varchar(2000) NOT NULL,
  `reply_time` datetime NOT NULL,
  PRIMARY KEY (`id`)
);