Test.php 4.3 KB

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