Exemplo n.º 1
0
 /**
  * 添加缓存sessin数据
  * @param $id 衣服id
  * @param $type 谁用 例:clothesVoid
  * @param $data 需要存在数据里的值 
  * @param $addess 需要存在数据里的值的位置 例:array('dd'=>array('kk'=>'da')),要将数据保存在二维数组kk下的写法 ('dd/kk')
  */
 public static function SessionAdd($id = 0, $type = '', $data = '', $addess = '')
 {
     $id = trim($id);
     $type = trim($type);
     $addess = trim($addess);
     $data = trim($data);
     try {
         Comm::checkValue($id, 'ID', 1, 1);
         Comm::checkValue($type, '', 0, 1);
         Comm::checkValue($addess, '', 0, 1);
         Comm::checkValue($data, '', 0, 1);
     } catch (Exception $e) {
         return false;
     }
     $addess2 = explode('/', $addess);
     $json_data = '';
     if ($id == 999999999) {
         $id = session_id();
     }
     if (isset($_SESSION[$type . $id])) {
         $json_data = $_SESSION[$type . $id];
         $json_data = trim($json_data);
         if (!empty($json_data)) {
             $json_data = json_decode($json_data, true);
         }
     }
     if (gettype($json_data) != 'array') {
         $json_data = array();
     }
     $xb = array_pop($addess2);
     //去除数组最后一个元素
     $json_data = json_encode(Comm::arrayAdd($json_data, $addess2, array($xb => $data)));
     $_SESSION[$type . $id] = $json_data;
     //		echo $type.$id.'---';
     //		print_r($json_data);exit();
 }
Exemplo n.º 2
0
 /**
  * 图片上传资料整理(与数据库对比后返回的更新到数据库的json数据)
  * @param $id:int 品牌id	
  * @return 成功返回整理后的json数据,否则返回false
  */
 private static function brandImgUp($id = 0)
 {
     $id = trim($id);
     try {
         Comm::checkValue($id, 'ID', 1, 1);
     } catch (Exception $e) {
         return false;
     }
     $arr = uploadd::SessionGet($id, self::$Img_Session_name);
     //获取session里的暂存数据
     if ($arr) {
         $arr = trim($arr);
         if (!empty($arr)) {
             $arr = json_decode($arr, true);
             if (count($arr) > 0) {
                 try {
                     $data = Yii::app()->db->createCommand()->select('logoimgpath')->from('beu_brand')->where('id=:id', array(':id' => $id))->queryAll();
                     if ($data[0]['logoimgpath'] != '') {
                         Comm::arrayDelete($data[0]['logoimgpath']);
                         //删除需要被替换的文件
                     }
                 } catch (Exception $e) {
                 }
                 return json_encode($arr);
             }
         }
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  * 根据触摸屏id对其下的modellimit字段修改
  * @param $touchid 触摸屏id
  * @param $arr 模特数组 array(模特)
  */
 public static function touchUpdateByIdModel($touchid, $arr = array())
 {
     $touchid = trim($touchid);
     try {
         Comm::checkValue($touchid, Yii::t('public', '触摸屏号'), 1, 1);
     } catch (BeubeuException $e) {
         throw new BeubeuException($e->getMessage(), $e->getCode());
     }
     if (count($arr) > 0 && gettype($arr) == 'array') {
         $modellimit = json_encode($arr);
         try {
             touch_config::model()->updateAll(array('modellimit' => $modellimit), 'id=:textx', array(':textx' => $touchid));
         } catch (BeubeuException $e) {
             throw new BeubeuException(Yii::t('public', '修改数据失败'), BeubeuException::SQL_UPDATE_ERR);
         }
     }
 }
Exemplo n.º 4
0
 /**
  * 查询状态表
  * @param $userid
  * @return usermode用户状态数组
  */
 public function usermodeSeleteStatus($userid)
 {
     $usermode = array();
     try {
         Comm::checkValue($userid, yii::t('beu_users', "用户编号"), 1, 1);
         //用户编号
     } catch (BeubeuException $e) {
         return $usermode;
     }
     $where = "userid={$userid}";
     $usermode = Yii::app()->db->createCommand()->select('*')->from("beu_usermode")->where($where)->queryAll();
     return $usermode;
 }
Exemplo n.º 5
0
 /**
  * 根据父级查询分类详细信息 
  * @param parentid int 分类id 默认0查询所有
  * @return 如果查询数据成功返回结果集
  * 否则返回false
  */
 public function categorySelectByParent($parentid = 0)
 {
     $parentid = trim($parentid);
     try {
         Comm::checkValue($parentid, Yii::t('beu_category', '父级编号'), 1, 1);
     } catch (BeubeuException $e) {
         echo $e->getMessage();
         return false;
     }
     try {
         $date = beu_category::model()->find('id=:parentid', array(':parentid' => $parentid));
         if (empty($date)) {
             throw new BeuBeuException(Yii::t('public', '查询数据失败'), BeuBeuException::SQL_SELECT_ERR);
         } else {
             return $date;
         }
     } catch (BeubeuException $e) {
         throw new BeuBeuException(Yii::t('public', '查询数据失败'), BeuBeuException::SQL_SELECT_ERR);
     }
 }
Exemplo n.º 6
0
 /**
  * 单品列表
  * @parm $arr
  * */
 public static function bclothes($arr = array(), $pagenumber = 1, $pagenum = 8)
 {
     $where = '1=1';
     $where2 = '1=1';
     if (!empty($arr['brandid'])) {
         $str_param = trim($arr['brandid']);
         $where .= " && beu_clothes.brandid in ({$str_param})";
         $where2 .= " && beu_clothes.brandid in ({$str_param})";
     }
     if (!empty($arr['singlespace'])) {
         $str_param = trim($arr['singlespace']);
         if ($str_param == 3) {
             $str_param = 0;
         }
         $where .= " && beu_clothes.singlespace = {$str_param}";
     }
     $push_clothes_arr = array();
     if (!empty($arr['status'])) {
         $str_param = trim($arr['status']);
         if ($str_param == 100 || $str_param == 200) {
             //获取已设置的推送天猫数据
             $p_where = array('tmall_push' => '=1');
             if (!empty($arr['brandid'])) {
                 $p_where['brandid'] = '=' . $arr['brandid'];
             }
             $push_clothes = self::getpushclothes('clothesid', $p_where);
             if ($push_clothes['status'] == 1) {
                 foreach ($push_clothes['data'] as $p_value) {
                     $push_clothes_arr[] = $p_value['clothesid'];
                 }
             }
         } else {
             $where .= " && beu_clothes.status = {$str_param}";
         }
     }
     //开衫闭合
     if (!empty($arr['open_close'])) {
         $str_param = trim($arr['open_close']);
         $where .= " && beu_clothes.open_close = " . ($str_param == 3 ? 0 : $str_param);
     }
     //模特类型
     if (!empty($arr['modeltype'])) {
         $str_param = trim($arr['modeltype']);
         $where .= " && beu_clothes.modelgender = {$str_param}";
     }
     //一级分类
     if (!empty($arr['clothescategory'])) {
         $str_param = trim($arr['clothescategory']);
         $where .= " && beu_clothes.clothescategory = {$str_param}";
     }
     //二级分类
     if (!empty($arr['clothescategory2'])) {
         $str_param = trim($arr['clothescategory2']);
         $where .= " && beu_clothes.clothescategory2 = {$str_param}";
     }
     //3.0遮罩
     if (isset($arr['mask3']) && !empty($arr['mask3'])) {
         $str_param = intval(trim($arr['mask3']));
         if ($str_param == 1) {
             //未做过3.0遮罩
             $where .= " && (beu_clothes.mask3 ='' or beu_clothes.mask3 is null)";
         } elseif ($str_param == 2) {
             //只做过正面3.0遮罩
             $where .= " && (beu_clothes.mask3 like '%\"angel0\":{%' and beu_clothes.mask3 not like '%\"angel6\":{%')";
         } elseif ($str_param == 3) {
             //包含正背面3.0遮罩
             $where .= " && (beu_clothes.mask3 like '%\"angel0\":{%' and beu_clothes.mask3 like '%\"angel6\":{%')";
         } elseif ($str_param == 4) {
             //只做过背面3.0遮罩
             $where .= " && (beu_clothes.mask3 not like '%\"angel0\":{%' and beu_clothes.mask3 like '%\"angel6\":{%')";
         }
     }
     if (isset($arr['strd_data'])) {
         $str_param = trim($arr['strd_data']);
         try {
             $where .= " && DATE_FORMAT(beu_clothes.date_add,'%Y-%m-%d') >='{$str_param}'";
         } catch (BeubeuException $e) {
         }
     }
     if (isset($arr['end_data'])) {
         $str_param = trim($arr['end_data']);
         try {
             //
             $where .= " && DATE_FORMAT(beu_clothes.date_add,'%Y-%m-%d') <='{$str_param}'";
         } catch (BeubeuException $e) {
         }
     }
     if (isset($arr['key'])) {
         //规范关键词
         $str_param = trim($arr['key']);
         if (empty($arr['keytype'])) {
             if (!empty($str_param)) {
                 $where .= ' and (';
                 try {
                     Comm::checkValue($str_param, Yii::t('public', '关键词'), 1, 1, self::$Int_max);
                     $where .= " beu_clothes.id={$str_param} or ";
                 } catch (BeubeuException $e) {
                 }
                 $where .= " beu_clothes.name like '%{$str_param}%'";
                 $where .= " or beu_clothes.brandnumber like '%{$str_param}%'";
                 $where .= " or beu_clothes.code like '%{$str_param}%'";
                 $where .= ' )';
             }
         } else {
             if ($arr['keytype'] == 2) {
                 //id
                 $where .= " and (beu_clothes.id={$str_param})";
             }
             if ($arr['keytype'] == 3) {
                 //品名
                 $where .= " and (beu_clothes.name like '%{$str_param}%')";
             }
             if ($arr['keytype'] == 1) {
                 //款号
                 $where .= " and (beu_clothes.brandnumber like '%{$str_param}%')";
             }
             if ($arr['keytype'] == 4) {
                 //款号
                 $where .= " and (beu_clothes.code like '%{$str_param}%')";
             }
             if ($arr['keytype'] == 5) {
                 //品牌
                 $brand_arr = array();
                 $brand_data = Yii::app()->db->createCommand()->select('beu_brand.id')->from('beu_brand')->where('status=10 and (id=\'' . $str_param . '\' or name like \'%' . $str_param . '%\' or englishname like \'%' . $str_param . '%\')')->queryAll();
                 if (count($brand_data) > 0) {
                     foreach ($brand_data as $brand_value) {
                         $brand_arr[] = $brand_value['id'];
                     }
                     $brand_arr = implode(',', $brand_arr);
                 } else {
                     $brand_arr = 0;
                 }
                 $where .= " and (beu_clothes.brandid in(" . $brand_arr . "))";
             }
         }
     }
     if (isset($arr['img_patch']) && is_array($arr['img_patch'])) {
         $img_patch_str = '';
         foreach ($arr['img_patch'] as $value) {
             if (!empty($img_patch_str)) {
                 $img_patch_str .= ' or ';
             }
             $img_patch_str .= "beu_clothes.code like '_____" . $value . "%'";
         }
         $where .= " and (" . $img_patch_str . ")";
     }
     if (isset($arr['dateorder']) && $arr['dateorder'] == 'asc') {
         $date_order = 'beu_clothes.date_add asc';
     } else {
         if (isset($arr['dateorder']) && $arr['dateorder'] == 'desc') {
             $date_order = 'beu_clothes.date_add desc';
         }
     }
     if (isset($arr['codeorder']) && $arr['codeorder'] == 'asc') {
         $date_order = 'beu_clothes.code asc';
     } else {
         if (isset($arr['codeorder']) && $arr['codeorder'] == 'desc') {
             $date_order = 'beu_clothes.code desc';
         }
     }
     $sel_str = '';
     //获取天猫 单品
     $tm_clothes_obj = Yii::app()->db->createCommand()->select('clothesid,status')->from('beu_clothes_status_tmall');
     if (isset($arr['img_status']) && $arr['img_status'] != -1) {
         $tm_clothes_obj->where("status=" . $arr['img_status']);
     }
     $tm_clothes_obj = $tm_clothes_obj->queryAll();
     $tm_clothes_id_arr = array();
     $tm_clothes_status_arr = array();
     foreach ($tm_clothes_obj as $key => $value) {
         $tm_clothes_id_arr[$key] = $value['clothesid'];
         $tm_clothes_status_arr[$key] = $value['status'];
     }
     $tm_clothes_id_str = 0;
     if (count($tm_clothes_id_arr) > 0) {
         $tm_clothes_id_str = implode(',', $tm_clothes_id_arr);
     }
     $tm_where = '';
     if (isset($arr['push_type']) && $arr['push_type'] == 'tmall') {
         //天猫
         $tm_where = ' and beu_clothes.id in(' . $tm_clothes_id_str . ')';
     } else {
         if (isset($arr['status']) && $arr['status'] == 100 && count($push_clothes_arr) == 0) {
             $tm_where = ' and beu_clothes.id in(0)';
         } else {
             if (isset($arr['status']) && $arr['status'] == 100 && count($push_clothes_arr) > 0) {
                 $tm_where = ' and beu_clothes.id in(' . implode(',', $push_clothes_arr) . ') and beu_clothes.id not in(' . $tm_clothes_id_str . ')';
             } else {
                 if (isset($arr['status']) && $arr['status'] == 200 && count($push_clothes_arr) == 0) {
                     $tm_where = ' and beu_clothes.id not in(' . $tm_clothes_id_str . ')';
                 } else {
                     if (isset($arr['status']) && $arr['status'] == 200 && count($push_clothes_arr) > 0) {
                         $tm_where = ' and beu_clothes.id not in(' . implode(',', array_merge(Comm::array_diff_fast($push_clothes_arr, $tm_clothes_id_arr), $tm_clothes_id_arr)) . ')';
                     } else {
                         $tm_where = ' and beu_clothes.id not in(' . $tm_clothes_id_str . ')';
                     }
                 }
             }
         }
     }
     //获取beu_clothes单品
     $obj2 = Yii::app()->db->createCommand()->select('beu_clothes.*' . $sel_str)->from('beu_clothes');
     $obj2 = $obj2->where($where . $tm_where)->order($date_order)->limit($pagenum, ($pagenumber - 1) * $pagenum)->queryAll();
     if (isset($arr['push_type']) && $arr['push_type'] == 'tmall') {
         //天猫
         foreach ($obj2 as $key => $value) {
             $arr_key = array_search($value['id'], $tm_clothes_id_arr);
             if ($arr_key !== false) {
                 $obj2[$key]['tm_status'] = $tm_clothes_status_arr[$arr_key];
             }
         }
     }
     //		echo Yii::app()->db->createCommand()
     //		->select('*')->from('beu_clothes')
     //		->where($where)->order('id desc')->limit ( $pagenum, ($pagenumber - 1) * $pagenum )->gettext();
     //		exit();
     $con = Yii::app()->db->createCommand()->select('count(beu_clothes.id) as conn')->from('beu_clothes');
     $con = $con->where($where . $tm_where)->queryRow();
     $timeobj = Yii::app()->db->createCommand()->select("DATE_FORMAT(date_add,'%Y-%m-%d') as dateadd")->from('beu_clothes');
     $timeobj = $timeobj->where($where2 . $tm_where)->order('dateadd desc')->group('dateadd')->queryAll();
     //翻页
     $criteria = new CDbCriteria();
     $pages = new CPagination($con['conn']);
     $pages->pageSize = $pagenum;
     $pages->applyLimit($criteria);
     if (!empty($obj2)) {
         $objj['timeobj'] = $timeobj;
         $objj["pages"] = $pages;
         //			$objj['con'] = $con;
         $objj['data'] = $obj2;
         return $objj;
     } else {
         return false;
     }
 }