Beispiel #1
0
 public function actionList()
 {
     $province = Yii::app()->request->getParam('province');
     $city = Yii::app()->request->getParam('city');
     $brand = Yii::app()->request->getParam('brand');
     $criteria = new CDbCriteria();
     $criteria->addCondition('Identity=2 and IsBlack="0" and IsFreeze="0" and Status="1"');
     if ($province) {
         $criteria->addCondition('Province=' . $province, 'AND');
     }
     if ($city) {
         $criteria->addCondition('City=' . $city, 'AND');
     }
     if (!empty($brand)) {
         $ids = $this->getdealerbybrand($brand);
         $criteria->addInCondition('ID', $ids);
     }
     $criteria->order = 'Sort ASC';
     $organ = Organ::model()->findAll($criteria);
     $organ = array();
     if (isset($organ)) {
         foreach ($organ as $key => $val) {
             $organ[$key] = $val->attributes;
             $organ[$key]['address'] = Area::getCity($val['Province']) . Area::getCity($val['City']) . Area::getCity($val['Area']);
             $brand = PapBrand::model()->find('OrganID=:organ', array(':organ' => $val['ID']));
             $organ[$key]['brandname'] = $brand['BrandName'];
         }
     }
     echo json_encode($organ);
 }
Beispiel #2
0
 public static function iddelbrand()
 {
     $OrganID = Yii::app()->user->getOrganID();
     $ID = Yii::app()->request->getParam('ID');
     $model = PapGoods::model()->findAll("OrganID=:OrganID and BrandID=:BrandID", array(':OrganID' => $OrganID, 'BrandID' => $ID));
     if ($model) {
         return 'nonull';
         exit;
     }
     $result = PapBrand::model()->deleteBypk($ID);
     return $result;
 }
Beispiel #3
0
 public static function getBrand($BrandID)
 {
     $result = PapBrand::model()->findByPK($BrandID);
     return $result['BrandName'];
 }
Beispiel #4
0
 public static function idgetbrand($brandid, $name)
 {
     $model = PapBrand::model()->findBypk($brandid);
     return $model->{$name};
 }
Beispiel #5
0
 public static function getGoods($params)
 {
     $sub = $params['sub'];
     $code = $params['code'];
     $rows = $params['rows'];
     // 每页显示条数
     $curpage = $params['page'] ? $params['page'] : 1;
     $sqlRs = self::getGoodsSql($params);
     $sql = $sqlRs["sql"];
     $countSql = $sqlRs["countSql"];
     $res = Yii::app()->papdb->createCommand($countSql)->queryAll();
     $count = $res[0]['count(*)'];
     $pages = new CPagination($count);
     $pages->pageSize = $rows;
     $offset = ($curpage - 1) * $pages->pageSize;
     $goods = Yii::app()->papdb->createCommand($sql . " LIMIT {$offset},{$pages->pageSize}")->queryAll();
     foreach ($goods as $k => $v) {
         $image = self::getOneGoodsImage($v['ID']);
         if (!$image) {
             $goods[$k]['image'] = F::uploadUrl() . 'common/goods-img-big.jpg';
         } else {
             $goods[$k]['image'] = F::uploadUrl() . $image;
         }
         //            //获取品牌名称
         $brandID = $v['BrandID'];
         $brandname = PapBrand::model()->findByPk($brandID);
         if ($brandname) {
             $goods[$k]['brandname'] = $brandname['BrandName'];
         }
         //获取标准名称
         $cd = self::getCategory($v['StandCode']);
         if (is_array($cd)) {
             $goods[$k]['cpname'] = $cd['CpName'];
         }
         //卖家信息
         $organInfo = Organ::model()->findByPk($v['OrganID'])->attributes;
         if ($organInfo) {
             $goods[$k]['dealername'] = $organInfo['OrganName'];
         }
         //OE号
         $goods[$k]['OENOS'] = self::getOENOSByGoodsID($v['ID']);
         // 车型车系
         $vehs = explode('、', self::getVehicleByGoodsID($v['ID']));
     }
     return array('data' => $goods, 'count' => $count);
 }