update checkout
This commit is contained in:
parent
87157d859f
commit
ce6a6d31d8
|
|
@ -21,4 +21,11 @@ class CheckoutController extends Controller
|
|||
$data = CheckoutService::checkoutData();
|
||||
return view('checkout', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
{
|
||||
$requestData = $request->all();
|
||||
$data = CheckoutService::update($requestData);
|
||||
return view('checkout', $data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ Route::prefix('/')
|
|||
Route::delete('carts/{cart}', [CartController::class, 'destroy'])->name('carts.destroy');
|
||||
|
||||
Route::get('checkout', [CheckoutController::class, 'index'])->name('checkout.index');
|
||||
Route::put('checkout', [CheckoutController::class, 'update'])->name('checkout.update');
|
||||
|
||||
Route::get('categories', [CategoryController::class, 'index'])->name('categories.index');
|
||||
Route::get('categories/{category}', [CategoryController::class, 'show'])->name('categories.show');
|
||||
|
|
|
|||
|
|
@ -20,6 +20,11 @@ use Beike\Shop\Http\Resources\Checkout\ShippingMethodItem;
|
|||
|
||||
class CheckoutService
|
||||
{
|
||||
/**
|
||||
* 获取结账页数据
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function checkoutData(): array
|
||||
{
|
||||
$customer = current_customer();
|
||||
|
|
@ -48,4 +53,51 @@ class CheckoutService
|
|||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新结账页数据
|
||||
*
|
||||
* @param $requestData ['shipping_address_id'=>1, 'payment_address_id'=>2, 'shipping_method'=>'code', 'payment_method'=>'code']
|
||||
* @return array
|
||||
*/
|
||||
public static function update($requestData): array
|
||||
{
|
||||
$shippingAddressId = $requestData['shipping_address_id'] ?? 0;
|
||||
$paymentAddressId = $requestData['payment_address_id'] ?? 0;
|
||||
$shippingMethod = $requestData['shipping_method'] ?? '';
|
||||
$paymentMethod = $requestData['payment_method'] ?? '';
|
||||
if ($shippingAddressId) {
|
||||
self::updateShippingAddressId($shippingAddressId);
|
||||
}
|
||||
if ($paymentAddressId) {
|
||||
self::updatePaymentAddressId($shippingAddressId);
|
||||
}
|
||||
if ($shippingMethod) {
|
||||
self::updateShippingMethod($shippingMethod);
|
||||
}
|
||||
if ($paymentMethod) {
|
||||
self::updatePaymentMethod($paymentMethod);
|
||||
}
|
||||
return self::checkoutData();
|
||||
}
|
||||
|
||||
private static function updateShippingAddressId($shippingAddressId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static function updatePaymentAddressId($shippingAddressId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static function updateShippingMethod($shippingAddressId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static function updatePaymentMethod($paymentMethod)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue