适配到店自提功能添加一些hook
This commit is contained in:
parent
3c6442d698
commit
f26cbaf0dd
|
|
@ -12,7 +12,6 @@
|
||||||
namespace Beike\Admin\Http\Controllers;
|
namespace Beike\Admin\Http\Controllers;
|
||||||
|
|
||||||
use Beike\Models\Order;
|
use Beike\Models\Order;
|
||||||
use Beike\Services\ShipmentService;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Beike\Repositories\OrderRepo;
|
use Beike\Repositories\OrderRepo;
|
||||||
use Beike\Services\StateMachineService;
|
use Beike\Services\StateMachineService;
|
||||||
|
|
@ -69,10 +68,8 @@ class OrderController extends Controller
|
||||||
public function show(Request $request, Order $order)
|
public function show(Request $request, Order $order)
|
||||||
{
|
{
|
||||||
$order->load(['orderTotals', 'orderHistories', 'orderShipments']);
|
$order->load(['orderTotals', 'orderHistories', 'orderShipments']);
|
||||||
$data = [
|
$data = hook_filter('account_order_detail', ['order' => $order, 'html_items' => []]);
|
||||||
'order' => $order,
|
$data['statuses'] = StateMachineService::getInstance($order)->nextBackendStatuses();
|
||||||
'statuses' => StateMachineService::getInstance($order)->nextBackendStatuses()
|
|
||||||
];
|
|
||||||
return view('admin::pages.orders.form', $data);
|
return view('admin::pages.orders.form', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ class Cart extends Base
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
protected $fillable = [
|
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
|
public function customer(): BelongsTo
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ class CartRepo
|
||||||
$cart->save();
|
$cart->save();
|
||||||
}
|
}
|
||||||
$cart->loadMissing(['shippingAddress', 'paymentAddress']);
|
$cart->loadMissing(['shippingAddress', 'paymentAddress']);
|
||||||
|
$cart->extra = json_decode($cart->extra, true);
|
||||||
return $cart;
|
return $cart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,8 @@ class OrderController extends Controller
|
||||||
{
|
{
|
||||||
$customer = current_customer();
|
$customer = current_customer();
|
||||||
$order = OrderRepo::getOrderByNumber($number, $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);
|
$this->updatePaymentMethod($paymentMethodCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
hook_action('after_checkout_update', $requestData);
|
hook_action('after_checkout_update', ['request_data' => $requestData, 'cart' => $this->cart]);
|
||||||
|
|
||||||
return $this->checkoutData();
|
return $this->checkoutData();
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +103,7 @@ class CheckoutService
|
||||||
StateMachineService::getInstance($order)->changeStatus(StateMachineService::UNPAID, '', true);
|
StateMachineService::getInstance($order)->changeStatus(StateMachineService::UNPAID, '', true);
|
||||||
CartRepo::clearSelectedCartProducts($customer);
|
CartRepo::clearSelectedCartProducts($customer);
|
||||||
|
|
||||||
hook_action('after_checkout_confirm', $order);
|
hook_action('after_checkout_confirm', ['order' => $order, 'cart' => $this->cart]);
|
||||||
|
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
@ -207,6 +207,7 @@ class CheckoutService
|
||||||
'shipping_method_code' => $currentCart->shipping_method_code,
|
'shipping_method_code' => $currentCart->shipping_method_code,
|
||||||
'payment_address_id' => $currentCart->payment_address_id,
|
'payment_address_id' => $currentCart->payment_address_id,
|
||||||
'payment_method_code' => $currentCart->payment_method_code,
|
'payment_method_code' => $currentCart->payment_method_code,
|
||||||
|
'extra' => $currentCart->extra,
|
||||||
],
|
],
|
||||||
'country_id' => (int)system_setting('base.country_id'),
|
'country_id' => (int)system_setting('base.country_id'),
|
||||||
'customer_id' => $customer->id ?? null,
|
'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