Test.php 2.8 KB

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