function get($search = null, $value = null, $exact = false)
 {
     if ($search != null) {
         $this->stores->search($search, $value, $exact);
         $res = $this->stores->get();
     } else {
         $res = null;
     }
     if ($res != null) {
         foreach ($res as $item) {
             $store = new StoreData($item);
             $this->franchisers->search("id", $store->get('franchiser_id'), true);
             $this->pos->search("store_id", $store->get('id'), true);
             $f = $this->franchisers->get();
             $fobj = new FranchiserData($f[0]);
             $pobj = new POSData($this->pos->get(), $store->get("store_id"));
             $store->add_Franchiser($fobj);
             $store->add_POS($pobj);
             $out[] = $store;
         }
     } else {
         //Setup empty store
         $s = new StoreData();
         $s->add_Franchiser(new FranchiserData());
         $s->add_POS(new POSData());
         $out[] = $s;
     }
     return $out;
 }
 public function indexAction()
 {
     $cid = intval($this->param('cid', 0));
     if (!$cid) {
         $url = ComTool::url("index");
         ComTool::redirect($url);
     }
     $category = CategoryData::getById($cid);
     if (!$category) {
         $url = ComTool::url("index");
         ComTool::redirect($url);
     }
     $curTime = time();
     $category['start_time'] = '09:00:00';
     $category['end_time'] = '24:00:00';
     $startTime = strtotime($category['start_time']);
     $endTime = strtotime($category['end_time']);
     $notStart = $curTime < $startTime ? true : false;
     //true为尚未开始
     $isOver = $curTime > $endTime ? true : false;
     //true为已结束
     $isOn = !$notStart && !$isOver;
     //过程中
     $this->assign('notStart', $notStart);
     $this->assign('isOver', $isOver);
     $this->assign('isOn', $isOn);
     $group = GroupData::getById($category['group_id']);
     $store = StoreData::getById($category['store_id']);
     $goods = GoodsData::getsByCid($cid);
     $cart = array();
     $cart = $this->getCart($cid);
     $this->assign('category', $category);
     $this->assign('group', $group);
     $this->assign('store', $store);
     $this->assign('goods', $goods);
     $this->assign('products', $cart['products']);
     $this->assign('totalPrice', $cart['totalPrice']);
     $this->display();
 }
 /**
  * 购物车
  */
 public function cartAction()
 {
     $gid = intval($this->param('g', 0));
     if (!$gid) {
         exit('empty g');
     }
     $cid = intval($this->param('c', 0));
     if (!$cid) {
         exit('empty c');
     }
     $category = CategoryData::getById($cid);
     if ($category['group_id'] != $gid) {
         exit('该圈子无此分类');
     }
     $cart = array();
     $cart = $this->getCart($cid);
     $group = GroupData::getById($category['group_id']);
     $currUser = $currUserGroup = array();
     $isLogin = $this->isLogin();
     if ($isLogin) {
         $currUser = $this->getCurrentUser();
         $userGroups = UserGroupData::getGroupsByUid($currUser['id']);
         foreach ($userGroups as $userGroup) {
             if ($group['id'] == $userGroup['group_id']) {
                 $currUserGroup = $userGroup;
                 break;
             }
         }
     }
     $store = StoreData::getById($category['store_id']);
     $this->assign('group', $group);
     $this->assign('store', $store);
     $this->assign('currUser', $currUser);
     $this->assign('currUserGroup', $currUserGroup);
     $this->assign('category', $category);
     $this->assign('products', $cart['products']);
     $this->assign('totalPrice', $cart['totalPrice']);
     $this->display();
 }
 /**
  * 添加分类
  */
 public function cateAction()
 {
     if (ComTool::isAjax()) {
         $group = $this->post('group');
         $store = $this->post('store');
         $level = $this->post('level');
         $parent = $this->post('parent');
         $name = $this->post('name');
         $ename = $this->post('ename');
         $desc = $this->post('desc');
         $limit = $this->post('limit');
         $days = $this->post('day');
         $start = $this->post('start');
         $end = $this->post('end');
         $orderway = $this->post('orderway');
         $status = $this->post('status');
         $deliver_desc = $this->post('deliver_desc');
         $data = array();
         $data['group_id'] = $group;
         $data['store_id'] = $store;
         $data['level'] = $level;
         $data['pid'] = $parent;
         $data['name'] = $name;
         $data['ename'] = $ename;
         $data['desc'] = $desc;
         $data['create_time'] = time();
         $data['update_time'] = time();
         $data['time_limit'] = $limit;
         $data['days'] = $days;
         $data['start_time'] = $start;
         $data['end_time'] = $end;
         $data['order_way'] = $orderway;
         $data['status'] = $status;
         $data['deliver_desc'] = $deliver_desc;
         $res = CategoryData::add($data);
         ComTool::result($res, '失败', '成功');
     }
     $parentCats = CategoryData::getParents();
     $allCats = CategoryData::getsAll();
     $groups = GroupData::getsAll();
     $stores = StoreData::getsAll();
     $this->assign('parentCats', $parentCats);
     $this->assign('allCats', $allCats);
     $this->assign('groups', $groups);
     $this->assign('stores', $stores);
     $this->display();
 }