1
0

提交代码

This commit is contained in:
2020-08-06 14:45:56 +08:00
commit 9d0d5f4be9
361 changed files with 36445 additions and 0 deletions

View 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());
}
}
}