Exemple #1
0
	public function actionConf()
	{
		$allRate = Rate::model()->findAll(array(
				'select'=>'id,name,code',
				));

		$rateConfigModel = RateConfig::model()->findByPk(1);//RateConfig::model()->find(array('condition'=>'id=1'));
		
		if(isset($_POST['RateConfig'])){
			$base = intval($_POST['RateConfig']['base']);
			if($base !=0){
				$rateConfigModel->base = $base;
				$rateConfigModel->autochange = $_POST['RateConfig']['autochange'];
				if($rateConfigModel->save(false)){
					Yii::app()->user->setFlash('success','保存成功!');
				}else{
					Yii::app()->user->setFlash('error','保存失败!');
				}
			}
		}
		
		$this->render('conf',array(
				'allRate'=>$allRate,
				'rateConfigModel'=>$rateConfigModel,
				));
	}
Exemple #2
0
	protected function getRateValue($from_Currency,$to_Currency)
	{
		$rate = 1;
		$rateConfigModel = RateConfig::model()->findByPk(1);
		if($rateConfigModel!=null){
			if($rateConfigModel->autochange == 1){//使用实时汇率
				$rate = $this->ExchangeRate($from_Currency,$to_Currency);
			}else{
				$rateModel = Rate::model()->find(array('select'=>'rate','condition'=>"code='$to_Currency'"));
				$rate = $rateModel->rate;
			}
		}
	
		return $rate;
	}