diff --git a/app/Http/Controllers/Api/Client/ClientController.php b/app/Http/Controllers/Api/Client/ClientController.php
index be7bd1e..174471e 100644
--- a/app/Http/Controllers/Api/Client/ClientController.php
+++ b/app/Http/Controllers/Api/Client/ClientController.php
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api\Client;
use App\Http\Controllers\Controller;
use App\Http\Requests\Api\Client\ClientAuthRequest;
use App\Http\Requests\Api\Client\ClientRegisterRequest;
+use App\Http\Requests\Api\Client\ClientUpdateRequest;
use App\Http\Resources\Api\Client\ClientResource;
use App\Services\Api\Client\ClientAuthService;
use Illuminate\Support\Facades\Auth;
@@ -213,4 +214,20 @@ class ClientController extends Controller
'message' => 'Đã đăng xuất thành công.',
]);
}
+
+ public function update(ClientUpdateRequest $request)
+ {
+ $user = auth('client')->user();
+
+ $user->fill($request->validated());
+ $user->save();
+
+ return response()->json([
+ 'error' => false,
+ 'message' => 'Cập nhật thông tin thành công',
+ 'data' => [
+ 'client' => new ClientResource($user),
+ ],
+ ]);
+ }
}
\ No newline at end of file
diff --git a/app/Http/Controllers/Api/Transaction/TransactionController.php b/app/Http/Controllers/Api/Transaction/TransactionController.php
index 21fbf28..6ba7d4f 100644
--- a/app/Http/Controllers/Api/Transaction/TransactionController.php
+++ b/app/Http/Controllers/Api/Transaction/TransactionController.php
@@ -6,6 +6,7 @@ use App\Enums\TransactionStatus;
use App\Http\Controllers\Controller;
use App\Http\Requests\DepositRequest;
use App\Http\Services\VNPayService;
+use App\Jobs\Mail\Customer\DepositSuccessJob;
use App\Models\Customer;
use App\Models\Log;
use App\Models\Transaction;
@@ -148,6 +149,17 @@ class TransactionController extends Controller
'customer_id' => $transaction->customer_id,
]);
+ DepositSuccessJob::dispatch([
+ 'customer_email' => $customer->email,
+ 'customer_name' => $customer->fullname,
+ 'transaction_code' => $transaction->public_code,
+ 'amount' => $transaction->amount,
+ 'credit' => $transaction->amount / 100,
+ 'current_total' => $customer->total,
+ 'current_credit' => $customer->credit,
+ 'deposit_date' => now()->format('d/m/Y H:i:s'),
+ ]);
+
DB::commit();
} catch (\Exception $e) {
DB::rollBack();
diff --git a/app/Http/Requests/Api/Client/ClientUpdateRequest.php b/app/Http/Requests/Api/Client/ClientUpdateRequest.php
new file mode 100644
index 0000000..f2f50a7
--- /dev/null
+++ b/app/Http/Requests/Api/Client/ClientUpdateRequest.php
@@ -0,0 +1,34 @@
+check();
+ }
+
+ public function rules(): array
+ {
+ return [
+ 'fullname' => 'required|string|max:255',
+ 'phone' => 'required|string|max:20',
+ 'company' => 'nullable|string|max:255',
+ 'address' => 'nullable|string|max:500',
+ 'province_code' => 'nullable|string|max:10',
+ 'ward_code' => 'nullable|string|max:10',
+ 'gender' => 'nullable|in:1,2,3',
+ ];
+ }
+
+ public function messages(): array
+ {
+ return [
+ 'fullname.required' => 'Họ tên là bắt buộc',
+ 'phone.required' => 'Số điện thoại là bắt buộc',
+ ];
+ }
+}
diff --git a/app/Jobs/Mail/Customer/DepositSuccessJob.php b/app/Jobs/Mail/Customer/DepositSuccessJob.php
new file mode 100644
index 0000000..b90a61d
--- /dev/null
+++ b/app/Jobs/Mail/Customer/DepositSuccessJob.php
@@ -0,0 +1,36 @@
+data = $data;
+ }
+
+ public function handle(): void
+ {
+ try {
+ Mail::to($this->data['customer_email'])
+ ->send(new DepositSuccess($this->data));
+ } catch (\Throwable $e) {
+ \Log::error('Không thể gửi email thông báo nạp tiền thành công: ' . $e->getMessage(), [
+ 'customer_email' => $this->data['customer_email'] ?? null,
+ 'transaction_code' => $this->data['transaction_code'] ?? null,
+ ]);
+ }
+ }
+}
diff --git a/app/Mail/Customer/DepositSuccess.php b/app/Mail/Customer/DepositSuccess.php
new file mode 100644
index 0000000..8583e8c
--- /dev/null
+++ b/app/Mail/Customer/DepositSuccess.php
@@ -0,0 +1,50 @@
+data = $data;
+ }
+
+ public function envelope(): Envelope
+ {
+ return new Envelope(
+ subject: '✅ Nạp tiền thành công - ' . number_format($this->data['amount']) . ' VNĐ',
+ );
+ }
+
+ public function content(): Content
+ {
+ return new Content(
+ view: 'emails.customer.deposit-success',
+ with: [
+ 'customerName' => $this->data['customer_name'] ?? 'Khách hàng',
+ 'transactionCode' => $this->data['transaction_code'] ?? 'N/A',
+ 'amount' => $this->data['amount'] ?? 0,
+ 'amountFormatted' => number_format($this->data['amount']) ?? '0',
+ 'credit' => $this->data['credit'] ?? 0,
+ 'creditFormatted' => number_format($this->data['credit']) ?? '0',
+ 'currentTotal' => $this->data['current_total'] ?? 0,
+ 'currentTotalFormatted' => number_format($this->data['current_total']) ?? '0',
+ 'currentCredit' => $this->data['current_credit'] ?? 0,
+ 'currentCreditFormatted' => number_format($this->data['current_credit']) ?? '0',
+ 'depositDate' => $this->data['deposit_date'] ?? now()->format('d/m/Y H:i:s'),
+ 'supportEmail' => config('mail.support_email', 'support@thegioiso.com'),
+ 'supportPhone' => config('mail.support_phone', '1900.xxxx'),
+ ],
+ );
+ }
+}
diff --git a/app/Models/Customer.php b/app/Models/Customer.php
index 6c35446..32185c2 100644
--- a/app/Models/Customer.php
+++ b/app/Models/Customer.php
@@ -52,6 +52,25 @@ class Customer extends Authenticatable implements JWTSubject
'ward_code',
];
+ protected $updatable = [
+ 'fullname',
+ 'phone',
+ 'company',
+ 'address',
+ 'province_code',
+ 'ward_code',
+ 'gender',
+ ];
+
+ public function updatableFill(array $data): self
+ {
+ $data = array_intersect_key($data, array_flip($this->updatable));
+ foreach ($data as $key => $value) {
+ $this->{$key} = $value;
+ }
+ return $this;
+ }
+
/**
* Appends for API
*/
diff --git a/public/images/image.png b/public/images/image.png
new file mode 100644
index 0000000..cda3c7d
Binary files /dev/null and b/public/images/image.png differ
diff --git a/resources/views/emails/customer/deposit-success.blade.php b/resources/views/emails/customer/deposit-success.blade.php
new file mode 100644
index 0000000..5184d71
--- /dev/null
+++ b/resources/views/emails/customer/deposit-success.blade.php
@@ -0,0 +1,443 @@
+
+
+
+
+
+ Nạp tiền thành công
+
+
+
+
+
+
+ | Đây là email tự động. Quý khách vui lòng không trả lời email này. |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | {{ $depositDate }} |
+ Hotline: {{ $supportPhone }} |
+
+
+
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+ |
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+
+
+ |
+ CÔNG TY CỔ PHẦN GIẢI PHÁP CÔNG NGHỆ THẾ GIỚI SỐ DỊCH VỤ SERVER - CLOUD - VPS CHUYÊN NGHIỆP
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ |
+ Chào khách hàng {{ $customerName }},
+ Thế Giới Số trân trọng cảm ơn quý khách hàng đã quan tâm và sử dụng dịch vụ trong thời gian qua.
+ Chúng tôi xin thông báo về việc nạp tiền vào tài khoản thành công.
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ | Thông tin giao dịch |
+ Chi tiết |
+
+
+
+
+ | Mã giao dịch |
+ {{ $transactionCode }} |
+
+
+ | Số tiền nạp |
+ {{ $amountFormatted }} VNĐ |
+
+
+ | Credit nhận được |
+ {{ $creditFormatted }} Credit |
+
+
+ | Thời gian |
+ {{ $depositDate }} |
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ |
+ Số dư tài khoản sau khi nạp:
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ | Loại |
+ Số dư hiện tại |
+
+
+
+
+ | Số dư VNĐ |
+ {{ $currentTotalFormatted }} VNĐ |
+
+
+ | Số dư Credit |
+ {{ $currentCreditFormatted }} Credit |
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ |
+ Lưu ý:
+ - Credit có thể được sử dụng để đăng ký các dịch vụ của Thế Giới Số như: Hosting, VPS, Server, Tên miền, SSL...
+ - Số dư VNĐ trong tài khoản sẽ được sử dụng để thanh toán các đơn hàng.
+ Nếu quý khách cần hỗ trợ, vui lòng liên hệ với chúng tôi.
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+ |
+ THANH TOÁN CHUYỂN KHOẢN
+ Tên tài khoản: Công ty Cổ Phần Giải Pháp Công nghệ Thế Giới Số Số TK VNĐ: 0999999999 Ngân hàng: VNPAY
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+ Copyright (c) 2024 The Gioi So. All Rights Reserved
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+
+ |
+
+
+ |
+
+ |
+
+
+
+ |
+
+
+
+
+
diff --git a/routes/client.php b/routes/client.php
index 9fe7d41..9756390 100644
--- a/routes/client.php
+++ b/routes/client.php
@@ -19,6 +19,7 @@ Route::prefix('v1')->as('api.')->group(function () {
Route::group(['middleware' => ['api.auth']], function () {
Route::get('me', 'me')->name('me');
Route::post('logout', 'logout')->name('logout');
+ Route::put('update', 'update')->name('update');
});
});
});