-- phpMyAdmin SQL Dump
-- version 5.2.2
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Jun 23, 2026 at 11:20 PM
-- Server version: 11.4.10-MariaDB-cll-lve
-- PHP Version: 8.4.21

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `smarmvty_smart`
--

-- --------------------------------------------------------

--
-- Table structure for table `activity_logs`
--

CREATE TABLE `activity_logs` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `action` varchar(120) DEFAULT NULL,
  `payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`payload`)),
  `ip_address` varchar(60) DEFAULT NULL,
  `user_agent` varchar(255) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `activity_logs`
--

INSERT INTO `activity_logs` (`id`, `user_id`, `action`, `payload`, `ip_address`, `user_agent`, `created_at`) VALUES
(1, 1, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-09 12:36:51'),
(2, 1, 'logout', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-09 12:38:43'),
(3, 2, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-09 12:38:53'),
(4, 2, 'logout', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-09 13:20:34'),
(5, 4, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-09 23:22:38'),
(6, 4, 'logout', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-09 23:56:11'),
(7, 4, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-09 23:57:14'),
(8, 4, 'logout', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-09 23:58:50'),
(9, 1, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-09 23:58:58'),
(10, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:16:25'),
(11, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:32:58'),
(12, 1, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:33:57'),
(13, 2, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:34:07'),
(14, 2, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:34:38'),
(15, 3, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:34:51'),
(16, 3, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:35:05'),
(17, 4, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:35:17'),
(18, 4, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:35:58'),
(19, 5, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:36:13'),
(20, 5, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:37:20'),
(21, 5, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:37:46'),
(22, 5, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:40:49'),
(23, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:42:04'),
(24, 4, 'login_success', '[]', '165.101.132.54', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36', '2026-05-10 04:47:19'),
(25, 4, 'login_success', '[]', '165.101.132.54', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36', '2026-05-10 04:47:19'),
(26, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 08:46:01'),
(27, 1, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 08:46:05'),
(28, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 08:46:10'),
(29, 1, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 08:47:37'),
(30, 4, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 08:47:49'),
(31, 4, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 08:48:30'),
(32, 5, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 08:48:44'),
(33, 5, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 08:49:42'),
(34, 1, 'login_success', '[]', '172.245.195.200', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 09:48:07'),
(35, 1, 'login_success', '[]', '203.20.108.29', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 11:20:19'),
(36, 1, 'login_success', '[]', '203.20.108.29', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 11:20:21'),
(37, 3, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 20:50:56'),
(38, 3, 'logout', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 20:52:05'),
(39, 2, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 20:52:15'),
(40, 2, 'logout', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 20:55:34'),
(41, 4, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 20:55:42'),
(42, 4, 'logout', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 21:01:52'),
(43, NULL, 'login_failed', '{\"email\":\"postcashier@smarttech-omp.com\"}', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 21:02:02'),
(44, 5, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 21:02:12'),
(45, 5, 'logout', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 21:02:50'),
(46, 1, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 21:02:57'),
(47, 1, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:00:39'),
(48, 1, 'logout', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:07:43'),
(49, 1, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:48:45'),
(50, 1, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:48:49'),
(51, 1, 'logout', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:50:40'),
(52, 3, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:50:45'),
(53, 3, 'logout', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:51:41'),
(54, 2, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:51:49'),
(55, 2, 'logout', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:51:53'),
(56, 4, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:51:57'),
(57, 4, 'logout', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:52:00'),
(58, 5, 'login_success', '[]', '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:52:07'),
(59, 5, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:54:51'),
(60, 5, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:55:18'),
(61, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:55:26'),
(62, 1, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:55:33'),
(63, 4, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:55:39'),
(64, 4, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-11 04:57:57'),
(65, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-13 00:49:08'),
(66, 1, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-13 00:49:14'),
(67, 2, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-13 00:49:24'),
(68, 2, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-13 00:49:29'),
(69, 3, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-13 00:49:41'),
(70, 3, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-13 00:49:45'),
(71, 4, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-13 00:49:54'),
(72, 4, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-13 00:49:58'),
(73, 5, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-13 00:50:06'),
(74, 5, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-13 00:50:12'),
(75, 5, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-15 00:03:22'),
(76, 1, 'login_success', '[]', '103.186.238.121', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36', '2026-05-15 09:25:20'),
(77, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36', '2026-05-16 02:54:55'),
(78, 5, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-17 02:56:47'),
(79, 5, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-17 02:56:59'),
(80, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-17 02:57:12'),
(81, 1, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-17 02:57:51'),
(82, 4, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-17 02:58:04'),
(83, 4, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-18 06:09:50'),
(84, 4, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-18 06:09:55'),
(85, 3, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-18 06:10:43'),
(86, 3, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-18 06:10:47'),
(87, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-18 06:10:58'),
(88, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 00:33:41'),
(89, 1, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 00:33:48'),
(90, NULL, 'login_failed', '{\"email\":\"admin@smarttech-omp.com\"}', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 00:33:57'),
(91, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 00:34:09'),
(92, 1, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 00:34:14'),
(93, NULL, 'login_failed', '{\"email\":\"admin@smarttech-omp.com\"}', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 00:34:22'),
(94, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 00:34:24'),
(95, 1, 'login_success', '[]', '37.111.194.135', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 01:14:55'),
(96, 2, 'login_success', '[]', '37.111.194.135', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 01:19:40'),
(97, 2, 'logout', '[]', '37.111.194.135', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 01:29:04'),
(98, 4, 'login_success', '[]', '37.111.194.135', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 01:29:24'),
(99, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-21 02:05:45'),
(100, 1, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-21 02:07:23'),
(101, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-24 07:36:53'),
(102, 1, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-24 07:37:00'),
(103, 2, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-24 07:37:09'),
(104, 2, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-24 07:37:13'),
(105, 3, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-24 07:37:23'),
(106, 3, 'logout', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-24 07:37:27'),
(107, 4, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-24 07:37:36'),
(108, 1, 'login_success', '[]', '58.145.188.151', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36', '2026-06-01 03:27:28'),
(109, 1, 'login_success', '[]', '58.145.188.151', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36', '2026-06-01 03:27:29'),
(110, 1, 'logout', '[]', '58.145.188.151', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36', '2026-06-01 03:27:41'),
(111, 8, 'login_blocked', '{\"status\":\"pending\"}', '37.111.194.7', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36', '2026-06-03 14:27:10'),
(112, 8, 'login_blocked', '{\"status\":\"pending\"}', '37.111.194.7', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36', '2026-06-03 14:27:31'),
(113, 1, 'login_success', '[]', '203.20.108.29', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36', '2026-06-03 20:58:39'),
(114, 1, 'login_success', '[]', '203.20.108.29', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36', '2026-06-03 20:58:40'),
(115, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Mobile Safari/537.36', '2026-06-12 06:42:37'),
(116, 1, 'login_success', '[]', '202.65.173.77', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Mobile Safari/537.36', '2026-06-12 06:42:38'),
(117, 1, 'login_success', '[]', '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:30:37'),
(118, 1, 'logout', '[]', '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:30:44'),
(119, NULL, 'login_failed', '{\"email\":\"admin@smarttech-omp.com\"}', '103.186.238.123', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:34:11'),
(120, 1, 'login_success', '[]', '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:35:37'),
(121, 1, 'login_success', '[]', '103.186.238.124', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:35:42'),
(122, 1, 'logout', '[]', '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:38:12'),
(123, 1, 'logout', '[]', '103.186.238.127', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:38:25'),
(124, 4, 'login_success', '[]', '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:38:27'),
(125, 4, 'logout', '[]', '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:38:35'),
(126, NULL, 'login_failed', '{\"email\":\"membe@smarttech-omp.com\"}', '103.186.238.125', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:39:45'),
(127, 4, 'login_success', '[]', '103.186.238.120', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:40:41'),
(128, 4, 'login_success', '[]', '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:40:42'),
(129, 4, 'logout', '[]', '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 11:03:50'),
(130, 5, 'login_success', '[]', '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 11:04:03'),
(131, 5, 'logout', '[]', '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 11:04:18'),
(132, 4, 'logout', '[]', '103.186.238.127', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 11:04:26'),
(133, 5, 'login_success', '[]', '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 11:05:25'),
(134, 5, 'login_success', '[]', '103.186.238.122', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 11:07:08'),
(135, 5, 'pos_shift_opened', '{\"shift_id\":1,\"register_id\":1,\"opening_cash\":0}', '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 11:08:51'),
(136, 5, 'logout', '[]', '103.186.238.127', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 11:10:13'),
(137, 5, 'login_success', '[]', '103.186.238.127', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:15:50'),
(138, 5, 'logout', '[]', '103.186.238.127', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:16:47'),
(139, NULL, 'login_failed', '{\"email\":\"member\\/poscashier@smarttech-omp.com\"}', '103.186.238.127', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:17:36'),
(140, 4, 'login_success', '[]', '103.186.238.127', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:18:04'),
(141, 3, 'login_success', '[]', '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:23:00'),
(142, 3, 'logout', '[]', '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:30:26'),
(143, 4, 'login_success', '[]', '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:30:37'),
(144, 4, 'logout', '[]', '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:36:38'),
(145, 4, 'login_success', '[]', '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:37:31'),
(146, 4, 'logout', '[]', '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:38:27'),
(147, 1, 'login_success', '[]', '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:38:50'),
(148, 1, 'logout', '[]', '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:43:39'),
(149, 4, 'login_success', '[]', '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:43:45'),
(150, 4, 'logout', '[]', '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:58:24'),
(151, 1, 'login_success', '[]', '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:58:32'),
(152, 4, 'logout', '[]', '103.186.238.120', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 10:07:17'),
(153, 1, 'logout', '[]', '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 10:10:24'),
(154, 1, 'login_success', '[]', '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 10:10:36'),
(155, 4, 'login_success', '[]', '103.186.238.122', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-18 03:55:00'),
(156, 4, 'login_success', '[]', '103.186.238.127', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-18 03:55:26'),
(157, 4, 'login_success', '[]', '103.186.238.127', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-18 04:59:30'),
(158, 4, 'logout', '[]', '103.186.238.127', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-18 05:02:52');

-- --------------------------------------------------------

--
-- Table structure for table `addresses`
--

CREATE TABLE `addresses` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `label` varchar(80) DEFAULT NULL,
  `recipient_name` varchar(150) DEFAULT NULL,
  `phone` varchar(60) DEFAULT NULL,
  `address_line` text DEFAULT NULL,
  `district_id` int(11) DEFAULT NULL,
  `area_id` int(11) DEFAULT NULL,
  `is_default` tinyint(4) DEFAULT 0,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `admin_staff_profiles`
--

CREATE TABLE `admin_staff_profiles` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `department` varchar(120) DEFAULT NULL,
  `designation` varchar(120) DEFAULT NULL,
  `permission_note` text DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `admin_wallets`
--

CREATE TABLE `admin_wallets` (
  `id` int(11) NOT NULL,
  `wallet_type` varchar(50) DEFAULT NULL,
  `balance` decimal(14,2) DEFAULT 0.00,
  `description` text DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `admin_wallets`
--

INSERT INTO `admin_wallets` (`id`, `wallet_type`, `balance`, `description`, `updated_at`) VALUES
(1, 'incentive_admin', 0.00, '5 percent marketing PSA incentive fund', '2026-05-09 12:36:17'),
(2, 'vat_tax_admin', 0.00, 'Withdrawal 7.5 percent VAT + TAX wallet', '2026-05-09 12:36:17');

-- --------------------------------------------------------

--
-- Table structure for table `affiliate_clicks`
--

CREATE TABLE `affiliate_clicks` (
  `id` int(11) NOT NULL,
  `referral_code` varchar(50) DEFAULT NULL,
  `landing_url` varchar(255) DEFAULT NULL,
  `ip_address` varchar(60) DEFAULT NULL,
  `user_agent` varchar(255) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `affiliate_conversions`
--

CREATE TABLE `affiliate_conversions` (
  `id` int(11) NOT NULL,
  `affiliate_member_id` int(11) DEFAULT NULL,
  `order_id` int(11) DEFAULT NULL,
  `amount` decimal(14,2) DEFAULT NULL,
  `commission` decimal(14,2) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `affiliate_members`
--

CREATE TABLE `affiliate_members` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `sponsor_id` int(11) DEFAULT NULL,
  `referral_code` varchar(50) DEFAULT NULL,
  `rank_code` varchar(20) DEFAULT 'IBO',
  `total_psa` decimal(14,2) DEFAULT 0.00,
  `weekly_personal_sales` decimal(14,2) DEFAULT 0.00,
  `landing_title` varchar(190) DEFAULT NULL,
  `landing_bio` text DEFAULT NULL,
  `landing_banner` varchar(255) DEFAULT NULL,
  `landing_image` varchar(255) DEFAULT NULL,
  `contact_info` text DEFAULT NULL,
  `social_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`social_json`)),
  `status` varchar(30) DEFAULT 'active',
  `last_royalty_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `affiliate_member_plans`
--

CREATE TABLE `affiliate_member_plans` (
  `id` int(11) NOT NULL,
  `affiliate_member_id` int(11) DEFAULT NULL,
  `plan_id` int(11) DEFAULT NULL,
  `starts_at` date DEFAULT NULL,
  `ends_at` date DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `affiliate_plans`
--

CREATE TABLE `affiliate_plans` (
  `id` int(11) NOT NULL,
  `code` varchar(50) DEFAULT NULL,
  `name` varchar(150) DEFAULT NULL,
  `price` decimal(12,2) DEFAULT NULL,
  `product_limit` int(11) DEFAULT NULL,
  `affiliate_percent` decimal(5,2) DEFAULT NULL,
  `leader_percent` decimal(5,2) DEFAULT NULL,
  `mentor_percent` decimal(5,2) DEFAULT NULL,
  `cm_percent` decimal(5,2) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `affiliate_plans`
--

INSERT INTO `affiliate_plans` (`id`, `code`, `name`, `price`, `product_limit`, `affiliate_percent`, `leader_percent`, `mentor_percent`, `cm_percent`, `status`) VALUES
(1, 'easy', 'Easy E-Dealer', 10000.00, 25, 45.00, 10.00, 5.00, 5.00, 'active'),
(2, 'standard', 'Standard E-Dealer', 50000.00, 100, 65.00, 10.00, 5.00, 5.00, 'active'),
(3, 'vip', 'VIP E-Dealer', 100000.00, 300, 80.00, 10.00, 5.00, 5.00, 'active');

-- --------------------------------------------------------

--
-- Table structure for table `affiliate_products`
--

CREATE TABLE `affiliate_products` (
  `id` int(11) NOT NULL,
  `affiliate_member_id` int(11) DEFAULT NULL,
  `product_id` int(11) DEFAULT NULL,
  `bundle_name` varchar(150) DEFAULT NULL,
  `sort_order` int(11) DEFAULT 0,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `affiliate_ranks`
--

CREATE TABLE `affiliate_ranks` (
  `id` int(11) NOT NULL,
  `code` varchar(20) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `required_psa` decimal(14,2) DEFAULT NULL,
  `royalty_eligible` tinyint(4) DEFAULT 1,
  `sort_order` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `affiliate_ranks`
--

INSERT INTO `affiliate_ranks` (`id`, `code`, `name`, `required_psa`, `royalty_eligible`, `sort_order`) VALUES
(1, 'CM', 'Chief Manager', 50000000.00, 1, 1),
(2, 'ED', 'Executive Director', 10000000.00, 1, 2),
(3, 'GM', 'General Manager', 7500000.00, 1, 3),
(4, 'AGM', 'Assistant General Manager', 5000000.00, 1, 4),
(5, 'SEO', 'Senior Executive Officer', 2500000.00, 1, 5),
(6, 'EO', 'Executive Officer', 25000.00, 1, 6),
(7, 'IBO', 'Independent Business Owner', 0.00, 0, 7);

-- --------------------------------------------------------

--
-- Table structure for table `affiliate_statements`
--

CREATE TABLE `affiliate_statements` (
  `id` int(11) NOT NULL,
  `affiliate_member_id` int(11) DEFAULT NULL,
  `statement_type` varchar(30) DEFAULT NULL,
  `period_start` date DEFAULT NULL,
  `period_end` date DEFAULT NULL,
  `total_sales` decimal(14,2) DEFAULT NULL,
  `total_psa` decimal(14,2) DEFAULT NULL,
  `total_royalty` decimal(14,2) DEFAULT NULL,
  `total_withdraw` decimal(14,2) DEFAULT NULL,
  `team_income` decimal(14,2) DEFAULT 0.00,
  `leadership_bonus` decimal(14,2) DEFAULT 0.00,
  `incentive_earnings` decimal(14,2) DEFAULT 0.00,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `affiliate_suspension_rules`
--

CREATE TABLE `affiliate_suspension_rules` (
  `id` int(11) NOT NULL,
  `name` varchar(150) DEFAULT NULL,
  `monthly_royalty_required` tinyint(4) DEFAULT 1,
  `auto_reactivate_on_royalty` tinyint(4) DEFAULT 1,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `affiliate_tree`
--

CREATE TABLE `affiliate_tree` (
  `id` int(11) NOT NULL,
  `ancestor_id` int(11) DEFAULT NULL,
  `descendant_id` int(11) DEFAULT NULL,
  `level_no` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `api_tokens`
--

CREATE TABLE `api_tokens` (
  `id` int(11) NOT NULL,
  `token_name` varchar(150) DEFAULT NULL,
  `token_hash` varchar(255) DEFAULT NULL,
  `abilities` text DEFAULT NULL,
  `last_used_at` datetime DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `areas`
--

CREATE TABLE `areas` (
  `id` int(11) NOT NULL,
  `district_id` int(11) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `areas`
--

INSERT INTO `areas` (`id`, `district_id`, `name`, `status`) VALUES
(1, 1, 'Mirpur', 'active'),
(2, 1, 'Dhanmondi', 'active'),
(3, 1, 'Uttara', 'active'),
(4, 2, 'Agrabad', 'active'),
(5, 3, 'Zindabazar', 'active');

-- --------------------------------------------------------

--
-- Table structure for table `backups`
--

CREATE TABLE `backups` (
  `id` int(11) NOT NULL,
  `file_path` varchar(255) DEFAULT NULL,
  `backup_type` varchar(50) DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `banners`
--

CREATE TABLE `banners` (
  `id` int(11) NOT NULL,
  `title` varchar(190) DEFAULT NULL,
  `image` varchar(255) DEFAULT NULL,
  `link` varchar(255) DEFAULT NULL,
  `position` varchar(80) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `brands`
--

CREATE TABLE `brands` (
  `id` int(11) NOT NULL,
  `name` varchar(150) DEFAULT NULL,
  `slug` varchar(190) DEFAULT NULL,
  `logo` varchar(255) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `meta_title` varchar(190) DEFAULT NULL,
  `meta_description` text DEFAULT NULL,
  `status` varchar(30) DEFAULT 'active',
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `brands`
--

INSERT INTO `brands` (`id`, `name`, `slug`, `logo`, `description`, `meta_title`, `meta_description`, `status`, `created_at`, `updated_at`) VALUES
(1, 'Smart Tech OMP', 'smart-tech-omp', NULL, 'Official Smart Tech OMP brand', NULL, NULL, 'active', '2026-05-09 12:36:17', NULL),
(2, 'Purchase Haat', 'purchase-haat', NULL, 'Marketplace brand', NULL, NULL, 'active', '2026-05-09 12:36:17', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `campaigns`
--

CREATE TABLE `campaigns` (
  `id` int(11) NOT NULL,
  `title` varchar(190) DEFAULT NULL,
  `slug` varchar(190) DEFAULT NULL,
  `banner` varchar(255) DEFAULT NULL,
  `starts_at` datetime DEFAULT NULL,
  `ends_at` datetime DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `carts`
--

CREATE TABLE `carts` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `session_id` varchar(120) DEFAULT NULL,
  `product_id` int(11) DEFAULT NULL,
  `variant_id` int(11) DEFAULT NULL,
  `qty` int(11) DEFAULT NULL,
  `price` decimal(12,2) DEFAULT NULL,
  `abandoned_at` datetime DEFAULT NULL,
  `recovered_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `categories`
--

CREATE TABLE `categories` (
  `id` int(11) NOT NULL,
  `parent_id` int(11) DEFAULT NULL,
  `name` varchar(150) DEFAULT NULL,
  `slug` varchar(190) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `banner` varchar(255) DEFAULT NULL,
  `meta_title` varchar(190) DEFAULT NULL,
  `meta_description` text DEFAULT NULL,
  `status` varchar(30) DEFAULT 'active',
  `sort_order` int(11) DEFAULT 0,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `categories`
--

INSERT INTO `categories` (`id`, `parent_id`, `name`, `slug`, `description`, `banner`, `meta_title`, `meta_description`, `status`, `sort_order`, `created_at`, `updated_at`) VALUES
(1, NULL, 'Smart Electronics', 'smart-electronics', 'Smart devices and electronics', NULL, NULL, NULL, 'active', 1, '2026-05-09 12:36:17', NULL),
(2, NULL, 'Security Devices', 'security-devices', 'Camera and security products', NULL, NULL, NULL, 'active', 2, '2026-05-09 12:36:17', NULL),
(3, NULL, 'Retail POS', 'retail-pos', 'POS, barcode and retail automation', NULL, NULL, NULL, 'active', 3, '2026-05-09 12:36:17', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `compares`
--

CREATE TABLE `compares` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `product_id` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `countries`
--

CREATE TABLE `countries` (
  `id` int(11) NOT NULL,
  `name` varchar(100) DEFAULT NULL,
  `code` varchar(10) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `countries`
--

INSERT INTO `countries` (`id`, `name`, `code`, `status`) VALUES
(1, 'Bangladesh', 'BD', 'active');

-- --------------------------------------------------------

--
-- Table structure for table `coupons`
--

CREATE TABLE `coupons` (
  `id` int(11) NOT NULL,
  `code` varchar(50) DEFAULT NULL,
  `discount_type` varchar(30) DEFAULT NULL,
  `discount_value` decimal(12,2) DEFAULT NULL,
  `min_order_amount` decimal(12,2) DEFAULT NULL,
  `starts_at` datetime DEFAULT NULL,
  `ends_at` datetime DEFAULT NULL,
  `usage_limit` int(11) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `coupon_usages`
--

CREATE TABLE `coupon_usages` (
  `id` int(11) NOT NULL,
  `coupon_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `order_id` int(11) DEFAULT NULL,
  `discount_amount` decimal(12,2) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `couriers`
--

CREATE TABLE `couriers` (
  `id` int(11) NOT NULL,
  `name` varchar(150) DEFAULT NULL,
  `phone` varchar(60) DEFAULT NULL,
  `api_config` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`api_config`)),
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `cron_runs`
--

CREATE TABLE `cron_runs` (
  `id` int(11) NOT NULL,
  `job_name` varchar(120) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `message` text DEFAULT NULL,
  `started_at` datetime DEFAULT NULL,
  `finished_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `delivery_charges`
--

CREATE TABLE `delivery_charges` (
  `id` int(11) NOT NULL,
  `country_id` int(11) DEFAULT NULL,
  `district_id` int(11) DEFAULT NULL,
  `area_id` int(11) DEFAULT NULL,
  `zone_name` varchar(150) DEFAULT NULL,
  `base_charge` decimal(12,2) DEFAULT NULL,
  `extra_kg_charge` decimal(12,2) DEFAULT NULL,
  `free_delivery_min` decimal(12,2) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `delivery_zones`
--

CREATE TABLE `delivery_zones` (
  `id` int(11) NOT NULL,
  `name` varchar(150) DEFAULT NULL,
  `country_id` int(11) DEFAULT NULL,
  `district_ids` text DEFAULT NULL,
  `area_ids` text DEFAULT NULL,
  `base_charge` decimal(12,2) DEFAULT NULL,
  `extra_kg_charge` decimal(12,2) DEFAULT NULL,
  `free_delivery_min` decimal(12,2) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `delivery_zones`
--

INSERT INTO `delivery_zones` (`id`, `name`, `country_id`, `district_ids`, `area_ids`, `base_charge`, `extra_kg_charge`, `free_delivery_min`, `status`, `created_at`, `updated_at`) VALUES
(1, 'Dhaka Metro', 1, '1', '1,2,3', 80.00, 20.00, 5000.00, 'active', '2026-05-09 12:36:17', NULL),
(2, 'Nationwide', 1, '1,2,3,4,5', '', 120.00, 30.00, 10000.00, 'active', '2026-05-09 12:36:17', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `digital_products`
--

CREATE TABLE `digital_products` (
  `id` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `file_path` varchar(255) DEFAULT NULL,
  `license_key` text DEFAULT NULL,
  `download_limit` int(11) DEFAULT 0,
  `expires_days` int(11) DEFAULT 0,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `districts`
--

CREATE TABLE `districts` (
  `id` int(11) NOT NULL,
  `country_id` int(11) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `districts`
--

INSERT INTO `districts` (`id`, `country_id`, `name`, `status`) VALUES
(1, 1, 'Dhaka', 'active'),
(2, 1, 'Chattogram', 'active'),
(3, 1, 'Sylhet', 'active'),
(4, 1, 'Rajshahi', 'active'),
(5, 1, 'Khulna', 'active');

-- --------------------------------------------------------

--
-- Table structure for table `email_templates`
--

CREATE TABLE `email_templates` (
  `id` int(11) NOT NULL,
  `template_key` varchar(100) DEFAULT NULL,
  `subject` varchar(190) DEFAULT NULL,
  `body` longtext DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `featured_sections`
--

CREATE TABLE `featured_sections` (
  `id` int(11) NOT NULL,
  `section_type` varchar(80) DEFAULT NULL,
  `title` varchar(190) DEFAULT NULL,
  `product_ids` text DEFAULT NULL,
  `sort_order` int(11) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `flash_sales`
--

CREATE TABLE `flash_sales` (
  `id` int(11) NOT NULL,
  `title` varchar(190) DEFAULT NULL,
  `starts_at` datetime DEFAULT NULL,
  `ends_at` datetime DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `flash_sale_products`
--

CREATE TABLE `flash_sale_products` (
  `id` int(11) NOT NULL,
  `flash_sale_id` int(11) DEFAULT NULL,
  `product_id` int(11) DEFAULT NULL,
  `flash_price` decimal(12,2) DEFAULT NULL,
  `stock_limit` int(11) DEFAULT NULL,
  `sold_qty` int(11) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `homepage_sections`
--

CREATE TABLE `homepage_sections` (
  `id` int(11) NOT NULL,
  `section_key` varchar(80) DEFAULT NULL,
  `title` varchar(190) DEFAULT NULL,
  `content_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`content_json`)),
  `sort_order` int(11) DEFAULT 0,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `invoices`
--

CREATE TABLE `invoices` (
  `id` int(11) NOT NULL,
  `order_id` int(11) DEFAULT NULL,
  `invoice_no` varchar(80) DEFAULT NULL,
  `vat_amount` decimal(12,2) DEFAULT NULL,
  `tax_amount` decimal(12,2) DEFAULT NULL,
  `file_path` varchar(255) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `leadership_royalties`
--

CREATE TABLE `leadership_royalties` (
  `id` int(11) NOT NULL,
  `psa_transaction_id` int(11) DEFAULT NULL,
  `affiliate_member_id` int(11) DEFAULT NULL,
  `leader_type` varchar(50) DEFAULT NULL,
  `amount` decimal(14,2) DEFAULT NULL,
  `percentage` decimal(5,2) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `login_history`
--

CREATE TABLE `login_history` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `ip_address` varchar(60) DEFAULT NULL,
  `user_agent` varchar(255) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `login_history`
--

INSERT INTO `login_history` (`id`, `user_id`, `ip_address`, `user_agent`, `created_at`) VALUES
(1, 1, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-09 12:36:51'),
(2, 2, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-09 12:38:53'),
(3, 4, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-09 23:22:38'),
(4, 4, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-09 23:57:14'),
(5, 1, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-09 23:58:58'),
(6, 1, '202.65.173.77', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:16:25'),
(7, 1, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:32:58'),
(8, 2, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:34:07'),
(9, 3, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:34:51'),
(10, 4, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:35:17'),
(11, 5, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:36:13'),
(12, 5, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:37:46'),
(13, 1, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 00:42:04'),
(14, 4, '165.101.132.54', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36', '2026-05-10 04:47:19'),
(15, 4, '165.101.132.54', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Mobile Safari/537.36', '2026-05-10 04:47:19'),
(16, 1, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 08:46:01'),
(17, 1, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 08:46:10'),
(18, 4, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 08:47:49'),
(19, 5, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 08:48:44'),
(20, 1, '172.245.195.200', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 09:48:07'),
(21, 1, '203.20.108.29', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 11:20:19'),
(22, 1, '203.20.108.29', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 11:20:21'),
(23, 3, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 20:50:56'),
(24, 2, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 20:52:15'),
(25, 4, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 20:55:42'),
(26, 5, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 21:02:12'),
(27, 1, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 21:02:57'),
(28, 1, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:00:39'),
(29, 1, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:48:45'),
(30, 1, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:48:49'),
(31, 3, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:50:45'),
(32, 2, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:51:49'),
(33, 4, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:51:57'),
(34, 5, '103.187.94.51', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:52:07'),
(35, 5, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:54:51'),
(36, 1, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:55:26'),
(37, 4, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-10 22:55:39'),
(38, 4, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', '2026-05-11 04:57:57'),
(39, 1, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-13 00:49:08'),
(40, 2, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-13 00:49:24'),
(41, 3, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-13 00:49:41'),
(42, 4, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-13 00:49:54'),
(43, 5, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-13 00:50:06'),
(44, 5, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-15 00:03:22'),
(45, 1, '103.186.238.121', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36', '2026-05-15 09:25:20'),
(46, 1, '202.65.173.77', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36', '2026-05-16 02:54:55'),
(47, 5, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-17 02:56:47'),
(48, 1, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-17 02:57:12'),
(49, 4, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-17 02:58:04'),
(50, 4, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-18 06:09:50'),
(51, 3, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-18 06:10:43'),
(52, 1, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-18 06:10:58'),
(53, 1, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 00:33:41'),
(54, 1, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 00:34:09'),
(55, 1, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 00:34:24'),
(56, 1, '37.111.194.135', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 01:14:55'),
(57, 2, '37.111.194.135', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 01:19:40'),
(58, 4, '37.111.194.135', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-20 01:29:24'),
(59, 1, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-21 02:05:45'),
(60, 1, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-24 07:36:53'),
(61, 2, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-24 07:37:09'),
(62, 3, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-24 07:37:23'),
(63, 4, '202.65.173.77', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36', '2026-05-24 07:37:36'),
(64, 1, '58.145.188.151', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36', '2026-06-01 03:27:28'),
(65, 1, '58.145.188.151', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36', '2026-06-01 03:27:29'),
(66, 1, '203.20.108.29', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36', '2026-06-03 20:58:39'),
(67, 1, '203.20.108.29', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Mobile Safari/537.36', '2026-06-03 20:58:40'),
(68, 1, '202.65.173.77', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Mobile Safari/537.36', '2026-06-12 06:42:37'),
(69, 1, '202.65.173.77', 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Mobile Safari/537.36', '2026-06-12 06:42:38'),
(70, 1, '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:30:37'),
(71, 1, '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:35:37'),
(72, 1, '103.186.238.124', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:35:42'),
(73, 4, '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:38:27'),
(74, 4, '103.186.238.120', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:40:41'),
(75, 4, '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 10:40:42'),
(76, 5, '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 11:04:03'),
(77, 5, '37.111.194.177', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 11:05:25'),
(78, 5, '103.186.238.122', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-13 11:07:08'),
(79, 5, '103.186.238.127', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:15:50'),
(80, 4, '103.186.238.127', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:18:04'),
(81, 3, '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:23:00'),
(82, 4, '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:30:37'),
(83, 4, '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:37:31'),
(84, 1, '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:38:50'),
(85, 4, '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:43:45'),
(86, 1, '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 09:58:32'),
(87, 1, '103.187.94.50', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-17 10:10:36'),
(88, 4, '103.186.238.122', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-18 03:55:00'),
(89, 4, '103.186.238.127', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-18 03:55:26'),
(90, 4, '103.186.238.127', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36', '2026-06-18 04:59:30');

-- --------------------------------------------------------

--
-- Table structure for table `management_psa_allocations`
--

CREATE TABLE `management_psa_allocations` (
  `id` int(11) NOT NULL,
  `psa_transaction_id` int(11) DEFAULT NULL,
  `group_name` varchar(80) DEFAULT NULL,
  `percentage` decimal(5,2) DEFAULT NULL,
  `amount` decimal(14,2) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `management_psa_allocations`
--

INSERT INTO `management_psa_allocations` (`id`, `psa_transaction_id`, `group_name`, `percentage`, `amount`, `created_at`) VALUES
(1, NULL, 'Company', 10.00, 0.00, '2026-05-09 12:36:17'),
(2, NULL, 'Share Holders', 15.00, 0.00, '2026-05-09 12:36:17'),
(3, NULL, 'Logistics', 15.00, 0.00, '2026-05-09 12:36:17'),
(4, NULL, 'Employees', 20.00, 0.00, '2026-05-09 12:36:17'),
(5, NULL, 'Office', 20.00, 0.00, '2026-05-09 12:36:17'),
(6, NULL, 'Sales', 10.00, 0.00, '2026-05-09 12:36:17'),
(7, NULL, 'Training', 10.00, 0.00, '2026-05-09 12:36:17');

-- --------------------------------------------------------

--
-- Table structure for table `media_files`
--

CREATE TABLE `media_files` (
  `id` int(11) NOT NULL,
  `disk` varchar(50) DEFAULT NULL,
  `file_name` varchar(190) DEFAULT NULL,
  `file_path` varchar(255) DEFAULT NULL,
  `mime_type` varchar(100) DEFAULT NULL,
  `file_size` int(11) DEFAULT NULL,
  `uploaded_by` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `menus`
--

CREATE TABLE `menus` (
  `id` int(11) NOT NULL,
  `title` varchar(150) DEFAULT NULL,
  `url` varchar(255) DEFAULT NULL,
  `parent_id` int(11) DEFAULT NULL,
  `location` varchar(60) DEFAULT NULL,
  `sort_order` int(11) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `newsletter_subscribers`
--

CREATE TABLE `newsletter_subscribers` (
  `id` int(11) NOT NULL,
  `email` varchar(150) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `notifications`
--

CREATE TABLE `notifications` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `channel` varchar(30) DEFAULT NULL,
  `title` varchar(150) DEFAULT NULL,
  `message` text DEFAULT NULL,
  `read_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `orders`
--

CREATE TABLE `orders` (
  `id` int(11) NOT NULL,
  `order_no` varchar(80) DEFAULT NULL,
  `customer_id` int(11) DEFAULT NULL,
  `customer_name` varchar(150) DEFAULT NULL,
  `customer_email` varchar(150) DEFAULT NULL,
  `customer_phone` varchar(60) DEFAULT NULL,
  `subtotal` decimal(12,2) DEFAULT NULL,
  `discount_amount` decimal(12,2) DEFAULT 0.00,
  `reward_discount` decimal(12,2) DEFAULT 0.00,
  `shipping_charge` decimal(12,2) DEFAULT 0.00,
  `vat_amount` decimal(12,2) DEFAULT 0.00,
  `total_amount` decimal(12,2) DEFAULT NULL,
  `paid_amount` decimal(12,2) DEFAULT 0.00,
  `due_amount` decimal(12,2) DEFAULT 0.00,
  `payment_method` varchar(50) DEFAULT NULL,
  `payment_status` varchar(30) DEFAULT NULL,
  `order_status` varchar(30) DEFAULT NULL,
  `delivery_address` text DEFAULT NULL,
  `order_note` text DEFAULT NULL,
  `tracking_no` varchar(120) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `order_items`
--

CREATE TABLE `order_items` (
  `id` int(11) NOT NULL,
  `order_id` int(11) DEFAULT NULL,
  `product_id` int(11) DEFAULT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `product_name` varchar(190) DEFAULT NULL,
  `sku` varchar(100) DEFAULT NULL,
  `qty` int(11) DEFAULT NULL,
  `unit_price` decimal(12,2) DEFAULT NULL,
  `purchase_price` decimal(12,2) DEFAULT 0.00,
  `total_price` decimal(12,2) DEFAULT NULL,
  `commission_amount` decimal(12,2) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `order_statuses`
--

CREATE TABLE `order_statuses` (
  `id` int(11) NOT NULL,
  `code` varchar(50) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `color` varchar(30) DEFAULT NULL,
  `sort_order` int(11) DEFAULT NULL,
  `notify_customer` tinyint(4) DEFAULT 1,
  `notify_vendor` tinyint(4) DEFAULT 1,
  `status` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `order_statuses`
--

INSERT INTO `order_statuses` (`id`, `code`, `name`, `color`, `sort_order`, `notify_customer`, `notify_vendor`, `status`) VALUES
(1, 'pending', 'Pending', '#f59e0b', 1, 1, 1, 'active'),
(2, 'confirmed', 'Confirmed', '#2563eb', 2, 1, 1, 'active'),
(3, 'processing', 'Processing', '#06b6d4', 3, 1, 1, 'active'),
(4, 'shipped', 'Shipped', '#7c3aed', 4, 1, 1, 'active'),
(5, 'delivered', 'Delivered', '#16a34a', 5, 1, 1, 'active'),
(6, 'cancelled', 'Cancelled', '#dc2626', 6, 1, 1, 'active');

-- --------------------------------------------------------

--
-- Table structure for table `order_status_history`
--

CREATE TABLE `order_status_history` (
  `id` int(11) NOT NULL,
  `order_id` int(11) DEFAULT NULL,
  `status` varchar(50) DEFAULT NULL,
  `note` text DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `otp_verifications`
--

CREATE TABLE `otp_verifications` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `purpose` varchar(80) DEFAULT NULL,
  `otp_code` varchar(20) DEFAULT NULL,
  `expires_at` datetime DEFAULT NULL,
  `verified_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `pages`
--

CREATE TABLE `pages` (
  `id` int(11) NOT NULL,
  `page_category_id` int(11) DEFAULT NULL,
  `title` varchar(190) DEFAULT NULL,
  `slug` varchar(190) DEFAULT NULL,
  `content` longtext DEFAULT NULL,
  `meta_title` varchar(190) DEFAULT NULL,
  `meta_description` text DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `page_categories`
--

CREATE TABLE `page_categories` (
  `id` int(11) NOT NULL,
  `name` varchar(150) DEFAULT NULL,
  `slug` varchar(190) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `payments`
--

CREATE TABLE `payments` (
  `id` int(11) NOT NULL,
  `order_id` int(11) DEFAULT NULL,
  `gateway` varchar(50) DEFAULT NULL,
  `transaction_id` varchar(150) DEFAULT NULL,
  `amount` decimal(12,2) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `raw_response` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`raw_response`)),
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `payment_gateways`
--

CREATE TABLE `payment_gateways` (
  `id` int(11) NOT NULL,
  `code` varchar(50) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `is_enabled` tinyint(4) DEFAULT 0,
  `sandbox_mode` tinyint(4) DEFAULT 1,
  `config_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`config_json`)),
  `sort_order` int(11) DEFAULT 0,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `payment_gateways`
--

INSERT INTO `payment_gateways` (`id`, `code`, `name`, `is_enabled`, `sandbox_mode`, `config_json`, `sort_order`, `updated_at`) VALUES
(1, 'sslcommerz', 'SSLCommerz', 1, 1, '{}', 1, '2026-05-09 12:36:17'),
(2, 'bkash', 'bKash', 1, 1, '{}', 2, '2026-05-09 12:36:17'),
(3, 'nagad', 'Nagad', 1, 1, '{}', 3, '2026-05-09 12:36:17'),
(4, 'wallet', 'Customer Wallet', 1, 0, '{}', 4, '2026-05-09 12:36:17'),
(5, 'cod', 'Cash on Delivery', 1, 0, '{}', 5, '2026-05-09 12:36:17'),
(6, 'partial', 'Partial Payment', 1, 1, '{}', 6, '2026-05-09 12:36:17');

-- --------------------------------------------------------

--
-- Table structure for table `payment_logs`
--

CREATE TABLE `payment_logs` (
  `id` int(11) NOT NULL,
  `gateway` varchar(50) DEFAULT NULL,
  `payload` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`payload`)),
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `permissions`
--

CREATE TABLE `permissions` (
  `id` int(11) NOT NULL,
  `module` varchar(80) DEFAULT NULL,
  `action` varchar(80) DEFAULT NULL,
  `description` varchar(255) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `pickup_points`
--

CREATE TABLE `pickup_points` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `name` varchar(150) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `contact_phone` varchar(60) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `pos_cash_movements`
--

CREATE TABLE `pos_cash_movements` (
  `id` int(11) NOT NULL,
  `shift_id` int(11) NOT NULL,
  `movement_type` varchar(40) DEFAULT NULL,
  `amount` decimal(14,2) DEFAULT NULL,
  `reason` text DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `pos_day_closings`
--

CREATE TABLE `pos_day_closings` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `outlet_id` int(11) DEFAULT NULL,
  `business_date` date DEFAULT NULL,
  `gross_sales` decimal(14,2) DEFAULT NULL,
  `discount_amount` decimal(14,2) DEFAULT NULL,
  `tax_amount` decimal(14,2) DEFAULT NULL,
  `refund_amount` decimal(14,2) DEFAULT NULL,
  `net_sales` decimal(14,2) DEFAULT NULL,
  `closed_by` int(11) DEFAULT NULL,
  `closed_at` datetime DEFAULT NULL,
  `status` varchar(30) DEFAULT 'closed'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `pos_devices`
--

CREATE TABLE `pos_devices` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `register_id` int(11) DEFAULT NULL,
  `device_uid` varchar(190) DEFAULT NULL,
  `device_name` varchar(150) DEFAULT NULL,
  `device_type` varchar(50) DEFAULT NULL,
  `browser_info` text DEFAULT NULL,
  `last_ip` varchar(60) DEFAULT NULL,
  `last_seen_at` datetime DEFAULT NULL,
  `status` varchar(30) DEFAULT 'active',
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `pos_discount_rules`
--

CREATE TABLE `pos_discount_rules` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `code` varchar(80) DEFAULT NULL,
  `name` varchar(150) DEFAULT NULL,
  `discount_type` varchar(30) DEFAULT NULL,
  `discount_value` decimal(14,2) DEFAULT NULL,
  `starts_at` datetime DEFAULT NULL,
  `ends_at` datetime DEFAULT NULL,
  `status` varchar(30) DEFAULT 'active',
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `pos_discount_rules`
--

INSERT INTO `pos_discount_rules` (`id`, `vendor_id`, `code`, `name`, `discount_type`, `discount_value`, `starts_at`, `ends_at`, `status`, `created_at`) VALUES
(1, 1, 'POSWELCOME', 'POS Walk-in Welcome Discount', 'fixed', 100.00, NULL, NULL, 'active', '2026-05-09 12:36:17');

-- --------------------------------------------------------

--
-- Table structure for table `pos_held_sales`
--

CREATE TABLE `pos_held_sales` (
  `id` int(11) NOT NULL,
  `hold_no` varchar(80) DEFAULT NULL,
  `vendor_id` int(11) NOT NULL,
  `register_id` int(11) DEFAULT NULL,
  `shift_id` int(11) DEFAULT NULL,
  `cashier_id` int(11) DEFAULT NULL,
  `customer_name` varchar(150) DEFAULT NULL,
  `cart_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`cart_json`)),
  `total_amount` decimal(14,2) DEFAULT 0.00,
  `status` varchar(30) DEFAULT 'held',
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `pos_outlets`
--

CREATE TABLE `pos_outlets` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) NOT NULL,
  `name` varchar(150) DEFAULT NULL,
  `code` varchar(80) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `phone` varchar(60) DEFAULT NULL,
  `status` varchar(30) DEFAULT 'active',
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `pos_outlets`
--

INSERT INTO `pos_outlets` (`id`, `vendor_id`, `name`, `code`, `address`, `phone`, `status`, `created_at`, `updated_at`) VALUES
(1, 1, 'Smart Tech OMP Dhaka Outlet', 'STO-DHK', 'Dhaka, Bangladesh', '01700000002', 'active', '2026-05-09 12:36:17', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `pos_payments`
--

CREATE TABLE `pos_payments` (
  `id` int(11) NOT NULL,
  `sale_id` int(11) NOT NULL,
  `payment_method` varchar(40) DEFAULT NULL,
  `amount` decimal(14,2) DEFAULT NULL,
  `reference_no` varchar(190) DEFAULT NULL,
  `provider` varchar(80) DEFAULT NULL,
  `status` varchar(30) DEFAULT 'paid',
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `pos_receipt_templates`
--

CREATE TABLE `pos_receipt_templates` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `name` varchar(150) DEFAULT NULL,
  `width` varchar(20) DEFAULT NULL,
  `header_html` text DEFAULT NULL,
  `footer_html` text DEFAULT NULL,
  `show_logo` tinyint(4) DEFAULT 1,
  `show_barcode` tinyint(4) DEFAULT 1,
  `is_default` tinyint(4) DEFAULT 0,
  `status` varchar(30) DEFAULT 'active',
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `pos_receipt_templates`
--

INSERT INTO `pos_receipt_templates` (`id`, `vendor_id`, `name`, `width`, `header_html`, `footer_html`, `show_logo`, `show_barcode`, `is_default`, `status`, `created_at`, `updated_at`) VALUES
(1, 1, 'Default 80mm Thermal Receipt', '80mm', '<h2>Smart Tech OMP</h2><p>Purchase Haat POS</p>', '<p>Thank you. Exchange/refund follows shop policy.</p>', 1, 1, 1, 'active', '2026-05-09 12:36:17', NULL),
(2, 1, 'A4 Tax Invoice', 'A4', '<h2>Purchase Haat</h2>', '<p>VAT/TAX and payment details are system generated.</p>', 1, 1, 0, 'active', '2026-05-09 12:36:17', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `pos_refunds`
--

CREATE TABLE `pos_refunds` (
  `id` int(11) NOT NULL,
  `sale_id` int(11) NOT NULL,
  `refund_no` varchar(80) DEFAULT NULL,
  `amount` decimal(14,2) DEFAULT NULL,
  `method` varchar(40) DEFAULT NULL,
  `reason` text DEFAULT NULL,
  `status` varchar(30) DEFAULT 'pending',
  `created_by` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `pos_registers`
--

CREATE TABLE `pos_registers` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) NOT NULL,
  `outlet_id` int(11) DEFAULT NULL,
  `name` varchar(150) DEFAULT NULL,
  `register_code` varchar(100) DEFAULT NULL,
  `device_uid` varchar(190) DEFAULT NULL,
  `receipt_width` varchar(20) DEFAULT '80mm',
  `printer_type` varchar(40) DEFAULT 'browser',
  `cash_drawer_enabled` tinyint(4) DEFAULT 0,
  `allow_offline` tinyint(4) DEFAULT 1,
  `status` varchar(30) DEFAULT 'active',
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `pos_registers`
--

INSERT INTO `pos_registers` (`id`, `vendor_id`, `outlet_id`, `name`, `register_code`, `device_uid`, `receipt_width`, `printer_type`, `cash_drawer_enabled`, `allow_offline`, `status`, `created_at`, `updated_at`) VALUES
(1, 1, 1, 'Main Counter Register', 'STO-POS-001', NULL, '80mm', 'browser', 1, 1, 'active', '2026-05-09 12:36:17', NULL),
(2, 1, 1, 'Mobile Sales Register', 'STO-MOB-001', NULL, '58mm', 'browser', 0, 1, 'active', '2026-05-09 12:36:17', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `pos_roles`
--

CREATE TABLE `pos_roles` (
  `id` int(11) NOT NULL,
  `code` varchar(50) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `pos_roles`
--

INSERT INTO `pos_roles` (`id`, `code`, `name`, `description`, `created_at`, `updated_at`) VALUES
(1, 'manager', 'POS Manager', 'Can sell, refund, manage shifts, cash drawer, reports and staff.', '2026-05-09 12:36:17', NULL),
(2, 'cashier', 'POS Cashier', 'Can sell, hold carts, print receipts and close assigned shift.', '2026-05-09 12:36:17', NULL),
(3, 'viewer', 'POS Report Viewer', 'Can view reports without completing sales.', '2026-05-09 12:36:17', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `pos_role_permissions`
--

CREATE TABLE `pos_role_permissions` (
  `id` int(11) NOT NULL,
  `pos_role_id` int(11) NOT NULL,
  `ability` varchar(80) DEFAULT NULL,
  `description` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `pos_role_permissions`
--

INSERT INTO `pos_role_permissions` (`id`, `pos_role_id`, `ability`, `description`) VALUES
(1, 2, 'pos.shift', 'Open and close own shift'),
(2, 2, 'pos.hold', 'Hold and resume carts'),
(3, 2, 'pos.sell', 'Complete POS sales'),
(4, 1, 'pos.settings', 'Manage POS settings'),
(5, 1, 'pos.report', 'View X/Z reports'),
(6, 1, 'pos.cash_drawer', 'Cash drawer movements'),
(7, 1, 'pos.shift', 'Open and close shifts'),
(8, 1, 'pos.refund', 'Create POS refunds'),
(9, 1, 'pos.hold', 'Hold and resume carts'),
(10, 1, 'pos.sell', 'Complete POS sales'),
(11, 3, 'pos.report', 'View POS reports');

-- --------------------------------------------------------

--
-- Table structure for table `pos_sales`
--

CREATE TABLE `pos_sales` (
  `id` int(11) NOT NULL,
  `sale_no` varchar(80) DEFAULT NULL,
  `vendor_id` int(11) NOT NULL,
  `register_id` int(11) DEFAULT NULL,
  `shift_id` int(11) DEFAULT NULL,
  `cashier_id` int(11) DEFAULT NULL,
  `customer_id` int(11) DEFAULT NULL,
  `subtotal` decimal(14,2) DEFAULT 0.00,
  `discount_amount` decimal(14,2) DEFAULT 0.00,
  `tax_amount` decimal(14,2) DEFAULT 0.00,
  `total_amount` decimal(14,2) DEFAULT 0.00,
  `paid_amount` decimal(14,2) DEFAULT 0.00,
  `change_amount` decimal(14,2) DEFAULT 0.00,
  `payment_status` varchar(30) DEFAULT 'pending',
  `sale_status` varchar(30) DEFAULT 'completed',
  `note` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `pos_sale_items`
--

CREATE TABLE `pos_sale_items` (
  `id` int(11) NOT NULL,
  `sale_id` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `variant_id` int(11) DEFAULT NULL,
  `sku` varchar(100) DEFAULT NULL,
  `barcode` varchar(120) DEFAULT NULL,
  `product_name` varchar(190) DEFAULT NULL,
  `qty` int(11) DEFAULT 1,
  `unit_price` decimal(14,2) DEFAULT 0.00,
  `discount_amount` decimal(14,2) DEFAULT 0.00,
  `line_total` decimal(14,2) DEFAULT 0.00,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `pos_scanner_events`
--

CREATE TABLE `pos_scanner_events` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `register_id` int(11) DEFAULT NULL,
  `cashier_id` int(11) DEFAULT NULL,
  `scan_value` varchar(190) DEFAULT NULL,
  `scan_type` varchar(40) DEFAULT NULL,
  `matched_product_id` int(11) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `pos_settings`
--

CREATE TABLE `pos_settings` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `setting_key` varchar(150) DEFAULT NULL,
  `setting_value` text DEFAULT NULL,
  `setting_group` varchar(80) DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `pos_settings`
--

INSERT INTO `pos_settings` (`id`, `vendor_id`, `setting_key`, `setting_value`, `setting_group`, `updated_at`) VALUES
(1, 1, 'pos_enabled', '1', 'general', '2026-05-09 12:36:17'),
(2, 1, 'default_payment_methods', 'cash,bkash,nagad,card,wallet', 'payment', '2026-05-09 12:36:17'),
(3, 1, 'allow_offline_queue', '1', 'pwa', '2026-05-09 12:36:17'),
(4, 1, 'receipt_auto_print', '1', 'printer', '2026-05-09 12:36:17'),
(5, 1, 'barcode_camera_enabled', '1', 'scanner', '2026-05-09 12:36:17'),
(6, 1, 'low_stock_warning', '5', 'inventory', '2026-05-09 12:36:17');

-- --------------------------------------------------------

--
-- Table structure for table `pos_shifts`
--

CREATE TABLE `pos_shifts` (
  `id` int(11) NOT NULL,
  `register_id` int(11) NOT NULL,
  `cashier_id` int(11) NOT NULL,
  `opening_cash` decimal(14,2) DEFAULT 0.00,
  `closing_cash` decimal(14,2) DEFAULT 0.00,
  `expected_cash` decimal(14,2) DEFAULT 0.00,
  `variance` decimal(14,2) DEFAULT 0.00,
  `status` varchar(30) DEFAULT 'open',
  `opened_at` datetime DEFAULT NULL,
  `closed_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `pos_shifts`
--

INSERT INTO `pos_shifts` (`id`, `register_id`, `cashier_id`, `opening_cash`, `closing_cash`, `expected_cash`, `variance`, `status`, `opened_at`, `closed_at`, `created_at`, `updated_at`) VALUES
(1, 1, 5, 0.00, 0.00, 0.00, 0.00, 'open', '2026-06-13 11:08:51', NULL, '2026-06-13 11:08:51', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `pos_staff_assignments`
--

CREATE TABLE `pos_staff_assignments` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `pos_role_id` int(11) NOT NULL,
  `outlet_id` int(11) DEFAULT NULL,
  `register_id` int(11) DEFAULT NULL,
  `status` varchar(30) DEFAULT 'active',
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `pos_staff_assignments`
--

INSERT INTO `pos_staff_assignments` (`id`, `vendor_id`, `user_id`, `pos_role_id`, `outlet_id`, `register_id`, `status`, `created_at`, `updated_at`) VALUES
(1, 1, 5, 2, 1, 1, 'active', '2026-05-09 12:36:17', NULL),
(2, 1, 6, 1, 1, NULL, 'active', '2026-05-09 12:36:17', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `pos_stock_movements`
--

CREATE TABLE `pos_stock_movements` (
  `id` int(11) NOT NULL,
  `sale_id` int(11) DEFAULT NULL,
  `product_id` int(11) NOT NULL,
  `variant_id` int(11) DEFAULT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `movement_type` varchar(50) DEFAULT NULL,
  `qty` int(11) DEFAULT NULL,
  `note` text DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `pos_sync_queue`
--

CREATE TABLE `pos_sync_queue` (
  `id` int(11) NOT NULL,
  `client_uuid` varchar(190) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `payload_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`payload_json`)),
  `status` varchar(30) DEFAULT 'pending',
  `response_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`response_json`)),
  `created_at` datetime DEFAULT NULL,
  `synced_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `pos_tax_rules`
--

CREATE TABLE `pos_tax_rules` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `name` varchar(150) DEFAULT NULL,
  `tax_percent` decimal(8,2) DEFAULT NULL,
  `applies_to` varchar(80) DEFAULT NULL,
  `status` varchar(30) DEFAULT 'active',
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `pos_tax_rules`
--

INSERT INTO `pos_tax_rules` (`id`, `vendor_id`, `name`, `tax_percent`, `applies_to`, `status`, `created_at`) VALUES
(1, 1, 'Default VAT Manual Entry', 0.00, 'all', 'active', '2026-05-09 12:36:17');

-- --------------------------------------------------------

--
-- Table structure for table `products`
--

CREATE TABLE `products` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `category_id` int(11) DEFAULT NULL,
  `brand_id` int(11) DEFAULT NULL,
  `name` varchar(190) DEFAULT NULL,
  `slug` varchar(190) DEFAULT NULL,
  `sku` varchar(100) DEFAULT NULL,
  `barcode` varchar(100) DEFAULT NULL,
  `product_code` varchar(100) DEFAULT NULL,
  `product_type` varchar(30) DEFAULT 'physical',
  `purchase_price` decimal(12,2) DEFAULT 0.00,
  `regular_price` decimal(12,2) DEFAULT 0.00,
  `sale_price` decimal(12,2) DEFAULT 0.00,
  `flash_price` decimal(12,2) DEFAULT 0.00,
  `stock` int(11) DEFAULT 0,
  `weight` decimal(10,2) DEFAULT 0.00,
  `image` varchar(255) DEFAULT NULL,
  `gallery_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`gallery_json`)),
  `video_url` varchar(255) DEFAULT NULL,
  `short_description` text DEFAULT NULL,
  `description` longtext DEFAULT NULL,
  `specifications` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`specifications`)),
  `reward_points` int(11) DEFAULT 0,
  `shipping_charge` decimal(12,2) DEFAULT 0.00,
  `is_featured` tinyint(4) DEFAULT 0,
  `is_trending` tinyint(4) DEFAULT 0,
  `is_best_selling` tinyint(4) DEFAULT 0,
  `sold_count` int(11) DEFAULT 0,
  `rating` decimal(3,2) DEFAULT 0.00,
  `status` varchar(30) DEFAULT 'pending',
  `meta_title` varchar(190) DEFAULT NULL,
  `meta_description` text DEFAULT NULL,
  `meta_keywords` text DEFAULT NULL,
  `og_image` varchar(255) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `products`
--

INSERT INTO `products` (`id`, `vendor_id`, `category_id`, `brand_id`, `name`, `slug`, `sku`, `barcode`, `product_code`, `product_type`, `purchase_price`, `regular_price`, `sale_price`, `flash_price`, `stock`, `weight`, `image`, `gallery_json`, `video_url`, `short_description`, `description`, `specifications`, `reward_points`, `shipping_charge`, `is_featured`, `is_trending`, `is_best_selling`, `sold_count`, `rating`, `status`, `meta_title`, `meta_description`, `meta_keywords`, `og_image`, `created_at`, `updated_at`) VALUES
(1, 1, 1, 1, 'Smart LED Television 43 inch', 'smart-led-television-43-inch', 'ST-LED43', '880100000001', 'STP-LED43', 'physical', 35000.00, 49900.00, 45900.00, 0.00, 18, 0.00, 'assets/images/gallery/product-images/01.png', NULL, NULL, '43 inch smart TV with warranty.', 'Product-wise landing content, variants, reward point, barcode and QR are supported.', NULL, 450, 250.00, 1, 1, 1, 0, 0.00, 'published', NULL, NULL, NULL, NULL, '2026-05-09 12:36:17', NULL),
(2, 1, 1, 1, 'Wireless Router AX1800', 'wireless-router-ax1800', 'ST-AX1800', '880100000002', 'STP-AX1800', 'physical', 4200.00, 7200.00, 6490.00, 0.00, 42, 0.00, 'assets/images/gallery/product-images/02.png', NULL, NULL, 'Dual band router.', 'Fast wireless router for home and office.', NULL, 65, 100.00, 1, 1, 0, 0, 0.00, 'published', NULL, NULL, NULL, NULL, '2026-05-09 12:36:17', NULL),
(3, 1, 3, 1, 'Android POS Barcode Kit', 'android-pos-barcode-kit', 'ST-POSKIT', '880100000003', 'STP-POSKIT', 'physical', 18000.00, 28500.00, 26900.00, 0.00, 9, 0.00, 'assets/images/gallery/product-images/03.png', NULL, NULL, 'Android POS and barcode scanner kit.', 'Retail automation bundle with barcode/QR-ready product data.', NULL, 260, 200.00, 1, 0, 1, 0, 0.00, 'published', NULL, NULL, NULL, NULL, '2026-05-09 12:36:17', NULL),
(4, 1, 2, 1, 'Solar IP Camera Pro', 'solar-ip-camera-pro', 'ST-IPCAM', '880100000004', 'STP-IPCAM', 'physical', 5200.00, 9800.00, 8990.00, 0.00, 27, 0.00, 'assets/images/gallery/product-images/04.png', NULL, NULL, 'Solar powered IP security camera.', 'Security camera with product QR landing page.', NULL, 90, 120.00, 1, 1, 0, 0, 0.00, 'published', NULL, NULL, NULL, NULL, '2026-05-09 12:36:17', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `product_images`
--

CREATE TABLE `product_images` (
  `id` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `image_path` varchar(255) DEFAULT NULL,
  `sort_order` int(11) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `product_landing_sections`
--

CREATE TABLE `product_landing_sections` (
  `id` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `section_type` varchar(80) DEFAULT NULL,
  `title` varchar(190) DEFAULT NULL,
  `content` longtext DEFAULT NULL,
  `media_path` varchar(255) DEFAULT NULL,
  `sort_order` int(11) DEFAULT 0,
  `status` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `product_metrics`
--

CREATE TABLE `product_metrics` (
  `id` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `views` int(11) DEFAULT 0,
  `carts` int(11) DEFAULT 0,
  `sales` int(11) DEFAULT 0,
  `conversion_rate` decimal(8,2) DEFAULT 0.00,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `product_questions`
--

CREATE TABLE `product_questions` (
  `id` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `question` text DEFAULT NULL,
  `answer` text DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `answered_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `product_reviews`
--

CREATE TABLE `product_reviews` (
  `id` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `rating` int(11) DEFAULT NULL,
  `review` text DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `product_specifications`
--

CREATE TABLE `product_specifications` (
  `id` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `group_name` varchar(150) DEFAULT NULL,
  `spec_name` varchar(150) DEFAULT NULL,
  `spec_value` text DEFAULT NULL,
  `sort_order` int(11) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `product_variants`
--

CREATE TABLE `product_variants` (
  `id` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `variant_name` varchar(150) DEFAULT NULL,
  `sku` varchar(100) DEFAULT NULL,
  `options_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`options_json`)),
  `price` decimal(12,2) DEFAULT NULL,
  `stock` int(11) DEFAULT 0,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `product_videos`
--

CREATE TABLE `product_videos` (
  `id` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `video_url` varchar(255) DEFAULT NULL,
  `sort_order` int(11) DEFAULT 0,
  `status` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `psa_rules`
--

CREATE TABLE `psa_rules` (
  `id` int(11) NOT NULL,
  `rule_code` varchar(80) DEFAULT NULL,
  `rule_name` varchar(150) DEFAULT NULL,
  `product_mode` varchar(50) DEFAULT NULL,
  `marketing_percent` decimal(5,2) DEFAULT NULL,
  `management_percent` decimal(5,2) DEFAULT NULL,
  `affiliate_distribution_percent` decimal(5,2) DEFAULT NULL,
  `global_royalty_percent` decimal(5,2) DEFAULT NULL,
  `leadership_royalty_percent` decimal(5,2) DEFAULT NULL,
  `incentive_percent` decimal(5,2) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `psa_rules`
--

INSERT INTO `psa_rules` (`id`, `rule_code`, `rule_name`, `product_mode`, `marketing_percent`, `management_percent`, `affiliate_distribution_percent`, `global_royalty_percent`, `leadership_royalty_percent`, `incentive_percent`, `status`) VALUES
(1, 'default', 'Default PSA Profit Split', 'all', 50.00, 50.00, 60.00, 25.00, 10.00, 5.00, 'active'),
(2, 'packaged', 'Packaged Products Marketing Profit', 'packaged', 45.00, 55.00, 60.00, 25.00, 10.00, 5.00, 'active'),
(3, 'individual', 'Individual Products Marketing Profit', 'individual', 60.00, 40.00, 60.00, 25.00, 10.00, 5.00, 'active');

-- --------------------------------------------------------

--
-- Table structure for table `psa_transactions`
--

CREATE TABLE `psa_transactions` (
  `id` int(11) NOT NULL,
  `order_id` int(11) DEFAULT NULL,
  `affiliate_member_id` int(11) DEFAULT NULL,
  `purchase_price` decimal(14,2) DEFAULT NULL,
  `sales_price` decimal(14,2) DEFAULT NULL,
  `profit_amount` decimal(14,2) DEFAULT NULL,
  `management_psa` decimal(14,2) DEFAULT NULL,
  `marketing_psa` decimal(14,2) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `push_subscribers`
--

CREATE TABLE `push_subscribers` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `endpoint` text DEFAULT NULL,
  `public_key` text DEFAULT NULL,
  `auth_token` text DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `referrals`
--

CREATE TABLE `referrals` (
  `id` int(11) NOT NULL,
  `referrer_user_id` int(11) DEFAULT NULL,
  `referred_user_id` int(11) DEFAULT NULL,
  `referral_code` varchar(50) DEFAULT NULL,
  `reward_amount` decimal(12,2) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `refunds`
--

CREATE TABLE `refunds` (
  `id` int(11) NOT NULL,
  `order_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `amount` decimal(12,2) DEFAULT NULL,
  `reason` text DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `related_products`
--

CREATE TABLE `related_products` (
  `id` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `related_product_id` int(11) DEFAULT NULL,
  `relation_type` varchar(40) DEFAULT NULL,
  `sort_order` int(11) DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `report_exports`
--

CREATE TABLE `report_exports` (
  `id` int(11) NOT NULL,
  `report_key` varchar(120) DEFAULT NULL,
  `file_path` varchar(255) DEFAULT NULL,
  `exported_by` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `returns`
--

CREATE TABLE `returns` (
  `id` int(11) NOT NULL,
  `order_id` int(11) DEFAULT NULL,
  `product_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `reason` text DEFAULT NULL,
  `preferred_solution` varchar(50) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `reward_points`
--

CREATE TABLE `reward_points` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `points` int(11) DEFAULT NULL,
  `point_type` varchar(30) DEFAULT NULL,
  `reference_type` varchar(80) DEFAULT NULL,
  `reference_id` int(11) DEFAULT NULL,
  `expires_at` date DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `reward_rules`
--

CREATE TABLE `reward_rules` (
  `id` int(11) NOT NULL,
  `rule_type` varchar(50) DEFAULT NULL,
  `reference_id` int(11) DEFAULT NULL,
  `point_rate` decimal(10,2) DEFAULT NULL,
  `min_amount` decimal(12,2) DEFAULT NULL,
  `point_value` decimal(10,4) DEFAULT 1.0000,
  `expiry_days` int(11) DEFAULT 0,
  `minimum_redeem` int(11) DEFAULT 0,
  `status` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `roles`
--

CREATE TABLE `roles` (
  `id` int(11) NOT NULL,
  `code` varchar(50) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `roles`
--

INSERT INTO `roles` (`id`, `code`, `name`, `description`, `created_at`, `updated_at`) VALUES
(1, 'admin', 'Super Admin', 'Full platform access', '2026-05-09 12:36:17', NULL),
(2, 'staff', 'Staff', 'Role-based staff access', '2026-05-09 12:36:17', NULL),
(3, 'vendor', 'Vendor', 'Vendor seller account', '2026-05-09 12:36:17', NULL),
(4, 'customer', 'Customer', 'Customer account', '2026-05-09 12:36:17', NULL),
(5, 'affiliate', 'Marketing Member', 'Affiliate/MLM marketing member', '2026-05-09 12:36:17', NULL),
(6, 'pos_manager', 'POS Manager', 'Vendor POS supervisor with register, shift, refund and report access', '2026-05-09 12:36:17', NULL),
(7, 'pos_cashier', 'POS Cashier', 'Cashier role for POS selling and held carts', '2026-05-09 12:36:17', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `role_permissions`
--

CREATE TABLE `role_permissions` (
  `role_id` int(11) NOT NULL,
  `permission_id` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `royalty_cycles`
--

CREATE TABLE `royalty_cycles` (
  `id` int(11) NOT NULL,
  `cycle_type` varchar(30) DEFAULT NULL,
  `period_start` date DEFAULT NULL,
  `period_end` date DEFAULT NULL,
  `total_amount` decimal(14,2) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `royalty_distributions`
--

CREATE TABLE `royalty_distributions` (
  `id` int(11) NOT NULL,
  `royalty_cycle_id` int(11) DEFAULT NULL,
  `affiliate_member_id` int(11) DEFAULT NULL,
  `rank_code` varchar(20) DEFAULT NULL,
  `amount` decimal(14,2) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `schema_markups`
--

CREATE TABLE `schema_markups` (
  `id` int(11) NOT NULL,
  `entity_type` varchar(80) DEFAULT NULL,
  `entity_id` int(11) DEFAULT NULL,
  `schema_type` varchar(80) DEFAULT NULL,
  `schema_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`schema_json`)),
  `status` varchar(30) DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `security_settings`
--

CREATE TABLE `security_settings` (
  `id` int(11) NOT NULL,
  `setting_key` varchar(150) DEFAULT NULL,
  `setting_value` text DEFAULT NULL,
  `setting_group` varchar(80) DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `seo_meta`
--

CREATE TABLE `seo_meta` (
  `id` int(11) NOT NULL,
  `entity_type` varchar(80) DEFAULT NULL,
  `entity_id` int(11) DEFAULT NULL,
  `slug` varchar(190) DEFAULT NULL,
  `meta_title` varchar(190) DEFAULT NULL,
  `meta_description` text DEFAULT NULL,
  `meta_keywords` text DEFAULT NULL,
  `og_image` varchar(255) DEFAULT NULL,
  `schema_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`schema_json`)),
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `seo_tools`
--

CREATE TABLE `seo_tools` (
  `id` int(11) NOT NULL,
  `tool_type` varchar(50) DEFAULT NULL,
  `content` longtext DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `settings`
--

CREATE TABLE `settings` (
  `id` int(11) NOT NULL,
  `setting_key` varchar(150) DEFAULT NULL,
  `setting_value` text DEFAULT NULL,
  `setting_group` varchar(80) DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `settings`
--

INSERT INTO `settings` (`id`, `setting_key`, `setting_value`, `setting_group`, `updated_at`) VALUES
(1, 'site_name', 'Purchase Haat', 'general', '2026-05-09 12:36:17'),
(2, 'brand_name', 'Smart Tech OMP', 'general', '2026-05-09 12:36:17'),
(3, 'currency', 'BDT', 'general', '2026-05-09 12:36:17'),
(4, 'point_value', '1', 'reward', '2026-05-09 12:36:17'),
(5, 'minimum_withdraw', '500', 'wallet', '2026-05-09 12:36:17'),
(6, 'weekly_royalty_min_sale', '2000', 'affiliate', '2026-05-09 12:36:17'),
(7, 'whatsapp_number', '8801700000000', 'social', '2026-05-09 12:36:17');

-- --------------------------------------------------------

--
-- Table structure for table `shipments`
--

CREATE TABLE `shipments` (
  `id` int(11) NOT NULL,
  `order_id` int(11) DEFAULT NULL,
  `courier_id` int(11) DEFAULT NULL,
  `tracking_no` varchar(150) DEFAULT NULL,
  `status` varchar(50) DEFAULT NULL,
  `shipped_at` datetime DEFAULT NULL,
  `delivered_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `shipping_rules`
--

CREATE TABLE `shipping_rules` (
  `id` int(11) NOT NULL,
  `rule_name` varchar(150) DEFAULT NULL,
  `rule_type` varchar(50) DEFAULT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `product_id` int(11) DEFAULT NULL,
  `category_id` int(11) DEFAULT NULL,
  `district_id` int(11) DEFAULT NULL,
  `area_id` int(11) DEFAULT NULL,
  `min_order_amount` decimal(12,2) DEFAULT NULL,
  `charge` decimal(12,2) DEFAULT NULL,
  `is_free` tinyint(4) DEFAULT 0,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `shipping_rules`
--

INSERT INTO `shipping_rules` (`id`, `rule_name`, `rule_type`, `vendor_id`, `product_id`, `category_id`, `district_id`, `area_id`, `min_order_amount`, `charge`, `is_free`, `status`, `created_at`) VALUES
(1, 'Default Nationwide', 'nationwide', NULL, NULL, NULL, NULL, NULL, 0.00, 120.00, 0, 'active', '2026-05-09 12:36:17'),
(2, 'Free Delivery 10000', 'free_delivery', NULL, NULL, NULL, NULL, NULL, 10000.00, 0.00, 1, 'active', '2026-05-09 12:36:17');

-- --------------------------------------------------------

--
-- Table structure for table `shop_categories`
--

CREATE TABLE `shop_categories` (
  `id` int(11) NOT NULL,
  `parent_id` int(11) DEFAULT NULL,
  `name` varchar(150) DEFAULT NULL,
  `slug` varchar(190) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `sort_order` int(11) DEFAULT 0,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `sliders`
--

CREATE TABLE `sliders` (
  `id` int(11) NOT NULL,
  `title` varchar(190) DEFAULT NULL,
  `subtitle` varchar(190) DEFAULT NULL,
  `image` varchar(255) DEFAULT NULL,
  `link` varchar(255) DEFAULT NULL,
  `sort_order` int(11) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `sms_templates`
--

CREATE TABLE `sms_templates` (
  `id` int(11) NOT NULL,
  `template_key` varchar(100) DEFAULT NULL,
  `body` text DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `social_links`
--

CREATE TABLE `social_links` (
  `id` int(11) NOT NULL,
  `platform` varchar(50) DEFAULT NULL,
  `url` varchar(255) DEFAULT NULL,
  `icon` varchar(80) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `sort_order` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `social_links`
--

INSERT INTO `social_links` (`id`, `platform`, `url`, `icon`, `status`, `sort_order`) VALUES
(1, 'whatsapp', 'https://wa.me/8801700000000', 'bi-whatsapp', 'active', 1),
(2, 'facebook', '#', 'bi-facebook', 'active', 2),
(3, 'messenger', '#', 'bi-messenger', 'active', 3),
(4, 'instagram', '#', 'bi-instagram', 'active', 4),
(5, 'tiktok', '#', 'bi-tiktok', 'active', 5),
(6, 'youtube', '#', 'bi-youtube', 'active', 6);

-- --------------------------------------------------------

--
-- Table structure for table `social_login_settings`
--

CREATE TABLE `social_login_settings` (
  `id` int(11) NOT NULL,
  `provider` varchar(50) DEFAULT NULL,
  `client_id` varchar(255) DEFAULT NULL,
  `client_secret` varchar(255) DEFAULT NULL,
  `redirect_url` varchar(255) DEFAULT NULL,
  `is_enabled` tinyint(4) DEFAULT 0,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `stock_ledgers`
--

CREATE TABLE `stock_ledgers` (
  `id` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `variant_id` int(11) DEFAULT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `movement_type` varchar(50) DEFAULT NULL,
  `quantity` int(11) DEFAULT NULL,
  `balance_after` int(11) DEFAULT NULL,
  `note` text DEFAULT NULL,
  `created_by` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `support_messages`
--

CREATE TABLE `support_messages` (
  `id` int(11) NOT NULL,
  `ticket_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `message` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `support_tickets`
--

CREATE TABLE `support_tickets` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `subject` varchar(190) DEFAULT NULL,
  `message` text DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `tax_vat_entries`
--

CREATE TABLE `tax_vat_entries` (
  `id` int(11) NOT NULL,
  `source_type` varchar(80) DEFAULT NULL,
  `source_id` int(11) DEFAULT NULL,
  `amount` decimal(14,2) DEFAULT NULL,
  `entry_type` varchar(40) DEFAULT NULL,
  `note` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `theme_settings`
--

CREATE TABLE `theme_settings` (
  `id` int(11) NOT NULL,
  `setting_key` varchar(120) DEFAULT NULL,
  `setting_value` text DEFAULT NULL,
  `setting_group` varchar(80) DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `role` varchar(30) NOT NULL DEFAULT 'customer',
  `name` varchar(150) DEFAULT NULL,
  `email` varchar(150) DEFAULT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `avatar` varchar(255) DEFAULT NULL,
  `password_hash` varchar(255) DEFAULT NULL,
  `email_verified_at` datetime DEFAULT NULL,
  `phone_verified_at` datetime DEFAULT NULL,
  `two_factor_enabled` tinyint(4) DEFAULT 0,
  `transaction_pin_hash` varchar(255) DEFAULT NULL,
  `status` varchar(30) DEFAULT 'active',
  `last_login_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `role`, `name`, `email`, `phone`, `avatar`, `password_hash`, `email_verified_at`, `phone_verified_at`, `two_factor_enabled`, `transaction_pin_hash`, `status`, `last_login_at`, `created_at`, `updated_at`) VALUES
(1, 'admin', 'Super Admin', 'admin@smarttech-omp.com', '01700000001', NULL, '$2y$12$wez2DzNuumYA9T7VDdH4cOkEQMZ2YahqyYefbKGiLZRl7x2sXGXmK', NULL, NULL, 0, NULL, 'active', '2026-06-17 10:10:36', '2026-05-09 12:36:17', NULL),
(2, 'vendor', 'Demo Vendor', 'vendor@smarttech-omp.com', '01700000002', NULL, '$2y$12$wez2DzNuumYA9T7VDdH4cOkEQMZ2YahqyYefbKGiLZRl7x2sXGXmK', NULL, NULL, 0, NULL, 'active', '2026-05-24 07:37:09', '2026-05-09 12:36:17', NULL),
(3, 'customer', 'Demo Customer', 'customer@smarttech-omp.com', '01700000003', NULL, '$2y$12$wez2DzNuumYA9T7VDdH4cOkEQMZ2YahqyYefbKGiLZRl7x2sXGXmK', NULL, NULL, 0, NULL, 'active', '2026-06-17 09:23:00', '2026-05-09 12:36:17', NULL),
(4, 'affiliate', 'Demo Marketing Member', 'member@smarttech-omp.com', '01700000004', NULL, '$2y$12$wez2DzNuumYA9T7VDdH4cOkEQMZ2YahqyYefbKGiLZRl7x2sXGXmK', NULL, NULL, 0, NULL, 'active', '2026-06-18 04:59:30', '2026-05-09 12:36:17', NULL),
(5, 'pos_cashier', 'Demo POS Cashier', 'poscashier@smarttech-omp.com', '01700000005', NULL, '$2y$12$wez2DzNuumYA9T7VDdH4cOkEQMZ2YahqyYefbKGiLZRl7x2sXGXmK', NULL, NULL, 0, NULL, 'active', '2026-06-17 09:15:50', '2026-05-09 12:36:17', NULL),
(6, 'pos_manager', 'Demo POS Manager', 'posmanager@smarttech-omp.com', '01700000006', NULL, '$2y$12$wez2DzNuumYA9T7VDdH4cOkEQMZ2YahqyYefbKGiLZRl7x2sXGXmK', NULL, NULL, 0, NULL, 'active', NULL, '2026-05-09 12:36:17', NULL),
(7, 'vendor', 'Ashraful', 'ashrafulislambhuiyan792@gmail.com', '01788312384', NULL, '$2y$10$yg.D9Jl5eW984w4L0SNvwuXU.jU8vTrInKacmC67M2.clhJeKpAHi', NULL, NULL, 0, NULL, 'pending', NULL, '2026-05-10 23:45:44', '2026-05-10 23:45:44'),
(8, 'vendor', 'Sheikh Alif Hemal', 'sheikhalifhemal@gmail.com', '01720402230', NULL, '$2y$10$5sfscnnx8QrrIZb9hoAKUOprKtWpx81wf9iLPUryD6iBBkc4EtSfG', NULL, NULL, 0, NULL, 'pending', NULL, '2026-06-03 14:26:58', '2026-06-03 14:26:58');

-- --------------------------------------------------------

--
-- Table structure for table `vendors`
--

CREATE TABLE `vendors` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `shop_name` varchar(190) DEFAULT NULL,
  `slug` varchar(190) DEFAULT NULL,
  `logo` varchar(255) DEFAULT NULL,
  `banner` varchar(255) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `policies` text DEFAULT NULL,
  `social_json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`social_json`)),
  `commission_type` varchar(30) DEFAULT 'percentage',
  `commission_value` decimal(12,2) DEFAULT 5.00,
  `rating` decimal(3,2) DEFAULT 0.00,
  `status` varchar(30) DEFAULT 'pending',
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `vendors`
--

INSERT INTO `vendors` (`id`, `user_id`, `shop_name`, `slug`, `logo`, `banner`, `address`, `policies`, `social_json`, `commission_type`, `commission_value`, `rating`, `status`, `created_at`, `updated_at`) VALUES
(1, 2, 'Smart Tech OMP Official', 'smart-tech-omp-official', NULL, NULL, 'Dhaka, Bangladesh', 'Warranty and return policy configurable by admin.', NULL, 'percentage', 5.00, 4.80, 'approved', '2026-05-09 12:36:17', NULL),
(2, 7, 'smarttech', 'smarttech', NULL, NULL, NULL, NULL, NULL, 'percentage', 5.00, 0.00, 'pending', '2026-05-10 23:45:44', '2026-05-10 23:45:44'),
(3, 8, 'AYAT', 'ayat', NULL, NULL, NULL, NULL, NULL, 'percentage', 5.00, 0.00, 'pending', '2026-06-03 14:26:58', '2026-06-03 14:26:58');

-- --------------------------------------------------------

--
-- Table structure for table `vendor_packages`
--

CREATE TABLE `vendor_packages` (
  `id` int(11) NOT NULL,
  `name` varchar(150) DEFAULT NULL,
  `price` decimal(12,2) DEFAULT NULL,
  `product_limit` int(11) DEFAULT NULL,
  `duration_days` int(11) DEFAULT NULL,
  `features` text DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `vendor_payouts`
--

CREATE TABLE `vendor_payouts` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `amount` decimal(14,2) DEFAULT NULL,
  `fee` decimal(14,2) DEFAULT NULL,
  `net_amount` decimal(14,2) DEFAULT NULL,
  `method` varchar(50) DEFAULT NULL,
  `account_details` text DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `vendor_ratings`
--

CREATE TABLE `vendor_ratings` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `rating` int(11) DEFAULT NULL,
  `review` text DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `vendor_shipping_methods`
--

CREATE TABLE `vendor_shipping_methods` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `method_name` varchar(150) DEFAULT NULL,
  `courier_id` int(11) DEFAULT NULL,
  `pickup_address` text DEFAULT NULL,
  `charge` decimal(12,2) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `vendor_subscriptions`
--

CREATE TABLE `vendor_subscriptions` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `package_id` int(11) DEFAULT NULL,
  `starts_at` date DEFAULT NULL,
  `ends_at` date DEFAULT NULL,
  `payment_status` varchar(30) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `vendor_verifications`
--

CREATE TABLE `vendor_verifications` (
  `id` int(11) NOT NULL,
  `vendor_id` int(11) DEFAULT NULL,
  `document_type` varchar(80) DEFAULT NULL,
  `document_no` varchar(150) DEFAULT NULL,
  `file_path` varchar(255) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `admin_note` text DEFAULT NULL,
  `verified_by` int(11) DEFAULT NULL,
  `verified_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `wallets`
--

CREATE TABLE `wallets` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `wallet_type` varchar(50) DEFAULT NULL,
  `balance` decimal(14,2) DEFAULT 0.00,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `wallet_transactions`
--

CREATE TABLE `wallet_transactions` (
  `id` int(11) NOT NULL,
  `wallet_id` int(11) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `wallet_type` varchar(50) DEFAULT NULL,
  `transaction_type` varchar(30) DEFAULT NULL,
  `amount` decimal(14,2) DEFAULT NULL,
  `fee` decimal(14,2) DEFAULT 0.00,
  `reference_type` varchar(80) DEFAULT NULL,
  `reference_id` int(11) DEFAULT NULL,
  `note` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `wallet_transfer_requests`
--

CREATE TABLE `wallet_transfer_requests` (
  `id` int(11) NOT NULL,
  `from_user_id` int(11) DEFAULT NULL,
  `to_user_id` int(11) DEFAULT NULL,
  `from_wallet` varchar(50) DEFAULT NULL,
  `to_wallet` varchar(50) DEFAULT NULL,
  `amount` decimal(14,2) DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `otp_verified_at` datetime DEFAULT NULL,
  `pin_verified_at` datetime DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `wishlists`
--

CREATE TABLE `wishlists` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `product_id` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- Table structure for table `withdraw_requests`
--

CREATE TABLE `withdraw_requests` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `wallet_type` varchar(50) DEFAULT NULL,
  `amount` decimal(14,2) DEFAULT NULL,
  `fee` decimal(14,2) DEFAULT NULL,
  `net_amount` decimal(14,2) DEFAULT NULL,
  `method` varchar(50) DEFAULT NULL,
  `account_details` text DEFAULT NULL,
  `status` varchar(30) DEFAULT NULL,
  `otp_verified_at` datetime DEFAULT NULL,
  `approved_by` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `activity_logs`
--
ALTER TABLE `activity_logs`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `addresses`
--
ALTER TABLE `addresses`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `admin_staff_profiles`
--
ALTER TABLE `admin_staff_profiles`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `admin_wallets`
--
ALTER TABLE `admin_wallets`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `wallet_type` (`wallet_type`);

--
-- Indexes for table `affiliate_clicks`
--
ALTER TABLE `affiliate_clicks`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `affiliate_conversions`
--
ALTER TABLE `affiliate_conversions`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `affiliate_members`
--
ALTER TABLE `affiliate_members`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `referral_code` (`referral_code`);

--
-- Indexes for table `affiliate_member_plans`
--
ALTER TABLE `affiliate_member_plans`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `affiliate_plans`
--
ALTER TABLE `affiliate_plans`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `affiliate_products`
--
ALTER TABLE `affiliate_products`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `affiliate_ranks`
--
ALTER TABLE `affiliate_ranks`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Indexes for table `affiliate_statements`
--
ALTER TABLE `affiliate_statements`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `affiliate_suspension_rules`
--
ALTER TABLE `affiliate_suspension_rules`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `affiliate_tree`
--
ALTER TABLE `affiliate_tree`
  ADD PRIMARY KEY (`id`),
  ADD KEY `ancestor_id` (`ancestor_id`),
  ADD KEY `descendant_id` (`descendant_id`);

--
-- Indexes for table `api_tokens`
--
ALTER TABLE `api_tokens`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `areas`
--
ALTER TABLE `areas`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `backups`
--
ALTER TABLE `backups`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `banners`
--
ALTER TABLE `banners`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `brands`
--
ALTER TABLE `brands`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `slug` (`slug`);

--
-- Indexes for table `campaigns`
--
ALTER TABLE `campaigns`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `slug` (`slug`);

--
-- Indexes for table `carts`
--
ALTER TABLE `carts`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `categories`
--
ALTER TABLE `categories`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `slug` (`slug`);

--
-- Indexes for table `compares`
--
ALTER TABLE `compares`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `user_compare` (`user_id`,`product_id`);

--
-- Indexes for table `countries`
--
ALTER TABLE `countries`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `coupons`
--
ALTER TABLE `coupons`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Indexes for table `coupon_usages`
--
ALTER TABLE `coupon_usages`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `couriers`
--
ALTER TABLE `couriers`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `cron_runs`
--
ALTER TABLE `cron_runs`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `delivery_charges`
--
ALTER TABLE `delivery_charges`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `delivery_zones`
--
ALTER TABLE `delivery_zones`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `digital_products`
--
ALTER TABLE `digital_products`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `districts`
--
ALTER TABLE `districts`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `email_templates`
--
ALTER TABLE `email_templates`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `template_key` (`template_key`);

--
-- Indexes for table `featured_sections`
--
ALTER TABLE `featured_sections`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `flash_sales`
--
ALTER TABLE `flash_sales`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `flash_sale_products`
--
ALTER TABLE `flash_sale_products`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `homepage_sections`
--
ALTER TABLE `homepage_sections`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `invoices`
--
ALTER TABLE `invoices`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `invoice_no` (`invoice_no`);

--
-- Indexes for table `leadership_royalties`
--
ALTER TABLE `leadership_royalties`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `login_history`
--
ALTER TABLE `login_history`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `management_psa_allocations`
--
ALTER TABLE `management_psa_allocations`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `media_files`
--
ALTER TABLE `media_files`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `menus`
--
ALTER TABLE `menus`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `newsletter_subscribers`
--
ALTER TABLE `newsletter_subscribers`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `email` (`email`);

--
-- Indexes for table `notifications`
--
ALTER TABLE `notifications`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `order_no` (`order_no`),
  ADD KEY `customer_id` (`customer_id`),
  ADD KEY `order_status` (`order_status`);

--
-- Indexes for table `order_items`
--
ALTER TABLE `order_items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `order_id` (`order_id`),
  ADD KEY `vendor_id` (`vendor_id`);

--
-- Indexes for table `order_statuses`
--
ALTER TABLE `order_statuses`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Indexes for table `order_status_history`
--
ALTER TABLE `order_status_history`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `otp_verifications`
--
ALTER TABLE `otp_verifications`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `pages`
--
ALTER TABLE `pages`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `slug` (`slug`);

--
-- Indexes for table `page_categories`
--
ALTER TABLE `page_categories`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `slug` (`slug`);

--
-- Indexes for table `payments`
--
ALTER TABLE `payments`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `payment_gateways`
--
ALTER TABLE `payment_gateways`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Indexes for table `payment_logs`
--
ALTER TABLE `payment_logs`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `permissions`
--
ALTER TABLE `permissions`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `pickup_points`
--
ALTER TABLE `pickup_points`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `pos_cash_movements`
--
ALTER TABLE `pos_cash_movements`
  ADD PRIMARY KEY (`id`),
  ADD KEY `shift_id` (`shift_id`),
  ADD KEY `movement_type` (`movement_type`);

--
-- Indexes for table `pos_day_closings`
--
ALTER TABLE `pos_day_closings`
  ADD PRIMARY KEY (`id`),
  ADD KEY `vendor_id` (`vendor_id`),
  ADD KEY `business_date` (`business_date`);

--
-- Indexes for table `pos_devices`
--
ALTER TABLE `pos_devices`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_pos_device_uid` (`device_uid`),
  ADD KEY `vendor_id` (`vendor_id`),
  ADD KEY `register_id` (`register_id`);

--
-- Indexes for table `pos_discount_rules`
--
ALTER TABLE `pos_discount_rules`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `pos_held_sales`
--
ALTER TABLE `pos_held_sales`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `hold_no` (`hold_no`),
  ADD KEY `vendor_id` (`vendor_id`),
  ADD KEY `register_id` (`register_id`),
  ADD KEY `status` (`status`);

--
-- Indexes for table `pos_outlets`
--
ALTER TABLE `pos_outlets`
  ADD PRIMARY KEY (`id`),
  ADD KEY `vendor_id` (`vendor_id`),
  ADD KEY `status` (`status`);

--
-- Indexes for table `pos_payments`
--
ALTER TABLE `pos_payments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sale_id` (`sale_id`),
  ADD KEY `payment_method` (`payment_method`),
  ADD KEY `status` (`status`);

--
-- Indexes for table `pos_receipt_templates`
--
ALTER TABLE `pos_receipt_templates`
  ADD PRIMARY KEY (`id`),
  ADD KEY `vendor_id` (`vendor_id`),
  ADD KEY `status` (`status`);

--
-- Indexes for table `pos_refunds`
--
ALTER TABLE `pos_refunds`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `refund_no` (`refund_no`),
  ADD KEY `sale_id` (`sale_id`),
  ADD KEY `status` (`status`);

--
-- Indexes for table `pos_registers`
--
ALTER TABLE `pos_registers`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_pos_register_code` (`register_code`),
  ADD KEY `vendor_id` (`vendor_id`),
  ADD KEY `outlet_id` (`outlet_id`),
  ADD KEY `status` (`status`);

--
-- Indexes for table `pos_roles`
--
ALTER TABLE `pos_roles`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Indexes for table `pos_role_permissions`
--
ALTER TABLE `pos_role_permissions`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_pos_role_ability` (`pos_role_id`,`ability`);

--
-- Indexes for table `pos_sales`
--
ALTER TABLE `pos_sales`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `sale_no` (`sale_no`),
  ADD KEY `vendor_id` (`vendor_id`),
  ADD KEY `register_id` (`register_id`),
  ADD KEY `shift_id` (`shift_id`),
  ADD KEY `cashier_id` (`cashier_id`),
  ADD KEY `customer_id` (`customer_id`),
  ADD KEY `payment_status` (`payment_status`),
  ADD KEY `sale_status` (`sale_status`);

--
-- Indexes for table `pos_sale_items`
--
ALTER TABLE `pos_sale_items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sale_id` (`sale_id`),
  ADD KEY `product_id` (`product_id`),
  ADD KEY `barcode` (`barcode`),
  ADD KEY `sku` (`sku`);

--
-- Indexes for table `pos_scanner_events`
--
ALTER TABLE `pos_scanner_events`
  ADD PRIMARY KEY (`id`),
  ADD KEY `vendor_id` (`vendor_id`),
  ADD KEY `register_id` (`register_id`),
  ADD KEY `cashier_id` (`cashier_id`),
  ADD KEY `scan_value` (`scan_value`);

--
-- Indexes for table `pos_settings`
--
ALTER TABLE `pos_settings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uniq_pos_setting` (`vendor_id`,`setting_key`);

--
-- Indexes for table `pos_shifts`
--
ALTER TABLE `pos_shifts`
  ADD PRIMARY KEY (`id`),
  ADD KEY `register_id` (`register_id`),
  ADD KEY `cashier_id` (`cashier_id`),
  ADD KEY `status` (`status`);

--
-- Indexes for table `pos_staff_assignments`
--
ALTER TABLE `pos_staff_assignments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `vendor_id` (`vendor_id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `pos_role_id` (`pos_role_id`),
  ADD KEY `status` (`status`);

--
-- Indexes for table `pos_stock_movements`
--
ALTER TABLE `pos_stock_movements`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sale_id` (`sale_id`),
  ADD KEY `product_id` (`product_id`),
  ADD KEY `vendor_id` (`vendor_id`),
  ADD KEY `movement_type` (`movement_type`);

--
-- Indexes for table `pos_sync_queue`
--
ALTER TABLE `pos_sync_queue`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `client_uuid` (`client_uuid`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `status` (`status`);

--
-- Indexes for table `pos_tax_rules`
--
ALTER TABLE `pos_tax_rules`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `products`
--
ALTER TABLE `products`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `slug` (`slug`),
  ADD UNIQUE KEY `sku` (`sku`),
  ADD KEY `vendor_id` (`vendor_id`),
  ADD KEY `category_id` (`category_id`),
  ADD KEY `brand_id` (`brand_id`),
  ADD KEY `status` (`status`);

--
-- Indexes for table `product_images`
--
ALTER TABLE `product_images`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `product_landing_sections`
--
ALTER TABLE `product_landing_sections`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `product_metrics`
--
ALTER TABLE `product_metrics`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `product_questions`
--
ALTER TABLE `product_questions`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `product_reviews`
--
ALTER TABLE `product_reviews`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `product_specifications`
--
ALTER TABLE `product_specifications`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `product_variants`
--
ALTER TABLE `product_variants`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `product_videos`
--
ALTER TABLE `product_videos`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `psa_rules`
--
ALTER TABLE `psa_rules`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `rule_code` (`rule_code`);

--
-- Indexes for table `psa_transactions`
--
ALTER TABLE `psa_transactions`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `push_subscribers`
--
ALTER TABLE `push_subscribers`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `referrals`
--
ALTER TABLE `referrals`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `refunds`
--
ALTER TABLE `refunds`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `related_products`
--
ALTER TABLE `related_products`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `report_exports`
--
ALTER TABLE `report_exports`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `returns`
--
ALTER TABLE `returns`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `reward_points`
--
ALTER TABLE `reward_points`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `reward_rules`
--
ALTER TABLE `reward_rules`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `roles`
--
ALTER TABLE `roles`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Indexes for table `role_permissions`
--
ALTER TABLE `role_permissions`
  ADD PRIMARY KEY (`role_id`,`permission_id`);

--
-- Indexes for table `royalty_cycles`
--
ALTER TABLE `royalty_cycles`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `royalty_distributions`
--
ALTER TABLE `royalty_distributions`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `schema_markups`
--
ALTER TABLE `schema_markups`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `security_settings`
--
ALTER TABLE `security_settings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `setting_key` (`setting_key`);

--
-- Indexes for table `seo_meta`
--
ALTER TABLE `seo_meta`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `seo_tools`
--
ALTER TABLE `seo_tools`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `settings`
--
ALTER TABLE `settings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `setting_key` (`setting_key`);

--
-- Indexes for table `shipments`
--
ALTER TABLE `shipments`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `shipping_rules`
--
ALTER TABLE `shipping_rules`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `shop_categories`
--
ALTER TABLE `shop_categories`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `slug` (`slug`);

--
-- Indexes for table `sliders`
--
ALTER TABLE `sliders`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `sms_templates`
--
ALTER TABLE `sms_templates`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `template_key` (`template_key`);

--
-- Indexes for table `social_links`
--
ALTER TABLE `social_links`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `social_login_settings`
--
ALTER TABLE `social_login_settings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `provider` (`provider`);

--
-- Indexes for table `stock_ledgers`
--
ALTER TABLE `stock_ledgers`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `support_messages`
--
ALTER TABLE `support_messages`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `support_tickets`
--
ALTER TABLE `support_tickets`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `tax_vat_entries`
--
ALTER TABLE `tax_vat_entries`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `theme_settings`
--
ALTER TABLE `theme_settings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `setting_key` (`setting_key`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `email` (`email`),
  ADD KEY `role` (`role`),
  ADD KEY `status` (`status`);

--
-- Indexes for table `vendors`
--
ALTER TABLE `vendors`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `slug` (`slug`);

--
-- Indexes for table `vendor_packages`
--
ALTER TABLE `vendor_packages`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `vendor_payouts`
--
ALTER TABLE `vendor_payouts`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `vendor_ratings`
--
ALTER TABLE `vendor_ratings`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `vendor_shipping_methods`
--
ALTER TABLE `vendor_shipping_methods`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `vendor_subscriptions`
--
ALTER TABLE `vendor_subscriptions`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `vendor_verifications`
--
ALTER TABLE `vendor_verifications`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `wallets`
--
ALTER TABLE `wallets`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `user_wallet` (`user_id`,`wallet_type`);

--
-- Indexes for table `wallet_transactions`
--
ALTER TABLE `wallet_transactions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `wallet_type` (`wallet_type`);

--
-- Indexes for table `wallet_transfer_requests`
--
ALTER TABLE `wallet_transfer_requests`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `wishlists`
--
ALTER TABLE `wishlists`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `user_product` (`user_id`,`product_id`);

--
-- Indexes for table `withdraw_requests`
--
ALTER TABLE `withdraw_requests`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `activity_logs`
--
ALTER TABLE `activity_logs`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=159;

--
-- AUTO_INCREMENT for table `addresses`
--
ALTER TABLE `addresses`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `admin_staff_profiles`
--
ALTER TABLE `admin_staff_profiles`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `admin_wallets`
--
ALTER TABLE `admin_wallets`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `affiliate_clicks`
--
ALTER TABLE `affiliate_clicks`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `affiliate_conversions`
--
ALTER TABLE `affiliate_conversions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `affiliate_members`
--
ALTER TABLE `affiliate_members`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `affiliate_member_plans`
--
ALTER TABLE `affiliate_member_plans`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `affiliate_plans`
--
ALTER TABLE `affiliate_plans`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `affiliate_products`
--
ALTER TABLE `affiliate_products`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `affiliate_ranks`
--
ALTER TABLE `affiliate_ranks`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `affiliate_statements`
--
ALTER TABLE `affiliate_statements`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `affiliate_suspension_rules`
--
ALTER TABLE `affiliate_suspension_rules`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `affiliate_tree`
--
ALTER TABLE `affiliate_tree`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `api_tokens`
--
ALTER TABLE `api_tokens`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `areas`
--
ALTER TABLE `areas`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `backups`
--
ALTER TABLE `backups`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `banners`
--
ALTER TABLE `banners`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `brands`
--
ALTER TABLE `brands`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `campaigns`
--
ALTER TABLE `campaigns`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `carts`
--
ALTER TABLE `carts`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `categories`
--
ALTER TABLE `categories`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `compares`
--
ALTER TABLE `compares`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `countries`
--
ALTER TABLE `countries`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `coupons`
--
ALTER TABLE `coupons`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `coupon_usages`
--
ALTER TABLE `coupon_usages`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `couriers`
--
ALTER TABLE `couriers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `cron_runs`
--
ALTER TABLE `cron_runs`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `delivery_charges`
--
ALTER TABLE `delivery_charges`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `delivery_zones`
--
ALTER TABLE `delivery_zones`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `digital_products`
--
ALTER TABLE `digital_products`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `districts`
--
ALTER TABLE `districts`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `email_templates`
--
ALTER TABLE `email_templates`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `featured_sections`
--
ALTER TABLE `featured_sections`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `flash_sales`
--
ALTER TABLE `flash_sales`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `flash_sale_products`
--
ALTER TABLE `flash_sale_products`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `homepage_sections`
--
ALTER TABLE `homepage_sections`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `invoices`
--
ALTER TABLE `invoices`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `leadership_royalties`
--
ALTER TABLE `leadership_royalties`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `login_history`
--
ALTER TABLE `login_history`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=91;

--
-- AUTO_INCREMENT for table `management_psa_allocations`
--
ALTER TABLE `management_psa_allocations`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `media_files`
--
ALTER TABLE `media_files`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `menus`
--
ALTER TABLE `menus`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `newsletter_subscribers`
--
ALTER TABLE `newsletter_subscribers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `notifications`
--
ALTER TABLE `notifications`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `orders`
--
ALTER TABLE `orders`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `order_items`
--
ALTER TABLE `order_items`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `order_statuses`
--
ALTER TABLE `order_statuses`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `order_status_history`
--
ALTER TABLE `order_status_history`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `otp_verifications`
--
ALTER TABLE `otp_verifications`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pages`
--
ALTER TABLE `pages`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `page_categories`
--
ALTER TABLE `page_categories`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `payments`
--
ALTER TABLE `payments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `payment_gateways`
--
ALTER TABLE `payment_gateways`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `payment_logs`
--
ALTER TABLE `payment_logs`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `permissions`
--
ALTER TABLE `permissions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pickup_points`
--
ALTER TABLE `pickup_points`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pos_cash_movements`
--
ALTER TABLE `pos_cash_movements`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pos_day_closings`
--
ALTER TABLE `pos_day_closings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pos_devices`
--
ALTER TABLE `pos_devices`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pos_discount_rules`
--
ALTER TABLE `pos_discount_rules`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `pos_held_sales`
--
ALTER TABLE `pos_held_sales`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pos_outlets`
--
ALTER TABLE `pos_outlets`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `pos_payments`
--
ALTER TABLE `pos_payments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pos_receipt_templates`
--
ALTER TABLE `pos_receipt_templates`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `pos_refunds`
--
ALTER TABLE `pos_refunds`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pos_registers`
--
ALTER TABLE `pos_registers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `pos_roles`
--
ALTER TABLE `pos_roles`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `pos_role_permissions`
--
ALTER TABLE `pos_role_permissions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;

--
-- AUTO_INCREMENT for table `pos_sales`
--
ALTER TABLE `pos_sales`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pos_sale_items`
--
ALTER TABLE `pos_sale_items`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pos_scanner_events`
--
ALTER TABLE `pos_scanner_events`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pos_settings`
--
ALTER TABLE `pos_settings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `pos_shifts`
--
ALTER TABLE `pos_shifts`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `pos_staff_assignments`
--
ALTER TABLE `pos_staff_assignments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `pos_stock_movements`
--
ALTER TABLE `pos_stock_movements`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pos_sync_queue`
--
ALTER TABLE `pos_sync_queue`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pos_tax_rules`
--
ALTER TABLE `pos_tax_rules`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `product_images`
--
ALTER TABLE `product_images`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_landing_sections`
--
ALTER TABLE `product_landing_sections`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_metrics`
--
ALTER TABLE `product_metrics`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_questions`
--
ALTER TABLE `product_questions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_reviews`
--
ALTER TABLE `product_reviews`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_specifications`
--
ALTER TABLE `product_specifications`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_variants`
--
ALTER TABLE `product_variants`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_videos`
--
ALTER TABLE `product_videos`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `psa_rules`
--
ALTER TABLE `psa_rules`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `psa_transactions`
--
ALTER TABLE `psa_transactions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `push_subscribers`
--
ALTER TABLE `push_subscribers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `referrals`
--
ALTER TABLE `referrals`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `refunds`
--
ALTER TABLE `refunds`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `related_products`
--
ALTER TABLE `related_products`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `report_exports`
--
ALTER TABLE `report_exports`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `returns`
--
ALTER TABLE `returns`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `reward_points`
--
ALTER TABLE `reward_points`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `reward_rules`
--
ALTER TABLE `reward_rules`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `roles`
--
ALTER TABLE `roles`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `royalty_cycles`
--
ALTER TABLE `royalty_cycles`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `royalty_distributions`
--
ALTER TABLE `royalty_distributions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `schema_markups`
--
ALTER TABLE `schema_markups`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `security_settings`
--
ALTER TABLE `security_settings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `seo_meta`
--
ALTER TABLE `seo_meta`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `seo_tools`
--
ALTER TABLE `seo_tools`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `settings`
--
ALTER TABLE `settings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `shipments`
--
ALTER TABLE `shipments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `shipping_rules`
--
ALTER TABLE `shipping_rules`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `shop_categories`
--
ALTER TABLE `shop_categories`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `sliders`
--
ALTER TABLE `sliders`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `sms_templates`
--
ALTER TABLE `sms_templates`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `social_links`
--
ALTER TABLE `social_links`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `social_login_settings`
--
ALTER TABLE `social_login_settings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `stock_ledgers`
--
ALTER TABLE `stock_ledgers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `support_messages`
--
ALTER TABLE `support_messages`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `support_tickets`
--
ALTER TABLE `support_tickets`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `tax_vat_entries`
--
ALTER TABLE `tax_vat_entries`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `theme_settings`
--
ALTER TABLE `theme_settings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;

--
-- AUTO_INCREMENT for table `vendors`
--
ALTER TABLE `vendors`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `vendor_packages`
--
ALTER TABLE `vendor_packages`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `vendor_payouts`
--
ALTER TABLE `vendor_payouts`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `vendor_ratings`
--
ALTER TABLE `vendor_ratings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `vendor_shipping_methods`
--
ALTER TABLE `vendor_shipping_methods`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `vendor_subscriptions`
--
ALTER TABLE `vendor_subscriptions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `vendor_verifications`
--
ALTER TABLE `vendor_verifications`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `wallets`
--
ALTER TABLE `wallets`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `wallet_transactions`
--
ALTER TABLE `wallet_transactions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `wallet_transfer_requests`
--
ALTER TABLE `wallet_transfer_requests`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `wishlists`
--
ALTER TABLE `wishlists`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `withdraw_requests`
--
ALTER TABLE `withdraw_requests`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

-- Completion migration appended below
-- Smart Tech OMP / Purchase Haat completion migration
-- Generated 2026-06-24
-- Import this once AFTER the existing smarmvty_smart.sql database.

SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO';
SET time_zone = '+06:00';
START TRANSACTION;

CREATE TABLE IF NOT EXISTS `commission_rules` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(150) NOT NULL,
  `rule_type` varchar(50) NOT NULL DEFAULT 'percentage',
  `vendor_id` int(11) DEFAULT NULL,
  `category_id` int(11) DEFAULT NULL,
  `product_id` int(11) DEFAULT NULL,
  `commission_value` decimal(12,2) NOT NULL DEFAULT 0.00,
  `status` varchar(30) NOT NULL DEFAULT 'active',
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_commission_vendor` (`vendor_id`),
  KEY `idx_commission_category` (`category_id`),
  KEY `idx_commission_product` (`product_id`),
  KEY `idx_commission_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `contact_messages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(150) NOT NULL,
  `email` varchar(150) DEFAULT NULL,
  `phone` varchar(60) DEFAULT NULL,
  `message` text NOT NULL,
  `status` varchar(30) NOT NULL DEFAULT 'new',
  `admin_note` text DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_contact_status` (`status`),
  KEY `idx_contact_created` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS `password_reset_tokens` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `email` varchar(150) NOT NULL,
  `token_hash` char(64) NOT NULL,
  `expires_at` datetime NOT NULL,
  `created_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uniq_password_reset_token` (`token_hash`),
  KEY `idx_password_reset_user` (`user_id`),
  KEY `idx_password_reset_email` (`email`),
  KEY `idx_password_reset_expiry` (`expires_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `withdraw_requests`
  ADD COLUMN IF NOT EXISTS `processed_at` datetime DEFAULT NULL AFTER `approved_by`;
ALTER TABLE `withdraw_requests`
  ADD INDEX IF NOT EXISTS `idx_withdraw_status` (`status`),
  ADD INDEX IF NOT EXISTS `idx_withdraw_processed` (`processed_at`);

ALTER TABLE `orders`
  ADD COLUMN IF NOT EXISTS `affiliate_member_id` int(11) DEFAULT NULL AFTER `customer_id`;
ALTER TABLE `orders`
  ADD INDEX IF NOT EXISTS `idx_order_affiliate` (`affiliate_member_id`);

ALTER TABLE `affiliate_conversions`
  ADD COLUMN IF NOT EXISTS `status` varchar(30) NOT NULL DEFAULT 'pending' AFTER `commission`,
  ADD COLUMN IF NOT EXISTS `processed_at` datetime DEFAULT NULL AFTER `status`;
ALTER TABLE `affiliate_conversions`
  ADD UNIQUE INDEX IF NOT EXISTS `uniq_affiliate_conversion_order` (`order_id`),
  ADD INDEX IF NOT EXISTS `idx_affiliate_conversion_status` (`status`);

ALTER TABLE `psa_transactions`
  ADD UNIQUE INDEX IF NOT EXISTS `uniq_psa_order_member` (`order_id`,`affiliate_member_id`);

ALTER TABLE `coupons`
  ADD COLUMN IF NOT EXISTS `vendor_id` int(11) DEFAULT NULL AFTER `id`;
ALTER TABLE `coupons`
  ADD INDEX IF NOT EXISTS `idx_coupon_vendor` (`vendor_id`);

ALTER TABLE `order_items`
  ADD COLUMN IF NOT EXISTS `fulfillment_status` varchar(30) NOT NULL DEFAULT 'pending' AFTER `commission_amount`,
  ADD COLUMN IF NOT EXISTS `tracking_no` varchar(150) DEFAULT NULL AFTER `fulfillment_status`;
ALTER TABLE `order_items`
  ADD INDEX IF NOT EXISTS `idx_order_item_fulfillment` (`fulfillment_status`),
  ADD INDEX IF NOT EXISTS `idx_order_item_tracking` (`tracking_no`);

ALTER TABLE `otp_verifications`
  MODIFY COLUMN `otp_code` varchar(255) DEFAULT NULL;
ALTER TABLE `otp_verifications`
  ADD INDEX IF NOT EXISTS `idx_otp_user_purpose` (`user_id`,`purpose`),
  ADD INDEX IF NOT EXISTS `idx_otp_expiry` (`expires_at`);

ALTER TABLE `product_metrics`
  ADD UNIQUE INDEX IF NOT EXISTS `uniq_product_metrics_product` (`product_id`);

ALTER TABLE `payments`
  ADD UNIQUE INDEX IF NOT EXISTS `uniq_gateway_transaction` (`gateway`,`transaction_id`),
  ADD INDEX IF NOT EXISTS `idx_payment_order` (`order_id`),
  ADD INDEX IF NOT EXISTS `idx_payment_status` (`status`);

ALTER TABLE `affiliate_products`
  ADD UNIQUE INDEX IF NOT EXISTS `uniq_affiliate_product` (`affiliate_member_id`,`product_id`);
ALTER TABLE `affiliate_members`
  ADD UNIQUE INDEX IF NOT EXISTS `uniq_affiliate_user` (`user_id`);
ALTER TABLE `affiliate_member_plans`
  ADD INDEX IF NOT EXISTS `idx_member_plan_status` (`affiliate_member_id`,`status`,`ends_at`);
ALTER TABLE `affiliate_statements`
  ADD UNIQUE INDEX IF NOT EXISTS `uniq_affiliate_statement_period` (`affiliate_member_id`,`statement_type`,`period_start`,`period_end`);
ALTER TABLE `royalty_cycles`
  ADD UNIQUE INDEX IF NOT EXISTS `uniq_royalty_cycle_period` (`cycle_type`,`period_start`,`period_end`);
ALTER TABLE `royalty_distributions`
  ADD UNIQUE INDEX IF NOT EXISTS `uniq_royalty_distribution_member` (`royalty_cycle_id`,`affiliate_member_id`);

INSERT INTO `commission_rules` (`name`,`rule_type`,`commission_value`,`status`,`created_at`,`updated_at`)
SELECT 'Default marketplace commission','percentage',5.00,'active',NOW(),NOW()
WHERE NOT EXISTS (SELECT 1 FROM `commission_rules` WHERE `name`='Default marketplace commission');

COMMIT;


-- Production-readiness v2 migration appended below.

SET SQL_MODE = 'NO_AUTO_VALUE_ON_ZERO';
SET time_zone = '+06:00';
START TRANSACTION;

CREATE TABLE IF NOT EXISTS `security_rate_limits` (
  `rate_key` char(64) NOT NULL,
  `hits` int(11) NOT NULL DEFAULT 0,
  `window_started_at` datetime NOT NULL,
  `expires_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`rate_key`),
  KEY `idx_security_rate_expiry` (`expires_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `users`
  ADD COLUMN IF NOT EXISTS `auth_version` int(11) NOT NULL DEFAULT 1 AFTER `transaction_pin_hash`,
  ADD COLUMN IF NOT EXISTS `must_change_password` tinyint(4) NOT NULL DEFAULT 0 AFTER `auth_version`,
  ADD COLUMN IF NOT EXISTS `password_changed_at` datetime DEFAULT NULL AFTER `must_change_password`;
ALTER TABLE `users`
  ADD INDEX IF NOT EXISTS `idx_users_status_role` (`status`,`role`);

ALTER TABLE `permissions`
  ADD INDEX IF NOT EXISTS `idx_permissions_module_action` (`module`,`action`);
ALTER TABLE `role_permissions`
  ADD INDEX IF NOT EXISTS `idx_role_permissions_permission` (`permission_id`);

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'dashboard','access','System overview, live sales, vendors, customers, orders, wallet and affiliate KPIs.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='dashboard' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'orders','access','Manage orders, statuses, partial payments, invoices, tracking and item-level vendor split.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='orders' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'order-status','access','Configure order statuses, email/SMS triggers, timeline colors and vendor/customer visibility.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='order-status' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'invoices','access','Download, print and search invoices with VAT/tax/wallet/point details.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='invoices' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'refunds','access','Refund requests, approval, gateway/wallet settlement and reason tracking.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='refunds' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'returns','access','Return and replacement requests, courier pickup, inspection and approval workflow.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='returns' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'abandoned-carts','access','Abandoned cart recovery, customer reminders and conversion tracking.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='abandoned-carts' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'products','access','Unlimited physical/digital products with product-wise landing, SEO, barcode, QR and stock.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='products' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'product-create','access','Advanced product form: gallery, video, variants, purchase/sale/flash price, reward point, shipping and SEO.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='product-create' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'product-variants','access','Variant dimensions such as size, color, weight, material, model, storage and SKU-level stock.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='product-variants' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'product-specifications','access','Specification groups and product specification values.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='product-specifications' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'inventory','access','Stock ledger, low-stock alerts, vendor stock and product/variant inventory adjustments.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='inventory' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'barcode-qr','access','Generate and print barcode/QR payloads with URL, SKU, product ID, price, vendor and stock.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='barcode-qr' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'categories','access','Unlimited categories/subcategories with banners and SEO.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='categories' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'shop-categories','access','Vendor shop category taxonomy and landing settings.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='shop-categories' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'brands','access','Brand management with logo, landing page and SEO.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='brands' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'product-reviews','access','Approve, reject and reply to product reviews and ratings.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='product-reviews' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'product-questions','access','Product Q&A moderation and vendor/admin answers.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='product-questions' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'related-products','access','Manual and automatic related product, upsell and cross-sell mapping.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='related-products' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'digital-products','access','Digital product files, license keys, download limits and expiry settings.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='digital-products' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'vendors','access','Vendor registration, approval, verification, shop details and policies.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='vendors' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'vendor-verification','access','KYC/NID/trade-license verification queue and notes.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='vendor-verification' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'vendor-packages','access','Vendor subscription/package plans, pricing, limits and duration.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='vendor-packages' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'vendor-subscriptions','access','Subscription activation, expiry, payment status and renewal.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='vendor-subscriptions' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'vendor-commission','access','Fixed, percentage, category-wise, product-wise and vendor-wise commission rules.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='vendor-commission' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'vendor-payouts','access','Vendor wallet, payout requests, settlement and statement export.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='vendor-payouts' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'vendor-ratings','access','Vendor-wise rating and review moderation.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='vendor-ratings' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'vendor-shipping','access','Vendor-wise shipping options, pickup address and courier preferences.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='vendor-shipping' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'customers','access','Customer profile, login history, wallet, orders, reviews and points.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='customers' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'customer-addresses','access','Customer address book and multiple shipping addresses.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='customer-addresses' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'wishlist-compare','access','Wishlist, comparison list, saved product and conversion analytics.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='wishlist-compare' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'referrals','access','Referral link rewards, invited customers, reward history and fraud checks.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='referrals' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'social-login','access','Google/Facebook login keys and enabled/disabled controls.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='social-login' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'otp-security','access','Email OTP, phone OTP, admin/vendor 2FA and transaction PIN settings.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='otp-security' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'affiliate','access','Affiliate PSA overview, latest sales, rank upgrades and royalty status.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='affiliate' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'affiliate-members','access','IBO/EO/SEO/AGM/GM/ED/CM member profile, sponsor, status and landing page.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='affiliate-members' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'affiliate-ranks','access','PSA thresholds from IBO to CM, rank automation and eligibility.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='affiliate-ranks' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'psa-rules','access','Management/marketing PSA split, packaged/individual product profit rules.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='psa-rules' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'psa-transactions','access','Order-wise profit, management PSA and marketing PSA ledger.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='psa-transactions' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'management-psa','access','Company, shareholders, logistics, employees, office, sales and training allocation.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='management-psa' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'global-royalty','access','Weekly minimum sale eligibility, royalty pool and all-rank distribution excluding IBO.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='global-royalty' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'leadership-royalty','access','Direct leader, mentor and senior mentor bonus distribution.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='leadership-royalty' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'incentive-fund','access','Admin incentive wallet and future incentive distribution.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='incentive-fund' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'auto-suspension','access','Monthly royalty miss suspension and automatic reactivation rules.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='auto-suspension' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'team-tree','access','Level-wise affiliate tree, upline/downline, team sales and PSA.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='team-tree' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'affiliate-plans','access','Easy, Standard and VIP E-Dealer plans and product limits.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='affiliate-plans' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'member-products','access','Members select products/bundles for their own store based on plan limit.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='member-products' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'affiliate-clicks','access','Affiliate link clicks, conversion tracking and landing analytics.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='affiliate-clicks' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'weekly-statements','access','Friday statements excluding CM, ED and IBO reports.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='weekly-statements' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'monthly-statements','access','Monthly statement generation on day 30 with royalty, wallet and withdraw details.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='monthly-statements' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'wallets','access','Cash, purchase, point, royalty, commission, withdraw, bonus and reward wallets.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='wallets' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'admin-wallets','access','Incentive wallet and VAT + TAX wallet balances.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='admin-wallets' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'wallet-transfers','access','Admin-to-cash/purchase and cash-to-purchase transfers with lock rules.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='wallet-transfers' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'withdrawals','access','7.5% charge, bank/bKash/Nagad withdrawals, limits, OTP and transaction PIN.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='withdrawals' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'reward-rules','access','Product/category/order-value points, expiry, conversion and redemption rules.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='reward-rules' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'reward-history','access','Customer/vendor reward point ledger and conversion history.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='reward-history' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'tax-vat','access','Tax/VAT wallet, withdrawal charges, invoice VAT settings and export.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='tax-vat' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'payments','access','Payment transaction list, partial payments and status history.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='payments' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'payment-gateways','access','SSLCommerz, bKash, Nagad, wallet and COD configuration.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='payment-gateways' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'sslcommerz','access','SSLCommerz credentials, sandbox/live toggle, callbacks and logs.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='sslcommerz' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'bkash','access','bKash checkout configuration, token, execute and callback logs.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='bkash' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'nagad','access','Nagad merchant configuration, callback and verification logs.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='nagad' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'cod','access','COD availability by zone/vendor/product and order amount.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='cod' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'payment-logs','access','Gateway request/response audit log.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='payment-logs' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'delivery','access','Delivery overview, zones, pending shipments and courier queue.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='delivery' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'countries','access','Country master data and active/inactive controls.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='countries' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'districts','access','Bangladesh district-wise delivery charge setup.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='districts' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'areas','access','Area/thana/zone master data and charge mapping.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='areas' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'delivery-zones','access','District/area multi-select zones and price rules.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='delivery-zones' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'shipping-rules','access','Local/nationwide, vendor-wise/product-wise, free delivery and minimum order rules.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='shipping-rules' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'couriers','access','Delivery partner/courier management and API configuration.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='couriers' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'shipments','access','Tracking number, delivery status, shipped/delivered timestamps.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='shipments' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pickup-points','access','Vendor pickup location and office pickup point setup.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pickup-points' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'cms','access','Unlimited pages and dynamic CMS page builder.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='cms' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'page-categories','access','Unlimited page categories and page grouping.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='page-categories' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'page-builder','access','Advanced homepage sections, product blocks and drag ordering.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='page-builder' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'menus','access','Header/footer/mobile menu builder.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='menus' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'sliders','access','Homepage sliders with CTA and schedule.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='sliders' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'banners','access','Promotional banner positions and campaign links.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='banners' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'theme-settings','access','Logo, color, typography, layout and mobile UI settings.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='theme-settings' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'seo','access','Meta title/description/keywords, Open Graph image and schema settings.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='seo' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'sitemap-robots','access','Sitemap generator and robots.txt editor.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='sitemap-robots' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'schema-markup','access','Product, organization, breadcrumb and FAQ schema controls.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='schema-markup' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'coupons','access','Coupon rules, usage limits, date range and redemption report.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='coupons' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'flash-sales','access','Flash sale products, prices, countdown and stock locks.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='flash-sales' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'campaigns','access','Campaign/deal-of-the-day promotional management.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='campaigns' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'featured-sections','access','Featured, trending, best-selling, new arrivals and custom product sections.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='featured-sections' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'newsletter','access','Newsletter subscribers, campaigns and export.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='newsletter' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'notifications','access','Admin/vendor/customer notification center.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='notifications' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'email-templates','access','Email notification template editor.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='email-templates' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'sms-templates','access','SMS/OTP template editor and provider config.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='sms-templates' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'push-notifications','access','Push subscribers, push campaigns and notification log.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='push-notifications' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'support-chat','access','Customer support chat, WhatsApp/Messenger links and contact inbox.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='support-chat' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'social-links','access','WhatsApp, Facebook, Messenger, Instagram, TikTok and YouTube settings.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='social-links' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'reports','access','Sales, vendor, product, customer, delivery, payment, commission, stock and reward reports.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='reports' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'sales-report','access','Date/vendor/category/product-wise sales report.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='sales-report' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'vendor-sales-report','access','Vendor sales, commission and payout report.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='vendor-sales-report' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'product-performance-report','access','Views, carts, sales, conversion, stock and profit report.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='product-performance-report' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'customer-report','access','Customer orders, wallet, point and retention report.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='customer-report' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'delivery-report','access','Delivery status, courier performance and charge report.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='delivery-report' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'payment-report','access','Payment method, gateway and status report.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='payment-report' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'commission-report','access','Vendor and affiliate commission report.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='commission-report' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'stock-report','access','Low stock, product/variant stock and adjustment report.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='stock-report' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'reward-report','access','Reward point earning/redeem/expiry report.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='reward-report' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'coupon-report','access','Coupon usage, discount and customer report.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='coupon-report' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'export-center','access','Export reports as CSV, Excel-compatible CSV and print/PDF views.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='export-center' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'roles','access','Role-based staff/admin permissions by module and action.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='roles' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'staff','access','Admin/staff users, role assignments and access status.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='staff' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'activity-logs','access','Admin/vendor/customer activity logs with IP and user agent.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='activity-logs' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'login-history','access','Login success/failure history and device information.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='login-history' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'backup-restore','access','Database backup, file backup, restore notes and download links.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='backup-restore' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'file-manager','access','Upload directory browser for banners, logos, products and documents.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='file-manager' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'api-settings','access','API tokens, callback URLs and webhook settings.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='api-settings' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'cron-jobs','access','Cron command reference for rank, royalty, statements and abandoned carts.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='cron-jobs' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'settings','access','Site, company, contact, currency, tax, order and security settings.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='settings' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pos','access','Central POS control center for mobile PWA selling, vendor registers, cashiers, scanners, printers and offline sync.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pos' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pos-outlets','access','Vendor-wise branches/outlets for retail counters, delivery pickup and inventory separation.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pos-outlets' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pos-registers','access','Register code, receipt width, printer type, cash drawer, offline mode and assigned vendor/outlet.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pos-registers' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pos-shifts','access','Opening cash, closing cash, expected drawer, variance and cashier shift lifecycle.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pos-shifts' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pos-cash-drawer','access','Cash in/out, drawer reasons, manager approval and audit log.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pos-cash-drawer' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pos-sales','access','Completed POS sales with payment status, cashier, customer, vendor and receipt links.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pos-sales' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pos-sale-items','access','Line-level POS sale item history, SKU, barcode, qty, price and item discounts.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pos-sale-items' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pos-payments','access','Cash, card, bKash, Nagad, wallet and split payment references.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pos-payments' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pos-refunds','access','Return, refund and exchange records with reason, method and approval status.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pos-refunds' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pos-receipts','access','58mm, 80mm and A4 receipt templates with logo, barcode and footer settings.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pos-receipts' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pos-devices','access','Registered mobile browsers, tablets, terminals, barcode devices and last seen tracking.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pos-devices' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pos-staff','access','Assign vendor POS managers/cashiers and granular abilities for selling, refund, shift and reports.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pos-staff' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pos-sync','access','PWA offline sale queue, duplicate protection, sync status and failed payload review.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pos-sync' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pos-reports','access','Cashier, register, payment, day close, tax, refund and product movement reports.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pos-reports' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'pos-settings','access','Global and vendor POS settings for scanner, printer, payment methods, offline mode and low-stock warnings.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='pos-settings' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'feature-map','access','View the platform feature map.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='feature-map' AND `action`='access');

INSERT INTO `permissions` (`module`,`action`,`description`,`created_at`)
SELECT 'control-panel-check','access','View deployment and environment diagnostics.',NOW()
WHERE NOT EXISTS (SELECT 1 FROM `permissions` WHERE `module`='control-panel-check' AND `action`='access');

-- Conservative default access for the built-in Staff role.
-- Super Admin can change these from Admin > Roles & Staff Permissions.
INSERT IGNORE INTO `role_permissions` (`role_id`,`permission_id`)
SELECT r.id,p.id FROM `roles` r JOIN `permissions` p
WHERE r.code='staff' AND p.action='access' AND p.module IN ('dashboard','orders','order-status','invoices','refunds','returns','products','product-create','product-variants','product-specifications','product-reviews','product-questions','inventory','stock-report','vendors','vendor-verification','customers','customer-addresses','support-chat','notifications','reports','sales-report','customer-report','vendor-sales-report','delivery-report','payment-report','pos','pos-sales','pos-sale-items','pos-payments','pos-refunds','pos-reports','feature-map','control-panel-check');

UPDATE `users` SET `auth_version`=1 WHERE `auth_version` IS NULL OR `auth_version`<1;

-- Force seeded demonstration accounts to replace the shared installation password.
UPDATE `users`
SET `must_change_password`=1
WHERE `password_changed_at` IS NULL
  AND `email` IN (
    'admin@smarttech-omp.com',
    'vendor@smarttech-omp.com',
    'customer@smarttech-omp.com',
    'member@smarttech-omp.com',
    'poscashier@smarttech-omp.com',
    'posmanager@smarttech-omp.com'
  );

COMMIT;
