瀏覽代碼

Merge remote-tracking branch 'origin/master'

syh 5 年之前
父節點
當前提交
678501e2cf

+ 6 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java

@@ -163,6 +163,8 @@ public class MaterialInfoController {
                                                      HttpServletRequest req) {
 
         Result<IPage<MaterialInfo>> result = new Result<>();
+        String materialName = materialInfo.getMaterialName();
+        materialInfo.setMaterialName(null);
         QueryWrapper<MaterialInfo> queryWrapper = new QueryWrapper<>();
         Object createTime = materialInfo.getCreateTime();
         materialInfo.setCreateTime(null);
@@ -199,6 +201,10 @@ public class MaterialInfoController {
                 }
             }
         }
+        if (!Check.isNull(materialName)) {
+            queryWrapper.like("material_name", materialName);
+
+        }
         Page<MaterialInfo> page = new Page<>(pageNo, pageSize);
         IPage<MaterialInfo> pageList = materialInfoService.page(page, queryWrapper);
         List<MaterialInfo> materialInfoList = pageList.getRecords();

+ 20 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialCutFrameServiceImpl.java

@@ -344,7 +344,25 @@ public class MaterialCutFrameServiceImpl extends ServiceImpl<MaterialCutFrameMap
             this.save(coveCutFrame);
             LoadFileUtil.delFile(coverCutFramePath);
             // 请求从数据接口 获取其余14张截图
+            getCut(materialId, videoUrl, loadImage, 1);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+
+    }
+
+
+    private void getCut(String materialId, String videoUrl, String loadImage, Integer count) {
+        try {
             Map<String, Object> coverMap = CloudVideoProcessUtil.videoCutFrameHandle(videoUrl, loadImage);
+            if (Check.isNullMap(coverMap) && count < 4) {
+                getCut(materialId, videoUrl, loadImage, count + 1);
+            }
+
+            if (Check.isNullMap(coverMap)) {
+                return;
+            }
             for (int i = 0; i <= 13; i++) {
                 String url = (String) coverMap.get(String.valueOf(i));
                 if (!Check.isNull(url)) {
@@ -360,8 +378,10 @@ public class MaterialCutFrameServiceImpl extends ServiceImpl<MaterialCutFrameMap
                 }
 
             }
+
         } catch (Exception e) {
             e.printStackTrace();
+
         }
 
 

+ 6 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -1133,6 +1133,7 @@ public class BatchController {
                 queryWrapper.between("stat_date", startDate, endDate);
             }
             queryWrapper.orderByDesc("stat_date");
+            queryWrapper.orderByDesc("photo_id");
             queryWrapper.groupBy("signature");
             Page<KuaiShouVideoGet> page = new Page<>(pageNo, pageSize);
             IPage<KuaiShouVideoGet> pageList = kuaiShouVideoGetService.page(page, queryWrapper);
@@ -1695,7 +1696,7 @@ public class BatchController {
             }
             JSONArray unitIds = requestJson.getJSONArray("unitIds");
             if (Check.isNull(unitIds)) {
-                throw new Exception("请选择需要修改的广告组");
+                throw new Exception("请选择需要复制的广告组");
             }
 
             Long copyToCampaignId = requestJson.getLong("copyToCampaignId");
@@ -1707,6 +1708,7 @@ public class BatchController {
                     continue;
                 }
                 kuaiShouGroupService.getGroupByUnitId(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitId);
+                kuaiShouGroupService.getCreativeByUnit(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitId);
                 QueryWrapper<KuaiShouGroup> queryWrapper = new QueryWrapper<>();
                 queryWrapper.eq("account_id", accountId);
                 queryWrapper.eq("unit_id", unitId);
@@ -1769,6 +1771,7 @@ public class BatchController {
 
             Long unitId = requestJson.getLong("unitId");
             kuaiShouGroupService.getGroupByUnitId(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitId);
+            kuaiShouGroupService.getCreativeByUnit(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitId);
             Long copyToCampaignId = requestJson.getLong("copyToCampaignId");
             JSONArray failArr = new JSONArray();
             Integer createCount = requestJson.getInteger("createCount");
@@ -1868,6 +1871,8 @@ public class BatchController {
             if (Check.isNull(oauthToken)) {
                 throw new Exception("未获取到账户信息");
             }
+            Long copyUnitId = requestJson.getLong("copyUnitId");
+            kuaiShouGroupService.getCreativeByUnit(oauthToken.getAccessToken(), oauthToken.getAccountId(), copyUnitId);
             JSONObject returnJson = new JSONObject();
             JSONObject groupJson = requestJson.getJSONObject("groupArr");
             requestJson.remove("groupArr");

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouGroupService.java

@@ -14,4 +14,6 @@ public interface IKuaiShouGroupService extends IService<KuaiShouGroup> {
     void getGroupList(String accessToken, Long accountId);
 
     void getGroupByUnitId(String accessToken, Long accountId, Long unitId);
+
+    void getCreativeByUnit(String accessToken, Long accountId, Long unitId);
 }

+ 116 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java

@@ -10,6 +10,7 @@ import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupTargetMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouScheduleMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -44,6 +45,8 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
     @Autowired
     private KuaiShouGroupTargetMapper groupTargetMapper;
     private static ExecutorService executorService = Executors.newFixedThreadPool(10);
+    @Autowired
+    private IKuaiShouCreativeService creativeService;
 
 
     /**
@@ -139,6 +142,119 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
     }
 
 
+    /**
+     * 根据组获取创意
+     *
+     * @param accessToken
+     * @param accountId
+     * @param unitId
+     */
+    @Override
+    public void getCreativeByUnit(String accessToken, Long accountId, Long unitId) {
+
+        try {
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Content-Type", " application/json");
+            headers.put("Access-Token", accessToken);
+            JSONObject param = new JSONObject();
+            param.put("advertiser_id", accountId);
+            param.put("page_size", 200);
+
+
+            param.put("unit_id", unitId);
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (Check.isNull(resultJson)) {
+                log.error("获取广告创意返回结果为空,advertiserId:{}", accountId);
+                return;
+            }
+            Integer code = resultJson.getInteger("code");
+            String message = resultJson.getString("message");
+            if (null == code || code != 0) {
+                log.error("获取广告创意返回结果异常,advertiserId:{},message:{}", accountId, message);
+                return;
+            }
+            JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+            if (null == details || details.size() <= 0) {
+                return;
+            }
+            for (int i = 0; i < details.size(); i++) {
+                JSONObject detailJson = JSONObject.parseObject(details.get(i).toString());
+                if (!Check.isNull(detailJson)) {
+                    KuaiShouCreative creative = new KuaiShouCreative();
+                    creative.setId("" + accountId + detailJson.getLong("creative_id"));
+                    creative.setAccountId(accountId);
+                    creative.setCampaignId(detailJson.getLong("campaign_id"));
+                    creative.setUnitId(detailJson.getLong("unit_id"));
+                    creative.setCreativeId(detailJson.getLong("creative_id"));
+                    creative.setCreativeName(detailJson.getString("creative_name"));
+                    creative.setCreativeMaterialType(detailJson.getInteger("creative_material_type"));
+                    if (!Check.isNull(detailJson.getJSONArray("material_url"))) {
+                        creative.setMaterialUrl(detailJson.getJSONArray("material_url").toJSONString());
+                    }
+
+                    if (!Check.isNull(detailJson.getJSONArray("image_tokens"))) {
+                        creative.setImageTokens(detailJson.getJSONArray("image_tokens").toJSONString());
+                    }
+                    creative.setStatus(detailJson.getInteger("status"));
+                    creative.setPutStatus(detailJson.getInteger("put_status"));
+                    creative.setCreateChannel(detailJson.getInteger("create_channel"));
+                    creative.setReviewDetail(detailJson.getString("review_detail"));
+                    creative.setCoverUrl(detailJson.getString("cover_url"));
+                    creative.setImageToken(detailJson.getString("image_token"));
+                    creative.setCoverWidth(detailJson.getString("cover_width"));
+                    creative.setCoverHeight(detailJson.getString("cover_height"));
+                    creative.setOverlayBgUrl(detailJson.getString("overlay_bg_url"));
+                    creative.setOverlayBgImageToken(detailJson.getString("overlay_bg_image_token"));
+                    creative.setStickerTitle(detailJson.getString("sticker_title"));
+                    creative.setOverlayType(detailJson.getString("overlay_type"));
+                    creative.setClickTrackUrl(detailJson.getString("click_track_url"));
+                    creative.setImpressionUrl(detailJson.getString("impression_url"));
+                    creative.setAdPhotoPlayedT3sUrl(detailJson.getString("ad_photo_played_t3s_url"));
+                    creative.setCreativeCreateTime(detailJson.getDate("create_time"));
+                    creative.setCreativeUpdateTime(detailJson.getDate("update_time"));
+                    creative.setFirstFrameType(detailJson.getInteger("first_frame_type"));
+                    JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
+                    if (!Check.isNull(displayInfoJson)) {
+                        creative.setDescription(displayInfoJson.getString("description"));
+                        creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
+                    }
+                    creative.setCreateTime(new Date());
+                    creative.setUpdateTime(new Date());
+                    creative.setSiteId(detailJson.getLong("site_id"));
+                    creative.setPhotoId(detailJson.getString("photo_id"));
+                    if (detailJson.getLong("photo_id") == 0) {
+                        JSONArray photoIds = new JSONArray();
+                        JSONObject programmed_creative_material = detailJson.getJSONObject("programmed_creative_material");
+                        if (!Check.isNull(programmed_creative_material)) {
+                            creative.setProgrammedCreativeMaterial(programmed_creative_material.toJSONString());
+                            JSONArray materials = programmed_creative_material.getJSONArray("materials");
+                            if (!Check.isNull(materials)) {
+                                for (int j = 0; j < materials.size(); j++) {
+                                    JSONObject materialJson = materials.getJSONObject(j);
+                                    if (!Check.isNull(materialJson)) {
+                                        Long photo_id = materialJson.getLong("photo_id");
+                                        photoIds.add(String.valueOf(photo_id));
+                                    }
+                                }
+                                creative.setPhotoIds(photoIds.toJSONString());
+                            }
+                        }
+                    }
+                    creativeService.saveOrUpdate(creative);
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+
+        }
+
+
+    }
+
+
     private void addGroupV2(Long advertiserId, JSONArray details) {
         if (!Check.isNull(details)) {
             List<KuaiShouGroup> groups = new ArrayList<>();

+ 2 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -2984,10 +2984,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             param.put("advertiser_id", accountId);
             param.put("page_size", 200);
 
-            Map<String, Object> deleteMap = new HashMap<>();
+           /* Map<String, Object> deleteMap = new HashMap<>();
             deleteMap.put("account_id", accountId);
             deleteMap.put("campaign_id", campaignId);
-            creativeService.removeByMap(deleteMap);
+            creativeService.removeByMap(deleteMap);*/
             QueryWrapper<KuaiShouGroup> groupQueryWrapper = new QueryWrapper<>();
             groupQueryWrapper.eq("account_id", accountId);
             groupQueryWrapper.eq("campaign_id", campaignId);