Exemplo n.º 1
0
 /**
 * 修改触摸屏
 * @param $id:int 触摸屏ID 默认0
 * @param $arr:Array 其内容如下
 * name:string(50) (可不填,触摸屏名)
 		brandid:int(4) (可不填,品牌ID)
 		isshow:text (可不填,是否显示对应的功能.存放的是二维数组.其中第一维为ipad,touch,brand分别表示IPAD,触摸屏和品牌专区.第二维里面对应的ID为b_category表的style为13的.1为显示)
 		touchbrand:string(1000)(可不填,触摸屏下的品牌  arr[brandid]=order 0-100)
 		openkey:string(1000)(可不填,打开触摸屏密钥)
 		description:string(5000) (可不填,试衣间简介)
 		headtail:string(1000) (可不填,页头,页尾 array[head][touch] 或 array[tail][touch])
 		enddate:date (可不填,到期时间)
 		lock:int(4) (可不填,锁定)
 		apikey:string(100) (可不填,同步密钥)
 * @return 如果添加数据成功返回true
 * 否则返回其错误信息
 */
 public function touchUpdateById($id = 0, $arr = array())
 {
     $id = trim($id);
     try {
         Comm::checkValue($id, Yii::t('public', '触摸屏号'), 1, 1);
     } catch (BeubeuException $e) {
         throw new BeubeuException($e->getMessage(), $e->getCode());
     }
     if (count($arr) > 0 && gettype($arr) == 'array') {
         $updata_arr = array();
         if (isset($arr['name'])) {
             $str_param = trim($arr['name']);
             try {
                 Comm::checkValue($str_param, Yii::t('touch_config', '触摸屏名'), 0, 0, 50);
                 $updata_arr['name'] = $str_param;
             } catch (Exception $e) {
             }
         }
         if (isset($arr['brandid'])) {
             $str_param = trim($arr['brandid']);
             try {
                 Comm::checkValue($str_param, Yii::t('public', '品牌号'), 1, 1, 50000);
                 $updata_arr['brandid'] = $str_param;
             } catch (Exception $e) {
             }
         }
         if (isset($arr['touchbrand'])) {
             $str_param = trim($arr['touchbrand']);
             try {
                 Comm::checkValue($str_param, Yii::t('touch_config', '触摸屏下的品牌'), 0, 1, 1000);
                 $updata_arr['touchbrand'] = $str_param;
             } catch (Exception $e) {
             }
         }
         if (isset($arr['isshow'])) {
             $str_param = trim($arr['isshow']);
             try {
                 Comm::checkValue($str_param, Yii::t('touch_config', '对应的功能'), 0, 1, 1000);
                 $updata_arr['isshow'] = $str_param;
             } catch (Exception $e) {
             }
         }
         if (isset($arr['openkey'])) {
             $str_param = trim($arr['openkey']);
             try {
                 Comm::checkValue($str_param, Yii::t('touch_config', '触摸屏密钥'), 0, 1, 1000);
                 $updata_arr['openkey'] = $str_param;
             } catch (Exception $e) {
             }
         }
         if (isset($arr['description'])) {
             $str_param = trim($arr['description']);
             try {
                 Comm::checkValue($str_param, Yii::t('touch_config', '试衣间简介'), 0, 1, 5000);
                 $updata_arr['description'] = $str_param;
             } catch (Exception $e) {
             }
         }
         if (isset($arr['headtail'])) {
             $str_param = trim($arr['headtail']);
             try {
                 Comm::checkValue($str_param, Yii::t('touch_config', '页头,页尾'), 0, 1, 1000);
                 $updata_arr['headtail'] = $str_param;
             } catch (Exception $e) {
             }
         }
         if (isset($arr['enddate'])) {
             $str_param = trim($arr['enddate']);
             try {
                 Comm::dataSingle($str_param, Yii::t('touch_config', '到期时间'));
                 $updata_arr['enddate'] = $str_param;
             } catch (Exception $e) {
             }
         }
         if (isset($arr['lock'])) {
             $str_param = trim($arr['lock']);
             try {
                 Comm::checkValue($str_param, Yii::t('touch_config', '锁定'), 1, 1, 1000);
                 $updata_arr['lock'] = $str_param;
             } catch (Exception $e) {
             }
         }
         if (isset($arr['apikey'])) {
             $str_param = trim($arr['apikey']);
             try {
                 Comm::checkValue($str_param, Yii::t('touch_config', '同步密钥'), 0, 1, 100);
                 $updata_arr['apikey'] = $str_param;
             } catch (Exception $e) {
             }
         }
         try {
             touch_config::model()->updateByPk($id, $updata_arr);
             return true;
         } catch (Exception $e) {
             throw new BeubeuException(Yii::t('public', '修改数据失败'), BeubeuException::SQL_UPDATE_ERR);
         }
     } else {
         throw new BeubeuException(Yii::t('beu_brand', '数据') . Yii::t('public', '不能为空'), BeubeuException::FIELD_EMPTY);
     }
 }
Exemplo n.º 2
0
 /**
 * 根据品牌ID对beu_brand表中数据的数据进行修改
 * @param $id:int 品牌id 默认0
 * @param $arr:Array 其内容如下
 * logoimgpath:string(255) (可不填,品牌图片)
 		telephone:string(255) (可不填,品牌电话)
 		address:string(255) (可不填,品牌地址)
 		fax:string(255) (可不填,传真)
 		website:string(255) (可不填,网站地址:http://dfa.com)
 		companyname:string(255) (可不填,公司名)
 		status:int (可不填,是否显示,默认为1。参数值也只能为1或2)
 		createdate:string(10) (可不填,创建时间)
 		code_start:款号规则开始位置
 		code_end:款号规则结束位置
 * @return 如果修改数据成功返回true
 * 否则返回false
 */
 public static function brandUpdateById($id = 0, $arr = array())
 {
     $id = trim($id);
     try {
         Comm::checkValue($id, Yii::t('public', '品牌号'), 1, 1);
     } catch (BeubeuException $e) {
         throw new BeubeuException($e->getMessage(), $e->getCode());
     }
     if (count($arr) > 0 && gettype($arr) == 'array') {
         $updata_arr = array();
         if (isset($arr['englishname'])) {
             try {
                 $englishname = trim($arr['englishname']);
                 Comm::checkValue($englishname, Yii::t('beu_brand', '品牌英文名'), 0, 1, 255);
                 $updata_arr['englishname'] = $englishname;
             } catch (BeubeuException $e) {
             }
         }
         if (isset($arr['name'])) {
             try {
                 $name = trim($arr['name']);
                 Comm::checkValue($name, Yii::t('beu_brand', '品牌名'), 0, 1, 255);
                 $updata_arr['name'] = $name;
             } catch (BeubeuException $e) {
                 throw new BeubeuException($e->getMessage(), $e->getCode());
             }
         }
         if (isset($arr['logoimgpath'])) {
             try {
                 $logoimgpath = trim($arr['logoimgpath']);
                 Comm::checkValue($logoimgpath, Yii::t('beu_brand', '公司地址'), 0, 0, 255);
                 $updata_arr['logoimgpath'] = $logoimgpath;
             } catch (BeubeuException $e) {
             }
         }
         if (isset($arr['telephone'])) {
             //公司电话字段存在,并且长度不超过255
             try {
                 $telephone = trim($arr['telephone']);
                 Comm::phoneToSingle($telephone, Yii::t('beu_brand', '电话号码'));
                 $updata_arr['telephone'] = $telephone;
             } catch (BeubeuException $e) {
             }
         }
         if (isset($arr['address'])) {
             //公司地址字段存在,并且长度不超过255
             try {
                 $address = trim($arr['address']);
                 Comm::checkValue($address, Yii::t('beu_brand', '公司地址'), 0, 0, 255);
                 $updata_arr['address'] = $address;
             } catch (BeubeuException $e) {
             }
         }
         if (isset($arr['fax'])) {
             //传真字段存在,并且长度不超过255
             try {
                 $fax = trim($arr['fax']);
                 Comm::phoneToSingle($fax, Yii::t('beu_brand', '传真'));
                 $updata_arr['fax'] = $fax;
             } catch (BeubeuException $e) {
             }
         }
         if (isset($arr['website'])) {
             //网站地址字段存在,并且长度不超过255
             try {
                 $website = trim($arr['website']);
                 Comm::checkValue($website, Yii::t('beu_brand', '网站地址'), 0, 0, 255);
                 $updata_arr['website'] = $website;
             } catch (BeubeuException $e) {
             }
         }
         if (isset($arr['companyname']) && !empty($arr['companyname']) && strlen($arr['companyname']) <= 255) {
             //公司名字段存在,并且长度不超过255
             try {
                 $companyname = trim($arr['companyname']);
                 Comm::checkValue($companyname, Yii::t('beu_brand', '公司名称'), 0, 0, 255);
                 $updata_arr['companyname'] = $companyname;
             } catch (BeubeuException $e) {
             }
         }
         if (!isset($arr['code_start']) || intval($arr['code_start']) != $arr['code_start']) {
             $updata_arr['code_start'] = 0;
         } else {
             $updata_arr['code_start'] = $arr['code_start'];
         }
         if (!isset($arr['code_end']) || intval($arr['code_end']) != $arr['code_end']) {
             $updata_arr['code_end'] = 0;
         } else {
             $updata_arr['code_end'] = $arr['code_end'];
         }
         if (isset($arr['status']) && !empty($arr['status']) && trim($arr['status']) == 11) {
             //显示状态字段存在,并且为2表示不显示
             $updata_arr['status'] = 11;
             //不显示
         } else {
             if (isset($arr['status']) && !empty($arr['status']) && trim($arr['status']) == 10) {
                 $updata_arr['status'] = 10;
                 //显示
             }
         }
         if (isset($arr['angle']) && !empty($arr['angle']) && intval($arr['angle']) == $arr['angle'] && $arr['angle'] > 0) {
             //衣服支持的角度
             $updata_arr['angle'] = $arr['angle'];
         }
         if (isset($arr['model'])) {
             //衣服支持的角度
             $updata_arr['model_type'] = $arr['model'];
         }
         if (isset($arr['createdate']) && !empty($arr['createdate'])) {
             //时间字段存在并格式正确
             try {
                 $createdate = trim($arr['createdate']);
                 Comm::dataSingle($createdate, Yii::t('beu_brand', '添加时间'), false);
                 $updata_arr['createdate'] = $createdate;
             } catch (BeubeuException $e) {
             }
         }
         $img = self::brandImgUp($id);
         if ($img) {
             $img = json_decode($img, true);
             try {
                 $updata_arr['logoimgpath'] = $img['brand']['img'];
             } catch (Exception $e) {
             }
         }
         try {
             beu_brand::model()->updateAll($updata_arr, 'id=:textx', array(':textx' => $id));
             Yii::app()->cache->delete(CacheName::getCacheName('brand_name_list_all'));
             //清除品牌列表
         } catch (BeubeuException $e) {
             throw new BeubeuException(Yii::t('public', '修改数据失败'), BeubeuException::SQL_UPDATE_ERR);
         }
     } else {
         throw new BeubeuException(Yii::t('beu_brand', '数据') . Yii::t('public', '不能为空'), BeubeuException::FIELD_EMPTY);
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * 根据条件查找beu_clothes表里的数据
  * @parm $brandid 品牌id
  * @parm $clothescategory 品类一级
  * @parm $clothescategory2 品类二级
  * @parm $modeltype 模特类型
  * @parm $strd_data 开始时间
  * @parm $end_data 结束时间
  * @parm $key 搜索条件(衣服名、衣服id、款号)
  * @parm $page 多少页
  * @parm $pagecount 每页显示数量
  * @return 成功后返回数据 array ('data' => $newstypelist, 'count' => $con,'pageSize'=>$pagecount,'page'=>$page ) data是查询到的数据,count是总页数,pageSize是每页显示数量,page是当前页
  */
 public static function beuclothesSelectForAll($page = 1, $pagecount = 20, $brandid = 0, $modeltype = 0, $clothescategory = 0, $clothescategory2 = 0, $strd_data = 0, $end_data = 0, $key = '')
 {
     $page = trim($page);
     $brandid = trim($brandid);
     $modeltype = trim($modeltype);
     $clothescategory = trim($clothescategory);
     $clothescategory2 = trim($clothescategory2);
     $strd_data = trim($strd_data);
     $end_data = trim($end_data);
     $key = trim($key);
     if (!empty($page)) {
         //规范页码
         try {
             Comm::checkValue($page, Yii::t('public', '页码'), 1, 0);
         } catch (BeubeuException $e) {
             $page = 1;
         }
     } else {
         $page = 1;
     }
     if (!empty($pagecount)) {
         try {
             Comm::checkValue($pagecount, '', 1, 1);
         } catch (BeubeuException $e) {
             $pagecount = 20;
         }
     } else {
         $page = 20;
     }
     $w_s = '';
     $w_s_arr = array();
     if (!empty($brandid)) {
         //规范品牌id
         try {
             Comm::checkValue($brandid, Yii::t('public', '品牌号'), 1, 1, self::$Int_max);
             $w_s = 'beu_clothes.brandid=:brandid';
             $w_s_arr[':brandid'] = $brandid;
         } catch (BeubeuException $e) {
         }
     }
     if (!empty($modeltype)) {
         //规范模特id
         try {
             Comm::checkValue($modeltype, Yii::t('public', '模特类型'), 1, 1, self::$Int_max);
             if (!empty($w_s)) {
                 $w_s .= ' and ';
             }
             $w_s .= 'beu_clothes.modelgender=:modelgender';
             $w_s_arr[':modelgender'] = $modeltype;
         } catch (BeubeuException $e) {
         }
     }
     if (!empty($clothescategory)) {
         //规范品类一级
         try {
             Comm::checkValue($clothescategory, Yii::t('clothes', '一级品类'), 1, 1, self::$Int_max);
             if (!empty($w_s)) {
                 $w_s .= ' and ';
             }
             $w_s .= 'beu_clothes.clothescategory=:clothescategory';
             $w_s_arr[':clothescategory'] = $clothescategory;
         } catch (BeubeuException $e) {
         }
     }
     if (!empty($clothescategory2)) {
         //规范品类二级
         try {
             Comm::checkValue($clothescategory2, Yii::t('clothes', '二级品类'), 1, 0, self::$Int_max);
             if (!empty($w_s)) {
                 $w_s .= ' and ';
             }
             $w_s .= 'beu_clothes.clothescategory2=:clothescategory2';
             $w_s_arr[':clothescategory2'] = $clothescategory2;
         } catch (BeubeuException $e) {
         }
     }
     if (!empty($strd_data)) {
         //开始时间
         try {
             $strd_data = Comm::dataSingle($strd_data, Yii::t('clothes', '开始时间'));
             if (!empty($w_s)) {
                 $w_s .= ' and ';
             }
             $w_s .= 'beu_clothes.date_add>=:strd_data';
             $w_s_arr[':strd_data'] = $strd_data;
         } catch (BeubeuException $e) {
         }
     }
     if (!empty($end_data)) {
         //结束时间
         try {
             $end_data = Comm::dataSingle($end_data, Yii::t('clothes', '结束时间'));
             if (!empty($w_s)) {
                 $w_s .= ' and ';
             }
             $w_s .= 'beu_clothes.date_add<=:end_data';
             $w_s_arr[':end_data'] = $end_data;
         } catch (BeubeuException $e) {
         }
     }
     if (!empty($key)) {
         //规范关键词
         if (!empty($w_s)) {
             $w_s .= ' and (';
         }
         try {
             Comm::checkValue($key, Yii::t('public', '关键词'), 1, 1, self::$Int_max);
             $w_s .= 'beu_clothes.id=:clothesid or ';
             $w_s_arr[':clothesid'] = $key;
         } catch (BeubeuException $e) {
         }
         $w_s .= 'beu_clothes.name like :name or beu_clothes.brandnumber like :brandnumber )';
         $w_s_arr[':name'] = "%{$key}%";
         $w_s_arr[':brandnumber'] = "%{$key}%";
     }
     try {
         $sql = Yii::app()->db->createCommand()->select('beu_clothes.id,beu_clothes.name,beu_clothes.brandid,beu_clothes.clothescategory,beu_clothes.clothescategory2,beu_clothes.brandnumber,beu_clothes.modelgender,thumbnail,beu_clothes.date_add,beu_brand.name as brandname')->from('beu_clothes')->join('beu_brand', 'beu_clothes.brandid=beu_brand.id')->where($w_s, $w_s_arr)->order('beu_clothes.id desc');
         $sql2 = $sql;
         $newstypelist = $sql->limit($pagecount, ($page - 1) * $pagecount)->queryAll();
         //获取总个数
         $con = $sql2->queryAll();
         $con = count($con);
         $criteria = new CDbCriteria();
         $pages = new CPagination($con);
         $pages->pageSize = $pagecount;
         $pages->applyLimit($criteria);
         if (count($newstypelist) > 0) {
             return array('data' => $newstypelist, 'count' => $con, 'pageSize' => $pagecount, 'page' => $pages);
         } else {
             throw new BeubeuException(Yii::t('public', '查询数据失败'), BeubeuException::SQL_SELECT_ERR);
         }
     } catch (BeubeuException $e) {
         throw new BeubeuException(Yii::t('public', '查询数据失败'), BeubeuException::SQL_SELECT_ERR);
     }
 }