| Server IP : 34.87.99.72 / Your IP : 216.73.217.31 Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 User : bitnami ( 1000) PHP Version : 7.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /opt/bitnami/apache/htdocs/app/app/Http/Controllers/ |
Upload File : |
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
// use App\Http\Services\PricingService;
use App\Http\Services\PriceCalculationService;
use App\Http\Services\ShippingService;
use App\Http\Requests\Pricings\ListRequest as PricingListRequest;
use App\Http\Requests\Pricings\UpdateRequest as PricingUpdateRequest;
use App\Http\Requests\Pricings\CheckRequest as PricingCheckRequest;
use App\Http\Requests\Pricings\CalculateDeliveryBookingFeeRequest;
use App\Http\Requests\IdOnlyRequest;
use Illuminate\Http\Request;
use App\Models\Pricing;
use App\Models\UserBoxDelivery;
class PricingController extends Controller
{
public function __construct(
// PricingService $pricingService,
PriceCalculationService $priceCalculationService,
ShippingService $shippingService
)
{
// $this->pricingService = $pricingService;
$this->priceCalculationService = $priceCalculationService;
$this->shippingService = $shippingService;
}
/* public function pricingList(PricingListRequest $request)
{
$payload = $request->validated();
$pricings = $this->pricingService->pricingList( $payload );
return self::successResponse('Success', $pricings );
}
public function pricingUpdate(PricingUpdateRequest $request)
{
$payload = $request->validated();
$pricing = $this->pricingService->pricingUpdateOrCreate( $payload );
return self::successResponse('Success',$pricing);
}*/
/**
* @OA\Get(
*
* path="/api/pricing/check",
* operationId="pricingCheck",
* tags={"PriceCalculation"},
* summary="pricingCheck",
* security={
* {
* "open_key": {}
* },
* {
* "api_key": {}
* }
* },
* @OA\Parameter(
* name="locker_id",
* description="locker_id",
* in="query",
* @OA\Schema(
* type="string",
* default=""
* )
* ),
* @OA\Parameter(
* name="box_size_id",
* description="box_size_id",
* in="query",
* @OA\Schema(
* type="string",
* default=""
* )
* ),
* @OA\Parameter(
* name="reserved_minute",
* description="reserved_minute",
* in="query",
* @OA\Schema(
* type="string",
* default=""
* )
* ),
* @OA\Response(
* response=200,
* description="Success",
* @OA\JsonContent()
* ),
* @OA\Response(response=400, description="Bad request"),
* @OA\Response(response=404, description="Resource Not Found"),
* @OA\Response(response=422, description="Unprocessable Entity"),
* @OA\Response(response=500, description="Internal Server Error"),
* )
*/
public function pricingCheck(PricingCheckRequest $request)
{
$payload = $request->validated();
$pricing = $this->priceCalculationService->computeBookingPrice( $payload );
return self::successResponse('Success',$pricing);
}
public function getBookingEndOfDay(Request $request)
{
$payload = $this->validate($request, [
'locker_id' => 'required',
'expired_at' => 'required',
'box_size_id' => 'required',
'now' => 'required',
]);
$pricing = $this->priceCalculationService->computeOvertimePrice( $payload );
return self::successResponse('Success',$pricing);
}
/**
* @OA\Get(
*
* path="/api/pricing/check-delivery",
* operationId="calculateDeliveryBookingFee",
* tags={"PriceCalculation"},
* summary="Calculate Booking and Shipping Fee",
* security={
* {
* "open_key": {}
* },
* {
* "api_key": {}
* }
* },
* @OA\Parameter(
* name="locker_id",
* description="locker_id",
* in="query",
* @OA\Schema(
* type="string",
* default=""
* )
* ),
* @OA\Parameter(
* name="box_size_id",
* description="box_size_id",
* in="query",
* @OA\Schema(
* type="string",
* default=""
* )
* ),
* @OA\Parameter(
* name="locker_postcode",
* description="Locker Postcode",
* in="query",
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Parameter(
* name="delivery_postcode",
* description="Delivery Postcode",
* in="query",
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Parameter(
* name="courier_id",
* description="Courier Id",
* in="query",
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Parameter(
* name="item_weight",
* description="Item Weight (kg)",
* in="query",
* @OA\Schema(
* type="string"
* )
* ),
* @OA\Response(
* response=200,
* description="Success",
* @OA\JsonContent()
* ),
* @OA\Response(response=400, description="Bad request"),
* @OA\Response(response=404, description="Resource Not Found"),
* @OA\Response(response=422, description="Unprocessable Entity"),
* @OA\Response(response=500, description="Internal Server Error"),
* )
*/
public function calculateDeliveryBookingFee(CalculateDeliveryBookingFeeRequest $request)
{
$payload = $request->validated();
$payload['reserved_minute'] = UserBoxDelivery::MAX_RESERVED_MINUTES;
$payload['type'] = 'delivery_booking';
$payload['subtotal'] = null;
$shipping_fee = $this->shippingService->calculateShippingFee($payload['locker_postcode'], $payload['delivery_postcode'], $payload['courier_id'], $payload['subtotal'], $payload['item_weight'], $payload['locker_id'], $payload['box_size_id']);
// $booking_fee = $this->priceCalculationService->computeBookingPrice( $payload );
// $final_price = $shipping_fee + $booking_fee;
return self::successResponse("Success", [
// 'shipping_fee' => $shipping_fee,
// 'pricing' => $booking_fee,
'total' => number_format((float)$shipping_fee, 2, '.', ''),
]);
}
}