瀏覽代碼

Merge remote-tracking branch 'origin/master'

syh 5 年之前
父節點
當前提交
3169a5cfc7
共有 21 個文件被更改,包括 1105 次插入123 次删除
  1. 33 3
      module-common/src/main/java/cn/com/ctop/common/module/utils/HttpUtils.java
  2. 6 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  3. 114 113
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/appium/entity/AppiumTaskItem.java
  4. 13 6
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/appium/service/impl/AppiumTaskServiceImpl.java
  5. 90 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/util/AppiumUtil.java
  6. 86 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/util/KuaimiUtil.java
  7. 4 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/jiema/service/IKuaimiService.java
  8. 86 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/jiema/service/impl/KuaimiServiceImpl.java
  9. 70 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/jiema/service/impl/WumaServiceImpl.java
  10. 101 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/MaterialRefuseController.java
  11. 10 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/MaterialRefuseMapper.java
  12. 26 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/MateriaRefuseMapper.xml
  13. 13 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouUpdateService.java
  14. 11 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IMaterialRefuseService.java
  15. 62 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouUpdateServiceImpl.java
  16. 25 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/MaterialRefuseServiceImpl.java
  17. 22 0
      module-report/src/main/java/cn/com/ctop/bytedance/controller/MaterialReportController.java
  18. 4 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/MaterialReportMapper.java
  19. 186 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/MaterialReportMapper.xml
  20. 17 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/IMaterialReportService.java
  21. 126 0
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/MaterialReportServiceImpl.java

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

@@ -204,10 +204,15 @@ public class HttpUtils {
             HttpPost httppost = new HttpPost(url);
             httppost.setHeader("User-Agent", USER_AGENT);
             httppost.addHeader("Content-Type", "application/json");
-            for (String key : headers.keySet()) {
-                httppost.setHeader(key, headers.get(key));
+            if (headers != null && headers.size() > 0) {
+                for (String key : headers.keySet()) {
+                    httppost.setHeader(key, headers.get(key));
+                }
             }
-            httppost.setEntity(new StringEntity(new Gson().toJson(param), Charset.forName("UTF-8")));
+            if (param != null && param.size() > 0) {
+                httppost.setEntity(new StringEntity(new Gson().toJson(param), Charset.forName("UTF-8")));
+            }
+
             HttpEntity respentity;
 
             HttpResponse response = httpClient.execute(httppost);
@@ -227,6 +232,31 @@ public class HttpUtils {
         return strReturn;
     }
 
+    public static String httpPostNoParamRequest(String url) {
+        HttpClient httpClient = createSslClientDefault();
+        String strReturn = "";
+        try {
+            HttpPost httppost = new HttpPost(url);
+            httppost.setHeader("User-Agent", USER_AGENT);
+            httppost.addHeader("Content-Type", "application/json");
+            HttpEntity respentity;
+            HttpResponse response = httpClient.execute(httppost);
+            int statusCode = response.getStatusLine().getStatusCode();
+            if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
+                String newUrl = response.getFirstHeader("Location").getValue();
+                return httpPostNoParamRequest(newUrl);
+            } else if (statusCode == HttpStatus.SC_OK) {
+                respentity = response.getEntity();
+                strReturn = EntityUtils.toString(respentity);
+                return strReturn;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error(e.getMessage());
+        }
+        return strReturn;
+    }
+
 
     public static String httpPostRequestTest(String url, String body, Map<String, String> headers) {
         HttpClient httpClient = createSslClientDefault();

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

@@ -119,7 +119,12 @@ public class KuaishouInterfaceConstant {
     /**
      * 快手-广告主信息
      */
-    public static final String ADVERTISER_INFO = "//rest/openapi/v1/advertiser/info";
+    public static final String ADVERTISER_INFO = "/rest/openapi/v1/advertiser/info";
+
+    /**
+     * 修改广告创意
+     */
+    public static final String UPDATE_CREATIVE = "/rest/openapi/v2/creative/update";
 
 
     /**

+ 114 - 113
module-crawler/src/main/java/cn/com/ctop/crawler/modules/appium/entity/AppiumTaskItem.java

@@ -1,19 +1,22 @@
 package cn.com.ctop.crawler.modules.appium.entity;
 
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
 import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
-import java.util.Date;
-import java.util.List;
-
 /**
  * 任务内容表
  * @author jeecg-boot
@@ -27,120 +30,118 @@ import java.util.List;
 @ApiModel(value = "ctop_appium_task_item对象", description = "任务内容表")
 public class AppiumTaskItem {
 
-    /**
-     * 主键
-     */
-    @TableId(type = IdType.AUTO)
-    @ApiModelProperty(value = "主键")
-    private Integer id;
-    /**
-     * 任务ID
-     */
-    @Excel(name = "任务ID", width = 15)
-    @ApiModelProperty(value = "任务ID")
-    private Integer taskId;
-    /**
-     * 父ID
-     */
-    @Excel(name = "父ID", width = 15)
-    @ApiModelProperty(value = "父ID")
-    private Integer parentId;
-    /**
-     * 顺序
-     */
-    @Excel(name = "顺序", width = 15)
-    @ApiModelProperty(value = "顺序")
-    private Integer seq;
-    /**
-     * 查找类型
-     */
-    @Excel(name = "查找类型", width = 15)
-    @ApiModelProperty(value = "查找类型")
-    private String findType;
+	/**
+	 * 主键
+	 */
+	@TableId(type = IdType.AUTO)
+	@ApiModelProperty(value = "主键")
+	private Integer id;
+	/**
+	 * 任务ID
+	 */
+	@Excel(name = "任务ID", width = 15)
+	@ApiModelProperty(value = "任务ID")
+	private Integer taskId;
+	/**
+	 * 父ID
+	 */
+	@Excel(name = "父ID", width = 15)
+	@ApiModelProperty(value = "父ID")
+	private Integer parentId;
+	/**
+	 * 顺序
+	 */
+	@Excel(name = "顺序", width = 15)
+	@ApiModelProperty(value = "顺序")
+	private Integer seq;
+	/**
+	 * 查找类型
+	 */
+	@Excel(name = "查找类型", width = 15)
+	@ApiModelProperty(value = "查找类型")
+	private String findType;
 
     @Excel(name = "名称", width = 15)
     @ApiModelProperty(value = "名称")
     private String name;
-    /**
-     * 查找关键字
-     */
-    @Excel(name = "查找关键字", width = 15)
-    @ApiModelProperty(value = "查找关键字")
-    private String findKey;
-    /**
-     * 点击类型
-     */
-    @Excel(name = "点击类型", width = 15)
-    @ApiModelProperty(value = "点击类型")
-    private String clickType;
-    /**
-     * 偏移量X
-     */
-    @Excel(name = "偏移量X", width = 15)
-    @ApiModelProperty(value = "偏移量X")
-    private Integer offsiteX;
-    /**
-     * 偏移量Y
-     */
-    @Excel(name = "偏移量Y", width = 15)
-    @ApiModelProperty(value = "偏移量Y")
-    private Integer offsiteY;
-    /**
-     * 循环间隔
-     */
-    @Excel(name = "循环间隔", width = 15)
-    @ApiModelProperty(value = "循环间隔")
-    private Integer loopRate;
-    /**
-     * 循环类型
-     */
-    @Excel(name = "循环类型", width = 15)
-    @ApiModelProperty(value = "循环类型")
-    private String loopType;
-    /**
-     * 是否必经执行
-     */
-    @Excel(name = "是否必经执行", width = 15)
-    @ApiModelProperty(value = "是否必经执行")
-    private Integer isMust;
-    /**
-     * 文本查找类型
-     */
-    @Excel(name = "文本查找类型", width = 15)
-    @ApiModelProperty(value = "文本查找类型")
-    private String textEqualType;
-    /**
-     * 文本查找关键字
-     */
-    @Excel(name = "文本查找关键字", width = 15)
-    @ApiModelProperty(value = "文本查找关键字")
-    private String textEqualKey;
-    /**
-     * 滑动类型
-     */
-    @Excel(name = "滑动类型", width = 15)
-    @ApiModelProperty(value = "滑动类型")
-    private String swapType;
-    /**
-     * 延迟时长
-     */
-    @Excel(name = "延迟时长", width = 15)
-    @ApiModelProperty(value = "延迟时长")
-    private Integer waitTime;
-    /**
-     * 是否执行完关闭
-     */
-    @Excel(name = "是否执行完关闭", width = 15)
-    @ApiModelProperty(value = "是否执行完关闭")
-    private Integer isClose;
-    /**
-     * createTime
-     */
+	/**
+	 * 查找关键字
+	 */
+	@Excel(name = "查找关键字", width = 15)
+	@ApiModelProperty(value = "查找关键字")
+	private String findKey;
+	/**
+	 * 点击类型
+	 */
+	@Excel(name = "点击类型", width = 15)
+	@ApiModelProperty(value = "点击类型")
+	private String clickType;
+	/**
+	 * 偏移量X
+	 */
+	@Excel(name = "偏移量X", width = 15)
+	@ApiModelProperty(value = "偏移量X")
+	private Integer offsiteX;
+	/**
+	 * 偏移量Y
+	 */
+	@Excel(name = "偏移量Y", width = 15)
+	@ApiModelProperty(value = "偏移量Y")
+	private Integer offsiteY;
+	/**
+	 * 循环间隔
+	 */
+	@Excel(name = "循环间隔", width = 15)
+	@ApiModelProperty(value = "循环间隔")
+	private Integer loopRate;
+	/**
+	 * 循环类型
+	 */
+	@Excel(name = "循环类型", width = 15)
+	@ApiModelProperty(value = "循环类型")
+	private String loopType;
+	/**
+	 * 是否必经执行
+	 */
+	@Excel(name = "是否必经执行", width = 15)
+	@ApiModelProperty(value = "是否必经执行")
+	private Integer isMust;
+	/**
+	 * 文本查找类型
+	 */
+	@Excel(name = "文本查找类型", width = 15)
+	@ApiModelProperty(value = "文本查找类型")
+	private String textEqualType;
+	/**
+	 * 文本查找关键字
+	 */
+	@Excel(name = "文本查找关键字", width = 15)
+	@ApiModelProperty(value = "文本查找关键字")
+	private String textEqualKey;
+	/**
+	 * 滑动类型
+	 */
+	@Excel(name = "滑动类型", width = 15)
+	@ApiModelProperty(value = "滑动类型")
+	private String swapType;
+	/**
+	 * 延迟时长
+	 */
+	@Excel(name = "延迟时长", width = 15)
+	@ApiModelProperty(value = "延迟时长")
+	private Integer waitTime;
+	/**
+	 * 是否执行完关闭
+	 */
+	@Excel(name = "是否执行完关闭", width = 15)
+	@ApiModelProperty(value = "是否执行完关闭")
+	private Integer isClose;
+	/**
+	 * createTime
+	 */
     @ApiModelProperty(value = "createTime")
-    private Date createTime;
-    /**
-     * updateTime
-     */
+	private Date createTime;
+	/**updateTime*/
     @ApiModelProperty(value = "updateTime")
 	private Date updateTime;
     @TableField(exist = false)

+ 13 - 6
module-crawler/src/main/java/cn/com/ctop/crawler/modules/appium/service/impl/AppiumTaskServiceImpl.java

@@ -4,17 +4,23 @@ import cn.com.ctop.crawler.modules.appium.entity.AppiumDevice;
 import cn.com.ctop.crawler.modules.appium.entity.AppiumTask;
 import cn.com.ctop.crawler.modules.appium.entity.AppiumTaskItem;
 import cn.com.ctop.crawler.modules.appium.entity.AppiumTaskLog;
+import cn.com.ctop.crawler.modules.appium.mapper.AppiumTaskItemMapper;
+import cn.com.ctop.crawler.modules.appium.mapper.AppiumTaskLogMapper;
 import cn.com.ctop.crawler.modules.appium.mapper.AppiumTaskMapper;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumDeviceService;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskItemService;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskLogService;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskService;
 import cn.com.ctop.crawler.modules.core.util.AppiumUtil;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import io.appium.java_client.android.AndroidDriver;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.List;
 
 /**
@@ -30,7 +36,7 @@ public class AppiumTaskServiceImpl extends ServiceImpl<AppiumTaskMapper, AppiumT
     @Autowired
     private IAppiumDeviceService iAppiumDeviceService;
     @Autowired
-    private IAppiumTaskLogService iAppiumTaskLogService;
+    private AppiumTaskLogMapper appiumTaskLogMapper;
 
     public void runTask(Integer taskId, Integer deviceId) {
         AppiumTask task = this.getById(taskId);
@@ -44,24 +50,25 @@ public class AppiumTaskServiceImpl extends ServiceImpl<AppiumTaskMapper, AppiumT
         log.setStatus(1);
         log.setTaskId(taskId);
         log.setTaskName(task.getTaskName());
-        iAppiumTaskLogService.save(log);
+        appiumTaskLogMapper.insert(log);
+        log.setId(log.getId());
         List<AppiumTaskItem> taskItemList = iAppiumTaskItemService.initTaskItemList(taskId, null);
         AppiumUtil appiumUtil = new AppiumUtil();
         try {
-            AndroidDriver androidDriver = appiumUtil.initAndroidDriver("http://39.106.184.70:4723/wd/hub", appiumDevice.getIp() + ":" + appiumDevice.getPort(), task.getAppPackage(), task.getAppActivity());
+            AndroidDriver androidDriver = appiumUtil.initAndroidDriver("http://127.0.0.1:4723/wd/hub", appiumDevice.getIp() + ":" + appiumDevice.getPort(), task.getAppPackage(), task.getAppActivity());
             if (taskItemList != null && taskItemList.size() > 0) {
                 for (AppiumTaskItem appiumTaskItem : taskItemList) {
                     appiumUtil.runTask(androidDriver, appiumTaskItem, null);
                 }
                 log.setStatus(2);
-                iAppiumTaskLogService.updateById(log);
+                appiumTaskLogMapper.updateById(log);
                 appiumDevice.setStatus(1);
                 iAppiumDeviceService.updateById(appiumDevice);
             }
         } catch (Exception e) {
             e.printStackTrace();
             log.setStatus(3);
-            iAppiumTaskLogService.updateById(log);
+            appiumTaskLogMapper.updateById(log);
             appiumDevice.setStatus(1);
             iAppiumDeviceService.updateById(appiumDevice);
         }

+ 90 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/util/AppiumUtil.java

@@ -71,6 +71,96 @@ public class AppiumUtil {
         return desiredCapabilities;
     }
 
+    public void loginKuaishou(AndroidDriver androidDriver) {
+        try {
+            for (int i = 0; i < 5; i++) {
+                Thread.sleep(3000L);
+                permissionAllow(androidDriver);
+            }
+            for (int i = 0; i < 3; i++) {
+                Thread.sleep(3000L);
+                closeBtnClick(androidDriver);
+            }
+            WebElement loginBtn = getElementById(androidDriver, "com.smile.gifmaker:id/left_text");
+            if (loginBtn != null && loginBtn.equals("登陆")) {
+                loginBtn.click();
+                WebElement mobileInput = getElementById(androidDriver, "com.smile.gifmaker:id/login_name_et");
+                WebElement nextBtn = getElementById(androidDriver, "com.smile.gifmaker:id/next_view");
+                if (mobileInput != null) {
+                    String token = KuaimiUtil.kuaimiLogin();
+                    String mobile = KuaimiUtil.getMobile(token, "2307");
+                    mobileInput.sendKeys(mobile);
+                    Thread.sleep(2000L);
+                    nextBtn.click();
+                    Thread.sleep(2000L);
+                    WebElement loginTitle = getElementById(androidDriver, "com.smile.gifmaker:id/login_title_tv");
+                    WebElement forgetBtn = getElementById(androidDriver, "com.smile.gifmaker:id/forget_psd_btn");
+                    if (loginTitle != null && loginTitle.equals("输入密码")) {
+                        forgetBtn.click();
+                        Thread.sleep(2000L);
+                        WebElement sendMsgBtn = getElementById(androidDriver, "com.smile.gifmaker:id/verify_tv");
+                        sendMsgBtn.click();
+                        Thread.sleep(5000L);
+                        int i = 0;
+                        while (i < 20) {
+                            String msg = null;
+                            try {
+                                msg = KuaimiUtil.getMessage(token, "2307", mobile);
+                            } catch (Exception e) {
+                                System.out.println("等待" + mobile + "短信验证码");
+                            }
+                            if (msg != null) {
+                                WebElement captchrInput = getElementById(androidDriver, "com.smile.gifmaker:id/verify_et");
+                                captchrInput.sendKeys(msg);
+                                Thread.sleep(2000);
+                                WebElement confirmBtn = getElementById(androidDriver, "com.smile.gifmaker:id/confirm_btn");
+                                confirmBtn.click();
+                                Thread.sleep(2000);
+                                WebElement newPwdInput = getElementById(androidDriver, "com.smile.gifmaker:id/login_psd_et");
+                                newPwdInput.sendKeys("a123456");
+                                Thread.sleep(2000);
+                                WebElement confirmBtn2 = getElementById(androidDriver, "com.smile.gifmaker:id/confirm_btn");
+                                confirmBtn2.click();
+                                Thread.sleep(3000);
+                                WebElement continueBtn = getElementById(androidDriver, "com.smile.gifmaker:id/positive");
+                                if (continueBtn != null) {
+                                    continueBtn.click();
+                                }
+                                Thread.sleep(3000);
+
+                                break;
+                            }
+                            i++;
+                            Thread.sleep(5000);
+                        }
+                        if (i == 20) {
+                            KuaimiUtil.addBlackList(token, "2307", mobile);
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
+    public void permissionAllow(AndroidDriver androidDriver) {
+        WebElement element = getElementById(androidDriver, "com.android.packageinstaller:id/permission_allow_button");
+        if (element != null) {
+            element.click();
+        }
+    }
+
+    public void closeBtnClick(AndroidDriver androidDriver) {
+        WebElement element = getElementById(androidDriver, "com.smile.gifmaker:id/close_btn");
+        if (element != null) {
+            element.click();
+        }
+    }
+
+
+
     public WebElement getElementById(AndroidDriver androidDriver, String id) {
         WebElement element = null;
         List<WebElement> elements = androidDriver.findElementsById(id);

+ 86 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/util/KuaimiUtil.java

@@ -0,0 +1,86 @@
+package cn.com.ctop.crawler.modules.core.util;
+
+import cn.com.ctop.common.module.utils.HttpUtils;
+
+public class KuaimiUtil {
+    public static final String KUAIMI_API_URL = "http://api.kmiyz.com/api/do.php";
+
+    public static String kuaimiLogin() throws Exception {
+        String result = HttpUtils.httpPostNoParamRequest(KUAIMI_API_URL + "?action=loginIn&name=xuzuoyun&password=heaven01");
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public static String getMobile(String token, String projectId) throws Exception {
+        String url = KUAIMI_API_URL + "?action=getPhone&sid=" + projectId + "&token=" + token;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        System.out.println(result);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public static String getMessage(String token, String projectId, String phone) throws Exception {
+        String url = KUAIMI_API_URL + "?action=getMessage&sid=" + projectId + "&token=" + token + "&phone=" + phone;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1].substring(6, 12);
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public static String addBlackList(String token, String projectId, String phone) throws Exception {
+        String url = KUAIMI_API_URL + "?action=addBlacklist&sid=" + projectId + "&token=" + token + "&phone=" + phone;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public static String cancelRecv(String token, String projectId, String phone) throws Exception {
+        String url = KUAIMI_API_URL + "?action=cancelRecv&sid=" + projectId + "&token=" + token + "&phone=" + phone;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public static void main(String[] args) {
+        KuaimiUtil k = new KuaimiUtil();
+        try {
+            String token = k.kuaimiLogin();
+            System.out.println(token);
+            String mobile = k.getMobile(token, "2307");
+            int times = 0;
+            while (times < 100) {
+                Thread.sleep(5000);
+                try {
+                    String msg = k.getMessage(token, "2307", mobile);
+                    System.out.println(msg);
+                    break;
+                } catch (Exception e) {
+                    System.out.println("等待短信");
+                }
+                times++;
+            }
+            System.out.println("完成");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 4 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/jiema/service/IKuaimiService.java

@@ -0,0 +1,4 @@
+package cn.com.ctop.crawler.modules.jiema.service;
+
+public interface IKuaimiService {
+}

+ 86 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/jiema/service/impl/KuaimiServiceImpl.java

@@ -0,0 +1,86 @@
+package cn.com.ctop.crawler.modules.jiema.service.impl;
+
+import cn.com.ctop.common.module.utils.HttpUtils;
+
+public class KuaimiServiceImpl {
+    public static final String KUAIMI_API_URL = "http://api.kmiyz.com/api/do.php";
+
+    public String kuaimiLogin() throws Exception {
+        String result = HttpUtils.httpPostNoParamRequest(KUAIMI_API_URL + "?action=loginIn&name=xuzuoyun&password=heaven01");
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public String getMobile(String token, String projectId) throws Exception {
+        String url = KUAIMI_API_URL + "?action=getPhone&sid=" + projectId + "&token=" + token;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        System.out.println(result);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public String getMessage(String token, String projectId, String phone) throws Exception {
+        String url = KUAIMI_API_URL + "?action=getMessage&sid=" + projectId + "&token=" + token + "&phone=" + phone;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1].substring(6, 12);
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public String addBlackList(String token, String projectId, String phone) throws Exception {
+        String url = KUAIMI_API_URL + "?action=addBlacklist&sid=" + projectId + "&token=" + token + "&phone=" + phone;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public String cancelRecv(String token, String projectId, String phone) throws Exception {
+        String url = KUAIMI_API_URL + "?action=cancelRecv&sid=" + projectId + "&token=" + token + "&phone=" + phone;
+        String result = HttpUtils.httpPostNoParamRequest(url);
+        if (result != null && result.startsWith("1")) {
+            System.out.println(result);
+            return result.split("\\|")[1];
+        } else {
+            throw new Exception();
+        }
+    }
+
+    public static void main(String[] args) {
+        KuaimiServiceImpl k = new KuaimiServiceImpl();
+        try {
+            String token = k.kuaimiLogin();
+            System.out.println(token);
+            String mobile = k.getMobile(token, "2307");
+            int times = 0;
+            while (times < 100) {
+                Thread.sleep(5000);
+                try {
+                    String msg = k.getMessage(token, "2307", mobile);
+                    System.out.println(msg);
+                    break;
+                } catch (Exception e) {
+                    System.out.println("等待短信");
+                }
+                times++;
+            }
+            System.out.println("完成");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 70 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/jiema/service/impl/WumaServiceImpl.java

@@ -0,0 +1,70 @@
+package cn.com.ctop.crawler.modules.jiema.service.impl;
+
+import cn.com.ctop.common.module.utils.HttpUtils;
+
+public class WumaServiceImpl {
+    public static final String WUMA_API_URL = "http://56ji.cn:7777";
+
+    public String login() throws Exception {
+//        String result = HttpUtils.httpPostNoParamRequest(WUMA_API_URL+"/Login?uName=xuzuoyun&pWord=heaven&isFixed=ojbk&Developer=U4iw3O%2fWTw6%2b17rjP8rmuA%3d%3d");
+        String result = HttpUtils.httpGetRequest(WUMA_API_URL + "/Login?uName=xuzuoyun&pWord=heaven&isFixed=ojbk&Developer=U4iw3O%2fWTw6%2b17rjP8rmuA%3d%3d");
+        return result.split("&")[0];
+    }
+
+    public String getMobile(String token) {
+        String result = HttpUtils.httpGetRequest(WUMA_API_URL + "/getPhone?ItemId=3244&token=" + token);
+        return result;
+    }
+//    public String getMobile(String token,String projectId) throws Exception{
+//        String url = KUAIMI_API_URL+"?action=getPhone&sid="+projectId+"&token="+token;
+//        String result = HttpUtils.httpPostNoParamRequest(url);
+//        System.out.println(result);
+//        if(result != null && result.startsWith("1")){
+//            System.out.println(result);
+//            return result.split("\\|")[1];
+//        }else {
+//            throw new Exception();
+//        }
+//    }
+//    public String getMessage(String token,String projectId,String phone) throws Exception{
+//        String url = KUAIMI_API_URL+"?action=getMessage&sid="+projectId+"&token="+token+"&phone="+phone;
+//        String result = HttpUtils.httpPostNoParamRequest(url);
+//        if(result != null && result.startsWith("1")){
+//            System.out.println(result);
+//            return result.split("\\|")[1].substring(6,12);
+//        }else {
+//            throw new Exception();
+//        }
+//    }
+//    public String addBlackList(String token,String projectId,String phone) throws Exception{
+//        String url = KUAIMI_API_URL+"?action=addBlacklist&sid="+projectId+"&token="+token+"&phone="+phone;
+//        String result = HttpUtils.httpPostNoParamRequest(url);
+//        if(result != null && result.startsWith("1")){
+//            System.out.println(result);
+//            return result.split("\\|")[1];
+//        }else {
+//            throw new Exception();
+//        }
+//    }
+//    public String cancelRecv(String token,String projectId,String phone) throws Exception{
+//        String url = KUAIMI_API_URL+"?action=cancelRecv&sid="+projectId+"&token="+token+"&phone="+phone;
+//        String result = HttpUtils.httpPostNoParamRequest(url);
+//        if(result != null && result.startsWith("1")){
+//            System.out.println(result);
+//            return result.split("\\|")[1];
+//        }else {
+//            throw new Exception();
+//        }
+//    }
+
+    public static void main(String[] args) {
+        WumaServiceImpl k = new WumaServiceImpl();
+        try {
+            String token = k.login();
+            String mobile = k.getMobile(token);
+            System.out.println(mobile);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

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

@@ -0,0 +1,101 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCreativeMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
+import cn.com.ctop.kuaishou.modules.batch.service.IMaterialRefuseService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.springframework.beans.factory.annotation.Autowired;
+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.RestController;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/MaterialRefuse")
+public class MaterialRefuseController {
+    @Autowired
+    private IMaterialRefuseService materialRefuseService;
+    @Autowired
+    private CtopOauthTokenMapper oauthTokenMapper;
+    @Autowired
+    private IKuaiShouUpdateService updateService;
+    @Autowired
+    private KuaiShouCreativeMapper creativeMapper;
+
+
+    @PostMapping(value = "/getRefuseCreative")
+    public Map<String, Object> getRefuseCreative(@RequestBody JSONObject jsonObject) {
+        Map<String, Object> map = new HashMap<>();
+        try {
+            List<JSONObject> list = materialRefuseService.getRefuseCreative(jsonObject.getLong("accountId"));
+            map.put("code", 0);
+            map.put("data", list);
+        } catch (Exception e) {
+            map.put("code", -1);
+            e.printStackTrace();
+        }
+
+        return map;
+    }
+
+    @PostMapping(value = "/updateCreative")
+    public Map<String, Object> updateCreative(@RequestBody JSONObject jsonObject) {
+        Map<String, Object> map = new HashMap<>();
+        if (Check.isNull(jsonObject)) {
+            map.put("code", -1);
+            map.put("message", "入参为空");
+            return map;
+        }
+
+        Long accountId = jsonObject.getLong("accountId");
+        QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("media_id", 2);
+        queryWrapper.orderByDesc("create_time");
+        queryWrapper.last("limit 1");
+        CtopOauthToken ctopOauthToken = oauthTokenMapper.selectOne(queryWrapper);
+        if (Check.isNull(ctopOauthToken)) {
+            map.put("code", -1);
+            map.put("message", "未获取授权信息");
+            return map;
+        }
+
+        Map<String, Object> creativeMap = updateService.updateCreative(ctopOauthToken.getAccessToken(), accountId, jsonObject);
+        if (Check.isNullMap(creativeMap)) {
+            map.put("code", -1);
+            map.put("message", "修改失败,返回为空");
+            return map;
+
+        }
+
+        if ((Integer) creativeMap.get("code") != 0) {
+            map.put("code", -1);
+            map.put("message", creativeMap.get("message"));
+            return map;
+        }
+
+        QueryWrapper<KuaiShouCreative> creativeQueryWrapper = new QueryWrapper<>();
+        creativeQueryWrapper.eq("account_id", accountId);
+        creativeQueryWrapper.eq("creative_id", jsonObject.getString("creativeId"));
+        creativeQueryWrapper.eq("unit_id", jsonObject.getString("unitId"));
+        creativeQueryWrapper.eq("campaign_id", jsonObject.getString("campaignId"));
+        int i = creativeMapper.delete(creativeQueryWrapper);
+        if (i > 0) {
+            map.put("code", 0);
+            map.put("message", "重审成功");
+            return map;
+        }
+
+        return null;
+    }
+
+}

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

@@ -0,0 +1,10 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.List;
+
+public interface MaterialRefuseMapper {
+    List<JSONObject> selectRefuseCreativeByAccountId(Long accountId);
+
+}

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

@@ -0,0 +1,26 @@
+<?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.MaterialRefuseMapper">
+
+    <select id="selectRefuseCreativeByAccountId" resultType="com.alibaba.fastjson.JSONObject">
+        select
+         t1.account_id accountId,
+         t1.campaign_id campaignId,
+         t1.unit_id unitId,
+         t1.creative_id creativeId,
+         t1.creative_name creativeName,
+         t2.url videoUrl,
+         t1.cover_url coverUrl,
+         t1.review_detail reviewDetail,
+         t1.description description
+    from
+        ctop_kuaishou_creative t1
+       left join ctop_kuaishou_video_get t2
+       on t1.account_id = t2.account_id
+       and t1.photo_id = t2.photo_id
+       where  t1.account_id = #{accountId}
+       and status = 42
+       order by t1.creative_id desc
+    </select>
+
+</mapper>

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

@@ -1,5 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
+import com.alibaba.fastjson.JSONObject;
+
 import java.util.Map;
 
 public interface IKuaiShouUpdateService {
@@ -73,4 +75,15 @@ public interface IKuaiShouUpdateService {
      */
     Map<String, Object> updateCreativeStatus(String token, Long advertiserId, Long creativeId, int putStatus, String loginId);
 
+
+    /**
+     * 修改创意
+     *
+     * @param token
+     * @param advertiserId
+     * @param requestJson
+     * @return
+     */
+    Map<String, Object> updateCreative(String token, Long advertiserId, JSONObject requestJson);
+
 }

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

@@ -0,0 +1,11 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface IMaterialRefuseService {
+    List<JSONObject> getRefuseCreative(@Param("accountId") Long accountId);
+
+}

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

@@ -421,4 +421,66 @@ public class KuaiShouUpdateServiceImpl implements IKuaiShouUpdateService {
 
         return returnMap;
     }
+
+
+    /**
+     * 修改创意
+     *
+     * @param token
+     * @param advertiserId
+     * @param requestJson
+     * @return
+     */
+    @Override
+    public Map<String, Object> updateCreative(String token, Long advertiserId, JSONObject requestJson) {
+        Map<String, Object> returnMap = new HashMap<>();
+        try {
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.UPDATE_CREATIVE;
+            Map<String, String> header = new HashMap<>();
+            header.put("Access-Token", token);
+            header.put("Content-Type", "application/json");
+            JSONObject params = new JSONObject();
+
+
+            String creativeId = requestJson.getString("creativeId");
+            String creativeName = requestJson.getString("creativeName");
+            String description = requestJson.getString("description");
+
+
+            params.put("advertiser_id", advertiserId);
+            params.put("creative_id", creativeId);
+            params.put("creative_name", creativeName);
+            params.put("description", description);
+            String result = HttpUtils.httpPostRequest(url, params, header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            System.err.println("返回结果: " + resultJson);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    returnMap.put("code", 0);
+                    returnMap.put("success", true);
+                    returnMap.put("message", "修改成功");
+                } else {
+                    log.error("修改广告创意状态失败,advertiserId:{},creativeId:{},返回信息:{}", advertiserId, creativeId, resultJson);
+                    returnMap.put("code", -1);
+                    returnMap.put("success", false);
+                    returnMap.put("message", resultJson.getString("message"));
+                }
+            } else {
+                log.error("修改广告创意返回结果为空,advertiserId:{},creativeId:{}", advertiserId, creativeId);
+                returnMap.put("code", -1);
+                returnMap.put("success", false);
+                returnMap.put("message", "修改广告组预算返回结果为空");
+            }
+
+        } catch (Exception e) {
+            log.error("修改广告创意异常,advertiserId:{}", advertiserId);
+            e.printStackTrace();
+            returnMap.put("code", -1);
+            returnMap.put("success", false);
+            returnMap.put("message", "修改广告创意异常");
+        }
+
+        return returnMap;
+    }
 }

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

@@ -0,0 +1,25 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.kuaishou.modules.batch.mapper.MaterialRefuseMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IMaterialRefuseService;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Slf4j
+@Service
+public class MaterialRefuseServiceImpl implements IMaterialRefuseService {
+    @Autowired
+    private MaterialRefuseMapper materialRefuseMapper;
+
+
+    @Override
+    public List<JSONObject> getRefuseCreative(Long accountId) {
+        List<JSONObject> refuseCreativeList = materialRefuseMapper.selectRefuseCreativeByAccountId(accountId);
+        return refuseCreativeList;
+    }
+
+}

+ 22 - 0
module-report/src/main/java/cn/com/ctop/bytedance/controller/MaterialReportController.java

@@ -2,6 +2,8 @@ package cn.com.ctop.bytedance.controller;
 
 
 import cn.com.ctop.bytedance.service.IMaterialReportService;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -34,4 +36,24 @@ public class MaterialReportController {
 
     }
 
+
+    @PostMapping(value = "/getMaterialAccount")
+    public List<UserAllocation> getKuaiShouChainRatio(@RequestBody String userId) {
+        if (Check.isNull(userId)) {
+            return null;
+        }
+        List<UserAllocation> accountIdList = materialReportService.selectAccountIds(userId);
+        return accountIdList;
+
+    }
+
+
+    @PostMapping(value = "/getMaterialReportByAccount")
+    public List<JSONObject> getMaterialReportByAccount(@RequestBody JSONObject json) {
+
+        List<JSONObject> reportList = materialReportService.selectReportByAccountIds(json);
+        return reportList;
+
+    }
+
 }

+ 4 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/MaterialReportMapper.java

@@ -18,4 +18,8 @@ public interface MaterialReportMapper {
     List<JSONObject> selectDailyByMap(Map<String, Object> paramsMap);
 
     JSONObject selectDailyChainRatioByMap(Map<String, Object> paramsMap);
+
+    List<JSONObject> selectHourMaterialList(Map<String, Object> paramsMap);
+
+    List<JSONObject> selectDayMaterialList(Map<String, Object> paramsMap);
 }

+ 186 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/MaterialReportMapper.xml

@@ -195,6 +195,10 @@
             <if test="signature != null">
                 and signature = #{signature}
             </if>
+            <if test="accountId != null">
+                and account_id = #{accountId}
+            </if>
+
         </where>
         group by signature
 
@@ -364,9 +368,191 @@
             <if test="endDate != null">
                 and stat_date &lt;= #{endDate}
             </if>
+
+            <if test="accountId != null">
+                and account_id = #{accountId}
+            </if>
         </where>
         group by signature
     </select>
 
 
+    <select id="selectHourMaterialList" parameterType="Map" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        sum(t2.charge) cost, -- 花费
+        sum(t2.photo_show) photoShow, -- 封面曝光数
+        sum(t2.photo_click) photoClick, -- 封面点击数
+        sum(t2.aclick) aclick, -- 素材曝光数
+        sum(t2.bclick) bclick, -- 行为数
+        (case
+        when sum(photo_show) != 0
+        then (sum(t2.photo_click) / sum(photo_show))
+        else 0
+        end
+        ) photoClickRatio, -- 封面点击率
+
+        (case
+        when sum(aclick) != 0
+        then (sum(t2.bclick) / sum(aclick))
+        else 0
+        end
+        ) actionRatio, -- 行为率
+
+        (case
+        when sum(t2.photo_show) != 0
+        then ((sum(t2.charge) / sum(t2.photo_show)) * 1000)
+        else 0
+        end
+        ) impression1kCost, -- 均千次封面曝光花费
+
+        (case
+        when sum(t2.photo_click) != 0
+        then (sum(t2.charge) / sum(t2.photo_click))
+        else 0
+        end
+        ) photoClickCost, -- 平均封面点击单价
+
+        (CASE
+        WHEN sum(t2.photo_click) != 0
+        THEN (sum(t2.charge) / sum(t2.photo_click))
+        ELSE 0
+        end
+        ) actionCost, -- 平均行为单价
+
+        (case
+        WHEN sum(t2.form_count) != 0
+        THEN sum(t2.form_count)
+        WHEN sum(t2.activation) != 0
+        THEN sum(t2.activation)
+        ELSE 0
+        END
+        ) conversions, -- 转化数
+
+        (
+        CASE
+        WHEN sum(t2.form_count) != 0
+        THEN (sum(t2.charge) / sum(t2.form_count))
+        WHEN sum(t2.activation) != 0
+        THEN (sum(t2.charge) / sum(t2.activation))
+        ELSE 0
+        END
+        ) conversionPrice, -- 转化单价
+
+        t2.url url, -- 视频url
+        t2.signature signature, -- 视频md5
+        t2.account_id accountId
+        from
+        ctop_oauth_token t1
+        left join
+        ctop_kuaishou_report_hourly_creative_statistic t2
+        on t1.id = t2.account_id
+        where t1.id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        and t1.media_id = '2'
+        <if test="statHour != null">
+            and t2.stat_hour &lt;= #{statHour}
+        </if>
+        <if test="statDate != null">
+            and t2.stat_date = #{statDate}
+        </if>
+        and t2.signature != ''
+        GROUP BY t2.signature
+        order by sum(t2.charge) desc
+        limit 100
+    </select>
+
+
+    <select id="selectDayMaterialList" parameterType="Map" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        sum(t2.charge) cost, -- 花费
+        sum(t2.photo_show) photoShow, -- 封面曝光数
+        sum(t2.photo_click) photoClick, -- 封面点击数
+        sum(t2.aclick) aclick, -- 素材曝光数
+        sum(t2.bclick) bclick, -- 行为数
+        (case
+        when sum(photo_show) != 0
+        then (sum(t2.photo_click) / sum(photo_show))
+        else 0
+        end
+        ) photoClickRatio, -- 封面点击率
+
+        (case
+        when sum(aclick) != 0
+        then (sum(t2.bclick) / sum(aclick))
+        else 0
+        end
+        ) actionRatio, -- 行为率
+
+        (case
+        when sum(t2.photo_show) != 0
+        then ((sum(t2.charge) / sum(t2.photo_show)) * 1000)
+        else 0
+        end
+        ) impression1kCost, -- 均千次封面曝光花费
+
+        (case
+        when sum(t2.photo_click) != 0
+        then (sum(t2.charge) / sum(t2.photo_click))
+        else 0
+        end
+        ) photoClickCost, -- 平均封面点击单价
+
+        (CASE
+        WHEN sum(t2.photo_click) != 0
+        THEN (sum(t2.charge) / sum(t2.photo_click))
+        ELSE 0
+        end
+        ) actionCost, -- 平均行为单价
+
+        (case
+        WHEN sum(t2.form_count) != 0
+        THEN sum(t2.form_count)
+        WHEN sum(t2.activation) != 0
+        THEN sum(t2.activation)
+        ELSE 0
+        END
+        ) conversions, -- 转化数
+
+        (
+        CASE
+        WHEN sum(t2.form_count) != 0
+        THEN (sum(t2.charge) / sum(t2.form_count))
+        WHEN sum(t2.activation) != 0
+        THEN (sum(t2.charge) / sum(t2.activation))
+        ELSE 0
+        END
+        ) conversionPrice, -- 转化单价
+
+        t2.url url, -- 视频url
+        t2.signature signature, -- 视频md5
+        t2.account_id accountId
+        from
+        ctop_oauth_token t1
+        left join
+        ctop_kuaishou_report_daily_creative_statistic t2
+        on t1.id = t2.account_id
+        where t1.id in
+        <foreach item="item" index="index" collection="accountIds"
+                 open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        and t1.media_id = '2'
+
+        <if test="startDate != null">
+            and t2.stat_date &gt;= #{startDate}
+        </if>
+
+        <if test="endDate != null">
+            and t2.stat_date &lt;= #{endDate}
+        </if>
+        and t2.signature != ''
+        GROUP BY t2.signature
+        order by sum(t2.charge) desc
+        limit 100
+    </select>
+
+
 </mapper>

+ 17 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/IMaterialReportService.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.bytedance.service;
 
+import cn.com.ctop.common.module.entity.UserAllocation;
 import com.alibaba.fastjson.JSONObject;
 
 import java.util.List;
@@ -23,4 +24,20 @@ public interface IMaterialReportService {
      * @return
      */
     JSONObject getKuaiShouChainRatio(JSONObject json);
+
+    /**
+     * 查询账号accountId
+     *
+     * @param userId
+     * @return
+     */
+    List<UserAllocation> selectAccountIds(String userId);
+
+    /**
+     * 根据账号 查新素材报表
+     *
+     * @param json
+     * @return
+     */
+    List<JSONObject> selectReportByAccountIds(JSONObject json);
 }

+ 126 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/MaterialReportServiceImpl.java

@@ -2,8 +2,12 @@ package cn.com.ctop.bytedance.service.impl;
 
 import cn.com.ctop.bytedance.mapper.MaterialReportMapper;
 import cn.com.ctop.bytedance.service.IMaterialReportService;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.utils.Check;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,6 +25,9 @@ public class MaterialReportServiceImpl implements IMaterialReportService {
     @Autowired
     private MaterialReportMapper materialReportMapper;
 
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
+
     @Override
     public String getRoleCodeByUserId(String userId) {
         return materialReportMapper.getRoleCodeByUserId(userId);
@@ -142,10 +149,14 @@ public class MaterialReportServiceImpl implements IMaterialReportService {
                 return null;
             }
             Integer type = json.getInteger("type");
+            String accountId = json.getString("accountId");
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
             String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
             Map<String, Object> paramsMap = new HashMap<>();
             paramsMap.put("signature", signature);
+            if (!Check.isNull(accountId)) {
+                paramsMap.put("accountId", accountId);
+            }
             String beContrastDate = "";
             String contrastStartDate = "";
             String beContrastStartDate = "";
@@ -430,4 +441,119 @@ public class MaterialReportServiceImpl implements IMaterialReportService {
     }
 
 
+    /**
+     * 查询 所有绑定账号
+     *
+     * @param userId
+     * @return
+     */
+
+
+    @Override
+    public List<UserAllocation> selectAccountIds(String userId) {
+        String roleCode = materialReportMapper.getRoleCodeByUserId(userId);
+        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("media_id", 2);
+        if ("operator".equals(roleCode)) {
+            queryWrapper.eq("userId", userId);
+        }
+        queryWrapper.isNotNull("account_id");
+        queryWrapper.groupBy("account_id");
+        queryWrapper.orderByAsc("advertiser_name");
+
+        List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
+        return userAllocations;
+    }
+
+    /**
+     * 根据账号 查询素材报表
+     *
+     * @param json
+     * @return
+     */
+    @Override
+    public List<JSONObject> selectReportByAccountIds(JSONObject json) {
+
+
+        long startTime = System.currentTimeMillis();
+
+        List<JSONObject> marketJsonList = new ArrayList<>();
+        try {
+            if (Check.isNull(json)) {
+                return marketJsonList;
+            }
+
+            JSONArray accountIds = json.getJSONArray("accountIds");
+            if (Check.isNull(accountIds)) {
+                return marketJsonList;
+            }
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+            Integer type = json.getInteger("type");
+
+            Map<String, Object> paramsMap = new HashMap<>();
+            paramsMap.put("accountIds", accountIds);
+            if (type == 1) { // 今天分时数据
+                Integer maxHour = materialReportMapper.selectMaxHourByDate(nowDate);
+                if (Check.isNull(maxHour) || maxHour == 0) {
+                    return marketJsonList;
+                }
+                Integer statHour = maxHour - 1;
+                paramsMap.put("statHour", statHour);
+                paramsMap.put("statDate", nowDate);
+                marketJsonList = materialReportMapper.selectHourMaterialList(paramsMap);
+
+            } else if (type == 2) {
+                paramsMap.put("startDate", anotherDay);
+                paramsMap.put("endDate", anotherDay);
+                marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
+
+            } else if (type == 3) {
+                String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
+                paramsMap.put("startDate", startDate);
+                paramsMap.put("endDate", anotherDay);
+                marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
+
+            } else if (type == 4) {
+                String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
+                paramsMap.put("startDate", startDate);
+                paramsMap.put("endDate", anotherDay);
+                marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
+
+            } else if (type == 5) {// 近一个月
+                String startDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
+                paramsMap.put("startDate", startDate);
+                paramsMap.put("endDate", anotherDay);
+                marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
+
+            } else if (type == 6) {// 近三个月
+                String startDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -3);
+                paramsMap.put("startDate", startDate);
+                paramsMap.put("endDate", anotherDay);
+                marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
+
+            } else if (type == 7) {// 近六个月
+                String startDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -6);
+                paramsMap.put("startDate", startDate);
+                paramsMap.put("endDate", anotherDay);
+                marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
+
+            } else if (type == 9) {  // 自定义查询日期
+                String startDate = json.getString("startDate");
+                String endDate = json.getString("endDate");
+                paramsMap.put("startDate", startDate);
+                paramsMap.put("endDate", endDate);
+                marketJsonList = materialReportMapper.selectDayMaterialList(paramsMap);
+
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        log.info("账户维度素材数据请求所用时长------------->: {} ms", System.currentTimeMillis() - startTime);
+        return marketJsonList;
+    }
+
+
 }