syh 4 gadi atpakaļ
vecāks
revīzija
c15fe78bfe
29 mainītis faili ar 537 papildinājumiem un 292 dzēšanām
  1. 82 82
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 20 13
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  3. 7 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialInfo.java
  4. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/HttpUtils.java
  5. 13 11
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/oceanengine/service/impl/OceanEngineServiceImpl.java
  6. 48 45
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadImageServiceImpl.java
  7. 1 1
      module-job-bytedance/src/main/resources/application.yml
  8. 1 1
      module-job-kuaishou/src/main/resources/application.yml
  9. 1 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  10. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouCampaignController.java
  11. 5 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java
  12. 93 43
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/MaterialRefuseController.java
  13. 2 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCreative.java
  14. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml
  15. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCreativeService.java
  16. 1 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java
  17. 22 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  18. 113 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreativeServiceImpl.java
  19. 3 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java
  20. 5 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java
  21. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouVideoGetServiceImpl.java
  22. 3 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  23. 7 9
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java
  24. 2 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaiShouYiCheReportMapper.xml
  25. 61 27
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml
  26. 5 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyAccountService.java
  27. 29 26
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAccountServiceImpl.java
  28. 4 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceCampaignController.java
  29. 2 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceAccountReportMapper.xml

+ 82 - 82
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -20,6 +20,7 @@ import java.util.*;
  * @Version 1.0
  */
 public class DateUtils extends PropertyEditorSupport {
+
     private static Logger logger = LoggerFactory.getLogger(DateUtils.class);
 
     public static ThreadLocal<SimpleDateFormat> date_sdf = new ThreadLocal<SimpleDateFormat>() {
@@ -66,10 +67,10 @@ public class DateUtils extends PropertyEditorSupport {
     };
 
     // 以毫秒表示的时间
-    private static final long DAY_IN_MILLIS = 24 * 3600 * 1000;
-    private static final long HOUR_IN_MILLIS = 3600 * 1000;
-    private static final long MINUTE_IN_MILLIS = 60 * 1000;
-    private static final long SECOND_IN_MILLIS = 1000;
+    private static final long DAY_IN_MILLIS = 24 * 3600 * 1000L;
+    private static final long HOUR_IN_MILLIS = 3600 * 1000L;
+    private static final long MINUTE_IN_MILLIS = 60 * 1000L;
+    private static final long SECOND_IN_MILLIS = 1000L;
 
     // 指定模式的时间格式
     private static SimpleDateFormat getSDFormat(String pattern) {
@@ -80,9 +81,7 @@ public class DateUtils extends PropertyEditorSupport {
     public static Date getNowDate() throws ParseException {
         SimpleDateFormat dsdf = new SimpleDateFormat("yyyy-MM-dd");
         String nowDate = getNowDate("yyyy-MM-dd");
-        Date parse = dsdf.parse(nowDate);
-        return parse;
-
+        return dsdf.parse(nowDate);
     }
 
 
@@ -95,8 +94,7 @@ public class DateUtils extends PropertyEditorSupport {
     public static String getDateByDateStr(String dateStr) throws ParseException {
         SimpleDateFormat dsdf = new SimpleDateFormat("yyyy-MM-dd");
         Date parse = dsdf.parse(dateStr);
-        String day = dsdf.format(parse);
-        return day;
+        return dsdf.format(parse);
     }
 
     public static Integer getHour(String dateStr) throws ParseException {
@@ -104,10 +102,7 @@ public class DateUtils extends PropertyEditorSupport {
         Calendar cal = Calendar.getInstance();
         Date date = sdf.parse(dateStr);
         cal.setTime(date);
-        Integer hour = cal.get(Calendar.HOUR_OF_DAY);
-        return hour;
-
-
+        return cal.get(Calendar.HOUR_OF_DAY);
     }
 
     /**
@@ -155,58 +150,6 @@ public class DateUtils extends PropertyEditorSupport {
         return list;
     }
 
-    public static List<Map<String, String>> getDateWeekRange(String startDate, String endDate) throws ParseException {
-        List<Map<String, String>> list = new ArrayList<Map<String, String>>();
-        String splitDate = DateUtils.addWeek(endDate, -1);
-        splitDate = DateUtils.addDay(splitDate, 1);
-        if (DateUtils.compareDate(startDate, splitDate) >= 0) {
-            Map<String, String> map = new HashMap<String, String>();
-            map.put("startDate", startDate);
-            map.put("endDate", endDate);
-            list.add(map);
-        } else {
-            while (DateUtils.compareDate(startDate, splitDate) < 0 || DateUtils.compareDate(startDate, endDate) <= 0) {
-                Map<String, String> map = new HashMap<String, String>();
-                map.put("startDate", splitDate);
-                map.put("endDate", endDate);
-                list.add(map);
-                splitDate = DateUtils.addWeek(splitDate, -1);
-                endDate = DateUtils.addWeek(endDate, -1);
-                if (DateUtils.compareDate(startDate, splitDate) > 0) {
-                    splitDate = startDate;
-                }
-            }
-        }
-        return list;
-    }
-
-    public static List<Map<String, String>> getDateMonthRange(String startDate, String endDate) throws ParseException {
-        List<Map<String, String>> list = new ArrayList<Map<String, String>>();
-        String splitDate = DateUtils.addMonth(endDate, -1);
-        splitDate = DateUtils.addDay(splitDate, 1);
-        if (DateUtils.compareDate(startDate, splitDate) >= 0) {
-            Map<String, String> map = new HashMap<String, String>();
-            map.put("startDate", startDate);
-            map.put("endDate", endDate);
-            list.add(map);
-        } else {
-            while (DateUtils.compareDate(startDate, splitDate) < 0 || DateUtils.compareDate(startDate, endDate) <= 0) {
-                Map<String, String> map = new HashMap<String, String>();
-                map.put("startDate", splitDate);
-                map.put("endDate", endDate);
-                list.add(map);
-                splitDate = DateUtils.addMonth(splitDate, -1);
-                endDate = DateUtils.addMonth(endDate, -1);
-                if (DateUtils.compareDate(startDate, splitDate) > 0) {
-                    splitDate = startDate;
-                }
-            }
-        }
-        return list;
-    }
-
-
-
     /**
      * 当前日历,这里用中国时间表示
      *
@@ -319,9 +262,6 @@ public class DateUtils extends PropertyEditorSupport {
      */
     public static String getDate(String format) {
         Date date = new Date();
-        if (null == date) {
-            return null;
-        }
         SimpleDateFormat sdf = new SimpleDateFormat(format);
         return sdf.format(date);
     }
@@ -388,8 +328,7 @@ public class DateUtils extends PropertyEditorSupport {
         Date dt = new Date();
         DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String nowTime = df.format(dt);
-        java.sql.Timestamp buydate = java.sql.Timestamp.valueOf(nowTime);
-        return buydate;
+        return Timestamp.valueOf(nowTime);
     }
 
     // ////////////////////////////////////////////////////////////////////////////
@@ -603,7 +542,8 @@ public class DateUtils extends PropertyEditorSupport {
      * @return 指定日期按“时:分“格式显示
      */
     public static String formatShortTime(Calendar cal) {
-        return short_time_sdf.get().format(cal.getTime());
+        SimpleDateFormat shortTimeSdf = new SimpleDateFormat("HH:mm");
+        return shortTimeSdf.format(cal.getTime());
     }
 
     /**
@@ -613,7 +553,8 @@ public class DateUtils extends PropertyEditorSupport {
      * @return 指定日期按“时:分“格式显示
      */
     public static String formatShortTime(Date date) {
-        return short_time_sdf.get().format(date);
+        SimpleDateFormat shortTimeSdf = new SimpleDateFormat("HH:mm");
+        return shortTimeSdf.format(date);
     }
 
     // ////////////////////////////////////////////////////////////////////////////
@@ -630,10 +571,15 @@ public class DateUtils extends PropertyEditorSupport {
      * @param pattern 转换的匹配格式
      * @return 如果转换成功则返回转换后的日期
      * @throws ParseException
+     * @throws
      */
-    public static Date parseDate(String src, String pattern) throws ParseException {
-        return getSDFormat(pattern).parse(src);
-
+    public static Date parseDate(String src, String pattern) {
+        try {
+            return getDateFormat(pattern).parse(src);
+        } catch (ParseException e) {
+            e.printStackTrace();
+            return null;
+        }
     }
 
     /**
@@ -642,9 +588,9 @@ public class DateUtils extends PropertyEditorSupport {
      * @param src     将要转换的原始字符窜
      * @param pattern 转换的匹配格式
      * @return 如果转换成功则返回转换后的日期
-     * @throws ParseException
+     * @throws
      */
-    public static Calendar parseCalendar(String src, String pattern) throws ParseException {
+    public static Calendar parseCalendar(String src, String pattern){
 
         Date date = parseDate(src, pattern);
         Calendar cal = Calendar.getInstance();
@@ -652,7 +598,7 @@ public class DateUtils extends PropertyEditorSupport {
         return cal;
     }
 
-    public static String formatAddDate(String src, String pattern, int amount) throws ParseException {
+    public static String formatAddDate(String src, String pattern, int amount) {
         Calendar cal;
         cal = parseCalendar(src, pattern);
         cal.add(Calendar.DATE, amount);
@@ -666,8 +612,9 @@ public class DateUtils extends PropertyEditorSupport {
      * @param pattern 转换的匹配格式
      * @return 如果转换成功则返回转换后的时间戳
      * @throws ParseException
+     * @throws
      */
-    public static Timestamp parseTimestamp(String src, String pattern) throws ParseException {
+    public static Timestamp parseTimestamp(String src, String pattern) {
         Date date = parseDate(src, pattern);
         return new Timestamp(date.getTime());
     }
@@ -767,13 +714,15 @@ public class DateUtils extends PropertyEditorSupport {
      * HH:mm:ss“ * @param text String类型的时间值
      */
     @Override
-    public void setAsText(String text) throws IllegalArgumentException {
+    public void setAsText(String text) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat datetimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         if (StringUtils.hasText(text)) {
             try {
                 if (text.indexOf(":") == -1 && text.length() == 10) {
-                    setValue(DateUtils.date_sdf.get().parse(text));
+                    setValue(format.parse(text));
                 } else if (text.indexOf(":") > 0 && text.length() == 19) {
-                    setValue(DateUtils.datetimeFormat.get().parse(text));
+                    setValue(datetimeFormat.parse(text));
                 } else {
                     throw new IllegalArgumentException("Could not parse date, date format is error ");
                 }
@@ -805,6 +754,57 @@ public class DateUtils extends PropertyEditorSupport {
             return null;
         }
     }
+
+    public static List<Map<String, String>> getDateWeekRange(String startDate, String endDate) throws ParseException {
+        List<Map<String, String>> list = new ArrayList<>();
+        String splitDate = DateUtils.addWeek(endDate, -1);
+        splitDate = DateUtils.addDay(splitDate, 1);
+        if (DateUtils.compareDate(startDate, splitDate) >= 0) {
+            Map<String, String> map = new HashMap<>();
+            map.put("startDate", startDate);
+            map.put("endDate", endDate);
+            list.add(map);
+        } else {
+            while (DateUtils.compareDate(startDate, splitDate) < 0 || DateUtils.compareDate(startDate, endDate) <= 0) {
+                Map<String, String> map = new HashMap<>();
+                map.put("startDate", splitDate);
+                map.put("endDate", endDate);
+                list.add(map);
+                splitDate = DateUtils.addWeek(splitDate, -1);
+                endDate = DateUtils.addWeek(endDate, -1);
+                if (DateUtils.compareDate(startDate, splitDate) > 0) {
+                    splitDate = startDate;
+                }
+            }
+        }
+        return list;
+    }
+
+    public static List<Map<String, String>> getDateMonthRange(String startDate, String endDate) throws ParseException {
+        List<Map<String, String>> list = new ArrayList<>();
+        String splitDate = DateUtils.addMonth(endDate, -1);
+        splitDate = DateUtils.addDay(splitDate, 1);
+        if (DateUtils.compareDate(startDate, splitDate) >= 0) {
+            Map<String, String> map = new HashMap<>();
+            map.put("startDate", startDate);
+            map.put("endDate", endDate);
+            list.add(map);
+        } else {
+            while (DateUtils.compareDate(startDate, splitDate) < 0 || DateUtils.compareDate(startDate, endDate) <= 0) {
+                Map<String, String> map = new HashMap<>();
+                map.put("startDate", splitDate);
+                map.put("endDate", endDate);
+                list.add(map);
+                splitDate = DateUtils.addMonth(splitDate, -1);
+                endDate = DateUtils.addMonth(endDate, -1);
+                if (DateUtils.compareDate(startDate, splitDate) > 0) {
+                    splitDate = startDate;
+                }
+            }
+        }
+        return list;
+    }
+
     public static String addMonth(String dateString, int month) throws ParseException {
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         Date date = sdf.parse(dateString);

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

@@ -208,9 +208,14 @@ public class MaterialInfoController {
 
         Result<IPage<MaterialInfo>> result = new Result<>();
         String materialName = materialInfo.getMaterialName();
+        String startDate = materialInfo.getStartDate();
+        String endDate = materialInfo.getEndDate();
+        materialInfo.setStartDate(null);
+        materialInfo.setEndDate(null);
+
+
         materialInfo.setMaterialName(null);
         QueryWrapper<MaterialInfo> queryWrapper = new QueryWrapper<>();
-        Object createTime = materialInfo.getCreateTime();
         materialInfo.setCreateTime(null);
         if (!Check.isNull(materialInfo.getUserId())) {
             String roleCode = materialInfoService.getRoleCodeByUserId(materialInfo.getUserId());
@@ -234,12 +239,11 @@ public class MaterialInfoController {
             } else {
                 queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());
             }
-            if (!Check.isNull(createTime)) {
+            if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
                 try {
-                    String dateString = DateUtils.getDateString(String.valueOf(createTime));
-                    Map<String, Object> map = DateUtils.getStartEndTime(dateString);
-                    queryWrapper.ge("create_time", map.get("start"));
-                    queryWrapper.lt("create_time", map.get("end"));
+                    String startDateStr = DateUtils.getDateString(startDate);
+                    String endDateStr = DateUtils.getDateString(endDate);
+                    queryWrapper.between("create_time", startDateStr, DateUtils.getEndTime(endDateStr));
                 } catch (ParseException e) {
                     e.printStackTrace();
                 }
@@ -326,9 +330,13 @@ public class MaterialInfoController {
         Result<IPage<MaterialInfo>> result = new Result<>();
         String materialName = materialInfo.getMaterialName();
         materialInfo.setMaterialName(null);
+        String startDate = materialInfo.getStartDate();
+        String endDate = materialInfo.getEndDate();
+        materialInfo.setStartDate(null);
+        materialInfo.setEndDate(null);
+
         QueryWrapper<MaterialInfo> queryWrapper = new QueryWrapper<>();
-        Object createTime = materialInfo.getCreateTime();
-        materialInfo.setCreateTime(null);
+
         if (!Check.isNull(materialInfo.getUserId())) {
             String roleCode = materialInfoService.getRoleCodeByUserId(materialInfo.getUserId());
             if (CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)) {
@@ -340,12 +348,11 @@ public class MaterialInfoController {
 
             queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());
 
-            if (!Check.isNull(createTime)) {
+            if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
                 try {
-                    String dateString = DateUtils.getDateString(String.valueOf(createTime));
-                    Map<String, Object> map = DateUtils.getStartEndTime(dateString);
-                    queryWrapper.ge("create_time", map.get("start"));
-                    queryWrapper.lt("create_time", map.get("end"));
+                    String startDateStr = DateUtils.getDateString(startDate);
+                    String endDateStr = DateUtils.getDateString(endDate);
+                    queryWrapper.between("create_time", startDateStr, DateUtils.getEndTime(endDateStr));
                 } catch (ParseException e) {
                     e.printStackTrace();
                 }

+ 7 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialInfo.java

@@ -168,4 +168,11 @@ public class MaterialInfo {
     private String supplierCode; // 素造供应商
 
 
+    @TableField(exist = false)
+    private String startDate;  // 是否有未审核封面
+
+    @TableField(exist = false)
+    private String endDate;  // 是否有未审核封面
+
+
 }

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/utils/HttpUtils.java

@@ -276,7 +276,7 @@ public class HttpUtils {
             if (param != null && param.size() > 0) {
                 httppost.setEntity(new StringEntity(new Gson().toJson(param), Charset.forName("UTF-8")));
             }
-            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(120 * 1000).setConnectTimeout(120 * 1000).build();
+            RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(300 * 1000).setConnectTimeout(300 * 1000).build();
             httppost.setConfig(requestConfig);
             HttpEntity respentity;
 

+ 13 - 11
module-crawler/src/main/java/cn/com/ctop/crawler/modules/oceanengine/service/impl/OceanEngineServiceImpl.java

@@ -1,8 +1,9 @@
 package cn.com.ctop.crawler.modules.oceanengine.service.impl;
 
 import cn.com.ctop.common.module.utils.Base64Utils;
+import cn.com.ctop.common.module.utils.CosUtils;
 import cn.com.ctop.common.module.utils.HttpUtils2;
-import cn.com.ctop.common.module.utils.OSSUtils;
+import cn.com.ctop.common.module.vo.ResFileDTO;
 import cn.com.ctop.crawler.modules.core.util.FateadmHttpUtil;
 import cn.com.ctop.crawler.modules.core.util.FateadmUtil;
 import cn.com.ctop.crawler.modules.core.util.FfmpegUtils;
@@ -30,7 +31,6 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.io.FileInputStream;
-import java.io.InputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.util.*;
@@ -56,8 +56,7 @@ public class OceanEngineServiceImpl implements IOceanEngineService {
             conn.addRequestProperty("User-Agent",
                     "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.8) Firefox/3.6.8");
             conn.connect();
-            String location = conn.getHeaderField("Location");
-            return location;
+            return conn.getHeaderField("Location");
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -76,7 +75,7 @@ public class OceanEngineServiceImpl implements IOceanEngineService {
                 if (node.get("data") != null&&node.get("data").get("materials")!=null) {
                     String dataJson = node.get("data").get("materials").toString();
                     List<HotMaterial> list = mapper.readValue(dataJson,new TypeReference<List<HotMaterial>>() {});
-                    if(list != null && list.size() > 0){
+                    if(list != null && !list.isEmpty()){
                         for (HotMaterial material : list){
                             material.setAppCode(appCode);
                             material.setAppName(appName);
@@ -90,8 +89,9 @@ public class OceanEngineServiceImpl implements IOceanEngineService {
                                 base64Code = FfmpegUtils.getVideoFirstImage(material.getVideoUrl(),20);
                             }
                             EffectCase.base64ToFile("/mnt/crawler/hotmat/",base64Code,material.getVid()+".jpg");
-                            String coverUrl = OSSUtils.uploadFile2OSS(new FileInputStream("/mnt/crawler/hotmat/"+material.getVid()+".jpg"),"ocean-engine/hot-material/",material.getVid()+".jpg");
-                            material.setCoverUrl(coverUrl);
+                            String fileSavePath = "/mnt/crawler/hotmat/"+material.getVid()+".jpg";
+                            ResFileDTO dto = CosUtils.uploadDetailInputStream(new FileInputStream(fileSavePath),material.getVid()+".jpg","jpg",1000L,"ocean-engine/hot-material/");
+                            material.setCoverUrl(dto.getFileUrl());
                             hotMaterialService.saveOrUpdate(material);
                         }
                         hotMaterialHandler(page+1,appCode,appName);
@@ -160,8 +160,9 @@ public class OceanEngineServiceImpl implements IOceanEngineService {
                         base64Code = FfmpegUtils.getVideoFirstImage(effectCase.getVideoUrl(),20);
                     }
                     EffectCase.base64ToFile("/mnt/crawler/effectcase/",base64Code,effectCase.getVid()+".jpg");
-                    String coverUrl = OSSUtils.uploadFile2OSS(new FileInputStream("/mnt/crawler/effectcase/"+effectCase.getVid()+".jpg"),"ocean-engine/effect-case/",effectCase.getVid()+".jpg");
-                    effectCase.setCoverUrl(coverUrl);
+                    String fileSavePath = "/mnt/crawler/effectcase/"+effectCase.getVid()+".jpg";
+                    ResFileDTO dto = CosUtils.uploadDetailInputStream(new FileInputStream(fileSavePath),effectCase.getVid()+".jpg","jpg",1000L,"ocean-engine/effect-case/");
+                    effectCase.setCoverUrl(dto.getFileUrl());
                     effectCase.setCreativeLabel(getCase.getString("creative_label"));
                 }
                 effectCaseService.saveOrUpdate(effectCase);
@@ -200,8 +201,9 @@ public class OceanEngineServiceImpl implements IOceanEngineService {
                                 base64Code = FfmpegUtils.getVideoFirstImage(douyinHot.getUrl(),20);
                             }
                             EffectCase.base64ToFile("/mnt/crawler/douyinhot/",base64Code,douyinHot.getMid()+".jpg");
-                            String coverUrl = OSSUtils.uploadFile2OSS(new FileInputStream("/mnt/crawler/douyinhot/"+douyinHot.getMid()+".jpg"),"ocean-engine/doyin-hot/",douyinHot.getMid()+".jpg");
-                            douyinHot.setCoverUrl(coverUrl);
+                            String fileSavePath = "/mnt/crawler/douyinhot/"+douyinHot.getMid()+".jpg";
+                            ResFileDTO dto = CosUtils.uploadDetailInputStream(new FileInputStream(fileSavePath),douyinHot.getMid()+".jpg","jpg",1000L,"ocean-engine/doyin-hot/");
+                            douyinHot.setCoverUrl(dto.getFileUrl());
                             douyinHotService.saveOrUpdate(douyinHot);
                         }
                         douyinHotHandler(page+1,listType);

+ 48 - 45
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadImageServiceImpl.java

@@ -8,7 +8,6 @@ import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
 import cn.com.ctop.manage.modules.material.service.IMaterialUploadImageService;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.SneakyThrows;
@@ -49,7 +48,7 @@ public class MaterialUploadImageServiceImpl implements IMaterialUploadImageServi
      * 同步素材到账号下
      */
     @Override
-    public void uploadImage(String videoId, Long accountId, String accessToken){
+    public synchronized void uploadImage(String videoId, Long accountId, String accessToken) {
         try {
             List<JSONObject> imageList = materialImageInfoService.getUrlList(videoId);
             if (!Check.isNull(imageList)) {
@@ -62,55 +61,57 @@ public class MaterialUploadImageServiceImpl implements IMaterialUploadImageServi
                         @SneakyThrows
                         @Override
                         public void run() {
-                            QueryWrapper<KuaiShouImageGet> imageQueryWrapper = new QueryWrapper<>();
-                            imageQueryWrapper.eq("account_id", accountId);
-                            imageQueryWrapper.eq("signature", imageInfo.getString("signature"));
-                            List<KuaiShouImageGet> imageGetList = imageGetService.list(imageQueryWrapper);
-                            if (Check.isNull(imageGetList)) {
-                                Map<String, String> headerMap = new HashMap<>();
-                                JSONObject requestJson = new JSONObject();
-                                requestJson.put("advertiser_id", accountId);
-                                headerMap.put("Access-Token", accessToken);
-                                headerMap.put("Content-Type", "multipart/form-data");
+                            synchronized (this) {
+                                QueryWrapper<KuaiShouImageGet> imageQueryWrapper = new QueryWrapper<>();
+                                imageQueryWrapper.eq("account_id", accountId);
+                                imageQueryWrapper.eq("signature", imageInfo.getString("signature"));
+                                List<KuaiShouImageGet> imageGetList = imageGetService.list(imageQueryWrapper);
+                                if (Check.isNull(imageGetList)) {
+                                    Map<String, String> headerMap = new HashMap<>();
+                                    JSONObject requestJson = new JSONObject();
+                                    requestJson.put("advertiser_id", accountId);
+                                    headerMap.put("Access-Token", accessToken);
+                                    headerMap.put("Content-Type", "multipart/form-data");
 
-                                requestJson.put("url", imageInfo.getString("imageUrl"));
-                                requestJson.put("signature", imageInfo.getString("signature"));
-                                requestJson.put("type", "2");
-                                requestJson.put("upload_type", "2");
-                                String requestUrl = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_UPLOAD;
-                                String result = exceptInfoForRestTemplate(requestUrl, requestJson, headerMap);
-                                JSONObject resultJson = JSONObject.parseObject(result);
-                                if (!Check.isNull(resultJson)) {
-                                    if (resultJson.getInteger("code") == 0) {
-                                        JSONObject dataJson = resultJson.getJSONObject("data");
-                                        if (!Check.isNull(dataJson)) {
-                                            String signature = dataJson.getString("signature");
-                                            String image_token = dataJson.getString("image_token");
-                                            KuaiShouImageGet imageGet = new KuaiShouImageGet();
-                                            imageGet.setId(accountId + image_token);
-                                            imageGet.setAccountId(accountId);
-                                            imageGet.setUrl(dataJson.getString("url"));
-                                            imageGet.setWidth(dataJson.getInteger("width"));
-                                            imageGet.setHeight(dataJson.getInteger("height"));
-                                            imageGet.setSize(dataJson.getInteger("size"));
-                                            imageGet.setFormat(dataJson.getString("format"));
-                                            Integer type = MaterialEnum.getTypeBySize(dataJson.getInteger("width"), dataJson.getInteger("height"));
-                                            if (!Check.isNull(type)) {
-                                                imageGet.setMaterialType(type);
+                                    requestJson.put("url", imageInfo.getString("imageUrl"));
+                                    requestJson.put("signature", imageInfo.getString("signature"));
+                                    requestJson.put("type", "2");
+                                    requestJson.put("upload_type", "2");
+                                    String requestUrl = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_UPLOAD;
+                                    String result = exceptInfoForRestTemplate(requestUrl, requestJson, headerMap);
+                                    JSONObject resultJson = JSONObject.parseObject(result);
+                                    if (!Check.isNull(resultJson)) {
+                                        if (resultJson.getInteger("code") == 0) {
+                                            JSONObject dataJson = resultJson.getJSONObject("data");
+                                            if (!Check.isNull(dataJson)) {
+                                                String signature = dataJson.getString("signature");
+                                                String image_token = dataJson.getString("image_token");
+                                                KuaiShouImageGet imageGet = new KuaiShouImageGet();
+                                                imageGet.setId(accountId + image_token);
+                                                imageGet.setAccountId(accountId);
+                                                imageGet.setUrl(dataJson.getString("url"));
+                                                imageGet.setWidth(dataJson.getInteger("width"));
+                                                imageGet.setHeight(dataJson.getInteger("height"));
+                                                imageGet.setSize(dataJson.getInteger("size"));
+                                                imageGet.setFormat(dataJson.getString("format"));
+                                                Integer type = MaterialEnum.getTypeBySize(dataJson.getInteger("width"), dataJson.getInteger("height"));
+                                                if (!Check.isNull(type)) {
+                                                    imageGet.setMaterialType(type);
+                                                }
+                                                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                                                imageGet.setStatDate(DateUtils.parseDate(nowDate, "yyyy-MM-dd"));
+                                                imageGet.setSignature(signature);
+                                                imageGet.setImageToken(image_token);
+                                                imageGetService.saveOrUpdate(imageGet);
                                             }
-                                            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-                                            imageGet.setStatDate(DateUtils.parseDate(nowDate, "yyyy-MM-dd"));
-                                            imageGet.setSignature(signature);
-                                            imageGet.setImageToken(image_token);
-                                            imageGetService.saveOrUpdate(imageGet);
+                                            log.info("快手封面素材素材同步完成,accountId:{},code:{},返回信息:{}", accountId, imageInfo.getString("signature"), resultJson);
+                                        } else {
+                                            log.error("快手同步封面素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
                                         }
-                                        log.info("快手封面素材素材同步完成,accountId:{},code:{},返回信息:{}", accountId, imageInfo.getString("signature"), resultJson);
-                                    } else {
-                                        log.error("快手同步封面素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
                                     }
                                 }
-                            }
 
+                            }
                         }
                     });
                 }
@@ -146,4 +147,6 @@ public class MaterialUploadImageServiceImpl implements IMaterialUploadImageServi
         }
         return null;
     }
+
+
 }

+ 1 - 1
module-job-bytedance/src/main/resources/application.yml

@@ -21,4 +21,4 @@ xxl:
       logpath: /data/applogs/xxl-job/jobhandler
       logretentiondays: 30
     admin:
-      addresses: http://39.106.184.70:8090/xxl-job-admin
+      addresses: http://139.186.29.76:8090

+ 1 - 1
module-job-kuaishou/src/main/resources/application.yml

@@ -21,4 +21,4 @@ xxl:
       logpath: /data/applogs/xxl-job/jobhandler
       logretentiondays: 30
     admin:
-      addresses: http://39.106.184.70:8090/xxl-job-admin
+      addresses: http://139.186.29.76:8090

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

@@ -125,14 +125,7 @@ public class BatchController {
             String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, 1);
 
 
-            Thread planThread = new Thread() {
-                @Override
-                public void run() {
-                    iKuaishouInterfaceService.getCampaignList(oauthToken, new java.util.Date(), new java.util.Date());
-
-                }
-            };
-            planThread.start();
+            iKuaishouInterfaceService.getCampaignList(oauthToken, new java.util.Date(), new java.util.Date());
 
 
             Thread thread = new Thread() {

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

@@ -66,6 +66,7 @@ public class KuaiShouCampaignController {
                                                          HttpServletRequest req) {
         Result<IPage<KuaiShouCampaign>> result = new Result<>();
         QueryWrapper<KuaiShouCampaign> queryWrapper = QueryGenerator.initQueryWrapper(kuaiShouCampaign, req.getParameterMap());
+        queryWrapper.orderByDesc("put_create_time");
         Page<KuaiShouCampaign> page = new Page<KuaiShouCampaign>(pageNo, pageSize);
         IPage<KuaiShouCampaign> pageList = kuaiShouCampaignService.page(page, queryWrapper);
         result.setSuccess(true);

+ 5 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java

@@ -144,7 +144,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouReportDailyAccountDTOList = accountService.getKuaishouAccountInfoByProjectId(dto.getProjectId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouReportDailyAccountDTOList = accountService.getKuaishouAccountInfoByProjectId(dto.getProjectId(),dto.getProjectList(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouReportDailyAccountDTOList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -173,7 +173,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouReportDailyAccountDTOList = accountService.getKuaishouSaleAccountInfoByProjectId(dto.getProjectId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouReportDailyAccountDTOList = accountService.getKuaishouSaleAccountInfoByProjectId(dto.getProjectList(), dto.getProjectId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouReportDailyAccountDTOList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -202,7 +202,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCampaignInfoByAccountId(dto.getAccountId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCampaignInfoByAccountId(dto.getProjectList(), dto.getAccountId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouCampaignInfoList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -231,7 +231,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouUnitInfoByCampaignId(dto.getCampaignId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouUnitInfoByCampaignId(dto.getProjectList(), dto.getCampaignId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouCampaignInfoList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -259,7 +259,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCreativeInfoByUnitId(dto.getUnitId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCreativeInfoByUnitId(dto.getProjectList(), dto.getUnitId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouCampaignInfoList);
         }catch(Exception e){
             log.error(e.getMessage());

+ 93 - 43
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/MaterialRefuseController.java

@@ -19,12 +19,13 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
-import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 @Slf4j
 @RestController
-@RequestMapping("/MaterialRefuse")
+@RequestMapping("/MaterialRefuse/")
 public class MaterialRefuseController {
     @Autowired
     private IMaterialRefuseService materialRefuseService;
@@ -34,9 +35,10 @@ public class MaterialRefuseController {
     private IKuaiShouUpdateService updateService;
     @Autowired
     private IKuaiShouCreativeService creativeService;
+    static ExecutorService executorService = Executors.newFixedThreadPool(15);
 
 
-    @GetMapping(value = "/getRefuseCreative")
+    @GetMapping(value = "getRefuseCreative")
     public Result<IPage<KuaiShouCreative>> getRefuseCreative(KuaiShouCreative creative,
                                                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                              @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@@ -58,13 +60,36 @@ public class MaterialRefuseController {
         return result;
     }
 
-    @PostMapping(value = "/updateCreative")
-    public Map<String, Object> updateCreative(@RequestBody JSONObject jsonObject) {
-        Map<String, Object> map = new HashMap<>();
+
+    @GetMapping(value = "syncCreative")
+    public Result<Boolean> syncCreative(Long accountId, Long campaignId) {
+        Result<Boolean> result = new Result<>();
+        try {
+            QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("account_id", accountId);
+            queryWrapper.eq("media_id", 2);
+            queryWrapper.orderByDesc("create_time");
+            queryWrapper.last("limit 1");
+            CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(queryWrapper);
+            if (Check.isNull(ctopOauthToken)) {
+                throw new Exception("未获取到授权信息");
+            }
+            creativeService.syncCreative(accountId, ctopOauthToken.getAccessToken(), campaignId, 1);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+    @PostMapping(value = "updateCreative")
+    public Result<Boolean> updateCreative(@RequestBody JSONObject jsonObject) {
+        Result<Boolean> result = new Result<>();
         if (Check.isNull(jsonObject)) {
-            map.put("code", -1);
-            map.put("message", "入参为空");
-            return map;
+            result.setSuccess(false);
+            result.setMessage("入参为空");
+            return result;
         }
 
         Long accountId = jsonObject.getLong("accountId");
@@ -75,34 +100,33 @@ public class MaterialRefuseController {
         queryWrapper.last("limit 1");
         CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(queryWrapper);
         if (Check.isNull(ctopOauthToken)) {
-            map.put("code", -1);
-            map.put("message", "未获取授权信息");
-            return map;
+            result.setSuccess(false);
+            result.setMessage("未获取到授权信息");
+            return result;
         }
 
         Map<String, Object> creativeMap = updateService.updateCreative(ctopOauthToken.getAccessToken(), accountId, jsonObject);
         if (Check.isNullMap(creativeMap)) {
-
-            map.put("code", -1);
-            map.put("message", "修改失败,返回为空");
-            return map;
+            result.setSuccess(false);
+            result.setMessage("修改失败,返回为空");
+            return result;
         }
 
         if ((Integer) creativeMap.get("code") != 0) {
-            map.put("code", -1);
-            map.put("message", creativeMap.get("message"));
-            return map;
+            result.setSuccess(false);
+            result.setMessage((String) creativeMap.get("message"));
+            return result;
         }
+        result.setSuccess(true);
 
-        return null;
+        return result;
     }
 
 
-    @PostMapping(value = "/batchUpdateCreative")
-    public Result<JSONObject> batchUpdateCreative(@RequestBody JSONObject jsonObject) {
+    @PostMapping(value = "batchUpdateCreative")
+    public Result<Boolean> batchUpdateCreative(@RequestBody JSONObject jsonObject) {
 
-        Result<JSONObject> result = new Result<>();
-        JSONObject returnJson = new JSONObject();
+        Result<Boolean> result = new Result<>();
         if (Check.isNull(jsonObject)) {
             result.setSuccess(false);
             result.setMessage("入参为空");
@@ -122,42 +146,68 @@ public class MaterialRefuseController {
             return result;
         }
 
+        Integer type = jsonObject.getInteger("type");
+        if (Check.isNull(type)) {
+            result.setSuccess(false);
+            result.setMessage("请选择修改类型");
+            return result;
+        }
+
+
         JSONArray creativeArr = jsonObject.getJSONArray("creativeArr");
-        Integer successCount = 0;
-        Integer failCount = 0;
-        if (!Check.isNull(creativeArr)) {
-
-            for (int i = 0; i < creativeArr.size(); i++) {
-                JSONObject creativeJson = creativeArr.getJSONObject(i);
-                if (!Check.isNull(creativeJson)) {
-                    Long creativeId = creativeJson.getLong("creativeId");
-                    JSONObject requestJson = new JSONObject();
-                    requestJson.put("creativeId", creativeId);
+        if (Check.isNull(creativeArr)) {
+            result.setSuccess(false);
+            result.setMessage("请选择修改创意");
+            return result;
+        }
+
+
+        for (int i = 0; i < creativeArr.size(); i++) {
+            JSONObject creativeJson = creativeArr.getJSONObject(i);
+            if (!Check.isNull(creativeJson)) {
+                Long creativeId = creativeJson.getLong("creativeId");
+                JSONObject requestJson = new JSONObject();
+                requestJson.put("creativeId", creativeId);
+                if (type == 0) {  // 替换修改广告语
                     String description = creativeJson.getString("description");
-                    if (!Check.isNull(description)) {
-                        requestJson.put("description", convertMoString(description));
+                    requestJson.put("description", convertMoString(description));
+                } else if (type == 1) { // 替换广告语
+                    String updateDescription = jsonObject.getString("updateDescription");
+                    String updateActionBarText = jsonObject.getString("updateActionBarText");
+                    if (Check.isNull(updateDescription) && Check.isNull(updateActionBarText)) {
+                        result.setSuccess(false);
+                        result.setMessage("广告语和行动号召按钮不能同时为空");
+                        return result;
+                    }
+                    if (!Check.isNull(updateDescription)) {
+                        requestJson.put("description", updateDescription);
+                    }
+                    if (!Check.isNull(updateActionBarText)) {
+                        requestJson.put("actionBarText", updateActionBarText);
+                    }
+
+                }
+
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
                         Map<String, Object> creativeMap = updateService.updateCreative(ctopOauthToken.getAccessToken(), accountId, requestJson);
                         Integer code = (Integer) creativeMap.get("code");
                         if (code == 0) {
                             log.info("拒审重提成功,accountId:{},creativeId:{}", accountId, creativeId);
-                            successCount += 1;
-
                         } else {
                             log.info("拒审重提失败,accountId:{},creativeId:{}", accountId, creativeId);
-                            failCount += 1;
                         }
                     }
+                });
 
-                }
 
             }
 
         }
-        returnJson.put("successCount", successCount);
-        returnJson.put("failCount", failCount);
 
         result.setSuccess(true);
-        result.setResult(returnJson);
+        result.setMessage("异步执行中,请稍后查看");
         return result;
     }
 

+ 2 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCreative.java

@@ -189,8 +189,9 @@ public class KuaiShouCreative {
      */
     @Excel(name = "第三方有效播放监测链接", width = 15)
     @ApiModelProperty(value = "第三方有效播放监测链接")
-    private String adPhotoPlayedT3sUrl;
+    private String adPhotoPlayedT3sUrl; // 第三方有效播放监测链接
     private String shortSlogan;
+    private String actionbarClickUrl; // 第三方点击按钮监测链接
     /**
      * 创建时间
      */

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml

@@ -34,6 +34,7 @@
         programmed_creative_material,
         photo_ids,
         short_slogan,
+        actionbar_click_url,
         creative_create_time,
         creative_update_time,
         create_time,
@@ -72,6 +73,7 @@
             #{creative.programmedCreativeMaterial},
             #{creative.photoIds},
             #{creative.shortSlogan},
+            #{creative.actionbarClickUrl},
             #{creative.creativeCreateTime},
             #{creative.creativeUpdateTime},
             #{creative.createTime},

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

@@ -31,4 +31,6 @@ public interface IKuaiShouCreativeService extends IService<KuaiShouCreative> {
      * @return
      */
     Integer checkCreativeCount(Long accountId, Long unitId);
+
+    void syncCreative(Long accountId, String accessToken, Long campaignId, Integer page);
 }

+ 1 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouVideoGetService.java

@@ -1,9 +1,6 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -17,5 +14,5 @@ import java.util.List;
 public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
     void replaceBatch(List<KuaiShouVideoGet> videoGets);
 
-    void getKeyFrame(String token,Long accountId, String md5, String photoId);
+    void getKeyFrame(String token, Long accountId, String md5, String photoId);
 }

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

@@ -1046,20 +1046,31 @@ public class BatchServiceImpl implements IBatchService {
                     continue;
                 }
                 creativeJson.put("creative_material_type", creative.getCreativeMaterialType());
+                String click_track_url = creative.getClickTrackUrl();
                 if (creative.getCreativeMaterialType() == 4) {
                     creativeJson.put("image_tokens", JSONArray.parseArray(creative.getImageTokens()));
                     creativeJson.put("short_slogan", creative.getShortSlogan());
+                    // 第三方开始播放监测链接
+                    if (!Check.isNull(click_track_url)) {
+                        creativeJson.put("impression_url", click_track_url);
+                    }
+
+                    if (!Check.isNull(creative.getImpressionUrl())) {
+                        creativeJson.put("impression_url", creative.getImpressionUrl());
+                    }
 
                 } else {
                     String photo_id = creative.getPhotoId();
                     creativeJson.put("photo_id", photo_id);
                     String image = creative.getImageToken();
                     creativeJson.put("image_token", image);
+                    if (!Check.isNull(click_track_url)) {
+                        creativeJson.put("click_track_url", click_track_url);
+                    }
                 }
 
 
                 String action_bar_text = creative.getActionBarText();
-                String click_track_url = creative.getClickTrackUrl();
                 JSONArray successArr = new JSONArray();
                 JSONArray failArr = new JSONArray();
                 String description = creative.getDescription();
@@ -1067,7 +1078,7 @@ public class BatchServiceImpl implements IBatchService {
                 creativeJson.put("action_bar_text", action_bar_text);
                 creativeJson.put("description", description.trim());
                 creativeJson.put("creative_name", name);
-                creativeJson.put("click_track_url", click_track_url);
+                //  creativeJson.put("click_track_url", click_track_url);
 
                 //封面广告语标题
                 if (!Check.isNull(creative.getStickerTitle())) {
@@ -1078,6 +1089,15 @@ public class BatchServiceImpl implements IBatchService {
                     creativeJson.put("overlay_type", creative.getOverlayType());
                 }
 
+                // 第三方有效播放监测链接
+                if (!Check.isNull(creative.getAdPhotoPlayedT3sUrl())) {
+                    creativeJson.put("ad_photo_played_t3s_url", creative.getAdPhotoPlayedT3sUrl());
+                }
+                // 第三方点击按钮监测链接
+                if (!Check.isNull(creative.getActionbarClickUrl())) {
+                    creativeJson.put("actionbar_click_url", creative.getActionbarClickUrl());
+                }
+
                 // 是否修改应用
                 if (!Check.isNull(appJson)) {
                     Boolean isUpdate = appJson.getBoolean("isUpdate");

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

@@ -1,17 +1,26 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreativeMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouVideoGetMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 快手-创意信息
@@ -19,6 +28,7 @@ import java.util.List;
  * @Date: 2019-07-23
  * @Version: V1.0
  */
+@Slf4j
 @Service
 public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMapper, KuaiShouCreative> implements IKuaiShouCreativeService {
     @Autowired
@@ -65,4 +75,107 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
     public Integer checkCreativeCount(Long accountId, Long unitId) {
         return kuaiShouCreativeMapper.checkCreativeCount(accountId, unitId);
     }
+
+    @Override
+    public void syncCreative(Long accountId, String accessToken, Long campaignId, Integer page) {
+
+
+        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("campaign_id", campaignId);
+        param.put("page_size", 200);
+        param.put("page", page);
+
+        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;
+        }
+        List<KuaiShouCreative> creatives = new ArrayList<>();
+        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"));
+                creative.setShortSlogan(detailJson.getString("short_slogan"));
+                creative.setActionbarClickUrl(detailJson.getString("actionbar_click_url"));
+                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 java.util.Date());
+                creative.setUpdateTime(new java.util.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());
+                        }
+                    }
+                }
+                creatives.add(creative);
+            }
+        }
+        this.replaceBatch(creatives);
+        this.syncCreative(accountId, accessToken, campaignId, page + 1);
+    }
 }

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

@@ -59,8 +59,8 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
     public void getGroupList(String accessToken, Long accountId) {
         QueryWrapper<KuaiShouCampaign> campaignQueryWrapper = new QueryWrapper<>();
         campaignQueryWrapper.eq("account_id", accountId);
-        campaignQueryWrapper.eq("status", 4);
-        campaignQueryWrapper.eq("put_status", 1);
+        /*campaignQueryWrapper.eq("status", 4);
+        campaignQueryWrapper.eq("put_status", 1);*/
         campaignQueryWrapper.orderByDesc("put_create_time");
         campaignQueryWrapper.last("limit 15");
         List<KuaiShouCampaign> list = kuaiShouCampaignService.list(campaignQueryWrapper);
@@ -216,6 +216,7 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
                     creative.setCreativeUpdateTime(detailJson.getDate("update_time"));
                     creative.setFirstFrameType(detailJson.getInteger("first_frame_type"));
                     creative.setShortSlogan(detailJson.getString("short_slogan"));
+                    creative.setActionbarClickUrl(detailJson.getString("actionbar_click_url"));
                     JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
                     if (!Check.isNull(displayInfoJson)) {
                         creative.setDescription(displayInfoJson.getString("description"));

+ 5 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java

@@ -489,6 +489,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
             String creativeId = requestJson.getString("creativeId");
             String creativeName = requestJson.getString("creativeName");
             String description = requestJson.getString("description");
+            String action_bar_text = requestJson.getString("actionBarText");
             if (!Check.isNull(creativeId)) {
                 params.put("creative_id", creativeId);
             }
@@ -498,6 +499,9 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
             if (!Check.isNull(description)) {
                 params.put("description", description);
             }
+            if (!Check.isNull(action_bar_text)) {
+                params.put("action_bar_text", action_bar_text);
+            }
 
 
             String result = HttpUtils.httpPostRequest(url, params, header);
@@ -508,7 +512,7 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
                     returnMap.put("code", 0);
                     returnMap.put("success", true);
                     returnMap.put("message", "修改成功");
-                    Thread.sleep(100);
+                    Thread.sleep(50);
                     interfaceService.getCreativeByCreativeId(token, advertiserId, Long.valueOf(creativeId));
 
                 } else {

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

@@ -54,7 +54,7 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
      * @param
      */
     @Override
-    public void getKeyFrame(String token, Long accountId, String videoMd5, String photoId) {
+    public synchronized void getKeyFrame(String token, Long accountId, String videoMd5, String photoId) {
         try {
             if (Check.isNull(videoMd5)) {
                 return;

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

@@ -1348,6 +1348,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     creative.setCreativeUpdateTime(detailJson.getDate("update_time"));
                     creative.setFirstFrameType(detailJson.getInteger("first_frame_type"));
                     creative.setShortSlogan(detailJson.getString("short_slogan"));
+                    creative.setActionbarClickUrl(detailJson.getString("actionbar_click_url"));
                     JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
                     if (!Check.isNull(displayInfoJson)) {
                         creative.setDescription(displayInfoJson.getString("description"));
@@ -1528,6 +1529,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                     creative.setCreativeUpdateTime(detailJson.getDate("update_time"));
                                     creative.setFirstFrameType(detailJson.getInteger("first_frame_type"));
                                     creative.setShortSlogan(detailJson.getString("short_slogan"));
+                                    creative.setActionbarClickUrl(detailJson.getString("actionbar_click_url"));
                                     JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
                                     if (!Check.isNull(displayInfoJson)) {
                                         creative.setDescription(displayInfoJson.getString("description"));
@@ -3049,6 +3051,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                     creative.setCreativeUpdateTime(detailJson.getDate("update_time"));
                                     creative.setFirstFrameType(detailJson.getInteger("first_frame_type"));
                                     creative.setShortSlogan(detailJson.getString("short_slogan"));
+                                    creative.setActionbarClickUrl(detailJson.getString("actionbar_click_url"));
                                     JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
                                     if (!Check.isNull(displayInfoJson)) {
                                         creative.setDescription(displayInfoJson.getString("description"));

+ 7 - 9
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java

@@ -20,11 +20,11 @@ public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouRep
 
     List<ProjectAccountDTO> getKuaishouProjectInfo(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectList")List<Long> projectList, @Param("yn")Integer yn);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(@Param("projectId")Long projectId, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectList")List<Long> projectList, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("accountId")Long accountId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(@Param("projectList")List<Long> projectList, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("accountId")Long accountId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("campaignId")Long campaignId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(@Param("projectList")List<Long> projectList, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("campaignId")Long campaignId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
 
     List<Long> queryProjectMemberByUserId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
 
@@ -36,17 +36,15 @@ public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouRep
 
     List<Long> queryProjectMemberByAdmins(@Param("mediaIds")List<Long> mediaIds);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("unitId")Long unitId, @Param("accountIds") List<Long> accoundIds, @Param("yn")Integer yn);
+    List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(@Param("projectList")List<Long> projectList, @Param("startDate")String startDate, @Param("endDate")String endDate, @Param("unitId")Long unitId, @Param("accountIds") List<Long> accoundIds, @Param("yn")Integer yn);
 
     KuaishouVideoInfoDTO getVideoUrl(@Param("photoId")Long photoId);
 
-    List<Long> getUserProjectAccountIds(@Param("userId")String userId);
+    List<Long> getUserProjectAccountIds(@Param("userId")String userId, @Param("yn")Integer yn);
 
-    List<Long> getUserProjectAccountIdsByAdmin();
+    List<Long> getUserProjectAccountIdsByAdmin(@Param("yn")Integer yn);
 
-
-
-    List<Long> getSaleProjectAccountIds(@Param("userId")String userId);
+    List<Long> getSaleProjectAccountIds(@Param("userId")String userId, @Param("yn")Integer yn);
 
 
 }

+ 2 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaiShouYiCheReportMapper.xml

@@ -34,7 +34,7 @@
         case
         when t1.system_type = 'android'
         then 16
-        when t1.system_type = 'IOS'
+        when t1.system_type = 'ios'
         then 23
         else 0
         end
@@ -446,7 +446,7 @@
             and t1.stat_date = #{statDate}
         </if>
         ) t2
-        WHERE t2.campaignName in(680,681,845,846,847,848,849,850,1070,1071,1072,1066,1069,1064)
+        WHERE t2.campaignName in(581,582,583,584,552,553,554,680,681,845,846,847,848,849,850,1070,1071,1072,1066,1069,1064)
 
     </select>
 

+ 61 - 27
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml

@@ -566,8 +566,8 @@
         end
         ) as 'photoClickCost', -- 平均封面点击单价
         (CASE
-        WHEN sum(a.photo_click) != 0
-        THEN round(sum(a.charge) / sum(a.photo_click),2)
+        WHEN sum(a.bclick) != 0
+        THEN round(sum(a.charge) / sum(a.bclick),2)
         ELSE 0
         end
         ) as 'actionCost', -- 平均行为单价
@@ -594,10 +594,18 @@
         a.stat_date &gt;= #{startDate}
         and
         a.stat_date &lt;= #{endDate}
+        <if test="projectId !=null ">
+        and
+        b.project_id = #{projectId}
+        </if>
 
-        <if test="projectId!=null and projectId != '' ">
+        <if test="projectList !=null ">
             and
-            b.project_id = #{projectId}
+            b.project_id in
+            <foreach collection="projectList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
         </if>
         <if test="accountIds !=null">
             and a.account_id in
@@ -655,8 +663,8 @@
             end
             ) as 'photoClickCost', -- 平均封面点击单价
             (CASE
-            WHEN ( sum(a.photo_click) is not null and sum(a.photo_click) != 0)
-            THEN round(sum(a.charge) / sum(a.photo_click),2)
+            WHEN ( sum(a.bclick) is not null and sum(a.bclick) != 0)
+            THEN round(sum(a.charge) / sum(a.bclick),2)
             ELSE 0
             end
             ) as 'actionCost', -- 平均行为单价
@@ -736,8 +744,8 @@
         end
         ) as 'photoClickCost', -- 平均封面点击单价
         (CASE
-        WHEN sum(a.photo_click) != 0
-        THEN round(sum(a.charge) / sum(a.photo_click),2)
+        WHEN sum(a.bclick) != 0
+        THEN round(sum(a.charge) / sum(a.bclick),2)
         ELSE 0
         end
         ) as 'actionCost', -- 平均行为单价
@@ -775,7 +783,14 @@
                 #{item}
             </foreach>
         </if>
-
+        <if test="projectList!=null">
+        and
+            b.project_id in
+            <foreach collection="projectList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
         group by a.campaign_id
         order by sum(a.charge) desc
 <!--        ) m-->
@@ -826,8 +841,8 @@
         end
         ) as 'photoClickCost', -- 平均封面点击单价
         (CASE
-        WHEN sum(a.photo_click) != 0
-        THEN round(sum(a.charge) / sum(a.photo_click),2)
+        WHEN sum(a.bclick) != 0
+        THEN round(sum(a.charge) / sum(a.bclick),2)
         ELSE 0
         end
         ) as 'actionCost', -- 平均行为单价
@@ -855,7 +870,8 @@
         a.stat_date &gt;= #{startDate}
         and
         a.stat_date &lt;= #{endDate}
-            <if test="campaignId != null and campaignId != ''">and
+            <if test="campaignId != null and campaignId != ''">
+            and
                 a.campaign_id = #{campaignId}
             </if>
             <if test="accountIds !=null">
@@ -865,6 +881,14 @@
                     #{item}
                 </foreach>
             </if>
+        <if test="projectList!=null">
+            and
+            b.project_id in
+            <foreach collection="projectList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
             group by unit_id
             order by sum(a.charge) desc
 <!--            ) m-->
@@ -876,19 +900,12 @@
 
     <select id="queryProjectMemberByUserId" resultType="long">
         select
-        distinct a.project_id as projectId
-       -- a.project_name as projectName,
-       -- a.advertiser_name as advertiserName,
-       -- c.responsible_name as responsibleName,
-       -- c.design_responsible_name as designResponsibleName
+        distinct c.id as projectId
         from
-        ctop_user_allocation a
-        left join ctop_project_member b on a.project_id = b.project_id
-        left join ctop_project c on a.project_id = c.id
+        ctop_project_member b
+        left join ctop_project c on b.project_id = c.id
         where b.user_id = #{userId}
-        and a.media_id in
+        and c.media_id in
         <foreach collection="mediaIds" item="item" separator=","
                  open="(" close=")">
             #{item}
@@ -947,7 +964,7 @@
         where a.user_id = #{userId}
     </select>
 
-    <!-- 设计师展示所有自己的角色下制作的视频 -->
+    <!-- 管理员所在项目 -->
     <select id="queryProjectMemberByAdmins" resultType="long">
         select
         id as projectId
@@ -1006,8 +1023,8 @@
             end
             ) as 'photoClickCost', -- 平均封面点击单价
             (CASE
-            WHEN sum(a.photo_click) != 0
-            THEN round(sum(a.charge) / sum(a.photo_click),2)
+            WHEN sum(a.bclick) != 0
+            THEN round(sum(a.charge) / sum(a.bclick),2)
             ELSE 0
             end
             ) as 'actionCost', -- 平均行为单价
@@ -1050,6 +1067,14 @@
                     #{item}
                 </foreach>
             </if>
+        <if test="projectList!=null">
+            and
+            b.project_id in
+            <foreach collection="projectList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
             group by a.creative_id
             order by sum(a.charge) desc
 <!--        )m-->
@@ -1076,9 +1101,12 @@
         (select project_id,account_id,media_id from ctop_user_allocation  group by account_id) a
         left join ctop_project_member b on a.project_id=b.project_id
         where
-        and a.media_id in (2,4)
-        order by a.create_time desc
+        a.media_id in (2,4)
+        and user_id = #{userId}
+        order by create_time desc
+        <if test="yn==1">
         limit 50
+        </if>
     </select>
 
     <select id="getUserProjectAccountIdsByAdmin" resultType="long">
@@ -1089,7 +1117,9 @@
         left join ctop_project b on a.project_id = b.id
         where
         b.media_id in (2,4)
+        <if test="yn==1">
         limit 50
+        </if>
     </select>
 
     <select id="getSaleProjectAccountIds" resultType="long">
@@ -1100,9 +1130,11 @@
         left join ctop_project b on a.project_id=b.id
         where
         b.sale_id = #{userId}
-        and b.media_id in (1,3)
+        and b.media_id in (2,4)
         order by a.create_time desc
+        <if test="yn==1">
         limit 50
+        </if>
     </select>
 
 </mapper>

+ 5 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyAccountService.java

@@ -20,14 +20,14 @@ public interface IKuaishouReportDailyAccountService extends IService<KuaishouRep
 
     PageInfo<ProjectAccountDTO> getKuaishouSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort, Integer yn);
 
-    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouSaleAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
+    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouSaleAccountInfoByProjectId(List<Long> projectList, Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
 
-    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
+    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, List<Long> projectList, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
 
-    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
+    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(List<Long> projectList, Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
 
-    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(Long campaignId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
+    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(List<Long> projectList, Long campaignId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
 
-    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
+    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(List<Long> projectList, Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
 
 }

+ 29 - 26
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAccountServiceImpl.java

@@ -74,7 +74,6 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
             if("admin".equals(roleCode)){
                 projectList = dailyAccountMapper.queryProjectMemberByAdmins(mediaIds);
             }else{
-
                 projectList = dailyAccountMapper.queryProjectInfoBySaleId(userId,mediaIds);
             }
         }
@@ -84,68 +83,72 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
     }
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouSaleAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouSaleAccountInfoByProjectId(List<Long> projectList, Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         //String userId = "e9ca23d68d884d4ebb19d07889727dae";
         String userId = sysUser.getId();
         String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
 
         List<Long> accountIds = null;
-        if(projectId == null){
+        if(projectList == null && projectId==null){
             if("admin".equals(roleCode)){
-                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin();
+                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin(0);
             }else {
-                accountIds = dailyAccountMapper.getSaleProjectAccountIds(userId);
+                accountIds = dailyAccountMapper.getSaleProjectAccountIds(userId,0);
             }
         }
 
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(startDate, endDate, projectId, accountIds, yn));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(projectId, startDate, endDate, projectList, accountIds, yn));
     }
 
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, List<Long> projectList, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         //String userId = "e9ca23d68d884d4ebb19d07889727dae";
         String userId = sysUser.getId();
         String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
 
+        //List<Long> mediaIds = new ArrayList<>();
+        //mediaIds.add(2L);
+        //mediaIds.add(4L);
+
         List<Long> accountIds = null;
-        if(projectId == null){
+        if(projectId==null && projectList==null){
             if("admin".equals(roleCode)){
-                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin();
+                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin(0);
             }else {
-                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId);
+                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId,0);
             }
         }
 
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(startDate, endDate, projectId, accountIds, yn));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(projectId, startDate, endDate, projectList, accountIds, yn));
     }
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(List<Long> projectList, Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         //String userId = "e9ca23d68d884d4ebb19d07889727dae";
         String userId = sysUser.getId();
         String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
 
         List<Long> accountIds = null;
-        if(accountId == null){
+        if(accountId == null && projectList==null){
             if("admin".equals(roleCode)){
-                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin();
+                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin(1);
             }else {
-                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId);
+                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId,1);
             }
         }
 
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouCampaignInfoByAccountId(startDate, endDate, accountId,accountIds,yn));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouCampaignInfoByAccountId(projectList, startDate, endDate, accountId,accountIds,yn));
     }
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(Long campaignId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(List<Long> projectList, Long campaignId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
 
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         //String userId = "e9ca23d68d884d4ebb19d07889727dae";
@@ -153,36 +156,36 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
         String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
 
         List<Long> accountIds = null;
-        if(campaignId == null){
+        if(campaignId == null && projectList == null){
             if("admin".equals(roleCode)){
-                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin();
+                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin(1);
             }else {
-                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId);
+                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId,1);
             }
         }
 
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouUnitInfoByCampaignId(startDate, endDate, campaignId,accountIds, yn));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouUnitInfoByCampaignId(projectList, startDate, endDate, campaignId,accountIds, yn));
     }
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(List<Long> projectList, Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         //String userId = "e9ca23d68d884d4ebb19d07889727dae";
         String userId = sysUser.getId();
         String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
 
         List<Long> accountIds = null;
-        if(unitId == null){
+        if(unitId == null && projectList ==null){
             if("admin".equals(roleCode)){
-                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin();
+                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin(1);
             }else {
-                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId);
+                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId,1);
             }
         }
 
         PageHelper.startPage(pageNum,pageSize);
-        List<KuaishouReportDailyAccountDTO> kuaishouCreativeInfoList = dailyAccountMapper.getKuaishouCreativeInfoByUnitId(startDate, endDate, unitId,accountIds, yn);
+        List<KuaishouReportDailyAccountDTO> kuaishouCreativeInfoList = dailyAccountMapper.getKuaishouCreativeInfoByUnitId(projectList, startDate, endDate, unitId,accountIds, yn);
         //for(KuaishouReportDailyAccountDTO creativeInfo:kuaishouCreativeInfoList){
         //    KuaishouVideoInfoDTO videoInfo = dailyAccountMapper.getVideoUrl(creativeInfo.getPhotoId());
         //    creativeInfo.setUrl(videoInfo.getUrl());

+ 4 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceCampaignController.java

@@ -50,6 +50,7 @@ public class ByteDanceCampaignController {
     @GetMapping(value = "/list")
     public Result<IPage<ByteDanceCampaign>> queryPageList(
             @RequestParam(name = "name",defaultValue = "")String name,
+            @RequestParam(name = "accountId",defaultValue = "0")String accountId,
             @RequestParam(name = "status",defaultValue = "")String status,
             @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
             @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@@ -70,6 +71,9 @@ public class ByteDanceCampaignController {
         if(null!=endDate&&!"".equals(endDate)){
             queryWrapper.le("campaign_create_time",endDate+" 11:59:59");
         }
+        if(null!=accountId&&"".equals(accountId.trim())){
+            queryWrapper.eq("account_id",accountId);
+        }
         queryWrapper.ne("status","CAMPAIGN_STATUS_DELETE");
         queryWrapper.orderByDesc("campaign_create_time");
         Page<ByteDanceCampaign> page = new Page<>(pageNo, pageSize);

+ 2 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceAccountReportMapper.xml

@@ -455,7 +455,7 @@
         b.sale_id = #{userId}
         and b.media_id in (1,3)
         order by a.create_time desc
-        limit 50
+
     </select>
 
     <select id="getUserProjectAccountIdsByAdmin" resultType="long">
@@ -466,7 +466,7 @@
         left join ctop_project b on a.project_id = b.id
         where
         b.media_id in (1,3)
-        limit 50
+
     </select>
 
 </mapper>