From 142904b0af9d464b2a57a0982508a1699ee6dfcb Mon Sep 17 00:00:00 2001 From: "marjuqi@ad" Date: Wed, 18 May 2022 11:15:25 +0700 Subject: [PATCH] activate lines after executing SegmentConstantsTableSeeder --- .../ShippingEstimationCalculatorLogic.php | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/Classes/Modules/Transactions/ControllersLogic/ShippingEstimationCalculatorLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/ShippingEstimationCalculatorLogic.php index de47b8ec..6f7d7369 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/ShippingEstimationCalculatorLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/ShippingEstimationCalculatorLogic.php @@ -53,24 +53,25 @@ class ShippingEstimationCalculatorLogic extends AbstractControllerLogic $cbm = (float) ($width * $length * $height); - // $base_price_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::BASE_PRICE]); - // $warehouse_rate_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::WAREHOUSE_RATE]); - // $state_rate_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::STATE_RATE]); - // $center_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::CENTER_POSTCODE]); - // $outstation_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::OUTSTATION_POSTCODE]); + $base_price_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::BASE_PRICE]); + $warehouse_rate_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::WAREHOUSE_RATE]); + $state_rate_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::STATE_RATE]); + $center_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::CENTER_POSTCODE]); + $outstation_postcode_constant = $this->fetchesSegmentConstant->execute(['segment_id' => 1, 'reference' => SegmentConstants::OUTSTATION_POSTCODE]); - // $selected_warehouse_rate = $this->getConstantByKey($warehouse_rate_constant, $request->input('warehouse_id')); - $warehouse_rate = 99;//is_object($selected_warehouse_rate) ? $selected_warehouse_rate->amount : 0; + $base_price = $this->getConstantByKey($base_price_constant, date('Y-m-d')); + $selected_warehouse_rate = $this->getConstantByKey($warehouse_rate_constant, $request->input('warehouse_id')); + $warehouse_rate = is_object($selected_warehouse_rate) ? $selected_warehouse_rate->amount : 0; - // $this->checkPostcodeExistInConstant($center_postcode_constant, $request->input('postcode')) === true ? $state_select = 'center' : '' ; - // $this->checkPostcodeExistInConstant($outstation_postcode_constant, $request->input('postcode')) === true ? $state_select = 'outstation' : '' ; - // $state_rate_constant = (array)$state_rate_constant; - $state_rate = 33;//$state_select == '' ? 0 : $state_rate_constant[$state_select]; + $this->checkPostcodeExistInConstant($center_postcode_constant, $request->input('postcode')) === true ? $state_select = 'center' : '' ; + $this->checkPostcodeExistInConstant($outstation_postcode_constant, $request->input('postcode')) === true ? $state_select = 'outstation' : '' ; + $state_rate_constant = (array)$state_rate_constant; + + $state_rate = $state_select == '' ? 0 : $state_rate_constant[$state_select]; $price_cbm = $base_price + $warehouse_rate + $state_rate; $total_cbm = $price_cbm * $cbm; - // and the outcome would be "520.00" MYR, for example. return $this->response([ 'cbm' => $cbm, 'total_cbm' => $total_cbm ]);