public function actionIndex() { $shop_id = Yii::app()->request->getParam('shop_id'); if (!$shop_id) { Error::output(Error::ERR_NO_SHOPID); } //查询出改商店的一些详细信息 $shopData = Shops::model()->findByPk($shop_id); if (!$shopData) { Error::output(Error::ERR_NO_SHOPID); } $shopData = CJSON::decode(CJSON::encode($shopData)); //根据店铺id查询出该店铺的菜单 $menuData = Menus::model()->with('food_sort', 'image', 'shops')->findAll(array('condition' => 't.shop_id=:shop_id AND t.status=:status', 'params' => array(':shop_id' => $shop_id, ':status' => 2))); $data = array(); foreach ($menuData as $k => $v) { $data[$k] = $v->attributes; $data[$k]['index_pic'] = $v->index_pic ? Yii::app()->params['img_url'] . $v->image->filepath . $v->image->filename : ''; $data[$k]['sort_name'] = $v->food_sort->name; $data[$k]['shop_name'] = $v->shops->name; $data[$k]['create_time'] = Yii::app()->format->formatDate($v->create_time); $data[$k]['status'] = Yii::app()->params['menu_status'][$v->status]; $data[$k]['price'] = $v->price; } Out::jsonOutput(array('shop' => $shopData, 'menus' => $data)); }
public function actionIndex() { //获取商家信息 $model = Shops::model()->with('image')->findAll('t.status=:status', array(':status' => 2)); $shopData = array(); foreach ($model as $k => $v) { $shopData[$k] = $v->attributes; $shopData[$k]['logo'] = $shopData[$k]['logo'] ? Yii::app()->params['img_url'] . $v->image->filepath . $v->image->filename : ''; } Out::jsonOutput(array('shops' => $shopData, 'isOnTime' => Yii::app()->check_time->isOnTime())); }
public function isShopOnTime($shop_id) { $shopData = Shops::model()->findByPk($shop_id); if (!$shopData) { Error::output(Error::ERR_NO_SHOPID); } $shopData = CJSON::decode(CJSON::encode($shopData)); $dataStr = date('Y-m-d', time()); $startTime = strtotime($dataStr . ' ' . $shopData['starttime']); $endTime = strtotime($dataStr . ' ' . $shopData['endtime']); if ($startTime <= time() && $endTime >= time()) { return true; } else { return false; } return false; }
public function run() { if (!Yii::app()->user->isGuest) { $im = Yii::app()->request->getPost('im'); $imbox = Yii::app()->request->getPost('imbox'); $inbase = Shops::model()->findByAttributes(array($imbox => $im), 'real_admin=' . Yii::app()->user->id); $shop = new Shops(); if (!$inbase) { throw new CHttpException(404, 'Ошибка.'); return true; } $rootPath = Yii::app()->getBasePath() . '/..'; $fullpath = $rootPath . '/uploads/shops/' . $inbase->id . '/photos/' . $im; if (file_exists($fullpath)) { $image = new Image($fullpath); $image->crop(Yii::app()->request->getPost('w'), Yii::app()->request->getPost('h'), Yii::app()->request->getPost('y'), Yii::app()->request->getPost('x')); $image->save(); MCleaner::cleanTempImg($im, 'shop'); $inbase->getUrl('220x114', 'resize', false, $im); echo Yii::app()->request->getPost('imbox'); } } }
public function actionLookMenu() { $shop_id = Yii::app()->request->getParam('shop_id'); if (!isset($shop_id)) { throw new CHttpException(404, Yii::t('yii', '请选择就餐类别')); } $resident_flag = Yii::app()->request->getParam('resident_flag'); if (isset($resident_flag)) { throw new CHttpException(404, Yii::t('yii', '常驻员工每天每餐仅每次仅允许订购一份!!')); } //查询出改商店的一些详细信息 $shopData = Shops::model()->findByPk($shop_id); if (!$shopData) { throw new CHttpException(404, Yii::t('yii', '您选择的餐类不存在!')); } $shopData = CJSON::decode(CJSON::encode($shopData)); //判断改商家有没有下市场 if (intval($shopData['status']) != 2) { throw new CHttpException(404, Yii::t('yii', '您选择的餐类已经下市!')); } //根据订单历史纪录查询当天是否已经存在同样的中餐、晚餐订单记录 //店铺->中餐、晚餐 //菜单->地点 //LCF $member_id = Yii::app()->user->member_userinfo['id']; $criteria = new CDbCriteria(); $today = strtotime(date('Y-m-d')); $criteria->order = 't.create_time DESC'; $criteria->select = '*'; $criteria->condition = 'food_user_id=:food_user_id AND shop_id = :shop_id AND create_time > :create_time AND status < :status'; $criteria->params = array(':food_user_id' => $member_id, ':shop_id' => $shop_id, ':create_time' => $today, ':status' => 3); //查询结果 $todayOrderCount = FoodOrder::model()->count($criteria); $memberInfo = Members::model()->find('id=:id', array(':id' => Yii::app()->user->member_userinfo['id'])); if ($memberInfo->resident == 1 && $todayOrderCount >= 1) { throw new CHttpException(404, Yii::t('yii', '你今天已经订过该餐了!!常驻员工每天每餐仅每次仅允许订购一份!!')); } //根据店铺id查询出该店铺的菜单 $menuData = Menus::model()->with('food_sort', 'image', 'shops')->findAll(array('condition' => 't.shop_id=:shop_id AND t.status=:status', 'params' => array(':shop_id' => $shop_id, ':status' => 2))); $data = array(); foreach ($menuData as $k => $v) { $data[$k] = $v->attributes; $data[$k]['index_pic'] = $v->index_pic ? Yii::app()->params['img_url'] . $v->image->filepath . $v->image->filename : ''; $data[$k]['sort_name'] = $v->food_sort->name; $data[$k]['shop_name'] = $v->shops->name; $data[$k]['create_time'] = Yii::app()->format->formatDate($v->create_time); $data[$k]['status'] = Yii::app()->params['menu_status'][$v->status]; $data[$k]['price'] = $v->price; } //获取该店的留言 $criteria = new CDbCriteria(); $criteria->order = 't.order_id DESC'; $criteria->condition = 't.shop_id=:shop_id AND t.status=:status'; $criteria->params = array(':shop_id' => $shop_id, ':status' => 1); $count = Message::model()->count($criteria); //构建分页 $pages = new CPagination($count); $pages->pageSize = Yii::app()->params['pagesize']; $pages->applyLimit($criteria); $messageMode = Message::model()->with('members', 'shops', 'replys')->findAll($criteria); $message = array(); foreach ($messageMode as $k => $v) { $message[$k] = $v->attributes; $message[$k]['shop_name'] = $v->shops->name; $message[$k]['user_name'] = $v->members->name; $message[$k]['create_time'] = date('Y-m-d H:i:s', $v->create_time); $message[$k]['status_text'] = Yii::app()->params['message_status'][$v->status]; $message[$k]['status_color'] = Yii::app()->params['status_color'][$v->status]; $_replys = Reply::model()->with('members')->findAll(array('condition' => 'message_id=:message_id', 'params' => array(':message_id' => $v->id))); if (!empty($_replys)) { foreach ($_replys as $kk => $vv) { $message[$k]['replys'][$kk] = $vv->attributes; $message[$k]['replys'][$kk]['create_time'] = date('Y-m-d H:i:s', $vv->create_time); $message[$k]['replys'][$kk]['user_name'] = $vv->user_id == -1 ? '行政MM说' : $vv->members->name; } } } $this->render('lookmenu', array('menus' => $data, 'shop' => $shopData, 'pages' => $pages, 'message' => $message)); }
public function loadModel($id) { $model = Shops::model()->with('image')->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionIndex() { //创建查询条件 $menuname = Yii::app()->request->getParam('k'); $shopId = Yii::app()->request->getParam('shop_id'); $criteria = new CDbCriteria(); $criteria->order = 't.order_id DESC'; if ($menuname) { $criteria->compare('t.name', $menuname, true); } if ($shopId) { $criteria->compare('t.shop_id', $shopId); } $count = Menus::model()->count($criteria); //构建分页 $pages = new CPagination($count); $pages->pageSize = Yii::app()->params['pagesize']; $pages->applyLimit($criteria); $model = Menus::model()->with('food_sort', 'image', 'shops')->findAll($criteria); $data = array(); foreach ($model as $k => $v) { $data[$k] = $v->attributes; $data[$k]['index_pic'] = $v->index_pic ? Yii::app()->params['img_url'] . $v->image->filepath . $v->image->filename : ''; $data[$k]['sort_name'] = $v->food_sort->name; $data[$k]['shop_name'] = $v->shops->name; $data[$k]['create_time'] = Yii::app()->format->formatDate($v->create_time); $data[$k]['status_text'] = Yii::app()->params['menu_status'][$v->status]; $data[$k]['status_color'] = Yii::app()->params['status_color'][$v->status]; $data[$k]['price'] = $v->price . ' Ks/份'; } //取出所有店家供前端选择 $shops = Shops::model()->findAll(); $shops = CJSON::decode(CJSON::encode($shops)); //输出到前端 $this->render('index', array('data' => $data, 'shops' => $shops, 'pages' => $pages)); }
/** * Get active/applied filters to make easier to cancel them. */ public function getActiveFilters($rootcat='goods') { // Render links to cancel applied filters like prices, manufacturers, attributes. $menuItems = array(); $url = explode(';', Yii::app()->request->getQuery('url')); $criteria=new CDbCriteria; $criteria->addInCondition('t.url', $url); $criteria->order = 't.name'; $categ = Categories::model()->findAll($criteria); $manufacturers = array_filter(explode(';', Yii::app()->request->getQuery('brand'))); $manufacturers = Brands::model()->findAllByPk($manufacturers); $accounts = array_filter(explode(';', Yii::app()->request->getQuery('account'))); $accounts = User::model()->findAllByPk($accounts); $shops = array_filter(explode(';', Yii::app()->request->getQuery('shop'))); $shops = Shops::model()->findAllByPk($shops); if(!empty($categ)) { foreach($categ as $category) { if($category->url != 'goods' && $category->url != 'services' && $category->url != 'all'){ array_push($menuItems, array( 'mode'=>'category', 'label'=> $category->name, 'url' => Yii::app()->request->removeUrlParamCat($rootcat, $category->url), 'titlecat'=>$category->url )); } } } if(!empty($manufacturers)) { foreach($manufacturers as $manufacturer) { array_push($menuItems, array( 'mode'=>'brand', 'label'=> $manufacturer->title, 'url' => Yii::app()->request->removeUrlParam('/store/catalog/view', 'brand', $manufacturer->id) )); } } // Process eav attributes $activeAttributes = $this->getOwner()->activeAttributes; if(!empty($activeAttributes)) { foreach($activeAttributes as $attributeName=>$value) { if(isset($this->getOwner()->eavAttributes[$attributeName])) { $attribute = $this->getOwner()->eavAttributes[$attributeName]; foreach($attribute->options as $option) { if(isset($activeAttributes[$attribute->name]) && in_array($option->id, $activeAttributes[$attribute->name])) { array_push($menuItems, array( 'mode'=>'attributes', 'submode'=>$attribute->name, 'label'=> $option->value, 'url' => Yii::app()->request->removeUrlParam('/store/catalog/view', $attribute->name, $option->id) )); } } } } } if(Yii::app()->request->getQuery('min_price')) { array_push($menuItems, array( 'mode'=>'minprice', 'label'=> Yii::t('StoreModule.core', 'от {minPrice} {c}', array('{minPrice}'=>(int)$this->getCurrentMinPrice(), '{c}'=>Yii::app()->currency->active->symbol)), 'url' => Yii::app()->request->removeUrlParam('/store/catalog/view', 'min_price') )); } if(Yii::app()->request->getQuery('max_price')) { array_push($menuItems, array( 'mode'=>'maxprice', 'label'=> Yii::t('StoreModule.core', 'до {maxPrice} {c}', array('{maxPrice}'=>(int)$this->getCurrentMaxPrice(), '{c}'=>Yii::app()->currency->active->symbol)), 'url' => Yii::app()->request->removeUrlParam('/store/catalog/view', 'max_price') )); } if(!empty($accounts)) { foreach($accounts as $account) { array_push($menuItems, array( 'mode'=>'account', 'label'=> $account->username, 'url' => Yii::app()->request->removeUrlParam('/store/catalog/view', 'account', $account->id) )); } } if(!empty($shops)) { foreach($shops as $shop) { array_push($menuItems, array( 'mode'=>'shop', 'label'=> $shop->title, 'url' => Yii::app()->request->removeUrlParam('/store/catalog/view', 'shop', $shop->id) )); } } return $menuItems; }
public function actionLookMenu() { $shop_id = Yii::app()->request->getParam('shop_id'); if (!isset($shop_id)) { throw new CHttpException(404, Yii::t('yii', '请选择一家餐厅')); } //查询出改商店的一些详细信息 $shopData = Shops::model()->findByPk($shop_id); if (!$shopData) { throw new CHttpException(404, Yii::t('yii', '您选择的这家餐厅不存在')); } $shopData = CJSON::decode(CJSON::encode($shopData)); //判断改商家有没有下市场 if (intval($shopData['status']) != 2) { throw new CHttpException(404, Yii::t('yii', '您选择的这家餐厅不存在或者已经倒闭了!')); } //根据店铺id查询出该店铺的菜单 $menuData = Menus::model()->with('food_sort', 'image', 'shops')->findAll(array('condition' => 't.shop_id=:shop_id AND t.status=:status', 'params' => array(':shop_id' => $shop_id, ':status' => 2))); $data = array(); foreach ($menuData as $k => $v) { $data[$k] = $v->attributes; $data[$k]['index_pic'] = $v->index_pic ? Yii::app()->params['img_url'] . $v->image->filepath . $v->image->filename : ''; $data[$k]['sort_name'] = $v->food_sort->name; $data[$k]['shop_name'] = $v->shops->name; $data[$k]['create_time'] = Yii::app()->format->formatDate($v->create_time); $data[$k]['status'] = Yii::app()->params['menu_status'][$v->status]; $data[$k]['price'] = $v->price; } //获取该店的留言 $criteria = new CDbCriteria(); $criteria->order = 't.order_id DESC'; $criteria->condition = 't.shop_id=:shop_id AND t.status=:status'; $criteria->params = array(':shop_id' => $shop_id, ':status' => 1); $count = Message::model()->count($criteria); //构建分页 $pages = new CPagination($count); $pages->pageSize = Yii::app()->params['pagesize']; $pages->applyLimit($criteria); $messageMode = Message::model()->with('members', 'shops', 'replys')->findAll($criteria); $message = array(); foreach ($messageMode as $k => $v) { $message[$k] = $v->attributes; $message[$k]['shop_name'] = $v->shops->name; $message[$k]['user_name'] = $v->members->name; $message[$k]['create_time'] = date('Y-m-d H:i:s', $v->create_time); $message[$k]['status_text'] = Yii::app()->params['message_status'][$v->status]; $message[$k]['status_color'] = Yii::app()->params['status_color'][$v->status]; $_replys = Reply::model()->with('members')->findAll(array('condition' => 'message_id=:message_id', 'params' => array(':message_id' => $v->id))); if (!empty($_replys)) { foreach ($_replys as $kk => $vv) { $message[$k]['replys'][$kk] = $vv->attributes; $message[$k]['replys'][$kk]['create_time'] = date('Y-m-d H:i:s', $vv->create_time); $message[$k]['replys'][$kk]['user_name'] = $vv->user_id == -1 ? '前台妹子说' : $vv->members->name; } } } $this->render('lookmenu', array('menus' => $data, 'shop' => $shopData, 'pages' => $pages, 'message' => $message)); }