Exemple #1
0
 public static function add($word, $hot, $order = 99)
 {
     $word = IFilter::act($word);
     $hot = intval($hot);
     $order = intval($order);
     if ($word != '') {
         $keywordObj = new IModel('keyword');
         $wordArray = explode(',', $word);
         //获取各个关键词的管理商品数量
         $resultCount = self::count($wordArray);
         foreach ($wordArray as $word) {
             if (IString::getStrLen($word) >= 15) {
                 continue;
             }
             $is_exists = $keywordObj->getObj('word = "' . $word . '"', 'hot');
             if (empty($is_exists)) {
                 $dataArray = array('hot' => $hot, 'word' => $word, 'goods_nums' => $resultCount[$word], 'order' => $order);
                 $keywordObj->setData($dataArray);
                 $keywordObj->add();
             }
         }
         return array('flag' => true);
     }
     return array('flag' => false, 'data' => '请填写关键词');
 }
Exemple #2
0
 /**
  * @brief 字符串转码
  * @param $content string 要转换的字符串
  * @return string
  */
 public function converContent($content)
 {
     if (IString::isUTF8($content) == false) {
         return iconv('GBK', 'UTF-8//IGNORE', $content);
     }
     return $content;
 }
 /**
  * @brief 验证字符串的长度,和数值的大小。$str 为字符串时,判定长度是否在给定的$min到$max之间的长度,为数值时,判定数值是否在给定的区间内。
  * @param mixed $str 要验证的内容
  * @param int $min 最小值或最小长度
  * @param int $max 最大值或最大长度
  * @return bool 验证通过返回 true 不通过返回 false
  */
 public static function len($str, $min, $max)
 {
     if (is_int($str)) {
         return $str >= $min && $str <= $max;
     }
     if (is_string($str)) {
         return IString::getStrLen($str) >= $min && IString::getStrLen($str) <= $max;
     }
     return false;
 }
Exemple #4
0
 /**
  * @brief 过滤字符串的长度
  * @param string $str 被限制的字符串
  * @param int $length 限制的字节数
  * @return string 空:超出限制值; $str:原字符串;
  */
 public static function limitLen($str, $length)
 {
     if ($length !== false) {
         $count = IString::getStrLen($str);
         if ($count > $length) {
             return '';
         } else {
             return $str;
         }
     }
     return $str;
 }
Exemple #5
0
 /**
  * @brief 商品检索,可以直接读取 $_GET 全局变量:attr,order,brand,min_price,max_price
  *        在检索商品过程中计算商品结果中的进一步属性和规格的筛选
  * @param mixed $defaultWhere string(条件) or array('search' => '模糊查找','category_extend' => '商品分类ID','字段' => 对应数据)
  * @param int $limit 读取数量
  * @param bool $isCondition 是否筛选出商品的属性,价格等数据
  * @return IQuery
  */
 public static function find($defaultWhere = '', $limit = 21, $isCondition = true)
 {
     //获取配置信息
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     $orderArray = array();
     //排序
     //开始查询
     $goodsObj = new IQuery("goods as go");
     $goodsObj->page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $goodsObj->fields = ' go.* ';
     $goodsObj->pagesize = $limit;
     /*where条件拼接*/
     //(1),当前产品分类
     $where = ' go.is_del = 0 ';
     //(2),商品属性,规格筛选
     $attrCond = array();
     $childSql = '';
     $attrArray = IReq::get('attr') ? IFilter::act(IReq::get('attr')) : array();
     foreach ($attrArray as $key => $val) {
         if ($key && $val) {
             $attrCond[] = ' attribute_id = ' . intval($key) . ' and FIND_IN_SET("' . $val . '",attribute_value)';
         }
     }
     //合并规格与属性的值,并且生成SQL查询语句
     $GoodsId = null;
     if ($attrCond) {
         $tempArray = array();
         foreach ($attrCond as $key => $cond) {
             $tempArray[] = '(' . $cond . ')';
         }
         $childSql = join(' or ', $tempArray);
         $goodsAttrObj = new IQuery('goods_attribute');
         $goodsAttrObj->fields = 'goods_id';
         $goodsAttrObj->where = $childSql;
         $goodsAttrObj->group = 'goods_id';
         $goodsAttrObj->having = 'count(goods_id) >= ' . count($attrCond);
         //每个子条件都有一条记录,则存在几个count(条件)必须包含count(goods_id)条数量
         $goodsIdArray = $goodsAttrObj->find();
         $goodsIds = array();
         foreach ($goodsIdArray as $key => $val) {
             $goodsIds[] = $val['goods_id'];
         }
         $GoodsId = $GoodsId === null ? array_unique($goodsIds) : array_unique(array_intersect($goodsIds, $GoodsId));
     }
     //(3),处理defaultWhere条件 goods, category_extend
     if ($defaultWhere) {
         //兼容array 和 string 数据类型的goods条件筛选
         $goodsCondArray = array();
         if (is_string($defaultWhere)) {
             $goodsCondArray[] = $defaultWhere;
         } else {
             if (is_array($defaultWhere)) {
                 foreach ($defaultWhere as $key => $val) {
                     if (!$val) {
                         continue;
                     }
                     //商品分类检索
                     if ($key == 'category_extend') {
                         $currentCatGoods = array();
                         $categoryExtendObj = new IModel('category_extend');
                         $categoryExtendList = $categoryExtendObj->query("category_id in (" . $val . ")", 'goods_id', 'id', 'desc');
                         foreach ($categoryExtendList as $key => $val) {
                             $currentCatGoods[] = $val['goods_id'];
                         }
                         $GoodsId = $GoodsId === null ? array_unique($currentCatGoods) : array_unique(array_intersect($currentCatGoods, $GoodsId));
                     } else {
                         if ($key == 'search') {
                             $wordWhere = array();
                             $wordLikeOrder = array();
                             //检查输入的内容是否为分词形式
                             if (preg_match("#\\s+#", $defaultWhere['search']) == false) {
                                 $wordWhere[] = ' name like "%' . $defaultWhere['search'] . '%" or find_in_set("' . $defaultWhere['search'] . '",search_words) ';
                                 $wordLikeOrder[] = $defaultWhere['search'];
                             }
                             //进行分词
                             if (IString::getStrLen($defaultWhere['search']) >= 4 || IString::getStrLen($defaultWhere['search']) <= 100) {
                                 $wordData = words_facade::run($defaultWhere['search']);
                                 if (isset($wordData['data']) && count($wordData['data']) >= 2) {
                                     foreach ($wordData['data'] as $word) {
                                         $wordWhere[] = ' name like "%' . $word . '%" ';
                                         $wordLikeOrder[] = $word;
                                     }
                                 }
                             }
                             //分词排序
                             if (count($wordLikeOrder) > 1) {
                                 $orderTempArray = array();
                                 foreach ($wordLikeOrder as $key => $val) {
                                     $orderTempArray[] = "(CASE WHEN name LIKE '%" . $val . "%' THEN " . $key . " ELSE 100 END)";
                                 }
                                 $orderArray[] = " (" . join('+', $orderTempArray) . ") asc ";
                             }
                             $goodsCondArray[] = join(' or ', $wordWhere);
                         } else {
                             $goodsCondArray[] = $key . ' = "' . $val . '"';
                         }
                     }
                 }
             }
         }
         //goods 条件
         if ($goodsCondArray) {
             $goodsDB = new IModel('goods as go');
             $goodsCondData = $goodsDB->query(join(" and ", $goodsCondArray), "id");
             $goodsCondId = array();
             foreach ($goodsCondData as $key => $val) {
                 $goodsCondId[] = $val['id'];
             }
             $GoodsId = $GoodsId === null ? array_unique($goodsCondId) : array_unique(array_intersect($goodsCondId, $GoodsId));
         }
     }
     //过滤商品ID被删除的情况
     if ($GoodsId) {
         if (!isset($goodsDB)) {
             $goodsDB = new IModel("goods as go");
         }
         $goodsCondData = $goodsDB->query("go.id in (" . join(',', $GoodsId) . ") and go.is_del = 0 ", "id");
         $GoodsId = array();
         foreach ($goodsCondData as $key => $val) {
             $GoodsId[] = $val['id'];
         }
     }
     $GoodsId = $GoodsId === array() || $GoodsId === null ? array(0) : array_unique($GoodsId);
     //存在商品ID数据
     if ($GoodsId) {
         $GoodsId = array_slice($GoodsId, 0, search_goods::MAX_GOODSID);
         $where .= " and go.id in (" . join(',', $GoodsId) . ") ";
         //商品属性进行检索
         if ($isCondition == true) {
             /******属性 开始******/
             $attrTemp = array();
             $goodsAttrDB = new IModel('goods_attribute');
             $attrData = $goodsAttrDB->query("goods_id in (" . join(',', $GoodsId) . ")");
             foreach ($attrData as $key => $val) {
                 //属性
                 if ($val['attribute_id']) {
                     if (!isset($attrTemp[$val['attribute_id']])) {
                         $attrTemp[$val['attribute_id']] = array();
                     }
                     $checkSelectedArray = explode(",", $val['attribute_value']);
                     foreach ($checkSelectedArray as $k => $v) {
                         if (!in_array($v, $attrTemp[$val['attribute_id']])) {
                             $attrTemp[$val['attribute_id']][] = $v;
                         }
                     }
                 }
             }
             //属性的数据拼接
             if ($attrTemp) {
                 $attrDB = new IModel('attribute');
                 $attrData = $attrDB->query("id in (" . join(',', array_keys($attrTemp)) . ") and search = 1", "*", "id", "asc", 8);
                 foreach ($attrData as $key => $val) {
                     self::$attrSearch[] = array('id' => $val['id'], 'name' => $val['name'], 'value' => $attrTemp[$val['id']]);
                 }
             }
             /******属性 结束******/
             /******品牌 开始******/
             $brandQuery = new IModel('brand as b,goods as go');
             self::$brandSearch = $brandQuery->query("go.brand_id = b.id and go.id in (" . join(',', $GoodsId) . ")", "distinct b.id,b.name", "b.sort", "asc", 10);
             /******品牌 结束******/
             /******价格 开始******/
             self::$priceSearch = goods_class::getGoodsPrice(join(',', $GoodsId));
             /******价格 结束******/
         }
     }
     //(4),商品价格
     $where .= floatval(IReq::get('min_price')) ? ' and go.sell_price >= ' . floatval(IReq::get('min_price')) : '';
     $where .= floatval(IReq::get('max_price')) ? ' and go.sell_price <= ' . floatval(IReq::get('max_price')) : '';
     //(5),商品品牌
     $where .= intval(IReq::get('brand')) ? ' and go.brand_id = ' . intval(IReq::get('brand')) : '';
     //排序类别
     $order = IFilter::act(IReq::get('order'), 'url');
     if ($order == null) {
         $order = isset($site_config['order_by']) ? $site_config['order_by'] : 'new';
         $asc = isset($site_config['order_type']) ? $site_config['order_type'] : 'desc';
     } else {
         if (stripos($order, '_toggle')) {
             $order = str_replace('_toggle', '', $order);
             $asc = 'asc';
         } else {
             $asc = 'desc';
         }
     }
     switch ($order) {
         //销售量
         case "sale":
             $orderArray[] = ' go.sale ' . $asc;
             break;
             //评分
         //评分
         case "cpoint":
             $orderArray[] = ' go.grade ' . $asc;
             break;
             //最新上架
         //最新上架
         case "new":
             $orderArray[] = ' go.id ' . $asc;
             break;
             //价格
         //价格
         case "price":
             $orderArray[] = ' go.sell_price ' . $asc;
             break;
             //根据排序字段
         //根据排序字段
         default:
             $orderArray[] = ' go.sort asc ';
     }
     //设置IQuery类的各个属性
     $goodsObj->where = $where;
     $goodsObj->order = join(',', $orderArray);
     return $goodsObj;
 }
Exemple #6
0
 /**
  * @brief 保存修改商品信息
  */
 function goods_update()
 {
     //获得post的数据
     $goods_id = IFilter::act(IReq::get('goods_id'), 'int');
     $goods_name = IFilter::act(IReq::get('goods_name'));
     $goods_category = IReq::get('goods_category');
     $goods_model = IFilter::act(IReq::get('goods_model'), 'int');
     $goods_brand = IFilter::act(IReq::get('goods_brand'), 'int');
     $goods_status = IFilter::act(IReq::get('goods_status'), 'int');
     $goods_notes = IFilter::act(IReq::get('goods_notes'));
     $goods_from = IFilter::act(IReq::get('goods_from'));
     $goods_sellernick = IFilter::act(IReq::get('goods_sellernick'));
     $goods_commission = IFilter::act(IReq::get('goods_commission'), 'float');
     $goods_url = IFilter::act(IReq::get('goods_url'));
     $goods_img = IFilter::act(IReq::get('goods_img'));
     $list_img = IFilter::act(IReq::get('list_img'));
     $show_img = IFilter::act(IReq::get('small_img'));
     $sell_price = IFilter::act(IReq::get('sell_price'), 'float');
     $market_price = IFilter::act(IReq::get('market_price'), 'float');
     $discount = IFilter::act(IReq::get('discount'), 'float');
     $store_nums = IFilter::act(IReq::get('store_nums'), 'int');
     $weight = IFilter::act(IReq::get('weight'), 'float');
     $store_unit = IFilter::act(IReq::get('store_unit'));
     $content = IFilter::act(IReq::get('content'), 'text');
     $seo_keywords = IReq::get('seo_keywords');
     $seo_description = IReq::get('seo_description');
     $point = IFilter::act(IReq::get('point'), 'int');
     $exp = IFilter::act(IReq::get('exp'), 'int');
     $sort = IFilter::act(IReq::get('sort'));
     $focus_photo = IFilter::act(IReq::get('focus_photo'));
     $goods_no = IFilter::act(IReq::get('goods_no'));
     $keywords_for_search = IFilter::act(IReq::get('keywords_for_search'));
     $tb_goods = new IModel('goods');
     if (!$goods_no) {
         //如用户没有输入商品货号,则默认货号
         $goods_no = Block::goods_no($goods_id);
     } else {
         $goods_info = $tb_goods->query("goods_no='" . $goods_no . "'");
         $flag = 2;
         if (count($goods_info) > 0) {
             if (count($goods_info) == 1) {
                 if ($goods_info[0]['id'] != $goods_id) {
                     $flag = 1;
                 }
             } else {
                 $flag = 1;
             }
         }
         if ($flag == 1) {
             $type = array('gid' => $goods_id, 'admin_name' => $this->admin['admin_name'], 'admin_pwd' => $this->admin['admin_pwd']);
             $goods_in_fo = $tb_goods->getObj('id=' . $goods_id);
             $goods = new goods_class();
             $data = $goods->edit($type, $goods_in_fo);
             $this->setRenderData($data);
             $this->redirect('goods_edit', false);
             Util::showMessage("您输入的货号已存在!");
         }
     }
     //标签关键词
     $keywords_for_search = trim($keywords_for_search, ",");
     if ($keywords_for_search) {
         $keywords_for_search_array = array();
         foreach (explode(",", $keywords_for_search) as $value) {
             if (IString::getStrLen($value) <= 15) {
                 keywords::add($value, 0);
                 $keywords_for_search_array[] = $value;
             }
         }
         if ($keywords_for_search_array) {
             $data = array('goods_id' => $goods_id, 'keywords' => join(',', $keywords_for_search_array));
             $obj_goods_keywords = new IModel("goods_keywords");
             $obj_goods_keywords->setData($data);
             if ($obj_goods_keywords->getObj("goods_id={$goods_id}")) {
                 $obj_goods_keywords->update("goods_id={$goods_id}");
             } else {
                 $obj_goods_keywords->add();
             }
         }
     }
     //大图片
     $show_img = $focus_photo;
     $list_img = $focus_photo;
     if ($focus_photo) {
         $foot = substr($focus_photo, strpos($focus_photo, '.'));
         //图片扩展名
         $head = substr($focus_photo, 0, strpos($focus_photo, '.'));
         //获得配置文件中的数据
         $config = new Config("site_config");
         $config_info = $config->getInfo();
         $list_thumb_width = isset($config_info['list_thumb_width']) ? $config_info['list_thumb_width'] : 175;
         $list_thumb_height = isset($config_info['list_thumb_height']) ? $config_info['list_thumb_height'] : 175;
         $show_thumb_width = isset($config_info['show_thumb_width']) ? $config_info['show_thumb_width'] : 85;
         $show_thumb_height = isset($config_info['show_thumb_height']) ? $config_info['show_thumb_height'] : 85;
         //list
         $list_img = $head . '_' . $list_thumb_width . '_' . $list_thumb_height . $foot;
         //show
         $show_img = $head . '_' . $show_thumb_width . '_' . $show_thumb_height . $foot;
     } elseif ($goods_img) {
         $focus_photo = $goods_img;
     }
     //规格
     $spec_va = IReq::get('spec_va');
     $spec = array();
     $spec_array = array();
     if ($spec_va) {
         $arr = explode(';', $spec_va);
         $i = 0;
         foreach ($arr as $value) {
             if ($value) {
                 $brr = explode('|', $value);
                 $j = 0;
                 foreach ($brr as $va) {
                     $crr = explode(',', $va);
                     $spec[$i][$j]['id'] = $crr[1];
                     $spec[$i][$j]['name'] = $crr[2];
                     $spec[$i][$j]['type'] = $crr[3];
                     //商品规格类型
                     $spec_array[$j]['id'] = $crr[1];
                     if (!isset($spec_array[$j]['value'])) {
                         $spec_array[$j]['value'] = $crr[2] . ',';
                     } else {
                         if (!strpos(',,' . $spec_array[$j]['value'], ',' . $crr[2] . ',')) {
                             $spec_array[$j]['value'] .= $crr[2] . ',';
                         }
                     }
                     $spec_array[$j]['type'] = $crr[3];
                     $spec_array[$j]['name'] = $crr[4];
                     $j++;
                 }
                 $i++;
             }
         }
     }
     /*goods表操作*/
     $tb_goods->setData(array('name' => $goods_name, 'notes' => $goods_notes, 'goods_no' => $goods_no, 'sell_price' => $sell_price, 'market_price' => $market_price, 'discount' => $discount, 'store_nums' => $store_nums, 'brand_id' => $goods_brand, 'is_del' => $goods_status, 'from' => $goods_from, 'sellernick' => $goods_sellernick, 'commission' => $goods_commission, 'url' => $goods_url, 'content' => $content, 'keywords' => $seo_keywords, 'description' => $seo_description, 'weight' => $weight, 'unit' => $store_unit, 'point' => $point, 'exp' => $exp, 'sort' => $sort, 'small_img' => $show_img, 'img' => $focus_photo, 'list_img' => $list_img));
     $tb_goods->update('id=' . $goods_id);
     //商品扩展分类
     $tb_category = new IModel('category_extend');
     $tb_category->del('goods_id=' . $goods_id);
     if ($goods_category) {
         $tb_category->setData(array('goods_id' => $goods_id, 'category_id' => $goods_category));
         $tb_category->add();
     }
     /*commend_goods表操作*/
     $goods_commend = IReq::get('goods_commend');
     $tb_commend = new IModel('commend_goods');
     $tb_commend->del('goods_id=' . $goods_id);
     if (!empty($goods_commend)) {
         if (is_array($goods_commend)) {
             for ($i = 0; $i < count($goods_commend); $i++) {
                 $tb_commend->setData(array('commend_id' => $goods_commend[$i], 'goods_id' => $goods_id));
                 $tb_commend->add();
             }
         } else {
             $tb_commend->setData(array('commend_id' => $goods_commend, 'goods_id' => $goods_id));
             $tb_commend->add();
         }
     }
     /*goods_photo_relation表操作*/
     $photo_name = IReq::get('photo_name');
     $tb_goods_relation = new IModel('goods_photo_relation');
     $tb_goods_relation->del('goods_id=' . $goods_id);
     if ($photo_name) {
         $photo_name = substr($photo_name, 0, -1);
         $arr = explode(',', $photo_name);
         if (count($arr) > 0) {
             foreach ($arr as $value) {
                 //当图片存在的时候保存
                 if (file_exists($value)) {
                     $tb_goods_relation->setData(array('goods_id' => $goods_id, 'photo_id' => md5_file($value)));
                     $tb_goods_relation->add();
                 }
             }
         }
     }
     /*products表以及group_price的操作*/
     $member_ids = IFilter::act(IReq::get('member_ids'));
     $group_id = IFilter::act(IReq::get('group_id'));
     $products_id = IFilter::act(IReq::get('products_id'));
     //先对products表操作,先修改,再删除没有了的pro
     $tb_products = new Imodel('products');
     $tb_group_ob = new Imodel('group_price');
     if ($group_id) {
         $tb_group_ob->del('id in (' . $group_id . ')');
     }
     $store_nums = 0;
     //商品数量
     if ($spec_va) {
         $sell_price_array = array();
         //所有货品的销售价格
         $market_price_array = array();
         //所有货品的市场价格
         $discount_array = array();
         //所有货品的成本价格
         $weight_array = array();
         //所有货品的重量
         $arr = explode(';', $spec_va);
         $i = 0;
         foreach ($arr as $value) {
             if ($value) {
                 $brr = explode('|', $value);
                 $j = 0;
                 $ids = array();
                 $spec_md5 = '';
                 $pro_id = '';
                 $new_pro = '';
                 foreach ($brr as $va) {
                     $crr = explode(',', $va);
                     $pro_id = $crr[0];
                     $new_pro = $pro_id;
                     //判断商品是否为新添加的,如果是则pro_id以a开头
                     if (stristr($pro_id, 'a') != '') {
                         $pro_id = substr($pro_id, 1);
                     }
                     $ids[$j]['id'] = $crr[1];
                     $ids[$j]['value'] = $crr[2];
                     $spec_md5 .= md5($ids[$j]['value']) . ',';
                     $j++;
                 }
                 $specTemp = explode(',', trim($spec_md5, ','));
                 sort($specTemp);
                 $spec_md5 = md5(serialize($specTemp));
                 $store_nums += IReq::get('store_nums' . $pro_id);
                 $tb_products->setData(array('goods_id' => $goods_id, 'products_no' => IReq::get('goods_no' . $pro_id) ? IReq::get('goods_no' . $pro_id) : $goods_no . '-' . ($i + 1), 'spec_array' => serialize($ids), 'market_price' => IReq::get('market_price' . $pro_id) ? IReq::get('market_price' . $pro_id) : $market_price, 'sell_price' => IReq::get('sell_price' . $pro_id) ? IReq::get('sell_price' . $pro_id) : $sell_price, 'store_nums' => IReq::get('store_nums' . $pro_id) ? IReq::get('store_nums' . $pro_id) : $store_nums, 'discount' => IReq::get('discount' . $pro_id) ? IReq::get('discount' . $pro_id) : $discount, 'weight' => IReq::get('weight' . $pro_id) ? IReq::get('weight' . $pro_id) : $weight, 'spec_md5' => $spec_md5));
                 //获得所有的货品的销售价格、市场价格、成本价格、货品的重量
                 $sell_price_array[] = IReq::get('sell_price' . $pro_id) ? IReq::get('sell_price' . $pro_id) : $sell_price;
                 $market_price_array[] = IReq::get('market_price' . $pro_id) ? IReq::get('market_price' . $pro_id) : $market_price;
                 $discount_array[] = IReq::get('discount' . $pro_id) ? IReq::get('discount' . $pro_id) : $discount;
                 $weight_array[] = IReq::get('weight' . $pro_id) ? IReq::get('weight' . $pro_id) : $weight;
                 $mem_array = explode(',', $member_ids);
                 if (strpos('|' . $new_pro, 'a') > 0) {
                     $pr_id = $tb_products->add();
                     foreach ($mem_array as $cc) {
                         $gro_price = IFilter::act(IReq::get('mem_0_' . $new_pro . '_' . $cc), 'int');
                         if ($gro_price > 0 && $pr_id != 0) {
                             $tb_group_ob->setData(array('goods_id' => $goods_id, 'products_id' => $pr_id, 'group_id' => $cc, 'price' => $gro_price));
                             $tb_group_ob->add();
                         }
                     }
                 } else {
                     $tb_products->update('id=' . $pro_id);
                     $group_arr = explode(',', $group_id . ',0');
                     if ($group_arr) {
                         foreach ($group_arr as $va) {
                             foreach ($mem_array as $cc) {
                                 $gro_price = IFilter::act(IReq::get('mem_' . $va . '_' . $pro_id . '_' . $cc), 'int');
                                 if ($gro_price > 0) {
                                     $tb_group_ob->setData(array('goods_id' => $goods_id, 'products_id' => $pro_id, 'group_id' => $cc, 'price' => $gro_price));
                                     $tb_group_ob->add();
                                 }
                             }
                         }
                     } else {
                         foreach ($mem_array as $cc) {
                             $gro_price = IFilter::act(IReq::get('mem_0_' . $pro_id . '_' . $cc), 'int');
                             if ($gro_price > 0) {
                                 $tb_group_ob->setData(array('goods_id' => $goods_id, 'products_id' => $pro_id, 'group_id' => $cc, 'price' => $gro_price));
                                 $tb_group_ob->add();
                             }
                         }
                     }
                 }
             }
             $i++;
         }
         //如果商品的价格为空,则将货品的销售价格中最低的赋予
         $addition = array('store_nums' => $store_nums);
         if (!empty($sell_price_array)) {
             $addition['sell_price'] = min($sell_price_array);
         }
         if (!empty($market_price_array)) {
             $addition['market_price'] = min($market_price_array);
         }
         if (!empty($discount_array)) {
             $addition['discount'] = min($discount_array);
         }
         if (!empty($weight_array)) {
             $addition['weight'] = min($weight_array);
         }
         $tb_goods->setData($addition);
         //如果有products数据,则将products中的货品数量全部相加并送入goods表
         $tb_goods->update('id=' . $goods_id);
     }
     $mem_array = explode(',', $member_ids);
     $group_arr = explode(',', $group_id . ',0');
     if ($group_arr) {
         foreach ($group_arr as $va) {
             foreach ($mem_array as $cc) {
                 $gro_price = IFilter::act(IReq::get('mem_' . $va . '_0_' . $cc), 'int');
                 if ($gro_price > 0) {
                     $tb_group_ob->setData(array('goods_id' => $goods_id, 'products_id' => 0, 'group_id' => $cc, 'price' => $gro_price));
                     $tb_group_ob->add();
                 }
             }
         }
     }
     //获得删除的products_id
     $del_products_id = IFilter::act(IReq::get('del_products_id'));
     if ($del_products_id) {
         $del_products_id = substr($del_products_id, 0, -1);
         $info = explode(',', $del_products_id);
         foreach ($info as $value) {
             if (strpos('|' . $value, 'a') == false) {
                 $tb_products->del('id=' . $value);
             }
         }
     }
     $this->redirect("goods_list");
 }
Exemple #7
0
    $query = new IQuery("order_goods");
    $query->where = "order_id = {$order_id} and goods_id = {$item['goods_id']} and product_id = {$item['product_id']}";
    $items = $query->find();
    foreach ($items as $key => $good) {
        ?>
						<?php 
        $goods = JSON::decode($good['goods_array']);
        ?>
						<a href="<?php 
        echo IUrl::creatUrl("/site/products/id/" . $item['goods_id'] . "");
        ?>
" target="_blank" title="<?php 
        echo isset($goods['name']) ? $goods['name'] : "";
        ?>
"><?php 
        echo IString::substr($goods['name'], 25);
        ?>
 X <?php 
        echo isset($good['goods_nums']) ? $good['goods_nums'] : "";
        ?>
件</a>
						<?php 
    }
    ?>
						<?php 
    if ($item['seller_id']) {
        ?>
						<a href="<?php 
        echo IUrl::creatUrl("/site/home/id/" . $item['seller_id'] . "");
        ?>
" target="_blank"><img src="<?php 
 /**
  * constructor,open the csv packet date file
  * @param string $csvFile csv file name
  * @param string $targetImagePath create csv image path
  */
 public function __construct($csvFile, $targetImagePath)
 {
     if (!preg_match('|^[\\w\\-]+$|', basename($csvFile, '.csv'))) {
         throw new Exception('the csv file name must use english');
     }
     if (!file_exists($csvFile)) {
         throw new Exception('the csv file is not exists!');
     }
     if (!is_dir($targetImagePath)) {
         throw new Exception('the save csv image dir is not exists!');
     }
     if (IString::isUTF8(file_get_contents($csvFile)) == false) {
         die("zip包里面的CSV文件编码格式错误,必须修改为UTF-8格式");
     }
     //read csv file into dataLine array
     setlocale(LC_ALL, 'en_US.UTF-8');
     $fileHandle = fopen($csvFile, 'r');
     while ($tempRow = fgetcsv($fileHandle, 0, $this->separator)) {
         $this->dataLine[] = $tempRow;
     }
     $this->sourceImagePath = dirname($csvFile) . '/' . basename($csvFile, '.csv');
     $this->targetImagePath = $targetImagePath;
     if (!$this->dataLine) {
         throw new Exception('the csv file is empty!');
     }
 }