fix shipping
This commit is contained in:
@@ -2,18 +2,14 @@
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Mail\Acheminement;
|
||||
use App\Mail\ConfirmationCommande;
|
||||
use App\Mail\Preparation;
|
||||
use App\Models\Shop\Order;
|
||||
use App\Repositories\Core\DateStats;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Traits\Model\Basic;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Orders
|
||||
{
|
||||
use DateStats;
|
||||
use Basic, DateStats;
|
||||
|
||||
public static function getByUUID($uuid)
|
||||
{
|
||||
@@ -38,68 +34,6 @@ class Orders
|
||||
return ($order && $detail) ? Invoices::saveInvoice($order->id, $data) : false;
|
||||
}
|
||||
|
||||
public static function testSend($id)
|
||||
{
|
||||
self::sendPreparation($id);
|
||||
}
|
||||
|
||||
public static function sendOrderConfirmed($order_id)
|
||||
{
|
||||
$order = self::get($order_id, ['customer', 'address']);
|
||||
$mail = new ConfirmationCommande($order);
|
||||
|
||||
return Mail::to($order->customer->email)->send($mail);
|
||||
}
|
||||
|
||||
public static function sendPreparation($order_id)
|
||||
{
|
||||
$order = self::get($order_id, ['customer', 'address']);
|
||||
$mail = new Preparation($order);
|
||||
|
||||
return Mail::to($order->customer->email)->send($mail);
|
||||
}
|
||||
|
||||
public static function sendShipping($order_id)
|
||||
{
|
||||
$order = self::get($order_id, ['customer', 'address']);
|
||||
$mail = new Acheminement($order);
|
||||
|
||||
return Mail::to($order->customer->email)->send($mail);
|
||||
}
|
||||
|
||||
public static function count()
|
||||
{
|
||||
return Order::count();
|
||||
}
|
||||
|
||||
public static function countInPreparationLess24H()
|
||||
{
|
||||
$start = Carbon::now()->subHours(24);
|
||||
$end = Carbon::now();
|
||||
|
||||
return Order::preparation()->byPeriod($start, $end, 'updated_at')->count();
|
||||
}
|
||||
|
||||
public static function countInPreparationLess48H()
|
||||
{
|
||||
$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();
|
||||
}
|
||||
|
||||
public static function getTotalByPeriod($start, $end)
|
||||
{
|
||||
return self::sumByPeriod($start, $end, 'total_shipped');
|
||||
}
|
||||
|
||||
public static function edit($id)
|
||||
{
|
||||
return [
|
||||
@@ -111,16 +45,6 @@ class Orders
|
||||
];
|
||||
}
|
||||
|
||||
public static function get($id, $relations = false)
|
||||
{
|
||||
return $relations ? Order::with($relations)->findOrFail($id) : Order::findOrFail($id);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
return ($data['id'] ?? false) ? self::update($data) : self::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
OrderStats::increase();
|
||||
@@ -130,20 +54,6 @@ class Orders
|
||||
return Order::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$item = self::get($id);
|
||||
$item->update($data);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function delete($id)
|
||||
{
|
||||
return Order::destroy($id);
|
||||
}
|
||||
|
||||
public static function download($id)
|
||||
{
|
||||
dump($id);
|
||||
@@ -180,9 +90,9 @@ class Orders
|
||||
public static function getNewRef()
|
||||
{
|
||||
$ref = date('ym').'00000';
|
||||
$last_ref = Order::orderBy('id', 'desc')->first();
|
||||
$lastRef = Order::orderBy('id', 'desc')->first();
|
||||
|
||||
return $last_ref ? $last_ref->ref + 1 : $ref + 1;
|
||||
return $lastRef ? $lastRef->ref + 1 : $ref + 1;
|
||||
}
|
||||
|
||||
public static function getModel()
|
||||
|
||||
Reference in New Issue
Block a user