适配到店自提功能添加一些hook
This commit is contained in:
parent
3c6442d698
commit
f26cbaf0dd
|
|
@ -12,7 +12,6 @@
|
|||
namespace Beike\Admin\Http\Controllers;
|
||||
|
||||
use Beike\Models\Order;
|
||||
use Beike\Services\ShipmentService;
|
||||
use Illuminate\Http\Request;
|
||||
use Beike\Repositories\OrderRepo;
|
||||
use Beike\Services\StateMachineService;
|
||||
|
|
@ -69,10 +68,8 @@ class OrderController extends Controller
|
|||
public function show(Request $request, Order $order)
|
||||
{
|
||||
$order->load(['orderTotals', 'orderHistories', 'orderShipments']);
|
||||
$data = [
|
||||
'order' => $order,
|
||||
'statuses' => StateMachineService::getInstance($order)->nextBackendStatuses()
|
||||
];
|
||||
$data = hook_filter('account_order_detail', ['order' => $order, 'html_items' => []]);
|
||||
$data['statuses'] = StateMachineService::getInstance($order)->nextBackendStatuses();
|
||||
return view('admin::pages.orders.form', $data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class Cart extends Base
|
|||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'customer_id', 'shipping_address_id', 'shipping_method_code', 'payment_address_id', 'payment_method_code'
|
||||
'customer_id', 'shipping_address_id', 'shipping_method_code', 'payment_address_id', 'payment_method_code', 'extra'
|
||||
];
|
||||
|
||||
public function customer(): BelongsTo
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ class CartRepo
|
|||
$cart->save();
|
||||
}
|
||||
$cart->loadMissing(['shippingAddress', 'paymentAddress']);
|
||||
$cart->extra = json_decode($cart->extra, true);
|
||||
return $cart;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ class OrderController extends Controller
|
|||
{
|
||||
$customer = current_customer();
|
||||
$order = OrderRepo::getOrderByNumber($number, $customer);
|
||||
return view('account/order_info', ['order' => $order]);
|
||||
$html = hook_filter('account_order_detail', ['order' => $order, 'html_items' => []]);
|
||||
return view('account/order_info', $html);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class CheckoutService
|
|||
$this->updatePaymentMethod($paymentMethodCode);
|
||||
}
|
||||
|
||||
hook_action('after_checkout_update', $requestData);
|
||||
hook_action('after_checkout_update', ['request_data' => $requestData, 'cart' => $this->cart]);
|
||||
|
||||
return $this->checkoutData();
|
||||
}
|
||||
|
|
@ -103,7 +103,7 @@ class CheckoutService
|
|||
StateMachineService::getInstance($order)->changeStatus(StateMachineService::UNPAID, '', true);
|
||||
CartRepo::clearSelectedCartProducts($customer);
|
||||
|
||||
hook_action('after_checkout_confirm', $order);
|
||||
hook_action('after_checkout_confirm', ['order' => $order, 'cart' => $this->cart]);
|
||||
|
||||
DB::commit();
|
||||
} catch (\Exception $e) {
|
||||
|
|
@ -207,6 +207,7 @@ class CheckoutService
|
|||
'shipping_method_code' => $currentCart->shipping_method_code,
|
||||
'payment_address_id' => $currentCart->payment_address_id,
|
||||
'payment_method_code' => $currentCart->payment_method_code,
|
||||
'extra' => $currentCart->extra,
|
||||
],
|
||||
'country_id' => (int)system_setting('base.country_id'),
|
||||
'customer_id' => $customer->id ?? null,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasColumn('carts', 'extra')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('carts', function (Blueprint $table) {
|
||||
$table->json('extra')->nullable()->after('payment_method_code');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
if (!Schema::hasColumn('carts', 'extra')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('carts', function (Blueprint $table) {
|
||||
$table->dropColumn('extra');
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue