Selaa lähdekoodia

Merge remote-tracking branch 'origin/master'

syh 4 vuotta sitten
vanhempi
commit
d1ead2e51b
36 muutettua tiedostoa jossa 1524 lisäystä ja 297 poistoa
  1. 11 0
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 7 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  3. 98 63
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  4. 3 1
      module-common/src/main/java/cn/com/ctop/common/module/enums/MaterialEnum.java
  5. 15 1
      module-common/src/main/java/cn/com/ctop/common/module/service/IMessageTemplate.java
  6. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/FileInfoServiceImpl.java
  7. 9 10
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java
  8. 27 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MessageTemplateImpl.java
  9. 10 3
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  10. 25 38
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadServiceImpl.java
  11. 3 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  12. 304 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouProgramCreativeController.java
  13. 2 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouActionBarText.java
  14. 69 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouOverRunLog.java
  15. 170 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouProgramCreative.java
  16. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouActionBarTextMapper.java
  17. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCreativeMapper.java
  18. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouOverRunLogMapper.java
  19. 16 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouProgramCreativeMapper.java
  20. 40 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouActionBarTextMapper.xml
  21. 13 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml
  22. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouOverRunLogMapper.xml
  23. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouProgramCreativeMapper.xml
  24. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouActionBarTextService.java
  25. 10 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouCreativeService.java
  26. 7 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouOverRunSendMessageService.java
  27. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouOverRunLogService.java
  28. 18 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouProgramCreativeService.java
  29. 224 169
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  30. 67 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouActionBarTextServiceImpl.java
  31. 6 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreativeServiceImpl.java
  32. 88 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouOverRunSendMessageServiceImpl.java
  33. 11 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  34. 19 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouOverRunLogServiceImpl.java
  35. 207 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouProgramCreativeServiceImpl.java
  36. 1 0
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/IWechatUserListService.java

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

@@ -247,6 +247,17 @@ public class DateUtils extends PropertyEditorSupport {
         return new Date();
     }
 
+
+    public static String getStartTime(Date date) {
+        Calendar dateStart = Calendar.getInstance();
+        dateStart.setTime(date);
+        dateStart.set(Calendar.HOUR_OF_DAY, 0);
+        dateStart.set(Calendar.MINUTE, 0);
+        dateStart.set(Calendar.SECOND, 0);
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return simpleDateFormat.format(dateStart.getTime());
+    }
+
     /**
      * 日期转换为字符串
      *

+ 7 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java

@@ -117,9 +117,14 @@ public class ProjectMemberController {
                     if (!Check.isNull(project)) {
                         SysUser responsible = sysUserService.getById(project.getResponsibleId());
 
-                        projectMember.setResponsibleName(responsible.getRealname());
+                        if (!Check.isNull(responsible)) {
+                            projectMember.setResponsibleName(responsible.getRealname());
+                        }
+
                         SysUser designResponsible = sysUserService.getById(project.getDesignResponsibleId());
-                        projectMember.setDesignResponsibleName(designResponsible.getRealname());
+                        if (!Check.isNull(designResponsible)) {
+                            projectMember.setDesignResponsibleName(designResponsible.getRealname());
+                        }
 
                         projectMember.setProjectName(project.getProjectName());
                         Product product = productService.getById(project.getProductId());

+ 98 - 63
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -5,16 +5,19 @@ import cn.com.ctop.check.entity.CtopCheckTaskList;
 import cn.com.ctop.check.service.ICtopCheckTaskListService;
 import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.entity.MaterialImageInfo;
+import cn.com.ctop.common.module.entity.UReportSubscriber;
 import cn.com.ctop.common.module.entity.UserAllocation;
-import cn.com.ctop.common.module.service.IBindAccountLoginService;
-import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.service.IMaterialImageInfoService;
-import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.message.handle.impl.EmailSendMsgHandle;
+import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
+import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
+import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
+import cn.com.ctop.oa.modules.service.IWechatDepartmentService;
+import cn.com.ctop.oa.modules.service.IWechatNoListService;
+import cn.com.ctop.oa.modules.service.IWechatUserListService;
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
@@ -26,6 +29,8 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import java.io.File;
+import java.text.ParseException;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -45,26 +50,52 @@ public class SampleTest {
     @Autowired
     private IReportService reportService;
     @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private IByteDanceAdvertiserDataService advertiserDataService;
+    @Autowired
     private IKuaiShouHistoryReportTaskService kuaiShouHistoryReportTaskService;
     @Autowired
-    private IMaterialImageInfoService imageInfoService;
-    @Test
-    public void loadBytedanceMatData(){
-        executorService = Executors.newFixedThreadPool(5);
-        List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
-        for (CtopOauthToken token:tokens) {
-            reportService.getAdvertiserPlanReport(token,new Date(),new Date(),CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
-        }
-    }
+    private IKuaiShouDailyReportTaskService dailyReportTaskService;
+
+    @Autowired
+    private IWechatDepartmentService wechatDepartment;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private IWechatUserListService wechatUserInfoService;
+    @Autowired
+    private IWechatCheckinDataService wechatCheckinDataService;
+    @Autowired
+    private IWechatNoListService wechatNoListService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouRealTimeDataService realTimeDataService;
+
+    @Autowired
+    private IKuaiShouCreativeService creativeService;
+    @Autowired
+    private IMessageTemplate messageTemplate;
+
+    @Autowired
+    private ISendMessageService sendMessageService;
+
+    @Autowired
+    private IKuaiShouOverRunSendMessageService overRunSendMessageService;
+
 
     @Test
-    public void initImageCode(){
-        QueryWrapper<MaterialImageInfo>queryWrapper = new QueryWrapper<>();
-        queryWrapper.le("update_time","2020-09-23 18:35:00");
-        List<MaterialImageInfo> imageInfos = imageInfoService.list(queryWrapper);
-        for (MaterialImageInfo image:imageInfos) {
-            imageInfoService.initImageCode(image);
-        }
+    public void getDepartment() throws ParseException {
+
+      /*  String message = messageTemplate.getCreativeOverRunMessage(23212L, 2000, "hahah");
+        //  LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        sendMessageService.sendMessage("14c3cd
+        5e5e434211a9bb5e8f9d8a335d", message);*/
+
+        overRunSendMessageService.creativeOverRunSendMessage(23212L);
+
+
     }
 
 
@@ -73,10 +104,10 @@ public class SampleTest {
         QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("media_id", 2);
         List<CtopOauthToken> list = oauthTokenService.list(queryWrapper);
-         for (CtopOauthToken token : list) {
-        kuaiShouHistoryReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), "2020-09-20", "2020-09-20", "daily");
+        for (CtopOauthToken token : list) {
+            kuaiShouHistoryReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), "2020-09-20", "2020-09-20", "daily");
 
-         }
+        }
 
     }
 
@@ -109,6 +140,7 @@ public class SampleTest {
     }
 
     static ExecutorService executorService = null;
+    //线程计数器/bytedance/bytedanceMaterialReport
     static CountDownLatch countDownLatch = null;
 
     @Test
@@ -142,12 +174,12 @@ public class SampleTest {
 
     @Test
     public void testLoadBytedanceData() {
-        List<UserAllocation> allocations = allocationService.getByParams(430L, null, 0);
+        List<UserAllocation> allocations = allocationService.getByParams(435L, null, 0);
         for (UserAllocation allocation : allocations) {
-            for (int i = 0; i < 10; i++) {
+            for (int i = 2; i < 10; i++) {
                 CtopOauthToken token = oauthTokenService.getTokenByAccountId(allocation.getAccountId());
                 Date getDate = DateUtils.addDay(new Date(), -i);
-                reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+                reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
             }
         }
     }
@@ -155,18 +187,18 @@ public class SampleTest {
     @Test
     public void loadKuaishouAgentData() {
         kuaishouReportDailyAgentService.loginAgent();
-//        for (int i = 0; i < 20; i++) {
-//            String currentDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -i));
-//            kuaishouReportDailyAgentService.getReport(currentDate, DateUtils.getNowDate("yyyy-MM-dd"));
-//        }
-//
-        try {
-            for (int i = 1; i < 30; i++) {
-                kuaishouReportDailyAgentService.getAccount(i);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
+        for (int i = 0; i < 20; i++) {
+            String currentDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -i));
+            kuaishouReportDailyAgentService.getReport(currentDate, DateUtils.getNowDate("yyyy-MM-dd"));
         }
+//
+//        try {
+//            for (int i = 1; i < 30; i++) {
+//                kuaishouReportDailyAgentService.getAccount(i);
+//            }
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
     }
 
     @Autowired
@@ -190,32 +222,35 @@ public class SampleTest {
         reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-09-01", "yy-MM-dd"), DateUtils.parseDate("2020-09-01", "yy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
     }
 
-    @Test
-    public void testBytedanceVideoReport(){
-        List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
-        for(int i=2;i<100;i++){
-            String date = DateUtils.formatDate(DateUtils.addDay(new Date(),-i));
-            for (CtopOauthToken token:tokens) {
-//                bytedanceReportService.bytedanceVideoMaterialReport(token, date, date);
-            }
-        }
-    }
+    @Autowired
+    IUReportExportService uReportExportService;
+    @Autowired
+    EmailSendMsgHandle emailSendMsgHandle;
+    @Autowired
+    IUReportService uReportService;
 
     @Test
-    public void loadKuaishouReportData() {
-        QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("media_id", 2);
-        List<CtopOauthToken> list = oauthTokenService.list(queryWrapper);
-        for (CtopOauthToken token : list) {
-            kuaiShouHistoryReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), "2020-09-17", "2020-09-19", "history");
-            kuaiShouHistoryReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), "2020-09-20", "2020-09-20", "daily");
+    public void sendUReport() {
+        uReportService.uReportList().forEach(uReport -> {
+            List<UReportSubscriber> uReportSubscriber = uReportService.getUReportSubscriberByFileId(uReport.getString("id"));
+            if (!uReportSubscriber.isEmpty()) {
+                String title = uReport.getString("name").replace(".ureport.xml", "");
+                String content = "您订阅的日报在附件中请注意查收》》》";
+                //下载文件到本地
+                uReportExportService.exportExcel(uReport.getString("name"));
+                uReportSubscriber.forEach(sender -> {
+                    emailSendMsgHandle.SendAttachment("bijiequan@c-top.com.cn", title, content,
+                            new File(System.getProperty("user.dir") + File.separator + "uReport" + File.separator + uReport.getString("name").replace("ureport.xml", "") + "xlsx"));
+                });
+            }
+        });
+        //发完全部订阅,删除文件
+        File file = new File(System.getProperty("user.dir") + File.separator + "uReport");
+        File[] files = file.listFiles();
+        if (files != null && files.length > 0) {
+            for (File f : files) {
+                f.delete();
+            }
         }
     }
-
-    @Autowired
-    private IKuaiShouHistoryReportTaskService historyReportTaskService;
-    @Test
-    public void loadHistoryJob(){
-        historyReportTaskService.getTaskList();
-    }
 }

+ 3 - 1
module-common/src/main/java/cn/com/ctop/common/module/enums/MaterialEnum.java

@@ -12,7 +12,9 @@ public enum MaterialEnum {
     VerticalVideo1080mall(1, 1080, 2200),
     VerticalVideoBig(1, 1080, 1920),
     HorizontalVideoSmall(2, 1280, 720),
-    HorizontalVideoBig(2, 1920, 1080);
+    HorizontalVideoBig(2, 1920, 1080),
+    BianlitieImageBig(4, 540, 540),
+    BianLitieImageSmall(4, 450, 450);
 
     private Integer type;
     private Integer width;

+ 15 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/IMessageTemplate.java

@@ -2,7 +2,19 @@ package cn.com.ctop.common.module.service;
 
 public interface IMessageTemplate {
 
-    String getMaterialSyncTemplate(String projectName, Long accountId, String accountName, String materialName, String reason);
+    String getMaterialSyncTemplate(String projectName, String accountId, String accountName, String materialName, String reason);
+
+    /**
+     * 同步成功发送消息
+     *
+     * @param projectName
+     * @param accountId
+     * @param accountName
+     * @param materialName
+     * @param reason
+     * @return
+     */
+    String getMaterialSyncSucessTemplate(String projectName, String accountId, String accountName, String materialName, String reason);
 
 
     String getMaterialRejectTemplate(String projectName, String materialName, String refuseReason);
@@ -11,4 +23,6 @@ public interface IMessageTemplate {
 
 
     String getFeishuMaterialRejectTemplate(String projectName, String materialName, String refuseReason);
+
+    String getCreativeOverRunMessage(Long accountId, Integer creativeCount,String authName);
 }

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/FileInfoServiceImpl.java

@@ -77,7 +77,7 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
                     log.error("头条上传素材失败,返回信息:{},accountId:{}", jsonObject, accountId);
                     UserAllocation allocation = userAllocationService.getByAccountId(Long.valueOf(accountId));
                     Project project = projectService.getById(allocation.getProjectId());
-                    String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), Long.valueOf(accountId), allocation.getAuthName(), materialName, jsonObject.getString("message"));
+                    String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), accountId, allocation.getAuthName(), materialName, jsonObject.getString("message"));
                     sendMessageService.sendMessage(userId, message);
                 }
 

+ 9 - 10
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -518,7 +518,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
             MaterialInfo info = new MaterialInfo();
             Long projectId = json.getLong("projectId");
             String code = json.getString("code");
-            info.setId(code + "_" + projectId);
+            info.setId(code + projectId);
             info.setCode(code);
             if (!Check.isNull(json.getString("watermarkUrl"))) {
                 info.setWatermarkUrl(json.getString("watermarkUrl"));
@@ -589,13 +589,13 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
             }
             materialTagInfoService.deleteByCode(code);
             JSONArray modalityTagList = json.getJSONArray("modalityTagList");
-            insertTagList(code, userId, modalityTagList);
+            insertTagList(code,userId,modalityTagList);
             JSONArray contentTagList = json.getJSONArray("contentTagList");
-            insertTagList(code, userId, contentTagList);
+            insertTagList(code,userId,contentTagList);
             JSONArray senceTagList = json.getJSONArray("senceTagList");
-            insertTagList(code, userId, senceTagList);
+            insertTagList(code,userId,senceTagList);
             JSONArray modTagList = json.getJSONArray("modTagList");
-            insertTagList(code, userId, modTagList);
+            insertTagList(code,userId,modTagList);
             getFile(info, project.getMediaId());
             ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
         } catch (Exception e) {
@@ -605,18 +605,17 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         return resultMap;
     }
 
-    private void insertTagList(String code, String userId, JSONArray tagList) {
-        if (null != tagList && !tagList.isEmpty()) {
-            for (int m = 0; m < tagList.size(); m++) {
+    private void insertTagList(String code,String userId,JSONArray tagList){
+        if(null!=tagList&&!tagList.isEmpty()){
+            for(int m=0;m<tagList.size();m++){
                 Long tagId = tagList.getLong(m);
                 TagInfo tagInfo = tagInfoService.getById(tagId);
-                MaterialTagInfo setTag = new MaterialTagInfo(code, tagInfo, userId);
+                MaterialTagInfo setTag= new MaterialTagInfo(code,tagInfo,userId);
                 setTag.setCategoryId(tagInfo.getTagCategoryId());
                 materialTagInfoService.save(setTag);
             }
         }
     }
-
     @Autowired
     private ITagInfoService tagInfoService;
     @Autowired

+ 27 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MessageTemplateImpl.java

@@ -19,7 +19,7 @@ public class MessageTemplateImpl implements IMessageTemplate {
      * @return
      */
     @Override
-    public String getMaterialSyncTemplate(String projectName, Long accountId, String accountName, String materialName, String reason) {
+    public String getMaterialSyncTemplate(String projectName, String accountId, String accountName, String materialName, String reason) {
         StringBuilder text = new StringBuilder();
         text.append("素材同步失败").append("<br/>")
                 .append("您的项目:").append(projectName + ",").append("<br/>")
@@ -32,6 +32,19 @@ public class MessageTemplateImpl implements IMessageTemplate {
     }
 
     @Override
+    public String getMaterialSyncSucessTemplate(String projectName, String accountId, String accountName, String materialName, String reason) {
+        StringBuilder text = new StringBuilder();
+        text.append("素材同步成功通知:").append("<br/>")
+                .append("您的项目:").append(projectName + ",").append("<br/>")
+                .append("下的快手账户:").append(accountId + ",").append("<br/>")
+                .append("授权名称为:" + accountName).append("<br/>")
+                .append("同步素材成功。").append("<br/>")
+                .append("素材名称为:").append(materialName).append("<br/>")
+                .append("请您前往查看。");
+        return text.toString();
+    }
+
+    @Override
     public String getFeishuMaterialSyncTemplate(String projectName, Long accountId, String accountName, String materialName, String reason) {
         StringBuilder text = new StringBuilder();
         text.append("素材同步失败").append("\n\r")
@@ -82,4 +95,17 @@ public class MessageTemplateImpl implements IMessageTemplate {
         text.append("请您联系相关同学及时调整");
         return text.toString();
     }
+
+    @Override
+    public String getCreativeOverRunMessage(Long accountId, Integer creativeCount, String authName) {
+        StringBuilder text = new StringBuilder();
+        text.append("创意超限通知:").append("<br/>")
+
+                .append("您的快手账户:").append(accountId + ",").append("<br/>")
+                .append("授权名称为:" + authName).append("<br/>")
+                .append("创意api创建超限。").append("<br/>")
+                .append("当前创建数为:").append(creativeCount).append("<br/>")
+                .append("如有疑问,请联系产品:吴永前。");
+        return text.toString();
+    }
 }

+ 10 - 3
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -20,6 +20,10 @@ public class KuaishouInterfaceConstant {
      */
     public static final String CAMPAIGN_REPORT = "/rest/openapi/v1/report/campaign_report";
     /**
+     * 程序化2.0创意
+     */
+    public static final String PROGRAM_LIST = "/rest/openapi/v2/creative/advanced/program/list";
+    /**
      * 广告组报表数据
      */
     public static final String GTOUP_REPORT = "/rest/openapi/v1/report/unit_report";
@@ -48,10 +52,14 @@ public class KuaishouInterfaceConstant {
      */
     public static final String AD_UNIT_CREATE = "/rest/openapi/v2/ad_unit/create";
     /**
-     * 创建广告
+     * 创建广告创意
      */
     public static final String AD_CREATIVE_CREATE = "/rest/openapi/v2/creative/create";
     /**
+     * 程序化创意 2.0
+     */
+    public static final String PROGRAM_CREATE = "/rest/openapi/v2/creative/advanced/program/create";
+    /**
      * 获取可选的深度转化类型
      */
     public static final String DEEP_CONVERSION_INFOS = "/rest/openapi/v1/ad_unit/ocpc/conversion_infos";
@@ -123,6 +131,7 @@ public class KuaishouInterfaceConstant {
      * 获取可选的动态词包
      */
     public static final String CREATIVE_WORD = "/rest/openapi/v1/tool/creative_word/list";
+    public static final String ACTION_BAR_TEXT_LIST = "/rest/openapi/v1/creative/action_bar_text/list";
 
 
     /**
@@ -237,6 +246,4 @@ public class KuaishouInterfaceConstant {
     public static final String HTTPS_PREFIX = "https:";
 
 
-
-
 }

+ 25 - 38
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadServiceImpl.java

@@ -10,6 +10,8 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.LoadFileUtil;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAdvertiserBaseInfo;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAdvertiserBaseInfoService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.manage.modules.material.service.IMaterialUploadImageService;
 import cn.com.ctop.manage.modules.material.service.IMaterialUploadService;
@@ -91,16 +93,16 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
         for (int j = 0; j < materialArray.size(); j++) {
             String materialId = materialArray.getString(j);
             MaterialInfo materialInfo = materialInfoMapper.selectById(materialId);
-            MaterialImageInfo materialImageInfo= materialImageInfoMapper.selectById(materialId);
-            if (Check.isNull(materialInfo)&&Check.isNull(materialImageInfo)) {
+            MaterialImageInfo materialImageInfo = materialImageInfoMapper.selectById(materialId);
+            if (Check.isNull(materialInfo) && Check.isNull(materialImageInfo)) {
                 continue;
             }
             try {
                 String url = "";
-                if(Check.isNull(materialInfo)){
-                    url= (String) materialImageInfo.getUrl();
-                }else {
-                    url= materialInfo.getUrl();
+                if (Check.isNull(materialInfo)) {
+                    url = (String) materialImageInfo.getUrl();
+                } else {
+                    url = materialInfo.getUrl();
                 }
                 String localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
 
@@ -115,7 +117,7 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                         public void run() {
                             try {
                                 log.info("头条文件多线程上传:{},accountId:{}", Thread.currentThread().getName(), accountId);
-                                if (materialInfo!=null&&"VIDEO".equals(materialInfo.getType())) {
+                                if (materialInfo != null && "VIDEO".equals(materialInfo.getType())) {
                                     fileInfoService.uploadVideoToBytedance(String.valueOf(accountId), localUrl, userId, materialInfo.getMaterialName());
 
                                 } else if ("IMAGE".equals(materialImageInfo.getType())) {
@@ -133,6 +135,9 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
         }
     }
 
+    @Autowired
+    private IKuaiShouAdvertiserBaseInfoService advertiserBaseInfoService;
+
     private void kuaiShouUpload(String mediaId, JSONArray materialArray, JSONArray accountArray, String userId) {
         for (int j = 0; j < materialArray.size(); j++) {
             String materialId = materialArray.getString(j);
@@ -182,41 +187,23 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                 String result = exceptInfoForRestTemplate(url, requestJson, headerMap);
                                 JSONObject resultJson = JSONObject.parseObject(result);
                                 if (!Check.isNull(resultJson)) {
+                                    KuaiShouAdvertiserBaseInfo baseInfo = advertiserBaseInfoService.getBaseInfo(accountId);
+
                                     if (resultJson.getInteger("code") == 0) {
                                         JSONObject dataJson = resultJson.getJSONObject("data");
                                         if (!Check.isNull(dataJson)) {
-
                                             String signature = dataJson.getString("signature");
-                                           /*
-                                             String photoId = dataJson.getString("photo_id");
-                                            KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
-                                            videoGet.setAccountId(accountId);
-                                            videoGet.setId(accountId + photoId);
-                                            videoGet.setUrl(materialInfo.getUrl());
-                                            QueryWrapper<MaterialParameter> parameterQueryWrapper = new QueryWrapper<>();
-                                            parameterQueryWrapper.eq("material_id", signature);
-                                            parameterQueryWrapper.last("limit 1");
-
-                                            MaterialParameter materialParameter = parameterMapper.selectOne(parameterQueryWrapper);
-                                            if (!Check.isNull(materialParameter)) {
-                                                String width = materialParameter.getWidth();
-                                                String height = materialParameter.getHeight();
-                                                videoGet.setWidth(Integer.valueOf(width));
-                                                videoGet.setHeight(Integer.valueOf(height));
-                                                Integer type = MaterialEnum.getTypeBySize(Integer.valueOf(width), Integer.valueOf(height));
-                                                if (!Check.isNull(type)) {
-                                                    videoGet.setMaterialType(type);
-                                                }
-                                            }
-                                            videoGet.setPhotoId(photoId);
-                                            videoGet.setSignature(signature);
-                                            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-                                            videoGet.setStatDate(DateUtils.parseDate(nowDate, "yyyy-MM-dd"));
-                                            videoGet.setCoverUrl(materialInfo.getUrl() + "?x-oss-process=video/snapshot,t_0,m_fast");
-                                            videoGet.setUploadDate(new Date());
-                                            kuaiShouVideoGetService.saveOrUpdate(videoGet);*/
+                                            //同步 视频关联的封面
                                             materialUploadImageService.uploadImage(signature, accountId, ctopOauthToken.getAccessToken());
+                                            // 发送推送成功通知
+                                            UserAllocation allocation = userAllocationService.getByAccountId(accountId);
+                                            Project project = projectService.getById(allocation.getProjectId());
+                                            String message = messageTemplate.getMaterialSyncSucessTemplate(project.getProjectName(), baseInfo.getUserId(), baseInfo.getUserName(), materialInfo.getMaterialName(), resultJson.getString("message"));
+                                            sendMessageService.sendMessage(userId, message);
 
+                                            /**
+                                             * 异步获取视频信息
+                                             */
                                             Thread thread = new Thread() {
                                                 @Override
                                                 public void run() {
@@ -233,10 +220,10 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                                         log.info("快手素材同步完成,accountId:{},code:{},返回信息:{}", accountId, materialInfo.getCode(), resultJson);
                                     } else {
                                         log.error("快手同步素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
-                                        //  发送消息到上传人
+                                        //  发送推送失败消息到上传人
                                         UserAllocation allocation = userAllocationService.getByAccountId(accountId);
                                         Project project = projectService.getById(allocation.getProjectId());
-                                        String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), accountId, allocation.getAuthName(), materialInfo.getMaterialName(), resultJson.getString("message"));
+                                        String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), baseInfo.getUserId(), baseInfo.getUserName(), materialInfo.getMaterialName(), resultJson.getString("message"));
                                         sendMessageService.sendMessage(userId, message);
                                     }
                                 }

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

@@ -2247,9 +2247,10 @@ public class BatchController {
         Result<Boolean> result = new Result<>();
         try {
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -30);
             String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, 1);
-            syncPullMaterialService.getSyncVideoList(accountId, nowDate, nowDate);
-            syncPullMaterialService.getSyncSuZaoList(accountId, nowDate, endDate);
+            syncPullMaterialService.getSyncVideoList(accountId, startDate, nowDate);
+            syncPullMaterialService.getSyncSuZaoList(accountId, startDate, endDate);
             Thread.sleep(5 * 1000L);
             result.setSuccess(true);
             result.setResult(true);

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

@@ -0,0 +1,304 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProgramCreative;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouProgramCreativeService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 快手-程序化创意
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-09-22
+ */
+@Slf4j
+@Api(tags = "快手-程序化创意")
+@RestController
+@RequestMapping("/ctop/kuaishouProgramCreative")
+public class KuaishouProgramCreativeController {
+    @Autowired
+    private IKuaishouProgramCreativeService kuaishouProgramCreativeService;
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouProgramCreative
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "快手-程序化创意-分页列表查询")
+    @ApiOperation(value = "快手-程序化创意-分页列表查询", notes = "快手-程序化创意-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouProgramCreative>> queryPageList(KuaishouProgramCreative kuaishouProgramCreative,
+                                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                HttpServletRequest req) {
+        Result<IPage<KuaishouProgramCreative>> result = new Result<>();
+        try {
+            if (Check.isNull(kuaishouProgramCreative.getAccountId()) || Check.isNull(kuaishouProgramCreative.getUnitId())) {
+                throw new Exception("必填参数不能为空");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(kuaishouProgramCreative.getAccountId());
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            kuaishouProgramCreativeService.getProgramCreative(oauthToken.getAccountId(), kuaishouProgramCreative.getUnitId(), oauthToken.getAccessToken(), null, null, 1);
+            QueryWrapper<KuaishouProgramCreative> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouProgramCreative, req.getParameterMap());
+            Page<KuaishouProgramCreative> page = new Page<KuaishouProgramCreative>(pageNo, pageSize);
+            IPage<KuaishouProgramCreative> pageList = kuaishouProgramCreativeService.page(page, queryWrapper);
+            result.setSuccess(true);
+            result.setResult(pageList);
+        } catch (Exception e) {
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+
+    /**
+     * 创建程序化创意
+     *
+     * @param requestJson
+     * @return
+     */
+
+    @PostMapping(value = "/createProgramCreative")
+    public Result<KuaishouProgramCreative> createProgramCreative(@RequestBody JSONObject requestJson) {
+        Result<KuaishouProgramCreative> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("创建程序化创意参数不能为空");
+            }
+
+            Long accountId = requestJson.getLong("accountId");
+            if (Check.isNull(accountId)) {
+                throw new Exception("请选择账户id");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+
+
+            JSONObject returnJson = kuaishouProgramCreativeService.createProgramCreative(oauthToken, requestJson);
+            result.success("添加成功!");
+
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
+    /**
+     * 添加
+     *
+     * @param kuaishouProgramCreative
+     * @return
+     */
+    @AutoLog(value = "快手-程序化创意-添加")
+    @ApiOperation(value = "快手-程序化创意-添加", notes = "快手-程序化创意-添加")
+    @PostMapping(value = "/add")
+    public Result<KuaishouProgramCreative> add(@RequestBody KuaishouProgramCreative kuaishouProgramCreative) {
+        Result<KuaishouProgramCreative> result = new Result<>();
+        try {
+            kuaishouProgramCreativeService.save(kuaishouProgramCreative);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouProgramCreative
+     * @return
+     */
+    @AutoLog(value = "快手-程序化创意-编辑")
+    @ApiOperation(value = "快手-程序化创意-编辑", notes = "快手-程序化创意-编辑")
+    @PutMapping(value = "/edit")
+    public Result<KuaishouProgramCreative> edit(@RequestBody KuaishouProgramCreative kuaishouProgramCreative) {
+        Result<KuaishouProgramCreative> result = new Result<KuaishouProgramCreative>();
+        KuaishouProgramCreative kuaishouProgramCreativeEntity = kuaishouProgramCreativeService.getById(kuaishouProgramCreative.getId());
+        if (kuaishouProgramCreativeEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = kuaishouProgramCreativeService.updateById(kuaishouProgramCreative);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "快手-程序化创意-通过id删除")
+    @ApiOperation(value = "快手-程序化创意-通过id删除", notes = "快手-程序化创意-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            kuaishouProgramCreativeService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "快手-程序化创意-批量删除")
+    @ApiOperation(value = "快手-程序化创意-批量删除", notes = "快手-程序化创意-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouProgramCreative> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouProgramCreative> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouProgramCreativeService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "快手-程序化创意-通过id查询")
+    @ApiOperation(value = "快手-程序化创意-通过id查询", notes = "快手-程序化创意-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<KuaishouProgramCreative> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<KuaishouProgramCreative> result = new Result<>();
+        KuaishouProgramCreative kuaishouProgramCreative = kuaishouProgramCreativeService.getById(id);
+        if (kuaishouProgramCreative == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(kuaishouProgramCreative);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouProgramCreative> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouProgramCreative kuaishouProgramCreative = JSON.parseObject(deString, KuaishouProgramCreative.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouProgramCreative, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouProgramCreative> pageList = kuaishouProgramCreativeService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "快手-程序化创意列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouProgramCreative.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("快手-程序化创意列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<KuaishouProgramCreative> listKuaishouProgramCreatives = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouProgramCreative.class, params);
+                kuaishouProgramCreativeService.saveBatch(listKuaishouProgramCreatives);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouProgramCreatives.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

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

@@ -30,9 +30,9 @@ public class KuaiShouActionBarText {
     /**
      * id
      */
-    @TableId(type = IdType.UUID)
+    @TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "id")
-    private Integer id;
+    private Long id;
     /**
      * 类型
      */

+ 69 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouOverRunLog.java

@@ -0,0 +1,69 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 超限记录表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-09-28
+ */
+@Data
+@TableName("ctop_kuaishou_over_run_log")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_over_run_log对象", description = "超限记录表")
+public class KuaishouOverRunLog {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 1 创意
+     */
+    @Excel(name = "1 创意", width = 15)
+    @ApiModelProperty(value = "1 创意")
+    private Integer mailType;
+    /**
+     * 消耗预警 日期
+     */
+    @Excel(name = "消耗预警 日期", width = 15)
+    @ApiModelProperty(value = "消耗预警 日期")
+    private String statDate;
+    /**
+     * 消耗预警 小时
+     */
+    @Excel(name = "消耗预警 小时", width = 15)
+    @ApiModelProperty(value = "消耗预警 小时")
+    private Integer statHour;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

+ 170 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouProgramCreative.java

@@ -0,0 +1,170 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 快手-程序化创意
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-09-22
+ */
+@Data
+@TableName("ctop_kuaishou_program_creative")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_program_creative对象", description = "快手-程序化创意")
+public class KuaishouProgramCreative {
+
+    /**
+     * id
+     */
+    @TableId
+    @ApiModelProperty(value = "id")
+    private String id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 广告组ID
+     */
+    @Excel(name = "广告组ID", width = 15)
+    @ApiModelProperty(value = "广告组ID")
+    private Long unitId;
+    /**
+     * 程序化创意包名称
+     */
+    @Excel(name = "程序化创意包名称", width = 15)
+    @ApiModelProperty(value = "程序化创意包名称")
+    private String packageName;
+    /**
+     * 横版视频 id list
+     */
+    @Excel(name = "横版视频 id list", width = 15)
+    @ApiModelProperty(value = "横版视频 id list")
+    private String horizontalPhotoIds;
+    /**
+     * 竖版视频 id list
+     */
+    @Excel(name = "竖版视频 id list", width = 15)
+    @ApiModelProperty(value = "竖版视频 id list")
+    private String verticalPhotoIds;
+    /**
+     * 封面imageToken
+     */
+    @Excel(name = "封面imageToken", width = 15)
+    @ApiModelProperty(value = "封面imageToken")
+    private String coverImageTokens;
+    /**
+     * 封面链接地址
+     */
+    @Excel(name = "封面链接地址", width = 15)
+    @ApiModelProperty(value = "封面链接地址")
+    private String coverImageUrls;
+    /**
+     * 建站id
+     */
+    @Excel(name = "建站id", width = 15)
+    @ApiModelProperty(value = "建站id")
+    private Long siteId;
+    /**
+     * 封面贴纸
+     */
+    @Excel(name = "封面贴纸", width = 15)
+    @ApiModelProperty(value = "封面贴纸")
+    private String stickerStyles;
+    /**
+     * 封面广告语
+     */
+    @Excel(name = "封面广告语", width = 15)
+    @ApiModelProperty(value = "封面广告语")
+    private String coverSlogans;
+    /**
+     * 行动号召按钮
+     */
+    @Excel(name = "行动号召按钮", width = 15)
+    @ApiModelProperty(value = "行动号召按钮")
+    private String actionBar;
+    /**
+     * 作品广告语
+     */
+    @Excel(name = "作品广告语", width = 15)
+    @ApiModelProperty(value = "作品广告语")
+    private String captions;
+    /**
+     * 第三方监测链接
+     */
+    @Excel(name = "第三方监测链接", width = 15)
+    @ApiModelProperty(value = "第三方监测链接")
+    private String clickUrl;
+    /**
+     * 第三方ActionBar点击监控链接
+     */
+    @Excel(name = "第三方ActionBar点击监控链接", width = 15)
+    @ApiModelProperty(value = "第三方ActionBar点击监控链接")
+    private String actionbarClickUrl;
+    /**
+     * 程序化创意操作状态,1:投放,2:暂停,3:删除
+     */
+    @Excel(name = "程序化创意操作状态,1:投放,2:暂停,3:删除", width = 15)
+    @ApiModelProperty(value = "程序化创意操作状态,1:投放,2:暂停,3:删除")
+    private Integer putStatus;
+    /**
+     * 程序化创意状态 -1:不限,1:计划已暂停,3:计划超预算,6:余额不足,11:组审核中,12:组审核未通过,14:已结束,15:组已暂停,17:组超预算,19:未达投放时间,40:创意已删除,41:审核中,42:审核未通过,46:已暂停,52:投放中,53:作品异常,55:部分素材审核通过
+     */
+    @Excel(name = "程序化创意状态 -1:不限,1:计划已暂停,3:计划超预算,6:余额不足,11:组审核中,12:组审核未通过,14:已结束,15:组已暂停,17:组超预算,19:未达投放时间,40:创意已删除,41:审核中,42:审核未通过,46:已暂停,52:投放中,53:作品异常,55:部分素材审核通过", width = 15)
+    @ApiModelProperty(value = "程序化创意状态 -1:不限,1:计划已暂停,3:计划超预算,6:余额不足,11:组审核中,12:组审核未通过,14:已结束,15:组已暂停,17:组超预算,19:未达投放时间,40:创意已删除,41:审核中,42:审核未通过,46:已暂停,52:投放中,53:作品异常,55:部分素材审核通过")
+    private Integer viewStatus;
+    /**
+     * 程序化创意状态描述
+     */
+    @Excel(name = "程序化创意状态描述", width = 15)
+    @ApiModelProperty(value = "程序化创意状态描述")
+    private String viewStatusReason;
+    /**
+     * 创意创建时间
+     */
+    @Excel(name = "创意创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创意创建时间")
+    private Date creativeCreateTime;
+    /**
+     * 创意最后修改时间
+     */
+    @Excel(name = "创意最后修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创意最后修改时间")
+    private Date creativeUpdateTime;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @Excel(name = "updateTime", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+}

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

@@ -11,4 +11,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface KuaiShouActionBarTextMapper extends BaseMapper<KuaiShouActionBarText> {
 
+    void insertSelective(KuaiShouActionBarText kuaiShouActionBarText);
 }

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

@@ -17,4 +17,6 @@ public interface KuaiShouCreativeMapper extends BaseMapper<KuaiShouCreative> {
     void replaceBatch(@Param(value = "creatives") List<KuaiShouCreative> creatives);
 
     Integer checkCreativeCount(@Param("accountId") Long accountId, @Param("unitId") Long unitId);
+
+    Integer getCreateCount(Long accountId, String startTime);
 }

+ 15 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouOverRunLogMapper.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouOverRunLog;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 超限记录表
+ *
+ * @author: jeecg-boot
+ * @date: 2020-09-28
+ * @cersion: V1.0
+ */
+public interface KuaishouOverRunLogMapper extends BaseMapper<KuaishouOverRunLog> {
+
+}

+ 16 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouProgramCreativeMapper.java

@@ -0,0 +1,16 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProgramCreative;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手-程序化创意
+ *
+ * @author: jeecg-boot
+ * @date: 2020-09-22
+ * @cersion: V1.0
+ */
+public interface KuaishouProgramCreativeMapper extends BaseMapper<KuaishouProgramCreative> {
+
+
+}

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

@@ -2,4 +2,44 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouActionBarTextMapper">
 
+    <insert id="insertSelective" parameterType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouActionBarText">
+        replace into ctop_kuaishou_action_bar_text
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                id,
+            </if>
+            <if test="type != null">
+                type,
+            </if>
+
+            <if test="actionBarText != null">
+                action_bar_text,
+            </if>
+
+            <if test="createTime != null">
+                create_time,
+            </if>
+            <if test="updateTime != null">
+                update_time,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                #{id,jdbcType=BIGINT},
+            </if>
+            <if test="type != null">
+                #{type},
+            </if>
+            <if test="actionBarText != null">
+                #{actionBarText},
+            </if>
+            <if test="createTime != null">
+                #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </trim>
+    </insert>
+
 </mapper>

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

@@ -87,4 +87,17 @@
      where  account_id = #{accountId}
      and unit_id = #{unitId}
     </select>
+
+    <select id="getCreateCount" resultType="java.lang.Integer">
+
+    SELECT
+	count(1)
+   FROM
+	ctop_kuaishou_creative
+   WHERE account_id = #{accountId}
+   AND creative_create_time &gt;= #{startTime}
+   AND create_channel = 1;
+    </select>
+
+
 </mapper>

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

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouOverRunLogMapper">
+
+</mapper>

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

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouProgramCreativeMapper.java:14">
+
+</mapper>

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

@@ -11,4 +11,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IKuaiShouActionBarTextService extends IService<KuaiShouActionBarText> {
 
+    void getActionBarText();
 }

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

@@ -3,6 +3,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -33,4 +34,13 @@ public interface IKuaiShouCreativeService extends IService<KuaiShouCreative> {
     Integer checkCreativeCount(Long accountId, Long unitId);
 
     void syncCreative(Long accountId, String accessToken, Long campaignId, Integer page);
+
+    /**
+     * 获取当前创意创建数
+     * @param accountId
+     * @param startTime
+     * @return
+     */
+
+    Integer getCreateCount(Long accountId, String startTime);
 }

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

@@ -0,0 +1,7 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+public interface IKuaiShouOverRunSendMessageService {
+    void creativeOverRunSendMessage(Long accountId);
+
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouOverRunLog;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 超限记录表
+ * @Author: jeecg-boot
+ * @Date: 2020-09-28
+ * @Version: V1.0
+ */
+public interface IKuaishouOverRunLogService extends IService<KuaishouOverRunLog> {
+
+}

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

@@ -0,0 +1,18 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProgramCreative;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 快手-程序化创意
+ * @Author: jeecg-boot
+ * @Date: 2020-09-22
+ * @Version: V1.0
+ */
+public interface IKuaishouProgramCreativeService extends IService<KuaishouProgramCreative> {
+    void getProgramCreative(Long accountId, Long unitId, String accessToken, String startDate, String endDate, Integer page);
+
+    JSONObject createProgramCreative(CtopOauthToken oauthToken, JSONObject requestJson);
+}

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

@@ -24,6 +24,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import static java.lang.Integer.valueOf;
+
 @Slf4j
 @Service
 public class BatchServiceImpl implements IBatchService {
@@ -174,10 +176,11 @@ public class BatchServiceImpl implements IBatchService {
         if (!Check.isNull(scene_id)) {
             unitJson.put("scene_id", scene_id);
         }
-
+        Integer sceneId = valueOf(scene_id.get(0).toString());
         // 资源创作方式
-        if (!Check.isNull(requestJson.getInteger("unitType"))) {
-            unitJson.put("unit_type", requestJson.getInteger("unitType"));
+        Integer unitType = requestJson.getInteger("unitType");
+        if (!Check.isNull(unitType)) {
+            unitJson.put("unit_type", unitType);
         }
 
         // 转化目标id
@@ -282,25 +285,28 @@ public class BatchServiceImpl implements IBatchService {
         if (!Check.isNull(requestJson.getJSONArray("deviceBrand"))) {
             targetJson.put("device_brand", requestJson.getJSONArray("deviceBrand"));
         }
-        //设备价格
-        if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
-            targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
-        }
-        //商业兴趣类型
-        if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
-            targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
-        }
-        // 商业兴趣
-        if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
-            targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
-        }
-        //网红粉丝
-        if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
-            targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
-        }
-        //兴趣视频用户
-        if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
-            targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
+
+        if (sceneId != 5) {
+            //设备价格
+            if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
+                targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
+            }
+            //商业兴趣类型
+            if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
+                targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
+            }
+            // 商业兴趣
+            if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
+                targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
+            }
+            //网红粉丝
+            if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
+                targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
+            }
+            //兴趣视频用户
+            if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
+                targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
+            }
         }
         // APP行为-按分类
         if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
@@ -319,26 +325,28 @@ public class BatchServiceImpl implements IBatchService {
             targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
         }
 
-        JSONObject intelliExtendJson = new JSONObject();
+        if (sceneId != 5) {
+            JSONObject intelliExtendJson = new JSONObject();
 
-        // 开启智能扩量
-        if (!Check.isNull(requestJson.getInteger("isOpen"))) {
-            intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
-        }
-        //不可突破年龄
-        if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
-            intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
-        }
-        //不可突破性别
-        if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
-            intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
-        }
-        // 不可突破地域
-        if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
-            intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
-        }
-        if (!Check.isNull(intelliExtendJson)) {
-            targetJson.put("intelli_extend", intelliExtendJson);
+            // 开启智能扩量
+            if (!Check.isNull(requestJson.getInteger("isOpen"))) {
+                intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
+            }
+            //不可突破年龄
+            if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
+                intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
+            }
+            //不可突破性别
+            if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
+                intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
+            }
+            // 不可突破地域
+            if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
+                intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
+            }
+            if (!Check.isNull(intelliExtendJson)) {
+                targetJson.put("intelli_extend", intelliExtendJson);
+            }
         }
 
         unitJson.put("target", targetJson);
@@ -400,6 +408,7 @@ public class BatchServiceImpl implements IBatchService {
                         successJson.put("unitName", unitName);
                         successJson.put("sceneId", scene_id);
                         successJson.put("ocpxActionType", ocpx_action_type);
+                        successJson.put("unitType", unitType);
                         successArr.add(successJson);
 
                         if (!Check.isNull(type) && "copy".equals(type)) {
@@ -471,6 +480,7 @@ public class BatchServiceImpl implements IBatchService {
             if (!Check.isNull(scene_id)) {
                 unitJson.put("scene_id", scene_id);
             }
+            Integer sceneId = valueOf(scene_id.get(0).toString());
 
             // 资源创作方式
             if (!Check.isNull(requestJson.getInteger("unitType"))) {
@@ -575,29 +585,34 @@ public class BatchServiceImpl implements IBatchService {
             if (!Check.isNull(requestJson.getInteger("network"))) {
                 targetJson.put("network", requestJson.getInteger("network"));
             }
+
             //设备品牌
             if (!Check.isNull(requestJson.getJSONArray("deviceBrand"))) {
                 targetJson.put("device_brand", requestJson.getJSONArray("deviceBrand"));
             }
-            //设备价格
-            if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
-                targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
-            }
-            //商业兴趣类型
-            if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
-                targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
-            }
-            // 商业兴趣
-            if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
-                targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
-            }
-            //网红粉丝
-            if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
-                targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
-            }
-            //兴趣视频用户
-            if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
-                targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
+            if (sceneId != 5) {
+
+
+                //设备价格
+                if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
+                    targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
+                }
+                //商业兴趣类型
+                if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
+                    targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
+                }
+                // 商业兴趣
+                if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
+                    targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
+                }
+                //网红粉丝
+                if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
+                    targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
+                }
+                //兴趣视频用户
+                if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
+                    targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
+                }
             }
             // APP行为-按分类
             if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
@@ -618,26 +633,27 @@ public class BatchServiceImpl implements IBatchService {
 
             JSONObject intelliExtendJson = new JSONObject();
 
-            // 开启智能扩量
-            if (!Check.isNull(requestJson.getInteger("isOpen"))) {
-                intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
-            }
-            //不可突破年龄
-            if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
-                intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
-            }
-            //不可突破性别
-            if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
-                intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
-            }
-            // 不可突破地域
-            if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
-                intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
-            }
-            if (!Check.isNull(intelliExtendJson)) {
-                targetJson.put("intelli_extend", intelliExtendJson);
+            if (sceneId != 5) {
+                // 开启智能扩量
+                if (!Check.isNull(requestJson.getInteger("isOpen"))) {
+                    intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
+                }
+                //不可突破年龄
+                if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
+                    intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
+                }
+                //不可突破性别
+                if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
+                    intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
+                }
+                // 不可突破地域
+                if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
+                    intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
+                }
+                if (!Check.isNull(intelliExtendJson)) {
+                    targetJson.put("intelli_extend", intelliExtendJson);
+                }
             }
-
             unitJson.put("target", targetJson);
             JSONObject groupJson = requestJson.getJSONObject("groupArr");
             if (Check.isNull(groupJson)) {
@@ -746,6 +762,8 @@ public class BatchServiceImpl implements IBatchService {
             if (!Check.isNull(scene_id)) {
                 unitJson.put("scene_id", scene_id);
             }
+
+            Integer sceneId = valueOf(scene_id.get(0).toString());
             // 资源创作方式
             if (!Check.isNull(group.getUnitType())) {
                 if (!Check.isNull(group.getUnitType())) {
@@ -754,7 +772,6 @@ public class BatchServiceImpl implements IBatchService {
 
                 //投放开始时间
                 if (!Check.isNull(group.getBeginTime())) {
-
                     String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
                     boolean beginTimeBoolean = DateUtils.compare(group.getBeginTime(), nowDate);
                     if (beginTimeBoolean) {
@@ -869,29 +886,32 @@ public class BatchServiceImpl implements IBatchService {
                     if (!Check.isNull(groupTarget.getDeviceBrand())) {
                         targetJson.put("device_brand", JSONArray.parseArray(groupTarget.getDeviceBrand()));
                     }
-                    //设备价格
-                    if (!Check.isNull(groupTarget.getDevicePrice())) {
-                        targetJson.put("device_price", JSONArray.parseArray(groupTarget.getDevicePrice()));
-                    }
-                    //商业兴趣类型
-                    if (!Check.isNull(groupTarget.getBusinessInterestType())) {
-                        targetJson.put("business_interest_type", groupTarget.getBusinessInterestType());
-                    }
-                    // 商业兴趣
-                    if (!Check.isNull(groupTarget.getBusinessInterest())) {
-                        targetJson.put("business_interest", JSONArray.parseArray(groupTarget.getBusinessInterest()));
-                    }
-                    //网红粉丝
-                    if (!Check.isNull(groupTarget.getFansStar())) {
-                        targetJson.put("fans_star", JSONArray.parseArray(groupTarget.getFansStar()));
-                    }
-                    //兴趣视频用户
-                    if (!Check.isNull(groupTarget.getInterestVideo())) {
-                        targetJson.put("interest_video", JSONArray.parseArray(groupTarget.getInterestVideo()));
-                    }
-                    // APP行为-按分类
-                    if (!Check.isNull(groupTarget.getAppInterest())) {
-                        targetJson.put("app_interest", JSONArray.parseArray(groupTarget.getAppInterest()));
+                    if (sceneId != 5) {
+
+                        //设备价格
+                        if (!Check.isNull(groupTarget.getDevicePrice())) {
+                            targetJson.put("device_price", JSONArray.parseArray(groupTarget.getDevicePrice()));
+                        }
+                        //商业兴趣类型
+                        if (!Check.isNull(groupTarget.getBusinessInterestType())) {
+                            targetJson.put("business_interest_type", groupTarget.getBusinessInterestType());
+                        }
+                        // 商业兴趣
+                        if (!Check.isNull(groupTarget.getBusinessInterest())) {
+                            targetJson.put("business_interest", JSONArray.parseArray(groupTarget.getBusinessInterest()));
+                        }
+                        //网红粉丝
+                        if (!Check.isNull(groupTarget.getFansStar())) {
+                            targetJson.put("fans_star", JSONArray.parseArray(groupTarget.getFansStar()));
+                        }
+                        //兴趣视频用户
+                        if (!Check.isNull(groupTarget.getInterestVideo())) {
+                            targetJson.put("interest_video", JSONArray.parseArray(groupTarget.getInterestVideo()));
+                        }
+                        // APP行为-按分类
+                        if (!Check.isNull(groupTarget.getAppInterest())) {
+                            targetJson.put("app_interest", JSONArray.parseArray(groupTarget.getAppInterest()));
+                        }
                     }
                     // APP行为-按APP名称
                     if (!Check.isNull(groupTarget.getAppIds())) {
@@ -906,26 +926,30 @@ public class BatchServiceImpl implements IBatchService {
                         targetJson.put("exclude_population", JSONArray.parseArray(groupTarget.getExcludePopulation()));
                     }
 
-                    JSONObject intelliExtendJson = new JSONObject();
+                    if (sceneId != 5) {
 
-                    // 开启智能扩量
-                    if (!Check.isNull(groupTarget.getIsOpen())) {
-                        intelliExtendJson.put("is_open", groupTarget.getIsOpen());
-                    }
-                    //不可突破年龄
-                    if (!Check.isNull(groupTarget.getNoAgeBreak())) {
-                        intelliExtendJson.put("no_age_break", groupTarget.getNoAgeBreak());
-                    }
-                    //不可突破性别
-                    if (!Check.isNull(groupTarget.getNoGenderBreak())) {
-                        intelliExtendJson.put("no_gender_break", groupTarget.getNoGenderBreak());
-                    }
-                    // 不可突破地域
-                    if (!Check.isNull(groupTarget.getNoAreaBreak())) {
-                        intelliExtendJson.put("no_area_break", groupTarget.getNoAreaBreak());
-                    }
-                    if (!Check.isNull(intelliExtendJson)) {
-                        targetJson.put("intelli_extend", intelliExtendJson);
+
+                        JSONObject intelliExtendJson = new JSONObject();
+
+                        // 开启智能扩量
+                        if (!Check.isNull(groupTarget.getIsOpen())) {
+                            intelliExtendJson.put("is_open", groupTarget.getIsOpen());
+                        }
+                        //不可突破年龄
+                        if (!Check.isNull(groupTarget.getNoAgeBreak())) {
+                            intelliExtendJson.put("no_age_break", groupTarget.getNoAgeBreak());
+                        }
+                        //不可突破性别
+                        if (!Check.isNull(groupTarget.getNoGenderBreak())) {
+                            intelliExtendJson.put("no_gender_break", groupTarget.getNoGenderBreak());
+                        }
+                        // 不可突破地域
+                        if (!Check.isNull(groupTarget.getNoAreaBreak())) {
+                            intelliExtendJson.put("no_area_break", groupTarget.getNoAreaBreak());
+                        }
+                        if (!Check.isNull(intelliExtendJson)) {
+                            targetJson.put("intelli_extend", intelliExtendJson);
+                        }
                     }
 
                     unitJson.put("target", targetJson);
@@ -1244,9 +1268,7 @@ public class BatchServiceImpl implements IBatchService {
         creativeJson.put("unit_id", unitId);
 
         // 素材类型
-        if (!Check.isNull(requestJson.get("creativeMaterialType"))) {
-            creativeJson.put("creative_material_type", requestJson.get("creativeMaterialType"));
-        }
+
         String action_bar_text = requestJson.getString("actionBarText");
         String click_track_url = requestJson.getString("clickTrackUrl");
         String site_id = requestJson.getString("siteId");
@@ -1260,6 +1282,11 @@ public class BatchServiceImpl implements IBatchService {
         if (!Check.isNull(dataJsons)) {
             for (int i = 0; i < dataJsons.size(); i++) {
                 JSONObject dataJson = dataJsons.getJSONObject(i);
+
+                String creativeMaterialType = dataJson.getString("creativeMaterialType");
+                String shortSlogan = dataJson.getString("shortSlogan");
+
+
                 if (!Check.isNull(dataJsons)) {
                     String description = dataJson.getString("description");
                     String photo_id = dataJson.getString("photoId");
@@ -1274,10 +1301,20 @@ public class BatchServiceImpl implements IBatchService {
                                 creativeJson.put("description", description.trim());
                                 creativeJson.put("creative_name", name);
                                 creativeJson.put("photo_id", photo_id);
-                                creativeJson.put("click_track_url", click_track_url);
+
                                 if (!Check.isNull(site_id)) {
                                     creativeJson.put("site_id", site_id);
                                 }
+                                if (!Check.isNull(creativeMaterialType)) {
+                                    creativeJson.put("creative_material_type", creativeMaterialType);
+                                }
+
+                                if (creativeMaterialType.equals("4")) {
+                                    if (!Check.isNull("shortSlogan")) {
+                                        creativeJson.put("short_slogan", shortSlogan);
+                                    }
+
+                                }
                                 String imageToken = null;
                                 String signature = imageJson.getString("signature");
                                 if (!Check.isNull(signature)) {
@@ -1300,7 +1337,16 @@ public class BatchServiceImpl implements IBatchService {
                                         continue;
                                     }
                                 }
-                                creativeJson.put("image_token", imageToken);
+                                if (creativeMaterialType.equals("4")) {
+                                    JSONArray tokenArr = new JSONArray();
+                                    tokenArr.add(imageToken);
+                                    creativeJson.put("image_tokens", tokenArr);
+                                    creativeJson.put("click_track_url", click_track_url);
+                                    creativeJson.put("impression_url", click_track_url);
+                                } else {
+                                    creativeJson.put("image_token", imageToken);
+                                    creativeJson.put("click_track_url", click_track_url);
+                                }
                                 Map<String, Object> returnUnitMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), accountId, creativeJson, 1);
                                 if (!Check.isNullMap(returnUnitMap)) {
                                     Integer code = (Integer) returnUnitMap.get("code");
@@ -1410,6 +1456,8 @@ public class BatchServiceImpl implements IBatchService {
                 unitJson.put("scene_id", scene_id);
             }
 
+            Integer sceneId = Integer.valueOf(scene_id.get(0).toString());
+
             // 出价
             if (!Check.isNull(requestJson.getLong("bid"))) {
                 unitJson.put("bid", requestJson.getLong("bid"));
@@ -1525,33 +1573,37 @@ public class BatchServiceImpl implements IBatchService {
             if (!Check.isNull(requestJson.getInteger("network"))) {
                 targetJson.put("network", requestJson.getInteger("network"));
             }
+
+
             //设备品牌
             if (!Check.isNull(requestJson.getJSONArray("deviceBrand"))) {
                 targetJson.put("device_brand", requestJson.getJSONArray("deviceBrand"));
             }
-            //设备价格
-            if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
-                targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
-            }
-            //商业兴趣类型
-            if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
-                targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
-            }
-            // 商业兴趣
-            if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
-                targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
-            }
-            //网红粉丝
-            if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
-                targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
-            }
-            //兴趣视频用户
-            if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
-                targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
-            }
-            // APP行为-按分类
-            if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
-                targetJson.put("app_interest", requestJson.getJSONArray("appInterest"));
+            if (sceneId != 5) {
+                //设备价格
+                if (!Check.isNull(requestJson.getJSONArray("devicePrice"))) {
+                    targetJson.put("device_price", requestJson.getJSONArray("devicePrice"));
+                }
+                //商业兴趣类型
+                if (!Check.isNull(requestJson.getInteger("businessInterestType"))) {
+                    targetJson.put("business_interest_type", requestJson.getInteger("businessInterestType"));
+                }
+                // 商业兴趣
+                if (!Check.isNull(requestJson.getJSONArray("businessInterest"))) {
+                    targetJson.put("business_interest", requestJson.getJSONArray("businessInterest"));
+                }
+                //网红粉丝
+                if (!Check.isNull(requestJson.getJSONArray("fansStar"))) {
+                    targetJson.put("fans_star", requestJson.getJSONArray("fansStar"));
+                }
+                //兴趣视频用户
+                if (!Check.isNull(requestJson.getJSONArray("interestVideo"))) {
+                    targetJson.put("interest_video", requestJson.getJSONArray("interestVideo"));
+                }
+                // APP行为-按分类
+                if (!Check.isNull(requestJson.getJSONArray("appInterest"))) {
+                    targetJson.put("app_interest", requestJson.getJSONArray("appInterest"));
+                }
             }
             // APP行为-按APP名称
             if (!Check.isNull(requestJson.getJSONArray("appIds"))) {
@@ -1566,26 +1618,28 @@ public class BatchServiceImpl implements IBatchService {
                 targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
             }
 
-            JSONObject intelliExtendJson = new JSONObject();
+            if (sceneId != 5) {
+                JSONObject intelliExtendJson = new JSONObject();
 
-            // 开启智能扩量
-            if (!Check.isNull(requestJson.getInteger("isOpen"))) {
-                intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
-            }
-            //不可突破年龄
-            if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
-                intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
-            }
-            //不可突破性别
-            if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
-                intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
-            }
-            // 不可突破地域
-            if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
-                intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
-            }
-            if (!Check.isNull(intelliExtendJson)) {
-                targetJson.put("intelli_extend", intelliExtendJson);
+                // 开启智能扩量
+                if (!Check.isNull(requestJson.getInteger("isOpen"))) {
+                    intelliExtendJson.put("is_open", requestJson.getInteger("isOpen"));
+                }
+                //不可突破年龄
+                if (!Check.isNull(requestJson.getInteger("noAgeBreak"))) {
+                    intelliExtendJson.put("no_age_break", requestJson.getInteger("noAgeBreak"));
+                }
+                //不可突破性别
+                if (!Check.isNull(requestJson.getInteger("noGenderBreak"))) {
+                    intelliExtendJson.put("no_gender_break", requestJson.getInteger("noGenderBreak"));
+                }
+                // 不可突破地域
+                if (!Check.isNull(requestJson.getInteger("noAreaBreak"))) {
+                    intelliExtendJson.put("no_area_break", requestJson.getInteger("noAreaBreak"));
+                }
+                if (!Check.isNull(intelliExtendJson)) {
+                    targetJson.put("intelli_extend", intelliExtendJson);
+                }
             }
 
             unitJson.put("target", targetJson);
@@ -1695,6 +1749,7 @@ public class BatchServiceImpl implements IBatchService {
 
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
+        log.info("获取联盟白名单,accountId:{},data:{}", accountId, resultJson);
         if (!Check.isNull(resultJson)) {
             Integer code = resultJson.getInteger("code");
             if (code == 0) {

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

@@ -1,11 +1,27 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+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.KuaiShouActionBarText;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouActionBarTextMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouActionBarTextService;
+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: 快手-行动号召文案
  * @Author: jeecg-boot
@@ -13,6 +29,57 @@ import org.springframework.stereotype.Service;
  * @Version: V1.0
  */
 @Service
+@Slf4j
 public class KuaiShouActionBarTextServiceImpl extends ServiceImpl<KuaiShouActionBarTextMapper, KuaiShouActionBarText> implements IKuaiShouActionBarTextService {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private KuaiShouActionBarTextMapper actionBarTextMapper;
+
+    @Override
+    public void getActionBarText() {
+
+        QueryWrapper queryWrapper = new QueryWrapper();
+        queryWrapper.eq("media_id", 2);
+        queryWrapper.orderByDesc("update_time");
+        queryWrapper.last("limit 1");
+        CtopOauthToken token = tokenService.getOne(queryWrapper);
+        List list = new ArrayList();
+        list.add(2);
+        list.add(3);
+        list.add(4);
+        list.add(5);
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.ACTION_BAR_TEXT_LIST;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", token.getAccessToken());
+        headers.put("Content-Type", "application/json");
+        JSONObject requestJson = new JSONObject();
+        requestJson.put("advertiser_id", token.getAccountId());
+        for (int i = 0; i < list.size(); i++) {
+            requestJson.remove("campaign_type");
+            requestJson.put("campaign_type", list.get(i));
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            Integer code = resultJson.getInteger("code");
+            if (code == 0) {
+                JSONObject data = resultJson.getJSONObject("data");
+                if (!Check.isNull(data)) {
+                    Integer campaign_type = data.getInteger("campaign_type");
+                    JSONArray action_bar_text = data.getJSONArray("action_bar_text");
+                    if (!Check.isNull(action_bar_text)) {
+                        for (int j = 0; j < action_bar_text.size(); j++) {
+                            String actionBarText = action_bar_text.getString(j);
+                            KuaiShouActionBarText kuaiShouActionBarText = new KuaiShouActionBarText();
+                            kuaiShouActionBarText.setActionBarText(actionBarText);
+                            kuaiShouActionBarText.setType(campaign_type);
+                            actionBarTextMapper.insertSelective(kuaiShouActionBarText);
+                        }
+                    }
+                }
+
+            }
+        }
+
 
+    }
 }

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

@@ -17,10 +17,7 @@ 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;
+import java.util.*;
 
 /**
  * @Description: 快手-创意信息
@@ -180,4 +177,9 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
         this.replaceBatch(creatives);
         this.syncCreative(accountId, accessToken, campaignId, page + 1);
     }
+
+    @Override
+    public Integer getCreateCount(Long accountId, String startTime) {
+        return kuaiShouCreativeMapper.getCreateCount(accountId, startTime);
+    }
 }

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

@@ -0,0 +1,88 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.service.IMessageTemplate;
+import cn.com.ctop.common.module.service.ISendMessageService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouOverRunLog;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouOverRunLogMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouOverRunSendMessageService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouOverRunLogService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+
+@Service
+@Slf4j
+public class KuaiShouOverRunSendMessageServiceImpl extends ServiceImpl<KuaishouOverRunLogMapper, KuaishouOverRunLog> implements IKuaiShouOverRunSendMessageService {
+
+    @Autowired
+    private IKuaiShouCreativeService creativeService;
+    @Autowired
+    private IMessageTemplate messageTemplate;
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private ISendMessageService sendMessageService;
+    @Autowired
+    private IKuaishouOverRunLogService overRunLogService;
+    @Autowired
+    private KuaishouOverRunLogMapper runLogMapper;
+
+
+    @Override
+    public void creativeOverRunSendMessage(Long accountId) {
+
+        try {
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            Integer hour = DateUtils.getHour(DateUtils.getNowDate("yyyy-MM-dd HH:mm:ss"));
+            QueryWrapper<KuaishouOverRunLog> overRunLogQueryWrapper = new QueryWrapper<>();
+            overRunLogQueryWrapper.eq("account_id", accountId);
+            overRunLogQueryWrapper.eq("stat_date", nowDate);
+            overRunLogQueryWrapper.eq("stat_hour", hour);
+            overRunLogQueryWrapper.last("limit 1");
+            KuaishouOverRunLog overRunLog = overRunLogService.getOne(overRunLogQueryWrapper);
+            if (!Check.isNull(overRunLog)) {
+                return;
+            }
+
+
+            String startTime = DateUtils.getStartTime(new Date());
+            Integer creativeCount = creativeService.getCreateCount(accountId, startTime);
+
+            UserAllocation userAllocation = userAllocationService.getByAccountId(accountId);
+            if (!Check.isNull(userAllocation)) {
+                String message = messageTemplate.getCreativeOverRunMessage(accountId, creativeCount, userAllocation.getAuthName());
+                LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+                if (Check.isNull(sysUser)) {
+                    return;
+                }
+                sendMessageService.sendMessage(sysUser.getId(), message);
+                KuaishouOverRunLog addOverRunLog = new KuaishouOverRunLog();
+                addOverRunLog.setAccountId(accountId);
+                addOverRunLog.setMailType(1);
+                addOverRunLog.setStatDate(nowDate);
+                addOverRunLog.setStatHour(hour);
+                runLogMapper.insert(addOverRunLog);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+
+        }
+
+    }
+
+    public static void main(String[] args) {
+        String startTime = DateUtils.getStartTime(new Date());
+        System.err.println(startTime);
+    }
+}

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

@@ -1725,6 +1725,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         returnJson.put("isWanJian", dataJson.getInteger("is_wan_jian"));
                         returnJson.put("isValidClue", dataJson.getInteger("is_valid_clue"));
                         returnJson.put("isPurchase", dataJson.getInteger("is_purchase"));
+                        returnJson.put("isFirstdayRoi", dataJson.getInteger("is_firstday_roi"));
+                        returnJson.put("isRegister", dataJson.getInteger("is_register"));
+                        returnJson.put("isOrderSubmit", dataJson.getInteger("is_order_submit"));
                         JSONArray deep_conversion_types = dataJson.getJSONArray("deep_conversion_types");
                         JSONArray deepConversionTypes = new JSONArray();
                         if (!Check.isNull(deep_conversion_types)) {
@@ -1763,6 +1766,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
      * @param advertiserId
      * @param requestJson
      */
+
+    @Autowired
+    private IKuaiShouOverRunSendMessageService overRunSendMessageService;
+
     @Override
     public Map<String, Object> creativeCreate(String accessToken, Long advertiserId, JSONObject requestJson, Integer count) {
         Map<String, Object> returnMap = new HashMap<>();
@@ -1804,6 +1811,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     if (code == 500000 && count <= 4) {
                         creativeCreate(accessToken, advertiserId, requestJson, count + 1);
                     }
+
+                    if (code == 400001 && resultJson.getString("message").equals("/rest/openapi/v2/creative/create已超日限")) {
+                        overRunSendMessageService.creativeOverRunSendMessage(advertiserId);
+                    }
                     log.error("创建广告创意失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson, count + 1);
                     returnMap.put("code", -1);
                     returnMap.put("message", resultJson.getString("message"));

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

@@ -0,0 +1,19 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouOverRunLog;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouOverRunLogMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouOverRunLogService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 超限记录表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-09-28
+ */
+@Service
+public class KuaishouOverRunLogServiceImpl extends ServiceImpl<KuaishouOverRunLogMapper, KuaishouOverRunLog> implements IKuaishouOverRunLogService {
+
+}

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

@@ -0,0 +1,207 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+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.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouProgramCreative;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouProgramCreativeMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouProgramCreativeService;
+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 lombok.var;
+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;
+
+/**
+ * 快手-程序化创意
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-09-22
+ */
+@Service
+@Slf4j
+public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProgramCreativeMapper, KuaishouProgramCreative> implements IKuaishouProgramCreativeService {
+
+    @Autowired
+    private IKuaiShouImageGetService imageGetService;
+    @Autowired
+    private IKuaiShouMaterialUploadService uploadService;
+
+
+    @Override
+    public void getProgramCreative(Long accountId, Long unitId, String accessToken, String startDate, String endDate, Integer page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.PROGRAM_LIST;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", accessToken);
+        Map<String, Object> param = new HashMap<>();
+        if (!Check.isNull(startDate)) {
+            param.put("start_date", startDate);
+        }
+        if (!Check.isNull(endDate)) {
+            param.put("end_date", endDate);
+        }
+
+        if (!Check.isNull(unitId)) {
+            JSONArray array = new JSONArray();
+            array.add(unitId);
+            param.put("unit_ids", array);
+        }
+
+
+        param.put("advertiser_id", accountId);
+        param.put("page_size", 500);
+        param.put("page", page);
+
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手广程序化创意异常:{},accountId:{}", message, accountId);
+            return;
+        }
+        JSONObject dataJson = resultJson.getJSONObject("data");
+        if (Check.isNull(dataJson)) {
+            log.error("获取快手广程序化创意返回data为空,accountId:{}", accountId);
+            return;
+        }
+        JSONArray details = dataJson.getJSONArray("details");
+        if (Check.isNull(details)) {
+            return;
+        }
+
+        List<KuaishouProgramCreative> programCreativeList = new ArrayList<>();
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject detailJson = details.getJSONObject(i);
+            if (!Check.isNull(detailJson)) {
+                detailJson.put("creative_create_time", detailJson.getDate("create_time"));
+                detailJson.put("creative_update_time", detailJson.getDate("update_time"));
+                var programCreative = JSONObject.toJavaObject(detailJson, KuaishouProgramCreative.class);
+                programCreative.setAccountId(accountId);
+                programCreative.setId(accountId + "_" + programCreative.getUnitId());
+                programCreativeList.add(programCreative);
+
+            }
+        }
+
+        this.saveOrUpdateBatch(programCreativeList);
+    //    getProgramCreative(accountId, unitId, accessToken, startDate, endDate, page + 1);
+
+
+    }
+
+    /**
+     * 创建程序化2.0
+     *
+     * @param oauthToken
+     * @param requestJson
+     * @return
+     */
+
+    @Override
+    public JSONObject createProgramCreative(CtopOauthToken oauthToken, JSONObject requestJson) {
+        try {
+
+
+            JSONObject pramsJson = new JSONObject();
+            pramsJson.put("advertiser_id", oauthToken.getAccountId());
+            pramsJson.put("unit_id", requestJson.getLong("unitId"));
+            pramsJson.put("package_name", requestJson.getString("packageName"));
+            pramsJson.put("horizontal_photo_ids", requestJson.getJSONArray("horizontalPhotoIds"));
+            pramsJson.put("vertical_photo_ids", requestJson.getJSONArray("verticalPhotoIds"));
+            pramsJson.put("cover_image_tokens", requestJson.getJSONArray("coverImageTokens"));
+            if (!Check.isNull(requestJson.getLong("siteId"))) {
+                pramsJson.put("site_id", requestJson.getLong("siteId"));
+            }
+
+            if (!Check.isNull(requestJson.getJSONArray("stickerStyles"))) {
+                pramsJson.put("sticker_styles", requestJson.getJSONArray("stickerStyles"));
+            }
+
+            if (!Check.isNull(requestJson.getJSONArray("coverSlogans"))) {
+                pramsJson.put("cover_slogans", requestJson.getJSONArray("coverSlogans"));
+            }
+
+            pramsJson.put("action_bar", requestJson.getString("actionBarText"));
+            pramsJson.put("captions", requestJson.getJSONArray("captions"));
+            if (!Check.isNull(requestJson.getString("clickUrl"))) {
+                pramsJson.put("click_url", requestJson.getString("clickUrl"));
+            }
+            if (!Check.isNull(requestJson.getString("actionbarClickUrl"))) {
+                pramsJson.put("actionbar_click_url", requestJson.getString("actionbarClickUrl"));
+            }
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Content-Type", "application/json");
+            headers.put("Access-Token", oauthToken.getAccessToken());
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.PROGRAM_CREATE;
+
+
+            JSONArray coverImageTokens = requestJson.getJSONArray("coverImageTokens");
+            JSONArray cover_image_tokens = new JSONArray();
+            requestJson.remove(coverImageTokens);
+            if (!Check.isNull(coverImageTokens)) {
+
+                for (int i = 0; i < coverImageTokens.size(); i++) {
+                    String signature = coverImageTokens.getString(i);
+                    if (Check.isNull(signature)) {
+                        continue;
+                    }
+                    String imageToken = null;
+
+                    if (!Check.isNull(signature)) {
+                        QueryWrapper<KuaiShouImageGet> queryWrapper = new QueryWrapper<>();
+                        queryWrapper.eq("account_id", oauthToken.getAccountId());
+                        queryWrapper.eq("signature", signature);
+                        queryWrapper.last("limit 1");
+                        KuaiShouImageGet imageGet = imageGetService.getOne(queryWrapper);
+                        if (!Check.isNull(imageGet)) {
+                            imageToken = imageGet.getImageToken();
+                        } else {
+                            String imageUrl = imageGetService.getUrlByCode(signature);
+                            imageToken = uploadService.kuauiShouImageUpload(imageUrl, signature, oauthToken.getAccountId(), oauthToken.getAccessToken());
+                        }
+                        cover_image_tokens.add(imageToken);
+                        /*if (Check.isNull(imageToken)) {
+                            JSONObject failJson = new JSONObject();
+                            failJson.put("creativeName", name);
+                            failJson.put("failMessage", "获取图片文件失败");
+                            failArr.add(failJson);
+                            continue;
+                        }*/
+                    }
+
+
+                }
+
+
+            }
+
+            pramsJson.put("cover_image_tokens", cover_image_tokens);
+
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, pramsJson.toJSONString(), headers);
+            System.err.println(result);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+
+        }
+
+
+        return null;
+    }
+}

+ 1 - 0
module-oa/src/main/java/cn/com/ctop/oa/modules/service/IWechatUserListService.java

@@ -12,3 +12,4 @@ import com.baomidou.mybatisplus.extension.service.IService;
 public interface IWechatUserListService extends IService<WechatUserList> {
     void getUserList();
 }
+