Beispiel #1
0
 /**
  * @param $province string 省份的id
  * @param $weight int 货物的重量
  * @param $goodsSum float 商品总价格
  * @return array()
  * @brief 配送方式计算管理模块
  */
 public static function getDelivery($province, $weight = 0, $goodsSum = 0)
 {
     $data = array();
     //获得配送方式表的对象
     $delivery = new IModel('delivery');
     //获取配送方式列表
     $where = 'is_delete = 0 and status = 1';
     $list = $delivery->query($where, '*', 'sort', 'asc');
     //循环各个配送方式
     foreach ($list as $value) {
         //设置首重和次重
         self::$firstWeight = $value['first_weight'];
         self::$secondWeight = $value['second_weight'];
         $data[$value['id']]['id'] = $value['id'];
         $data[$value['id']]['name'] = $value['name'];
         $data[$value['id']]['type'] = $value['type'];
         $data[$value['id']]['description'] = $value['description'];
         $data[$value['id']]['if_delivery'] = '0';
         //当配送方式是统一配置的时候,不进行区分地区价格
         if ($value['price_type'] == 0) {
             $data[$value['id']]['price'] = self::getFeeByWeight($weight, $value['first_price'], $value['second_price']);
         } else {
             $matchKey = '';
             $flag = false;
             //每项都是以';'隔开的省份ID
             $area_groupid = unserialize($value['area_groupid']);
             foreach ($area_groupid as $key => $result) {
                 //匹配到了特殊的省份运费价格
                 if (strpos($result, ';' . $province . ';') !== false) {
                     $matchKey = $key;
                     $flag = true;
                     break;
                 }
             }
             //匹配到了特殊的省份运费价格
             if ($flag) {
                 //获取当前省份特殊的运费价格
                 $firstprice = unserialize($value['firstprice']);
                 $secondprice = unserialize($value['secondprice']);
                 $data[$value['id']]['price'] = self::getFeeByWeight($weight, $firstprice[$matchKey], $secondprice[$matchKey]);
             } else {
                 //判断是否设置默认费用了
                 if ($value['open_default'] == 1) {
                     $data[$value['id']]['price'] = self::getFeeByWeight($weight, $value['first_price'], $value['second_price']);
                 } else {
                     $data[$value['id']]['price'] = '0';
                     $data[$value['id']]['if_delivery'] = '1';
                 }
             }
         }
         //计算保价
         if ($value['is_save_price'] == 1) {
             $tempProtectPrice = $goodsSum * ($value['save_rate'] * 0.01);
             $data[$value['id']]['protect_price'] = $tempProtectPrice <= $value['low_price'] ? $value['low_price'] : $tempProtectPrice;
         } else {
             $data[$value['id']]['protect_price'] = 0;
         }
     }
     return $data;
 }
Beispiel #2
0
 /**
  * @brief 获取地区
  */
 public function area_child()
 {
     $parent_id = intval(IReq::get("aid"));
     $areaDB = new IModel('areas');
     $data = $areaDB->query("parent_id={$parent_id}", '*', 'sort', 'asc');
     echo JSON::encode($data);
 }
Beispiel #3
0
 public static function ucenter_order()
 {
     $siteConfig = new Config('site_config');
     $order_cancel_time = $siteConfig->order_cancel_time !== "" ? intval($siteConfig->order_cancel_time) : 7;
     $order_finish_time = $siteConfig->order_finish_time !== "" ? intval($siteConfig->order_finish_time) : 20;
     $orderModel = new IModel('order');
     $orderCancelData = $order_cancel_time >= 0 ? $orderModel->query(" if_del = 0 and pay_type != 0 and status in(1) and datediff(NOW(),create_time) >= {$order_cancel_time} ", "id,order_no,4 as type_data") : array();
     $orderCreateData = $order_finish_time >= 0 ? $orderModel->query(" if_del = 0 and distribution_status = 1 and status in(1,2) and datediff(NOW(),send_time) >= {$order_finish_time} ", "id,order_no,5 as type_data") : array();
     $resultData = array_merge($orderCreateData, $orderCancelData);
     if ($resultData) {
         foreach ($resultData as $key => $val) {
             $type = $val['type_data'];
             $order_id = $val['id'];
             $order_no = $val['order_no'];
             //oerder表的对象
             $tb_order = new IModel('order');
             $tb_order->setData(array('status' => $type, 'completion_time' => ITime::getDateTime()));
             $tb_order->update('id=' . $order_id);
             //生成订单日志
             $tb_order_log = new IModel('order_log');
             //订单自动完成
             if ($type == '5') {
                 $action = '完成';
                 $note = '订单【' . $order_no . '】完成成功';
                 //完成订单并且进行支付
                 Order_Class::updateOrderStatus($order_no);
                 //增加用户评论商品机会
                 Order_Class::addGoodsCommentChange($order_id);
                 $logObj = new log('db');
                 $logObj->write('operation', array("系统自动", "订单更新为完成", '订单号:' . $order_no));
             } else {
                 $action = '作废';
                 $note = '订单【' . $order_no . '】作废成功';
                 //订单重置取消
                 Order_class::resetOrderProp($order_id);
                 $logObj = new log('db');
                 $logObj->write('operation', array("系统自动", "订单更新为作废", '订单号:' . $order_no));
             }
             $tb_order_log->setData(array('order_id' => $order_id, 'user' => "系统自动", 'action' => $action, 'result' => '成功', 'note' => $note, 'addtime' => ITime::getDateTime()));
             $tb_order_log->add();
         }
     }
 }
Beispiel #4
0
 /**
  * @param $user_id string 用户的id
  * @return $message String 返回站内消息id的字符串
  * @brief 获得member表中的messageid,去掉-的message的id
  */
 public function get_mess_ids()
 {
     $tb_member = new IModel('member');
     $member_info = $tb_member->query('user_id=' . $this->user_id);
     $message = null;
     $this->old_ids = $member_info[0]['message_ids'];
     if (count($member_info) > 0) {
         $message = str_replace('-', '', $member_info[0]['message_ids']);
     }
     return $message;
 }
Beispiel #5
0
 /**
  * @brief 根据传入的地域ID获取地域名称,获取的名称是根据ID依次获取的
  * @param int 地域ID 匿名参数可以多个id
  * @return array
  */
 public static function name()
 {
     $result = array();
     $paramArray = func_get_args();
     $areaDB = new IModel('areas');
     $areaData = $areaDB->query("area_id in (" . trim(join(',', $paramArray), ",") . ")");
     foreach ($areaData as $key => $value) {
         $result[$value['area_id']] = $value['area_name'];
     }
     return $result;
 }
Beispiel #6
0
 function init()
 {
     $this->tablePre = isset(IWeb::$app->config['DB']['tablePre']) ? IWeb::$app->config['DB']['tablePre'] : '';
     // 获取导航配置
     $guideObj = new IModel('guide');
     $guide_list = $guideObj->query('', '`order`,`name`,`link`', '`order`', 'desc');
     if (count($guide_list) > 0) {
         $this->guide_list = $guide_list;
     }
     $this->sort_type_map = array('0' => "{$this->tablePre}goods.sort ASC", '1' => "{$this->tablePre}goods.volume DESC", '2' => "{$this->tablePre}goods.discount ASC");
     $siteConfigObj = new Config("site_config");
     $site_config = $siteConfigObj->getInfo();
     $this->site_config = $site_config;
 }
Beispiel #7
0
 public static function get_cat_by_id($id)
 {
     if (!is_array($id)) {
         $id = array($id);
     }
     if (!$id) {
         return array();
     }
     foreach ($id as $key => $value) {
         $id[$key] = intval($value);
     }
     $id = implode(",", array_unique($id));
     $tb_help_cat = new IModel('help_category');
     $list = $tb_help_cat->query("id IN ({$id})");
     return Util::array_rekey($list, 'id');
 }
Beispiel #8
0
 /**
  * @brief 品牌分类添加、修改
  */
 function category_edit()
 {
     $category_id = (int) IReq::get('cid');
     //编辑品牌分类 读取品牌分类信息
     if ($category_id) {
         $obj_brand_category = new IModel('brand_category');
         $category_info = $obj_brand_category->query('id=' . $category_id);
         if (is_array($category_info) && ($info = $category_info[0])) {
             $this->data['category'] = array('id' => $info['id'], 'name' => $info['name']);
         } else {
             $this->category_list();
             Util::showMessage("没有找到相关品牌分类!");
             return;
         }
     }
     $this->setRenderData($this->data);
     $this->redirect('category_edit', false);
 }
Beispiel #9
0
 /**
  * 退订,并记录退订理由
  * @param string $email 
  * @param string $content 退订理由
  * @static
  */
 public static function unsubscribe($email, $content)
 {
     $email = addslashes($email);
     $tb = new IModel("email_registry");
     $re = $tb->query("email = '{$email}' AND flag=1");
     if (!$re) {
         return array('flag' => false, 'data' => '你还没有订阅');
     }
     $re = end($re);
     /*
     $re['content'] = htmlspecialchars($content,ENT_QUOTES);
     $re['flag'] = 0;
     $tb->setData($re);
     $tb->update("id={$re['id']}");
     */
     $tb->del("id={$re['id']}");
     return array('flag' => true, 'data' => 'success');
 }
Beispiel #10
0
 static function showCat($selectName = 'category_id', $selectedValue = null, $defaultValue = array())
 {
     //取得文章分类信息
     $catObj = new IModel('article_category');
     $data = $catObj->query('', 'id,name,path', 'path', 'asc');
     $str = '<select class="auto" name="' . $selectName . '" pattern="required" alt="请选择分类值">';
     //默认option值
     if (!empty($defaultValue)) {
         $str .= '<option value="' . current($defaultValue) . '">' . key($defaultValue) . '</option>';
     }
     //拼接分类信息
     foreach ($data as $val) {
         $isSelect = $val['id'] == $selectedValue ? 'selected=selected' : null;
         $str .= '<option value="' . $val['id'] . '" ' . $isSelect . '>' . str_repeat("&nbsp;&nbsp;", substr_count($val['path'], ",") - 2) . '└' . $val['name'] . '</option>';
     }
     $str .= '</select>';
     return $str;
 }
Beispiel #11
0
 /**
  * @brief 修改品牌
  */
 function brand_edit()
 {
     $brand_id = (int) IReq::get('bid');
     //编辑品牌 读取品牌信息
     if ($brand_id) {
         $obj_brand = new IModel('brand');
         $brand_info = $obj_brand->query('id=' . $brand_id);
         if (is_array($brand_info) && ($info = $brand_info[0])) {
             $this->data['brand'] = array('id' => $info['id'], 'name' => $info['name'], 'logo' => $info['logo'], 'url' => $info['url'], 'sort' => $info['sort'], 'description' => $info['description']);
         } else {
             $this->category_list();
             Util::showMessage("没有找到相关品牌分类!");
             return;
         }
     }
     $this->setRenderData($this->data);
     $this->redirect('brand_edit', false);
 }
Beispiel #12
0
 /**
  * 检测用户是否能够评论
  *
  * @param int $comment_id 评论id
  * @param int $user_id 用户id
  * @return array() array(成功or失败,数据)
  */
 public static function can_comment($comment_id, $user_id)
 {
     $comment_id = intval($comment_id);
     $user_id = intval($user_id);
     $tb_comment = new IModel("comment");
     $comment = $tb_comment->query("id={$comment_id} AND user_id={$user_id}");
     if (!$comment) {
         return array(-1, "没有这条数据");
     }
     $comment = end($comment);
     if ($comment['status'] != 0) {
         return array(-2, $comment);
     }
     $time = strtotime($comment['time']);
     if ($time < 3600 * 24 * 30 * 6) {
         return array(-3, $comment);
     }
     return array(1, $comment);
 }
Beispiel #13
0
 function registry_list()
 {
     $tb_user_group = new IModel('user_group');
     $data_group = $tb_user_group->query();
     $data_group = is_array($data_group) ? $data_group : array();
     $group = array();
     foreach ($data_group as $value) {
         $group[$value['id']] = $value['group_name'];
     }
     $this->data['group'] = $group;
     $this->setRenderData($this->data);
     //获取模板
     $tb_tpl = new IModel("msg_template");
     $tpl = $tb_tpl->getObj("id=2");
     if (!$tpl) {
         $tpl = array('name' => '', 'title' => '', 'content' => '');
     }
     $this->tpl = $tpl;
     $this->redirect('registry_list');
 }
Beispiel #14
0
 public function getBrandListByGoodsCategoryId($id, $limit = 14)
 {
     $result = array();
     $tb_brand_category = new IModel('brand_category');
     $info = $tb_brand_category->query("goods_category_id=" . $id);
     if ($info) {
         $query = new IQuery('brand');
         foreach ($info as $key => $val) {
             $query->where = " FIND_IN_SET(" . $val['id'] . ",category_ids) ";
             $query->order = 'sort asc';
             $query->limit = $limit;
             $list = $query->find();
             $result = array_merge($result, $list);
             if (count($result) >= $limit) {
                 $result = array_slice($result, 0, $limit);
                 break;
             }
         }
     }
     return $result;
 }
Beispiel #15
0
 public function getPaymentListByOnline()
 {
     $where = " type = 1 and status = 0 and class_name not in ('balance','offline') ";
     switch (IClient::getDevice()) {
         //移动支付
         case IClient::MOBILE:
             $where .= ' and client_type in(2,3) ';
             //如果不是微信客户端,去掉微信专用支付
             if (IClient::isWechat() == false) {
                 $where .= " and class_name != 'wap_wechat'";
             }
             break;
             //pc支付
         //pc支付
         case IClient::PC:
             $where .= ' and client_type in(1,3) ';
             break;
     }
     $paymentDB = new IModel('payment');
     return $paymentDB->query($where);
 }
Beispiel #16
0
 function goods_copy()
 {
     $idArray = explode(',', IReq::get('id'));
     $idArray = IFilter::act($idArray, 'int');
     $goodsDB = new IModel('goods');
     $goodsAttrDB = new IModel('goods_attribute');
     $goodsPhotoRelationDB = new IModel('goods_photo_relation');
     $productsDB = new IModel('products');
     $goodsData = $goodsDB->query('id in (' . join(',', $idArray) . ') and is_share = 1 and is_del = 0 and seller_id = 0', '*');
     if ($goodsData) {
         foreach ($goodsData as $key => $val) {
             //判断是否重复
             if ($goodsDB->getObj('seller_id = ' . $this->seller['seller_id'] . ' and name = "' . $val['name'] . '"')) {
                 die('商品不能重复复制');
             }
             $oldId = $val['id'];
             //商品数据
             unset($val['id'], $val['visit'], $val['favorite'], $val['sort'], $val['comments'], $val['sale'], $val['grade'], $val['is_share']);
             $val['seller_id'] = $this->seller['seller_id'];
             $val['goods_no'] .= '-' . $this->seller['seller_id'];
             $goodsDB->setData($val);
             $goods_id = $goodsDB->add();
             //商品属性
             $attrData = $goodsAttrDB->query('goods_id = ' . $oldId);
             if ($attrData) {
                 foreach ($attrData as $k => $v) {
                     unset($v['id']);
                     $v['goods_id'] = $goods_id;
                     $goodsAttrDB->setData($v);
                     $goodsAttrDB->add();
                 }
             }
             //商品图片
             $photoData = $goodsPhotoRelationDB->query('goods_id = ' . $oldId);
             if ($photoData) {
                 foreach ($photoData as $k => $v) {
                     unset($v['id']);
                     $v['goods_id'] = $goods_id;
                     $goodsPhotoRelationDB->setData($v);
                     $goodsPhotoRelationDB->add();
                 }
             }
             //货品
             $productsData = $productsDB->query('goods_id = ' . $oldId);
             if ($productsData) {
                 foreach ($productsData as $k => $v) {
                     unset($v['id']);
                     $v['products_no'] .= '-' . $this->seller['seller_id'];
                     $v['goods_id'] = $goods_id;
                     $productsDB->setData($v);
                     $productsDB->add();
                 }
             }
         }
         die('success');
     } else {
         die('复制的商品不存在');
     }
 }
Beispiel #17
0
 /**
  * @brief 回收站
  */
 function recycling()
 {
     $search = IReq::get('search');
     $keywords = IReq::get('keywords');
     $search_sql = IFilter::act($search, 'string');
     $keywords = IFilter::act($keywords, 'string');
     $where = ' 1 ';
     if ($search && $keywords) {
         $where .= " and {$search_sql} like '%{$keywords_sql}%' ";
     }
     $this->data['search'] = $search;
     $this->data['keywords'] = $keywords;
     $this->data['where'] = $where;
     $tb_user_group = new IModel('user_group');
     $data_group = $tb_user_group->query();
     $data_group = is_array($data_group) ? $data_group : array();
     $group = array();
     foreach ($data_group as $value) {
         $group[$value['id']] = $value['group_name'];
     }
     $this->data['group'] = $group;
     $this->setRenderData($this->data);
     $this->redirect('recycling');
 }
Beispiel #18
0
 /**
  * @brief 获取当前时间段正在使用的广告数据
  * @param $position int 广告位ID
  * @param $goods_cat_id 商品分类ID
  * @return array
  */
 public static function getAdList($position, $goods_cat_id = 0)
 {
     $now = date("Y-m-d H:i:s", ITime::getNow());
     $adDB = new IModel("ad_manage");
     return $adDB->query("position_id={$position} and goods_cat_id = {$goods_cat_id} and start_time < '{$now}' AND end_time > '{$now}' ORDER BY `order` ASC ");
 }
Beispiel #19
0
 /**
  * 导出商品csv
  * */
 function output_csv()
 {
     $id = IReq::get('id');
     $date_format = IReq::get('date_format');
     //淘宝数据
     $tao_arr = array();
     $tao_arr[] = IReq::get('category');
     $tao_arr[] = IReq::get('ems');
     $tao_arr[] = IReq::get('exp');
     $tao_arr[] = IReq::get('post');
     $csvObj = new Csv();
     if ($id) {
         $good_id = explode(',', $id);
         $csvObj->export($date_format, $good_id, $tao_arr);
     } else {
         $arr = array();
         $tb_goods = new IModel('goods');
         $goods_info = $tb_goods->query('', 'id');
         foreach ($goods_info as $value) {
             $arr[] = $value['id'];
         }
         $csvObj->export($date_format, $arr, $tao_arr);
     }
     exit;
 }
Beispiel #20
0
 public function conver($expressConfig, $order_id, $seller_id = 0)
 {
     $resultArray = array();
     //函数返回数据
     $wholeData = array();
     //实际的数据
     //获取订单信息
     $id = intval($order_id);
     $orderObj = new IModel('order');
     $orderRow = $orderObj->getObj('id = ' . $id . ' and seller_id = ' . $seller_id);
     if (empty($orderRow)) {
         return null;
     }
     //获取发货地址信息
     $shipInfoObj = new IModel('merch_ship_info');
     $shipList = $shipInfoObj->query('is_del = 1 and seller_id = ' . $seller_id, '*', 'is_default', 'desc', '1');
     if (empty($shipList)) {
         $shipRow = array('ship_user_name' => '', 'address' => '', 'telphone' => '', 'mobile' => '', 'postcode' => '', 'province' => '', 'city' => '', 'area' => '');
     } else {
         $shipRow = $shipList[0];
     }
     //获取订单总重量和总数量
     $orderGoodsObj = new IModel('order_goods');
     $orderTotal = $orderGoodsObj->getObj('order_id = ' . $id, 'SUM(goods_nums) as num_total,SUM(goods_weight * goods_nums) as weight_total');
     /*拼接实际数据 $wholeData*/
     //查询area地域数据
     $areaData = area::name($orderRow['province'], $orderRow['city'], $orderRow['area'], $shipRow['province'], $shipRow['city'], $shipRow['area']);
     //获取site_config配置信息
     $site_config = new Config('site_config');
     $site_config = $site_config->getInfo();
     $wholeData['ship_name'] = $orderRow['accept_name'];
     $wholeData['ship_area_0'] = isset($areaData[$orderRow['province']]) ? $areaData[$orderRow['province']] : '';
     $wholeData['ship_area_1'] = isset($areaData[$orderRow['city']]) ? $areaData[$orderRow['city']] : '';
     $wholeData['ship_area_2'] = isset($areaData[$orderRow['area']]) ? $areaData[$orderRow['area']] : '';
     $wholeData['ship_addr'] = $orderRow['address'];
     $wholeData['ship_tel'] = $orderRow['telphone'];
     $wholeData['ship_mobile'] = $orderRow['mobile'];
     $wholeData['ship_zip'] = $orderRow['postcode'];
     $wholeData['ship_detail_addr'] = $wholeData['ship_area_0'] . $wholeData['ship_area_1'] . $wholeData['ship_area_2'] . $orderRow['address'];
     $wholeData['dly_name'] = $shipRow['ship_user_name'];
     $wholeData['dly_area_0'] = isset($areaData[$shipRow['province']]) ? $areaData[$shipRow['province']] : '';
     $wholeData['dly_area_1'] = isset($areaData[$shipRow['city']]) ? $areaData[$shipRow['city']] : '';
     $wholeData['dly_area_2'] = isset($areaData[$shipRow['area']]) ? $areaData[$shipRow['area']] : '';
     $wholeData['dly_address'] = $shipRow['address'];
     $wholeData['dly_tel'] = $shipRow['telphone'];
     $wholeData['dly_mobile'] = $shipRow['mobile'];
     $wholeData['dly_zip'] = $shipRow['postcode'];
     $wholeData['date_y'] = date('Y');
     $wholeData['date_m'] = date('m');
     $wholeData['date_d'] = date('d');
     $wholeData['order_id'] = $orderRow['order_no'];
     $wholeData['order_price'] = $orderRow['order_amount'];
     $wholeData['order_weight'] = isset($orderTotal['weight_total']) ? $orderTotal['weight_total'] : '';
     $wholeData['order_count'] = isset($orderTotal['num_total']) ? $orderTotal['num_total'] : '';
     $wholeData['order_memo'] = $orderRow['note'];
     $wholeData['ship_time'] = $orderRow['accept_time'];
     $wholeData['shop_name'] = isset($site_config['name']) ? $site_config['name'] : '';
     $wholeData['tick'] = '√';
     //进行数据替换
     foreach ($expressConfig as $key => $val) {
         $item_tmp = JSON::decode($val);
         $item_tmp['typeText'] = isset($wholeData[$item_tmp['typeId']]) ? $wholeData[$item_tmp['typeId']] : '';
         $resultArray[] = JSON::encode($item_tmp);
     }
     return $resultArray;
 }
Beispiel #21
0
 public function getOrderInfo($order)
 {
     $orderObj = new IModel('order');
     $areaIdArray = array();
     $orderList = $orderObj->query('id in (' . $order . ')');
     foreach ($orderList as $val) {
         $areaIdArray[] = $val['province'];
         $areaIdArray[] = $val['city'];
         $areaIdArray[] = $val['area'];
     }
     $areaIdArray = array_unique($areaIdArray);
     $areaObj = new IModel('areas');
     $areaList = $areaObj->query('area_id in (' . join(",", $areaIdArray) . ')');
     $areaData = array();
     foreach ($areaList as $val) {
         $areaData[$val['area_id']] = $val['area_name'];
     }
     foreach ($orderList as $key => $val) {
         $orderList[$key]['province_str'] = $areaData[$val['province']];
         $orderList[$key]['city_str'] = $areaData[$val['city']];
         $orderList[$key]['area_str'] = $areaData[$val['area']];
     }
     return $orderList;
 }
Beispiel #22
0
 static function getCategroy($category_id)
 {
     $sub_category = '';
     if ($category_id) {
         $tb_category = new IModel('category');
         $category_info = $tb_category->query('parent_id=' . $category_id);
         if (count($category_info) > 0) {
             foreach ($category_info as $value) {
                 $sub_category .= $value['id'] . ',';
                 $sub_category .= self::getCategroy($value['id']);
             }
         }
     }
     return $sub_category;
 }
Beispiel #23
0
 function role_edit_act()
 {
     $id = IFilter::act(IReq::get('id', 'post'));
     $roleObj = new IModel('admin_role');
     //要入库的数据
     $dataArray = array('id' => $id, 'name' => IFilter::string(IReq::get('name', 'post')), 'rights' => null);
     //检查权限码是否为空
     $rights = IFilter::act(IReq::get('right', 'post'));
     if (empty($rights) || $rights[0] == '') {
         $this->roleRow = $dataArray;
         $this->redirect('role_edit', false);
         Util::showMessage('请选择要分配的权限');
     }
     //拼接权限码
     $rightsArray = array();
     $rightObj = new IModel('right');
     $rightList = $rightObj->query('id in (' . join(",", $rights) . ')', '`right`');
     foreach ($rightList as $key => $val) {
         $rightsArray[] = trim($val['right'], ',');
     }
     $dataArray['rights'] = empty($rightsArray) ? '' : ',' . join(',', $rightsArray) . ',';
     $roleObj->setData($dataArray);
     if ($id) {
         $where = 'id = ' . $id;
         $roleObj->update($where);
     } else {
         $roleObj->add();
     }
     $this->redirect('role_list');
 }
Beispiel #24
0
 public function goodsCommend()
 {
     //商品字符串的逗号间隔
     $id = IFilter::act(IReq::get('id'));
     if ($id) {
         $idArray = explode(",", $id);
         $idArray = IFilter::act($idArray, 'int');
         $id = join(',', $idArray);
     }
     $goodsDB = new IModel('goods');
     $goodsData = $goodsDB->query("id in (" . $id . ")", "id,name");
     $goodsCommendDB = new IModel('commend_goods');
     foreach ($goodsData as $key => $val) {
         $goodsCommendData = $goodsCommendDB->query("goods_id = " . $val['id']);
         foreach ($goodsCommendData as $k => $v) {
             $goodsData[$key]['commend'][$v['commend_id']] = 1;
         }
     }
     die(JSON::encode($goodsData));
 }
Beispiel #25
0
 function article_edit()
 {
     $data = array();
     $id = IFilter::act(IReq::get('id'), 'int');
     if ($id) {
         $id = intval($id);
         //获取文章信息
         $articleObj = new IModel('article');
         $where = 'id = ' . $id;
         $data = $articleObj->getObj($where);
         if ($data) {
             //获取文章关联商品ID值
             $relationObj = new IModel('relation');
             $where = 'article_id = ' . $id;
             $relationGoods = $relationObj->query($where);
             $this->relationStr = null;
             foreach ($relationGoods as $rs) {
                 if ($this->relationStr != '') {
                     $this->relationStr .= ',';
                 }
                 $this->relationStr .= $rs['goods_id'];
             }
             //根据商品ID获取商品信息
             if ($this->relationStr != null) {
                 $goodsObj = new IModel('goods');
                 $where = 'id in (' . $this->relationStr . ')';
                 $this->goodsList = $goodsObj->query($where, 'img,name');
             }
             $this->articleRow = $data;
             $this->redirect('article_edit', false);
         }
     }
     if (count($data) == 0) {
         $this->redirect('article_edit');
     }
 }
Beispiel #26
0
 /**
  * @brief 计算商品价格
  * @param Array $buyInfo ,购物车格式
  * @return array or bool
  */
 public function goodsCount($buyInfo)
 {
     $this->sum = 0;
     //原始总额(优惠前)
     $this->final_sum = 0;
     //应付总额(优惠后)
     $this->weight = 0;
     //总重量
     $this->reduce = 0;
     //减少总额
     $this->count = 0;
     //总数量
     $this->promotion = array();
     //促销活动规则文本
     $this->proReduce = 0;
     //促销活动规则优惠额
     $this->point = 0;
     //增加积分
     $this->exp = 0;
     //增加经验
     $this->isFreeFreight = false;
     //是否免运费
     $user_id = $this->user_id;
     $group_id = $this->group_id;
     $goodsList = array();
     $productList = array();
     /*开始计算goods和product的优惠信息 , 会根据条件分析出执行以下哪一种情况:
      *(1)查看此商品(货品)是否已经根据不同会员组设定了优惠价格;
      *(2)当前用户是否属于某个用户组中的成员,并且此用户组享受折扣率;
      *(3)优惠价等于商品(货品)原价;
      */
     //获取商品或货品数据
     /*Goods 拼装商品优惠价的数据*/
     if (isset($buyInfo['goods']['id']) && $buyInfo['goods']['id']) {
         //购物车中的商品数据
         $goodsIdStr = join(',', $buyInfo['goods']['id']);
         $goodsObj = new IModel('goods as go');
         $goodsList = $goodsObj->query('go.id in (' . $goodsIdStr . ')', 'go.name,go.id as goods_id,go.img,go.sell_price,go.point,go.weight,go.store_nums,go.exp,go.goods_no,0 as product_id');
         //开始优惠情况判断
         foreach ($goodsList as $key => $val) {
             //检查库存
             if ($buyInfo['goods']['data'][$val['goods_id']]['count'] <= 0 || $buyInfo['goods']['data'][$val['goods_id']]['count'] > $val['store_nums']) {
                 return "商品:" . $val['name'] . "购买数量超出库存,请重新调整购买数量";
             }
             $groupPrice = $this->getGroupPrice($val['goods_id'], 'goods');
             $goodsList[$key]['reduce'] = $groupPrice === null ? 0 : $val['sell_price'] - $groupPrice;
             $goodsList[$key]['count'] = $buyInfo['goods']['data'][$val['goods_id']]['count'];
             $current_sum_all = $goodsList[$key]['sell_price'] * $goodsList[$key]['count'];
             $current_reduce_all = $goodsList[$key]['reduce'] * $goodsList[$key]['count'];
             $goodsList[$key]['sum'] = $current_sum_all - $current_reduce_all;
             //全局统计
             $this->weight += $val['weight'] * $goodsList[$key]['count'];
             $this->point += $val['point'] * $goodsList[$key]['count'];
             $this->exp += $val['exp'] * $goodsList[$key]['count'];
             $this->sum += $current_sum_all;
             $this->reduce += $current_reduce_all;
             $this->count += $goodsList[$key]['count'];
         }
     }
     /*Product 拼装商品优惠价的数据*/
     if (isset($buyInfo['product']['id']) && $buyInfo['product']['id']) {
         //购物车中的货品数据
         $productIdStr = join(',', $buyInfo['product']['id']);
         $productObj = new IQuery('products as pro,goods as go');
         $productObj->where = 'pro.id in (' . $productIdStr . ') and go.id = pro.goods_id';
         $productObj->fields = 'pro.sell_price,pro.weight,pro.id as product_id,pro.spec_array,pro.goods_id,pro.store_nums,pro.products_no as goods_no,go.name,go.point,go.exp,go.img';
         $productList = $productObj->find();
         //开始优惠情况判断
         foreach ($productList as $key => $val) {
             //检查库存
             if ($buyInfo['product']['data'][$val['product_id']]['count'] <= 0 || $buyInfo['product']['data'][$val['product_id']]['count'] > $val['store_nums']) {
                 return "货品:" . $val['name'] . "购买数量超出库存,请重新调整购买数量";
             }
             $groupPrice = $this->getGroupPrice($val['product_id'], 'product');
             $productList[$key]['reduce'] = $groupPrice === null ? 0 : $val['sell_price'] - $groupPrice;
             $productList[$key]['count'] = $buyInfo['product']['data'][$val['product_id']]['count'];
             $current_sum_all = $productList[$key]['sell_price'] * $productList[$key]['count'];
             $current_reduce_all = $productList[$key]['reduce'] * $productList[$key]['count'];
             $productList[$key]['sum'] = $current_sum_all - $current_reduce_all;
             //全局统计
             $this->weight += $val['weight'] * $productList[$key]['count'];
             $this->point += $val['point'] * $productList[$key]['count'];
             $this->exp += $val['exp'] * $productList[$key]['count'];
             $this->sum += $current_sum_all;
             $this->reduce += $current_reduce_all;
             $this->count += $productList[$key]['count'];
         }
     }
     $final_sum = $this->sum - $this->reduce;
     //总金额满足的促销规则
     if ($user_id) {
         $proObj = new ProRule($final_sum);
         $proObj->setUserGroup($group_id);
         $this->isFreeFreight = $proObj->isFreeFreight();
         $this->promotion = $proObj->getInfo();
         $this->proReduce = $final_sum - $proObj->getSum();
     } else {
         $this->promotion = array();
         $this->proReduce = 0;
     }
     $this->final_sum = $final_sum - $this->proReduce;
     return array('final_sum' => $this->final_sum, 'promotion' => $this->promotion, 'proReduce' => $this->proReduce, 'sum' => $this->sum, 'goodsList' => array_merge($goodsList, $productList), 'count' => $this->count, 'reduce' => $this->reduce, 'weight' => $this->weight, 'freeFreight' => $this->isFreeFreight, 'point' => $this->point, 'exp' => $this->exp);
 }
Beispiel #27
0
 /**
  * @brief 根据模型编号  获取模型详细信息
  *
  * @param int $model_id 模型编号
  *
  * @return array 数组格式 	Array ( [id] => '',[name] => '', [model_attr] => Array ( ),[model_spec] => Array ( ))
  */
 public function get_model_info($model_id)
 {
     $model_id = intval($model_id);
     //初始化model商品模型表类对象
     $modelObj = new IModel('model');
     //根据模型编号  获取商品模型详细信息
     $model_info = $modelObj->getObj('id = ' . $model_id);
     if ($model_info) {
         //反序列化 商品模型规格数据
         $model_info['model_spec'] = array();
         if ($model_info['spec_ids']) {
             $specDB = new IModel('spec');
             $model_info['model_spec'] = $specDB->query("id in (" . $model_info['spec_ids'] . ")");
         }
         //初始化attribute商品模型属性表类对象
         $attributeObj = new IModel('attribute');
         //根据商品模型编号 获取商品模型扩展属性
         $model_attr = $attributeObj->query("model_id = " . $model_id);
         $model_info['model_attr'] = $model_attr;
     }
     return $model_info;
 }
Beispiel #28
0
<?php

$goods_class = new goods_class();
$tb_category = new IModel('category');
$category = $goods_class->sortdata($tb_category->query(false, '*', 'sort', 'asc'), 0, '--');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理后台</title>
<link rel="stylesheet" href="<?php 
echo IUrl::creatUrl("") . "views/" . $this->theme . "/skin/" . $this->skin . "/css/admin.css";
?>
" />
<script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/jquery/jquery-1.11.3.min.js"></script><script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/jquery/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/artdialog/artDialog.js"></script><script type="text/javascript" charset="UTF-8" src="<?php 
echo BASE_URL;
?>
/runtime/_systemjs/artdialog/plugins/iframeTools.js"></script><link rel="stylesheet" type="text/css" href="<?php 
echo BASE_URL;
?>
Beispiel #29
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;
 }
Beispiel #30
0
 public function goods_share()
 {
     $idArray = explode(',', IReq::get('id'));
     $id = IFilter::act($idArray, 'int');
     $goodsDB = new IModel('goods');
     $goodsData = $goodsDB->query('id in (' . join(',', $id) . ')');
     foreach ($goodsData as $key => $val) {
         $is_share = $val['is_share'] == 1 ? 0 : 1;
         $goodsDB->setData(array('is_share' => $is_share));
         $goodsDB->update('id = ' . $val['id'] . ' and seller_id = 0');
     }
 }