You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

108 lines
2.9 KiB

  1. <?php
  2. namespace backend\modules\hotel\controllers;
  3. use Yii;
  4. use yii\filters\AccessControl;
  5. /**
  6. * Default controller for the `Hotel` module
  7. */
  8. class DefaultController extends HotelController
  9. {
  10. public $layout = "@backend/modules/hotel/views/layouts/main";
  11. public function behaviors()
  12. {
  13. return [
  14. 'access' => [
  15. 'class' => AccessControl::className(),
  16. 'rules' => [
  17. [
  18. 'actions' => ['index', 'clear-memcache'],
  19. 'allow' => true,
  20. 'roles' => ['@'],
  21. ],
  22. ],
  23. ]
  24. ];
  25. }
  26. /**
  27. * Renders the index view for the module
  28. * @return string
  29. */
  30. public function actionIndex()
  31. {
  32. return $this->render('index');
  33. }
  34. /**
  35. * User: wangxj
  36. *
  37. * CS服务器memcache关于酒店 的memcache删除
  38. *
  39. * @param string $key
  40. * @return string
  41. */
  42. public function actionClearMemcache($key = 'hotel_newOrder')
  43. {
  44. $this->layout = "@backend/modules/hotel/views/layouts/iframe";
  45. $cache = Yii::$app->cacheCS;
  46. $cache->encrypt = false;
  47. $newOrder = $cache->get($key);
  48. if (Yii::$app->request->isPost && $_POST['order_id']) {
  49. if ($newOrder && count($newOrder) > 0) {
  50. foreach ($newOrder as &$hotels) {
  51. if (count($hotels) > 0) {
  52. foreach ($hotels as $index => &$order) {
  53. if ($order['order_id'] == $_POST['order_id']) {
  54. unset($hotels[$index]);
  55. $cache->set($key, $newOrder);
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }
  62. if(isset($_POST['hotel_id']) && $_POST['hotel_id'] != '') {
  63. $hotels = explode(',', $_POST['hotel_id']);
  64. foreach ($hotels as $hotel) {
  65. unset($newOrder[$hotel]);
  66. $cache->set($key, $newOrder);
  67. }
  68. }
  69. return $this->render('memcache', ['data' => $newOrder]);
  70. }
  71. /**
  72. * User: wangxj
  73. *
  74. * 订单缓存检查 ::todo
  75. *
  76. */
  77. public function actionHotelMemcacheCheck()
  78. {
  79. $this->layout = "@backend/modules/hotel/views/layouts/iframe";
  80. $cache = Yii::$app->cache;
  81. $cache->encrypt = false;
  82. $newOrder = $cache->get('hotel_newOrder');
  83. if ($newOrder && count($newOrder) > 0) {
  84. foreach ($newOrder as &$hotels) {
  85. if (count($hotels) > 0) {
  86. foreach ($hotels as $index => &$order) {
  87. if ($order['order_id'] == $_POST['order_id']) {
  88. unset($hotels[$index]);
  89. // $cache->set($key, $newOrder);
  90. }
  91. }
  92. }
  93. }
  94. }
  95. }
  96. }