Test.php 4.3 KB

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