From 2fcd62d624fde468ce6a147882759b9e0e6146dd Mon Sep 17 00:00:00 2001 From: Hritikkk9 Date: Mon, 8 Jul 2024 15:47:35 +0530 Subject: [PATCH 1/4] proration period updated --- .../APIs/Customer_API/StripeWebhookController.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/Http/Controllers/APIs/Customer_API/StripeWebhookController.php b/app/Http/Controllers/APIs/Customer_API/StripeWebhookController.php index ce05ea0..6d0fd47 100644 --- a/app/Http/Controllers/APIs/Customer_API/StripeWebhookController.php +++ b/app/Http/Controllers/APIs/Customer_API/StripeWebhookController.php @@ -92,7 +92,14 @@ class StripeWebhookController extends Controller Log::info("Referral User Subscription Updating Function Starts"); $referralUserSubscriptionData = Subscriptions::where('iam_principal_xid', $referralUserId)->where('subscription_status', '=', 'active')->first(); + + $stripe->subscriptions->update( + $referralUserSubscriptionData->subscription_id, + ['proration_behavior' => 'none'] + ); if ($referralUserSubscriptionData && $referralUserSubscriptionData->is_cancelled_subscription == 0) { + + //update subscription add 30 days trial period to this subscription $nextPaymentDate = $referralUserSubscriptionData->next_payment_date; $date = new DateTime($nextPaymentDate); @@ -129,6 +136,14 @@ class StripeWebhookController extends Controller //checkout store in db $subscriptionData = $stripe->checkout->sessions->retrieve($session->id, []); $SubscriptionObject = $stripe->subscriptions->retrieve($subscriptionData->subscription, []); + //update proration behavior + $stripe->subscriptions->update( + $subscriptionData->subscription, + ['proration_behavior' => 'none'] + ); + + //update proration behavior + $priceObject = $stripe->prices->retrieve($SubscriptionObject->plan->id, []); $amountSubtotalDollars = $subscriptionData->amount_total / 100; From e0e63c4611ee076421dcc05c8290db2d422e255e Mon Sep 17 00:00:00 2001 From: sayliraut Date: Mon, 8 Jul 2024 15:55:58 +0530 Subject: [PATCH 2/4] changes --- .../RestaurantApi_Service.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/app/Services/APIs/RestaurantService/RestaurantApi_Service.php b/app/Services/APIs/RestaurantService/RestaurantApi_Service.php index fdb4624..08405b4 100644 --- a/app/Services/APIs/RestaurantService/RestaurantApi_Service.php +++ b/app/Services/APIs/RestaurantService/RestaurantApi_Service.php @@ -40,28 +40,40 @@ class RestaurantApi_Service ->where('principal_xid', $userDetail->id) ->get(); - // $restaurantDetails = []; + $restaurantDetails = []; + $isActive = true; + $inactiveMessage = ""; foreach ($restaurantRoles as $restaurantRole) { $restaurant = ManageRestaurant::select('id', 'name', 'description', 'restaurant_id', 'address', 'image', 'bio', 'try_on_1', 'phone_number', 'try_on_2', 'try_on_3', 'try_on_4', 'exclusion', 'latitude', 'longtitude', 'is_active', 'created_by', 'modified_by', 'deleted_at', 'created_at', 'updated_at') ->where('id', $restaurantRole->restaurant_xid) - ->where('is_active', 1) ->first(); if ($restaurant) { $restaurant->image = ListingImageUrl('restaurant_images', $restaurant->image); $restaurant->description = strip_tags($restaurant->description); - // $restaurantDetails[] = $restaurant; + if ($restaurant->is_active == 0) { + $isActive = false; + $inactiveMessage = "Your restaurant is currently not participating in Cheers to the Season. Please reach out to contact@cheerstotheseason.com to re-enroll."; + } + + // Add restaurant details to the array + $restaurantDetails[] = $restaurant; } } // Construct response $response = [ 'user_detail' => $userDetail, - 'restaurant_details' => $restaurant, + 'restaurant_details' => $restaurantDetails, + 'is_active' => $isActive, ]; + if (!$isActive) { + $response['message'] = $inactiveMessage; + } + // Return JSON response with success message return jsonResponseWithSuccessMessageApi(__('auth.User_details_fetch'), $response, 200); } catch (Exception $ex) { @@ -74,6 +86,7 @@ class RestaurantApi_Service + public function updateRestaurantDetail($restIamId, $request) { try { From 69aa9acba863b75f54a15604adb089d6702985d8 Mon Sep 17 00:00:00 2001 From: sayliraut Date: Mon, 8 Jul 2024 16:40:22 +0530 Subject: [PATCH 3/4] sales graph --- .../Controllers/Admin/DashboardController.php | 74 ++++++- resources/views/Admin/dashboard.blade.php | 193 +++++++++++++----- 2 files changed, 204 insertions(+), 63 deletions(-) diff --git a/app/Http/Controllers/Admin/DashboardController.php b/app/Http/Controllers/Admin/DashboardController.php index 0480db5..1ef8bbb 100644 --- a/app/Http/Controllers/Admin/DashboardController.php +++ b/app/Http/Controllers/Admin/DashboardController.php @@ -17,14 +17,64 @@ class DashboardController extends Controller * Use : To show the dashboard. */ - // public function showDashboard(){ - - - // return view('Admin.dashboard'); - // } public function showDashboard() { - // Monthly data + + $dailyData = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("DATE(created_at) as date")) + ->whereBetween('created_at', [now()->subDays(7), now()]) // Fetch data for the last 7 days + ->groupBy(DB::raw("DATE(created_at)")) + ->orderBy(DB::raw("DATE(created_at)")) + ->pluck('count', 'date') + ->toArray(); + + $start_date = now()->subDays(7)->startOfDay(); + $end_date = now()->endOfDay(); + $formattedDailyData = []; + while ($start_date <= $end_date) { + $formattedDailyData[$start_date->format('Y-m-d')] = isset($dailyData[$start_date->format('Y-m-d')]) ? $dailyData[$start_date->format('Y-m-d')] : 0; + $start_date->addDay(); + } + + + $defaultData = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month")) + ->whereYear('created_at', date('Y')) + ->groupBy(DB::raw("MONTH(created_at)")) + ->orderBy(DB::raw("MONTH(created_at)")) + ->pluck('count', 'month') + ->toArray(); + + $months = range(1, 12); + $formattedDefaultData = []; + foreach ($months as $month) { + $formattedDefaultData[$month] = isset($defaultData[$month]) ? $defaultData[$month] : 0; + } + $quarterlyData = Subscriptions::select( + DB::raw("COUNT(*) as count"), + DB::raw("QUARTER(created_at) as quarter") + ) + ->whereYear('created_at', date('Y')) + ->groupBy(DB::raw("QUARTER(created_at)")) + ->orderBy(DB::raw("QUARTER(created_at)")) + ->pluck('count', 'quarter') + ->toArray(); + + // Ensure that $quarterlyData contains zeros for quarters with no data + for ($i = 1; $i <= 4; $i++) { + if (!isset($quarterlyData[$i])) { + $quarterlyData[$i] = 0; + } + } + + // Sort the array by quarter keys + ksort($quarterlyData); + + // Fetching data for yearly option + $yearlyData = Subscriptions::select(DB::raw("COUNT(*) as count"), DB::raw("YEAR(created_at) as year")) + ->groupBy(DB::raw("YEAR(created_at)")) + ->pluck('count', 'year') + ->toArray(); + + $dataMonthlyWithType3 = IamPrincipal::select(DB::raw("COUNT(*) as count"), DB::raw("MONTH(created_at) as month")) ->where('principal_type_xid', 3) ->whereYear('created_at', date('Y')) @@ -78,7 +128,9 @@ class DashboardController extends Controller $customerCount = IamPrincipal::where('principal_type_xid', '=', 3)->count(); $restaurantCount = Subscriptions::where('is_active', 1)->count(); - $recent_transaction = Subscriptions::with('subscription')->get()->toArray(); + $dateTime = now(); + $formattedDateTime = $dateTime->format('Y-m-d H:i:s'); + $recent_transaction = Subscriptions::where('next_payment_date', '>=', $formattedDateTime)->with('subscription')->get()->toArray(); return view('Admin.dashboard', compact( @@ -90,7 +142,13 @@ class DashboardController extends Controller 'dataQuarterlyWithType4', 'dataYearlyWithType3', 'dataYearlyWithType4', - 'recent_transaction' + 'recent_transaction', + 'dailyData', + 'formattedDailyData', + 'defaultData', + 'formattedDefaultData', + 'quarterlyData', + 'yearlyData' )); } } diff --git a/resources/views/Admin/dashboard.blade.php b/resources/views/Admin/dashboard.blade.php index 8e23a70..2f333c4 100644 --- a/resources/views/Admin/dashboard.blade.php +++ b/resources/views/Admin/dashboard.blade.php @@ -64,41 +64,38 @@
-
-
-
-
-
-
User Graph
- -
-
+
+
+
+
+
User Graph
+
+
- {{--
-
-
-
-
Sales Graph
- -
-
-
-
-
-
--}} - +
+
+
+
+
Sales Graph
+ +
+
+
+
+
@@ -346,7 +343,6 @@ }); }); -