@fleetbase/storefront-engine 0.3.22 → 0.3.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/addon/services/storefront.js +1 -1
- package/composer.json +1 -1
- package/extension.json +1 -1
- package/package.json +1 -1
- package/server/src/Console/Commands/PurgeExpiredCarts.php +39 -0
- package/server/src/Http/Controllers/v1/OrderController.php +43 -0
- package/server/src/Http/Resources/Product.php +6 -5
- package/server/src/Notifications/StorefrontOrderPreparing.php +5 -0
- package/server/src/Providers/StorefrontServiceProvider.php +2 -0
- package/server/src/routes.php +5 -0
|
@@ -221,7 +221,7 @@ export default class StorefrontService extends Service.extend(Evented) {
|
|
|
221
221
|
modal.startLoading();
|
|
222
222
|
|
|
223
223
|
try {
|
|
224
|
-
|
|
224
|
+
await store.save();
|
|
225
225
|
this.notifications.success(this.intl.t('storefront.service.storefront.storefront-create-success'));
|
|
226
226
|
// this.currentUser.setOption('activeStorefront', store.id);
|
|
227
227
|
this.setActiveStorefront(store);
|
package/composer.json
CHANGED
package/extension.json
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Console\Commands;
|
|
4
|
+
|
|
5
|
+
use Illuminate\Console\Command;
|
|
6
|
+
use Illuminate\Support\Facades\DB;
|
|
7
|
+
|
|
8
|
+
class PurgeExpiredCarts extends Command
|
|
9
|
+
{
|
|
10
|
+
/**
|
|
11
|
+
* The name and signature of the console command.
|
|
12
|
+
*
|
|
13
|
+
* @var string
|
|
14
|
+
*/
|
|
15
|
+
protected $signature = 'storefront:purge-carts';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The console command description.
|
|
19
|
+
*
|
|
20
|
+
* @var string
|
|
21
|
+
*/
|
|
22
|
+
protected $description = 'Permanently delete all expired carts from the database';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Execute the console command.
|
|
26
|
+
*
|
|
27
|
+
* @return int
|
|
28
|
+
*/
|
|
29
|
+
public function handle()
|
|
30
|
+
{
|
|
31
|
+
// Alternatively, using the DB facade for direct deletion
|
|
32
|
+
$dbDeletedCount = DB::table('carts')->where('expires_at', '<', now())->delete();
|
|
33
|
+
|
|
34
|
+
// Log and output the results
|
|
35
|
+
$this->info("Successfully deleted {$dbDeletedCount} expired carts.");
|
|
36
|
+
|
|
37
|
+
return Command::SUCCESS;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\Storefront\Http\Controllers\v1;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Models\Order;
|
|
6
|
+
use Fleetbase\Http\Controllers\Controller;
|
|
7
|
+
use Fleetbase\Storefront\Support\Storefront;
|
|
8
|
+
use Illuminate\Http\Request;
|
|
9
|
+
|
|
10
|
+
class OrderController extends Controller
|
|
11
|
+
{
|
|
12
|
+
/**
|
|
13
|
+
* Marks a pickup order as completed by "customer pickup".
|
|
14
|
+
*
|
|
15
|
+
* @return \Illuminate\Http\Response
|
|
16
|
+
*/
|
|
17
|
+
public function completeOrderPickup(Request $request)
|
|
18
|
+
{
|
|
19
|
+
$customer = Storefront::getCustomerFromToken();
|
|
20
|
+
$order = Order::where('public_id', $request->order)->whereNull('deleted_at')->with(['customer'])->first();
|
|
21
|
+
|
|
22
|
+
if (!$order) {
|
|
23
|
+
return response()->apiError('No order found.');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Confirm the completion is done by the customer
|
|
27
|
+
if ($order->customer_uuid !== $customer->uuid) {
|
|
28
|
+
return response()->apiError('Not authorized to pickup this order for completion.');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Patch order config
|
|
32
|
+
Storefront::patchOrderConfig($order);
|
|
33
|
+
|
|
34
|
+
// update activity to completed
|
|
35
|
+
$order->updateStatus('completed');
|
|
36
|
+
|
|
37
|
+
return response()->json([
|
|
38
|
+
'status' => 'ok',
|
|
39
|
+
'order' => $order->public_id,
|
|
40
|
+
'status' => $order->status,
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -5,6 +5,7 @@ namespace Fleetbase\Storefront\Http\Resources;
|
|
|
5
5
|
use Fleetbase\Http\Resources\FleetbaseResource;
|
|
6
6
|
use Fleetbase\Support\Http;
|
|
7
7
|
use Illuminate\Support\Arr;
|
|
8
|
+
use Illuminate\Support\Collection;
|
|
8
9
|
use Illuminate\Support\Str;
|
|
9
10
|
|
|
10
11
|
class Product extends FleetbaseResource
|
|
@@ -55,7 +56,7 @@ class Product extends FleetbaseResource
|
|
|
55
56
|
];
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
public function mapHours(
|
|
59
|
+
public function mapHours(Collection|array $hours = []): array
|
|
59
60
|
{
|
|
60
61
|
if (empty($hours)) {
|
|
61
62
|
return [];
|
|
@@ -79,7 +80,7 @@ class Product extends FleetbaseResource
|
|
|
79
80
|
);
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
public function mapFiles(
|
|
83
|
+
public function mapFiles(Collection|array $files = [], $contentType = 'image')
|
|
83
84
|
{
|
|
84
85
|
return collect($files)->map(function ($file) use ($contentType) {
|
|
85
86
|
if (!Str::contains($file->content_type, $contentType)) {
|
|
@@ -90,7 +91,7 @@ class Product extends FleetbaseResource
|
|
|
90
91
|
})->filter()->values();
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
public function mapAddonCategories(
|
|
94
|
+
public function mapAddonCategories(Collection|array $addonCategories = [])
|
|
94
95
|
{
|
|
95
96
|
return collect($addonCategories)->map(function ($addonCategory) {
|
|
96
97
|
$addons = data_get($addonCategory, 'category.addons', []);
|
|
@@ -122,7 +123,7 @@ class Product extends FleetbaseResource
|
|
|
122
123
|
});
|
|
123
124
|
}
|
|
124
125
|
|
|
125
|
-
public function mapProductAddons(
|
|
126
|
+
public function mapProductAddons(Collection|array $addons = [], $excluded = [])
|
|
126
127
|
{
|
|
127
128
|
return collect($addons)->map(function ($addon) use ($excluded) {
|
|
128
129
|
if (is_array($excluded) && in_array($addon->uuid, $excluded)) {
|
|
@@ -159,7 +160,7 @@ class Product extends FleetbaseResource
|
|
|
159
160
|
})->filter()->values();
|
|
160
161
|
}
|
|
161
162
|
|
|
162
|
-
public function mapVariants(
|
|
163
|
+
public function mapVariants(Collection|array $variants = [])
|
|
163
164
|
{
|
|
164
165
|
return collect($variants)->map(function ($variant) {
|
|
165
166
|
$productVariantArr = [
|
|
@@ -5,7 +5,9 @@ namespace Fleetbase\Storefront\Notifications;
|
|
|
5
5
|
use Exception;
|
|
6
6
|
use Fleetbase\FleetOps\Models\Order;
|
|
7
7
|
use Fleetbase\FleetOps\Support\Utils;
|
|
8
|
+
use Fleetbase\Storefront\Models\Network;
|
|
8
9
|
use Fleetbase\Storefront\Models\NotificationChannel;
|
|
10
|
+
use Fleetbase\Storefront\Models\Store;
|
|
9
11
|
use Fleetbase\Storefront\Support\Storefront;
|
|
10
12
|
// use Fleetbase\FleetOps\Support\Utils;
|
|
11
13
|
use Illuminate\Bus\Queueable;
|
|
@@ -28,6 +30,9 @@ class StorefrontOrderPreparing extends Notification
|
|
|
28
30
|
{
|
|
29
31
|
use Queueable;
|
|
30
32
|
|
|
33
|
+
public Order $order;
|
|
34
|
+
public Store|Network $storefront;
|
|
35
|
+
|
|
31
36
|
/**
|
|
32
37
|
* Create a new notification instance.
|
|
33
38
|
*
|
|
@@ -55,6 +55,7 @@ class StorefrontServiceProvider extends CoreServiceProvider
|
|
|
55
55
|
public $commands = [
|
|
56
56
|
\Fleetbase\Storefront\Console\Commands\NotifyStorefrontOrderNearby::class,
|
|
57
57
|
\Fleetbase\Storefront\Console\Commands\SendOrderNotification::class,
|
|
58
|
+
\Fleetbase\Storefront\Console\Commands\PurgeExpiredCarts::class,
|
|
58
59
|
];
|
|
59
60
|
|
|
60
61
|
/**
|
|
@@ -89,6 +90,7 @@ class StorefrontServiceProvider extends CoreServiceProvider
|
|
|
89
90
|
$this->registerCommands();
|
|
90
91
|
$this->scheduleCommands(function ($schedule) {
|
|
91
92
|
$schedule->command('storefront:notify-order-nearby')->everyMinute()->storeOutputInDb();
|
|
93
|
+
$schedule->command('storefront:purge-carts')->daily()->storeOutputInDb();
|
|
92
94
|
});
|
|
93
95
|
$this->registerObservers();
|
|
94
96
|
$this->registerMiddleware();
|
package/server/src/routes.php
CHANGED
|
@@ -84,6 +84,11 @@ Route::prefix(config('storefront.api.routing.prefix', 'storefront'))->namespace(
|
|
|
84
84
|
$router->delete('{id}', 'ReviewController@find');
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
+
// storefront/v1/orders
|
|
88
|
+
$router->group(['prefix' => 'orders'], function () use ($router) {
|
|
89
|
+
$router->put('picked-up', 'OrderController@completeOrderPickup');
|
|
90
|
+
});
|
|
91
|
+
|
|
87
92
|
// storefront/v1/customers
|
|
88
93
|
$router->group(['prefix' => 'customers'], function () use ($router) {
|
|
89
94
|
$router->put('{id}', 'CustomerController@update');
|