Bläddra i källkod

Merge branch 'master' into kuaishou-ai-advertising

zhaoxian 4 år sedan
förälder
incheckning
3b39b85b38
50 ändrade filer med 1633 tillägg och 246 borttagningar
  1. 2 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/HotInformationCtroller.java
  2. 28 12
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  3. 17 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/orderplatform/controller/DesignerCommitProcessCtrl.java
  4. 0 1
      jeecg-boot-module-system/src/main/resources/application.yml
  5. 29 9
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  6. 1 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/RuleAccountTemplate.java
  7. 20 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/vo/TemplateAppliedVo.java
  8. 2 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/mapper/xml/RuleAccountTemplateMapper.xml
  9. 5 2
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java
  10. 4 31
      module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialAscription.java
  11. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataPlan.java
  12. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTargetKuaishou.java
  13. 6 6
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java
  14. 1 1
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/oceanengine/service/IHotMaterialService.java
  15. 4 1
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/oceanengine/service/impl/HotMaterialServiceImpl.java
  16. 66 51
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadImageServiceImpl.java
  17. 0 6
      module-job-bytedance/pom.xml
  18. 16 1
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/ByteDancePlanRuleDataJob.java
  19. 8 5
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/RuleDataAccountCleanJob.java
  20. 8 2
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataAccountCleanJob.java
  21. 8 3
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataPlanCleanJob.java
  22. 11 5
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataTargetCleanJob.java
  23. 13 3
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataUnitCleanJob.java
  24. 1 2
      module-job-kuaishou/src/main/resources/application-jiaoyang.yml
  25. 2 3
      module-job-kuaishou/src/main/resources/application-prod.yml
  26. 255 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouStrategyController.java
  27. 4 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouTemplateController.java
  28. 30 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouTemplateTargetController.java
  29. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouTrackUrlCollection.java
  30. 227 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouStrategy.java
  31. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouAdvertiserBaseInfoMapper.java
  32. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouStrategyMapper.java
  33. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouAdvertiserBaseInfoMapper.xml
  34. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouStrategyMapper.xml
  35. 3 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouAdvertiserBaseInfoService.java
  36. 39 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouStrategyService.java
  37. 5 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  38. 10 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouAdvertiserBaseInfoServiceImpl.java
  39. 63 10
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  40. 548 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouStrategyServiceImpl.java
  41. 42 11
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouTemplateServiceImpl.java
  42. 3 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IRuleKuaiShouAccountService.java
  43. 4 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IRuleKuaiShouPlanService.java
  44. 3 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouAccountServiceImpl.java
  45. 49 18
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouPlanServiceImpl.java
  46. 23 2
      module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatCheckinDataServiceImpl.java
  47. 4 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IRuleByteDanceAccountService.java
  48. 29 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java
  49. 3 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/RuleByteDanceAccountServiceImpl.java
  50. 3 48
      pom.xml

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

@@ -75,13 +75,14 @@ public class HotInformationCtroller {
         Result<IPage<HotMaterial>> result = new Result<>();
         Map<String, String[]> paramMap = req.getParameterMap();
         String userName = paramMap.get("userName") != null ? paramMap.get("userName")[0] : null;
+        String title = paramMap.get("title")!=null?paramMap.get("title")[0]:null;
         String start = paramMap.get("start") != null ? paramMap.get("start")[0] : null;
         String end = paramMap.get("end") != null ? paramMap.get("end")[0] : null;
         String orderByColumn = paramMap.get("orderByColumn") != null ? paramMap.get("orderByColumn")[0] : null;
         String orderByType = paramMap.get("orderByType") != null ? paramMap.get("orderByType")[0] : null;
         Integer pageSize = paramMap.get("pageSize") != null ? Integer.parseInt(paramMap.get("pageSize")[0]) : null;
         Integer pageNo = paramMap.get("pageNo") != null ? Integer.parseInt(paramMap.get("pageNo")[0]) : null;
-        IPage<HotMaterial> list = hotMaterialService.queryHotFeeds(userName, start, end, orderByColumn, orderByType, pageNo, pageSize);
+        IPage<HotMaterial> list = hotMaterialService.queryHotFeeds(title,userName, start, end, orderByColumn, orderByType, pageNo, pageSize);
         result.setResult(list);
         result.setSuccess(true);
         return result;

+ 28 - 12
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java

@@ -1,5 +1,7 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
+import cn.com.ctop.alarm.modules.service.IRuleAccountTemplateService;
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
@@ -362,6 +364,9 @@ public class UserAllocationController {
      * @param userAllocation
      * @return
      */
+    @Autowired
+    private IRuleAccountTemplateService ruleAccountTemplateService;
+
     @AutoLog(value = "用户分配-编辑")
     @ApiOperation(value = "用户分配-编辑", notes = "用户分配-编辑")
     @PutMapping(value = "/edit")
@@ -372,6 +377,17 @@ public class UserAllocationController {
             result.error500("未找到对应实体");
         } else {
             boolean ok = userAllocationService.updateById(userAllocation);
+            Integer accountStatus = userAllocation.getAccountStatus();
+            if (!Check.isNull(accountStatus)) {
+                if (accountStatus == 1) {
+                    QueryWrapper<RuleAccountTemplate> ruleAccountTemplateQueryWrapper = new QueryWrapper<>();
+                    ruleAccountTemplateQueryWrapper.eq("account_id", userAllocationEntity.getAccountId());
+                    RuleAccountTemplate updateRuleAccountTemplate = new RuleAccountTemplate();
+                    updateRuleAccountTemplate.setTemplateStatus(1);
+                    ruleAccountTemplateService.update(updateRuleAccountTemplate, ruleAccountTemplateQueryWrapper);
+                }
+            }
+
             UserAllocation update = userAllocationService.getById(userAllocation.getId());
             QueryWrapper<ProjectMember> memberQueryWrapper = new QueryWrapper<>();
             memberQueryWrapper.eq("user_id", update.getUserId());
@@ -478,30 +494,30 @@ public class UserAllocationController {
     }
 
     /**
-     *  账户绑定是否开启删评论开关
+     * 账户绑定是否开启删评论开关
      */
     @PostMapping(value = "/onOrOffDeleteComment")
-    public Result<Object> onOrOffMonitoringLink(@RequestParam Long accountId, @RequestParam Integer switchType){
-        Result<Object> result=new Result<>();
-        UserAllocation userAllocation=new UserAllocation();
+    public Result<Object> onOrOffMonitoringLink(@RequestParam Long accountId, @RequestParam Integer switchType) {
+        Result<Object> result = new Result<>();
+        UserAllocation userAllocation = new UserAllocation();
         userAllocation.setAccountId(accountId);
-        UpdateWrapper<UserAllocation> wrapper=new UpdateWrapper<>();
+        UpdateWrapper<UserAllocation> wrapper = new UpdateWrapper<>();
         //开启删评论
-        if(switchType==0){
-            wrapper.set("delete_comment",0);
+        if (switchType == 0) {
+            wrapper.set("delete_comment", 0);
             wrapper.setEntity(userAllocation);
             boolean update = userAllocationService.update(wrapper);
-            if(update){
+            if (update) {
                 result.success("删评论开启成功");
             }
-        }else if(switchType==1){
-            wrapper.set("delete_comment",1);
+        } else if (switchType == 1) {
+            wrapper.set("delete_comment", 1);
             wrapper.setEntity(userAllocation);
             boolean update = userAllocationService.update(wrapper);
-            if(update){
+            if (update) {
                 result.success("删评论关闭成功");
             }
-        }else {
+        } else {
             result.error500("未知操作");
         }
         return result;

+ 17 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/orderplatform/controller/DesignerCommitProcessCtrl.java

@@ -16,7 +16,8 @@ import org.springframework.web.bind.annotation.RestController;
 @Slf4j
 @RestController
 @RequestMapping("/platform/designer")
-public class DesignerCommitProcessCtrl {
+public class
+DesignerCommitProcessCtrl {
 
     @Autowired
     private IPlatformOrderService platformOrderService;
@@ -83,4 +84,19 @@ public class DesignerCommitProcessCtrl {
         }
         return result;
     }
+
+    /**
+     *  设计组长修改指派人
+     */
+    @PostMapping("/assignAgain")
+    public Result<Object> assignAgain(@RequestBody PlatformMaterial platformMaterial) {
+        Result<Object> result = new Result<>();
+        boolean ok = platformMaterialService.updateById(platformMaterial);
+        if (ok) {
+            result.success("物料重新指派成功!");
+        }else {
+            result.error500("物料重新指派失败,请联系管理员!");
+        }
+        return result;
+    }
 }

+ 0 - 1
jeecg-boot-module-system/src/main/resources/application.yml

@@ -1,6 +1,5 @@
 spring:
   profiles:
-#    active: wps
     active: @activatedProperties@
 swagger:
   production: false

+ 29 - 9
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -24,7 +24,6 @@ import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyServ
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceFundDailyService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.junit.Test;
@@ -60,15 +59,23 @@ public class SampleTest {
     private IKuaiShouHistoryReportTaskService kuaiShouHistoryReportTaskService;
     @Autowired
     private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService iKuaishouInterfaceService;
 
     @Test
-    public void loadBytedanceCreativeData() {
-        QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
+    public void loadBytedanceCreativeData() throws ParseException {
+
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date parse = simpleDateFormat.parse("2020-12-11");
+        CtopOauthToken tokenByAccountId = oauthTokenService.getTokenByAccountId(5982133L);
+        iKuaishouInterfaceService.getAdvertiserGroupReportDaily(tokenByAccountId, parse, parse);
+
+      /*  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");
-        }
+        }*/
     }
 
     @Autowired
@@ -264,12 +271,13 @@ public class SampleTest {
 
     @Autowired
     private IBytedanceReportService bytedanceReportService;
+
     @Test
-    public void loadBytedanceVideoReportData(){
+    public void loadBytedanceVideoReportData() {
         Date getDate = DateUtils.addDay(new Date(), -1);
         String date = DateUtils.formatDate(getDate);
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
-        for (CtopOauthToken token:tokens){
+        for (CtopOauthToken token : tokens) {
             bytedanceReportService.bytedanceVideoMaterialReport(token, date, date);
         }
     }
@@ -350,20 +358,32 @@ public class SampleTest {
 
     @Autowired
     private IKuaiShouCommentService kuaiShouCommentService;
+
     @Test
-    public void kuaishouDeleteComment(){
+    public void kuaishouDeleteComment() {
         kuaiShouCommentService.shieldComment(8018853L);
     }
+
     @Autowired
     private IByteDanceVideoReportDailyService videoReportDailyService;
 
     @Test
-    public void formatVideoReportData(){
-        for(int i=1;i<45;i++){
+    public void formatVideoReportData() {
+        for (int i = 1; i < 45; i++) {
             Date getDate = DateUtils.addDay(new Date(), -i);
             String date = DateUtils.formatDate(getDate);
             videoReportDailyService.videoInfoList(date, date);
         }
     }
 
+    @Autowired
+    private IRuleKuaiShouPlanService ruleKuaiShouPlanService;
+
+    @Test
+    public void execute() {
+        CtopOauthToken token = tokenService.getTokenByAccountId(9589905L);
+        ruleKuaiShouPlanService.cleanRuleDataTarget(token.getAccountId(), 1);
+    }
+
+
 }

+ 1 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/RuleAccountTemplate.java

@@ -44,6 +44,7 @@ public class RuleAccountTemplate {
     @Excel(name = "模板id", width = 15)
     @ApiModelProperty(value = "模板id")
     private Long templateId;
+    private Integer templateStatus;
 
     /**
      * createTime

+ 20 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/vo/TemplateAppliedVo.java

@@ -8,6 +8,8 @@ public class TemplateAppliedVo {
     private String templateName;
     private Long projectId;
     private String projectName;
+    private Integer templateStatus;
+    private Integer accountStatus;
     private String userId;
     private String userName;
 
@@ -67,6 +69,22 @@ public class TemplateAppliedVo {
         this.projectName = projectName;
     }
 
+    public Integer getTemplateStatus() {
+        return templateStatus;
+    }
+
+    public void setTemplateStatus(Integer templateStatus) {
+        this.templateStatus = templateStatus;
+    }
+
+    public Integer getAccountStatus() {
+        return accountStatus;
+    }
+
+    public void setAccountStatus(Integer accountStatus) {
+        this.accountStatus = accountStatus;
+    }
+
     public String getUserId() {
         return userId;
     }
@@ -93,6 +111,8 @@ public class TemplateAppliedVo {
                 ", templateName='" + templateName + '\'' +
                 ", projectId=" + projectId +
                 ", projectName='" + projectName + '\'' +
+                ", templateStatus=" + templateStatus +
+                ", accountStatus=" + accountStatus +
                 ", userId='" + userId + '\'' +
                 ", userName='" + userName + '\'' +
                 '}';

+ 2 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/mapper/xml/RuleAccountTemplateMapper.xml

@@ -6,6 +6,8 @@
             resultType="cn.com.ctop.alarm.modules.entity.vo.TemplateAppliedVo">
         select
         t1.id id,
+        t1.template_status templateStatus,
+        t2.account_status accountStatus,
         t1.account_id accountId,
         t2.auth_name authName,
         t1.template_id templateId,

+ 5 - 2
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java

@@ -106,7 +106,10 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
         log.info("------start------");
         Long startTime = System.currentTimeMillis();
         //查询账户绑定过的规则模板
-        List<RuleAccountTemplate> ruleAccountTemplates = ruleAccountTemplateMapper.selectByMap(null);
+        Map<String, Object> map = new HashMap<>();
+        //0状态为启动
+        map.put("template_status", 0);
+        List<RuleAccountTemplate> ruleAccountTemplates = ruleAccountTemplateMapper.selectByMap(map);
         if (Check.isNull(ruleAccountTemplates)) {
             log.error("查询账户绑定过的规则模板失败");
             return;
@@ -148,7 +151,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
         JSONObject matchData = null;
         //媒体类型 1,3:头条2:快手
         if (NoEn.NO1.valueInt() == type || NoEn.NO3.valueInt() == type) {
-            //查询抖音匹配数据
+            //查询头条匹配数据
             matchData = getRuleData(templates.getAccountId(), "TT");
         } else {
             matchData = getRuleData(templates.getAccountId(), "KS");

+ 4 - 31
module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialAscription.java

@@ -3,12 +3,7 @@ package cn.com.ctop.common.module.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;
 
@@ -21,56 +16,34 @@ import java.util.Date;
  */
 @Data
 @TableName("ctop_material_ascription")
-@EqualsAndHashCode(callSuper = false)
-@Accessors(chain = true)
-@ApiModel(value = "ctop_material_ascription对象", description = "素材归属标")
 public class MaterialAscription {
 
-    /**
-     * id
-     */
     @TableId(type = IdType.UUID)
-    @ApiModelProperty(value = "id")
     private String id;
     /**
      * 素材库id
      */
-    @Excel(name = "素材库id", width = 15)
-    @ApiModelProperty(value = "素材库id")
     private String materialId;
     /**
      * 剪辑人id
      */
-    @Excel(name = "剪辑人id", width = 15)
-    @ApiModelProperty(value = "剪辑人id")
     private String clipId;
+    private String clipName;
     /**
      * 拍摄人id
      */
-    @Excel(name = "拍摄人id", width = 15)
-    @ApiModelProperty(value = "拍摄人id")
     private String shotId;
+    private String shotName;
     /**
      * 策划id
      */
-    @Excel(name = "策划id", width = 15)
-    @ApiModelProperty(value = "策划id")
     private String planId;
+    private String planName;
     /**
      * 平面id
      */
-    @Excel(name = "平面id", width = 15)
-    @ApiModelProperty(value = "平面id")
     private String planeId;
-
-    /**
-     * createTime
-     */
-    @ApiModelProperty(value = "createTime")
+    private String code;
     private Date createTime;
-    /**
-     * updateTime
-     */
-    @ApiModelProperty(value = "updateTime")
     private Date updateTime;
 }

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataPlan.java

@@ -34,6 +34,8 @@ public class RuleDataPlan {
 	private String downloadUrl;
 	private BigDecimal cost;
 	private Long convertNum;
+	private Long convertId;
+	private String deepConvertTarget;
 	private BigDecimal convertCost;
 	private BigDecimal nextDayOpenRate;
 	private BigDecimal nextDayOpenCost;

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTargetKuaishou.java

@@ -10,7 +10,7 @@ import lombok.Data;
 @Data
 @TableName("ctop_rule_data_target_kuaishou")
 public class RuleDataTargetKuaishou {
-    
+
 	/**id*/
 	private Long id;
 	/**accountId*/

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

@@ -3,10 +3,7 @@ package cn.com.ctop.common.module.service.impl;
 import cn.com.ctop.common.module.constant.CosConstant;
 import cn.com.ctop.common.module.entity.*;
 import cn.com.ctop.common.module.enums.MaterialSupplierEnum;
-import cn.com.ctop.common.module.mapper.MaterialAscriptionMapper;
-import cn.com.ctop.common.module.mapper.MaterialInfoMapper;
-import cn.com.ctop.common.module.mapper.MaterialParameterMapper;
-import cn.com.ctop.common.module.mapper.MaterialTagMapper;
+import cn.com.ctop.common.module.mapper.*;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.*;
 import com.alibaba.fastjson.JSONArray;
@@ -502,7 +499,6 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         Map<String, Object> resultMap = new HashMap<>();
         try {
             String type = json.getString("type");
-
             String url = "";
             if (!Check.isNull(json.getString("url"))) {
                 url = "https:" + json.getString("url");
@@ -569,10 +565,14 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
             if (!Check.isNull(ascription)) {
                 MaterialAscription materialAscription = new MaterialAscription();
                 materialAscription.setMaterialId(info.getCode());
-                materialAscription.setClipId(ascription.getString("clipId"));
+                String clipId = ascription.getString("clipId");
+                if(null!=clipId&&!"".equals(clipId.trim())){
+                    materialAscription.setClipId(clipId);
+                }
                 materialAscription.setShotId(ascription.getString("shotId"));
                 materialAscription.setPlanId(ascription.getString("planId"));
                 materialAscription.setPlaneId(ascription.getString("planeId"));
+                materialAscription.setCode(info.getCode());
                 materialAscriptionMapper.deleteByMap(deleteMap);
                 int result = materialAscriptionMapper.insert(materialAscription);
                 if (result > 0) {

+ 1 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/oceanengine/service/IHotMaterialService.java

@@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import java.util.List;
 
 public interface IHotMaterialService extends IService<HotMaterial> {
-    IPage<HotMaterial> queryHotFeeds(String userName, String start, String end, String orderByColumn, String orderByType, Integer pageNo, Integer pageSize);
+    IPage<HotMaterial> queryHotFeeds(String title,String userName, String start, String end, String orderByColumn, String orderByType, Integer pageNo, Integer pageSize);
 
     List<HotMaterial> getId();
 

+ 4 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/oceanengine/service/impl/HotMaterialServiceImpl.java

@@ -17,11 +17,14 @@ import java.util.List;
 
 public class HotMaterialServiceImpl extends ServiceImpl<HotMaterialMapper, HotMaterial> implements IHotMaterialService {
     @Override
-    public IPage<HotMaterial> queryHotFeeds(String userName, String start, String end, String orderByColumn, String orderByType, Integer pageNo, Integer pageSize) {
+    public IPage<HotMaterial> queryHotFeeds(String title,String userName, String start, String end, String orderByColumn, String orderByType, Integer pageNo, Integer pageSize) {
         QueryWrapper<HotMaterial> queryWrapper = new QueryWrapper<>();
         if (null != userName && !"".equals(userName)) {
             queryWrapper.like("author", userName);
         }
+        if (null != title && !"".equals(title)) {
+            queryWrapper.like("title", title);
+        }
         if (null != start && !"".equals(start) && null != end && !"".equals(end)) {
             queryWrapper.between("create_time", start, end);
         }

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

@@ -6,6 +6,7 @@ import cn.com.ctop.common.module.utils.Check;
 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.service.IKuaiShouAdvertiserBaseInfoService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
 import cn.com.ctop.manage.modules.material.service.IMaterialUploadImageService;
 import com.alibaba.fastjson.JSONObject;
@@ -35,7 +36,7 @@ import java.util.concurrent.Executors;
 @Slf4j
 @Service
 public class MaterialUploadImageServiceImpl implements IMaterialUploadImageService {
-    static ExecutorService executorService = Executors.newFixedThreadPool(8);
+    static ExecutorService executorService = Executors.newFixedThreadPool(15);
 
     @Value("${oss.replace.download}")
     private String downloadUrl;
@@ -44,6 +45,8 @@ public class MaterialUploadImageServiceImpl implements IMaterialUploadImageServi
     private IMaterialImageInfoService materialImageInfoService;
     @Autowired
     private IKuaiShouImageGetService imageGetService;
+    @Autowired
+    private IKuaiShouAdvertiserBaseInfoService baseInfoService;
 
     /**
      * 同步素材到账号下
@@ -58,63 +61,75 @@ public class MaterialUploadImageServiceImpl implements IMaterialUploadImageServi
                     if (Check.isNull(imageInfo)) {
                         continue;
                     }
-                    executorService.submit(new Runnable() {
-                        @SneakyThrows
-                        @Override
-                        public void run() {
-                            synchronized (this) {
-                                QueryWrapper<KuaiShouImageGet> imageQueryWrapper = new QueryWrapper<>();
-                                imageQueryWrapper.eq("account_id", accountId);
-                                imageQueryWrapper.eq("signature", imageInfo.getString("signature"));
-                                List<KuaiShouImageGet> imageGetList = imageGetService.list(imageQueryWrapper);
-                                if (Check.isNull(imageGetList)) {
-                                    Map<String, String> headerMap = new HashMap<>();
-                                    JSONObject requestJson = new JSONObject();
-                                    requestJson.put("advertiser_id", accountId);
-                                    headerMap.put("Access-Token", accessToken);
-                                    headerMap.put("Content-Type", "multipart/form-data");
 
-                                    requestJson.put("url", imageInfo.getString("imageUrl"));
-                                    requestJson.put("signature", imageInfo.getString("signature"));
-                                    requestJson.put("type", "2");
-                                    requestJson.put("upload_type", "2");
-                                    String requestUrl = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_UPLOAD;
-                                    String result = exceptInfoForRestTemplate(requestUrl, requestJson, headerMap);
-                                    JSONObject resultJson = JSONObject.parseObject(result);
-                                    if (!Check.isNull(resultJson)) {
-                                        if (resultJson.getInteger("code") == 0) {
-                                            JSONObject dataJson = resultJson.getJSONObject("data");
-                                            if (!Check.isNull(dataJson)) {
-                                                String signature = dataJson.getString("signature");
-                                                String image_token = dataJson.getString("image_token");
-                                                KuaiShouImageGet imageGet = new KuaiShouImageGet();
-                                                imageGet.setId(accountId + image_token);
-                                                imageGet.setAccountId(accountId);
-                                                imageGet.setUrl(dataJson.getString("url"));
-                                                imageGet.setWidth(dataJson.getInteger("width"));
-                                                imageGet.setHeight(dataJson.getInteger("height"));
-                                                imageGet.setSize(dataJson.getInteger("size"));
-                                                imageGet.setFormat(dataJson.getString("format"));
-                                                Integer type = MaterialEnum.getTypeBySize(dataJson.getInteger("width"), dataJson.getInteger("height"));
-                                                if (!Check.isNull(type)) {
-                                                    imageGet.setMaterialType(type);
+                    List<Long> accountList = baseInfoService.getAccountListByAccountId(accountId);
+                    if (Check.isNull(accountList)) {
+                        return;
+                    }
+
+                    for (int j = 0; j < accountList.size(); j++) {
+                        Long imageAccountId = accountList.get(j);
+                        if (Check.isNull(imageAccountId)) {
+                            continue;
+                        }
+                        executorService.submit(new Runnable() {
+                            @SneakyThrows
+                            @Override
+                            public void run() {
+                                synchronized (this) {
+                                    QueryWrapper<KuaiShouImageGet> imageQueryWrapper = new QueryWrapper<>();
+                                    imageQueryWrapper.eq("account_id", imageAccountId);
+                                    imageQueryWrapper.eq("signature", imageInfo.getString("signature"));
+                                    List<KuaiShouImageGet> imageGetList = imageGetService.list(imageQueryWrapper);
+                                    if (Check.isNull(imageGetList)) {
+                                        Map<String, String> headerMap = new HashMap<>();
+                                        JSONObject requestJson = new JSONObject();
+                                        requestJson.put("advertiser_id", imageAccountId);
+                                        headerMap.put("Access-Token", accessToken);
+                                        headerMap.put("Content-Type", "multipart/form-data");
+
+                                        requestJson.put("url", imageInfo.getString("imageUrl"));
+                                        requestJson.put("signature", imageInfo.getString("signature"));
+                                        requestJson.put("type", "2");
+                                        requestJson.put("upload_type", "2");
+                                        String requestUrl = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_UPLOAD;
+                                        String result = exceptInfoForRestTemplate(requestUrl, requestJson, headerMap);
+                                        JSONObject resultJson = JSONObject.parseObject(result);
+                                        if (!Check.isNull(resultJson)) {
+                                            if (resultJson.getInteger("code") == 0) {
+                                                JSONObject dataJson = resultJson.getJSONObject("data");
+                                                if (!Check.isNull(dataJson)) {
+                                                    String signature = dataJson.getString("signature");
+                                                    String image_token = dataJson.getString("image_token");
+                                                    KuaiShouImageGet imageGet = new KuaiShouImageGet();
+                                                    imageGet.setId(imageAccountId + image_token);
+                                                    imageGet.setAccountId(imageAccountId);
+                                                    imageGet.setUrl(dataJson.getString("url"));
+                                                    imageGet.setWidth(dataJson.getInteger("width"));
+                                                    imageGet.setHeight(dataJson.getInteger("height"));
+                                                    imageGet.setSize(dataJson.getInteger("size"));
+                                                    imageGet.setFormat(dataJson.getString("format"));
+                                                    Integer type = MaterialEnum.getTypeBySize(dataJson.getInteger("width"), dataJson.getInteger("height"));
+                                                    if (!Check.isNull(type)) {
+                                                        imageGet.setMaterialType(type);
+                                                    }
+                                                    String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                                                    imageGet.setStatDate(DateUtils.parseDate(nowDate, "yyyy-MM-dd"));
+                                                    imageGet.setSignature(signature);
+                                                    imageGet.setImageToken(image_token);
+                                                    imageGetService.saveOrUpdate(imageGet);
                                                 }
-                                                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-                                                imageGet.setStatDate(DateUtils.parseDate(nowDate, "yyyy-MM-dd"));
-                                                imageGet.setSignature(signature);
-                                                imageGet.setImageToken(image_token);
-                                                imageGetService.saveOrUpdate(imageGet);
+                                                log.info("快手封面素材素材同步完成,accountId:{},code:{},返回信息:{}", imageAccountId, imageInfo.getString("signature"), resultJson);
+                                            } else {
+                                                log.error("快手同步封面素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
                                             }
-                                            log.info("快手封面素材素材同步完成,accountId:{},code:{},返回信息:{}", accountId, imageInfo.getString("signature"), resultJson);
-                                        } else {
-                                            log.error("快手同步封面素材失败,返回信息:{},请求参数:{}", resultJson, requestJson);
                                         }
                                     }
-                                }
 
+                                }
                             }
-                        }
-                    });
+                        });
+                    }
                 }
             }
         } catch (Exception e) {

+ 0 - 6
module-job-bytedance/pom.xml

@@ -84,12 +84,6 @@
             <scope>compile</scope>
         </dependency>
         <dependency>
-            <groupId>cn.com.ctop</groupId>
-            <artifactId>module-oa</artifactId>
-            <version>2.0.2</version>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
             <groupId>com.aliyun.oss</groupId>
             <artifactId>aliyun-sdk-oss</artifactId>
             <version>3.5.0</version>

+ 16 - 1
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/ByteDancePlanRuleDataJob.java

@@ -2,6 +2,8 @@ package cn.com.ctop.job.bytedance.handler;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IRuleDataPlanService;
+import cn.com.ctop.common.module.service.IRuleDataTargetService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
 import com.xxl.job.core.handler.annotation.XxlJob;
@@ -9,7 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -19,11 +23,22 @@ public class ByteDancePlanRuleDataJob {
     private ICtopOauthTokenService tokenService;
     @Autowired
     private IReportService reportService;
+    @Autowired
+    private IRuleDataPlanService ruleDataPlanService;
+    @Autowired
+    private IRuleDataTargetService ruleDataTargetService;
     private ExecutorService executorService = Executors.newFixedThreadPool(10);
     @XxlJob("bytedancePlanRuleLoadJob")
     public void execute() throws Exception {
         Date date = new Date();
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
-        tokens.forEach(token -> executorService.submit(()->reportService.getAdvertiserPlanRuleData(token,date,date,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY)));
+        tokens.forEach(token -> executorService.submit(()->{
+            //1:删除历史数据
+            Map<String,Object> params = new HashMap<>();
+            params.put("account_id",token.getAccountId());
+            ruleDataPlanService.removeByMap(params);
+            ruleDataTargetService.removeByMap(params);
+            reportService.getAdvertiserPlanRuleData(token,date,date, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        }));
     }
 }

+ 8 - 5
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/RuleDataAccountCleanJob.java

@@ -12,25 +12,28 @@ import com.xxl.job.core.handler.annotation.XxlJob;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 @Component
 public class RuleDataAccountCleanJob {
-
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
-
     @Autowired
     private IRuleByteDanceAccountService ruleByteDanceAccountService;
-
     private ExecutorService executorService = Executors.newFixedThreadPool(10);
-
     @XxlJob("ruleDataAccountCleanJob")
     public void execute() throws Exception {
         XxlJobHelper.log("规则预警账户维度数据开始清洗");
         List<CtopOauthToken> tokens = oauthTokenService.selectToutiaoToken();
-        tokens.forEach(token -> executorService.submit(()->ruleByteDanceAccountService.cleanRuleDataAccount(token.getAccountId())));
+        tokens.forEach(token -> executorService.submit(()->{
+            Map<String,Object> params = new HashMap<>();
+            params.put("account_id",token.getAccountId());
+            ruleByteDanceAccountService.removeByMap(params);
+            ruleByteDanceAccountService.cleanRuleDataAccount(token.getAccountId());
+        }));
     }
 }

+ 8 - 2
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataAccountCleanJob.java

@@ -8,13 +8,14 @@ import com.xxl.job.core.handler.annotation.XxlJob;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 @Component
 public class RuleKuaiShouDataAccountCleanJob {
-
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
 
@@ -27,6 +28,11 @@ public class RuleKuaiShouDataAccountCleanJob {
     public void execute() throws Exception {
         XxlJobHelper.log("规则预警账户维度数据开始清洗");
         List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
-        tokens.forEach(token -> executorService.submit(()->ruleKuaiShouAccountService.cleanRuleDataAccount(token.getAccountId())));
+        tokens.forEach(token -> executorService.submit(()->{
+            Map<String,Object> params = new HashMap<>();
+            params.put("account_id",token.getAccountId());
+            ruleKuaiShouAccountService.removeByMap(params);
+            ruleKuaiShouAccountService.cleanRuleDataAccount(token.getAccountId());
+        }));
     }
 }

+ 8 - 3
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataPlanCleanJob.java

@@ -8,7 +8,9 @@ import com.xxl.job.core.handler.annotation.XxlJob;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -16,16 +18,19 @@ import java.util.concurrent.Executors;
 public class RuleKuaiShouDataPlanCleanJob {
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
-
     @Autowired
     private IRuleKuaiShouPlanService ruleKuaiShouPlanService;
-
     private ExecutorService executorService = Executors.newFixedThreadPool(10);
 
     @XxlJob("ruleKuaiShouDataPlanCleanJob")
     public void execute() throws Exception {
         XxlJobHelper.log("规则预警计划维度数据开始清洗");
         List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
-        tokens.forEach(token -> executorService.submit(()->ruleKuaiShouPlanService.cleanRuleDataPlan(token.getAccountId(),1)));
+        tokens.forEach(token -> executorService.submit(()->{
+            Map<String,Object> params = new HashMap<>();
+            params.put("account_id",token.getAccountId());
+            ruleKuaiShouPlanService.removeByMap(params);
+            ruleKuaiShouPlanService.cleanRuleDataPlan(token.getAccountId(),1);
+        }));
     }
 }

+ 11 - 5
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataTargetCleanJob.java

@@ -2,33 +2,39 @@ package cn.com.ctop.job.kuaishou.handler;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IRuleDataTargetKuaishouService;
 import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
-import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 @Component
 public class RuleKuaiShouDataTargetCleanJob {
-
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
-
     @Autowired
     private IRuleKuaiShouPlanService ruleKuaiShouPlanService;
-
+    @Autowired
+    private IRuleDataTargetKuaishouService ruleDataTargetKuaishouService;
     private ExecutorService executorService = Executors.newFixedThreadPool(10);
 
     @XxlJob("ruleKuaiShouDataTargetCleanJob")
     public void execute() throws Exception {
         XxlJobHelper.log("规则预警定向维度数据开始清洗");
         List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
-        tokens.forEach(token -> executorService.submit(() -> ruleKuaiShouPlanService.cleanRuleDataTarget(token.getAccountId(), 1)));
+        tokens.forEach(token -> executorService.submit(() ->{
+            Map<String,Object>params = new HashMap<>();
+            params.put("account_id",token.getAccountId());
+            ruleDataTargetKuaishouService.removeByMap(params);
+            ruleKuaiShouPlanService.cleanRuleDataTarget(token.getAccountId(), 1);
+        }));
     }
 
 }

+ 13 - 3
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataUnitCleanJob.java

@@ -2,23 +2,28 @@ package cn.com.ctop.job.kuaishou.handler;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IRuleDataUnitKuaishouService;
 import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-
+@Component
 public class RuleKuaiShouDataUnitCleanJob {
-
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
 
     @Autowired
     private IRuleKuaiShouPlanService ruleKuaiShouPlanService;
+    @Autowired
+    private IRuleDataUnitKuaishouService ruleDataUnitKuaishouService;
 
     private ExecutorService executorService = Executors.newFixedThreadPool(10);
 
@@ -26,7 +31,12 @@ public class RuleKuaiShouDataUnitCleanJob {
     public void execute() throws Exception {
         XxlJobHelper.log("规则预警组维度数据开始清洗");
         List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
-        tokens.forEach(token -> executorService.submit(() -> ruleKuaiShouPlanService.cleanRuleDataUnit(token.getAccountId(), DateUtils.date2Str(), DateUtils.date2Str(), 1)));
+        tokens.forEach(token -> executorService.submit(() -> {
+            Map<String,Object>params = new HashMap<>();
+            params.put("account_id",token.getAccountId());
+            ruleDataUnitKuaishouService.removeByMap(params);
+            ruleKuaiShouPlanService.cleanRuleDataUnit(token.getAccountId(), DateUtils.date2Str(), DateUtils.date2Str(), 1);
+        }));
     }
 
 }

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

@@ -221,11 +221,10 @@ xxl:
   job:
     accessToken:
     executor:
-      appname: module-job-kuaishou-v2
+      appname: module-job-kuaishou
       port: 9998
       ip:
       logpath: /data/applogs/xxl-job/jobhandler
       logretentiondays: 30
     admin:
       addresses: http://129.28.150.229:8090/xxl-job-admin
-#      addresses: http://139.186.29.76:8090/xxl-job-admin

+ 2 - 3
module-job-kuaishou/src/main/resources/application-prod.yml

@@ -221,11 +221,10 @@ xxl:
   job:
     accessToken:
     executor:
-      appname: module-job-kuaishou-v2
+      appname: module-job-kuaishou
       port: 9998
       ip:
       logpath: /data/applogs/xxl-job/jobhandler
       logretentiondays: 30
     admin:
-      addresses: http://129.28.150.229:8090/xxl-job-admin
-#      addresses: http://139.186.29.76:8090/xxl-job-admin
+      addresses: http://139.186.29.76:8090/xxl-job-admin

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

@@ -0,0 +1,255 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouStrategyService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+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.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+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;
+
+/**
+ * kuaishou.modules.batch-优化评估策略表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-10
+ */
+@Slf4j
+@Api(tags = "kuaishou.modules.batch-优化评估策略表")
+@RestController
+@RequestMapping("/kuaishouStrategy")
+public class KuaishouStrategyController {
+    @Autowired
+    private IKuaishouStrategyService kuaishouStrategyService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param kuaishouStrategy
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "kuaishou.modules.batch-优化评估策略表-分页列表查询")
+    @ApiOperation(value = "kuaishou.modules.batch-优化评估策略表-分页列表查询", notes = "kuaishou.modules.batch-优化评估策略表-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<KuaishouStrategy>> queryPageList(KuaishouStrategy kuaishouStrategy,
+                                                         @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                         HttpServletRequest req) {
+        Result<IPage<KuaishouStrategy>> result = new Result<>();
+        QueryWrapper<KuaishouStrategy> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouStrategy, req.getParameterMap());
+        Page<KuaishouStrategy> page = new Page<KuaishouStrategy>(pageNo, pageSize);
+        IPage<KuaishouStrategy> pageList = kuaishouStrategyService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param kuaishouStrategy
+     * @return
+     */
+    @AutoLog(value = "kuaishou.modules.batch-优化评估策略表-添加")
+    @ApiOperation(value = "kuaishou.modules.batch-优化评估策略表-添加", notes = "kuaishou.modules.batch-优化评估策略表-添加")
+    @PostMapping(value = "/add")
+    public Result<Object> add(@RequestBody JSONObject data) {
+        Result<Object> result = new Result<>();
+        try {
+            if (Check.isNull(data.getLong("accountId"))) {
+                return Result.error(-1, "请选择账户");
+            }
+            KuaishouStrategy strategy = JSONObject.toJavaObject(data, KuaishouStrategy.class);
+            kuaishouStrategyService.save(strategy);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param kuaishouStrategy
+     * @return
+     */
+    @AutoLog(value = "kuaishou.modules.batch-优化评估策略表-编辑")
+    @ApiOperation(value = "kuaishou.modules.batch-优化评估策略表-编辑", notes = "kuaishou.modules.batch-优化评估策略表-编辑")
+    @PostMapping(value = "/edit")
+    public Result<Object> edit(@RequestBody JSONArray ids) {
+        try {
+            return kuaishouStrategyService.shutDownPlan(ids);
+        } catch (Exception e) {
+            log.error("关停策略下的计划异常", e);
+        }
+        return Result.error("关停失败");
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "kuaishou.modules.batch-优化评估策略表-通过id删除")
+    @ApiOperation(value = "kuaishou.modules.batch-优化评估策略表-通过id删除", notes = "kuaishou.modules.batch-优化评估策略表-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            kuaishouStrategyService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "kuaishou.modules.batch-优化评估策略表-批量删除")
+    @ApiOperation(value = "kuaishou.modules.batch-优化评估策略表-批量删除", notes = "kuaishou.modules.batch-优化评估策略表-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<KuaishouStrategy> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<KuaishouStrategy> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.kuaishouStrategyService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "kuaishou.modules.batch-优化评估策略表-通过id查询")
+    @ApiOperation(value = "kuaishou.modules.batch-优化评估策略表-通过id查询", notes = "kuaishou.modules.batch-优化评估策略表-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<Object> queryById(@RequestParam(name = "id", required = true) String id) {
+        if (Check.isNull(id)) {
+            return Result.error(-1, "请选择查看的策略");
+        }
+        KuaishouStrategy strategy = kuaishouStrategyService.getById(id);
+        if (Check.isNull(strategy)) {
+            return Result.error(-1, "策略不存在");
+        }
+        return Result.ok(strategy);
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<KuaishouStrategy> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                KuaishouStrategy kuaishouStrategy = JSON.parseObject(deString, KuaishouStrategy.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(kuaishouStrategy, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<KuaishouStrategy> pageList = kuaishouStrategyService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "kuaishou.modules.batch-优化评估策略表列表");
+        mv.addObject(NormalExcelConstants.CLASS, KuaishouStrategy.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("kuaishou.modules.batch-优化评估策略表列表数据", "导出人: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<KuaishouStrategy> listKuaishouStrategys = ExcelImportUtil.importExcel(file.getInputStream(), KuaishouStrategy.class, params);
+                kuaishouStrategyService.saveBatch(listKuaishouStrategys);
+                return Result.ok("文件导入成功!数据行数:" + listKuaishouStrategys.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("文件导入失败!");
+    }
+
+}

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

@@ -118,9 +118,9 @@ public class KuaishouTemplateController {
      * @param
      * @return
      */
-    @GetMapping(value = "/createTemplate")
-    public Result<Boolean> createTemplate(@RequestBody JSONObject requestJson) {
-        Result<Boolean> result = new Result<>();
+    @PostMapping(value = "/createTemplate")
+    public Result<JSONObject> createTemplate(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
         try {
 
             Long accountId = requestJson.getLong("accountId");
@@ -133,6 +133,7 @@ public class KuaishouTemplateController {
             }
             JSONObject returnJson = kuaishouTemplateService.createTemplate(accountId, oauthToken.getAccessToken(), requestJson);
             result.setSuccess(true);
+            result.setResult(returnJson);
         } catch (Exception e) {
             e.printStackTrace();
             result.setSuccess(false);

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

@@ -1,9 +1,12 @@
 package cn.com.ctop.kuaishou.modules.batch.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplate;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouTemplateTarget;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateTargetService;
 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;
@@ -47,6 +50,8 @@ import java.util.Map;
 public class KuaishouTemplateTargetController {
     @Autowired
     private IKuaishouTemplateTargetService kuaishouTemplateTargetService;
+    @Autowired
+    private IKuaishouTemplateService kuaishouTemplateService;
 
     /**
      * 分页列表查询
@@ -73,6 +78,31 @@ public class KuaishouTemplateTargetController {
         return result;
     }
 
+    @AutoLog(value = "快手-定向模板-详情-分页列表查询")
+    @ApiOperation(value = "快手-定向模板-详情-分页列表查询", notes = "快手-定向模板-详情-分页列表查询")
+    @GetMapping(value = "/getDetailByTemplateId")
+    public Result<JSONObject> getDetailByTemplateId(KuaishouTemplateTarget kuaishouTemplateTarget,
+                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                    HttpServletRequest req) {
+        Result<JSONObject> result = new Result<>();
+        QueryWrapper<KuaishouTemplateTarget> queryWrapper = QueryGenerator.initQueryWrapper(kuaishouTemplateTarget, req.getParameterMap());
+        queryWrapper.last("limit 1");
+        KuaishouTemplateTarget one = kuaishouTemplateTargetService.getOne(queryWrapper);
+        JSONObject json = new JSONObject();
+        json.put("detail", one);
+        QueryWrapper<KuaishouTemplate> baseQueryWrapper = new QueryWrapper<>();
+        baseQueryWrapper.eq("template_id", kuaishouTemplateTarget.getTemplateId());
+        baseQueryWrapper.last("limit 1");
+        // KuaishouTemplate
+        KuaishouTemplate base = kuaishouTemplateService.getOne(baseQueryWrapper);
+        json.put("base", base);
+        result.setSuccess(true);
+        result.setResult(json);
+        return result;
+    }
+
+
     /**
      * 添加
      *

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

@@ -58,6 +58,7 @@ public class KuaiShouTrackUrlCollection {
     @Excel(name = "url", width = 15)
     @ApiModelProperty(value = "url")
     private String trackUrl;
+    private String trackType;
     /**
      * 创建时间
      */

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

@@ -0,0 +1,227 @@
+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-12-10
+ */
+@Data
+@TableName("ctop_kuaishou_strategy")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_strategy对象", description = "快手-优化评估策略表")
+public class KuaishouStrategy {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * 策略名称
+     */
+    @Excel(name = "策略名称", width = 15)
+    @ApiModelProperty(value = "策略名称")
+    private String strategyName;
+    /**
+     * 策略状态 0 关停,1激活
+     */
+    @Excel(name = "策略状态 0 关停,1激活", width = 15)
+    @ApiModelProperty(value = "策略状态 0 关停,1激活")
+    private String strategyState;
+    /**
+     * 应用场景{1:素材+出价}{2:素材+定向}{3:时间+出价}。。。
+     */
+    @Excel(name = "应用场景{1:素材+出价}{2:素材+定向}{3:时间+出价}。。。", width = 15)
+    @ApiModelProperty(value = "应用场景{1:素材+出价}{2:素材+定向}{3:时间+出价}。。。")
+    private String scenes;
+    /**
+     * 营销目标{1应用安装},{2电商下单},{3推广品牌},{4营销线上},{5应用活跃}
+     */
+    @Excel(name = "营销目标{1应用安装},{2电商下单},{3推广品牌},{4营销线上},{5应用活跃}", width = 15)
+    @ApiModelProperty(value = "营销目标{1应用安装},{2电商下单},{3推广品牌},{4营销线上},{5应用活跃}")
+    private String marketingGoal;
+    /**
+     * 应用id集
+     */
+    @Excel(name = "应用id集", width = 15)
+    @ApiModelProperty(value = "应用id集")
+    private String appIds;
+    /**
+     * 转化目标
+     */
+    @Excel(name = "转化目标", width = 15)
+    @ApiModelProperty(value = "转化目标")
+    private Long convertId;
+    /**
+     * 定向模板id
+     */
+    @Excel(name = "模板id", width = 15)
+    @ApiModelProperty(value = "模板id")
+    private String templateId;
+    /**
+     * 地域
+     */
+    @Excel(name = "地域", width = 15)
+    @ApiModelProperty(value = "地域")
+    private String region;
+    /**
+     * 年龄段:{0:不限}{18:18-23岁}{24:24-30岁}{31:31-40岁}{41:41-49岁}{50:50岁+
+     */
+    @Excel(name = "年龄段:{[]:不限}{18:18-23岁}{24:24-30岁}{31:31-40岁}{41:41-49岁}{50:50岁+", width = 15)
+    @ApiModelProperty(value = "年龄段:{[]:不限}{18:18-23岁}{24:24-30岁}{31:31-40岁}{41:41-49岁}{50:50岁+")
+    private String agesRange;
+    /**
+     * 性别 1:女性, 2:男性, 0:不限
+     */
+    @Excel(name = "性别 1:女性, 2:男性, 0:不限", width = 15)
+    @ApiModelProperty(value = "性别 1:女性, 2:男性, 0:不限")
+    private Integer gender;
+    /**
+     * 操作系统 1: Android, 2: iOS, 0:不限
+     */
+    @Excel(name = "操作系统 1: Android, 2: iOS, 0:不限", width = 15)
+    @ApiModelProperty(value = "操作系统 1: Android, 2: iOS, 0:不限")
+    private Integer platformOs;
+    /**
+     * 自定义人群 0不限,1:定向,:2:排除,:3同时定向排除
+     */
+    @Excel(name = "自定义人群 0不限,1:定向,:2:排除,:3同时定向排除", width = 15)
+    @ApiModelProperty(value = "自定义人群 0不限,1:定向,:2:排除,:3同时定向排除")
+    private String customCrowd;
+    /**
+     * 定向人群包
+     */
+    @Excel(name = "定向人群包", width = 15)
+    @ApiModelProperty(value = "定向人群包")
+    private String population;
+    /**
+     * 排除人群包
+     */
+    @Excel(name = "排除人群包", width = 15)
+    @ApiModelProperty(value = "排除人群包")
+    private String excludePopulation;
+    /**
+     * 投放开始时间
+     */
+    @Excel(name = "投放开始时间", width = 15)
+    @ApiModelProperty(value = "投放开始时间")
+    private String beginTime;
+    /**
+     * 投放结束时间
+     */
+    @Excel(name = "投放结束时间", width = 15)
+    @ApiModelProperty(value = "投放结束时间")
+    private String endTime;
+    /**
+     * 投放时段
+     */
+    @Excel(name = "投放时段", width = 15)
+    @ApiModelProperty(value = "投放时段")
+    private Object scheduleTime;
+    /**
+     * 策略预算
+     */
+    @Excel(name = "策略预算", width = 15)
+    @ApiModelProperty(value = "策略预算")
+    private Long budget;
+    /**
+     * 出价类型(优化目标) 2点击数(CPC),10转化数(OCPM)
+     */
+    @Excel(name = "出价类型(优化目标) 2点击数(CPC),10转化数(OCPM)", width = 15)
+    @ApiModelProperty(value = "出价类型(优化目标) 2点击数(CPC),10转化数(OCPM)")
+    private Integer bidType;
+    /**
+     * 封面点击出价
+     */
+    @Excel(name = "封面点击出价", width = 15)
+    @ApiModelProperty(value = "封面点击出价")
+    private Long bid;
+    /**
+     * 转化目标,2:行为数,180:激活数,53:表单数,190: 付费,191:首日ROI 。。。
+     */
+    @Excel(name = "转化目标,2:行为数,180:激活数,53:表单数,190: 付费,191:首日ROI 。。。", width = 15)
+    @ApiModelProperty(value = "转化目标,2:行为数,180:激活数,53:表单数,190: 付费,191:首日ROI 。。。")
+    private Integer ocpxActionType;
+    /**
+     * 转化目标出价
+     */
+    @Excel(name = "转化目标出价", width = 15)
+    @ApiModelProperty(value = "转化目标出价")
+    private Integer cpaBid;
+    /**
+     * 深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无
+     */
+    @Excel(name = "深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无", width = 15)
+    @ApiModelProperty(value = "深度转化目标 3: 付费,7: 次日留存,10: 完件, 11: 授信 ,0:无")
+    private Integer deepConversionType;
+    /**
+     * 深度转化目标出价
+     */
+    @Excel(name = "深度转化目标出价", width = 15)
+    @ApiModelProperty(value = "深度转化目标出价")
+    private Integer deepConversionBid;
+
+    /**
+     * 广告位 1:优选广告位
+     */
+    private String sceneId;
+    /**
+     * 下载详情页ID,建站id
+     */
+    private String siteId;
+    /**
+     * 第三方开始播放监测链接
+     */
+    private String impressionUrl;
+    /**
+     * 第三方开始播放监测链接
+     */
+    private String url;
+    /**
+     * 当计划类型为3(获取电商下单)时必填:
+     * 1 - 淘宝商品短链
+     * 2 - 淘宝商品itemID
+     * 4 - 金牛电商
+     */
+    private String urlType;
+    /**
+     * 第三方点击检测链接
+     */
+    private String clickTrackUrl;
+    /**
+     * 第三方点击按钮监测链接
+     */
+    private String actionbarClickUrl;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+}

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

@@ -2,6 +2,9 @@ package cn.com.ctop.kuaishou.modules.batch.mapper;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAdvertiserBaseInfo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 快手-广告主基本信息
@@ -12,4 +15,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface KuaiShouAdvertiserBaseInfoMapper extends BaseMapper<KuaiShouAdvertiserBaseInfo> {
 
+    List<Long> getAccountListByAccountId(@Param("userId") String userId);
 }

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * kuaishou.modules.batch-优化评估策略表
+ *
+ * @author: jeecg-boot
+ * @date: 2020-12-10
+ * @cersion: V1.0
+ */
+public interface KuaishouStrategyMapper extends BaseMapper<KuaishouStrategy> {
+
+}

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

@@ -2,4 +2,10 @@
 <!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.KuaiShouAdvertiserBaseInfoMapper">
 
+    <select id="getAccountListByAccountId" resultType="java.lang.Long">
+    select  account_id
+    from ctop_kuaishou_advertiser_base_info
+    where  user_id = #{userId}
+    </select>
+
 </mapper>

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouStrategyMapper.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.KuaishouStrategyMapper">
+
+</mapper>

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

@@ -17,4 +17,7 @@ public interface IKuaiShouAdvertiserBaseInfoService extends IService<KuaiShouAdv
     KuaiShouAdvertiserBaseInfo getBaseInfo(Long accountId);
 
     List<KuaiShouAdvertiserBaseInfo> getAccountIdList(String userId);
+
+    List<Long> getAccountListByAccountId(Long accountId);
+
 }

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

@@ -0,0 +1,39 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+import java.util.Map;
+
+/**
+ * @Description: kuaishou.modules.batch-优化评估策略表
+ * @Author: jeecg-boot
+ * @Date: 2020-12-10
+ * @Version: V1.0
+ */
+public interface IKuaishouStrategyService extends IService<KuaishouStrategy> {
+    /**
+     * 页面关停操作
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    Result<Object> shutDownPlan(JSONArray ids);
+
+    /**
+     * 创建快手广告计划
+     *
+     * @param oauthToken token签名
+     * @param groupJson  广告计划
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    Map<String, Object> createPlanLevelStrategy(CtopOauthToken oauthToken, JSONObject data);
+}

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

@@ -1347,7 +1347,7 @@ public class BatchServiceImpl implements IBatchService {
                                 }
 
                                 if ("4".equals(creativeMaterialType)) {
-                                    if (!Check.isNull("shortSlogan")) {
+                                    if (!Check.isNull(shortSlogan)) {
                                         creativeJson.put("short_slogan", shortSlogan);
                                     }
                                 }
@@ -1435,6 +1435,7 @@ public class BatchServiceImpl implements IBatchService {
         creativeJson.put("advertiser_id", accountId);
         creativeJson.put("unit_id", unitId);
         String click_track_url = requestJson.getString("clickTrackUrl");
+        String actionbar_click_url = requestJson.getString("actionbarClickUrl");
 
 
         // 素材类型
@@ -1519,6 +1520,9 @@ public class BatchServiceImpl implements IBatchService {
                                 creative.put("image_token", imageToken);
                                 creativeJson.put("click_track_url", click_track_url);
                             }
+                            if(!Check.isNull(actionbar_click_url)){
+                                creativeJson.put("actionbar_click_url", actionbar_click_url);
+                            }
 
                             creatives.add(creative);
                         }

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

@@ -49,4 +49,14 @@ public class KuaiShouAdvertiserBaseInfoServiceImpl extends ServiceImpl<KuaiShouA
         queryWrapper.groupBy("account_id");
         return advertiserBaseInfoMapper.selectList(queryWrapper);
     }
+
+    @Override
+    public List<Long> getAccountListByAccountId(Long accountId) {
+        QueryWrapper<KuaiShouAdvertiserBaseInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.last("limit 1");
+        KuaiShouAdvertiserBaseInfo kuaiShouAdvertiserBaseInfo = advertiserBaseInfoMapper.selectOne(queryWrapper);
+        List<Long> accountList = advertiserBaseInfoMapper.getAccountListByAccountId(kuaiShouAdvertiserBaseInfo.getUserId());
+        return accountList;
+    }
 }

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

@@ -4,18 +4,69 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.enums.MaterialEnum;
 import cn.com.ctop.common.module.service.IUserAllocationService;
-import cn.com.ctop.common.module.utils.*;
-import cn.com.ctop.kuaishou.modules.batch.entity.*;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.JsonUtil;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAdvertiserBaseInfo;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouConversionInfos;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouConversionTypes;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouDailyFlows;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouRegionListChildren;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouRegionListParent;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouTargetingTags;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouPopulation;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
-import cn.com.ctop.kuaishou.modules.batch.mapper.*;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAdvertiserBaseInfoMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAppListMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouConversionInfosMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouConversionTypesMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouRegionListChildrenMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouRegionListParentMapper;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouTargetingTagsMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAdvertiserBaseInfoService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyFlowsService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouOverRunSendMessageService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouPopulationService;
+import cn.com.ctop.kuaishou.modules.batch.service.IWarningOperationService;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
-import cn.com.ctop.kuaishou.modules.report.entity.*;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCampaign;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCreative;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCreativeStatistic;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyGroup;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyAccount;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCampaign;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreative;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyCreativeStatistic;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyGroup;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCampaignMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyGroupMapper;
-import cn.com.ctop.kuaishou.modules.report.service.*;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyCampaignService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyCreativeService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyCreativeStatisticService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyAccountService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCampaignService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyCreativeService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyGroupService;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -49,7 +100,11 @@ import java.io.IOException;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
@@ -335,7 +390,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
-        System.out.println(resultJson);
         Integer code = resultJson.getInteger("code");
         String message = resultJson.getString("message");
         if (null == code || code != 0) {
@@ -1339,7 +1393,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
     @Override
     public void getCreativeList(CtopOauthToken token, Date startDate, Date endDate) {
-
         getCreativeListByPage(token.getAccessToken(), token.getAccountId(), startDate, endDate, 1);
     }
 
@@ -1983,6 +2036,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                         };
                         thread.start();
                         returnMap.put("code", 0);
+                        returnMap.put("creativeId", creativeId);
                         returnMap.put("message", "success");
                         returnMap.put("success", true);
                     }
@@ -2011,7 +2065,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 returnMap.put("desc", "result is null");
                 returnMap.put("success", false);
             }
-
         } catch (Exception e) {
             log.error("创建广告创意失败,advertiser_id:{}", advertiserId);
             returnMap.put("code", -1);

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

@@ -0,0 +1,548 @@
+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.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouStrategyMapper;
+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.IKuaiShouUpdateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouStrategyService;
+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 com.xxl.job.core.enums.NoEn;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.api.vo.Result;
+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.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 快手-优化评估策略表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-10
+ */
+@Slf4j
+@Service
+public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMapper, KuaishouStrategy> implements IKuaishouStrategyService {
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private IKuaiShouImageGetService imageGetService;
+    @Autowired
+    private IKuaiShouMaterialUploadService uploadService;
+    @Autowired
+    private IKuaiShouUpdateService kuaiShouUpdateService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+
+    //TODO
+    @Override
+    public Result<Object> shutDownPlan(JSONArray ids) {
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = sysUser.getId();
+        for (Object id : ids) {
+            List<JSONObject> list = new ArrayList<>();
+            CtopOauthToken token = tokenService.getTokenByAccountId(list.get(0).getLong("accountId"));
+            for (JSONObject object : list) {
+                kuaiShouUpdateService.updateCampaignStatus(token.getAccessToken(), token.getAccountId(), object.getLong("campaignId"), NoEn.NO2.valueInt(), userId);
+            }
+        }
+        return null;
+    }
+
+    /**
+     * @param oauthToken token签名
+     * @param groupJson  广告计划
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    public Map<String, Object> createPlanLevelStrategy(CtopOauthToken oauthToken, JSONObject data) {
+        JSONObject planJson = new JSONObject();
+        /**计划类型
+         * 2: 提升应用安装
+         * 3:获取电商下单
+         * 4:推广品牌活动
+         * 5:收集销售线索
+         * 7:提高应用活跃
+         */
+        if (Check.isNull(data.getInteger("type"))) {
+            return getNullValueResult("广告组必填参数:type,计划类型为空");
+        } else {
+            planJson.put("type", data.getInteger("type"));
+        }
+        //单日预算金额
+        if (!Check.isNull(data.getLong("dayBudget"))) {
+            planJson.put("day_budget", data.getLong("dayBudget"));
+        }
+        //分日预算
+        if (!Check.isNull(data.getJSONArray("dayBudgetSchedule"))) {
+            planJson.put("day_budget_schedule", data.getJSONArray("dayBudgetSchedule"));
+        }
+        return kuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), planJson);
+    }
+
+    public JSONArray createGroupLevelStrategy(CtopOauthToken oauthToken, JSONObject data) {
+        JSONArray resultArr = new JSONArray();
+        JSONArray groupInfo = data.getJSONArray("groupInfo");
+        for (int i = 0; i < groupInfo.size(); i++) {
+            Map<String, Object> resutlGroupMap = new HashMap<>();
+            JSONObject groupJson = groupInfo.getJSONObject(i);
+            try {
+                resutlGroupMap = createGroupLevelAd(oauthToken, groupJson);
+            } catch (Exception e) {
+                log.error("unitName:{},根据策略创建广告组异常", groupJson.get("unitName"), e);
+            }
+            if (!Check.isNull(resutlGroupMap)) {
+                resutlGroupMap.put("unitName", groupJson.getString("unitName"));
+                if ((boolean) resutlGroupMap.get("success")) {
+                    JSONArray creativeInfo = groupJson.getJSONArray("creativeInfo");
+                    if (Check.isNull(creativeInfo)) {
+                        resutlGroupMap.put("desc", "入参数据缺失创意级信息,仅创建计划成功");
+                    } else {
+                        JSONArray resultCretiveList = new JSONArray();
+                        for (int j = 0; j < creativeInfo.size(); j++) {
+                            Map<String, Object> creativeMap = new HashMap<>();
+                            JSONObject creativeJson = creativeInfo.getJSONObject(i);
+                            creativeMap.put("creativeName", creativeJson.getString("creativeName"));
+                            creativeJson.put("unitId", resutlGroupMap.get("unitId"));
+                            try {
+                                creativeMap = createCreativeLevelStrategy(oauthToken, creativeJson);
+                            } catch (Exception e) {
+                                log.error("unitId:{},根据策略创建广告创意异常", resutlGroupMap.get("unitId"), e);
+                            }
+                            resultCretiveList.add(creativeMap);
+                        }
+                        resutlGroupMap.put("resultCretiveList", resultCretiveList);
+                    }
+                }
+            }
+            resultArr.add(resutlGroupMap);
+        }
+        return resultArr;
+    }
+
+
+    /**
+     * 根据策略创建广告组
+     *
+     * @param oauthToken token签名
+     * @param groupJson  广告计划
+     * @return void
+     * @throws
+     * @author ZHAOXA
+     */
+    private Map<String, Object> createGroupLevelAd(CtopOauthToken oauthToken, JSONObject groupJson) throws Exception {
+        JSONObject unitJson = new JSONObject();
+        //广告计划ID
+        if (!Check.isNull(groupJson.getLong("campaignId"))) {
+            unitJson.put("campaign_id", groupJson.getLong("campaignId"));
+        } else {
+            return getNullValueResult("广告组必填参数:campaign_id,广告计划ID为空");
+        }
+        //广告组名称
+        if (!Check.isNull(groupJson.getString("unitName"))) {
+            unitJson.put("unit_name", groupJson.getString("unitName"));
+        } else {
+            return getNullValueResult("广告组必填参数:unit_name,广告组名称为空");
+        }
+        // 优化目标出价类型
+        if (!Check.isNull(groupJson.getInteger("bidType"))) {
+            unitJson.put("bid_type", groupJson.getInteger("bidType"));
+        } else {
+            return getNullValueResult("广告组必填参数:bid_type,优化目标出价类型为空");
+        }
+        /* 资源位置
+        1:优选广告位
+        3:视频播放页广告-便利贴广告(不支持深度转化目标的优化);
+        5:联盟广告,与其他类型互斥
+        6:上下滑大屏广告;
+        7:信息流广告;
+        3、6、7可多选*/
+        Integer sceneId = groupJson.getJSONArray("sceneId").getInteger(0);
+        if (!Check.isNull(groupJson.getJSONArray("sceneId"))) {
+            unitJson.put("scene_id", groupJson.getJSONArray("sceneId"));
+        } else {
+            return getNullValueResult("广告组必填参数:scene_id,资源位置为空");
+        }
+        // 资源创作方式  4: 自定义;5:程序化创意  7:程序化创意2.0
+        if (!Check.isNull(groupJson.getInteger("unitType"))) {
+            unitJson.put("unit_type", groupJson.getInteger("unitType"));
+        } else {
+            return getNullValueResult("广告组必填参数:unit_type,资源创作方式为空");
+        }
+        // 创意展现方式 1-轮播 2-优选
+        if (!Check.isNull(groupJson.getInteger("showMode"))) {
+            unitJson.put("show_mode", groupJson.getInteger("showMode"));
+        } else {
+            return getNullValueResult("广告组必填参数:show_mode,创意展现方式为空");
+        }
+        /**
+         投放方式
+         1 - 加速投放
+         2 - 平滑投放
+         3-优先低成本(投放时间范围只可为全天;预算不可为不限或空)
+         */
+        if (!Check.isNull(groupJson.getInteger("speed"))) {
+            unitJson.put("speed", groupJson.getInteger("speed"));
+        } else {
+            return getNullValueResult("广告组必填参数:speed,投放方式为空");
+        }
+        // 封面点击出价
+        if (!Check.isNull(groupJson.getLong("bid"))) {
+            unitJson.put("bid", groupJson.getLong("bid"));
+        }
+        // 深度转化出价
+        if (!Check.isNull(groupJson.getLong("cpaBid"))) {
+            unitJson.put("cpa_bid", groupJson.getLong("cpaBid"));
+        }
+        // 深度转化目标出价
+        if (!Check.isNull(groupJson.getLong("deepConversionBid"))) {
+            unitJson.put("deep_conversion_bid", groupJson.getLong("deepConversionBid"));
+        }
+        // 深度转化目标
+        if (!Check.isNull(groupJson.getInteger("deepConversionType"))) {
+            unitJson.put("deep_conversion_type", groupJson.getInteger("deepConversionType"));
+        }
+        // 优化目标
+        if (!Check.isNull(groupJson.getInteger("ocpxActionType"))) {
+            unitJson.put("ocpx_action_type", groupJson.getInteger("ocpxActionType"));
+        }
+        //投放开始时间
+        if (!Check.isNull(groupJson.getString("beginTime"))) {
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            boolean beginTimeBoolean = DateUtils.compare(groupJson.getString("beginTime"), nowDate);
+            if (beginTimeBoolean) {
+                unitJson.put("begin_time", nowDate);
+            } else {
+                unitJson.put("begin_time", groupJson.getString("beginTime"));
+            }
+        } else {
+            return getNullValueResult("广告组必填参数:begin_time,投放开始时间为空");
+        }
+        // 投放结束时间
+        if (!Check.isNull(groupJson.getString("endTime"))) {
+            unitJson.put("end_time", groupJson.getString("beginTime"));
+        }
+        // 投放时间段
+        if (!Check.isNull(groupJson.getString("scheduleTime"))) {
+            unitJson.put("schedule_time", groupJson.getString("scheduleTime"));
+        }
+        //定向模板id(选)
+        if (!Check.isNull(groupJson.getLong("templateId"))) {
+            unitJson.put("template_id", groupJson.getLong("templateId"));
+        }
+        // 优先从系统应用商店下载 1:优先从系统应用商店下载使用,默认0
+        if (!Check.isNull(groupJson.getInteger("useAppMarket"))) {
+            unitJson.put("use_app_market", groupJson.getInteger("useAppMarket"));
+        }
+         /*应用商店列表
+          华为:huawei,
+          OPPO:oppo
+          VIVO:vivo
+         小米:xiaomi
+         魅族:meizu
+         锤子:smartisan*/
+        if (!Check.isNull(groupJson.getJSONArray("appStore"))) {
+            unitJson.put("app_store", groupJson.getJSONArray("appStore"));
+        }
+        // 转化目标id
+        if (!Check.isNull(groupJson.getInteger("convertId"))) {
+            unitJson.put("convert_id", groupJson.getInteger("convertId"));
+        }
+        // 广告组单日预算 指定0表示预算不限,默认为0;不小于100元,不超过100000000元,仅支持输入数字;
+        if (!Check.isNull(groupJson.getLong("dayBudget"))) {
+            unitJson.put("day_budget", groupJson.getLong("dayBudget"));
+        }
+        // url类型
+        if (!Check.isNull(groupJson.getInteger("urlType"))) {
+            unitJson.put("url_type", groupJson.getInteger("urlType"));
+        }
+        // url类型
+        if (!Check.isNull(groupJson.getString("webUriType"))) {
+            unitJson.put("web_uri_type", groupJson.getString("webUriType"));
+        }
+        // url
+        if (!Check.isNull(groupJson.getString("url"))) {
+            unitJson.put("url", groupJson.getString("url"));
+        }
+        // appId
+        if (!Check.isNull(groupJson.getLong("appId"))) {
+            unitJson.put("app_id", groupJson.getLong("appId"));
+        }
+        // 预约广告 1:IOS预约 缺省为不传或传0
+        if (!Check.isNull(groupJson.getLong("siteType"))) {
+            unitJson.put("site_type", groupJson.getLong("siteType"));
+        }
+        // 游戏礼包码
+        if (!Check.isNull(groupJson.getLong("giftData"))) {
+            unitJson.put("gift_data", groupJson.getLong("giftData"));
+        }
+        // -----------------用户定向-----------
+        JSONObject targetJson = new JSONObject();
+        // 地域
+        if (!Check.isNull(groupJson.getJSONArray("region"))) {
+            targetJson.put("region", groupJson.getJSONArray("region"));
+        }
+        // 自定义年龄段
+        JSONArray ageArr = groupJson.getJSONArray("age");
+        if (!Check.isNull(ageArr)) {
+            JSONObject ageJson = new JSONObject();
+            ageJson.put("min", ageArr.get(0));
+            ageJson.put("max", ageArr.get(1));
+            targetJson.put("age", ageJson);
+        }
+        // 固定年龄段
+        if (!Check.isNull(groupJson.getJSONArray("agesRange"))) {
+            targetJson.put("ages_range", groupJson.getJSONArray("agesRange"));
+        }
+        // 性别
+        if (!Check.isNull(groupJson.getInteger("gender"))) {
+            targetJson.put("gender", groupJson.getInteger("gender"));
+        }
+        //操作系统
+        if (!Check.isNull(groupJson.getInteger("platformOs"))) {
+            targetJson.put("platform_os", groupJson.getInteger("platformOs"));
+        }
+        //Android版本
+        if (!Check.isNull(groupJson.getInteger("androidOsv"))) {
+            targetJson.put("android_osv", groupJson.getInteger("androidOsv"));
+        }
+        // iOS版本
+        if (!Check.isNull(groupJson.getInteger("iosOsv"))) {
+            targetJson.put("ios_osv", groupJson.getInteger("iosOsv"));
+        }
+        //网络环境
+        if (!Check.isNull(groupJson.getInteger("network"))) {
+            targetJson.put("network", groupJson.getInteger("network"));
+        }
+        //设备品牌
+        if (!Check.isNull(groupJson.getJSONArray("deviceBrand"))) {
+            targetJson.put("device_brand", groupJson.getJSONArray("deviceBrand"));
+        }
+        //设备价格
+        if (!Check.isNull(groupJson.getJSONArray("devicePrice"))) {
+            targetJson.put("device_price", groupJson.getJSONArray("devicePrice"));
+        }
+
+        if (sceneId != 5) {
+            //过滤已转化人群纬度
+            if (!Check.isNull(groupJson.getInteger("filterConvertedLevel"))) {
+                targetJson.put("filter_converted_level", groupJson.getInteger("filterConvertedLevel"));
+            }
+            //商业兴趣类型
+            if (!Check.isNull(groupJson.getInteger("businessInterestType"))) {
+                targetJson.put("business_interest_type", groupJson.getInteger("businessInterestType"));
+            }
+            // 商业兴趣
+            if (!Check.isNull(groupJson.getJSONArray("businessInterest"))) {
+                targetJson.put("business_interest", groupJson.getJSONArray("businessInterest"));
+            }
+            //网红粉丝
+            if (!Check.isNull(groupJson.getJSONArray("fansStar"))) {
+                targetJson.put("fans_star", groupJson.getJSONArray("fansStar"));
+            }
+            //兴趣视频用户
+            if (!Check.isNull(groupJson.getJSONArray("interestVideo"))) {
+                targetJson.put("interest_video", groupJson.getJSONArray("interestVideo"));
+            }
+            //智能扩量
+            JSONObject intelliExtendJson = new JSONObject();
+            // 开启智能扩量
+            if (!Check.isNull(groupJson.getInteger("isOpen"))) {
+                intelliExtendJson.put("is_open", groupJson.getInteger("isOpen"));
+            }
+            //不可突破年龄
+            if (!Check.isNull(groupJson.getInteger("noAgeBreak"))) {
+                intelliExtendJson.put("no_age_break", groupJson.getInteger("noAgeBreak"));
+            }
+            //不可突破性别
+            if (!Check.isNull(groupJson.getInteger("noGenderBreak"))) {
+                intelliExtendJson.put("no_gender_break", groupJson.getInteger("noGenderBreak"));
+            }
+            // 不可突破地域
+            if (!Check.isNull(groupJson.getInteger("noAreaBreak"))) {
+                intelliExtendJson.put("no_area_break", groupJson.getInteger("noAreaBreak"));
+            }
+            if (!Check.isNull(intelliExtendJson)) {
+                targetJson.put("intelli_extend", intelliExtendJson);
+            }
+        }
+        // APP行为-按分类
+        if (!Check.isNull(groupJson.getJSONArray("appInterest"))) {
+            targetJson.put("app_interest", groupJson.getJSONArray("appInterest"));
+        }
+        // APP行为-按APP名称
+        if (!Check.isNull(groupJson.getJSONArray("appIds"))) {
+            targetJson.put("app_ids", groupJson.getJSONArray("appIds"));
+        }
+        // 人群包定向
+        if (!Check.isNull(groupJson.getJSONArray("population"))) {
+            targetJson.put("population", groupJson.getJSONArray("population"));
+        }
+        // 人群包排除
+        if (!Check.isNull(groupJson.getJSONArray("excludePopulation"))) {
+            targetJson.put("exclude_population", groupJson.getJSONArray("excludePopulation"));
+        }
+
+        if (!Check.isNull(groupJson.getJSONArray("thirdPlatformCode"))) {
+            targetJson.put("third_platform_code", groupJson.getJSONArray("thirdPlatformCode"));
+        }
+        unitJson.put("target", targetJson);
+        return kuaishouInterfaceService.adUnitCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), unitJson, 1);
+    }
+
+    /**
+     * 根据策略创建创意
+     *
+     * @param
+     * @return com.alibaba.fastjson.JSONObject
+     * @throws
+     * @author ZHAOXA
+     */
+    private Map<String, Object> createCreativeLevelStrategy(CtopOauthToken oauthToken, JSONObject data) {
+        Map<String, Object> resultMap = new HashMap<>();
+        JSONObject creativeJson = new JSONObject();
+        //广告组ID
+        if (!Check.isNull(data.get("unitId"))) {
+            creativeJson.put("unit_id", data.get("unitId"));
+        } else {
+            return getNullValueResult("广告创意必填参数:unit_id,广告组ID为空");
+        }
+        //创意名称
+        if (!Check.isNull(data.get("creativeName"))) {
+            creativeJson.put("creative_name", data.get("creativeName"));
+        } else {
+            return getNullValueResult("广告创意必填参数:creative_name,创意名称为空");
+        }
+        //视频ID
+        if (!Check.isNull(data.get("photoId"))) {
+            creativeJson.put("photo_id", data.get("photoId"));
+        }
+        /**
+         * 素材类型
+         * 1:竖版视频
+         * 2:横版视频
+         * 4:便利贴单图图片创意
+         * 5:竖版图片
+         * 6:横版图片
+         */
+        String creativeMaterialType = data.getString("creativeMaterialType");
+        if (!Check.isNull(creativeMaterialType)) {
+            creativeJson.put("creative_material_type", creativeMaterialType);
+        } else {
+            return getNullValueResult("广告创意必填参数:creative_material_type,素材类型为空");
+        }
+        //行动号召按钮文案
+        if (!Check.isNull(data.getString("actionBarText"))) {
+            creativeJson.put("action_bar_text", data.getString("actionBarText"));
+        } else {
+            return getNullValueResult("广告创意必填参数:action_bar_text,行动号召按钮文案为空");
+        }
+        //广告语
+        if (!Check.isNull(data.getString("description"))) {
+            creativeJson.put("description", data.getString("description"));
+        } else {
+            return getNullValueResult("广告创意必填参数:description,广告语为空");
+        }
+        //便利贴创意短广告语
+        if (!Check.isNull(data.getString("shortSlogan"))) {
+            creativeJson.put("short_slogan", data.getString("shortSlogan"));
+        }
+        //封面广告语标题
+        if (!Check.isNull(data.getString("stickerTitle"))) {
+            creativeJson.put("sticker_title", data.getString("stickerTitle"));
+        }
+        //贴纸样式类型
+        if (!Check.isNull(data.getString("overlayType"))) {
+            creativeJson.put("overlay_type", data.getString("overlayType"));
+        }
+        //广告标签
+        if (!Check.isNull(data.getString("exposeTag"))) {
+            creativeJson.put("expose_tag", data.getString("exposeTag"));
+        }
+        //广告标签2期
+        if (!Check.isNull(data.getJSONArray("newExposeTag"))) {
+            creativeJson.put("new_expose_tag", data.getJSONArray("newExposeTag"));
+        }
+        //安卓下载中间页ID
+        if (!Check.isNull(data.getLong("siteId"))) {
+            creativeJson.put("site_id", data.getLong("siteId"));
+        }
+        String imageToken = null;
+        String signature = data.getString("signature");
+        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 url = imageGetService.getUrlByCode(signature);
+                imageToken = uploadService.kuauiShouImageUpload(url, signature, oauthToken.getAccountId(), oauthToken.getAccessToken());
+            }
+            if (Check.isNull(imageToken)) {
+                resultMap.put("success", false);
+                resultMap.put("creativeName", data.get("creativeName"));
+                resultMap.put("message", "获取图片文件失败");
+                return resultMap;
+            }
+        }
+        JSONArray tokenArr = new JSONArray();
+        //封面图片token
+        creativeJson.put("image_token", imageToken);
+        //便利贴单图图片创意token
+        tokenArr.add(imageToken);
+        creativeJson.put("image_tokens", tokenArr);
+        if (!Check.isNull(data.getString("clickTrackUrl"))) {
+            //第三方点击检测链接
+            creativeJson.put("click_track_url", data.getString("clickTrackUrl"));
+            //第三方开始播放监测链接
+            creativeJson.put("impression_url", data.getString("clickTrackUrl"));
+        }
+        //第三方有效播放监测链接
+        if (!Check.isNull(data.getString("adPhotoPlayedT3sUrl"))) {
+            creativeJson.put("ad_photo_played_t3s_url", data.getString("adPhotoPlayedT3sUrl"));
+        }
+        //第三方点击按钮监测链接
+        if (!Check.isNull(data.getString("actionbarClickUrl"))) {
+            creativeJson.put("actionbar_click_url", data.getString("actionbarClickUrl"));
+        }
+        //创意分类
+        if (!Check.isNull(data.getString("creativeCategory"))) {
+            creativeJson.put("creative_category", data.getString("creativeCategory"));
+        }
+        //创意标签
+        if (!Check.isNull(data.getString("creativeTag"))) {
+            creativeJson.put("creative_tag", data.getString("creative_tag"));
+        }
+        return kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), creativeJson, 1);
+    }
+
+    private Map<String, Object> getNullValueResult(String msg) {
+        Map<String, Object> map = new HashMap<>();
+        map.put("code", -1);
+        map.put("message", "error");
+        map.put("desc", msg);
+        map.put("success", false);
+        return map;
+    }
+
+}

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

@@ -186,7 +186,7 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
      */
     @Override
     public JSONObject createTemplate(Long accountId, String accessToken, JSONObject requestJson) {
-
+        JSONObject returnJson = new JSONObject();
 
         try {
             if (Check.isNull(requestJson.getString("templateName"))) {
@@ -298,17 +298,34 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
             headers.put("Content-Type", " application/json");
 
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_CREATE;
-            System.err.println(param);
+
             String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
 
             JSONObject resultJson = JSONObject.parseObject(result);
-            System.err.println(resultJson);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    getTemplateByAccountId(accountId, accessToken, 1);
+                    returnJson.put("code", 0);
+                    JSONObject data = resultJson.getJSONObject("data");
+                    returnJson.put("templateId", data.getLong("template_id"));
+
+                } else {
+                    returnJson.put("code", -1);
+                    returnJson.put("message", returnJson.getString("message"));
+                }
+            } else {
+                returnJson.put("code", -1);
+                returnJson.put("message", "返回结果为空");
+            }
 
 
         } catch (Exception e) {
             e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
         }
-        return null;
+        return returnJson;
     }
 
 
@@ -322,6 +339,7 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
      */
     @Override
     public JSONObject updateTemplate(Long accountId, String accessToken, JSONObject requestJson) {
+        JSONObject returnJson = new JSONObject();
         try {
             if (Check.isNull(requestJson.getString("templateName"))) {
                 throw new Exception("定向模板名称为必传项");
@@ -430,18 +448,31 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
             Map<String, String> headers = new HashMap<String, String>();
             headers.put("Access-Token", accessToken);
             headers.put("Content-Type", " application/json");
-
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_CREATE;
-            System.err.println(param);
             String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
-
             JSONObject resultJson = JSONObject.parseObject(result);
-            System.err.println(resultJson);
-
-
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    getTemplateByAccountId(accountId, accessToken, 1);
+                    returnJson.put("code", 0);
+                    JSONObject data = resultJson.getJSONObject("data");
+                    if (!Check.isNull(data)) {
+                        returnJson.put("templateId", data.getLong("template_id"));
+                    }
+                } else {
+                    returnJson.put("code", -1);
+                    returnJson.put("message", returnJson.getString("message"));
+                }
+            } else {
+                returnJson.put("code", -1);
+                returnJson.put("message", "返回结果为空");
+            }
         } catch (Exception e) {
             e.printStackTrace();
+            returnJson.put("code", -1);
+            returnJson.put("message", e.getMessage());
         }
-        return null;
+        return returnJson;
     }
 }

+ 3 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IRuleKuaiShouAccountService.java

@@ -1,7 +1,8 @@
 package cn.com.ctop.kuaishou.modules.report.service;
 
-public interface IRuleKuaiShouAccountService {
+import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
+import com.baomidou.mybatisplus.extension.service.IService;
 
+public interface IRuleKuaiShouAccountService extends IService<RuleDataAccountKuaishou> {
     void cleanRuleDataAccount(Long accountId);
-
 }

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

@@ -1,9 +1,12 @@
 package cn.com.ctop.kuaishou.modules.report.service;
 
+import cn.com.ctop.common.module.entity.RuleDatePlanKuaishou;
+import com.baomidou.mybatisplus.extension.service.IService;
+
 /**
  *  快手规则引擎数据清洗;计划、组、定向
  */
-public interface IRuleKuaiShouPlanService {
+public interface IRuleKuaiShouPlanService extends IService<RuleDatePlanKuaishou> {
 
     /**
      *  计划

+ 3 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouAccountServiceImpl.java

@@ -2,17 +2,19 @@ package cn.com.ctop.kuaishou.modules.report.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
+import cn.com.ctop.common.module.mapper.RuleDataAccountKuaishouMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IRuleDataAccountKuaishouService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouGetAccountFundService;
 import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouAccountService;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service
-public class RuleKuaiShouAccountServiceImpl implements IRuleKuaiShouAccountService {
+public class RuleKuaiShouAccountServiceImpl extends ServiceImpl<RuleDataAccountKuaishouMapper, RuleDataAccountKuaishou> implements IRuleKuaiShouAccountService {
 
     @Autowired
     IKuaiShouGetAccountFundService kuaiShouGetAccountFundService;

+ 49 - 18
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouPlanServiceImpl.java

@@ -3,6 +3,7 @@ package cn.com.ctop.kuaishou.modules.report.service.impl;
 import cn.com.ctop.common.module.entity.RuleDataTargetKuaishou;
 import cn.com.ctop.common.module.entity.RuleDatePlanKuaishou;
 import cn.com.ctop.common.module.entity.RuleDateUnitKuaishou;
+import cn.com.ctop.common.module.mapper.RuleDatePlanKuaishouMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IRuleDataTargetKuaishouService;
 import cn.com.ctop.common.module.service.IRuleDataUnitKuaishouService;
@@ -15,6 +16,7 @@ import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
 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 com.xxl.job.core.context.XxlJobHelper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -27,7 +29,7 @@ import java.util.List;
 import java.util.Map;
 
 @Service
-public class RuleKuaiShouPlanServiceImpl implements IRuleKuaiShouPlanService {
+public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaishouMapper, RuleDatePlanKuaishou>  implements IRuleKuaiShouPlanService {
 
     @Autowired
     ICtopOauthTokenService oauthTokenService;
@@ -120,18 +122,19 @@ public class RuleKuaiShouPlanServiceImpl implements IRuleKuaiShouPlanService {
         String result = HttpUtils.kuaiShouhttpPostRequest("https://ad.e.kuaishou.com/rest/openapi/v1/ad_unit/list", param.toJSONString(), headers);
         JSONObject resultJson = JSONObject.parseObject(result);
         if (Check.isNull(resultJson)) {
-            XxlJobHelper.log("获取广告组接口异常,advertiserId:{}", accountId);
+            XxlJobHelper.log("获取定向信息接口异常,advertiserId:{}", accountId);
             return;
         }
         Integer code = resultJson.getInteger("code");
         if (null == code || code != 0) {
-            XxlJobHelper.log("获取广告组返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
+            XxlJobHelper.log("获取定向信息返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
             return;
         }
         JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
         if (Check.isNull(details)) {
             return;
         }
+
         this.insertTarget(accountId, details);
         cleanRuleDataTarget(accountId, page + 1);
     }
@@ -172,7 +175,7 @@ public class RuleKuaiShouPlanServiceImpl implements IRuleKuaiShouPlanService {
                 //未知优化目标数据存空
                 if(group.getOcpxActionType()!=0){
                     unit.setConvertNum(handleConvertNum(group.getOcpxActionType(),unitDetail));
-                    if(unit.getConvertNum()!=0){
+                    if(null!=unit.getConvertNum()&&unit.getConvertNum()!=0){
                         unit.setConvertCost(unitDetail.getBigDecimal("charge").divide(BigDecimal.valueOf(unit.getConvertNum()), 2, RoundingMode.HALF_UP));
                     }
                 }
@@ -190,20 +193,35 @@ public class RuleKuaiShouPlanServiceImpl implements IRuleKuaiShouPlanService {
         details.forEach(detail -> {
             JSONObject unitDetail = (JSONObject) detail;
             RuleDataTargetKuaishou target = new RuleDataTargetKuaishou();
-            if ((unitDetail.getInteger("status") == 20 || unitDetail.getInteger("status") == 19) &&
-                    unitDetail.getInteger("put_status") == 1) {
+            Integer status = unitDetail.getInteger("status");
+            Integer putStatus = unitDetail.getInteger("put_status");
+            if ((status == 20 || status == 19) && putStatus == 1) {
                 target.setId(unitDetail.getLong("unit_id"));
                 target.setAccountId(accountId);
                 target.setPlanId(unitDetail.getLong("campaign_id"));
                 target.setUnitId(unitDetail.getLong("unit_id"));
                 target.setSceneId(unitDetail.getJSONArray("scene_id")==null?"":unitDetail.getJSONArray("scene_id").toString());
-                target.setRegion(unitDetail.getJSONArray("region")==null?"":unitDetail.getJSONArray("region").toString());
-                target.setGender(unitDetail.getInteger("gender")==null?0:unitDetail.getInteger("gender"));
-                target.setPlatformOs(unitDetail.getInteger("platform_os")==null?0:unitDetail.getInteger("platform_os"));
-                target.setDeviceBrand(unitDetail.getJSONArray("device_brand")==null?"":unitDetail.getJSONArray("device_brand").toString());
-                target.setDevicePrice(unitDetail.getJSONArray("device_price")==null?"":unitDetail.getJSONArray("device_price").toString());
-                target.setFilterConvertedLevel(unitDetail.getInteger("filter_converted_level")==null?0:unitDetail.getInteger("filter_converted_level"));
-                target.setIsOpen(unitDetail.getInteger("is_open")==null?0:unitDetail.getInteger("is_open"));
+
+                JSONArray region = unitDetail.getJSONObject("target").getJSONArray("region");
+                target.setRegion(region==null?"":region.toJSONString());
+
+                Integer gender = unitDetail.getJSONObject("target").getInteger("gender");
+                target.setGender(gender==null?0:gender);
+
+                Integer platformOs = unitDetail.getJSONObject("target").getInteger("platform_os");
+                target.setPlatformOs(platformOs==null?0:platformOs);
+
+                JSONArray deviceBrand = unitDetail.getJSONObject("target").getJSONArray("device_brand");
+                target.setDeviceBrand(deviceBrand==null?"":deviceBrand.toJSONString());
+
+                JSONArray devicePrice = unitDetail.getJSONObject("target").getJSONArray("device_price");
+                target.setDevicePrice(devicePrice==null?"":devicePrice.toJSONString());
+
+                Integer filterConvertedLevel = unitDetail.getJSONObject("target").getInteger("filter_converted_level");
+                target.setFilterConvertedLevel(filterConvertedLevel);
+
+                Integer isOpen = unitDetail.getJSONObject("target").getJSONObject("intelli_extend").getInteger("is_open");
+                target.setIsOpen(isOpen==null?0:isOpen);
                 target.setScheduleTime(unitDetail.getString("schedule_time")==null?"":unitDetail.getString("schedule_time"));
                 batch.add(target);
             }
@@ -213,14 +231,27 @@ public class RuleKuaiShouPlanServiceImpl implements IRuleKuaiShouPlanService {
         }
     }
 
+    /**
+     * 53:提交线索,form_count
+     * 180:激活,activation
+     * 190: 付费,event_pay
+     * 191:首日ROI,event_pay_roi
+     * 348:有效线索,event_valid_clues
+     * 383: 授信,event_credit_grant_app
+     * 384: 完件 event_jin_jian_app
+     * 715:微信复制 event_add_wechat
+     * @param ocpxActionType
+     * @param detail
+     * @return
+     */
     private Long handleConvertNum(int ocpxActionType,JSONObject detail){
         Long convertNum=null;
         switch (ocpxActionType){
             case 2:
-                convertNum=detail.getLong("submit");
+                convertNum=detail.getLong("bclick");
                 break;
             case 10:
-                convertNum=detail.getLong("show");
+                convertNum=detail.getLong("aclick");
                 break;
             case 11:
                 convertNum=detail.getLong("photo_click");
@@ -229,7 +260,7 @@ public class RuleKuaiShouPlanServiceImpl implements IRuleKuaiShouPlanService {
                 convertNum=detail.getLong("download_completed");
                 break;
             case 53:
-                convertNum=detail.getLong("event_valid_clues");
+                convertNum=detail.getLong("form_count");
                 break;
             case 180:
                 convertNum=detail.getLong("activation");
@@ -244,10 +275,10 @@ public class RuleKuaiShouPlanServiceImpl implements IRuleKuaiShouPlanService {
                 convertNum=detail.getLong("event_valid_clues");
                 break;
             case 383:
-                convertNum=detail.getLong("event_credit_grant_landing_page");
+                convertNum=detail.getLong("event_credit_grant_app");
                 break;
             case 384:
-                convertNum=detail.getLong("event_jin_jian_landing_page");
+                convertNum=detail.getLong("event_jin_jian_app");
                 break;
             case 715:
                 convertNum=detail.getLong("event_add_wechat");

+ 23 - 2
module-oa/src/main/java/cn/com/ctop/oa/modules/service/impl/WechatCheckinDataServiceImpl.java

@@ -21,6 +21,7 @@ import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.text.ParseException;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -86,6 +87,16 @@ public class WechatCheckinDataServiceImpl extends ServiceImpl<WechatCheckinDataM
                                 Date checkDate = DateUtils.stampToTime(checkinTimeStamp);
                                 String dateStr = DateUtils.formatDate(checkDate);
                                 long dateLong = DateUtils.timeToStamp(dateStr + DAY_BEGIN);
+                                //判断上班是否是周一,周一打卡时间超过9.35则算迟到
+                                String exceptionType = jsonObject.getString("exception_type");
+                                if (NoEn.NO1.valueStr().equals(checkinTypeCode)) {
+                                    if ("星期一".equals(DateUtils.getWhatDay(checkinTimeStamp))) {
+                                        long toTime = DateUtils.timeToStamp(dateStr + " 09:35:00");
+                                        if (checkinTimeStamp > toTime) {
+                                            exceptionType = Check.isNull(exceptionType) ? "时间异常" : exceptionType;
+                                        }
+                                    }
+                                }
                                 buf = new StringBuffer();
                                 String id = buf.append(userId).append("_").append(checkinTypeCode).append("_").append(dateLong).toString();
                                 checkinData.setId(id);
@@ -107,7 +118,7 @@ public class WechatCheckinDataServiceImpl extends ServiceImpl<WechatCheckinDataM
                                 checkinData.setLocationDetail(jsonObject.getString("location_detail"));
                                 checkinData.setGroupName(jsonObject.getString("groupname"));
                                 checkinData.setDeviceid(jsonObject.getString("deviceid"));
-                                checkinData.setExceptionType(jsonObject.getString("exception_type"));
+                                checkinData.setExceptionType(exceptionType);
                                 checkinData.setLocationTitle(jsonObject.getString("location_title"));
                                 checkinData.setWifimac(jsonObject.getString("wifimac"));
                                 checkinData.setMediaids(jsonObject.getJSONArray("mediaids").toJSONString());
@@ -163,11 +174,21 @@ public class WechatCheckinDataServiceImpl extends ServiceImpl<WechatCheckinDataM
                                 checkinType = jsonObject.getString("checkin_type");
                                 //1上班,2下班
                                 checkinTypeCode = "上班打卡".equals(checkinType) ? NoEn.NO1.valueStr() : NoEn.NO2.valueStr();
+                                String exceptionType = jsonObject.getString("exception_type");
                                 //下班打卡时间
                                 Long checkinTimeStamp = jsonObject.getLong("checkin_time");
                                 Date checkDate = DateUtils.stampToTime(checkinTimeStamp);
                                 String dateStr = DateUtils.formatDate(checkDate);
                                 long dateLong = DateUtils.timeToStamp(dateStr + DAY_BEGIN);
+                                //判断上班是否是周一,周一打卡时间超过9.35则算迟到
+                                if (NoEn.NO1.valueStr().equals(checkinTypeCode)) {
+                                    if ("星期一".equals(DateUtils.getWhatDay(checkinTimeStamp))) {
+                                        long toTime = DateUtils.timeToStamp(dateStr + " 10:00:00");
+                                        if (checkinTimeStamp > toTime) {
+                                            exceptionType = Check.isNull(exceptionType) ? "时间异常" : exceptionType;
+                                        }
+                                    }
+                                }
                                 buf = new StringBuffer();
                                 String id = buf.append(userId).append("_").append(checkinTypeCode).append("_").append(dateLong).toString();
                                 checkinData.setId(id);
@@ -189,7 +210,7 @@ public class WechatCheckinDataServiceImpl extends ServiceImpl<WechatCheckinDataM
                                 checkinData.setLocationDetail(jsonObject.getString("location_detail"));
                                 checkinData.setGroupName(jsonObject.getString("groupname"));
                                 checkinData.setDeviceid(jsonObject.getString("deviceid"));
-                                checkinData.setExceptionType(jsonObject.getString("exception_type"));
+                                checkinData.setExceptionType(exceptionType);
                                 checkinData.setLocationTitle(jsonObject.getString("location_title"));
                                 checkinData.setWifimac(jsonObject.getString("wifimac"));
                                 checkinData.setMediaids(jsonObject.getJSONArray("mediaids").toJSONString());

+ 4 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IRuleByteDanceAccountService.java

@@ -1,6 +1,9 @@
 package cn.com.ctop.toutiao.modules.report.service;
 
-public interface IRuleByteDanceAccountService {
+import cn.com.ctop.common.module.entity.RuleDataAccount;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+public interface IRuleByteDanceAccountService extends IService<RuleDataAccount> {
 
     void cleanRuleDataAccount(Long accountId);
 

+ 29 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java

@@ -205,6 +205,14 @@ public class ReportServiceImpl implements IReportService {
                 ruleDataPlan.setPricing(plan.getPricing());
                 ruleDataPlan.setCpaBid(plan.getCpaBid());
                 ruleDataPlan.setDeepCpabid(plan.getDeepCpaBid());
+                Long convertId = plan.getConvertId();
+                if(null!=convertId&&convertId!=0){
+                    ruleDataPlan.setConvertId(plan.getConvertId());
+                    String deepConvertTarget = readAdConvert(token,plan.getConvertId());
+                    if(null!=deepConvertTarget){
+                        ruleDataPlan.setDeepConvertTarget(deepConvertTarget);
+                    }
+                }
                 RuleDataTarget target = new RuleDataTarget();
                 JSONObject audienceObject = JSONObject.parseObject(plan.getAudience());
                 target.setAccountId(token.getAccountId());
@@ -287,6 +295,26 @@ public class ReportServiceImpl implements IReportService {
         }
     }
 
+
+    public String readAdConvert(CtopOauthToken token,Long convertId) {
+        String url = "https://ad.oceanengine.com/open_api/2/tools/ad_convert/read/";
+        JSONObject params = new JSONObject();
+        params.put("advertiser_id", token.getAccountId());
+        params.put("convert_id", convertId);
+        JSONObject result = HttpUtils.bytedanceGetRequest(token.getAccessToken(),url,params);
+        Integer code = result.getInteger("code");
+        String message = result.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取转化数据异常=》account:{};convertId:{};message:{}", token.getAccountId(), convertId,message);
+            return  null;
+        }
+        if(null!=result.getJSONObject("data")&&null!=result.getJSONObject("data").getString("deep_external_action")&&!"".equals(result.getJSONObject("data").getString("deep_external_action"))){
+            return result.getJSONObject("data").getString("deep_external_action");
+        }
+        return null;
+    }
+
+
     @Autowired
     private IByteDanceCreativeService creativeService;
     @Autowired
@@ -440,6 +468,7 @@ public class ReportServiceImpl implements IReportService {
                 if (code == 200 || code == 1) {
                     byteDanceVideoReportDailyService.videoInfoListByAccountId(formatDate, formatDate, token.getAccountId());
                 }
+
                 //
             }
         } catch (Exception e) {

+ 3 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/RuleByteDanceAccountServiceImpl.java

@@ -2,16 +2,18 @@ package cn.com.ctop.toutiao.modules.report.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.RuleDataAccount;
+import cn.com.ctop.common.module.mapper.RuleDataAccountMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IRuleDataAccountService;
 import cn.com.ctop.toutiao.modules.report.service.IRuleByteDanceAccountService;
 import cn.com.ctop.toutiao.modules.tool.service.IByteDanceGetAccountFundService;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 @Service
-public class RuleByteDanceAccountServiceImpl implements IRuleByteDanceAccountService {
+public class RuleByteDanceAccountServiceImpl extends ServiceImpl<RuleDataAccountMapper, RuleDataAccount> implements IRuleByteDanceAccountService {
 
     @Autowired
     IByteDanceGetAccountFundService byteDanceGetAccountFundService;

+ 3 - 48
pom.xml

@@ -96,7 +96,6 @@
         <commons.version>2.6</commons.version>
         <aliyun-java-sdk-core.version>3.5.0</aliyun-java-sdk-core.version>
         <aliyun-java-sdk-dysmsapi.version>1.0.0</aliyun-java-sdk-dysmsapi.version>
-
     </properties>
 
     <dependencies>
@@ -121,9 +120,9 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-        <groupId>org.springframework.boot</groupId>
-        <artifactId>spring-boot-starter-aop</artifactId>
-    </dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-aop</artifactId>
+        </dependency>
         <!-- 第三方登录 -->
         <dependency>
             <groupId>com.xkcoding.justauth</groupId>
@@ -225,35 +224,6 @@
             <version>5.1.47</version>
             <scope>runtime</scope>
         </dependency>
-        <!--sqlserver-->
-        <dependency>
-            <groupId>net.sourceforge.jtds</groupId>
-            <artifactId>jtds</artifactId>
-            <version>1.3.1</version>
-            <scope>runtime</scope>
-        </dependency>
-        <dependency>
-            <groupId>com.microsoft.sqlserver</groupId>
-            <artifactId>mssql-jdbc</artifactId>
-            <version>7.2.1.jre8</version>
-            <scope>runtime</scope>
-        </dependency>
-        <!-- mini文件存储服务 -->
-        <dependency>
-            <groupId>io.minio</groupId>
-            <artifactId>minio</artifactId>
-            <version>4.0.0</version>
-            <exclusions>
-                <exclusion>
-                    <artifactId>guava</artifactId>
-                    <groupId>com.google.guava</groupId>
-                </exclusion>
-                <exclusion>
-                    <artifactId>jsr305</artifactId>
-                    <groupId>com.google.code.findbugs</groupId>
-                </exclusion>
-            </exclusions>
-        </dependency>
         <!-- Quartz定时任务 -->
         <dependency>
             <groupId>org.springframework.boot</groupId>
@@ -383,16 +353,6 @@
             <version>3.6.0</version>
         </dependency>
         <dependency>
-            <groupId>us.codecraft</groupId>
-            <artifactId>webmagic-core</artifactId>
-            <version>0.7.3</version>
-        </dependency>
-        <dependency>
-            <groupId>us.codecraft</groupId>
-            <artifactId>webmagic-extension</artifactId>
-            <version>0.7.3</version>
-        </dependency>
-        <dependency>
             <groupId>net.sourceforge.htmlunit</groupId>
             <artifactId>htmlunit</artifactId>
             <version>2.36.0</version>
@@ -402,11 +362,6 @@
             <artifactId>java-client</artifactId>
             <version>7.2.0</version>
         </dependency>
-        <!--        <dependency>-->
-        <!--            <groupId>io.aexp.nodes.graphql</groupId>-->
-        <!--            <artifactId>nodes</artifactId>-->
-        <!--            <version>0.4.0</version>-->
-        <!--        </dependency>-->
         <dependency>
             <groupId>commons-codec</groupId>
             <artifactId>commons-codec</artifactId>