From cdc3690a0354e01b44852f4c9da3b7204128d2eb Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 13 八月 2021 18:46:36 +0800
Subject: [PATCH] 增加苹果内购回调日志,兼容苹果内购

---
 src/main/java/com/yeshi/buwan/controller/admin/api/VideoAdminController.java |  134 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 123 insertions(+), 11 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/controller/admin/api/VideoAdminController.java b/src/main/java/com/yeshi/buwan/controller/admin/api/VideoAdminController.java
index 5ccdcbb..f2d04ca 100644
--- a/src/main/java/com/yeshi/buwan/controller/admin/api/VideoAdminController.java
+++ b/src/main/java/com/yeshi/buwan/controller/admin/api/VideoAdminController.java
@@ -1,17 +1,22 @@
 package com.yeshi.buwan.controller.admin.api;
 
 import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
 
 import javax.annotation.Resource;
 
+import com.google.common.base.Function;
+import com.google.common.collect.Maps;
 import com.google.gson.Gson;
-import com.yeshi.buwan.domain.SolrVideo;
+import com.yeshi.buwan.domain.VideoResource;
+import com.yeshi.buwan.domain.solr.SolrAlbumVideo;
+import com.yeshi.buwan.domain.video.VideoInfoExtra;
 import com.yeshi.buwan.dto.search.SolrResultDTO;
 import com.yeshi.buwan.dto.search.SolrVideoSearchFilter;
 import com.yeshi.buwan.iqiyi.IqiYiNewAPI;
-import com.yeshi.buwan.service.manager.SolrAlbumDataManager;
+import com.yeshi.buwan.service.imp.VideoResourceService;
+import com.yeshi.buwan.service.inter.video.VideoInfoExtraService;
+import com.yeshi.buwan.service.manager.search.SolrAlbumVideoDataManager;
 import com.yeshi.buwan.util.Constant;
 import com.yeshi.buwan.vo.video.VideoAdminInfoVO;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -28,7 +33,6 @@
 import com.yeshi.buwan.service.imp.VideoManager;
 import com.yeshi.buwan.util.JsonUtil;
 import com.yeshi.buwan.util.StringUtil;
-import com.yeshi.buwan.util.TimeUtil;
 import com.yeshi.buwan.web.tag.PageEntity;
 
 import net.sf.json.JSONArray;
@@ -48,6 +52,9 @@
     private ResourceVideoService resourceVideoService;
 
     @Resource
+    private VideoResourceService videoResourceService;
+
+    @Resource
     private IqiyiUtil iqiyiUtil;
 
     @Resource
@@ -57,7 +64,10 @@
     private ThreadPoolTaskExecutor taskExecutor;
 
     @Resource
-    private SolrAlbumDataManager solrAlbumDataManager;
+    private SolrAlbumVideoDataManager solrAlbumDataManager;
+
+    @Resource
+    private VideoInfoExtraService videoInfoExtraService;
 
     @RequestMapping(value = "/changevideoshow", method = RequestMethod.POST)
     public void changeVideoShow(String id, int show, PrintWriter out) {
@@ -85,7 +95,17 @@
     }
 
     @RequestMapping(value = "/videolist", method = RequestMethod.POST)
-    public void videoList(int videotype, int page, String key, String resourceIds, int contenttype, PrintWriter out) {
+    public void videoList(int videotype, int page, String key, String type, String resourceIds, int contenttype, String freeType, String area, PrintWriter out) {
+
+        if (StringUtil.isNullOrEmpty(type)) {
+            type = "name";
+        }
+
+        Integer freeTypeInt = null;
+        if (!StringUtil.isNullOrEmpty(freeType)) {
+            freeTypeInt = Integer.parseInt(freeType);
+        }
+
 
         List<VideoInfo> list = null;
         long count = 0;
@@ -93,7 +113,20 @@
         //姝g墖鎼滅储
         if (contenttype == 1) {
             SolrVideoSearchFilter filter = new SolrVideoSearchFilter();
-            filter.setKey(key);
+
+            switch (type) {
+                case "name":
+                    filter.setKey(key);
+                    break;
+                case "actor":
+                    filter.setActor(key);
+                    break;
+                case "director":
+                    filter.setDirector(key);
+                    break;
+            }
+
+
             filter.setVideoType(videotype == 0 ? null : videotype);
             filter.setContentType(1);
             if (!StringUtil.isNullOrEmpty(resourceIds)) {
@@ -102,15 +135,25 @@
                 for (int i = 0; i < array.size(); i++) {
                     rids[i] = array.optString(i);
                 }
-                filter.setResourceIds(rids);
+                filter.setResourceIds(Arrays.asList(rids));
             }
 
             filter.setSortKey("updateTime");
 
+            filter.setFreeType(freeTypeInt);
+
+            filter.setArea(StringUtil.isNullOrEmpty(area) ? null : area.trim());
+
+            List<VideoResource> resourceList = videoResourceService.getResourceList();
+            Map<Long, String> resourceMap = new HashMap<>();
+            for (VideoResource vr : resourceList) {
+                resourceMap.put(Long.parseLong(vr.getId()), vr.getName());
+            }
+
             SolrResultDTO dto = solrAlbumDataManager.find(filter, page, Constant.pageCount);
             if (dto.getVideoList() != null)
-                for (SolrVideo videoInfo : dto.getVideoList())
-                    voList.add(VideoAdminInfoVO.create(videoInfo));
+                for (SolrAlbumVideo videoInfo : (List<SolrAlbumVideo>) dto.getVideoList())
+                    voList.add(VideoAdminInfoVO.create(videoInfo,resourceMap));
             count = dto.getTotalCount();
         } else {
             list = classService.getTypeVideoListAdmin(videotype == 0 ? "" : videotype + "", page, key,
@@ -120,6 +163,38 @@
                 for (VideoInfo videoInfo : list)
                     voList.add(VideoAdminInfoVO.create(videoInfo));
         }
+
+        List<String> ids = new ArrayList<>();
+        for (VideoAdminInfoVO a : voList) {
+            ids.add(a.getId());
+        }
+
+        List<VideoInfoExtra> extraList = videoInfoExtraService.listByIds(ids);
+
+        Map<String, VideoInfoExtra> maps = Maps.uniqueIndex(extraList.iterator(), new Function<VideoInfoExtra, String>() {
+            @Override
+            public String apply(VideoInfoExtra extra) {
+                return extra.getId();
+            }
+        });
+        //杩囨护鍥剧墖
+        for (VideoAdminInfoVO a : voList) {
+            VideoInfoExtra extra = maps.get(a.getId());
+            if (extra != null) {
+
+                if (a.getHpicture() != null) {
+                    if (!StringUtil.isNullOrEmpty(extra.gethPosterPicture()))
+                        a.setHpicture(extra.gethPosterPicture());
+                }
+
+                if (a.getVpicture() != null) {
+                    if (!StringUtil.isNullOrEmpty(extra.getvPosterPicture()))
+                        a.setVpicture(extra.getvPosterPicture());
+                }
+            }
+        }
+
+
         JSONObject object = new JSONObject();
         object.put("code", 0);
         JSONObject data = new JSONObject();
@@ -188,5 +263,42 @@
         out.print(data);
     }
 
+    @RequestMapping("getVideoInfoExtra")
+    public void getVideoInfoExtra(String id, PrintWriter out) {
+        VideoInfoExtra extra = videoInfoExtraService.getById(id);
+        JSONObject object = new JSONObject();
+        if (extra != null) {
+            object.put("code", 0);
+            object.put("data", new Gson().toJson(extra));
+        } else {
+            object.put("code", 1);
+            object.put("msg", "鏃犻檮鍔犱俊鎭�");
+        }
+        out.print(object);
+    }
+
+    @RequestMapping("updateVideoInfoExtra")
+    public void updateVideoInfoExtra(String id, String vPicture, String hPicture, PrintWriter out) {
+        VideoInfoExtra extra = new VideoInfoExtra();
+        extra.setId(id);
+        if (StringUtil.isNullOrEmpty(vPicture)) {
+            vPicture = "";
+        }
+
+        extra.setvPosterPicture(vPicture);
+
+        if (StringUtil.isNullOrEmpty(hPicture)) {
+            hPicture = "";
+        }
+
+        extra.sethPosterPicture(hPicture);
+
+        videoInfoExtraService.save(extra);
+
+        JSONObject object = new JSONObject();
+        object.put("code", 0);
+        out.print(object);
+    }
+
 
 }

--
Gitblit v1.8.0