fixed checkout service
This commit is contained in:
parent
622901eaf5
commit
95ad14093a
|
|
@ -15,8 +15,16 @@ class ProductSku extends Base
|
||||||
'images' => 'array',
|
'images' => 'array',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $appends = ['image'];
|
||||||
|
|
||||||
public function product()
|
public function product()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Product::class);
|
return $this->belongsTo(Product::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getImageAttribute()
|
||||||
|
{
|
||||||
|
$images = $this->images ?? [];
|
||||||
|
return $images[0] ?? '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,8 @@ class CartDetail extends JsonResource
|
||||||
'product_id' => $this->product_id,
|
'product_id' => $this->product_id,
|
||||||
'sku_id' => $this->product_sku_id,
|
'sku_id' => $this->product_sku_id,
|
||||||
'name' => $description->name,
|
'name' => $description->name,
|
||||||
'image' => image_resize($sku->image),
|
'image' => $sku->image,
|
||||||
|
'image_url' => image_resize($sku->image),
|
||||||
'quantity' => $this->quantity,
|
'quantity' => $this->quantity,
|
||||||
'selected' => $this->selected,
|
'selected' => $this->selected,
|
||||||
'price' => $price,
|
'price' => $price,
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,7 @@ class CartService
|
||||||
return $description && $product;
|
return $description && $product;
|
||||||
});
|
});
|
||||||
|
|
||||||
$cartList = CartDetail::collection($cartItems)->jsonSerialize();
|
return CartDetail::collection($cartItems)->jsonSerialize();
|
||||||
return $cartList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,10 @@
|
||||||
|
|
||||||
namespace Beike\Shop\Services;
|
namespace Beike\Shop\Services;
|
||||||
|
|
||||||
use Beike\Models\Cart;
|
|
||||||
use Beike\Models\CartProduct;
|
|
||||||
use Beike\Models\Customer;
|
use Beike\Models\Customer;
|
||||||
use Beike\Models\Order;
|
|
||||||
use Beike\Repositories\CartRepo;
|
use Beike\Repositories\CartRepo;
|
||||||
use Beike\Repositories\OrderRepo;
|
use Beike\Repositories\OrderRepo;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Beike\Repositories\PluginRepo;
|
use Beike\Repositories\PluginRepo;
|
||||||
use Beike\Repositories\AddressRepo;
|
use Beike\Repositories\AddressRepo;
|
||||||
use Beike\Repositories\CountryRepo;
|
use Beike\Repositories\CountryRepo;
|
||||||
|
|
@ -81,9 +79,15 @@ class CheckoutService
|
||||||
$checkoutData = self::checkoutData();
|
$checkoutData = self::checkoutData();
|
||||||
$checkoutData['customer'] = $customer;
|
$checkoutData['customer'] = $customer;
|
||||||
|
|
||||||
$order = OrderRepo::create($checkoutData);
|
try {
|
||||||
|
DB::beginTransaction();
|
||||||
CartRepo::clearSelectedCartProducts($customer);
|
$order = OrderRepo::create($checkoutData);
|
||||||
|
CartRepo::clearSelectedCartProducts($customer);
|
||||||
|
DB::commit();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
DB::rollBack();
|
||||||
|
dd($e);
|
||||||
|
}
|
||||||
|
|
||||||
// Notification::endmail();
|
// Notification::endmail();
|
||||||
// Notification::sendsms();
|
// Notification::sendsms();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue