TestCommand.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace App\Console\Test;
  3. use App\Cache\StatisticCache;
  4. use App\Cache\UserCache;
  5. use App\Facade\Site;
  6. use App\Jobs\ReportDy;
  7. use App\Libs\Utils;
  8. use App\Models\User\User;
  9. use App\Models\User\UserEarningsLogs;
  10. use App\Services\OpenApi\OpenService;
  11. use App\Services\Pay\PayService;
  12. use Illuminate\Console\Command;
  13. use Illuminate\Support\Facades\DB;
  14. use Illuminate\Support\Facades\Redis;
  15. use Vinkla\Hashids\Facades\Hashids;
  16. /**
  17. * 测试
  18. */
  19. class TestCommand extends Command
  20. {
  21. /**
  22. * @var string
  23. */
  24. protected $signature = 'test {--token=} {--uid=} {--eid=}';
  25. /**
  26. * The console command description.
  27. * php artisan Payment:BasePayment --bid='1'
  28. *
  29. * @var string
  30. */
  31. protected $description = '测试';
  32. private $openService;
  33. private $payService;
  34. public function __construct(
  35. OpenService $openService,
  36. PayService $payService
  37. )
  38. {
  39. parent::__construct();
  40. $this->openService = $openService;
  41. $this->payService = $payService;
  42. }
  43. /**
  44. * handle
  45. */
  46. public function handle()
  47. {
  48. // $result = $this->payService->reportPay(18, date('YmdHis').getMillisecond().rand(1000,9999));
  49. // dd($result);
  50. //
  51. // dd('exit');
  52. $token = $this->option('token');
  53. $uid = $this->option('uid');
  54. $eid = $this->option('eid');
  55. if ($eid) dd(Hashids::decode($eid));
  56. if (!$token) $token = '67ecfebf74424f52472cec71769c339f';
  57. if (!$uid) $uid = 18;
  58. // $instance = $this->openService->getInstance();
  59. // $res = $instance->generateShareLink('app/home', json_encode(['promotion_code'=>100001, 'invite_code'=>100023]));
  60. // $res = $instance->getShareQueryInfo('https://z.douyin.com/6sJ3LOR');
  61. // dd($res);
  62. // $path = urlencode('pages/index/index?invite_code=100055');
  63. // $res = $instance->createQRCode('pages/index/index');
  64. // 写入测试用户token
  65. UserCache::setTokenData($token, ['uid'=>$uid, 'distribution_channel_id'=>1, 'send_order_id'=>0, 'from_uid'=>0]);
  66. // 写入测试用户最近阅读记录
  67. UserCache::delRecentBooks($uid);
  68. $bids = [1,5,6,4,29,59,47,68,53,86,87,58,100,37];
  69. foreach ($bids as $bid) {
  70. $book_info = DB::table('books')->where('id', $bid)->select('name', 'cover')->first();
  71. $random_sequence = mt_rand(1,20);
  72. $chapter = DB::table('chapters')->where(['bid'=>$bid, 'is_check'=>1, 'is_deleted'=>0, 'sequence'=>$random_sequence])
  73. ->select('id', 'name')->first();
  74. UserCache::setRecentBooks($uid, [
  75. 'bid' => $bid,
  76. 'book_name' => getProp($book_info, 'name'),
  77. 'cover' => getProp($book_info, 'cover'),
  78. 'cid' => getProp($chapter, 'id'),
  79. 'chapter_name' => getProp($chapter, 'name'),
  80. 'read_time' => date('Y-m-d H:i:s', time()+mt_rand(0,1800)),
  81. 'sequence' => $random_sequence,
  82. 'gender' => 2
  83. ]);
  84. }
  85. // 写入测试用户当前阅读书籍和章节
  86. UserCache::delCurrentChapter($uid);
  87. UserCache::setCurrentChapter($uid, [
  88. 'bid' => 94,
  89. 'book_name' => '闪婚后,晏先生被甜妻撩上瘾',
  90. 'cover' => 'http://zwcontent.oss-cn-hangzhou.aliyuncs.com/books/cover/ed5Ntjzi3W.jpg',
  91. 'cid' => 100000970,
  92. 'chapter_name' => '第152章 吃瓜',
  93. 'read_time' => date('Y-m-d H:i:s', time()+1800),
  94. 'sequence' => 152,
  95. 'gender' => 2,
  96. ]);
  97. }
  98. }