123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\api\logic;
-
- use app\common\basics\Logic;
- use app\common\enum\LiveRoomEnum;
- use app\common\model\live\LiveRoom;
- use app\common\server\UrlServer;
-
-
-
- class LiveLogic extends Logic
- {
-
-
-
- public static function lists($page_no, $page_size)
- {
- $count = LiveRoom::where(['del' => 0])->count();
- $lists = LiveRoom::with(['shop'])->where(['del' => 0])
- ->where('wx_room_id', '>', 0)
- ->order(['live_status' => 'asc', 'sort' => 'asc', 'id' => 'desc'])
- ->hidden(['share_img_id', 'feeds_img_id', 'cover_img_id'])
- ->select();
-
- foreach ($lists as &$item) {
- $item['share_img'] = UrlServer::getFileUrl($item['share_img']);
- $item['feeds_img'] = UrlServer::getFileUrl($item['feeds_img']);
- $item['cover_img'] = UrlServer::getFileUrl($item['cover_img']);
- $item['live_status_text'] = LiveRoomEnum::getLiveStatusDesc($item['live_status']);
- $item['start_time_tips'] = friend_date($item['start_time']);
- $item['start_time_text'] = date('y-m-d H:i', $item['start_time']);
- $item['end_time_text'] = date('y-m-d H:i', $item['end_time']);
- }
-
- return [
- 'list' => $lists,
- 'count' => $count,
- 'more' => is_more($count, $page_no, $page_size),
- 'page_no' => $page_no,
- 'page_size' => $page_size
- ];
- }
-
-
-
-
- public static function shopLive($shopId)
- {
- $room = LiveRoom::with(['shop'])->where([
- 'shop_id' => $shopId,
- 'live_status' => LiveRoomEnum::LIVE_STATUS_ING,
- 'del' => 0
- ])
- ->where('wx_room_id', '>', 0)
- ->order(['sort' => 'asc', 'id' => 'desc'])
- ->hidden(['share_img_id', 'feeds_img_id', 'cover_img_id'])
- ->findOrEmpty()
- ->toArray();
-
- if (empty($room)) {
-
- $room = LiveRoom::with(['shop'])->where([
- 'shop_id' => $shopId,
- 'live_status' => LiveRoomEnum::LIVE_STATUS_WAIT,
- 'del' => 0
- ])
- ->where('wx_room_id', '>', 0)
- ->where('start_time', '>', time())
- ->order(['sort' => 'asc', 'id' => 'desc', 'start_time' => 'asc'])
- ->hidden(['share_img_id', 'feeds_img_id', 'cover_img_id'])
- ->findOrEmpty()
- ->toArray();
- }
-
- if (!empty($room)) {
- $room['share_img'] = UrlServer::getFileUrl($room['share_img']);
- $room['feeds_img'] = UrlServer::getFileUrl($room['feeds_img']);
- $room['cover_img'] = UrlServer::getFileUrl($room['cover_img']);
- $room['live_status_text'] = LiveRoomEnum::getLiveStatusDesc($room['live_status']);
- $room['start_time_tips'] = friend_date($room['start_time']);
- $room['start_time_text'] = date('y-m-d H:i', $room['start_time']);
- $room['end_time_text'] = date('y-m-d H:i', $room['end_time']);
- }
- return $room;
- }
-
-
- }
|