LiveRoomLists.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\shopapi\lists;
  20. use app\common\enum\LiveEnum;
  21. use app\common\service\WeChatService;
  22. /**
  23. * 直播间列表
  24. * Class LiveRoomLists
  25. * @package app\shopapi\lists
  26. */
  27. class LiveRoomLists extends BaseShopDataLists
  28. {
  29. public function lists(): array
  30. {
  31. $result = WeChatService::getLiveRoom($this->limitOffset, $this->limitLength);
  32. if (!is_array($result)) {
  33. return [];
  34. }
  35. $data = [];
  36. foreach ($result['room_info'] as $item) {
  37. $data[] = [
  38. 'name' => $item['name'],
  39. 'room_id' => $item['roomid'],
  40. 'cover_img' => $item['cover_img'],
  41. 'anchor_name' => $item['anchor_name'],
  42. 'status' => $item['live_status'],
  43. 'live_status' => LiveEnum::getLiveStatus($item['live_status']),
  44. 'goods' => count($item['goods']),
  45. 'start_time' => date('Y-m-d H:i:s', $item['start_time']),
  46. 'end_time' => date('Y-m-d H:i:s', $item['end_time'])
  47. ];
  48. }
  49. $this->total = $result['total'];
  50. return $data;
  51. }
  52. public function count(): int
  53. {
  54. return $this->total;
  55. }
  56. }