Commit b7d033acdbfae0848dc028c92995b2fb014985b6

Authored by liwei2917
1 parent ab78fc0f

新增直播申请审核

src/main/java/com/cnlive/shenhe/api/LiveApplyControllerApi.java 0 → 100644
  1 +package com.cnlive.shenhe.api;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONArray;
  5 +import com.alibaba.fastjson.JSONObject;
  6 +import com.cnlive.shenhe.bean.ErrorEnum;
  7 +import com.cnlive.shenhe.bean.ResponseBean;
  8 +import com.cnlive.shenhe.entity.ShyLive;
  9 +import com.cnlive.shenhe.entity.ShyLiveapply;
  10 +import com.cnlive.shenhe.entity.ShyVideos;
  11 +import com.cnlive.shenhe.serviceImpl.LiveApplyServiceImpl;
  12 +import com.cnlive.shenhe.serviceImpl.VideosServiceImpl;
  13 +import com.cnlive.shenhe.utils.AntiFraudUtil;
  14 +import com.cnlive.shenhe.utils.CommonUtils;
  15 +
  16 +import java.sql.Timestamp;
  17 +import java.util.Date;
  18 +import java.util.HashMap;
  19 +import java.util.List;
  20 +import java.util.Map;
  21 +import java.util.UUID;
  22 +
  23 +import org.apache.commons.lang3.StringUtils;
  24 +import org.slf4j.Logger;
  25 +import org.slf4j.LoggerFactory;
  26 +import org.springframework.beans.factory.annotation.Autowired;
  27 +import org.springframework.stereotype.Controller;
  28 +import org.springframework.web.bind.annotation.PostMapping;
  29 +import org.springframework.web.bind.annotation.RequestBody;
  30 +import org.springframework.web.bind.annotation.RequestMapping;
  31 +import org.springframework.web.bind.annotation.RequestMethod;
  32 +import org.springframework.web.bind.annotation.ResponseBody;
  33 +import com.cnlive.shenhe.utils.AntiFraudUtil;
  34 +
  35 +
  36 +@SuppressWarnings("unused")
  37 +@Controller
  38 +@RequestMapping("/api/liveApply")
  39 +public class LiveApplyControllerApi {
  40 + private static Logger logger = LoggerFactory.getLogger(LiveApplyControllerApi.class);
  41 +
  42 + @Autowired
  43 + LiveApplyServiceImpl liveApplyServiceImpl;
  44 +
  45 + @PostMapping("/import")
  46 + @ResponseBody
  47 + public JSONObject impotVideo(String param) {
  48 + JSONObject map = new JSONObject();
  49 + JSONObject result = new JSONObject();
  50 + boolean YorN =true;//初始化一个请求数据库返回结果
  51 +
  52 + logger.info("直播申请入库,param=====" + param);
  53 + JSONObject json = JSONObject.parseObject(param);
  54 + //获取所有参数
  55 + String activityId = json.getString("activityId");//直播活动id
  56 + String channelId = json.getString("channelId");//直播频道id
  57 + Integer spId = Integer.parseInt(json.getString("spId"));//spid
  58 + String sender = json.getString("sender");//直播发起人
  59 + String mobile = json.getString("mobile");//联系方式
  60 + String callback = json.getString("callback");//回调地址
  61 + String organization = json.getString("organization");//直播发起单位
  62 + String theme = json.getString("theme");//直播主题
  63 + String startTime = json.getString("preStartTime");//预计开始时间
  64 + Integer businessModel = Integer.parseInt(json.getString("businessModel"));//商务模式:0免费 1收费
  65 + Integer contentProperty = Integer.parseInt(json.getString("contentProperty"));//内容属性:1商业类活动 0非商业活动
  66 + String simpleContent = json.getString("simpleContent");//内容简述
  67 + String keys = json.getString("keys");//要点报备:0品牌植入 1广告植入 2商品推销 3网家家独家麦标
  68 + String livePlace = json.getString("livePlace");//直播地点
  69 + String pushUrl = json.getString("pushUrl");//推流地址
  70 + String pullUrl = json.getString("pullUrl");//拉流地址
  71 + String platforms = json.getString("platforms");//播出平台及通道:0网家家 1CNLive网站 2@TV互动电视
  72 + Date timestamp_start =null;
  73 + if (CommonUtils.isNotEmpty(startTime)) {
  74 + timestamp_start = new Timestamp(Long.valueOf(startTime));
  75 + }
  76 + String endTime = json.getString("preEndTime");//预计结束时间
  77 + Date timestamp_end =null;
  78 + if (CommonUtils.isNotEmpty(endTime)) {
  79 + timestamp_end = new Timestamp(Long.valueOf(endTime));
  80 + }
  81 +
  82 + ShyLiveapply shyliveApply1 = new ShyLiveapply();
  83 + //得到直播活动id去查询是否已有
  84 + shyliveApply1.setActivity_id(activityId);
  85 + //查询一下 存在,更新 没有,插入
  86 + List<ShyLiveapply> listshyLiveApply = liveApplyServiceImpl.findshyLiveApply(shyliveApply1);
  87 +
  88 + if (listshyLiveApply.size() > 0) {
  89 + ShyLiveapply shyliveApply = listshyLiveApply.get(0);
  90 + //封装数据入库
  91 + shyliveApply.setSp_id(spId);//设置spid
  92 + shyliveApply.setSender(sender);//设置发送者
  93 + shyliveApply.setMobile(mobile);//设置联系方式
  94 + shyliveApply.setOrganization(organization);//设置直播发起单位
  95 + shyliveApply.setTheme(theme);//直播主题
  96 + shyliveApply.setPreStartTime(timestamp_start);//预计开始时间
  97 + shyliveApply.setPreEndTime(timestamp_end);//预计结束时间
  98 + shyliveApply.setBusinessModel(businessModel);//商务模式:0免费 1收费
  99 + shyliveApply.setContentProperty(contentProperty);//内容属性:1商业类活动 0非商业活动
  100 + shyliveApply.setSimpleContent(simpleContent);//内容简述
  101 + shyliveApply.setKeys(keys);//要点报备:0品牌植入 1广告植入 2商品推销 3网家家独家麦标
  102 + shyliveApply.setLivePlace(livePlace);//直播地点
  103 + shyliveApply.setPushUrl(pushUrl);//推流地址
  104 + shyliveApply.setPullUrl(pullUrl);//拉流地址
  105 + shyliveApply.setPlatforms(platforms);//播出平台及通道:0网家家 1CNLive网站 2@TV互动电视
  106 + shyliveApply.setCallback(callback);//设置回调地址
  107 + shyliveApply.setReceive(0);
  108 + shyliveApply.setShenhe_state(0);
  109 + shyliveApply.setUpdater(null);
  110 + shyliveApply.setAuditor(null);
  111 + shyliveApply.setUpdated_at(CommonUtils.getCurrentTime());//更新时间
  112 +
  113 + liveApplyServiceImpl.getShenheType(shyliveApply);//获取审核类型
  114 + YorN = liveApplyServiceImpl.updateshyLiveApply(shyliveApply);
  115 + }else{
  116 + //查了,没有,直接插入数据库
  117 + shyliveApply1.setChannel_id(channelId);//设置频道id
  118 + shyliveApply1.setSp_id(spId);//设置spid
  119 + shyliveApply1.setSender(sender);//设置发送者
  120 + shyliveApply1.setMobile(mobile);//设置联系方式
  121 + shyliveApply1.setOrganization(organization);//设置直播发起单位
  122 + shyliveApply1.setTheme(theme);//直播主题
  123 + shyliveApply1.setPreStartTime(timestamp_start);//预计开始时间
  124 + shyliveApply1.setPreEndTime(timestamp_end);//预计结束时间
  125 + shyliveApply1.setBusinessModel(businessModel);//商务模式:0免费 1收费
  126 + shyliveApply1.setContentProperty(contentProperty);//内容属性:1商业类活动 0非商业活动
  127 + shyliveApply1.setSimpleContent(simpleContent);//内容简述
  128 + shyliveApply1.setKeys(keys);//要点报备:0品牌植入 1广告植入 2商品推销 3网家家独家麦标
  129 + shyliveApply1.setLivePlace(livePlace);//直播地点
  130 + shyliveApply1.setPushUrl(pushUrl);//推流地址
  131 + shyliveApply1.setPullUrl(pullUrl);//拉流地址
  132 + shyliveApply1.setPlatforms(platforms);//播出平台及通道:0网家家 1CNLive网站 2@TV互动电视
  133 + shyliveApply1.setCallback(callback);//设置回调地址
  134 + liveApplyServiceImpl.getShenheType(shyliveApply1);//获取审核类型
  135 + shyliveApply1.setReceive(0);
  136 + shyliveApply1.setShenhe_state(0);
  137 + shyliveApply1.setUpdater(null);
  138 + shyliveApply1.setAuditor(null);
  139 + shyliveApply1.setShenhe_msg(null);
  140 + shyliveApply1.setCreated_at(CommonUtils.getCurrentTime());//创建时间
  141 + shyliveApply1.setUpdated_at(CommonUtils.getCurrentTime());//更新时间
  142 +
  143 + YorN = liveApplyServiceImpl.impotLiveApply(shyliveApply1);
  144 + }
  145 +
  146 + if (YorN == true) {
  147 + result.put("errorCode", "0");
  148 + result.put("errorMessage", "直播申请审核请求收到成功");
  149 + map.put("statusCode", "200");
  150 + map.put("result", result);
  151 + } else {
  152 + result.put("errorCode", "-1");
  153 + result.put("errorMessage", "直播申请审核入库失败");
  154 + map.put("statusCode", "300");
  155 + map.put("result", result);
  156 + }
  157 + return map;
  158 + }
  159 +
  160 +}
... ...
src/main/java/com/cnlive/shenhe/api/LiveControllerApi.java
... ... @@ -83,7 +83,7 @@ public class LiveControllerApi {
83 83 if (listshyLive.size() > 0) {
84 84 ShyLive shyLive = listshyLive.get(0);
85 85 //封装数据入库
86   - shylive1.setSp_id(spId);//设置spid
  86 + shyLive.setSp_id(spId);//设置spid
87 87 shyLive.setActivity_name(activityName);//设置直播活动名称
88 88 shyLive.setActivity_status(activityStatus);//设置直播活动状态
89 89 if(activityStatus==3){//发布直播
... ...
src/main/java/com/cnlive/shenhe/controller/LiveApplyController.java 0 → 100644
  1 +package com.cnlive.shenhe.controller;
  2 +
  3 +import org.apache.poi.xssf.usermodel.XSSFCell;
  4 +import org.apache.poi.xssf.usermodel.XSSFRow;
  5 +import org.apache.poi.xssf.usermodel.XSSFSheet;
  6 +import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  7 +import com.alibaba.fastjson.JSON;
  8 +import com.alibaba.fastjson.JSONObject;
  9 +import com.cnlive.shenhe.bean.ErrorEnum;
  10 +import com.cnlive.shenhe.bean.ResponseBean;
  11 +import com.cnlive.shenhe.bean.SessionUser;
  12 +import com.cnlive.shenhe.entity.ShyLive;
  13 +import com.cnlive.shenhe.entity.ShyLiveapply;
  14 +import com.cnlive.shenhe.entity.ShySites;
  15 +import com.cnlive.shenhe.entity.ShyUsers;
  16 +import com.cnlive.shenhe.entity.ShyVideos;
  17 +import com.cnlive.shenhe.serviceImpl.LiveApplyServiceImpl;
  18 +import com.cnlive.shenhe.serviceImpl.LiveServiceImpl;
  19 +import com.cnlive.shenhe.serviceImpl.SitesServiceImpl;
  20 +import com.cnlive.shenhe.serviceImpl.UsersServiceImpl;
  21 +import com.cnlive.shenhe.serviceImpl.VideosServiceImpl;
  22 +import com.cnlive.shenhe.utils.AuditPass;
  23 +import com.cnlive.shenhe.utils.CommonConst;
  24 +import com.cnlive.shenhe.utils.CommonUtils;
  25 +import com.github.pagehelper.PageInfo;
  26 +import org.slf4j.Logger;
  27 +import org.slf4j.LoggerFactory;
  28 +import org.springframework.beans.factory.annotation.Autowired;
  29 +import org.springframework.beans.factory.annotation.Value;
  30 +import org.springframework.stereotype.Controller;
  31 +import org.springframework.ui.Model;
  32 +import org.springframework.web.bind.annotation.GetMapping;
  33 +import org.springframework.web.bind.annotation.PostMapping;
  34 +import org.springframework.web.bind.annotation.RequestMapping;
  35 +import org.springframework.web.bind.annotation.ResponseBody;
  36 +
  37 +import javax.servlet.ServletOutputStream;
  38 +import javax.servlet.http.HttpServletResponse;
  39 +import javax.servlet.http.HttpSession;
  40 +import java.io.*;
  41 +import java.util.List;
  42 +
  43 +@Controller
  44 +@RequestMapping("/liveApply")
  45 +public class LiveApplyController {
  46 + private static Logger logger = LoggerFactory.getLogger(LiveApplyController.class);
  47 + @Autowired
  48 + AuditPass Pass;
  49 + @Autowired
  50 + VideosServiceImpl videosService;
  51 + @Autowired
  52 + UsersServiceImpl usersService;
  53 + @Autowired
  54 + SitesServiceImpl sitesService;
  55 + @Autowired
  56 + LiveServiceImpl liveService;
  57 +
  58 + @Value("${qn_domain}")
  59 + String qn_domain;
  60 +
  61 + @Value("${ks_domain}")
  62 + String ks_domain;
  63 +
  64 +
  65 + @Autowired
  66 + LiveApplyServiceImpl liveApplyServiceImpl;
  67 +
  68 + /**
  69 + * 直播申请审核信息回调接口
  70 + *
  71 + * @param activity_id 视频id
  72 + * @param state 状态码
  73 + * @param attr_tags 标签
  74 + * @param msg 备注信息
  75 + * @return
  76 + */
  77 + @PostMapping("/shenheLiveApply")
  78 + @ResponseBody
  79 + public ResponseBean shenheInfo(Integer id, Integer state, String msg, HttpSession session) {
  80 + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
  81 + String userId = sessionUser.getUserId();
  82 + ShyLiveapply shyliveApply = liveApplyServiceImpl.selectByPrimaryKey(id);
  83 + JSONObject result = null;
  84 + try {
  85 + result = Pass.liveApplyPass(shyliveApply.getActivity_id(), state+2, "", msg, shyliveApply.getCallback());
  86 + } catch (Exception e) {
  87 + e.printStackTrace();
  88 + System.out.println("直播申请审核失败");
  89 + return new ResponseBean(ErrorEnum.ERROR);
  90 + }
  91 + if (result == null) {
  92 + System.out.println("直播申请审核失败且接口错误没有返回信息");
  93 + return new ResponseBean(ErrorEnum.ERROR);
  94 + }
  95 + Integer code = result.getInteger("code");
  96 + if (code != 0) {
  97 + System.out.println("直播申请审核失败,code==" + code);
  98 + return new ResponseBean(code, result.getString("msg"));
  99 + }
  100 + int i = liveApplyServiceImpl.updateLiveApply(id, userId,null, state, msg);
  101 + if (i == 0) {
  102 + return new ResponseBean(ErrorEnum.ERROR);
  103 + }
  104 + return new ResponseBean(ErrorEnum.SUCCESS);
  105 + }
  106 +
  107 + /**
  108 + * 内容分页列表接口
  109 + *
  110 + * @param video_title
  111 + * @param start_date
  112 + * @param end_date
  113 + * @param state
  114 + * @param page
  115 + * @param pageSize
  116 + * @param orderByClause
  117 + * @return
  118 + */
  119 + @GetMapping("/page")
  120 + public Object getListVideos(Model model,String activity_id,String start_date,String end_date,
  121 + String activity_name, Integer activity_status, Integer page,Integer pageSize,
  122 + Integer shenhe_state, String sp_desc, HttpSession session) {
  123 + System.out.println("进入直播内容页");
  124 + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
  125 +// if(CommonUtils.isNull(sessionUser)){
  126 +// return "redirect:/users/login";
  127 +// }
  128 + Integer spid = sessionUser.getSpid();
  129 + String userId = sessionUser.getUserId();
  130 + if (CommonUtils.isNull(page)) page = 1;
  131 + if (CommonUtils.isNull(pageSize)) pageSize = 20;
  132 + if (CommonUtils.isNotEmpty(sp_desc) && spid == 0) {
  133 + ShySites shySite=sitesService.findspidBySpdesc(sp_desc);
  134 + if(CommonUtils.isNotNull(shySite)){
  135 + spid = shySite.getSpid();
  136 + }else{
  137 + return "page/sitesError.html";
  138 + }
  139 + } else if (CommonUtils.isEmpty(sp_desc) && spid == 0) {
  140 + spid = null;
  141 + }
  142 + String orderByClause="";
  143 + if(shenhe_state!=null&&shenhe_state==0){//审核状态:全部待领
  144 + orderByClause="activity_start_time ";
  145 + }else if(shenhe_state!=null&&shenhe_state==1){//审核状态:待审核
  146 + orderByClause="activity_start_time ";
  147 + }else if(shenhe_state!=null&&shenhe_state==2){//审核状态:已审核
  148 + orderByClause="activity_start_time desc";
  149 + }else{//审核状态:全部
  150 + orderByClause="is_hot desc, activity_start_time ";
  151 + if(activity_status!=null &&(activity_status==0 ||activity_status==2 || activity_status==4)){//直播状态:结束、撤销、下线
  152 + orderByClause="is_hot desc, activity_start_time desc";
  153 + }
  154 + }
  155 + PageInfo<ShyLive> livePage = liveService.getListContent(activity_name, start_date,end_date,
  156 + activity_id, activity_status, page, pageSize, shenhe_state, orderByClause, spid, userId);
  157 + List<ShyLive> list = livePage.getList();
  158 + if (!list.isEmpty()) {
  159 + for (ShyLive live : list) {
  160 + //显示spid简称
  161 + ShySites shySites = sitesService.findspidDescByspid(live.getSp_id());
  162 + if (CommonUtils.isNotNull(shySites)) {
  163 + live.setSpid_desc(shySites.getName());
  164 + }
  165 + }
  166 + }
  167 + model.addAttribute("livePage", livePage);
  168 + model.addAttribute("pageSize", pageSize);
  169 + return "page/live.html";
  170 + }
  171 +
  172 + /**
  173 + * 内容详情页接口(查看)
  174 + *
  175 + * @param id
  176 + * @return
  177 + */
  178 + @GetMapping("/details")
  179 + public Object getDetailsLive(Model model, Integer id) {
  180 + ShyLive live = liveService.getDetailsLive(id);
  181 +
  182 + //显示spid简称
  183 + ShySites shySites = sitesService.findspidDescByspid(live.getSp_id());
  184 + if (CommonUtils.isNotNull(shySites)) {
  185 + live.setSpid_desc(shySites.getName());
  186 + }
  187 +
  188 + model.addAttribute("live", live);
  189 +
  190 + return "page/liveDetail.html";
  191 + }
  192 +
  193 + /**
  194 + * 认领
  195 + *
  196 + * @param ids 根据id认领
  197 + * @param num 认领条数
  198 + * @param session
  199 + * @return
  200 + */
  201 + @PostMapping("/receive")
  202 + @ResponseBody
  203 + public ResponseBean receive(String ids, Integer num, HttpSession session) {
  204 + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
  205 + String userId = sessionUser.getUserId();
  206 + Integer spid = sessionUser.getSpid();
  207 + //领取时要检查领取的数据是否可以领
  208 + if (CommonUtils.isNotEmpty(ids)) {
  209 + String[] cids = ids.split(",");
  210 + for (String cid : cids) {
  211 + ShyLive shyLive = liveService.selectByPrimaryKey(Integer.parseInt(cid));
  212 + if (CommonUtils.isNotNull(shyLive)) {
  213 + if (shyLive.getShenhe_state() != CommonConst.RECEIVE_BEFORE ) {
  214 + return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "您领取的内容中有已被领取或者已经被审核,请检查并重试");
  215 + }
  216 + } else {
  217 + return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "您领取的内容不存在,请检查并重试");
  218 +
  219 + }
  220 + }
  221 + }
  222 + Integer n = liveService.receive(ids, num, userId, spid);
  223 + return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "认领到" + n + "条内容");
  224 + }
  225 +
  226 +
  227 + /**
  228 + * 退领
  229 + * @param ids
  230 + * @param session
  231 + * @return
  232 + */
  233 + @PostMapping("/retReceive")
  234 + @ResponseBody
  235 + public ResponseBean retReceive(String ids, HttpSession session) {
  236 + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
  237 + String userId = sessionUser.getUserId();
  238 + //在退领操作前先判断是否包含已退领或者已经审核的数据,有则退回检查并重新退领
  239 + String[] cids = ids.split(",");
  240 + for (String cid : cids) {
  241 + ShyLive shyLive = liveService.selectByPrimaryKey(Integer.parseInt(cid));
  242 + if (shyLive.getShenhe_state() != CommonConst.RECEIVE_AFTER || !shyLive.getAuditor().equals(userId)) {
  243 + return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "退领失败,您选中的内容包含已退领的或已经审核的");
  244 + }
  245 + }
  246 + return liveService.retReceive(ids, userId);
  247 + }
  248 +
  249 + /**
  250 + * 打回(审核拒绝)
  251 + *
  252 + * @param ids
  253 + * @param msg
  254 + * @param session
  255 + * @return
  256 + */
  257 + @PostMapping("/repulse")
  258 + @ResponseBody
  259 + public ResponseBean repulse(String ids, String msg, HttpSession session) {
  260 + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
  261 + String userId = sessionUser.getUserId();
  262 + ResponseBean responseBean = new ResponseBean();
  263 + String[] shyLiveIds = ids.split(",");
  264 + String showMsg = "";
  265 + for (String shyLiveId : shyLiveIds) {
  266 + ShyLive shyLive = liveService.selectByPrimaryKey(Integer.parseInt(shyLiveId));
  267 + JSONObject result = null;
  268 + try {
  269 + result = Pass.livePass(shyLive.getActivity_id(), 6, msg, msg, shyLive.getCallback());
  270 + } catch (Exception e) {
  271 + logger.error("直播视频审核失败,id==" + shyLiveId, e);
  272 + showMsg = showMsg + "," + shyLive.getActivity_id() + " 拒绝请求失败";
  273 + break;
  274 + }
  275 + if (result == null) {
  276 + logger.error("直播视频审核失败且接口错误没有返回信息,id==" + shyLiveId);
  277 + showMsg = showMsg + "," + shyLive.getActivity_id() + " 拒绝请求失败";
  278 + break;
  279 + }
  280 + Integer code = result.getInteger("errorCode");
  281 + if (code != 0) {
  282 + logger.error("直播视频审核失败,id:{},code:{}", shyLiveId, code);
  283 + showMsg = showMsg + "," + shyLive.getActivity_id() + " " + result.getString(" errorMessage");
  284 + break;
  285 + }
  286 + int i = liveService.updateLive(Integer.parseInt(shyLiveId), userId,"", 4, msg);
  287 + if (i == 0) {
  288 + showMsg = showMsg + "," + shyLive.getActivity_id() + " 更新失败";
  289 + break;
  290 + }
  291 + }
  292 + if (CommonUtils.isNotEmpty(showMsg)) {
  293 + responseBean.setErrorCode(ErrorEnum.ERROR.getErrorCode());
  294 + responseBean.setErrorMessage(showMsg);
  295 + }
  296 + return responseBean;
  297 + }
  298 +
  299 + /**
  300 + * 同步直播云信息
  301 + *
  302 + * @param ids
  303 + * @param msg
  304 + * @param session
  305 + * @return
  306 + */
  307 + @PostMapping("/syncLive")
  308 + @ResponseBody
  309 + public ResponseBean syncLive(String ids, HttpSession session) {
  310 + logger.info("同步直播云信息接口进入");
  311 + ResponseBean responseBean = new ResponseBean();
  312 + String[] shyLiveIds = ids.split(",");
  313 + String showMsg = "";
  314 + for (String shyLiveId : shyLiveIds) {
  315 + ShyLive shyLive = liveService.selectByPrimaryKey(Integer.parseInt(shyLiveId));
  316 + JSONObject result = null;
  317 + try {
  318 + result = Pass.syncLive(shyLive.getActivity_id());
  319 + } catch (Exception e) {
  320 + logger.error("直播云信息同步失败,id==" + shyLiveId, e);
  321 + showMsg = showMsg + "," + shyLive.getActivity_id() + " 拒绝请求失败";
  322 + break;
  323 + }
  324 + if (result == null) {
  325 + logger.error("直播云信息同步失败且接口错误没有返回信息,id==" + shyLiveId);
  326 + showMsg = showMsg + "," + shyLive.getActivity_id() + " 拒绝请求失败";
  327 + break;
  328 + }
  329 + Integer code = result.getInteger("errorCode");
  330 + if (code != 0) {
  331 + logger.error("直播云信息同步失败,id:{},code:{}", shyLiveId, code);
  332 + showMsg = result.getString("errorMessage");
  333 + break;
  334 + }
  335 + }
  336 + if (CommonUtils.isNotEmpty(showMsg)) {
  337 + responseBean.setErrorCode(ErrorEnum.ERROR.getErrorCode());
  338 + responseBean.setErrorMessage(showMsg);
  339 + }else{
  340 + showMsg="直播云信息同步成功";
  341 + responseBean.setErrorCode(ErrorEnum.SUCCESS.getErrorCode());
  342 + responseBean.setErrorMessage(showMsg);
  343 + }
  344 + return responseBean;
  345 + }
  346 +
  347 + /**
  348 + * 根据条件导出excel
  349 + */
  350 + @GetMapping("excel")
  351 + public void getExcel(String activity_id,String start_date,String end_date,
  352 + String activity_name, Integer activity_status, Integer page,Integer pageSize,
  353 + Integer shenhe_state, String orderByClause, String sp_desc, HttpSession session,HttpServletResponse response) {
  354 + SessionUser sessionUser = (SessionUser) session.getAttribute(SessionUser.getSessionKey());
  355 + Integer spid = sessionUser.getSpid();
  356 + String userId = sessionUser.getUserId();
  357 + if (CommonUtils.isNotEmpty(sp_desc) && spid == 0) {
  358 + ShySites shySite=sitesService.findspidBySpdesc(sp_desc);
  359 + if(CommonUtils.isNotNull(shySite)){
  360 + spid = shySite.getSpid();
  361 + }
  362 + }else if (CommonUtils.isEmpty(sp_desc) && spid == 0) {
  363 + spid = null;
  364 + }
  365 + List<ShyLive> liveList = liveService.findByCondition(activity_name, start_date,end_date,
  366 + activity_id, activity_status, page, pageSize, shenhe_state, orderByClause, spid);
  367 +
  368 + String fileName = "直播数据";
  369 +
  370 + XSSFWorkbook wb = new XSSFWorkbook();
  371 + ServletOutputStream out = null;
  372 + BufferedInputStream bis = null;
  373 + BufferedOutputStream bos = null;
  374 + try {
  375 + XSSFSheet sheetlist = wb.createSheet(fileName);
  376 + XSSFRow row = sheetlist.createRow(0);//行
  377 + XSSFCell cell = row.createCell(0);//列
  378 + cell.setCellValue("id");
  379 + cell = row.createCell(1);//列
  380 + cell.setCellValue("sp昵称");
  381 + cell = row.createCell(2);//列
  382 + cell.setCellValue("频道_id");
  383 + cell = row.createCell(3);//列
  384 + cell.setCellValue("直播活动id");
  385 + cell = row.createCell(4);//列
  386 + cell.setCellValue("直播活动名称");
  387 + cell = row.createCell(5);//列
  388 + cell.setCellValue("直播活动状态");
  389 + cell = row.createCell(6);//列
  390 + cell.setCellValue("直播活动开始时间");
  391 + cell = row.createCell(7);//列
  392 + cell.setCellValue("直播活动结束时间");
  393 + cell = row.createCell(8);//列
  394 + cell.setCellValue("直播活动简介");
  395 + cell = row.createCell(9);//列
  396 + cell.setCellValue("审核类型");
  397 + cell = row.createCell(10);//列
  398 + cell.setCellValue("审核状态");
  399 + cell = row.createCell(11);//列
  400 + cell.setCellValue("审核员");
  401 + cell = row.createCell(12);//列
  402 + cell.setCellValue("审核信息");
  403 + cell = row.createCell(13);//列
  404 + cell.setCellValue("创建时间");
  405 + cell = row.createCell(14);//列
  406 + cell.setCellValue("最后更新时间");
  407 +
  408 + for (int i = 0; i < liveList.size(); i++) {
  409 + row = sheetlist.createRow((short) (i + 1));//行
  410 + cell = row.createCell(0);//列
  411 + cell.setCellValue(liveList.get(i).getId());
  412 + cell = row.createCell(1);//列
  413 + cell.setCellValue(sitesService.findspidDescByspid(liveList.get(i).getSp_id()).getName());
  414 + cell = row.createCell(2);//列
  415 + cell.setCellValue(liveList.get(i).getChannel_id());
  416 + cell = row.createCell(3);//列
  417 + cell.setCellValue(liveList.get(i).getActivity_id());
  418 + cell = row.createCell(4);//列
  419 + cell.setCellValue(liveList.get(i).getActivity_name());
  420 + /*状态需要处理成用户可读*/
  421 + String activityStatus = "";//直播活动状态,1:直播中,2:直播完成,3:待直播,0:直播撤销(手动),4:直播下线(强制)
  422 + if (liveList.get(i).getActivity_status() == 0) {
  423 + activityStatus = "直播撤销(手动)";
  424 + } else if (liveList.get(i).getActivity_status() == 1) {
  425 + activityStatus = "正在直播";
  426 + } else if(liveList.get(i).getActivity_status() == 2){
  427 + activityStatus = "直播完成";
  428 + }else if(liveList.get(i).getActivity_status() == 3){
  429 + activityStatus = "等待直播";
  430 + }else if(liveList.get(i).getActivity_status() == 4){
  431 + activityStatus = "直播下线(强制)";
  432 + }
  433 + cell = row.createCell(5);//列
  434 + cell.setCellValue(activityStatus);
  435 + cell = row.createCell(6);//列
  436 + cell.setCellValue(CommonUtils.formatDate(liveList.get(i).getActivity_start_time(), "yyyy-MM-dd HH:mm:ss"));
  437 + cell = row.createCell(7);//列
  438 + cell.setCellValue(CommonUtils.formatDate(liveList.get(i).getActivity_end_time(), "yyyy-MM-dd HH:mm:ss"));
  439 + cell = row.createCell(8);//列
  440 + cell.setCellValue(liveList.get(i).getActivity_intro());
  441 +
  442 + /*状态需要处理成用户可读*/
  443 + String shenheType = "";//审核类型,1:免审,2:机审,3:人工审
  444 + if (liveList.get(i).getShenhe_type() == 1) {
  445 + shenheType = "免审";
  446 + } else if (liveList.get(i).getShenhe_type() == 2) {
  447 + shenheType = "机审";
  448 + } else {
  449 + shenheType = "人工审";
  450 + }
  451 +
  452 + cell = row.createCell(9);//列
  453 + cell.setCellValue(shenheType);
  454 +
  455 + /*状态需要处理成用户可读*/
  456 + String shenheState = "";//审核状态 0:未认领 1.已认领,2:已审核
  457 + if (liveList.get(i).getShenhe_type() == 1) {
  458 + shenheState = "已认领";
  459 + } else if (liveList.get(i).getShenhe_type() == 2) {
  460 + shenheState = "已审核";
  461 + } else {
  462 + shenheState = "未认领";
  463 + }
  464 +
  465 + cell = row.createCell(10);//列
  466 + cell.setCellValue(shenheState);
  467 +
  468 + /* 审核员需要做处理*/
  469 + String updater = "";//审核员名字
  470 + if (liveList.get(i).getShenhe_state() != CommonConst.RECEIVE_BEFORE) {
  471 + updater = CommonUtils.isEmpty(liveList.get(i).getUpdater()) || "null".equals(liveList.get(i).getUpdater())? "自动通过":liveList.get(i).getUpdater();
  472 + String auditor_id = liveList.get(i).getAuditor();
  473 + if (CommonUtils.isNotEmpty(auditor_id)) {
  474 + ShyUsers user = new ShyUsers();
  475 + user.setUser_id(auditor_id);
  476 + user = usersService.select(user);
  477 + if (CommonUtils.isNotNull(user)) {
  478 + String email = CommonUtils.isEmpty(user.getEmail()) || "null".equals(user.getEmail()) ? "" : user.getEmail();
  479 + String userName = CommonUtils.isEmpty(user.getUsername()) ? email : user.getUsername();
  480 + updater = userName ;
  481 + }
  482 + }
  483 + }
  484 +
  485 + cell = row.createCell(11);//列
  486 + cell.setCellValue(updater);
  487 + cell = row.createCell(12);//列
  488 + cell.setCellValue(liveList.get(i).getShenhe_msg());
  489 + cell = row.createCell(13);//列
  490 + cell.setCellValue(CommonUtils.formatDate(liveList.get(i).getCreated_at(), "yyyy-MM-dd HH:mm:ss"));
  491 + cell = row.createCell(14);//列
  492 + cell.setCellValue(CommonUtils.formatDate(liveList.get(i).getUpdated_at(), "yyyy-MM-dd HH:mm:ss"));
  493 + }
  494 +
  495 + ByteArrayOutputStream os = new ByteArrayOutputStream();
  496 + wb.write(os);
  497 + byte[] content = os.toByteArray();
  498 + InputStream is = new ByteArrayInputStream(content);
  499 + response.setContentType("application/vnd.ms-excel;charset=utf-8");
  500 + response.setHeader("Content-Disposition", "attachment;filename=" + new String((fileName + ".xlsx").getBytes(), "iso-8859-1"));
  501 + out = response.getOutputStream();
  502 + bis = new BufferedInputStream(is);
  503 + bos = new BufferedOutputStream(out);
  504 + byte[] buff = new byte[2048];
  505 + int bytesRead;
  506 + while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
  507 + bos.write(buff, 0, bytesRead);
  508 + }
  509 + } catch (final Exception e) {
  510 + e.printStackTrace();
  511 + try {
  512 + if (bis != null)
  513 + bis.close();
  514 + if (bos != null)
  515 + bos.close();
  516 + } catch (Exception e1) {
  517 + e1.printStackTrace();
  518 + }
  519 + } finally {
  520 + try {
  521 + if (bis != null)
  522 + bis.close();
  523 + if (bos != null)
  524 + bos.close();
  525 + } catch (Exception e2) {
  526 + e2.printStackTrace();
  527 + }
  528 + }
  529 + }
  530 +
  531 + @PostMapping("/ceshi")
  532 + @ResponseBody
  533 + public static String ceshi(String name) {
  534 +
  535 +
  536 + return name;
  537 + }
  538 +
  539 +}
... ...
src/main/java/com/cnlive/shenhe/serviceImpl/LiveApplyServiceImpl.java 0 → 100644
  1 +package com.cnlive.shenhe.serviceImpl;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONArray;
  5 +import com.alibaba.fastjson.JSONObject;
  6 +import com.cnlive.shenhe.bean.ErrorEnum;
  7 +import com.cnlive.shenhe.bean.ResponseBean;
  8 +import com.cnlive.shenhe.entity.ShyChannel;
  9 +import com.cnlive.shenhe.entity.ShyLive;
  10 +import com.cnlive.shenhe.entity.ShyLiveapply;
  11 +import com.cnlive.shenhe.entity.ShySites;
  12 +import com.cnlive.shenhe.entity.ShyUsers;
  13 +import com.cnlive.shenhe.entity.ShyUsersfree;
  14 +import com.cnlive.shenhe.entity.ShyVideofilter;
  15 +import com.cnlive.shenhe.entity.ShyVideos;
  16 +import com.cnlive.shenhe.job.VideosJob;
  17 +import com.cnlive.shenhe.mapper.ShyLiveMapper;
  18 +import com.cnlive.shenhe.mapper.ShyLiveapplyMapper;
  19 +import com.cnlive.shenhe.mapper.ShySitesMapper;
  20 +import com.cnlive.shenhe.mapper.ShyUsersMapper;
  21 +import com.cnlive.shenhe.mapper.ShyVideosMapper;
  22 +import com.cnlive.shenhe.utils.AntiFraudUtil;
  23 +import com.cnlive.shenhe.utils.AuditPass;
  24 +import com.cnlive.shenhe.utils.CommonConst;
  25 +import com.cnlive.shenhe.utils.CommonUtils;
  26 +import com.github.pagehelper.PageHelper;
  27 +import com.github.pagehelper.PageInfo;
  28 +
  29 +
  30 +import org.apache.ibatis.session.RowBounds;
  31 +import org.slf4j.Logger;
  32 +import org.slf4j.LoggerFactory;
  33 +import org.springframework.beans.factory.annotation.Autowired;
  34 +import org.springframework.beans.factory.annotation.Value;
  35 +import org.springframework.stereotype.Service;
  36 +import tk.mybatis.mapper.entity.Example;
  37 +
  38 +import java.sql.Timestamp;
  39 +import java.text.ParseException;
  40 +import java.util.ArrayList;
  41 +import java.util.Arrays;
  42 +import java.util.HashMap;
  43 +import java.util.List;
  44 +import java.util.Map;
  45 +
  46 +/**
  47 + * @Auther: liwei
  48 + * @Date: 2018/11/30 14:23
  49 + * @Description:
  50 + */
  51 +@Service
  52 +public class LiveApplyServiceImpl {
  53 + private static Logger logger = LoggerFactory.getLogger(LiveApplyServiceImpl.class);
  54 + @Autowired
  55 + ShyLiveMapper shyLiveMapper;
  56 + @Autowired
  57 + ShyLiveapplyMapper shyLiveApplyMapper;
  58 + @Autowired
  59 + ShyUsersMapper shyUsersMapper;
  60 +
  61 + @Autowired
  62 + SitesServiceImpl sitesService;
  63 +
  64 + //==============
  65 + public boolean impotLiveApply(ShyLiveapply shyLiveApply) {
  66 + int result = shyLiveApplyMapper.insertSelective(shyLiveApply);
  67 + if (result == 0) {
  68 + return false;
  69 + }
  70 + return true;
  71 + }
  72 +
  73 + //==============
  74 + public ShyLiveapply selectByPrimaryKey(Integer id) {
  75 + ShyLiveapply shyLiveApply = shyLiveApplyMapper.selectByPrimaryKey(id);
  76 + return shyLiveApply;
  77 + }
  78 +
  79 + //=============
  80 + public List<ShyLiveapply> findshyLiveApply(ShyLiveapply shyLiveApply) {
  81 + List<ShyLiveapply> shyLiveApplylist = shyLiveApplyMapper.selectByRowBounds(shyLiveApply, new RowBounds(0, 100));
  82 + return shyLiveApplylist;
  83 + }
  84 +
  85 + //==============
  86 + public boolean updateshyLiveApply(ShyLiveapply shyLiveApply) {
  87 + int i = shyLiveApplyMapper.updateByPrimaryKey(shyLiveApply);
  88 + if (i == 0) {
  89 + return false;
  90 + }
  91 + return true;
  92 + }
  93 +
  94 + //==============
  95 + public int updateLiveApply(Integer id, String auditor_id,String updater, Integer status, String msg) {
  96 + ShyLiveapply shyLiveapply = shyLiveApplyMapper.selectByPrimaryKey(id);
  97 + shyLiveapply.setAuditor(auditor_id);
  98 + shyLiveapply.setShenhe_state(status);
  99 + shyLiveapply.setReceive(CommonConst.RECEIVE_AFTER);
  100 + shyLiveapply.setShenhe_msg(msg);
  101 + shyLiveapply.setUpdater(updater);
  102 + shyLiveapply.setUpdated_at(CommonUtils.getCurrentTime());
  103 + return shyLiveApplyMapper.updateByPrimaryKey(shyLiveapply);
  104 + }
  105 +
  106 + //===============
  107 + public PageInfo<ShyLive> getListContent(String activity_name, String start_date, String end_date,
  108 + String activity_id, Integer activity_status, Integer page, Integer pageSize,
  109 + Integer shenhe_state, String orderByClause, Integer spid, String userId) {
  110 + Example example = new Example(ShyLive.class);
  111 + Example.Criteria criteria = example.createCriteria();
  112 +// Example.Criteria criteria2 = example.createCriteria();
  113 + if (CommonUtils.isNotEmpty(orderByClause)) {
  114 + example.setOrderByClause(orderByClause);
  115 + }
  116 + if (CommonUtils.isNotEmpty(start_date)) {
  117 + Timestamp startdate = null;
  118 + try {
  119 + startdate = CommonUtils.parseDate(start_date, "yyyy-MM-dd");
  120 + } catch (ParseException e) {
  121 + e.printStackTrace();
  122 + }
  123 + criteria.andGreaterThanOrEqualTo("activity_start_time", startdate);
  124 +// criteria2.andGreaterThanOrEqualTo("activity_start_time", startdate);
  125 + }
  126 + if ( CommonUtils.isNotEmpty(end_date)) {
  127 + Timestamp enddate = null;
  128 + try {
  129 + enddate = CommonUtils.parseDate(end_date, "yyyy-MM-dd");
  130 + } catch (ParseException e) {
  131 + e.printStackTrace();
  132 + }
  133 + criteria.andLessThanOrEqualTo("activity_end_time", enddate);
  134 +// criteria2.andLessThanOrEqualTo("activity_end_time", enddate);
  135 + }
  136 + if (CommonUtils.isNotEmpty(activity_name)) {
  137 + criteria.andLike("activity_name", "%" + activity_name + "%");
  138 +// criteria2.andLike("activity_name", "%" + activity_name + "%");
  139 + }
  140 +
  141 + if (CommonUtils.isNotEmpty(activity_id)) {
  142 + criteria.andEqualTo("activity_id", activity_id);
  143 +// criteria2.andEqualTo("activity_id", activity_id);
  144 + }
  145 + if (CommonUtils.isNotNull(spid)) {
  146 + criteria.andEqualTo("sp_id", spid);
  147 +// criteria2.andEqualTo("spid", spid);
  148 + }
  149 + if (CommonUtils.isNotNull(shenhe_state)) {
  150 + criteria.andEqualTo("shenhe_state", shenhe_state);
  151 +// criteria2.andEqualTo("shenhe_state", shenhe_state);
  152 + if (shenhe_state != CommonConst.RECEIVE_BEFORE) {
  153 + criteria.andEqualTo("auditor", userId);
  154 +// criteria2.andEqualTo("auditor", userId);
  155 + }
  156 + }
  157 + if (CommonUtils.isNotNull(activity_status) ) {
  158 + criteria.andEqualTo("activity_status", activity_status);
  159 + }
  160 + criteria.andEqualTo("is_show", 1);
  161 + //排序
  162 +// example.setOrderByClause("is_hot desc, activity_start_time desc");
  163 + PageHelper.startPage(page, pageSize, true);
  164 + List<ShyLive> shyLiveList = shyLiveMapper.selectByExample(example);
  165 + PageInfo<ShyLive> pageInfo = new PageInfo<>(shyLiveList);
  166 + return pageInfo;
  167 + }
  168 +
  169 + //======================
  170 + public ShyLive getDetailsLive(Integer id) {
  171 + ShyLive shyLive = shyLiveMapper.selectByPrimaryKey(id);
  172 + if (shyLive.getShenhe_state() != CommonConst.RECEIVE_BEFORE) {
  173 + String updater = CommonUtils.isEmpty(shyLive.getUpdater()) || "null".equals(shyLive.getUpdater())? "自动通过":shyLive.getUpdater();
  174 + String auditor_id = shyLive.getAuditor();
  175 + if (CommonUtils.isNotEmpty(auditor_id)) {
  176 + ShyUsers user = new ShyUsers();
  177 + user.setUser_id(auditor_id);
  178 + user = shyUsersMapper.selectOne(user);
  179 + String email = CommonUtils.isEmpty(user.getEmail()) || "null".equals(user.getEmail())? "" : user.getEmail();
  180 + String userName = CommonUtils.isEmpty(user.getUsername()) ? email: user.getUsername();
  181 + updater = userName;
  182 + }
  183 + shyLive.setUpdater(updater);
  184 + }
  185 + return shyLive;
  186 + }
  187 +
  188 + //====================
  189 + public Integer receive(String ids, Integer num, String userId, Integer spid) {
  190 + Integer n = 0;
  191 + if (CommonUtils.isNotEmpty(ids)) {
  192 + String[] cids = ids.split(",");
  193 + for (String cid : cids) {
  194 + ShyLive shyLive = shyLiveMapper.selectByPrimaryKey(Integer.parseInt(cid));
  195 + if (CommonUtils.isNotNull(shyLive) && shyLive.getShenhe_state() == CommonConst.RECEIVE_BEFORE ) {
  196 + shyLive.setAuditor(userId);;
  197 + shyLive.setShenhe_state(CommonConst.RECEIVE_AFTER);
  198 + shyLiveMapper.updateByPrimaryKeySelective(shyLive);
  199 + n++;
  200 + }
  201 + }
  202 + } else if (CommonUtils.isNotNull(num) && num > 0) {
  203 + Example example = new Example(ShyLive.class);
  204 + example.setOrderByClause("is_hot desc, activity_start_time asc");
  205 + example.and().andEqualTo("shenhe_state", CommonConst.RECEIVE_BEFORE);
  206 + if (CommonUtils.isNotNull(spid) && spid != 0) example.and().andEqualTo("spid", spid);
  207 + List<ShyLive> shyLiveList = shyLiveMapper.selectByExampleAndRowBounds(example, new RowBounds(0, num));
  208 + if (!shyLiveList.isEmpty()) {
  209 + for (ShyLive shyLive : shyLiveList) {
  210 + shyLive.setAuditor(userId);
  211 + shyLive.setShenhe_state(CommonConst.RECEIVE_AFTER);
  212 + shyLiveMapper.updateByPrimaryKeySelective(shyLive);
  213 + n++;
  214 + }
  215 + }
  216 + }
  217 + return n;
  218 + }
  219 +
  220 + //================
  221 + public ResponseBean retReceive(String ids, String userId) {
  222 + String[] cids = ids.split(",");
  223 + for (String cid : cids) {
  224 + ShyLive shyLive = shyLiveMapper.selectByPrimaryKey(Integer.parseInt(cid));
  225 + if (shyLive.getShenhe_state() == CommonConst.RECEIVE_AFTER && shyLive.getAuditor().equals(userId)) {
  226 + shyLive.setShenhe_state(CommonConst.RECEIVE_BEFORE);
  227 + shyLive.setAuditor(null);
  228 + int i = shyLiveMapper.updateByPrimaryKey(shyLive);
  229 + if (i != 1) {
  230 + return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "退领失败,请重试");
  231 + }
  232 + } else {
  233 + return new ResponseBean(ErrorEnum.ERROR.getErrorCode(), "退领失败,您选中的内容包含已退领的或已经审核的");
  234 + }
  235 + }
  236 + return new ResponseBean(ErrorEnum.SUCCESS.getErrorCode(), "已退领");
  237 + }
  238 +
  239 + /**
  240 + * 根据条件导出数据excel
  241 + * @return
  242 + */
  243 + public List<ShyLive> findByCondition(String activity_id,String start_date,String end_date,
  244 + String activity_name, Integer activity_status, Integer page,Integer pageSize,
  245 + Integer shenhe_state, String orderByClause, Integer spid) {
  246 + Example example = new Example(ShyLive.class);
  247 + Example.Criteria criteria = example.createCriteria();
  248 + if (CommonUtils.isNotEmpty(orderByClause)) {
  249 + example.setOrderByClause(orderByClause);
  250 + }else{
  251 + //默认排序
  252 + example.setOrderByClause("activity_start_time asc");
  253 + }
  254 + if (CommonUtils.isNotEmpty(start_date)) {
  255 + Timestamp startdate = null;
  256 + try {
  257 + startdate = CommonUtils.parseDate(start_date, "yyyy-MM-dd HH:mm");
  258 + } catch (ParseException e) {
  259 + e.printStackTrace();
  260 + }
  261 + criteria.andGreaterThanOrEqualTo("activity_start_time", startdate);
  262 + }
  263 + if ( CommonUtils.isNotEmpty(end_date)) {
  264 + Timestamp enddate = null;
  265 + try {
  266 + enddate = CommonUtils.parseDate(end_date, "yyyy-MM-dd HH:mm");
  267 + } catch (ParseException e) {
  268 + e.printStackTrace();
  269 + }
  270 + criteria.andLessThanOrEqualTo("activity_end_time", enddate);
  271 + }
  272 + if (CommonUtils.isNotEmpty(activity_name)) {
  273 + criteria.andLike("activity_name", "%" + activity_name + "%");
  274 + }
  275 + if (CommonUtils.isNotNull(activity_status) ) {
  276 + criteria.andEqualTo("activity_status", activity_status);
  277 + }
  278 + if (CommonUtils.isNotEmpty(activity_id)) {
  279 + criteria.andEqualTo("activity_id", activity_id);
  280 + }
  281 + if (CommonUtils.isNotNull(spid)) {
  282 + criteria.andEqualTo("spid", spid);
  283 + }
  284 + if (CommonUtils.isNotNull(shenhe_state)) {
  285 + criteria.andEqualTo("shenhe_state", shenhe_state);
  286 + }
  287 +
  288 + List<ShyLive> shyLiveList = shyLiveMapper.selectByExample(example);
  289 + return shyLiveList;
  290 + }
  291 +
  292 + /**
  293 + * 获得审核类型
  294 + * @param shyChannel
  295 + */
  296 + public void getShenheType(ShyLiveapply shyLiveApply){
  297 +
  298 + //获取直播频道免审sp
  299 + List<Integer> sites = sitesService.getBusinessList(CommonConst.BUSINESS_LIVEAPPLY);
  300 + //初始化一个审核状态
  301 + Integer shenheType=3;//审核类型,1:免审,2:机审,3:人工审
  302 + //如果当前sp是免审sp
  303 + if(sites.contains(shyLiveApply.getSp_id())){
  304 + shenheType=1;//免审
  305 + }
  306 + shyLiveApply.setShenhe_type(shenheType);
  307 + }
  308 +
  309 +
  310 +}
... ...
src/main/java/com/cnlive/shenhe/serviceImpl/LiveServiceImpl.java
1 1 package com.cnlive.shenhe.serviceImpl;
2 2  
3   -import com.alibaba.fastjson.JSON;
4   -import com.alibaba.fastjson.JSONArray;
5   -import com.alibaba.fastjson.JSONObject;
6 3 import com.cnlive.shenhe.bean.ErrorEnum;
7 4 import com.cnlive.shenhe.bean.ResponseBean;
8 5 import com.cnlive.shenhe.entity.ShyLive;
9   -import com.cnlive.shenhe.entity.ShySites;
10 6 import com.cnlive.shenhe.entity.ShyUsers;
11   -import com.cnlive.shenhe.entity.ShyUsersfree;
12   -import com.cnlive.shenhe.entity.ShyVideofilter;
13   -import com.cnlive.shenhe.entity.ShyVideos;
14   -import com.cnlive.shenhe.job.VideosJob;
15 7 import com.cnlive.shenhe.mapper.ShyLiveMapper;
16 8 import com.cnlive.shenhe.mapper.ShySitesMapper;
17 9 import com.cnlive.shenhe.mapper.ShyUsersMapper;
18 10 import com.cnlive.shenhe.mapper.ShyVideosMapper;
19   -import com.cnlive.shenhe.utils.AntiFraudUtil;
20 11 import com.cnlive.shenhe.utils.AuditPass;
21 12 import com.cnlive.shenhe.utils.CommonConst;
22 13 import com.cnlive.shenhe.utils.CommonUtils;
... ... @@ -34,11 +25,7 @@ import tk.mybatis.mapper.entity.Example;
34 25  
35 26 import java.sql.Timestamp;
36 27 import java.text.ParseException;
37   -import java.util.ArrayList;
38   -import java.util.Arrays;
39   -import java.util.HashMap;
40 28 import java.util.List;
41   -import java.util.Map;
42 29  
43 30 /**
44 31 * @Auther: chenhao
... ... @@ -49,33 +36,10 @@ import java.util.Map;
49 36 public class LiveServiceImpl {
50 37 private static Logger logger = LoggerFactory.getLogger(LiveServiceImpl.class);
51 38 @Autowired
52   - ShyVideosMapper shyVideosMapper;
53   - @Autowired
54 39 ShyLiveMapper shyLiveMapper;
55 40 @Autowired
56   - ShySitesMapper shySitesMapper;
57   - @Autowired
58 41 ShyUsersMapper shyUsersMapper;
59 42  
60   - @Autowired
61   - LiveServiceImpl videosService;
62   - @Autowired
63   - SitesServiceImpl sitesService;
64   -
65   - @Autowired
66   - UsersfreeServiceImpl usersfreeServiceImpl;
67   -
68   - @Autowired
69   - VideofilterServiceImpl videofilterServiceImpl;
70   -
71   - @Value("${qn_domain}")
72   - String qn_domain;
73   -
74   - @Value("${ks_domain}")
75   - String ks_domain;
76   -
77   - @Autowired
78   - AuditPass Pass;
79 43  
80 44 //==============
81 45 public boolean impotVideo(ShyLive shyLive) {
... ...
src/main/java/com/cnlive/shenhe/utils/AuditPass.java
... ... @@ -87,6 +87,28 @@ public class AuditPass {
87 87 }
88 88  
89 89 /**
  90 + * 直播视频回调
  91 + *
  92 + * @param activity_id
  93 + * @param state
  94 + * @param attr_tags
  95 + * @param msg
  96 + * @return
  97 + */
  98 + public JSONObject liveApplyPass(String activity_id, int state, String attr_tags, String msg, String callBack) {
  99 + logger.info("直播申请回调:id:{},state:{},attr_tags:{},exceptionMessage:{}", activity_id, state, attr_tags, msg);
  100 + JSONObject params = new JSONObject();
  101 + params.put("id", activity_id);
  102 + params.put("state", state);
  103 + params.put("attr_tags", attr_tags);
  104 + params.put("exceptionMessage", msg);
  105 + HttpUtil httpUtil = HttpUtil.init();
  106 + httpUtil.setParam("param", params.toJSONString());
  107 + Map<String, String> post = httpUtil.post(callBack);
  108 + return JSONObject.parseObject(post.get("result"));
  109 + }
  110 +
  111 + /**
90 112 * 直播云信息同步
91 113 * @param json
92 114 * @param callBack
... ...
src/main/java/com/cnlive/shenhe/utils/CommonConst.java
... ... @@ -83,8 +83,13 @@ public class CommonConst {
83 83 */
84 84 public static Integer BUSINESS_CHANNEL = 4;
85 85  
  86 + /**
  87 + * 白名单业务:直播申请
  88 + */
  89 + public static Integer BUSINESS_LIVEAPPLY = 5;
  90 +
86 91 //白名单设置
87   - public static JSONObject BUSINESS = JSONObject.parseObject("{\"1\":\"点播业务\",\"2\":\"评论业务\",\"3\":\"图文业务\",\"4\":\"频道业务\"}");
  92 + public static JSONObject BUSINESS = JSONObject.parseObject("{\"1\":\"点播业务\",\"2\":\"评论业务\",\"3\":\"图文业务\",\"4\":\"频道业务\",\"5\":\"直播申请业务\"}");
88 93 //通知消息设置
89 94 public static JSONObject NOTICE = JSONObject.parseObject("{\"1\":\"频道通知\",\"2\":\"直播申请通知\"}");
90 95  
... ...