Actualizacuion de Rama Kquiroz
This commit is contained in:
@@ -3,11 +3,14 @@
|
||||
namespace App\Http\Controllers\Api\V2;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\V2\Auction\AuctionBidProducts;
|
||||
use App\Http\Resources\V2\Auction\AuctionPurchaseHistory;
|
||||
use App\Http\Resources\V2\AuctionMiniCollection;
|
||||
use App\Http\Resources\V2\AuctionProductDetailCollection;
|
||||
use App\Http\Resources\V2\ProductMiniCollection;
|
||||
use App\Models\AuctionProductBid;
|
||||
use App\Models\Product;
|
||||
use Request;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
|
||||
class AuctionProductController extends Controller
|
||||
@@ -15,7 +18,6 @@ class AuctionProductController extends Controller
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$products = Product::latest()->where('published', 1)->where('auction_product', 1);
|
||||
if (get_setting('seller_auction_product') == 0) {
|
||||
$products = $products->where('added_by', 'admin');
|
||||
@@ -32,4 +34,32 @@ class AuctionProductController extends Controller
|
||||
$detailedProduct = Product::where('id', $id)->get();
|
||||
return new AuctionProductDetailCollection($detailedProduct);
|
||||
}
|
||||
|
||||
public function bided_products_list()
|
||||
{
|
||||
$own_bids = AuctionProductBid::where('user_id', auth()->id())->orderBy('id', 'desc')->pluck('product_id');
|
||||
$bided_products = Product::whereIn('id', $own_bids)->paginate(10);
|
||||
return AuctionBidProducts::collection($bided_products);
|
||||
}
|
||||
|
||||
public function user_purchase_history(Request $request)
|
||||
{
|
||||
|
||||
$orders = DB::table('orders')
|
||||
->orderBy('code', 'desc')
|
||||
->join('order_details', 'orders.id', '=', 'order_details.order_id')
|
||||
->join('products', 'order_details.product_id', '=', 'products.id')
|
||||
->where('orders.user_id', auth()->user()->id)
|
||||
->where('products.auction_product', '1');
|
||||
if ($request->payment_status != "" || $request->payment_status != null) {
|
||||
$orders = $orders->where('orders.payment_status', $request->payment_status);
|
||||
}
|
||||
if ($request->delivery_status != "" || $request->delivery_status != null) {
|
||||
$orders = $orders->where('orders.delivery_status', $request->delivery_status);
|
||||
}
|
||||
|
||||
$orders = $orders->select('order_details.order_id as id')->paginate(15);
|
||||
|
||||
return AuctionPurchaseHistory::collection($orders);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,17 +52,23 @@ class AuthController extends Controller
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'result' => false,
|
||||
'message' => $validator->errors()
|
||||
'message' => $validator->errors()->all()
|
||||
]);
|
||||
}
|
||||
|
||||
$user = new User([
|
||||
'name' => $request->name,
|
||||
'email' => $request->register_by == 'email' ? $request->email_or_phone : '',
|
||||
'phone' => $request->register_by == 'phone' ? $request->email_or_phone : '',
|
||||
'password' => bcrypt($request->password),
|
||||
'verification_code' => rand(100000, 999999)
|
||||
]);
|
||||
$user = new User();
|
||||
$user->name = $request->name;
|
||||
if ($request->register_by == 'email') {
|
||||
|
||||
$user->email = $request->email_or_phone;
|
||||
}
|
||||
if ($request->register_by == 'phone') {
|
||||
$user->phone = $request->email_or_phone;
|
||||
}
|
||||
$user->password = bcrypt($request->password);
|
||||
$user->verification_code = rand(100000, 999999);
|
||||
$user->save();
|
||||
|
||||
|
||||
$user->email_verified_at = null;
|
||||
if ($user->email != null) {
|
||||
@@ -172,9 +178,9 @@ class AuthController extends Controller
|
||||
if (!$user->banned) {
|
||||
if (Hash::check($request->password, $user->password)) {
|
||||
|
||||
if ($user->email_verified_at == null) {
|
||||
return response()->json(['result' => false, 'message' => translate('Please verify your account'), 'user' => null], 401);
|
||||
}
|
||||
// if ($user->email_verified_at == null) {
|
||||
// return response()->json(['result' => false, 'message' => translate('Please verify your account'), 'user' => null], 401);
|
||||
// }
|
||||
return $this->loginSuccess($user);
|
||||
} else {
|
||||
return response()->json(['result' => false, 'message' => translate('Unauthorized'), 'user' => null], 401);
|
||||
|
||||
@@ -6,6 +6,8 @@ use App\Models\Cart;
|
||||
use App\Models\Product;
|
||||
use App\Models\Shop;
|
||||
use App\Models\User;
|
||||
use App\Utility\CartUtility;
|
||||
use App\Utility\NagadUtility;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@@ -30,29 +32,29 @@ class CartController extends Controller
|
||||
|
||||
$sum = 0.00;
|
||||
$subtotal = 0.00;
|
||||
$tax = 0.00;
|
||||
$tax = 0.00;
|
||||
foreach ($items as $cartItem) {
|
||||
$product = Product::find($cartItem['product_id']);
|
||||
$subtotal += cart_product_price($cartItem, $product, false, false) * $cartItem['quantity'];
|
||||
$tax += cart_product_tax($cartItem, $product, false) * $cartItem['quantity'];
|
||||
}
|
||||
|
||||
|
||||
$shipping_cost = $items->sum('shipping_cost');
|
||||
$sum = $subtotal + $tax + $shipping_cost;
|
||||
$discount = $items->sum('discount');
|
||||
$sum = ($subtotal + $tax + $shipping_cost) - $discount;
|
||||
|
||||
return response()->json([
|
||||
'sub_total' => format_price($subtotal),
|
||||
'tax' => format_price($tax),
|
||||
'shipping_cost' => format_price($shipping_cost ),
|
||||
'discount' => format_price($items->sum('discount')),
|
||||
'grand_total' => format_price($sum),
|
||||
'sub_total' => single_price($subtotal),
|
||||
'tax' => single_price($tax),
|
||||
'shipping_cost' => single_price($shipping_cost),
|
||||
'discount' => single_price($discount),
|
||||
'grand_total' => single_price($sum),
|
||||
'grand_total_value' => convert_price($sum),
|
||||
'coupon_code' => $items[0]->coupon_code,
|
||||
'coupon_applied' => $items[0]->coupon_applied == 1,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function count()
|
||||
{
|
||||
$items = auth()->user()->carts;
|
||||
@@ -63,13 +65,13 @@ class CartController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getList()
|
||||
{
|
||||
$owner_ids = Cart::where('user_id', auth()->user()->id)->select('owner_id')->groupBy('owner_id')->pluck('owner_id')->toArray();
|
||||
$currency_symbol = currency_symbol();
|
||||
$shops = [];
|
||||
$sub_total = 0.00;
|
||||
$grand_total = 0.00;
|
||||
if (!empty($owner_ids)) {
|
||||
foreach ($owner_ids as $owner_id) {
|
||||
$shop = array();
|
||||
@@ -78,124 +80,135 @@ class CartController extends Controller
|
||||
if (!empty($shop_items_raw_data)) {
|
||||
foreach ($shop_items_raw_data as $shop_items_raw_data_item) {
|
||||
$product = Product::where('id', $shop_items_raw_data_item["product_id"])->first();
|
||||
$shop_items_data_item["id"] = intval($shop_items_raw_data_item["id"]) ;
|
||||
$shop_items_data_item["owner_id"] =intval($shop_items_raw_data_item["owner_id"]) ;
|
||||
$shop_items_data_item["user_id"] =intval($shop_items_raw_data_item["user_id"]) ;
|
||||
$shop_items_data_item["product_id"] =intval($shop_items_raw_data_item["product_id"]) ;
|
||||
$price = cart_product_price($shop_items_raw_data_item, $product, false, false) * intval($shop_items_raw_data_item["quantity"]);
|
||||
$tax = cart_product_tax($shop_items_raw_data_item, $product, false);
|
||||
$shop_items_data_item["id"] = intval($shop_items_raw_data_item["id"]);
|
||||
$shop_items_data_item["owner_id"] = intval($shop_items_raw_data_item["owner_id"]);
|
||||
$shop_items_data_item["user_id"] = intval($shop_items_raw_data_item["user_id"]);
|
||||
$shop_items_data_item["product_id"] = intval($shop_items_raw_data_item["product_id"]);
|
||||
$shop_items_data_item["product_name"] = $product->getTranslation('name');
|
||||
$shop_items_data_item["auction_product"] = $product->auction_product;
|
||||
$shop_items_data_item["product_thumbnail_image"] = uploaded_asset($product->thumbnail_img);
|
||||
$shop_items_data_item["variation"] = $shop_items_raw_data_item["variation"];
|
||||
$shop_items_data_item["price"] =(double) cart_product_price($shop_items_raw_data_item, $product, false, false);
|
||||
$shop_items_data_item["price"] = (float) cart_product_price($shop_items_raw_data_item, $product, false, false);
|
||||
$shop_items_data_item["currency_symbol"] = $currency_symbol;
|
||||
$shop_items_data_item["tax"] =(double) cart_product_tax($shop_items_raw_data_item, $product,false);
|
||||
$shop_items_data_item["shipping_cost"] =(double) $shop_items_raw_data_item["shipping_cost"];
|
||||
$shop_items_data_item["quantity"] =intval($shop_items_raw_data_item["quantity"]) ;
|
||||
$shop_items_data_item["lower_limit"] = intval($product->min_qty) ;
|
||||
$shop_items_data_item["upper_limit"] = intval($product->stocks->where('variant', $shop_items_raw_data_item['variation'])->first()->qty) ;
|
||||
$shop_items_data_item["tax"] = (float) cart_product_tax($shop_items_raw_data_item, $product, false);
|
||||
$shop_items_data_item["price"] = single_price($price);
|
||||
$shop_items_data_item["currency_symbol"] = $currency_symbol;
|
||||
$shop_items_data_item["tax"] = single_price($tax);
|
||||
// $shop_items_data_item["tax"] = (float) cart_product_tax($shop_items_raw_data_item, $product, false);
|
||||
$shop_items_data_item["shipping_cost"] = (float) $shop_items_raw_data_item["shipping_cost"];
|
||||
$shop_items_data_item["quantity"] = intval($shop_items_raw_data_item["quantity"]);
|
||||
$shop_items_data_item["lower_limit"] = intval($product->min_qty);
|
||||
$shop_items_data_item["upper_limit"] = intval($product->stocks->where('variant', $shop_items_raw_data_item['variation'])->first()->qty);
|
||||
|
||||
$sub_total += $price + $tax;
|
||||
$shop_items_data[] = $shop_items_data_item;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$grand_total += $sub_total;
|
||||
$shop_data = Shop::where('user_id', $owner_id)->first();
|
||||
if ($shop_data) {
|
||||
$shop['name'] = $shop_data->name;
|
||||
$shop['owner_id'] =(int) $owner_id;
|
||||
$shop['owner_id'] = (int) $owner_id;
|
||||
$shop['sub_total'] = single_price($sub_total);
|
||||
$shop['cart_items'] = $shop_items_data;
|
||||
} else {
|
||||
$shop['name'] = "Inhouse";
|
||||
$shop['owner_id'] =(int) $owner_id;
|
||||
$shop['owner_id'] = (int) $owner_id;
|
||||
$shop['sub_total'] = single_price($sub_total);
|
||||
$shop['cart_items'] = $shop_items_data;
|
||||
}
|
||||
$shops[] = $shop;
|
||||
$sub_total = 0.00;
|
||||
}
|
||||
}
|
||||
|
||||
//dd($shops);
|
||||
|
||||
return response()->json($shops);
|
||||
return response()->json([
|
||||
"grand_total" => single_price($grand_total),
|
||||
"data" =>
|
||||
$shops
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function add(Request $request)
|
||||
{
|
||||
$carts = Cart::where('user_id', auth()->user()->id)->get();
|
||||
$check_auction_in_cart = CartUtility::check_auction_in_cart($carts);
|
||||
$product = Product::findOrFail($request->id);
|
||||
|
||||
$variant = $request->variant;
|
||||
$tax = 0;
|
||||
|
||||
if ($variant == '')
|
||||
$price = $product->unit_price;
|
||||
else {
|
||||
$product_stock = $product->stocks->where('variant', $variant)->first();
|
||||
$price = $product_stock->price;
|
||||
if ($check_auction_in_cart && $product->auction_product == 0) {
|
||||
return response()->json([
|
||||
'result' => false,
|
||||
'message' => translate('Remove auction product from cart to add this product.')
|
||||
], 200);
|
||||
}
|
||||
|
||||
//discount calculation based on flash deal and regular discount
|
||||
//calculation of taxes
|
||||
$discount_applicable = false;
|
||||
|
||||
if ($product->discount_start_date == null) {
|
||||
$discount_applicable = true;
|
||||
}
|
||||
elseif (strtotime(date('d-m-Y H:i:s')) >= $product->discount_start_date &&
|
||||
strtotime(date('d-m-Y H:i:s')) <= $product->discount_end_date) {
|
||||
$discount_applicable = true;
|
||||
}
|
||||
|
||||
if ($discount_applicable) {
|
||||
if($product->discount_type == 'percent'){
|
||||
$price -= ($price*$product->discount)/100;
|
||||
}
|
||||
elseif($product->discount_type == 'amount'){
|
||||
$price -= $product->discount;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($product->taxes as $product_tax) {
|
||||
if ($product_tax->tax_type == 'percent') {
|
||||
$tax += ($price * $product_tax->tax) / 100;
|
||||
} elseif ($product_tax->tax_type == 'amount') {
|
||||
$tax += $product_tax->tax;
|
||||
}
|
||||
if ($check_auction_in_cart == false && count($carts) > 0 && $product->auction_product == 1) {
|
||||
return response()->json([
|
||||
'result' => false,
|
||||
'message' => translate('Remove other products from cart to add this auction product.')
|
||||
], 200);
|
||||
}
|
||||
|
||||
if ($product->min_qty > $request->quantity) {
|
||||
return response()->json(['result' => false, 'message' => translate("Minimum")." {$product->min_qty} ".translate("item(s) should be ordered")], 200);
|
||||
return response()->json([
|
||||
'result' => false,
|
||||
'message' => translate("Minimum") . " {$product->min_qty} " . translate("item(s) should be ordered")
|
||||
], 200);
|
||||
}
|
||||
|
||||
$stock = $product->stocks->where('variant', $variant)->first()->qty;
|
||||
$variant = $request->variant;
|
||||
$tax = 0;
|
||||
$quantity = $request->quantity;
|
||||
|
||||
$variant_string = $variant != null && $variant != "" ? translate("for")." ($variant)" : "";
|
||||
if ($stock < $request->quantity && $product->digital == 0) {
|
||||
if ($stock == 0) {
|
||||
return response()->json(['result' => false, 'message' => "Stock out"], 200);
|
||||
} else {
|
||||
return response()->json(['result' => false, 'message' => translate("Only") ." {$stock} ".translate("item(s) are available")." {$variant_string}"], 200);
|
||||
}
|
||||
}
|
||||
$product_stock = $product->stocks->where('variant', $variant)->first();
|
||||
|
||||
$cart_item = Cart::where('product_id', $request->id)->where("user_id",auth()->id())->first();
|
||||
if($cart_item && $cart_item->product->digital == 1) {
|
||||
return response()->json(['result' => false, 'message' => 'Already added this product' ]);
|
||||
}
|
||||
|
||||
Cart::updateOrCreate([
|
||||
$cart = Cart::firstOrNew([
|
||||
'variation' => $variant,
|
||||
'user_id' => auth()->user()->id,
|
||||
'owner_id' => $product->user_id,
|
||||
'product_id' => $request->id,
|
||||
'variation' => $variant
|
||||
], [
|
||||
'price' => $price,
|
||||
'tax' => $tax,
|
||||
'shipping_cost' => 0,
|
||||
'quantity' => DB::raw("quantity + $request->quantity")
|
||||
'product_id' => $request['id']
|
||||
]);
|
||||
|
||||
if(\App\Utility\NagadUtility::create_balance_reference($request->cost_matrix) == false){
|
||||
return response()->json(['result' => false, 'message' => 'Cost matrix error' ]);
|
||||
$variant_string = $variant != null && $variant != "" ? translate("for") . " ($variant)" : "";
|
||||
|
||||
if ($cart->exists && $product->digital == 0) {
|
||||
if ($product->auction_product == 1 && ($cart->product_id == $product->id)) {
|
||||
return response()->json([
|
||||
'result' => false,
|
||||
'message' => translate('This auction product is already added to your cart.')
|
||||
], 200);
|
||||
}
|
||||
if ($product_stock->qty < $cart->quantity + $request['quantity']) {
|
||||
if ($product_stock->qty == 0) {
|
||||
return response()->json([
|
||||
'result' => false,
|
||||
'message' => translate("Stock out")
|
||||
], 200);
|
||||
} else {
|
||||
return response()->json([
|
||||
'result' => false,
|
||||
'message' => translate("Only") . " {$product_stock->qty} " . translate("item(s) are available") . " {$variant_string}"
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
if ($product->digital == 1 && ($cart->product_id == $product->id)) {
|
||||
return response()->json([
|
||||
'result' => false,
|
||||
'message' => translate('Already added this product')
|
||||
]);
|
||||
}
|
||||
$quantity = $cart->quantity + $request['quantity'];
|
||||
}
|
||||
|
||||
$price = CartUtility::get_price($product, $product_stock, $request->quantity);
|
||||
$tax = CartUtility::tax_calculation($product, $price);
|
||||
CartUtility::save_cart_data($cart, $product, $price, $tax, $quantity);
|
||||
|
||||
if (NagadUtility::create_balance_reference($request->cost_matrix) == false) {
|
||||
return response()->json(['result' => false, 'message' => 'Cost matrix error']);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
@@ -208,7 +221,10 @@ class CartController extends Controller
|
||||
{
|
||||
$cart = Cart::find($request->id);
|
||||
if ($cart != null) {
|
||||
|
||||
$product = Product::find($cart->product_id);
|
||||
if ($product->auction_product == 1) {
|
||||
return response()->json(['result' => false, 'message' => translate('Maximum available quantity reached')], 200);
|
||||
}
|
||||
if ($cart->product->stocks->where('variant', $cart->variation)->first()->qty >= $request->quantity) {
|
||||
$cart->update([
|
||||
'quantity' => $request->quantity
|
||||
@@ -235,7 +251,7 @@ class CartController extends Controller
|
||||
$product = Product::where('id', $cart_item->product_id)->first();
|
||||
|
||||
if ($product->min_qty > $cart_quantities[$i]) {
|
||||
return response()->json(['result' => false, 'message' => translate("Minimum")." {$product->min_qty} ".translate("item(s) should be ordered for")." {$product->name}"], 200);
|
||||
return response()->json(['result' => false, 'message' => translate("Minimum") . " {$product->min_qty} " . translate("item(s) should be ordered for") . " {$product->name}"], 200);
|
||||
}
|
||||
|
||||
$stock = $cart_item->product->stocks->where('variant', $cart_item->variation)->first()->qty;
|
||||
@@ -244,26 +260,21 @@ class CartController extends Controller
|
||||
$cart_item->update([
|
||||
'quantity' => $cart_quantities[$i]
|
||||
]);
|
||||
|
||||
} else {
|
||||
if ($stock == 0 ) {
|
||||
return response()->json(['result' => false, 'message' => translate("No item is available for")." {$product->name}{$variant_string},".translate("remove this from cart")], 200);
|
||||
if ($stock == 0) {
|
||||
return response()->json(['result' => false, 'message' => translate("No item is available for") . " {$product->name}{$variant_string}," . translate("remove this from cart")], 200);
|
||||
} else {
|
||||
return response()->json(['result' => false, 'message' => translate("Only")." {$stock} ".translate("item(s) are available for")." {$product->name}{$variant_string}"], 200);
|
||||
return response()->json(['result' => false, 'message' => translate("Only") . " {$stock} " . translate("item(s) are available for") . " {$product->name}{$variant_string}"], 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
return response()->json(['result' => true, 'message' => translate('Cart updated')], 200);
|
||||
|
||||
} else {
|
||||
return response()->json(['result' => false, 'message' => translate('Cart is empty')], 200);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
|
||||
@@ -94,7 +94,7 @@ class CheckoutController
|
||||
}
|
||||
|
||||
if($coupon_discount>0){
|
||||
Cart::where('user_id', auth()->user()->id)->update([
|
||||
Cart::where('user_id', auth()->user()->id)->where('owner_id', $coupon->user_id)->update([
|
||||
'discount' => $coupon_discount / count($cart_items),
|
||||
'coupon_code' => $request->coupon_code,
|
||||
'coupon_applied' => 1
|
||||
|
||||
@@ -32,7 +32,7 @@ public function purchase_package_free(Request $request)
|
||||
$user->save();
|
||||
return $this->success(translate('Package purchasing successful'));
|
||||
} else {
|
||||
return $this->failed(translate('You can not purchase this package anymore.'));
|
||||
return $this->failed(translate('You cannot purchase this package anymore.'));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,20 +16,19 @@ class DigitalProductController extends Controller
|
||||
{
|
||||
$product = Product::findOrFail($request->id);
|
||||
$orders = Order::select("id")->where('user_id', auth()->user()->id)->pluck('id');
|
||||
$orderDetails = OrderDetail::where("product_id",$request->id)->whereIn("order_id",$orders)->get();
|
||||
$orderDetails = OrderDetail::where("product_id", $request->id)->whereIn("order_id", $orders)->get();
|
||||
if (auth()->user()->user_type == 'admin' || auth()->user()->id == $product->user_id || $orderDetails) {
|
||||
$upload = Upload::findOrFail($product->file_name);
|
||||
if (env('FILESYSTEM_DRIVER') == "s3") {
|
||||
return \Storage::disk('s3')->download($upload->file_name, $upload->file_original_name . "." . $upload->extension);
|
||||
} else {
|
||||
if (file_exists(base_path('public/' . $upload->file_name))) {
|
||||
$file = public_path()."/$upload->file_name";
|
||||
return response()->download($file,config('app.name')."_".$upload->file_original_name);
|
||||
$file = public_path() . "/$upload->file_name";
|
||||
return response()->download($file, config('app.name') . "_" . $upload->file_original_name . "." . $upload->extension);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return response()->download(File("dd.pdf"),"failed.jpg");
|
||||
return response()->download(File("dd.pdf"), "failed.jpg");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@ class PaymentTypesController
|
||||
$payment_type['payment_type_key'] = 'paypal';
|
||||
$payment_type['image'] = static_asset('assets/img/cards/paypal.png');
|
||||
$payment_type['name'] = "Paypal";
|
||||
$payment_type['title'] = "Checkout with Paypal";
|
||||
$payment_type['title'] = translate("Checkout with Paypal");
|
||||
$payment_type['offline_payment_id'] = 0;
|
||||
$payment_type['details'] = "";
|
||||
if ($mode == 'wallet') {
|
||||
$payment_type['title'] = "Recharge with Paypal";
|
||||
$payment_type['title'] = translate("Recharge with Paypal");
|
||||
}
|
||||
|
||||
$payment_types[] = $payment_type;
|
||||
@@ -47,11 +47,11 @@ class PaymentTypesController
|
||||
$payment_type['payment_type_key'] = 'stripe';
|
||||
$payment_type['image'] = static_asset('assets/img/cards/stripe.png');
|
||||
$payment_type['name'] = "Stripe";
|
||||
$payment_type['title'] = "Checkout with Stripe";
|
||||
$payment_type['title'] = translate("Checkout with Stripe");
|
||||
$payment_type['offline_payment_id'] = 0;
|
||||
$payment_type['details'] = "";
|
||||
if ($mode == 'wallet') {
|
||||
$payment_type['title'] = "Recharge with Stripe";
|
||||
$payment_type['title'] = translate("Recharge with Stripe");
|
||||
}
|
||||
|
||||
$payment_types[] = $payment_type;
|
||||
@@ -62,11 +62,11 @@ class PaymentTypesController
|
||||
$payment_type['payment_type_key'] = 'instamojo_payment';
|
||||
$payment_type['image'] = static_asset('assets/img/cards/instamojo.png');
|
||||
$payment_type['name'] = "Instamojo";
|
||||
$payment_type['title'] = "Checkout with Instamojo";
|
||||
$payment_type['title'] = translate("Checkout with Instamojo");
|
||||
$payment_type['offline_payment_id'] = 0;
|
||||
$payment_type['details'] = "";
|
||||
if ($mode == 'wallet') {
|
||||
$payment_type['title'] = "Recharge with Stripe";
|
||||
$payment_type['title'] = translate("Recharge with Instamojo");
|
||||
}
|
||||
|
||||
$payment_types[] = $payment_type;
|
||||
@@ -78,11 +78,11 @@ class PaymentTypesController
|
||||
$payment_type['payment_type_key'] = 'razorpay';
|
||||
$payment_type['image'] = static_asset('assets/img/cards/rozarpay.png');
|
||||
$payment_type['name'] = "Razorpay";
|
||||
$payment_type['title'] = "Checkout with Razorpay";
|
||||
$payment_type['title'] = translate("Checkout with Razorpay");
|
||||
$payment_type['offline_payment_id'] = 0;
|
||||
$payment_type['details'] = "";
|
||||
if ($mode == 'wallet') {
|
||||
$payment_type['title'] = "Recharge with Razorpay";
|
||||
$payment_type['title'] = translate("Recharge with Razorpay");
|
||||
}
|
||||
|
||||
$payment_types[] = $payment_type;
|
||||
@@ -94,11 +94,11 @@ class PaymentTypesController
|
||||
$payment_type['payment_type_key'] = 'paystack';
|
||||
$payment_type['image'] = static_asset('assets/img/cards/paystack.png');
|
||||
$payment_type['name'] = "Paystack";
|
||||
$payment_type['title'] = "Checkout with Paystack";
|
||||
$payment_type['title'] = translate("Checkout with Paystack");
|
||||
$payment_type['offline_payment_id'] = 0;
|
||||
$payment_type['details'] = "";
|
||||
if ($mode == 'wallet') {
|
||||
$payment_type['title'] = "Recharge with Paystack";
|
||||
$payment_type['title'] = translate("Recharge with Paystack");
|
||||
}
|
||||
|
||||
$payment_types[] = $payment_type;
|
||||
@@ -110,11 +110,11 @@ class PaymentTypesController
|
||||
$payment_type['payment_type_key'] = 'iyzico';
|
||||
$payment_type['image'] = static_asset('assets/img/cards/iyzico.png');
|
||||
$payment_type['name'] = "Iyzico";
|
||||
$payment_type['title'] = "Checkout with Iyzico";
|
||||
$payment_type['title'] = translate("Checkout with Iyzico");
|
||||
$payment_type['offline_payment_id'] = 0;
|
||||
$payment_type['details'] = "";
|
||||
if ($mode == 'wallet') {
|
||||
$payment_type['title'] = "Recharge with Iyzico";
|
||||
$payment_type['title'] = translate("Recharge with Iyzico");
|
||||
}
|
||||
|
||||
$payment_types[] = $payment_type;
|
||||
@@ -126,11 +126,11 @@ class PaymentTypesController
|
||||
$payment_type['payment_type_key'] = 'bkash';
|
||||
$payment_type['image'] = static_asset('assets/img/cards/bkash.png');
|
||||
$payment_type['name'] = "Bkash";
|
||||
$payment_type['title'] = "Checkout with Bkash";
|
||||
$payment_type['title'] = translate("Checkout with Bkash");
|
||||
$payment_type['offline_payment_id'] = 0;
|
||||
$payment_type['details'] = "";
|
||||
if ($mode == 'wallet') {
|
||||
$payment_type['title'] = "Recharge with Bkash";
|
||||
$payment_type['title'] = translate("Recharge with Bkash");
|
||||
}
|
||||
|
||||
$payment_types[] = $payment_type;
|
||||
@@ -142,11 +142,11 @@ class PaymentTypesController
|
||||
$payment_type['payment_type_key'] = 'nagad';
|
||||
$payment_type['image'] = static_asset('assets/img/cards/nagad.png');
|
||||
$payment_type['name'] = "Nagad";
|
||||
$payment_type['title'] = "Checkout with Nagad";
|
||||
$payment_type['title'] = translate("Checkout with Nagad");
|
||||
$payment_type['offline_payment_id'] = 0;
|
||||
$payment_type['details'] = "";
|
||||
if ($mode == 'wallet') {
|
||||
$payment_type['title'] = "Recharge with Nagad";
|
||||
$payment_type['title'] = translate("Recharge with Nagad");
|
||||
}
|
||||
|
||||
$payment_types[] = $payment_type;
|
||||
@@ -158,11 +158,11 @@ class PaymentTypesController
|
||||
$payment_type['payment_type_key'] = 'sslcommerz';
|
||||
$payment_type['image'] = static_asset('assets/img/cards/sslcommerz.png');
|
||||
$payment_type['name'] = "Sslcommerz";
|
||||
$payment_type['title'] = "Checkout with Sslcommerz";
|
||||
$payment_type['title'] = translate("Checkout with Sslcommerz");
|
||||
$payment_type['offline_payment_id'] = 0;
|
||||
$payment_type['details'] = "";
|
||||
if ($mode == 'wallet') {
|
||||
$payment_type['title'] = "Recharge with Sslcommerz";
|
||||
$payment_type['title'] = translate("Recharge with Sslcommerz");
|
||||
}
|
||||
|
||||
$payment_types[] = $payment_type;
|
||||
@@ -176,11 +176,11 @@ class PaymentTypesController
|
||||
$payment_type['payment_type_key'] = 'flutterwave';
|
||||
$payment_type['image'] = static_asset('assets/img/cards/flutterwave.png');
|
||||
$payment_type['name'] = "Flutterwave";
|
||||
$payment_type['title'] = "Checkout with Flutterwave";
|
||||
$payment_type['title'] = translate("Checkout with Flutterwave");
|
||||
$payment_type['offline_payment_id'] = 0;
|
||||
$payment_type['details'] = "";
|
||||
if ($mode == 'wallet') {
|
||||
$payment_type['title'] = "Recharge with Flutterwave";
|
||||
$payment_type['title'] = translate("Recharge with Flutterwave");
|
||||
}
|
||||
|
||||
$payment_types[] = $payment_type;
|
||||
@@ -194,11 +194,11 @@ class PaymentTypesController
|
||||
$payment_type['payment_type_key'] = 'paytm';
|
||||
$payment_type['image'] = static_asset('assets/img/cards/paytm.jpg');
|
||||
$payment_type['name'] = "Paytm";
|
||||
$payment_type['title'] = "Checkout with Paytm";
|
||||
$payment_type['title'] = translate("Checkout with Paytm");
|
||||
$payment_type['offline_payment_id'] = 0;
|
||||
$payment_type['details'] = "";
|
||||
if ($mode == 'wallet') {
|
||||
$payment_type['title'] = "Recharge with Paytm";
|
||||
$payment_type['title'] = translate("Recharge with Paytm");
|
||||
}
|
||||
|
||||
$payment_types[] = $payment_type;
|
||||
@@ -209,11 +209,11 @@ class PaymentTypesController
|
||||
$payment_type['payment_type_key'] = 'khalti';
|
||||
$payment_type['image'] = static_asset('assets/img/cards/khalti.png');
|
||||
$payment_type['name'] = "Khalti";
|
||||
$payment_type['title'] = "Checkout with Khalti";
|
||||
$payment_type['title'] = translate("Checkout with Khalti");
|
||||
$payment_type['offline_payment_id'] = 0;
|
||||
$payment_type['details'] = "";
|
||||
if ($mode == 'wallet') {
|
||||
$payment_type['title'] = "Recharge with Khalti";
|
||||
$payment_type['title'] = translate("Recharge with Khalti");
|
||||
}
|
||||
|
||||
$payment_types[] = $payment_type;
|
||||
@@ -229,7 +229,7 @@ class PaymentTypesController
|
||||
$payment_type['payment_type_key'] = 'wallet';
|
||||
$payment_type['image'] = static_asset('assets/img/cards/wallet.png');
|
||||
$payment_type['name'] = "Wallet";
|
||||
$payment_type['title'] = "Wallet Payment";
|
||||
$payment_type['title'] = translate("Wallet Payment");
|
||||
$payment_type['offline_payment_id'] = 0;
|
||||
$payment_type['details'] = "";
|
||||
|
||||
@@ -257,7 +257,7 @@ class PaymentTypesController
|
||||
$payment_type['payment_type_key'] = 'cash_on_delivery';
|
||||
$payment_type['image'] = static_asset('assets/img/cards/cod.png');
|
||||
$payment_type['name'] = "Cash Payment";
|
||||
$payment_type['title'] = "Cash on delivery";
|
||||
$payment_type['title'] = translate("Cash on delivery");
|
||||
$payment_type['offline_payment_id'] = 0;
|
||||
$payment_type['details'] = "";
|
||||
|
||||
|
||||
@@ -6,11 +6,13 @@ use App\Http\Resources\V2\PurchasedResource;
|
||||
use App\Http\Resources\V2\PurchaseHistoryMiniCollection;
|
||||
use App\Http\Resources\V2\PurchaseHistoryCollection;
|
||||
use App\Http\Resources\V2\PurchaseHistoryItemsCollection;
|
||||
use App\Models\Cart;
|
||||
use App\Models\Order;
|
||||
use App\Models\OrderDetail;
|
||||
use App\Models\Product;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\User;
|
||||
use App\Utility\CartUtility;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class PurchaseHistoryController extends Controller
|
||||
@@ -77,4 +79,87 @@ class PurchaseHistoryController extends Controller
|
||||
|
||||
return PurchasedResource::collection($order_detail_products);
|
||||
}
|
||||
|
||||
public function re_order($id)
|
||||
{
|
||||
$user_id = auth()->user()->id;
|
||||
$success_msgs = [];
|
||||
$failed_msgs = [];
|
||||
|
||||
$carts = Cart::where('user_id', auth()->user()->id)->get();
|
||||
$check_auction_in_cart = CartUtility::check_auction_in_cart($carts);
|
||||
if ($check_auction_in_cart) {
|
||||
array_push($failed_msgs, translate('Remove auction product from cart to add products.'));
|
||||
return response()->json([
|
||||
'success_msgs' => $success_msgs,
|
||||
'failed_msgs' => $failed_msgs
|
||||
]);
|
||||
}
|
||||
|
||||
$order = Order::findOrFail($id);
|
||||
|
||||
$data['user_id'] = $user_id;
|
||||
foreach ($order->orderDetails as $key => $orderDetail) {
|
||||
$product = $orderDetail->product;
|
||||
|
||||
if (
|
||||
!$product || $product->published == 0 ||
|
||||
$product->approved == 0 || ($product->wholesale_product && !addon_is_activated("wholesale"))
|
||||
) {
|
||||
array_push($failed_msgs, translate('An item from this order is not available now.'));
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($product->auction_product == 1) {
|
||||
array_push($failed_msgs, translate('You can not re order an auction product.'));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// If product min qty is greater then the ordered qty, then update the order qty
|
||||
$order_qty = $orderDetail->quantity;
|
||||
if ($product->digital == 0 && $order_qty < $product->min_qty) {
|
||||
$order_qty = $product->min_qty;
|
||||
}
|
||||
|
||||
$cart = Cart::firstOrNew([
|
||||
'variation' => $orderDetail->variation,
|
||||
'user_id' => $user_id,
|
||||
'product_id' => $product->id
|
||||
]);
|
||||
|
||||
$product_stock = $product->stocks->where('variant', $orderDetail->variation)->first();
|
||||
if ($product_stock) {
|
||||
$quantity = 1;
|
||||
|
||||
if ($product->digital != 1) {
|
||||
$quantity = $product_stock->qty;
|
||||
if ($quantity > 0) {
|
||||
if ($cart->exists) {
|
||||
$order_qty = $cart->quantity + $order_qty;
|
||||
}
|
||||
//If order qty is greater then the product stock, set order qty = current product stock qty
|
||||
$quantity = ($quantity >= $order_qty) ? $order_qty : $quantity;
|
||||
} else {
|
||||
array_push($failed_msgs, $product->getTranslation('name') . ' ' . translate('is stock out.'));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$price = CartUtility::get_price($product, $product_stock, $quantity);
|
||||
$tax = CartUtility::tax_calculation($product, $price);
|
||||
|
||||
CartUtility::save_cart_data($cart, $product, $price, $tax, $quantity);
|
||||
array_push($success_msgs, $product->getTranslation('name') . ' ' . translate('added to cart.'));
|
||||
} else {
|
||||
array_push($failed_msgs, $product->getTranslation('name') . ' ' . translate(' is stock out.'));
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success_msgs' => $success_msgs,
|
||||
'failed_msgs' => $failed_msgs
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class ConversationController extends Controller
|
||||
|
||||
return $this->success(translate('Message send successfully'));
|
||||
}else{
|
||||
return $this->failed(translate('You can not send this message.'));
|
||||
return $this->failed(translate('You cannot send this message.'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class ConversationController extends Controller
|
||||
return new MessageCollection($messages);
|
||||
} else {
|
||||
|
||||
return $this->failed(translate('You can not see this message.'));
|
||||
return $this->failed(translate('You cannot see this message.'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V2\Seller;
|
||||
|
||||
use App\Http\Controllers\Api\V2\Controller;
|
||||
use App\Http\Resources\V2\Seller\DigitalProductCollection;
|
||||
use App\Http\Resources\V2\Seller\CategoriesCollection;
|
||||
use App\Http\Resources\V2\Seller\DigitalProductDetailsResource;
|
||||
use App\Models\Category;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductTax;
|
||||
use App\Models\ProductTranslation;
|
||||
use App\Models\Upload;
|
||||
use Auth;
|
||||
|
||||
|
||||
use App\Services\ProductService;
|
||||
use App\Services\ProductStockService;
|
||||
use App\Services\ProductTaxService;
|
||||
use Artisan;
|
||||
|
||||
class DigitalProductController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$products = Product::where('digital', 1)->where('user_id', Auth::user()->id)->orderBy('created_at', 'desc');
|
||||
return new DigitalProductCollection($products->paginate(10));
|
||||
}
|
||||
|
||||
public function getCategory()
|
||||
{
|
||||
$categories = Category::where('parent_id', 0)
|
||||
->where('digital', 1)
|
||||
->with('childrenCategories')
|
||||
->get();
|
||||
return CategoriesCollection::collection($categories);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
if (addon_is_activated('seller_subscription')) {
|
||||
if (!seller_package_validity_check(auth()->user()->id)) {
|
||||
return $this->failed(translate('Please upgrade your package.'));
|
||||
}
|
||||
}
|
||||
|
||||
if (auth()->user()->user_type != 'seller') {
|
||||
return $this->failed(translate('Unauthenticated User.'));
|
||||
}
|
||||
|
||||
// Product Store
|
||||
$product = (new ProductService)->store($request->except([
|
||||
'_token', 'tax_id', 'tax', 'tax_type'
|
||||
]));
|
||||
|
||||
$request->merge(['product_id' => $product->id, 'current_stock' => 0]);
|
||||
|
||||
//Product Stock
|
||||
(new ProductStockService)->store($request->only([
|
||||
'unit_price', 'current_stock', 'product_id'
|
||||
]), $product);
|
||||
|
||||
//VAT & Tax
|
||||
if ($request->tax_id) {
|
||||
(new ProductTaxService)->store($request->only([
|
||||
'tax_id', 'tax', 'tax_type', 'product_id'
|
||||
]));
|
||||
}
|
||||
|
||||
// Product Translations
|
||||
$request->merge(['lang' => env('DEFAULT_LANGUAGE')]);
|
||||
ProductTranslation::create($request->only([
|
||||
'lang', 'name', 'unit', 'description', 'product_id'
|
||||
]));
|
||||
|
||||
return $this->success(translate('Digital Product has been inserted successfully'));
|
||||
}
|
||||
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
$product = Product::findOrFail($id);
|
||||
$product->lang = $request->lang == null ? env("DEFAULT_LANGUAGE") : $request->lang;
|
||||
|
||||
return new DigitalProductDetailsResource($product);
|
||||
}
|
||||
|
||||
public function update(Request $request, Product $product)
|
||||
{
|
||||
//Product Update
|
||||
$product = (new ProductService)->update($request->except([
|
||||
'_token', 'tax_id', 'tax', 'tax_type'
|
||||
]), $product);
|
||||
|
||||
//Product Stock
|
||||
foreach ($product->stocks as $key => $stock) {
|
||||
$stock->delete();
|
||||
}
|
||||
|
||||
$request->merge(['product_id' => $product->id, 'current_stock' => 0]);
|
||||
|
||||
(new ProductStockService)->store($request->only([
|
||||
'unit_price', 'current_stock', 'product_id'
|
||||
]), $product);
|
||||
|
||||
//VAT & Tax
|
||||
if ($request->tax_id) {
|
||||
ProductTax::where('product_id', $product->id)->delete();
|
||||
(new ProductTaxService)->store($request->only([
|
||||
'tax_id', 'tax', 'tax_type', 'product_id'
|
||||
]));
|
||||
}
|
||||
|
||||
// Product Translations
|
||||
ProductTranslation::updateOrCreate(
|
||||
$request->only(['lang', 'product_id']),
|
||||
$request->only(['name', 'description'])
|
||||
);
|
||||
|
||||
return $this->success(translate('Digital Product has been Updated successfully'));
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$product_destroy = (new ProductService)->destroy($id);
|
||||
|
||||
if ($product_destroy) {
|
||||
Artisan::call('view:clear');
|
||||
Artisan::call('cache:clear');
|
||||
return $this->success(translate('Digital Product deleted successfully'));
|
||||
}
|
||||
return $this->failed(translate('Something Went Wrong.'));
|
||||
}
|
||||
|
||||
// Digital Product File Download
|
||||
public function download($id)
|
||||
{
|
||||
if (auth()->user()->user_type != 'seller') {
|
||||
return $this->failed(translate('Unauthenticated User.'));
|
||||
}
|
||||
|
||||
$product = Product::where('id', $id)->where('user_id', auth()->user()->id)->first();
|
||||
if (!$product) {
|
||||
return $this->failed(translate('This product is not yours'));
|
||||
}
|
||||
|
||||
$upload = Upload::findOrFail($product->file_name);
|
||||
if (env('FILESYSTEM_DRIVER') == "s3") {
|
||||
return \Storage::disk('s3')->download($upload->file_name, $upload->file_original_name . "." . $upload->extension);
|
||||
} else {
|
||||
if (file_exists(base_path('public/' . $upload->file_name))) {
|
||||
$file = public_path() . "/$upload->file_name";
|
||||
return response()->download($file, config('app.name') . "_" . $upload->file_original_name . "." . $upload->extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,6 +196,12 @@ class ProductController extends Controller
|
||||
|
||||
public function change_status(Request $request)
|
||||
{
|
||||
if (addon_is_activated('seller_subscription')) {
|
||||
if (!seller_package_validity_check()) {
|
||||
return $this->failed(translate('Please upgrade your package'));
|
||||
}
|
||||
}
|
||||
|
||||
$product = Product::where('user_id', auth()->user()->id)
|
||||
->where('id', $request->id)
|
||||
->update([
|
||||
|
||||
@@ -122,12 +122,11 @@ class ShopController extends Controller
|
||||
->select(DB::raw("sum(grand_total) as total, DATE_FORMAT(created_at, '%b-%d') as date"))
|
||||
->groupBy(DB::raw("DATE_FORMAT(created_at, '%Y-%m-%d')"))
|
||||
->get()->toArray();
|
||||
//dd($data->toArray());
|
||||
|
||||
//$array_date = [];
|
||||
$sales_array = [];
|
||||
for ($i = 0; $i < 7; $i++) {
|
||||
$new_date = date("M-d", strtotime(($i + 1) . " days ago"));
|
||||
for ($i = 1; $i < 8; $i++) {
|
||||
$new_date = date("M-d", strtotime(($i - 1) . " days ago"));
|
||||
//$array_date[] = date("M-d", strtotime($i." days ago"));
|
||||
|
||||
$sales_array[$i]['date'] = $new_date;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\V2;
|
||||
|
||||
use App\Models\Order;
|
||||
@@ -6,12 +7,15 @@ use Illuminate\Http\Request;
|
||||
use App\Http\Resources\V2\PurchaseHistoryMiniCollection;
|
||||
use App\Http\Resources\V2\PurchaseHistoryCollection;
|
||||
use App\Http\Resources\V2\PurchaseHistoryItemsCollection;
|
||||
use App\Http\Resources\V2\ShopCollection;
|
||||
use App\Models\OrderDetail;
|
||||
|
||||
class SellerController extends Controller {
|
||||
|
||||
|
||||
|
||||
class SellerController extends Controller
|
||||
{
|
||||
|
||||
public function topSellers()
|
||||
{
|
||||
$best_selers = get_best_sellers(5);
|
||||
return new ShopCollection($best_selers);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -27,39 +27,39 @@ class ShippingController extends Controller
|
||||
|
||||
foreach ($request->seller_list as $key => $seller) {
|
||||
$seller['shipping_cost'] = 0;
|
||||
|
||||
|
||||
$carts = Cart::where('user_id', auth()->user()->id)->where("owner_id", $seller['seller_id'])->get();
|
||||
|
||||
foreach ($carts as $key => $cartItem) {
|
||||
$cartItem['shipping_cost'] = 0;
|
||||
|
||||
if($seller['shipping_type'] == 'pickup_point') {
|
||||
|
||||
if ($seller['shipping_type'] == 'pickup_point') {
|
||||
$cartItem['shipping_type'] = 'pickup_point';
|
||||
$cartItem['pickup_point'] = $seller['shipping_id'];
|
||||
}else
|
||||
} else
|
||||
if ($seller['shipping_type'] == 'home_delivery') {
|
||||
$cartItem['shipping_type'] = 'home_delivery';
|
||||
$cartItem['pickup_point'] = 0;
|
||||
|
||||
|
||||
$cartItem['shipping_cost'] = getShippingCost($main_carts, $key);
|
||||
}else
|
||||
} else
|
||||
if ($seller['shipping_type'] == 'carrier') {
|
||||
$cartItem['shipping_type'] = 'carrier';
|
||||
$cartItem['pickup_point'] = 0;
|
||||
$cartItem['carrier_id'] = $seller['shipping_id'];
|
||||
$cartItem['shipping_cost'] = getShippingCost($carts, $key,$seller['shipping_id']);
|
||||
$cartItem['shipping_cost'] = getShippingCost($carts, $key, $seller['shipping_id']);
|
||||
}
|
||||
|
||||
|
||||
$cartItem->save();
|
||||
}
|
||||
}
|
||||
|
||||
//Total shipping cost $calculate_shipping
|
||||
$total_shipping_cost = Cart::where('user_id', auth()->user()->id)->sum('shipping_cost');
|
||||
return response()->json(['result' => true, 'shipping_type' => get_setting('shipping_type'), 'value' => convert_price($total_shipping_cost), 'value_string' => format_price($total_shipping_cost)], 200);
|
||||
return response()->json(['result' => true, 'shipping_type' => get_setting('shipping_type'), 'value' => convert_price($total_shipping_cost), 'value_string' => format_price(convert_price($total_shipping_cost))], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getDeliveryInfo()
|
||||
{
|
||||
$owner_ids = Cart::where('user_id', auth()->user()->id)->select('owner_id')->groupBy('owner_id')->pluck('owner_id')->toArray();
|
||||
@@ -73,13 +73,14 @@ class ShippingController extends Controller
|
||||
if (!empty($shop_items_raw_data)) {
|
||||
foreach ($shop_items_raw_data as $shop_items_raw_data_item) {
|
||||
$product = Product::where('id', $shop_items_raw_data_item["product_id"])->first();
|
||||
$shop_items_data_item["id"] = intval($shop_items_raw_data_item["id"]) ;
|
||||
$shop_items_data_item["owner_id"] =intval($shop_items_raw_data_item["owner_id"]) ;
|
||||
$shop_items_data_item["user_id"] =intval($shop_items_raw_data_item["user_id"]) ;
|
||||
$shop_items_data_item["product_id"] =intval($shop_items_raw_data_item["product_id"]) ;
|
||||
$shop_items_data_item["id"] = intval($shop_items_raw_data_item["id"]);
|
||||
$shop_items_data_item["owner_id"] = intval($shop_items_raw_data_item["owner_id"]);
|
||||
$shop_items_data_item["user_id"] = intval($shop_items_raw_data_item["user_id"]);
|
||||
$shop_items_data_item["product_id"] = intval($shop_items_raw_data_item["product_id"]);
|
||||
$shop_items_data_item["product_name"] = $product->getTranslation('name');
|
||||
$shop_items_data_item["product_thumbnail_image"] = uploaded_asset($product->thumbnail_img);
|
||||
/*
|
||||
$shop_items_data_item["product_is_digital"] = $product->digital == 1;
|
||||
/*
|
||||
$shop_items_data_item["variation"] = $shop_items_raw_data_item["variation"];
|
||||
$shop_items_data_item["price"] =(double) cart_product_price($shop_items_raw_data_item, $product, false, false);
|
||||
$shop_items_data_item["currency_symbol"] = $currency_symbol;
|
||||
@@ -90,7 +91,6 @@ class ShippingController extends Controller
|
||||
$shop_items_data_item["upper_limit"] = intval($product->stocks->where('variant', $shop_items_raw_data_item['variation'])->first()->qty) ;
|
||||
*/
|
||||
$shop_items_data[] = $shop_items_data_item;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,18 +100,16 @@ class ShippingController extends Controller
|
||||
|
||||
if ($shop_data) {
|
||||
$shop['name'] = $shop_data->name;
|
||||
$shop['owner_id'] =(int) $owner_id;
|
||||
$shop['owner_id'] = (int) $owner_id;
|
||||
$shop['cart_items'] = $shop_items_data;
|
||||
|
||||
} else {
|
||||
$shop['name'] = "Inhouse";
|
||||
$shop['owner_id'] =(int) $owner_id;
|
||||
$shop['owner_id'] = (int) $owner_id;
|
||||
$shop['cart_items'] = $shop_items_data;
|
||||
|
||||
}
|
||||
$shop['carriers'] = seller_base_carrier_list($owner_id);
|
||||
$shop['pickup_points']=[];
|
||||
if(get_setting('pickup_point') == 1){
|
||||
$shop['pickup_points'] = [];
|
||||
if (get_setting('pickup_point') == 1) {
|
||||
$pickup_point_list = PickupPoint::where('pick_up_status', '=', 1)->get();
|
||||
$shop['pickup_points'] = PickupPointResource::collection($pickup_point_list);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class WalletController extends Controller
|
||||
$user = User::find(auth()->user()->id);
|
||||
$latest = Wallet::where('user_id', auth()->user()->id)->latest()->first();
|
||||
return response()->json([
|
||||
'balance' => format_price($user->balance),
|
||||
'balance' => single_price($user->balance),
|
||||
'last_recharged' => $latest == null ? "Not Available" : $latest->created_at->diffForHumans(),
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user