admin
2021-09-24 f788607ff771a47bc60d6a86e00b3433c40f3d2c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package com.yeshi.buwan.controller.api;
 
import com.google.gson.*;
import com.yeshi.buwan.domain.live.*;
import com.yeshi.buwan.domain.user.LoginUser;
import com.yeshi.buwan.domain.vip.*;
import com.yeshi.buwan.dto.order.PPTVVideoPrice;
import com.yeshi.buwan.dto.order.PayWayInfoDTO;
import com.yeshi.buwan.exception.PPTVException;
import com.yeshi.buwan.exception.goldcorn.GoldCornException;
import com.yeshi.buwan.exception.order.OrderException;
import com.yeshi.buwan.exception.order.PayException;
import com.yeshi.buwan.exception.vip.VIPException;
import com.yeshi.buwan.exception.vip.VideoBuyRecordException;
import com.yeshi.buwan.live.migu.MiGuLiveListInfo;
import com.yeshi.buwan.live.migu.MiguLiveApiUtil;
import com.yeshi.buwan.service.inter.LoginUserService;
import com.yeshi.buwan.service.inter.juhe.PPTVService;
import com.yeshi.buwan.service.inter.live.*;
import com.yeshi.buwan.service.inter.order.OrderService;
import com.yeshi.buwan.service.inter.system.SystemConfigService;
import com.yeshi.buwan.service.inter.vip.VIPPriceService;
import com.yeshi.buwan.service.inter.vip.VIPService;
import com.yeshi.buwan.util.*;
import com.yeshi.buwan.videos.pptv.entity.PPTVSeries;
import com.yeshi.buwan.videos.pptv.entity.VideoPPTVMap;
import com.yeshi.buwan.vo.AcceptData;
import com.yeshi.buwan.vo.client.user.UserInfoVO;
import com.yeshi.buwan.vo.order.OrderInfoVO;
import com.yeshi.buwan.vo.tvlive.TVLiveChannelVO;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.yeshi.utils.annotation.RequestSerializableByKey;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * 电视直播
 */
@Controller
@RequestMapping("api/v2/tvlive")
public class TVLiveController {
 
    Logger logger = LoggerFactory.getLogger(TVLiveController.class);
 
 
    @Resource
    private TVLiveCategoryService tvLiveCategoryService;
 
    @Resource
    private TVLiveCategoryChannelService tvLiveCategoryChannelService;
 
    @Resource
    private TVLiveChannelResourceService tvLiveChannelResourceService;
 
    @Resource
    private MiGuLiveService miGuLiveService;
 
 
    @RequestMapping("getCategory")
    @ResponseBody
    public String getCategory(AcceptData acceptData) {
        Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
        List<SuperTVLiveCategory> superList = tvLiveCategoryService.listSuper(acceptData.getDetailSystem().getId(), 1, 20);
        List<String> channelIds = new ArrayList<>();
        for (SuperTVLiveCategory category : superList) {
            channelIds.add(category.getCid());
        }
        List<TVLiveCategory> categoryList = tvLiveCategoryService.listByIds(channelIds);
        JSONObject data = new JSONObject();
        data.put("count", categoryList.size());
        data.put("data", gson.toJson(categoryList));
        return JsonUtilV2.loadTrueJson(data.toString());
    }
 
 
    @RequestMapping("getChannelList")
    @ResponseBody
    public String getChannelList(AcceptData acceptData, String cid, int page) {
 
        if (StringUtil.isNullOrEmpty(cid)) {
            return JsonUtilV2.loadFalseJson("cid为空");
        }
 
        List<TVLiveChannel> channelList = tvLiveCategoryChannelService.listChannelByCid(cid, null, page, Constant.pageCount);
        long count = tvLiveCategoryChannelService.countChannelByCid(cid, null);
 
        List<TVLiveChannelVO> voList = new ArrayList<>();
        for (TVLiveChannel channel : channelList) {
            voList.add(TVLiveChannelVO.create(channel));
        }
        JSONObject root = new JSONObject();
        root.put("list", new Gson().toJson(voList));
        root.put("count", count);
        return JsonUtilV2.loadTrueJson(root.toString());
    }
 
    @RequestMapping("getPlayUrl")
    @ResponseBody
    public String getPlayUrl(AcceptData acceptData, String id) {
 
        if (StringUtil.isNullOrEmpty(id)) {
            return JsonUtilV2.loadFalseJson("id为空");
        }
 
        //获取播放链接
 
        List<TVLiveChannelResourceMap> mapList = tvLiveChannelResourceService.listByChannelId(id);
        if (mapList == null || mapList.size() == 0) {
            return JsonUtilV2.loadFalseJson("暂无播放源");
        }
 
        TVLiveChannelResourceMap map = mapList.get(0);
        String playUrl = null;
        if (map.getResource() == TVLiveResource.migu) {
            MiGuLiveListInfo info = miGuLiveService.selectByPrimaryKey(map.getRid());
            playUrl = MiguLiveApiUtil.getPlayUrl(info.getPID());
        } else if (map.getResource() == TVLiveResource.other) {
            playUrl = map.getPlayUrl();
        }
        JSONObject root = new JSONObject();
        root.put("playUrl", playUrl);
        return JsonUtilV2.loadTrueJson(root.toString());
    }
 
 
}