SyncWechatMaterialStatistics.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace App\Console\Commands\BatchWechatMaterial;
  3. use App\Http\Controllers\Wechat\Statistic\NewsStatisticsController;
  4. use App\Http\Controllers\WechatController;
  5. use App\Modules\User\Services\UserService;
  6. use Illuminate\Console\Command;
  7. use App\Modules\WechatMaterial\Services\WechatMaterialSendMsgService;
  8. use Illuminate\Support\Facades\DB;
  9. use Redis;
  10. /**
  11. * 同步微信素材统计信息
  12. *
  13. */
  14. class SyncWechatMaterialStatistics extends Command
  15. {
  16. /**
  17. * The name and signature of the console command.
  18. *
  19. * @var string
  20. */
  21. protected $signature = 'sync_wechat_material_statistics';
  22. /**
  23. * The console command description.
  24. *
  25. * @var string
  26. */
  27. protected $description = '同步微信素材统计信息';
  28. /**
  29. * Create a new command instance.
  30. *
  31. * @return void
  32. */
  33. public function __construct()
  34. {
  35. parent::__construct();
  36. }
  37. /**
  38. * Execute the console command.
  39. *
  40. * @return mixed
  41. */
  42. public function handle()
  43. {
  44. $this->start();
  45. }
  46. public function start()
  47. {
  48. myLog('SyncWechatMaterialStatistics')->notice('------- 查询群发消息送达数开始');
  49. #region 短网址测试
  50. // $url = $WechatController->app->url;
  51. // $shortUrl = $url->shorten('https://m.ycsd.cn/');
  52. // var_dump($shortUrl);
  53. #endregion
  54. #region 基本框架 为确保公众号数据已完成统计和处理,请于每天上午8点后查询公众号前一天的数据。
  55. // $queryDay = date("Y-m-d",strtotime('-1 day', time()));
  56. // WechatMaterialSendMsgService::updateFirstDayMaterialUV($queryDay);
  57. #endregion
  58. $WechatController = new WechatController('wxdbc486f1b4f6a8c3');
  59. $stats = $WechatController->app->stats;
  60. $r = $stats->articleSummary('2020-07-14', '2020-07-14');
  61. var_dump($r);
  62. var_dump(json_decode($r, true)['list']);
  63. $list = json_decode($r, true)['list'];
  64. foreach ($list as $item) {
  65. if ($item['msgid'] != '') {
  66. var_dump($item['msgid']);
  67. }
  68. }
  69. myLog('SyncWechatMaterialStatistics')->notice('------- 查询群发消息送达数结束');
  70. }
  71. }