示例#1
0
 public function init()
 {
     $value = $this->getValue();
     if ($this->_riseValue === null) {
         $tendencyModel = new NegotiationTendency();
         $tendencyRow = $tendencyModel->fetchRow(array('customer_type = ?' => $this->customerType, 'for_pln' => 't', 'ghost = ?' => 'f'), 'created_at DESC');
         $queryModel = new NegotiationQuery();
         $queryRow = $queryModel->fetchRow(array('ghost = ?' => 'f', 'for_pln = ?' => 't'), 'id DESC');
         switch ($this->stepNumber) {
             case 0:
                 $this->setValue($value);
                 return;
             case 1:
                 $column = 'additional1';
                 break;
             case 2:
                 $column = 'additional2';
                 break;
             case 3:
                 $column = 'additional3';
                 break;
             case -1:
                 $value += $tendencyRow->tendency * 0.05;
                 $this->setValue($value);
                 return;
         }
         $this->_riseValue = 0.05 * $tendencyRow->tendency * ($queryRow->{$column} / 100);
     }
     $value += $this->_riseValue;
     $this->setValue($value);
 }
示例#2
0
 public function init()
 {
     $value = $this->getValue();
     if ($this->_riseValue === null) {
         if ($value == 0) {
             $baseInterestModel = new CurrencyInterest();
             $data = $baseInterestModel->getDataByInput($this->brandId, $this->currency, $this->customerType);
             $m = $this->daysToM($this->depositDays);
             foreach ($data as $v) {
                 $d = Zend_Json_Decoder::decode($v['json_data']);
                 //$tendency = round((float) ($d['tendency'] / 10), 2);
                 if ($d['data'][$m][3]['low_currency_bracket'] * 1000 <= $this->depositAmount) {
                     //  $this->_riseValue = $d['data'][$m][3]['interest'];
                     $hight = 3;
                     break;
                 } elseif ($d['data'][$m][2]['low_currency_bracket'] * 1000 <= $this->depositAmount) {
                     //  $this->_riseValue = $d['data'][$m][2]['interest'];
                     $hight = 2;
                     break;
                 } elseif ($d['data'][$m][1]['low_currency_bracket'] * 1000 <= $this->depositAmount) {
                     //  $this->_riseValue = $d['data'][$m][1]['interest'];
                     $hight = 1;
                     break;
                 } elseif ($d['data'][$m][0]['low_currency_bracket'] * 1000 <= $this->depositAmount) {
                     // $this->_riseValue = $d['data'][$m][0]['interest'];
                     $hight = 0;
                     break;
                 } else {
                     throw new Exception('Unrecodnizable deposit amount', '45');
                 }
             }
             if ($this->depositDays <= 90) {
                 $this->_riseValue = $this->linearInterpolation(0, 90, 0, $d['data']['3M'][$hight]['interest'], $this->depositDays);
             } elseif ($this->depositDays <= 180) {
                 $this->_riseValue = $this->linearInterpolation(90, 180, $d['data']['3M'][$hight]['interest'], $d['data']['6M'][$hight]['interest'], $this->depositDays);
             } elseif ($this->depositDays <= 365) {
                 $this->_riseValue = $this->linearInterpolation(180, 365, $d['data']['6M'][$hight]['interest'], $d['data']['12M'][$hight]['interest'], $this->depositDays);
             } else {
                 $this->_riseValue = $d['data'][$m][$hight]['interest'];
             }
         }
         $queryModel = new NegotiationQuery();
         $queryRow = $queryModel->fetchRow(array('ghost = ?' => 'f', 'for_pln = ?' => 'f'), 'id DESC');
         $tendencyModel = new NegotiationTendency();
         $tendencyRow = $tendencyModel->fetchRow(array('customer_type = ?' => $this->customerType, 'for_pln = ?' => 'f', 'ghost = ?' => 'f'), 'created_at DESC');
         $tendency = round((double) ($tendencyRow->tendency / 100), 4);
         switch ($this->counterOfferNo) {
             case 0:
                 $value += $this->_riseValue;
                 $this->setValue($value);
                 return;
             case 1:
                 $column = 'additional1';
                 break;
             case 2:
                 $column = 'additional2';
                 break;
             case 3:
                 $column = 'additional3';
                 break;
             case -1:
                 $value += $this->_riseValue;
                 $this->setValue($value);
                 return;
         }
         $x = (double) ($queryRow->{$column} / 100);
         $this->_riseValue += round($tendency * $x, 4);
     }
     $value += $this->_riseValue;
     $this->setValue($value);
 }