BookController.php 978 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace console\controllers;
  3. use common\components\noticeUtil;
  4. use yii\console\Controller;
  5. use Yii;
  6. class BookController extends Controller
  7. {
  8. public function actionAssignSeat()
  9. {
  10. ini_set('memory_limit', '2045M');
  11. set_time_limit(0);
  12. $cacheKey = 'assign_seat_main_book_sn_list';
  13. $num = Yii::$app->redis->executeCommand('SCARD', [$cacheKey]);
  14. if ($num <= 0) {
  15. return false;
  16. }
  17. if ($num > 20) {
  18. noticeUtil::push("assign seat all 已经超过20家了,请及时解决", '15280215347');
  19. }
  20. $list = Yii::$app->redis->executeCommand('SMEMBERS', [$cacheKey]);
  21. if (empty($list)) {
  22. return false;
  23. }
  24. foreach ($list as $key => $val) {
  25. //$mainId . '_' . $bookSn
  26. $arr = explode('_', $val);
  27. $mainId = $arr[0];
  28. $bookSn = $arr[1];
  29. echo $mainId . ' ' . $bookSn . "\n";
  30. }
  31. }
  32. }