|
@@ -2,22 +2,28 @@
|
|
|
|
|
|
|
|
namespace Longyi\RewardPoints\Http\Controllers;
|
|
namespace Longyi\RewardPoints\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
|
|
+use Longyi\RewardPoints\Models\RewardActiveRule;
|
|
|
use Longyi\RewardPoints\Repositories\RewardPointRepository;
|
|
use Longyi\RewardPoints\Repositories\RewardPointRepository;
|
|
|
|
|
+use Longyi\RewardPoints\Repositories\RewardPointSettingRepository;
|
|
|
use Longyi\RewardPoints\Models\RewardPointCustomerSign;
|
|
use Longyi\RewardPoints\Models\RewardPointCustomerSign;
|
|
|
-use Longyi\RewardPoints\Models\RewardActiveRule;
|
|
|
|
|
|
|
+use Longyi\RewardPoints\Helpers\ApiResponse;
|
|
|
use Carbon\Carbon;
|
|
use Carbon\Carbon;
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Routing\Controller;
|
|
use Illuminate\Routing\Controller;
|
|
|
-use Webkul\User\Repositories\RoleRepository;
|
|
|
|
|
-use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
+use Longyi\RewardPoints\Models\RewardPointHistory;
|
|
|
class RewardPointsController extends Controller
|
|
class RewardPointsController extends Controller
|
|
|
{
|
|
{
|
|
|
protected $rewardPointRepository;
|
|
protected $rewardPointRepository;
|
|
|
|
|
+ protected $settingRepository;
|
|
|
protected $_config;
|
|
protected $_config;
|
|
|
|
|
|
|
|
- public function __construct(RewardPointRepository $rewardPointRepository)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public function __construct(
|
|
|
|
|
+ RewardPointRepository $rewardPointRepository,
|
|
|
|
|
+ RewardPointSettingRepository $settingRepository
|
|
|
|
|
+ ) {
|
|
|
$this->rewardPointRepository = $rewardPointRepository;
|
|
$this->rewardPointRepository = $rewardPointRepository;
|
|
|
|
|
+ $this->settingRepository = $settingRepository;
|
|
|
$this->_config = request('_config');
|
|
$this->_config = request('_config');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -40,7 +46,13 @@ class RewardPointsController extends Controller
|
|
|
$customer = auth()->guard('customer')->user();
|
|
$customer = auth()->guard('customer')->user();
|
|
|
|
|
|
|
|
if (!$customer) {
|
|
if (!$customer) {
|
|
|
- return response()->json(['error' => 'Please login first'], 401);
|
|
|
|
|
|
|
+ return ApiResponse::unauthorized();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Check if sign in feature is enabled
|
|
|
|
|
+ $signinEnabled = $this->settingRepository->getConfigValue('signin_enabled', true);
|
|
|
|
|
+ if (!$signinEnabled) {
|
|
|
|
|
+ return ApiResponse::forbidden('Sign in feature is disabled');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$today = Carbon::now()->format('Y-m-d');
|
|
$today = Carbon::now()->format('Y-m-d');
|
|
@@ -50,7 +62,7 @@ class RewardPointsController extends Controller
|
|
|
->first();
|
|
->first();
|
|
|
|
|
|
|
|
if ($existingSign) {
|
|
if ($existingSign) {
|
|
|
- return response()->json(['error' => 'Already signed in today'], 400);
|
|
|
|
|
|
|
+ return ApiResponse::error('Already signed in today');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$lastSign = RewardPointCustomerSign::where('customer_id', $customer->id)
|
|
$lastSign = RewardPointCustomerSign::where('customer_id', $customer->id)
|
|
@@ -61,7 +73,7 @@ class RewardPointsController extends Controller
|
|
|
if ($lastSign) {
|
|
if ($lastSign) {
|
|
|
$lastSignDate = Carbon::parse($lastSign->sign_date);
|
|
$lastSignDate = Carbon::parse($lastSign->sign_date);
|
|
|
$yesterday = Carbon::yesterday();
|
|
$yesterday = Carbon::yesterday();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ($lastSignDate->toDateString() === $yesterday->toDateString()) {
|
|
if ($lastSignDate->toDateString() === $yesterday->toDateString()) {
|
|
|
$countDate = $lastSign->count_date + 1;
|
|
$countDate = $lastSign->count_date + 1;
|
|
|
} elseif ($lastSignDate->toDateString() !== $today) {
|
|
} elseif ($lastSignDate->toDateString() !== $today) {
|
|
@@ -69,54 +81,68 @@ class RewardPointsController extends Controller
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $rule = RewardActiveRule::where('type_of_transaction', RewardActiveRule::TYPE_SIGN_IN)
|
|
|
|
|
- ->where('status', 1)
|
|
|
|
|
- ->first();
|
|
|
|
|
-
|
|
|
|
|
- $basePoints = config('rewardpoints.sign_in.base_points', 10);
|
|
|
|
|
- $points = $rule ? $rule->reward_point : $basePoints;
|
|
|
|
|
-
|
|
|
|
|
- if ($countDate % 30 == 0) {
|
|
|
|
|
- $bonusPoints = config('rewardpoints.sign_in.month_bonus_points', 100);
|
|
|
|
|
- $points += $bonusPoints;
|
|
|
|
|
- } elseif ($countDate % 7 == 0) {
|
|
|
|
|
- $bonusPoints = config('rewardpoints.sign_in.week_bonus_points', 20);
|
|
|
|
|
- $points += $bonusPoints;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // Get sign in points from ly_mw_reward_points_settings table
|
|
|
|
|
+ $points = $this->getSignInPointsByDay($countDate);
|
|
|
|
|
|
|
|
|
|
+ // Create sign in record (Laravel auto-maintains created_at and updated_at)
|
|
|
$sign = RewardPointCustomerSign::create([
|
|
$sign = RewardPointCustomerSign::create([
|
|
|
'customer_id' => $customer->id,
|
|
'customer_id' => $customer->id,
|
|
|
'sign_date' => $today,
|
|
'sign_date' => $today,
|
|
|
'count_date' => $countDate,
|
|
'count_date' => $countDate,
|
|
|
'point' => $points,
|
|
'point' => $points,
|
|
|
- 'code' => uniqid('SIGN_'),
|
|
|
|
|
- 'created' => Carbon::now(),
|
|
|
|
|
- 'updated' => Carbon::now()
|
|
|
|
|
|
|
+ 'code' => uniqid('SIGN_')
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
|
|
+ // Add points to customer account
|
|
|
$this->rewardPointRepository->addPoints(
|
|
$this->rewardPointRepository->addPoints(
|
|
|
$customer->id,
|
|
$customer->id,
|
|
|
- RewardActiveRule::TYPE_SIGN_IN,
|
|
|
|
|
|
|
+ RewardActiveRule::TYPE_SIGN_IN,
|
|
|
$points,
|
|
$points,
|
|
|
null,
|
|
null,
|
|
|
- "Daily sign-in bonus (Day {$countDate})"
|
|
|
|
|
|
|
+ "Daily sign-in reward (Day {$countDate})"
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- return response()->json([
|
|
|
|
|
- 'success' => true,
|
|
|
|
|
|
|
+ $totalPoints = $this->rewardPointRepository->getCustomerPoints($customer->id);
|
|
|
|
|
+
|
|
|
|
|
+ return ApiResponse::success([
|
|
|
'points' => $points,
|
|
'points' => $points,
|
|
|
'streak' => $countDate,
|
|
'streak' => $countDate,
|
|
|
- 'total_points' => $this->rewardPointRepository->getCustomerPoints($customer->id)
|
|
|
|
|
- ]);
|
|
|
|
|
|
|
+ 'total_points' => $totalPoints
|
|
|
|
|
+ ], "Sign in successful! Earned {$points} points");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Get sign in points by day from ly_mw_reward_points_settings table
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function getSignInPointsByDay($day)
|
|
|
|
|
+ {
|
|
|
|
|
+ // Map sign in days to configuration codes
|
|
|
|
|
+ $dayPointsMap = [
|
|
|
|
|
+ 1 => 'signin_day1_points',
|
|
|
|
|
+ 2 => 'signin_day2_points',
|
|
|
|
|
+ 3 => 'signin_day3_points',
|
|
|
|
|
+ 4 => 'signin_day4_points',
|
|
|
|
|
+ 5 => 'signin_day5_points',
|
|
|
|
|
+ 6 => 'signin_day6_points',
|
|
|
|
|
+ 7 => 'signin_day7_points',
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ // If <= 7 days, use corresponding configuration
|
|
|
|
|
+ if ($day <= 7 && isset($dayPointsMap[$day])) {
|
|
|
|
|
+ return (int) $this->settingRepository->getConfigValue($dayPointsMap[$day], 10);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 8 days and beyond, use signin_day8_plus_points configuration
|
|
|
|
|
+ return (int) $this->settingRepository->getConfigValue('signin_day8_plus_points', 70);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
public function getSignStatus()
|
|
public function getSignStatus()
|
|
|
{
|
|
{
|
|
|
$customer = auth()->guard('customer')->user();
|
|
$customer = auth()->guard('customer')->user();
|
|
|
-
|
|
|
|
|
if (!$customer) {
|
|
if (!$customer) {
|
|
|
- return response()->json(['error' => 'Please login first'], 401);
|
|
|
|
|
|
|
+ return ApiResponse::unauthorized();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ Log::info('Customer login event triggered');
|
|
|
$today = Carbon::now()->format('Y-m-d');
|
|
$today = Carbon::now()->format('Y-m-d');
|
|
|
$signedToday = RewardPointCustomerSign::where('customer_id', $customer->id)
|
|
$signedToday = RewardPointCustomerSign::where('customer_id', $customer->id)
|
|
|
->where('sign_date', $today)
|
|
->where('sign_date', $today)
|
|
@@ -125,47 +151,153 @@ class RewardPointsController extends Controller
|
|
|
$lastSign = RewardPointCustomerSign::where('customer_id', $customer->id)
|
|
$lastSign = RewardPointCustomerSign::where('customer_id', $customer->id)
|
|
|
->orderBy('sign_date', 'desc')
|
|
->orderBy('sign_date', 'desc')
|
|
|
->first();
|
|
->first();
|
|
|
|
|
+ $currentGroup = 'sign_in';
|
|
|
|
|
+ $settings = $this->settingRepository->getSettingsByGroup($currentGroup);
|
|
|
|
|
+ $dayNamesMap = [
|
|
|
|
|
+ 'signin_day1_points' => 'Day 1 Sign-in Points',
|
|
|
|
|
+ 'signin_day2_points' => 'Day 2 Sign-in Points',
|
|
|
|
|
+ 'signin_day3_points' => 'Day 3 Sign-in Points',
|
|
|
|
|
+ 'signin_day4_points' => 'Day 4 Sign-in Points',
|
|
|
|
|
+ 'signin_day5_points' => 'Day 5 Sign-in Points',
|
|
|
|
|
+ 'signin_day6_points' => 'Day 6 Sign-in Points',
|
|
|
|
|
+ 'signin_day7_points' => 'Day 7 Sign-in Points',
|
|
|
|
|
+ 'signin_day8_plus_points' => 'Day 7+ Sign-in Points',
|
|
|
|
|
+ ];
|
|
|
|
|
|
|
|
- return response()->json([
|
|
|
|
|
|
|
+ $new = [];
|
|
|
|
|
+ foreach ($settings as $setting) {
|
|
|
|
|
+ $code = $setting['code'];
|
|
|
|
|
+ if (array_key_exists($code, $dayNamesMap)) {
|
|
|
|
|
+ $new[] = [
|
|
|
|
|
+ 'day' => $dayNamesMap[$code],
|
|
|
|
|
+ 'points' => $setting['value']
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return ApiResponse::success([
|
|
|
'signed_today' => $signedToday,
|
|
'signed_today' => $signedToday,
|
|
|
'current_streak' => $lastSign ? $lastSign->count_date : 0,
|
|
'current_streak' => $lastSign ? $lastSign->count_date : 0,
|
|
|
|
|
+ 'signed_detail' => $new,
|
|
|
'total_points' => $this->rewardPointRepository->getCustomerPoints($customer->id)
|
|
'total_points' => $this->rewardPointRepository->getCustomerPoints($customer->id)
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Get customer points history/records
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param Request $request
|
|
|
|
|
+ * @return \Illuminate\Http\JsonResponse
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getPointsHistory(Request $request)
|
|
|
|
|
+ {
|
|
|
|
|
+ $customer = auth()->guard('customer')->user();
|
|
|
|
|
+
|
|
|
|
|
+ if (!$customer) {
|
|
|
|
|
+ return ApiResponse::unauthorized();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Get pagination parameters
|
|
|
|
|
+ $page = $request->input('page', 1);
|
|
|
|
|
+ $limit = $request->input('per_page', 20);
|
|
|
|
|
+
|
|
|
|
|
+ // Validate limit
|
|
|
|
|
+ $limit = min(max($limit, 1), 100); // Limit between 1 and 100
|
|
|
|
|
+
|
|
|
|
|
+ // Get paginated history
|
|
|
|
|
+ $history = $this->rewardPointRepository->getHistory($customer->id, $limit,$page);
|
|
|
|
|
+
|
|
|
|
|
+ // Transform history data
|
|
|
|
|
+ $transformedHistory = collect($history->items())->map(function ($item) {
|
|
|
|
|
+ return [
|
|
|
|
|
+ 'id' => $item->history_id,
|
|
|
|
|
+ 'type' => $item->type_of_transaction,
|
|
|
|
|
+ 'type_text' => $this->getTransactionTypeText($item->type_of_transaction),
|
|
|
|
|
+ 'amount' => $item->amount,
|
|
|
|
|
+ 'balance' => $item->balance,
|
|
|
|
|
+ 'detail' => $item->transaction_detail,
|
|
|
|
|
+ 'order_id' => $item->history_order_id > 0 ? $item->history_order_id : null,
|
|
|
|
|
+ 'expired_day' => $item->expired_day,
|
|
|
|
|
+ 'expired_time' => $item->expired_time ? Carbon::parse($item->expired_time)->format('Y-m-d H:i:s') : null,
|
|
|
|
|
+ 'remaining_points' => $item->point_remaining,
|
|
|
|
|
+ 'status' => $item->status,
|
|
|
|
|
+ 'status_text' => $this->getStatusText($item->status),
|
|
|
|
|
+ 'created_at' => Carbon::parse($item->transaction_time)->format('Y-m-d H:i:s'),
|
|
|
|
|
+ ];
|
|
|
|
|
+ });
|
|
|
|
|
+ return ApiResponse::paginated(
|
|
|
|
|
+ [
|
|
|
|
|
+ 'current_points' => $this->rewardPointRepository->getCustomerPoints($customer->id),
|
|
|
|
|
+ 'history' => $transformedHistory
|
|
|
|
|
+ ],
|
|
|
|
|
+ $history
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Get customer points summary
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return \Illuminate\Http\JsonResponse
|
|
|
|
|
+ */
|
|
|
|
|
+ public function getPointsSummary()
|
|
|
|
|
+ {
|
|
|
|
|
+ $customer = auth()->guard('customer')->user();
|
|
|
|
|
+
|
|
|
|
|
+ if (!$customer) {
|
|
|
|
|
+ return ApiResponse::unauthorized();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $totalPoints = $this->rewardPointRepository->getCustomerPoints($customer->id);
|
|
|
|
|
+ // Get points expired in the last month
|
|
|
|
|
+ $oneMonthAgo = Carbon::now()->subMonth();
|
|
|
|
|
+ $recentlyExpired = RewardPointHistory::where('customer_id', $customer->id)
|
|
|
|
|
+ ->where('status', RewardPointHistory::STATUS_EXPIRED)
|
|
|
|
|
+ ->whereNotNull('expired_time')
|
|
|
|
|
+ ->where('expired_time', '>=', $oneMonthAgo)
|
|
|
|
|
+ ->sum('amount') * -1;
|
|
|
|
|
+
|
|
|
|
|
+ // Get expiring points in the next month (still valid but will expire soon)
|
|
|
|
|
+ $nextMonth = Carbon::now()->addMonth();
|
|
|
|
|
+ $expiringSoon = RewardPointHistory::where('customer_id', $customer->id)
|
|
|
|
|
+ ->where('status', RewardPointHistory::STATUS_COMPLETED)
|
|
|
|
|
+ ->whereNotNull('expired_time')
|
|
|
|
|
+ ->where('expired_time', '>', Carbon::now())
|
|
|
|
|
+ ->where('expired_time', '<=', $nextMonth)
|
|
|
|
|
+ ->sum('point_remaining');
|
|
|
|
|
+
|
|
|
|
|
+ return ApiResponse::success([
|
|
|
|
|
+ 'recently_expired' => $recentlyExpired,
|
|
|
|
|
+ 'expiring_soon' => $expiringSoon,
|
|
|
|
|
+ 'current_points' => $totalPoints
|
|
|
|
|
+ ]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Apply reward points to cart
|
|
* Apply reward points to cart
|
|
|
*/
|
|
*/
|
|
|
public function applyPoints(Request $request)
|
|
public function applyPoints(Request $request)
|
|
|
{
|
|
{
|
|
|
$points = $request->input('points', 0);
|
|
$points = $request->input('points', 0);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$cartRewardPoints = app('cartrewardpoints');
|
|
$cartRewardPoints = app('cartrewardpoints');
|
|
|
$validation = $cartRewardPoints->validatePoints($points);
|
|
$validation = $cartRewardPoints->validatePoints($points);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ($validation !== true) {
|
|
if ($validation !== true) {
|
|
|
- return response()->json([
|
|
|
|
|
- 'success' => false,
|
|
|
|
|
- 'message' => $validation
|
|
|
|
|
- ], 400);
|
|
|
|
|
|
|
+ return ApiResponse::error($validation);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
$result = $cartRewardPoints->applyPoints($points);
|
|
$result = $cartRewardPoints->applyPoints($points);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if ($result) {
|
|
if ($result) {
|
|
|
$discountDetails = $cartRewardPoints->getDiscountDetails();
|
|
$discountDetails = $cartRewardPoints->getDiscountDetails();
|
|
|
-
|
|
|
|
|
- return response()->json([
|
|
|
|
|
- 'success' => true,
|
|
|
|
|
- 'message' => 'Reward points applied successfully',
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return ApiResponse::success([
|
|
|
'discount' => $discountDetails
|
|
'discount' => $discountDetails
|
|
|
- ]);
|
|
|
|
|
|
|
+ ], 'Reward points applied successfully');
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- return response()->json([
|
|
|
|
|
- 'success' => false,
|
|
|
|
|
- 'message' => 'Failed to apply reward points'
|
|
|
|
|
- ], 400);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return ApiResponse::error('Failed to apply reward points');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -175,11 +307,8 @@ class RewardPointsController extends Controller
|
|
|
{
|
|
{
|
|
|
$cartRewardPoints = app('cartrewardpoints');
|
|
$cartRewardPoints = app('cartrewardpoints');
|
|
|
$cartRewardPoints->removePoints();
|
|
$cartRewardPoints->removePoints();
|
|
|
-
|
|
|
|
|
- return response()->json([
|
|
|
|
|
- 'success' => true,
|
|
|
|
|
- 'message' => 'Reward points removed successfully'
|
|
|
|
|
- ]);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return ApiResponse::success([], 'Reward points removed successfully');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -188,8 +317,8 @@ class RewardPointsController extends Controller
|
|
|
public function getPointsInfo()
|
|
public function getPointsInfo()
|
|
|
{
|
|
{
|
|
|
$cartRewardPoints = app('cartrewardpoints');
|
|
$cartRewardPoints = app('cartrewardpoints');
|
|
|
-
|
|
|
|
|
- return response()->json([
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return ApiResponse::success([
|
|
|
'available_points' => $cartRewardPoints->getAvailablePoints(),
|
|
'available_points' => $cartRewardPoints->getAvailablePoints(),
|
|
|
'points_used' => $cartRewardPoints->getPointsUsed(),
|
|
'points_used' => $cartRewardPoints->getPointsUsed(),
|
|
|
'discount_amount' => $cartRewardPoints->getDiscountAmount(),
|
|
'discount_amount' => $cartRewardPoints->getDiscountAmount(),
|
|
@@ -197,4 +326,41 @@ class RewardPointsController extends Controller
|
|
|
'max_points_allowed' => $cartRewardPoints->getMaxPointsByCartTotal()
|
|
'max_points_allowed' => $cartRewardPoints->getMaxPointsByCartTotal()
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Get transaction type text
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function getTransactionTypeText($type)
|
|
|
|
|
+ {
|
|
|
|
|
+ $types = [
|
|
|
|
|
+ 1 => 'Daily Sign In',
|
|
|
|
|
+ 2 => 'Registration',
|
|
|
|
|
+ 3 => 'Order Purchase',
|
|
|
|
|
+ 4 => 'Product Review',
|
|
|
|
|
+ 5 => 'Referral',
|
|
|
|
|
+ 6 => 'Birthday',
|
|
|
|
|
+ 7 => 'Share',
|
|
|
|
|
+ 8 => 'Subscription',
|
|
|
|
|
+ 9 => 'Login',
|
|
|
|
|
+ 99 => 'admin',
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ return $types[$type] ?? 'Unknown';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Get status text
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function getStatusText($status)
|
|
|
|
|
+ {
|
|
|
|
|
+ $statuses = [
|
|
|
|
|
+ 1 => 'Completed',
|
|
|
|
|
+ 0 => 'Pending',
|
|
|
|
|
+ 3 => 'Expired',
|
|
|
|
|
+ 2 => 'Cancelled'
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ return $statuses[$status] ?? 'Unknown';
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|