add shipping rules
This commit is contained in:
@@ -2,15 +2,14 @@
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Mail\Acheminement;
|
||||
use App\Mail\ConfirmationCommande;
|
||||
use App\Mail\Preparation;
|
||||
use App\Models\Shop\Order;
|
||||
use App\Repositories\Core\DateStats;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Orders
|
||||
{
|
||||
@@ -35,6 +34,7 @@ class Orders
|
||||
unset($data['detail']);
|
||||
unset($data['payment_type']);
|
||||
unset($data['sale_channel_id']);
|
||||
|
||||
return ($order && $detail) ? Invoices::saveInvoice($order->id, $data) : false;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ class Orders
|
||||
{
|
||||
$order = self::get($order_id, ['customer', 'address']);
|
||||
$mail = new ConfirmationCommande($order);
|
||||
|
||||
return Mail::to($order->customer->email)->send($mail);
|
||||
}
|
||||
|
||||
@@ -54,6 +55,7 @@ class Orders
|
||||
{
|
||||
$order = self::get($order_id, ['customer', 'address']);
|
||||
$mail = new Preparation($order);
|
||||
|
||||
return Mail::to($order->customer->email)->send($mail);
|
||||
}
|
||||
|
||||
@@ -61,6 +63,7 @@ class Orders
|
||||
{
|
||||
$order = self::get($order_id, ['customer', 'address']);
|
||||
$mail = new Acheminement($order);
|
||||
|
||||
return Mail::to($order->customer->email)->send($mail);
|
||||
}
|
||||
|
||||
@@ -73,6 +76,7 @@ class Orders
|
||||
{
|
||||
$start = Carbon::now()->subHours(24);
|
||||
$end = Carbon::now();
|
||||
|
||||
return Order::preparation()->byPeriod($start, $end, 'updated_at')->count();
|
||||
}
|
||||
|
||||
@@ -80,12 +84,14 @@ class Orders
|
||||
{
|
||||
$start = Carbon::now()->subHours(48);
|
||||
$end = Carbon::now();
|
||||
|
||||
return Order::preparation()->byPeriod($start, $end, 'updated_at')->count();
|
||||
}
|
||||
|
||||
public static function countInPreparationMore48H()
|
||||
{
|
||||
$start = Carbon::now()->subHours(48);
|
||||
|
||||
return Order::preparation()->where('updated_at', '>', $start)->count();
|
||||
}
|
||||
|
||||
@@ -120,6 +126,7 @@ class Orders
|
||||
OrderStats::increase();
|
||||
$data['uuid'] = Str::uuid()->toString();
|
||||
$data['ref'] = self::getNewRef();
|
||||
|
||||
return Order::create($data);
|
||||
}
|
||||
|
||||
@@ -128,6 +135,7 @@ class Orders
|
||||
$id = $id ? $id : $data['id'];
|
||||
$item = self::get($id);
|
||||
$item->update($data);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
@@ -150,6 +158,7 @@ class Orders
|
||||
public static function getStatusByName($name)
|
||||
{
|
||||
$data = array_flip(self::statuses());
|
||||
|
||||
return $data[$name] ?? '';
|
||||
}
|
||||
|
||||
@@ -170,8 +179,9 @@ class Orders
|
||||
|
||||
public static function getNewRef()
|
||||
{
|
||||
$ref = date('ym') . '00000';
|
||||
$ref = date('ym').'00000';
|
||||
$last_ref = Order::orderBy('id', 'desc')->first();
|
||||
|
||||
return $last_ref ? $last_ref->ref + 1 : $ref + 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user