Example #1
0
 public function actionIndex()
 {
     $shop_id = Yii::app()->request->getParam('shop_id');
     if (!$shop_id) {
         Error::output(Error::ERR_NO_SHOPID);
     }
     //获取该店的留言
     $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);
     $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;
             }
         }
     }
     Out::jsonOutput($message);
 }
Example #2
0
 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));
 }
Example #3
0
 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;
 }
Example #4
0
 public function beforeControllerAction($controller, $action)
 {
     if (parent::beforeControllerAction($controller, $action)) {
         //如果需要登陆就检测用户是否登陆
         if (defined('NEED_LOGIN') && NEED_LOGIN) {
             //检测
             $accessToken = Yii::app()->request->getParam('access_token');
             if (!$accessToken) {
                 Error::output(Error::ERR_NO_LOGIN);
             } else {
                 //检测token有没有过期
                 $userLogin = UserLogin::model()->find("token = :token AND login_time + " . Yii::app()->params['login_expire_time'] . " > " . time(), array(':token' => $accessToken));
                 if ($userLogin) {
                     //根据用户id查询用户信息
                     $memberInfo = Members::model()->find('id = :id', array(':id' => $userLogin->user_id));
                     if (!$memberInfo) {
                         Error::output(Error::ERR_NO_LOGIN);
                     }
                     //转换成数组
                     $memberInfo = CJSON::decode(CJSON::encode($memberInfo));
                     //把用户信息存放到user里面供访问
                     unset($memberInfo['password'], $memberInfo['salt']);
                     //如果存在头像,就返回
                     if ($memberInfo['avatar']) {
                         //取图片数据
                         $material = Material::model()->findByPk($memberInfo['avatar']);
                         $memberInfo['avatar'] = array('host' => Yii::app()->params['img_url'], 'filepath' => $material->filepath, 'filename' => $material->filename);
                     }
                     $this->_user = $memberInfo;
                 } else {
                     Error::output(Error::ERR_NO_LOGIN);
                 }
             }
         }
         return true;
     } else {
         return false;
     }
 }
Example #5
0
}
//function get_photo($pid, $cid) {
//
//	$photo = new Photo($pid);
//	$data = $photo->get(100, 100);
//
//	return array(
//		'id' => $pid,
//		'title' => $photo->_dbo->photo_title,
//		'description' => $photo->_dbo->photo_description,
//		'url' => url('view') . "&amp;pid=$pid&amp;cid=$cid",
//		'thumb_img' => $data[7],
//		'thumb' => $data[0],
//		'user_id' => $photo->_dbo->user_id,
//		'user_login' => $photo->_user->user_login,
//		'user_url' => url('user', array('uid' => $photo->_dbo->user_id))
//	);
//}
$action = Utils::pg("action", "start");
if ($action == "admin" || strpos($action, 'adm-') === 0) {
    $engine = new Admin($action);
} else {
    $engine = new Phphoto($action);
}
if (!$engine->valid()) {
    $engine = new Error($action, $engine->statusCode());
}
// Page not found. Give up.
$engine->call();
$engine->output($time_start);
Example #6
0
 protected function error($msg)
 {
     $err = new Error();
     $out = $err->output($msg);
     return $out;
 }
Example #7
0
 public function actionModifyAvatar()
 {
     //处理图片
     if ($_FILES['avatar'] && !$_FILES['avatar']['error']) {
         $imgInfo = Yii::app()->material->upload('avatar');
         if ($imgInfo) {
             //更新到用户表里面
             $member = Members::model()->findByPk($this->module->user['id']);
             $member->avatar = $imgInfo['id'];
             if ($member->save()) {
                 Out::jsonOutput(array('return' => 1));
                 //留言成功
             } else {
                 Error::output(Error::ERR_UPLOAD_FAIL);
             }
         } else {
             Error::output(Error::ERR_UPLOAD_FAIL);
         }
     } else {
         Error::output(Error::ERR_NO_SELECT_FILE);
     }
 }
Example #8
0
 public function actionRegister()
 {
     $name = Yii::app()->request->getParam('name');
     $password1 = Yii::app()->request->getParam('password1');
     $password2 = Yii::app()->request->getParam('password2');
     if (!$name) {
         Error::output(Error::ERR_NO_USER_NAME);
     } else {
         if (strlen($name) > 15) {
             Error::output(Error::ERR_USERNAME_TOO_LONG);
         }
     }
     if (!$password1 || !$password2) {
         Error::output(Error::ERR_NO_PASSWORD);
     } else {
         if (strlen($password1) > 15 || strlen($password2) > 15) {
             Error::output(Error::ERR_PASSWORD_TOO_LONG);
         } else {
             if ($password1 !== $password2) {
                 Error::output(Error::ERR_TWO_PASSWORD_NOT_SAME);
             }
         }
     }
     //判断该用户是不是已经存在了
     $_member = Members::model()->find('name=:name', array(':name' => $name));
     if ($_member) {
         Error::output(Error::ERR_USER_HAS_EXISTS);
     }
     //随机长生一个干扰码
     $salt = Common::getGenerateSalt();
     $model = new Members();
     $model->name = $name;
     $model->salt = $salt;
     $model->password = md5($salt . $password1);
     $model->create_time = time();
     $model->update_time = time();
     if ($model->save()) {
         $model->order_id = $model->id;
         $model->save();
         //注册成功返回数据
         $member = CJSON::decode(CJSON::encode($model));
         //返回数据
         Out::jsonOutput($member);
     } else {
         Error::output(Error::ERR_SAVE_FAIL);
     }
 }