コード例 #1
0
 echo "    {date}          : " . (is_null($pickingData->takingDate) ? "null" : date("Y-m-d H:i:s T", $pickingData->takingDate)) . "<br>";
 echo "    {documents}     : " . ($pickingData->documents ? "true" : "false") . "<br>";
 $arrFinalServices = Util::filterServicesByWeightIntervals($arrSelectedServices, $pickingData->weightDeclared, $eps, $senderSiteId, $receiverSiteId, $pickingData->takingDate, $pickingData->documents);
 echo "<br><br>";
 echo "Резултат:<br>";
 echo "---------<br>";
 var_dump($arrFinalServices);
 if (count($arrFinalServices) == 0) {
     // Нямаме услуга за тази пратка и тя не може да бъде изпълнена
     throw new ClientException("Не е налична услуга за тази пратка.");
 }
 // Параметри за калкулация
 $paramCalculation = new ParamCalculation();
 $paramCalculation->setBroughtToOffice(!is_null($pickingData->bringToOfficeId));
 $paramCalculation->setToBeCalled(!is_null($pickingData->takeFromOfficeId));
 $paramCalculation->setParcelsCount($pickingData->parcelsCount);
 $paramCalculation->setWeightDeclared($pickingData->weightDeclared);
 $paramCalculation->setDocuments($pickingData->documents);
 $paramCalculation->setPalletized($pickingData->palletized);
 $paramCalculation->setFragile($pickingData->fragile);
 //При изпозване на $paramCalculation->setSenderSiteId($senderSiteId) вместо paramCalculation.setSenderId($senderClientData->getClientId())
 //не се използват преференциите на подателя по договор
 //$paramCalculation->setSenderSiteId($senderSiteId);
 $paramCalculation->setSenderId($senderClientData->getClientId());
 $paramCalculation->setReceiverSiteId($receiverSiteId);
 $paramCalculation->setPayerType($pickingData->payerType);
 $paramCalculation->setAmountCodBase($pickingData->amountCODBase);
 $paramCalculation->setTakingDate($pickingData->takingDate);
 $paramCalculation->setAutoAdjustTakingDate($pickingData->autoAdjust);
 // Adjust to first allowed taking date
 if (count($arrFinalServices) == 1) {
コード例 #2
0
ファイル: SpeedyServiceDump.php プロジェクト: fire1/speedy
 /** Calculate base data
  * @param $data
  * @return array
  */
 public function calculate($data)
 {
     $this->_error = '';
     $resultCalculation = array();
     if (isset($this->resultLogin)) {
         try {
             $paramCalculation = new \ParamCalculation();
             $paramCalculation->setSenderId($this->resultLogin->getClientId());
             $paramCalculation->setBroughtToOffice($this->config->get('speedy_from_office') && $this->config->get('speedy_office_id'));
             $paramCalculation->setToBeCalled($data['to_office'] && $data['office_id']);
             $paramCalculation->setParcelsCount($data['count']);
             $paramCalculation->setWeightDeclared($data['weight']);
             $paramCalculation->setDocuments($this->config->get('speedy_documents'));
             $paramCalculation->setPalletized(false);
             if (!empty($data['fixed_time'])) {
                 $paramCalculation->setFixedTimeDelivery($data['fixed_time']);
             } else {
                 $paramCalculation->setFixedTimeDelivery(null);
             }
             if (isset($data['loading'])) {
                 if ($data['insurance']) {
                     if ($data['fragile']) {
                         $paramCalculation->setFragile(true);
                     } else {
                         $paramCalculation->setFragile(false);
                     }
                     $paramCalculation->setAmountInsuranceBase($data['totalNoShipping']);
                     $paramCalculation->setPayerTypeInsurance(\ParamCalculation::PAYER_TYPE_RECEIVER);
                 } else {
                     $paramCalculation->setFragile(false);
                 }
             } elseif ($this->config->get('speedy_insurance')) {
                 if ($this->config->get('speedy_fragile')) {
                     $paramCalculation->setFragile(true);
                 } else {
                     $paramCalculation->setFragile(false);
                 }
                 $paramCalculation->setAmountInsuranceBase($data['totalNoShipping']);
                 $paramCalculation->setPayerTypeInsurance(\ParamCalculation::PAYER_TYPE_RECEIVER);
             } else {
                 $paramCalculation->setFragile(false);
             }
             if (!($data['to_office'] && $data['office_id'])) {
                 $paramCalculation->setReceiverSiteId($data['city_id']);
             }
             $paramCalculation->setPayerType(\ParamCalculation::PAYER_TYPE_RECEIVER);
             if ($data['cod']) {
                 $paramCalculation->setAmountCodBase($data['total']);
             } else {
                 $paramCalculation->setAmountCodBase(0);
             }
             $paramCalculation->setTakingDate($data['taking_date']);
             $paramCalculation->setAutoAdjustTakingDate(true);
             if ($this->config->get('speedy_from_office') && $this->config->get('speedy_office_id')) {
                 $paramCalculation->setWillBringToOfficeId($this->config->get('speedy_office_id'));
             }
             if ($data['to_office'] && $data['office_id']) {
                 $paramCalculation->setOfficeToBeCalledId($data['office_id']);
             } else {
                 $paramCalculation->setOfficeToBeCalledId(null);
             }
             $resultCalculation = $this->ePSFacade->calculateMultipleServices($paramCalculation, $this->config->get('speedy_allowed_methods'));
             foreach ($resultCalculation as $key => $service) {
                 if ($service->getErrorDescription()) {
                     unset($resultCalculation[$key]);
                 }
             }
             $resultCalculation = array_values($resultCalculation);
         } catch (\Exception $e) {
             $this->_error = $e->getMessage();
             $this->log->addError('Speedy :: calculate :: ' . $e->getMessage());
         }
     }
     return $resultCalculation;
 }