|
- <?php
-
- namespace backend\modules\hotel\controllers;
-
- use Yii;
- use yii\filters\AccessControl;
-
- /**
- * Default controller for the `Hotel` module
- */
- class DefaultController extends HotelController
- {
- public $layout = "@backend/modules/hotel/views/layouts/main";
- public function behaviors()
- {
- return [
- 'access' => [
- 'class' => AccessControl::className(),
- 'rules' => [
- [
- 'actions' => ['index', 'clear-memcache'],
- 'allow' => true,
- 'roles' => ['@'],
- ],
- ],
- ]
- ];
- }
- /**
- * Renders the index view for the module
- * @return string
- */
- public function actionIndex()
- {
- return $this->render('index');
- }
-
- /**
- * User: wangxj
- *
- * CS服务器memcache关于酒店 的memcache删除
- *
- * @param string $key
- * @return string
- */
- public function actionClearMemcache($key = 'hotel_newOrder')
- {
- $this->layout = "@backend/modules/hotel/views/layouts/iframe";
- $cache = Yii::$app->cacheCS;
- $cache->encrypt = false;
- $newOrder = $cache->get($key);
-
- if (Yii::$app->request->isPost && $_POST['order_id']) {
- if ($newOrder && count($newOrder) > 0) {
- foreach ($newOrder as &$hotels) {
- if (count($hotels) > 0) {
- foreach ($hotels as $index => &$order) {
- if ($order['order_id'] == $_POST['order_id']) {
- unset($hotels[$index]);
- $cache->set($key, $newOrder);
- }
- }
-
- }
- }
- }
- }
-
- if(isset($_POST['hotel_id']) && $_POST['hotel_id'] != '') {
- $hotels = explode(',', $_POST['hotel_id']);
- foreach ($hotels as $hotel) {
- unset($newOrder[$hotel]);
- $cache->set($key, $newOrder);
- }
- }
-
- return $this->render('memcache', ['data' => $newOrder]);
- }
-
- /**
- * User: wangxj
- *
- * 订单缓存检查 ::todo
- *
- */
- public function actionHotelMemcacheCheck()
- {
- $this->layout = "@backend/modules/hotel/views/layouts/iframe";
- $cache = Yii::$app->cache;
- $cache->encrypt = false;
- $newOrder = $cache->get('hotel_newOrder');
-
- if ($newOrder && count($newOrder) > 0) {
- foreach ($newOrder as &$hotels) {
- if (count($hotels) > 0) {
- foreach ($hotels as $index => &$order) {
- if ($order['order_id'] == $_POST['order_id']) {
- unset($hotels[$index]);
- // $cache->set($key, $newOrder);
- }
- }
-
- }
- }
- }
- }
- }
|