activate lines after executing SegmentConstantsTableSeeder

This commit is contained in:
marjuqi@ad
2022-05-18 11:15:25 +07:00
parent 97fe1d9192
commit 142904b0af
@@ -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
]);