/** * 列表 */ public function lists($status = null) { $model = new GoodsModel(); $map = array(); $status_view = array('default' => '所有', 'del' => '已删除', 'forbid' => '禁用', 'allow' => '正常'); //查询条件 处理 $map['store_id'] = STID; $store_M = new Model('Store'); $store_info = $store_M->find(STID); if (empty($store_info)) { $this->error('店铺不存在'); } $this->assign('store_info', $store_info); //店铺信息 if (isset($status) && key_exists($status, GoodsModel::$mystat)) { //指定查询状态 $map['status'] = GoodsModel::$mystat[$status]; $now_status = $status_view[$status]; } else { $map['status'] = array('EGT', 0); //默认查询状态为未删除的数据 $now_status = $status_view['default']; } /******************/ $list = $this->_lists($model, $map); $this->assign('list', $list); //列表 $this->assign('now_status', $now_status); //当前页面筛选的状态 if (!empty($list)) { $cate_M = new Model('Category'); $cate_ids = field_unique($list, 'cate_id'); //列表中用到的会员ID $map = array('id' => array('in', $cate_ids)); $catelist = $cate_M->where($map)->getField('id,cate_name'); $this->assign('catelist', $catelist); //列表用到的分类, ID为key索引 } /*****用于添加商品的商品分类树**/ $catetreemap = array('store_id' => STID, 'status' => '1'); //只要状态正常商品分类 $cate_M = new CategoryModel(); $cate_tree = $cate_M->ztreeArr($catetreemap); $cate_tree = array_merge(array(array('id' => 0, 'pId' => 0, 'name' => '无分类', 'open' => true)), $cate_tree); $cate_tree = json_encode($cate_tree); $this->assign('tree_json', $cate_tree); //category ztree json // 记录当前列表页的cookie cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']); $this->display(); }
/** * 指定店铺 的 商品列表 * @param number $sid 所属店铺ID * @param string $status 状态string */ public function lists($sid, $status = null) { $model = new GoodsModel(); $map = array(); $status_view = array('default' => '所有', 'del' => '已删除', 'forbid' => '禁用', 'allow' => '正常'); //查询条件 处理 $map['store_id'] = (int) $sid; if ($map['store_id'] <= 0) { $this->error('参数非法'); } $store_M = new Model('Store'); $store_info = $store_M->find($map['store_id']); if (empty($store_info)) { $this->error('店铺不存在'); } $this->assign('store_info', $store_info); //店铺信息 if (isset($status) && key_exists($status, GoodsModel::$mystat)) { //指定查询状态 $map['status'] = GoodsModel::$mystat[$status]; $now_status = $status_view[$status]; } else { $map['status'] = array('EGT', 0); //默认查询状态为未删除的数据 $now_status = $status_view['default']; } /******************/ $list = $this->_lists($model, $map); $this->assign('list', $list); //列表 $this->assign('now_status', $now_status); //当前页面筛选的状态 if (!empty($list)) { $cate_M = new Model('Category'); $cate_ids = field_unique($list, 'cate_id'); //列表中用到的会员ID $map = array('id' => array('in', $cate_ids)); $catelist = $cate_M->where($map)->getField('id,cate_name'); $this->assign('catelist', $catelist); //列表用到的分类, ID为key索引 } // 记录当前列表页的cookie cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']); $this->display(); }
/** * 订单查看页面 */ public function read($id) { $map['id'] = (int) $id; if ($map['id'] <= 0) { $this->error('请选择要查看的订单'); } $model = new OrderModel(); if (false === $model->checkAuth($map['id'])) { $this->error('没有权限'); } $info = $model->where($map)->find(); $this->assign('info', $info); //订单信息 $pay_M = new Model('Payment'); $pay_info = $pay_M->find($info['payment_id']); $this->assign('pay_info', $pay_info); //支付方式信息 $og_M = new Model('OrderGoods'); $ordergoods = $og_M->where('order_id=' . $id)->select(); $this->assign('ordergoods', $ordergoods); //订单商品列表 if (!empty($ordergoods)) { $goods_M = new Model('goods'); $goods_ids = field_unique($ordergoods, 'goods_id'); $map = array('id' => array('in', $goods_ids)); $goodslist = $goods_M->where($map)->getField('id,goods_name,image'); $this->assign('goodslist', $goodslist); //列表用到的, ID为key索引 } cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']); $this->display(); }
/** * select()数据中, 返回 某些字段的所有数据 * @param array $list * @param string/array $filed */ function field_unique($list, $filed) { $arr = array(); if (!empty($list)) { if (is_array($filed)) { foreach ($filed as $k => $v) { $arr[$k] = field_unique($list, $v); } } else { $filedarr = explode(",", $filed); foreach ($list as $row) { foreach ($filedarr as $k => $v) { $arr[] = $row[$v]; } } $arr = array_unique($arr); } } return $arr; }
/** * 订单筛选列表 * 存在 主键id 或 sn 则忽略其他查询条件 * @param number $cfm confirm 客户收货确认 0-否 1-是(订单完结) * @param number $unr unreceived 用户未收货申请1-是,0-否;必须在收货截止时间内才能申请 * @param number $ship ship_status 配送状态 0-未开始 1-配送中 */ public function order($cfm = null, $unr = null, $ship = null) { if (!MID) { $this->redirect('Index/index'); } $map = array(); $map['member_id'] = MID; $map['status'] = 1; //状态正常的订单 if (isset($cfm) && in_array($cfm, \Manage\Model\OrderModel::$S_confirm)) { $map['confirm'] = $cfm; } if (isset($unr) && in_array($unr, \Manage\Model\OrderModel::$S_unreceived)) { $map['unreceived'] = $unr; } if (isset($ship) && in_array($ship, \Manage\Model\OrderModel::$S_ship_status)) { $map['ship_status'] = $ship; } /*************/ //筛选状态 if ($map['ship_status'] === '0') { $condition = '1'; } else { if ($map['confirm'] === '0') { $condition = '2'; } else { $condition = '0'; } } $this->assign('condition', $condition); //筛选状态 /**************/ $model = new Model('Order'); $list = $model->where($map)->order("add_time DESC")->select(); $this->assign('list', $list); //列表 if (!empty($list)) { $store_M = new Model('Store'); $store_ids = field_unique($list, 'store_id'); $map = array('id' => array('in', $store_ids)); $storelist = $store_M->where($map)->getField('id,store_name'); $this->assign('storelist', $storelist); //列表用到的店铺, ID为key索引 } // 记录当前列表页的cookie cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']); $this->display(); }
/** * 查看订单内商品列表 * @param int $id 订单id */ public function readGoods($id) { $id = (int) $id; if ($id <= 0) { $this->error('请先选择订单'); } $og_M = new Model('OrderGoods'); $list = $og_M->where('order_id=' . $id)->select(); $this->assign('list', $list); $store_M = new Model('Store'); $store_info = $store_M->find($id); $this->assign('store_info', $store_info); if (!empty($list)) { $goods_M = new Model('goods'); $goods_ids = field_unique($list, 'goods_id'); $map = array('id' => array('in', $goods_ids)); $goodslist = $goods_M->where($map)->getField('id,goods_name'); $this->assign('goodslist', $goodslist); //列表用到的, ID为key索引 } cookie(C('CURRENT_URL_NAME'), $_SERVER['REQUEST_URI']); $this->display(); }