You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
839 B
35 lines
839 B
<?php
|
|
|
|
namespace App\Admin\Actions\Post;
|
|
|
|
use App\Enums\OrderShipStatusEnum;
|
|
use App\Enums\OrderStatusEnum;
|
|
use App\Models\Order;
|
|
use App\Models\User;
|
|
use Encore\Admin\Actions\RowAction;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Http\Request;
|
|
|
|
class OrderReceivedAction extends RowAction
|
|
{
|
|
public $name = '确认收货';
|
|
|
|
public function handle(Order $order)
|
|
{
|
|
if ($order->status != OrderStatusEnum::PAID) {
|
|
|
|
return back()->withErrors('订单未付款', 'error');
|
|
}
|
|
|
|
if ($order->ship_status != OrderShipStatusEnum::DELIVERED) {
|
|
|
|
return back()->withErrors('订单未发货', 'error');
|
|
}
|
|
|
|
$order->ship_status = OrderShipStatusEnum::RECEIVED;
|
|
$order->save();
|
|
|
|
return $this->response()->success('确认收货成功.')->refresh();
|
|
}
|
|
}
|