Test.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 app\models\system\SystemPool;
  10. use app\models\user\UserSearch;
  11. use app\models\user\WechatUser;
  12. use crmeb\services\async\LuckyExtACalc;
  13. use crmeb\services\async\LuckyExtBCalc;
  14. use crmeb\services\async\task\AsyncClass;
  15. use crmeb\services\async\task\WechatNotify;
  16. use think\facade\Config;
  17. use RobThree\Auth\TwoFactorAuth;
  18. use RobThree\Auth\TwoFactorAuthException;
  19. use tw\redis\UserRds;
  20. class Test
  21. {
  22. public function index()
  23. {
  24. $redis = Redis::instance();
  25. var_dump($redis->get(['CRMEB','TESD']));
  26. }
  27. protected function test_board() {
  28. Log::warning("board updated.");
  29. $ctl = new UserBoardController();
  30. $ctl->cache_board();
  31. }
  32. protected function test_calc() {
  33. $activities = [new ClearanceCalc(), new LuckyCalc(), new LuckyExtACalc(), new LuckyExtBCalc()];
  34. foreach($activities as $activity) {
  35. $activity->calc();
  36. }
  37. }
  38. protected function test_carousel() {
  39. SystemCarousel::add('good test', '/pages/leader_board/index');
  40. print_r(SystemCarousel::getFirst(20));
  41. SystemCarousel::removeTrash();
  42. }
  43. protected function test_wechat_robot() {
  44. $key = Config::get('app.qy_weixin_robot_aristotle');
  45. // $svc = \crmeb\services\QyWeixinService::instance();
  46. // $svc->key($key)->markdown("### user commented\n>hhhh\n1. upm youth\n2. shiny tommorowwww")->post();
  47. WechatNotify::push(WechatNotify::TYPE_COMMENT, $key, 'gdf');
  48. }
  49. protected function test_2fa()
  50. {
  51. $tfa = new TwoFactorAuth('twong');
  52. $secret = $tfa->createSecret();
  53. echo 'secret:' . $secret;
  54. $img = $tfa->getQRCodeImageAsDataUri('twongqr', $secret);
  55. echo 'img:' . $img;
  56. echo '<img src="'.$img .'" />';
  57. echo 'chunk:' . chunk_split($secret, 4, ' ');
  58. $code = $tfa->getCode($secret);
  59. echo 'code:' . $code;
  60. echo 'result:' . $tfa->verifyCode($secret, $code);
  61. }
  62. protected function test_routine_reg()
  63. {
  64. $routine['nickName'] = '山河另';
  65. $routine['gender']=1;
  66. $routine['language'] = 'zncn';
  67. $routine['city']='zd';//
  68. $routine['province']='hn';
  69. $routine['country']='cn';//
  70. $routine['avatarUrl']='http://x';
  71. $routine['openId']='great';//
  72. $routine['session_key']='bbc';
  73. $routine['unionId']='';//用户在开放平台的唯一标识符
  74. $routine['spid'] = 3;
  75. $routine['code'] = '5';
  76. $routine['session_key'] = 'bi';
  77. $routine['login_type'] = 'routine';
  78. echo WechatUser::routineOauth($routine);
  79. }
  80. protected function test_async_func()
  81. {
  82. AsyncClass::push('\app\admin\controller\Test', [], 'gd', []);
  83. }
  84. protected function test_redis()
  85. {
  86. $ur = new UserRds();
  87. $ur->set(1, 'streak', 3);
  88. echo $ur->get(1, 'streak');
  89. echo $ur->get(1, 'notexists');
  90. $ur->sets(1, ['name'=>'didi', 'age'=>28]);
  91. print_r($ur->gets(1, ['name', 'age']));
  92. print_r($ur->gets(1, ['friends', 'teacher']));
  93. print_r($ur->getAll(1));
  94. }
  95. public function test()
  96. {
  97. // $this->test_redis();
  98. // echo UserSearch::InsertHistory(1, "good");
  99. // print_r(UserSearch::getList(1, 20));
  100. // return $this->test_routine_reg();
  101. // echo SystemPool::incrby(1000, 1, 'clr', 2000);
  102. // print_r(SystemPool::getList(1, 20));
  103. }
  104. }