public static function getCooperationtype($id) { $OrganID = Yii::app()->user->getOrganID(); $model = GoodsPriceManage::model()->find("OrganID={$OrganID} and ID={$id}")->attributes; //return $model['CooperationType']; if ($model['CooperationType'] == 'A') { return "A:VIP客户"; } else { if ($model['CooperationType'] == 'B') { return "B:重要客户"; } else { $model['CooperationType'] ? $model['CooperationType'] : 'C'; return "C:普通客户"; } } }
public function actionEditdis() { $this->pageTitle = Yii::app()->name . '-' . "修改价格比"; $id = Yii::app()->request->getParam('id'); //获取要修改的ID $OrganID = Yii::app()->user->getOrganID(); $bool = true; if ($id) { $model = GoodsPriceManage::model()->findByPk($id); } else { $model = new GoodsPriceManage(); } $this->performAjaxValidation($model); if (isset($_POST['GoodsPriceManage'])) { if ($model->CooperationType == 'A') { $model->PriceRatio = $_POST['GoodsPriceManage']['PriceRatio']; $res = GoodsPriceManage::model()->find(array("condition" => "OrganID = {$OrganID} AND CooperationType like 'B%'")); // echo 'B.' . $res['PriceRatio'] . '||A.' . $_POST['GoodsPriceManage']['PriceRatio'];exit; if (!empty($res['PriceRatio']) && $res['PriceRatio'] <= $_POST['GoodsPriceManage']['PriceRatio']) { //如果B比A还小 $bool = false; } } if ($model->CooperationType == 'B') { $model->PriceRatio = $_POST['GoodsPriceManage']['PriceRatio']; // if (empty($model->PriceRatio)) { // $bool = false; // } $res = GoodsPriceManage::model()->find(array("condition" => "OrganID = {$OrganID} AND CooperationType like 'A%'")); // echo 'A.' . $res['PriceRatio'] . '||B.' . $_POST['GoodsPriceManage']['PriceRatio'];exit; if (!empty($res['PriceRatio']) && $res['PriceRatio'] >= $_POST['GoodsPriceManage']['PriceRatio']) { //如果A比B还大 $bool = false; } if ($_POST['GoodsPriceManage']['PriceRatio'] >= 100) { $bool = false; } } if ($model->CooperationType == 'C') { $bool = false; } if ($bool == true) { $model->save(); $this->redirect(array('index')); } } switch ($model['CooperationType']) { case 'A': $cooperationType = 'VIP客户'; break; case 'B': $cooperationType = '重要客户'; break; case 'C': $cooperationType = '普通客户'; break; } $aa = GoodsPriceManage::model()->find(array("condition" => "OrganID = {$OrganID} AND CooperationType like 'A%'")); $bb = GoodsPriceManage::model()->find(array("condition" => "OrganID = {$OrganID} AND CooperationType like 'B%'")); $this->render('editdis', array('model' => $model, 'aa' => $aa, 'bb' => $bb, 'cooperationType' => $cooperationType)); }