add SMSpanel
This commit is contained in:
@@ -1,64 +1,337 @@
|
||||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400"></a></p>
|
||||
# Khanegi — سرور API (Laravel)
|
||||
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||
</p>
|
||||
**API اصلی** پلتفرم معاملات طلا و آبشده با تمرکز بر مشتریان خانگی. تمام منطق کسبوکار، احراز هویت، دیتابیس، کیف پول و یکپارچهسازی با سیستمهای خارجی در این پروژه قرار دارد.
|
||||
|
||||
## About Laravel
|
||||
| مورد | مقدار |
|
||||
|------|--------|
|
||||
| فریمورک | Laravel 8.75 |
|
||||
| PHP | ^7.3 \| ^8.0 |
|
||||
| Auth | JWT (`tymon/jwt-auth`) + Sanctum |
|
||||
| DB | MySQL 8 |
|
||||
| پکیج داخلی | `Rooyesh\Wallet` |
|
||||
| تاریخ شمسی | `morilog/jalali`, `hekmatinasser/verta` |
|
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
---
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
## نقش در معماری Khanegi
|
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
```
|
||||
Khanegi/
|
||||
├── userModular/ ← پنل مشتری (مصرفکننده /customer, /auth)
|
||||
├── admin/ ← پنل مدیریت (مصرفکننده /admin, /auth)
|
||||
└── server/ ← این پروژه
|
||||
```
|
||||
|
||||
## Learning Laravel
|
||||
کلاینتها REST + JWT به این سرور متصل میشوند. برای رویدادهای لحظهای قیمت، SSE از `/api/price/stream` استفاده میشود. broadcast اختیاری WebSocket از طریق `WebsocketBroadcastService` انجام میشود.
|
||||
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||
---
|
||||
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
## پیشنیازها
|
||||
|
||||
## Laravel Sponsors
|
||||
- PHP 7.3+ یا 8.x
|
||||
- Composer
|
||||
- MySQL 8
|
||||
- Node.js (فقط برای Laravel Mix، اختیاری)
|
||||
|
||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
|
||||
---
|
||||
|
||||
### Premium Partners
|
||||
## نصب و اجرا
|
||||
|
||||
- **[Vehikl](https://vehikl.com/)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Cubet Techno Labs](https://cubettech.com)**
|
||||
- **[Cyber-Duck](https://cyber-duck.co.uk)**
|
||||
- **[Many](https://www.many.co.uk)**
|
||||
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
|
||||
- **[DevSquad](https://devsquad.com)**
|
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
|
||||
- **[OP.GG](https://op.gg)**
|
||||
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
|
||||
- **[Lendio](https://lendio.com)**
|
||||
```bash
|
||||
cd server
|
||||
composer install
|
||||
# ایجاد .env و تنظیم DB_*, JWT_SECRET, APP_KEY
|
||||
php artisan key:generate
|
||||
php artisan jwt:secret
|
||||
php artisan migrate
|
||||
php artisan serve # http://localhost:8000
|
||||
```
|
||||
|
||||
## Contributing
|
||||
### Docker
|
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
```bash
|
||||
docker-compose up
|
||||
# app: :8000, db: :3306
|
||||
```
|
||||
|
||||
## Code of Conduct
|
||||
### Deploy DB موجود
|
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
```bash
|
||||
bash database/sql/run_deploy_existing_db.sh
|
||||
```
|
||||
|
||||
## Security Vulnerabilities
|
||||
جزئیات: [database/sql/DEPLOY_CHECKLIST.md](./database/sql/DEPLOY_CHECKLIST.md)
|
||||
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
---
|
||||
|
||||
## License
|
||||
## ساختار پروژه
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
```
|
||||
server/
|
||||
├── app/
|
||||
│ ├── Http/Controllers/
|
||||
│ │ ├── Admin/ # بکآفیس
|
||||
│ │ ├── Customer/ # اپ مشتری
|
||||
│ │ ├── Auth/ # ورود، ثبتنام
|
||||
│ │ ├── Site/ # قیمت، شهر، گزارش
|
||||
│ │ ├── pay/ # PayPing
|
||||
│ │ ├── Finance/ # مالی
|
||||
│ │ └── Single/ # سفارشات تک
|
||||
│ ├── Models/ # 30 مدل Eloquent
|
||||
│ └── Services/ # 22 سرویس
|
||||
├── packages/rooyesh/wallet/ # کیف پول داخلی
|
||||
├── routes/
|
||||
│ ├── api.php
|
||||
│ ├── auth.php
|
||||
│ ├── admin.php
|
||||
│ ├── customer.php
|
||||
│ ├── pargar.php # فقط is_store
|
||||
│ └── web.php
|
||||
├── config/
|
||||
│ ├── auth.php, jwt.php
|
||||
│ ├── price_providers.php
|
||||
│ ├── payment.php, fee.php
|
||||
│ └── validation.php
|
||||
├── database/
|
||||
│ ├── migrations/ # 21 migration (2026_*)
|
||||
│ ├── schema/mysql-schema.sql.reference
|
||||
│ └── sql/ # deploy scripts
|
||||
├── docker-compose.yml
|
||||
└── Dockerfile
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## گروههای Route
|
||||
|
||||
بارگذاری در `RouteServiceProvider`:
|
||||
|
||||
| Prefix | Middleware | File | مخاطب |
|
||||
|--------|------------|------|--------|
|
||||
| `/api` | api | `api.php` | عمومی (قیمت، شهر، تنظیمات) |
|
||||
| `/auth` | api + validation | `auth.php` | ورود |
|
||||
| `/admin` | api | `admin.php` | پنل مدیریت |
|
||||
| `/customer` | api | `customer.php` | اپ مشتری |
|
||||
| `/pargar` | LogRequests | `pargar.php` | حسابداری (فقط `is_store`) |
|
||||
| `/` | web | `web.php` | views, cron |
|
||||
|
||||
Rate limit: **60 req/min** روی `api`.
|
||||
|
||||
---
|
||||
|
||||
## API Endpoints (خلاصه)
|
||||
|
||||
### `/auth` — احراز هویت
|
||||
|
||||
| Method | Path | توضیح |
|
||||
|--------|------|--------|
|
||||
| POST | `/auth/login` | ورود (رمز/SMS) |
|
||||
| POST | `/auth/verify` | تأیید OTP |
|
||||
| POST | `/auth/register` | ثبتنام مشتری |
|
||||
|
||||
### `/api` — عمومی
|
||||
|
||||
| Endpoint | عملکرد |
|
||||
|----------|--------|
|
||||
| GET `/api/candle` | نمودار شمعی |
|
||||
| GET/POST `/api/price/last` | آخرین قیمت |
|
||||
| GET `/api/price/stream` | SSE قیمت لحظهای |
|
||||
| GET `/api/city/*` | استان/شهر |
|
||||
| GET `/api/get_settings` | تنظیمات عمومی |
|
||||
| GET `/api/const/key/{key}` | ثابتها |
|
||||
| POST `/api/price_triggers/table` | جدول هشدار قیمت |
|
||||
| Store: `/api/cart/*`, `/api/categories` | سبد خرید بدون لاگین |
|
||||
|
||||
### `/admin` — مدیریت (JWT: `auth:user`)
|
||||
|
||||
| Domain | Endpoints |
|
||||
|--------|-----------|
|
||||
| Profile | `GET /admin/me`, `POST /admin/me/update` |
|
||||
| Users | `resource /admin/user`, `POST /admin/user/table` |
|
||||
| Customers | `resource /admin/customer`, archive, assets, referrals |
|
||||
| Products | `resource /admin/product`, quick actions, categories |
|
||||
| Prices | `POST /admin/price`, `/admin/prices/chart`, sync logs |
|
||||
| Orders | `POST /admin/order/table`, single orders |
|
||||
| Wallet | charge, withdraw, transactions |
|
||||
| Dashboard | `GET/POST /admin/dashboard`, finance |
|
||||
| Tahesab | sync, register, retry |
|
||||
| Settings | `GET/POST /admin/get_settings` |
|
||||
| Messages | `resource /admin/messages` |
|
||||
| Gift Card | `POST /admin/giftcard/generate` |
|
||||
| Offer Codes | `resource /admin/offer_code` |
|
||||
|
||||
### `/customer` — مشتری (JWT: `auth:customer`)
|
||||
|
||||
| Domain | Endpoints |
|
||||
|--------|-----------|
|
||||
| Profile | `GET /customer/me`, `POST /customer/me/update` |
|
||||
| Wallet | `GET /customer/wallet/me`, withdraw, transactions |
|
||||
| Orders | `POST /customer/order`, `POST /customer/order/table` |
|
||||
| Fund | `resource /customer/fund`, deposit/withdraw |
|
||||
| Product | `POST /customer/wallet/product/deposit` |
|
||||
| Bank Account | `resource /customer/account` |
|
||||
| Gateway | `POST /customer/charge_account` |
|
||||
| Referral | `POST /customer/im_from/{code}` |
|
||||
| Price Trigger | `resource /customer/price_triggers` |
|
||||
| Address | `resource /customer/address` |
|
||||
| Gift Card | `POST /customer/giftcard/use` |
|
||||
| Store | `POST /customer/havale`, `POST /customer/cart/checkout` |
|
||||
|
||||
### `/pargar` — حسابداری پرگار (فقط `is_store=true`)
|
||||
|
||||
- webhookهای حسابداری، مشتری، سفارش، مانده
|
||||
|
||||
---
|
||||
|
||||
## مدلها و دامنههای کسبوکار
|
||||
|
||||
| دامنه | Models |
|
||||
|--------|--------|
|
||||
| کاربران | `User` |
|
||||
| مشتریان | `Customer`, `CustomersSetting` |
|
||||
| کاتالوگ | `Product`, `Category`, `Price`, `PriceCandle`, `PriceTrigger` |
|
||||
| معاملات | `Order` |
|
||||
| مالی | `Fund`, `Withdraw`, `BankAccount` |
|
||||
| کیف پول | `Wallet`, `Transaction` (Rooyesh) |
|
||||
| فروشگاه | `Cart`, `CartItem` |
|
||||
| کارت هدیه | `GiftCard`, `GiftCardCodes`, `OfferCode` |
|
||||
| حسابداری | `Tahesab`, `Pargar`, `TransactionsAdmin` |
|
||||
| سیستم | `Setting`, `Cnt`, `Message`, `Log`, `File`, `City` |
|
||||
| Sync | `PriceSyncLog`, `PriceSyncLogItem` |
|
||||
|
||||
**تنظیمات runtime** در جدول `settings` ذخیره میشود (`ConfigService`).
|
||||
|
||||
کلیدهای رایج در `config/price_providers.php`:
|
||||
|
||||
- `price_provider` — `montzar` \| `main_product` \| `zaarbox`
|
||||
- `is_store` — حالت فروشگاهی
|
||||
- `register_jibit_verify` — احراز هویت Jibit
|
||||
- `profit_gold_api_enabled` — API سود طلا
|
||||
- `external_order_api_enabled` — API سفارش خارجی
|
||||
|
||||
---
|
||||
|
||||
## احراز هویت
|
||||
|
||||
### Guards
|
||||
|
||||
| Guard | Model | کاربرد |
|
||||
|-------|-------|--------|
|
||||
| `user` | `User` | ادمین |
|
||||
| `customer` | `Customer` | مشتری خانگی |
|
||||
|
||||
### Login Flow
|
||||
|
||||
- Provider: `user` یا `customer`
|
||||
- روشها: password، SMS OTP (4 رقمی)، master password
|
||||
- TTL JWT: **43200 دقیقه** (30 روز)
|
||||
- بررسی: `active`, `is_archive` (مشتری)
|
||||
|
||||
### Middleware
|
||||
|
||||
- `auth:user` / `auth:customer` — JWT
|
||||
- `validation` — rules از `config/validation.php` + تبدیل اعداد فارسی
|
||||
- `throttle:api` — 60 req/min
|
||||
- `LogRequests` — لاگ Pargar
|
||||
|
||||
---
|
||||
|
||||
## سرویسهای کلیدی
|
||||
|
||||
| سرویس | کاربرد |
|
||||
|--------|--------|
|
||||
| `ConfigService` | تنظیمات از DB + fallback |
|
||||
| `ProductPriceService` | قیمتگذاری محصولات |
|
||||
| `PriceStreamService` | SSE قیمت لحظهای |
|
||||
| `MontzarService` | منبع قیمت Montzar |
|
||||
| `ZaarboxPriceService` | منبع قیمت Zaarbox |
|
||||
| `TahesabSyncService` | همگامسازی تهحساب |
|
||||
| `WalletBalanceService` | مانده کیف پول |
|
||||
| `AssetSummaryService` | خلاصه دارایی |
|
||||
| `WebsocketBroadcastService` | trigger WebSocket اختیاری |
|
||||
| `NotificationService` | SMS و اعلان |
|
||||
| `ReferralGiftService` | پاداش معرف |
|
||||
| `AccountingLedgerService` | دفتر حسابداری |
|
||||
|
||||
---
|
||||
|
||||
## پکیج کیف پول (Rooyesh)
|
||||
|
||||
```
|
||||
packages/rooyesh/wallet/
|
||||
├── WalletInterface
|
||||
├── TransactionInterface
|
||||
└── Models: Wallet, Transaction, TransactionMeta
|
||||
```
|
||||
|
||||
مدیریت موجودی `cash` (ریال) و `gold` (طلا) per owner.
|
||||
|
||||
---
|
||||
|
||||
## یکپارچهسازیهای خارجی
|
||||
|
||||
| سرویس | کاربرد |
|
||||
|--------|--------|
|
||||
| **تهحساب** | حسابداری، مانده، اسناد |
|
||||
| **پرگار** | sync مشتری/سفارش (store mode) |
|
||||
| **PayPing** | درگاه پرداخت |
|
||||
| **Montzar / Zaarbox** | منبع قیمت |
|
||||
| **Jibit** | احراز هویت ثبتنام |
|
||||
| **WebSocket (اختیاری)** | realtime trigger |
|
||||
|
||||
### Trigger WebSocket
|
||||
|
||||
```php
|
||||
// WebsocketBroadcastService
|
||||
// POST {wss_link}/prc/api/trigger-update
|
||||
// body: { "trigger": "price_update", ... }
|
||||
```
|
||||
|
||||
تنظیم از `settings`: `wss_link`, `wss_http_port`, `wss_trigger_host`
|
||||
|
||||
---
|
||||
|
||||
## متغیرهای محیط
|
||||
|
||||
### `.env` استاندارد
|
||||
|
||||
```env
|
||||
APP_NAME, APP_ENV, APP_KEY, APP_DEBUG, APP_URL
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD
|
||||
JWT_SECRET
|
||||
```
|
||||
|
||||
**توجه:** بیشتر credentialهای یکپارچهسازی در جدول `settings` است، نه `.env`.
|
||||
|
||||
---
|
||||
|
||||
## Deploy
|
||||
|
||||
| روش | توضیح |
|
||||
|------|--------|
|
||||
| PHP-FPM + Nginx | production استاندارد |
|
||||
| Docker | `docker-compose.yml` — app + MySQL |
|
||||
| DB موجود | `baseline_migrations.sql` → `migrate` → `deploy_settings_const.sql` |
|
||||
|
||||
مستندات:
|
||||
|
||||
- [database/sql/DEPLOY_CHECKLIST.md](./database/sql/DEPLOY_CHECKLIST.md)
|
||||
- [database/schema/README.md](./database/schema/README.md)
|
||||
|
||||
---
|
||||
|
||||
## نکات امنیتی
|
||||
|
||||
1. routeهای debug در `web.php` و `api.php` (`/test`, `/check`) را در production غیرفعال کنید.
|
||||
2. `JWT_SECRET` را rotate کنید.
|
||||
3. master password pattern (`monTech@...`) را بررسی کنید.
|
||||
4. CORS: `allowed_origins: ['*']` — در production محدود کنید.
|
||||
|
||||
---
|
||||
|
||||
## مستندات مرتبط
|
||||
|
||||
- [README اپ مشتری](../userModular/README.md)
|
||||
- [README پنل ادمین](../admin/README.md)
|
||||
- [README نمای کلی](../README.md)
|
||||
|
||||
Reference in New Issue
Block a user