Beispiel #1
0
 public function actionSetprice()
 {
     $OrganID = Commonmodel::getOrganID();
     $type = $_POST['CooperationType'];
     $bool = true;
     if ($type == 'A:VIP客户') {
         $res = PriceManage::model()->find(array("condition" => "OrganID = {$OrganID} AND CooperationType = 'B:重要客户'"));
         if (!empty($res['PriceRatio']) && $res['PriceRatio'] <= $_POST['PriceRatio']) {
             $bool = false;
         }
     } elseif ($type == 'B:重要客户') {
         $res = PriceManage::model()->find(array("condition" => "OrganID = {$OrganID} AND CooperationType = 'A:VIP客户'"));
         if ($res['PriceRatio'] >= $_POST['PriceRatio']) {
             $bool = false;
         }
     }
     if ($bool == true) {
         $model = PriceManage::model()->updateByPk($_POST['priceID'], array("PriceRatio" => $_POST['PriceRatio'], "UpdateTime" => time()));
     }
     if ($bool == false) {
         $result['errorMsg'] = "设置失败,A类VIP客户价格比要小于B类重要客户!";
     } elseif ($model == 1 && $bool == true) {
         $result['success'] = "价格比设置成功!";
     } else {
         $result['errorMsg'] = "系统异常,价格比设置失败!";
     }
     echo json_encode($result);
 }
Beispiel #2
0
 public static function getContactprice($dealerID, $seriveID)
 {
     $criteria = new CDbCriteria();
     $criteria->select = "cooperationtype";
     $OrganID = Commonmodel::getOrganID();
     $Identity = Commonmodel::getIdentity($OrganID);
     //判断当前登录用户角色类别(修理厂/经销商)
     if ($Identity['identity'] == 3) {
         //修理厂角色登录
         $criteria->addCondition("t.user_id = {$dealerID}", "AND");
         //经销商ID
         $criteria->addCondition("t.contact_user_id = {$OrganID}", "AND");
         //当前登录的修理厂ID
         $criteria->addCondition("t.Status=0", 'AND');
     } elseif ($Identity['identity'] == 2) {
         //经销商角色登录
         $criteria->addCondition("t.user_id = {$OrganID}", "AND");
         //当前登录的经销商ID
         //  $criteria->addCondition("t.contact_user_id =$seriveID", "AND");
         $criteria->addCondition("t.contact_user_id = :seriveID", 'AND');
         $criteria->addCondition("t.Status=0", 'AND');
         $criteria->params[':seriveID'] = $seriveID;
         //修理厂ID(询价对象ID)
     }
     $contact = BusinessContacts::model()->find($criteria);
     if ($contact) {
         $model = PriceManage::model()->find(array("condition" => "OrganID = {$dealerID} AND CooperationType = '{$contact['cooperationtype']}'"));
     }
     return $model;
 }