Test.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace app\admin\controller;
  3. use crmeb\services\async\LuckyCalc;
  4. use crmeb\services\async\ClearanceCalc;
  5. use crmeb\utils\Redis;
  6. use think\facade\Log;
  7. use app\api\controller\board\UserBoardController;
  8. use app\models\redis\SystemCarousel;
  9. use crmeb\services\async\LuckyExtACalc;
  10. use crmeb\services\async\LuckyExtBCalc;
  11. use crmeb\services\async\task\WechatNotify;
  12. use think\facade\Config;
  13. use RobThree\Auth\TwoFactorAuth;
  14. use RobThree\Auth\TwoFactorAuthException;
  15. class Test
  16. {
  17. public function index()
  18. {
  19. $redis = Redis::instance();
  20. var_dump($redis->get(['CRMEB','TESD']));
  21. }
  22. protected function test_board() {
  23. Log::warning("board updated.");
  24. $ctl = new UserBoardController();
  25. $ctl->cache_board();
  26. }
  27. protected function test_calc() {
  28. $activities = [new ClearanceCalc(), new LuckyCalc(), new LuckyExtACalc(), new LuckyExtBCalc()];
  29. foreach($activities as $activity) {
  30. $activity->calc();
  31. }
  32. }
  33. protected function test_carousel() {
  34. SystemCarousel::add('good test', '/pages/leader_board/index');
  35. print_r(SystemCarousel::getFirst(20));
  36. SystemCarousel::removeTrash();
  37. }
  38. protected function test_wechat_robot() {
  39. $key = Config::get('app.qy_weixin_robot_aristotle');
  40. // $svc = \crmeb\services\QyWeixinService::instance();
  41. // $svc->key($key)->markdown("### user commented\n>hhhh\n1. upm youth\n2. shiny tommorowwww")->post();
  42. WechatNotify::push(WechatNotify::TYPE_COMMENT, $key, 'gdf');
  43. }
  44. protected function test_2fa()
  45. {
  46. $tfa = new TwoFactorAuth('twong');
  47. $secret = $tfa->createSecret();
  48. echo 'secret:' . $secret;
  49. $img = $tfa->getQRCodeImageAsDataUri('twongqr', $secret);
  50. echo 'img:' . $img;
  51. echo '<img src="'.$img .'" />';
  52. echo 'chunk:' . chunk_split($secret, 4, ' ');
  53. $code = $tfa->getCode($secret);
  54. echo 'code:' . $code;
  55. echo 'result:' . $tfa->verifyCode($secret, $code);
  56. }
  57. public function test()
  58. {
  59. // $this->test_calc();
  60. }
  61. }