提交代码
This commit is contained in:
78
app/Agent/Controllers/OrderController.php
Normal file
78
app/Agent/Controllers/OrderController.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Agent\Controllers;
|
||||
|
||||
use App\Events\CardOrderSignined;
|
||||
use App\Models\CardOrder;
|
||||
use Auth;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
view()->share('app_title', '我的订单');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$orders = CardOrder::where('user_id', Auth::guard('agent')->id())
|
||||
->orderBy('id', 'desc')
|
||||
->get();
|
||||
|
||||
return view('Agent::orders.index', compact('orders'));
|
||||
}
|
||||
|
||||
public function unpay()
|
||||
{
|
||||
$orders = CardOrder::where('status', 0)
|
||||
->where('user_id', Auth::guard('agent')->id())
|
||||
->orderBy('id', 'desc')
|
||||
->get();
|
||||
return view('Agent::orders.index', compact('orders'));
|
||||
}
|
||||
|
||||
public function paid()
|
||||
{
|
||||
$orders = CardOrder::where('status', 1)
|
||||
->where('user_id', Auth::guard('agent')->id())
|
||||
->orderBy('id', 'desc')
|
||||
->get();
|
||||
return view('Agent::orders.index', compact('orders'));
|
||||
}
|
||||
|
||||
public function delivered()
|
||||
{
|
||||
$orders = CardOrder::where('status', 2)
|
||||
->where('user_id', Auth::guard('agent')->id())
|
||||
->orderBy('id', 'desc')
|
||||
->get();
|
||||
return view('Agent::orders.index', compact('orders'));
|
||||
}
|
||||
|
||||
public function signed()
|
||||
{
|
||||
$orders = CardOrder::where('status', 3)
|
||||
->where('user_id', Auth::guard('agent')->id())
|
||||
->orderBy('id', 'desc')
|
||||
->get();
|
||||
return view('Agent::orders.index', compact('orders'));
|
||||
}
|
||||
|
||||
public function sign($orderid)
|
||||
{
|
||||
$order = CardOrder::where('order_id', $orderid)->firstOrFail();
|
||||
try {
|
||||
$order->express->update([
|
||||
'receive_at' => now(),
|
||||
]);
|
||||
|
||||
$order->status = 3;
|
||||
$order->save();
|
||||
event(new CardOrderSignined($order));
|
||||
return $this->success('签收成功', route('Agent.orders.signed'));
|
||||
} catch (\Exception $e) {
|
||||
return $this->error('签收失败' . $e->getmessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user