Przeglądaj źródła

Merge remote-tracking branch 'origin/test' into test2

xuzuoyun 5 lat temu
rodzic
commit
45b403e5c1
66 zmienionych plików z 2453 dodań i 801 usunięć
  1. 114 0
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  2. 6 6
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  3. 14 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BindAccountLoginController.java
  4. 11 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ByteDanceAdvertiserPostController.java
  5. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/ICreateInternalService.java
  6. 57 39
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CreateInternalServiceImpl.java
  7. 4 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/controller/FileController.java
  8. 27 35
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/industry/controller/IndustryController.java
  9. 18 18
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/media/controller/MediaController.java
  10. 31 31
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysCategoryServiceImpl.java
  11. 0 1
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  12. 2 1
      module-common/src/main/java/cn/com/ctop/common/module/entity/BindAccountAuth.java
  13. 2 1
      module-common/src/main/java/cn/com/ctop/common/module/entity/BindAccountLogin.java
  14. 0 1
      module-common/src/main/java/cn/com/ctop/common/module/entity/HttpClientEntity.java
  15. 2 1
      module-common/src/main/java/cn/com/ctop/common/module/entity/SourceFile.java
  16. 2 1
      module-common/src/main/java/cn/com/ctop/common/module/entity/UserAllocation.java
  17. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/mapper/BindAccountAuthMapper.java
  18. 1 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml
  19. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/service/IFileInfoService.java
  20. 17 4
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  21. 1 4
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/FileInfoServiceImpl.java
  22. 2 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/Base64Utils.java
  23. 6 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/HttpGetWithBodyEntity.java
  24. 0 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/ImageUtils.java
  25. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/OSSUtils.java
  26. 248 0
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/controller/MaterialInfoController.java
  27. 63 0
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/entity/MaterialInfo.java
  28. 15 0
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/mapper/MaterialInfoMapper.java
  29. 5 0
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/mapper/xml/MaterialInfoMapper.xml
  30. 21 0
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/IMaterialInfoService.java
  31. 62 0
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialInfoServiceImpl.java
  32. 33 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java
  33. 0 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCreateAppTemplate.java
  34. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouGroupBidMapper.java
  35. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupBidServiceImpl.java
  36. 33 17
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  37. 9 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAccount.java
  38. 5 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCampaign.java
  39. 8 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCreative.java
  40. 9 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyGroup.java
  41. 8 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyAccount.java
  42. 10 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyCampaign.java
  43. 5 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyCreative.java
  44. 5 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyGroup.java
  45. 26 4
      module-report/src/main/java/cn/com/ctop/bytedance/controller/BytedanceReportController.java
  46. 2 1
      module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceAdvertiserHourlyReport.java
  47. 110 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/ReportMapper.java
  48. 165 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/ReportMapper.xml
  49. 20 1
      module-report/src/main/java/cn/com/ctop/bytedance/service/IBytedanceReportService.java
  50. 429 26
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceReportServiceImpl.java
  51. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/controller/ByteDanceBudgetTemplateController.java
  52. 175 110
      module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceAdvertisePlan.java
  53. 213 160
      module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceAdvertiser.java
  54. 29 20
      module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceAdvertiserBudget.java
  55. 2 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceBudgetTemplate.java
  56. 135 110
      module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceCampaign.java
  57. 2 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceCampaignTemplate.java
  58. 105 69
      module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceCreative.java
  59. 63 43
      module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceCreativeMaterial.java
  60. 2 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceUserOrientationTemplate.java
  61. 2 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/BytedanceAdvertisePlanTemplate.java
  62. 4 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/service/IByteDanceAdvertiserDataService.java
  63. 36 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertisePlanServiceImpl.java
  64. 68 16
      module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertiserDataServiceImpl.java
  65. 1 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceCampaignTemplateServiceImpl.java
  66. 1 6
      pom.xml

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

@@ -751,4 +751,118 @@ public class DateUtils extends PropertyEditorSupport {
     }
 
 
+    /**
+     * @param format 返回日期格式
+     * @param date   传入的初始日期
+     * @param num    天数
+     * @return
+     * @throws ParseException
+     */
+    public static String getAnotherDay(String format, String date, Integer num) throws ParseException {
+
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+        Date date_ = sdf.parse(date);// 将字符串转化为时间格式
+        Calendar calendar = Calendar.getInstance(); // 得到日历
+        calendar.setTime(date_);// 把开始日期赋给日历
+        calendar.add(Calendar.DAY_OF_MONTH, num); // 设置为num天
+        Date resultDate = calendar.getTime(); // 得到时间
+        return sdf.format(resultDate);
+    }
+
+
+    public static String getNowDate(String format) {
+
+        SimpleDateFormat sdf = new SimpleDateFormat(format);
+
+        Date date = new Date();
+
+        return sdf.format(date);
+    }
+
+
+    public static String getMonthBefore(String format, String nowTime, int amount) throws ParseException {
+        // 获取当前时间
+        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
+        Date date = dateFormat.parse(nowTime);
+
+        Calendar calendar = Calendar.getInstance(); //得到日历
+        calendar.setTime(date);//把当前时间赋给日历
+        calendar.add(calendar.MONTH, amount); //设置为前2月,可根据需求进行修改
+        date = calendar.getTime();//获取2个月前的时间
+
+        return dateFormat.format(date);
+    }
+
+    public static Map<String, Object> compare_date(String format, String DATE1, String DATE2) {
+
+
+        DateFormat df = new SimpleDateFormat(format);
+        Map<String, Object> map = new HashMap<>();
+        try {
+            Date dt1 = df.parse(DATE1);
+            Date dt2 = df.parse(DATE2);
+            if (dt1.getTime() > dt2.getTime()) {
+                map.put("bigDate", DATE1);
+                map.put("smallDate", DATE2);
+                return map;
+            } else if (dt1.getTime() < dt2.getTime()) {
+                map.put("bigDate", DATE2);
+                map.put("smallDate", DATE1);
+                return map;
+            }
+        } catch (Exception exception) {
+            exception.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 日期中获取年份
+     *
+     * @param format
+     * @param date
+     * @return
+     * @throws ParseException
+     */
+    public static String getYear(String format, String date) throws ParseException {
+
+        SimpleDateFormat df = new SimpleDateFormat(format);
+        Date parse = df.parse(date);
+        return String.format("%tY", parse);
+
+    }
+
+    /**
+     * 日期中获取月份
+     *
+     * @param format
+     * @param date
+     * @return
+     * @throws ParseException
+     */
+    public static String getMonth(String format, String date) throws ParseException {
+
+        SimpleDateFormat df = new SimpleDateFormat(format);
+        Date parse = df.parse(date);
+        return String.format("%tm", parse);
+
+    }
+
+    /**
+     * 日期中获取天
+     *
+     * @param format
+     * @param date
+     * @return
+     * @throws ParseException
+     */
+    public static String getDay(String format, String date) throws ParseException {
+
+        SimpleDateFormat df = new SimpleDateFormat(format);
+        Date parse = df.parse(date);
+        return String.format("%td", parse);
+
+    }
+
+
 }

+ 6 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -1,11 +1,5 @@
 package org.jeecg.config;
 
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import javax.servlet.Filter;
-
 import org.apache.shiro.mgt.DefaultSessionStorageEvaluator;
 import org.apache.shiro.mgt.DefaultSubjectDAO;
 import org.apache.shiro.mgt.SecurityManager;
@@ -20,6 +14,11 @@ import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.DependsOn;
 
+import javax.servlet.Filter;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
 /**
  * @author: Scott
  * @date: 2018/2/7
@@ -91,6 +90,7 @@ public class ShiroConfig {
 		filterChainDefinitionMap.put("/webjars/**", "anon");
 		filterChainDefinitionMap.put("/v2/**", "anon");
         filterChainDefinitionMap.put("/kuaishou", "anon");
+        filterChainDefinitionMap.put("/kuaishou/report", "anon");
 		filterChainDefinitionMap.put("/ctop/bindAccount/**", "anon");
 		filterChainDefinitionMap.put("/**/*.mp4", "anon");
         filterChainDefinitionMap.put("/bytedance", "anon");

+ 14 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BindAccountLoginController.java

@@ -39,6 +39,7 @@ import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -63,7 +64,6 @@ public class BindAccountLoginController {
     private ICreateInternalService createInternalService;
 
     /**
-     *
      * @param json
      * @return
      */
@@ -72,8 +72,8 @@ public class BindAccountLoginController {
         Result<IPage<BindAccountLogin>> result = new Result<>();
         String advertiserId = json.getString("advertiserId");
         if (Check.isNull(advertiserId)) {
-            System.err.println("advertiserId不能为空");
             result.setSuccess(false);
+            result.setMessage("广告主id为空");
             return result;
         }
         //创建人
@@ -84,8 +84,17 @@ public class BindAccountLoginController {
         String advertiserName = json.getString("advertiser_name");
         //账号
         String accountName = json.getString("accountName");
-        boolean trueOrFalse = createInternalService.bindLogin(advertiserId, accountName, password, loginType, userId, advertiserName);
+        Map<String, Object> stringObjectMap = createInternalService.bindLogin(advertiserId, accountName, password, loginType, userId, advertiserName);
+        Boolean trueOrFalse = (Boolean) stringObjectMap.get("success");
         if (trueOrFalse) {
+            Map<String, Object> deleteMap = new HashMap<>();
+            deleteMap.put("account_name", accountName);
+            deleteMap.put("user_id", userId);
+            deleteMap.put("advertiser_id", advertiserId);
+            userAllocationMapper.deleteByMap(deleteMap);
+
+            Long accountId = (Long) stringObjectMap.get("accountId");
+
             String realName = json.getString("realName");
             //部门id
             String departmentId = json.getString("departmentId");
@@ -97,6 +106,7 @@ public class BindAccountLoginController {
             userAllocation.setDistributionName(distributionName);
             userAllocation.setUserId(userId);
             userAllocation.setAdvertiserId(advertiserId);
+            userAllocation.setAccountId(accountId);
             userAllocation.setDepartmentId(departmentId);
             userAllocation.setAdvertiserName(advertiserName);
             userAllocation.setAccountName(accountName);
@@ -109,6 +119,7 @@ public class BindAccountLoginController {
         }
 
         result.setSuccess(trueOrFalse);
+        result.setMessage((String) stringObjectMap.get("message"));
         return result;
     }
 

+ 11 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ByteDanceAdvertiserPostController.java

@@ -15,10 +15,7 @@ import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.system.entity.SysDictItem;
 import org.jeecg.modules.system.service.ISysDictItemService;
 import org.springframework.beans.factory.annotation.Autowired;
-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.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.Map;
@@ -116,6 +113,16 @@ public class ByteDanceAdvertiserPostController {
     }
 
     /**
+     * 7:获取广告主广告组信息
+     *
+     * @param accountId 本平台广告主id
+     */
+    @GetMapping("/advertiser/campaign/list")
+    public Map<String, Object> advertiserCampaignList(String accountId) {
+        return advertiserDataService.getAdvertiserCampaignList(accountId);
+    }
+
+    /**
      * 8:获取广告主广告创意信息
      * @param accountId 本平台广告主id
      */

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/ICreateInternalService.java

@@ -9,5 +9,5 @@ public interface ICreateInternalService {
 
     Map<String, Object> checkAccountPassword(String account, String password);
 
-     boolean bindLogin(String advertiserId, String accountName, String password, String loginType, String userId,String advertiserName);
+    Map<String, Object> bindLogin(String advertiserId, String accountName, String password, String loginType, String userId, String advertiserName);
 }

+ 57 - 39
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CreateInternalServiceImpl.java

@@ -54,14 +54,25 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
     private BytedanceUrlInfoMapper urlInfoMapper;
 
     @Override
-    public boolean bindLogin(String advertiserId, String accountName, String password, String loginType, String userId, String advertiserName) {
+    public Map<String, Object> bindLogin(String advertiserId, String accountName, String password, String loginType, String userId, String advertiserName) {
+
+        Map<String, Object> returnMap = new HashMap<>();
         Map<String, Object> requestMap = new HashMap<>();
         requestMap.put("advertiser_id", advertiserId);
         requestMap.put("account_name", accountName);
         requestMap.put("login_type", loginType);
+        requestMap.put("user_id", userId);
+        Map<String, Object> deleteMap = new HashMap<>();
+        deleteMap.put("advertiser_id", advertiserId);
+        deleteMap.put("account_name", accountName);
+        deleteMap.put("login_type", loginType);
+        deleteMap.put("user_id", userId);
+        bindAccountLoginMapper.deleteByMap(deleteMap);
         List<BindAccountLogin> bindAccounts = bindAccountLoginMapper.selectByMap(requestMap);
         if (!Check.isNull(bindAccounts)) {
-            return false;
+            returnMap.put("success", false);
+            returnMap.put("message", "账号已存在");
+            return returnMap;
         }
         String accountId = "";
         //头条登录
@@ -69,7 +80,9 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
             Map<String, Object> result = this.checkAccountPassword(accountName, password);
             Boolean checkSuccess = (Boolean) result.get("success");
             if (!checkSuccess) {
-                return false;
+                returnMap.put("success", false);
+                returnMap.put("message", "账号验证失败");
+                return returnMap;
             }
             accountId = (String) result.get("id");
         }
@@ -79,14 +92,15 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
         bindAccountLogin.setPassword(password);
         bindAccountLogin.setAccountId(accountId);
         bindAccountLogin.setLoginType(loginType);
-        bindAccountLogin.setAccountName(advertiserName);
         bindAccountLogin.setUserId(userId);
         int i = bindAccountLoginMapper.insert(bindAccountLogin);
         if (i > 0) {
             log.info("登录账号绑定成功,广告主id:{}", bindAccountLogin.getAdvertiserId());
-            return true;
+            returnMap.put("success", true);
+            returnMap.put("accountUd", password);
+            return returnMap;
         }
-        return false;
+        return returnMap;
     }
 
     @Override
@@ -197,6 +211,7 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
         //1:获取用户名密码
         Long accountId = requestJson.getLong("accountId");
         Long userOrientationId = requestJson.getLong("userOrientationId");
+        String campaignId = requestJson.getString("campaignId");
         BindAccountLogin bindAccountLogin = bindAccountLoginService.selectByAccountId(accountId + "");
         if (null == bindAccountLogin) {
             ResultMapUtils.setResultMap(resultMap, StatusCode.ACCOUNT_HAS_NOT_EXIST.getCode());
@@ -288,49 +303,52 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 //登录成功 进入推广页面
                 webDriver.get("https://ad.oceanengine.com/pages/promotion.html#/ad");
                 Thread.sleep(3000);
-                //创建广告组页面
-                webDriver.get("https://ad.oceanengine.com/pages/campaign/create.html");
                 String templateName = requestJson.getString("templateName");
-                Map<String, Object> campaignParam = new HashMap<>();
                 String uuid = UUID.randomUUID().toString();
-                campaignParam.put("campaign_id", "");
-                campaignParam.put("campaign_name", templateName + "-广告组-" + uuid.substring(1, 7));
-                campaignParam.put("landing_type", 3);
-                campaignParam.put("campaign_type", 1);
-                Map<String, Object> budgetMap = new HashMap<>();
-                budgetMap.put("budget", 0);
-                budgetMap.put("budget_mode", -1);
-                campaignParam.put("budget", budgetMap);
-                for (Cookie cookie : webDriver.manage().getCookies()) {
-                    if ("csrftoken".equals(cookie.getName())) {
-                        csrftoken = cookie.getValue();
+                if (null == campaignId || campaignId.equals("")) {
+                    //创建广告组页面
+                    webDriver.get("https://ad.oceanengine.com/pages/campaign/create.html");
+                    Map<String, Object> campaignParam = new HashMap<>();
+                    campaignParam.put("campaign_id", "");
+                    campaignParam.put("campaign_name", templateName + "-广告组-" + uuid.substring(1, 7));
+                    campaignParam.put("landing_type", 3);
+                    campaignParam.put("campaign_type", 1);
+                    Map<String, Object> budgetMap = new HashMap<>();
+                    budgetMap.put("budget", 0);
+                    budgetMap.put("budget_mode", -1);
+                    campaignParam.put("budget", budgetMap);
+                    for (Cookie cookie : webDriver.manage().getCookies()) {
+                        if ("csrftoken".equals(cookie.getName())) {
+                            csrftoken = cookie.getValue();
+                        }
+                        BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
+                        ck.setDomain("ad.oceanengine.com");
+                        ck.setExpiryDate(cookie.getExpiry());
+                        ck.setPath(cookie.getPath());
+                        HttpUtils2.cookieStore.addCookie(ck);
                     }
-                    BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
-                    ck.setDomain("ad.oceanengine.com");
-                    ck.setExpiryDate(cookie.getExpiry());
-                    ck.setPath(cookie.getPath());
-                    HttpUtils2.cookieStore.addCookie(ck);
+
+                    header.put("Accept", "application/json, text/javascript, */*; q=0.01");
+                    header.put("Connection", "keep-alive");
+                    header.put("Host", "ad.oceanengine.com");
+                    header.put("Content-Type", "application/json");
+                    header.put("Origin", "https://ad.oceanengine.com");
+                    header.put("X-CSRFToken", csrftoken);
+                    header.put("X-Requested-With", "XMLHttpRequest");
+                    header.put("Referer", "https://ad.oceanengine.com/pages/campaign/create.html");
+                    // 创建广告组返回信息
+                    res = HttpUtils2.httpPostRequest("https://ad.oceanengine.com/overture/campaign/create/", campaignParam, header);
+                    JsonNode node = mapper.readTree(res);
+                    campaignId = node.get("data").get("campaign_id").asText();
+                    System.out.println(res);
                 }
 
-                header.put("Accept", "application/json, text/javascript, */*; q=0.01");
-                header.put("Connection", "keep-alive");
-                header.put("Host", "ad.oceanengine.com");
-                header.put("Content-Type", "application/json");
-                header.put("Origin", "https://ad.oceanengine.com");
-                header.put("X-CSRFToken", csrftoken);
-                header.put("X-Requested-With", "XMLHttpRequest");
-                header.put("Referer", "https://ad.oceanengine.com/pages/campaign/create.html");
-                // 创建广告组返回信息
-                res = HttpUtils2.httpPostRequest("https://ad.oceanengine.com/overture/campaign/create/", campaignParam, header);
-                System.out.println(res);
                 Integer itratorNum = requestJson.getInteger("itratorNum");
                 JSONObject data = new JSONObject();
                 if (null != itratorNum && itratorNum > 0) {
                     //循环创建广告计划
                     for (int i = 0; i < itratorNum; i++) {
-                        JsonNode node = mapper.readTree(res);
                         //广告组id
-                        String campaignId = node.get("data").get("campaign_id").asText();
                         String url2 = "https://ad.oceanengine.com/pages/ad/create.html?campaign_id=" + campaignId + "&landing_type=3&temp_id=ADvQb";
                         webDriver.get(url2);
                         header.put("Referer", url2);
@@ -474,7 +492,7 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                             //获取modify_time
                             Thread.sleep(5000L);
                             advertiserDataService.getAdvertiserPlan(bindAccountLogin.getAccountId(), adId + "");
-                            advertiserDataService.updateAd(token, adId, template);
+                            advertiserDataService.updateAd(token, adId, template, requestJson);
                         }
                         Long creativeTemplateId = requestJson.getLong("creativeTemplateId");
 

+ 4 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/controller/FileController.java

@@ -1,6 +1,6 @@
 package org.jeecg.modules.fileupload.controller;
 
-import cn.com.ctop.common.module.service.IFileInfoService;
+import cn.com.ctop.manage.modules.material.service.IMaterialInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -14,17 +14,16 @@ import java.util.Map;
  */
 @RestController
 public class FileController {
-
     @Autowired
-    private IFileInfoService fileInfoService;
+    private IMaterialInfoService materialInfoService;
 
     @RequestMapping("file/check")
     public Map<String, Object> chenckFile(String code) {
-        return fileInfoService.checkFile(code);
+        return materialInfoService.checkMaterialInfo(code);
     }
 
     @PostMapping("file/insert")
     public Map<String, Object> insertFile(String code, String url) {
-        return fileInfoService.insertFile(code, url);
+        return materialInfoService.insert(code, url);
     }
 }

+ 27 - 35
jeecg-boot-module-system/src/main/java/org/jeecg/modules/industry/controller/IndustryController.java

@@ -1,38 +1,34 @@
 package org.jeecg.modules.industry.controller;
 
-import java.util.*;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+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.aspect.annotation.AutoLog;
+import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.industry.entity.Industry;
 import org.jeecg.modules.industry.model.IndustryTree;
 import org.jeecg.modules.industry.service.IIndustryService;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import lombok.extern.slf4j.Slf4j;
-
-import org.jeecg.modules.system.model.TreeModel;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
 import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
-
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
-import com.alibaba.fastjson.JSON;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
+
+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.*;
 
  /**
  * @Description: 行业表
@@ -74,16 +70,18 @@ public class IndustryController {
 		 // 全部权限ids
 		 List<String> ids = new ArrayList<>();
 		 try {
-
 			 List<Industry> list = industryService.list();
 			 List<IndustryTree> treeList = new ArrayList<IndustryTree>();
 			 for (Industry industry : list) {
 				 ids.add(industry.getId());
 			 }
 			 getTreeList(treeList,list,null);
-			 Map<String, Object> resMap = new HashMap<String, Object>();
-			 resMap.put("treeList", treeList); // 全部树节点数据
-			 resMap.put("ids", ids);// 全部树ids
+
+			 Map<String, Object> resMap = new HashMap<>();
+			 // 全部树节点数据
+			 resMap.put("treeList", treeList);
+			 // 全部树ids
+			 resMap.put("ids", ids);
 			 result.setResult(resMap);
 			 result.setSuccess(true);
 		 } catch (Exception e) {
@@ -100,13 +98,11 @@ public class IndustryController {
 			 if (temp == null && oConvertUtils.isEmpty(tempPid)) {
 				 treeList.add(tree);
 				 getTreeList(treeList,metaList,tree);
-
 			 } else if (temp != null && tempPid != null && tempPid.equals(temp.getId())) {
 			 	if(temp.getChildren() == null){
 					temp.setChildren(new ArrayList<IndustryTree>());
 				}
 				 temp.getChildren().add(tree);
-
 			 }
 
 		 }
@@ -121,7 +117,7 @@ public class IndustryController {
 	@ApiOperation(value="行业表-添加", notes="行业表-添加")
 	@PostMapping(value = "/add")
 	public Result<Industry> add(@RequestBody Industry industry) {
-		Result<Industry> result = new Result<Industry>();
+		Result<Industry> result = new Result<>();
 		try {
 			industryService.save(industry);
 			result.success("添加成功!");
@@ -141,18 +137,16 @@ public class IndustryController {
 	@ApiOperation(value="行业表-编辑", notes="行业表-编辑")
 	@PutMapping(value = "/edit")
 	public Result<Industry> edit(@RequestBody Industry industry) {
-		Result<Industry> result = new Result<Industry>();
+		Result<Industry> result = new Result<>();
 		Industry industryEntity = industryService.getById(industry.getId());
 		if(industryEntity==null) {
 			result.error500("未找到对应实体");
 		}else {
 			boolean ok = industryService.updateById(industry);
-			//TODO 返回false说明什么?
 			if(ok) {
 				result.success("修改成功!");
 			}
 		}
-
         return result;
 	}
 
@@ -165,7 +159,7 @@ public class IndustryController {
 	@ApiOperation(value="行业表-通过id删除", notes="行业表-通过id删除")
 	@DeleteMapping(value = "/delete")
 	public Result<Industry> delete(@RequestParam(name="id",required=true) String id) {
-		Result<Industry> result = new Result<Industry>();
+		Result<Industry> result = new Result<>();
 		Industry industry = industryService.getById(id);
 		if(industry==null) {
 			result.error500("未找到对应实体");
@@ -175,7 +169,6 @@ public class IndustryController {
 				result.success("删除成功!");
 			}
 		}
-
         return result;
 	}
 
@@ -188,7 +181,7 @@ public class IndustryController {
 	@ApiOperation(value="行业表-批量删除", notes="行业表-批量删除")
 	@DeleteMapping(value = "/deleteBatch")
 	public Result<Industry> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
-		Result<Industry> result = new Result<Industry>();
+		Result<Industry> result = new Result<>();
 		if(ids==null || "".equals(ids.trim())) {
 			result.error500("参数不识别!");
 		}else {
@@ -207,7 +200,7 @@ public class IndustryController {
 	@ApiOperation(value="行业表-通过id查询", notes="行业表-通过id查询")
 	@GetMapping(value = "/queryById")
 	public Result<Industry> queryById(@RequestParam(name="id",required=true) String id) {
-		Result<Industry> result = new Result<Industry>();
+		Result<Industry> result = new Result<>();
 		Industry industry = industryService.getById(id);
 		if(industry==null) {
 			result.error500("未找到对应实体");
@@ -238,7 +231,6 @@ public class IndustryController {
       } catch (UnsupportedEncodingException e) {
           e.printStackTrace();
       }
-
       //Step.2 AutoPoi 导出Excel
       ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
       List<Industry> pageList = industryService.list(queryWrapper);
@@ -262,8 +254,9 @@ public class IndustryController {
       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();
+          MultipartFile file = entity.getValue();
+
+		  ImportParams params = new ImportParams();
           params.setTitleRows(2);
           params.setHeadRows(1);
           params.setNeedSave(true);
@@ -286,5 +279,4 @@ public class IndustryController {
       }
       return Result.ok("文件导入失败!");
   }
-
 }

+ 18 - 18
jeecg-boot-module-system/src/main/java/org/jeecg/modules/media/controller/MediaController.java

@@ -46,7 +46,7 @@ import java.util.Map;
 public class MediaController {
 	@Autowired
 	private IMediaService mediaService;
-	
+
 	/**
 	  * 分页列表查询
 	 * @param media
@@ -62,15 +62,15 @@ public class MediaController {
 									  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
 									  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
 									  HttpServletRequest req) {
-		Result<IPage<Media>> result = new Result<IPage<Media>>();
+		Result<IPage<Media>> result = new Result<>();
 		QueryWrapper<Media> queryWrapper = QueryGenerator.initQueryWrapper(media, req.getParameterMap());
-		Page<Media> page = new Page<Media>(pageNo, pageSize);
+		Page<Media> page = new Page<>(pageNo, pageSize);
 		IPage<Media> pageList = mediaService.page(page, queryWrapper);
 		result.setSuccess(true);
 		result.setResult(pageList);
 		return result;
 	}
-	
+
 	/**
 	  *   添加
 	 * @param media
@@ -80,7 +80,7 @@ public class MediaController {
 	@ApiOperation(value="媒体表-添加", notes="媒体表-添加")
 	@PostMapping(value = "/add")
 	public Result<Media> add(@RequestBody Media media) {
-		Result<Media> result = new Result<Media>();
+		Result<Media> result = new Result<>();
 		try {
 			mediaService.save(media);
 			result.success("添加成功!");
@@ -90,7 +90,7 @@ public class MediaController {
 		}
 		return result;
 	}
-	
+
 	/**
 	  *  编辑
 	 * @param media
@@ -100,7 +100,7 @@ public class MediaController {
 	@ApiOperation(value="媒体表-编辑", notes="媒体表-编辑")
 	@PutMapping(value = "/edit")
 	public Result<Media> edit(@RequestBody Media media) {
-		Result<Media> result = new Result<Media>();
+		Result<Media> result = new Result<>();
 		Media mediaEntity = mediaService.getById(media.getId());
 		if(mediaEntity==null) {
 			result.error500("未找到对应实体");
@@ -111,11 +111,11 @@ public class MediaController {
 				result.success("修改成功!");
 			}
 		}
-		
+
 		return result;
 	}
-	
-	/**
+
+	 /**
 	  *   通过id删除
 	 * @param id
 	 * @return
@@ -124,7 +124,7 @@ public class MediaController {
 	@ApiOperation(value="媒体表-通过id删除", notes="媒体表-通过id删除")
 	@DeleteMapping(value = "/delete")
 	public Result<Media> delete(@RequestParam(name="id",required=true) String id) {
-		Result<Media> result = new Result<Media>();
+		Result<Media> result = new Result<>();
 		Media media = mediaService.getById(id);
 		if(media==null) {
 			result.error500("未找到对应实体");
@@ -134,11 +134,11 @@ public class MediaController {
 				result.success("删除成功!");
 			}
 		}
-		
+
 		return result;
 	}
-	
-	/**
+
+	 /**
 	  *  批量删除
 	 * @param ids
 	 * @return
@@ -147,7 +147,7 @@ public class MediaController {
 	@ApiOperation(value="媒体表-批量删除", notes="媒体表-批量删除")
 	@DeleteMapping(value = "/deleteBatch")
 	public Result<Media> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
-		Result<Media> result = new Result<Media>();
+		Result<Media> result = new Result<>();
 		if(ids==null || "".equals(ids.trim())) {
 			result.error500("参数不识别!");
 		}else {
@@ -156,8 +156,8 @@ public class MediaController {
 		}
 		return result;
 	}
-	
-	/**
+
+	 /**
 	  * 通过id查询
 	 * @param id
 	 * @return
@@ -166,7 +166,7 @@ public class MediaController {
 	@ApiOperation(value="媒体表-通过id查询", notes="媒体表-通过id查询")
 	@GetMapping(value = "/queryById")
 	public Result<Media> queryById(@RequestParam(name="id",required=true) String id) {
-		Result<Media> result = new Result<Media>();
+		Result<Media> result = new Result<>();
 		Media media = mediaService.getById(id);
 		if(media==null) {
 			result.error500("未找到对应实体");

+ 31 - 31
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysCategoryServiceImpl.java

@@ -65,37 +65,37 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
         return pageList.getRecords();
     }
 
-	@Override
-	public JSONArray getByteDanceIndustryList() {
-		JSONArray result = new JSONArray();
-		String pid = "6c6b0ad4f49b65f3943528e8a35d74fc";
-		List<SysCategory> categories = this.getListByPid(pid);
-		for (SysCategory category : categories) {
-			JSONObject object = new JSONObject();
-			object.put("value", category.getCode());
-			object.put("label", category.getName());
-			JSONArray childListArray = new JSONArray();
-			List<SysCategory> childList = this.getListByPid(category.getId());
-			for (SysCategory child : childList) {
-				JSONObject childObject = new JSONObject();
-				childObject.put("value", child.getCode());
-				childObject.put("label", child.getName());
-				JSONArray secendChildListArray = new JSONArray();
-				List<SysCategory> secendChildList = this.getListByPid(child.getId());
-				for (SysCategory secendChild : secendChildList) {
-					JSONObject secendChildObject = new JSONObject();
-					secendChildObject.put("value", secendChild.getCode());
-					secendChildObject.put("label", secendChild.getName());
-					secendChildListArray.add(secendChildObject);
-				}
-				childObject.put("children", secendChildListArray);
-				childListArray.add(childObject);
-			}
-			object.put("children", childListArray);
-			result.add(object);
-		}
-		return result;
-	}
+    @Override
+    public JSONArray getByteDanceIndustryList() {
+        JSONArray result = new JSONArray();
+        String pid = "6c6b0ad4f49b65f3943528e8a35d74fc";
+        List<SysCategory> categories = this.getListByPid(pid);
+        for (SysCategory category : categories) {
+            JSONObject object = new JSONObject();
+            object.put("value", category.getCode());
+            object.put("label", category.getName());
+            JSONArray childListArray = new JSONArray();
+            List<SysCategory> childList = this.getListByPid(category.getId());
+            for (SysCategory child : childList) {
+                JSONObject childObject = new JSONObject();
+                childObject.put("value", child.getCode());
+                childObject.put("label", child.getName());
+                JSONArray secendChildListArray = new JSONArray();
+                List<SysCategory> secendChildList = this.getListByPid(child.getId());
+                for (SysCategory secendChild : secendChildList) {
+                    JSONObject secendChildObject = new JSONObject();
+                    secendChildObject.put("value", secendChild.getCode());
+                    secendChildObject.put("label", secendChild.getName());
+                    secendChildListArray.add(secendChildObject);
+                }
+                childObject.put("children", secendChildListArray);
+                childListArray.add(childObject);
+            }
+            object.put("children", childListArray);
+            result.add(object);
+        }
+        return result;
+    }
 
 	@Override
 	public List<TreeSelectModel> queryListByCode(String pcode) throws JeecgBootException{

+ 0 - 1
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -131,7 +131,6 @@ public class SampleTest {
                 //获取modify_time
                 Thread.sleep(5000L);
                 advertiserDataService.getAdvertiserPlan(accountId, adId + "");
-                advertiserDataService.updateAd(token, adId, template);
             }
         }
     }

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

@@ -16,9 +16,10 @@ import java.util.Date;
 
 /**
  * 账号绑定-授权
+ *
  * @author jeecg-boot
- * @date 2019-07-31
  * @version V1.0
+ * @date 2019-07-31
  */
 @Data
 @TableName("ctop_bind_account_auth")

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

@@ -16,9 +16,10 @@ import java.util.Date;
 
 /**
  * 账号绑定-登陆
+ *
  * @author jeecg-boot
- * @date 2019-07-31
  * @version V1.0
+ * @date 2019-07-31
  */
 @Data
 @TableName("ctop_bind_account_login")

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

@@ -1,6 +1,5 @@
 package cn.com.ctop.common.module.entity;
 
-import cn.com.ctop.common.module.utils.HttpClientUtils;
 import lombok.Data;
 import org.apache.http.client.CookieStore;
 import org.apache.http.impl.client.CloseableHttpClient;

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

@@ -14,9 +14,10 @@ import java.util.Date;
 
 /**
  * 统一资源库文件信息
+ *
  * @author jeecg-boot
- * @date 2019-09-02
  * @version V1.0
+ * @date 2019-09-02
  */
 @Data
 @TableName("ctop_source_file")

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

@@ -16,9 +16,10 @@ import java.util.Date;
 
 /**
  * 用户分配
+ *
  * @author jeecg-boot
- * @date 2019-08-08
  * @version V1.0
+ * @date 2019-08-08
  */
 @Data
 @TableName("ctop_user_allocation")

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/mapper/BindAccountAuthMapper.java

@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 /**
  * @Description: 账号绑定-授权
  * @Author: jeecg-boot
- * @Date:   2019-07-31
+ * @Date: 2019-07-31
  * @Version: V1.0
  */
 public interface BindAccountAuthMapper extends BaseMapper<BindAccountAuth> {

+ 1 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml

@@ -23,6 +23,7 @@
         select
         <include refid="Base_Column_List"/>
         from ctop_oauth_token
+        group by account_id
     </select>
 
 

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

@@ -24,7 +24,7 @@ public interface IFileInfoService extends IService<FileInfo> {
 
     List<FileInfo> getFileInfoByMd5(String md5);
 
-    Map<String, Object> checkFile(String code);
+    Map<String, Object> checkFileInfo(String code);
 
     Map<String, Object> getCreativeWords(Long accountId);
 

+ 17 - 4
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java

@@ -70,9 +70,20 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
         }
         JSONObject data = resultObject.getJSONObject("data");
         CtopOauthToken refreshToken = new CtopOauthToken(token, data);
-        cTopOauthTokenMapper.deleteById(token.getId());
+       /* cTopOauthTokenMapper.deleteById(token.getId());
         cTopOauthTokenMapper.insert(refreshToken);
-        log.info("头条刷新token成功:accountId:{}", accountId);
+        CtopOauthToken topOauthToken = new CtopOauthToken();
+        topOauthToken.setAccessToken(refreshToken.getAccessToken());
+        topOauthToken.setRefreshToken(refreshToken.getRefreshToken());*/
+
+        QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("media_id", 1);
+
+        int i = cTopOauthTokenMapper.update(refreshToken, queryWrapper);
+        if (i > 0) {
+            log.info("头条刷新token成功:accountId:{}", accountId);
+        }
         resultMap.put("message", "token刷新成功");
         resultMap.put("code", 0);
         return resultMap;
@@ -104,7 +115,6 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
                     if (!Check.isNull(oauthToken)) {
                         JSONObject dataJson = resultJson.getJSONObject("data");
                         if (!Check.isNull(dataJson)) {
-                            oauthToken.setAccountId(accountId);
                             oauthToken.setAccessToken(dataJson.getString("access_token"));
                             long accessTokenExpireIn = dataJson.getLong("access_token_expires_in") * 1000L;
                             long now = System.currentTimeMillis();
@@ -115,7 +125,10 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
                             Date refreshTokenExpireInDate = new Date(now + refreshTokenExpireIn);
                             oauthToken.setRefreshTokenExpiresIn(refreshTokenExpireInDate);
                             oauthToken.setUpdateTime(new Date());
-                            int i = cTopOauthTokenMapper.updateByPrimaryKeySelective(oauthToken);
+                            QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
+                            queryWrapper.eq("account_id", accountId);
+                            queryWrapper.eq("media_id", 2);
+                            int i = cTopOauthTokenMapper.update(oauthToken, queryWrapper);
                             if (i > 0) {
                                 log.info("快手刷新token成功,accountId:{}", accountId);
                             }

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

@@ -130,10 +130,7 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
     }
 
     @Override
-    /**
-     * 校验文件唯一性
-     */
-    public Map<String, Object> checkFile(String code) {
+    public Map<String, Object> checkFileInfo(String code) {
         Map<String, Object> result = new HashMap<>();
         QueryWrapper<SourceFile> wrapper = new QueryWrapper<>();
         wrapper.eq("code", code).orderByDesc("id").last("limit 1");

Plik diff jest za duży
+ 2 - 1
module-common/src/main/java/cn/com/ctop/common/module/utils/Base64Utils.java


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

@@ -6,18 +6,23 @@ import java.net.URI;
 
 public class HttpGetWithBodyEntity extends HttpEntityEnclosingRequestBase {
     private final static String METHOD_NAME = "GET";
+
     @Override
     public String getMethod() {
         return METHOD_NAME;
     }
+
     public HttpGetWithBodyEntity() {
         super();
     }
+
     public HttpGetWithBodyEntity(final URI uri) {
         super();
         setURI(uri);
     }
+
     HttpGetWithBodyEntity(final String uri) {
-        super(); setURI(URI.create(uri));
+        super();
+        setURI(URI.create(uri));
     }
 }

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

@@ -242,7 +242,6 @@ public class ImageUtils {
         list.add("这样穿不简单");
 
 
-
         return list;
     }
 }

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

@@ -123,7 +123,7 @@ public class OSSUtils {
     /**
      * 上传图片至OSS
      *
-     * @param file       上传文件(文件全路径如:D:\\image\\cake.jpg)
+     * @param file 上传文件(文件全路径如:D:\\image\\cake.jpg)
      * @return String 返回的唯一MD5数字签名
      */
     public static String uploadObject2Oss(File file) {

+ 248 - 0
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/controller/MaterialInfoController.java

@@ -0,0 +1,248 @@
+package cn.com.ctop.manage.modules.material.controller;
+
+import cn.com.ctop.manage.modules.material.entity.MaterialInfo;
+import cn.com.ctop.manage.modules.material.service.IMaterialInfoService;
+import com.alibaba.fastjson.JSON;
+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.aspect.annotation.AutoLog;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 素材信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-10-11
+ */
+@Slf4j
+@Api(tags = "素材信息")
+@RestController
+@RequestMapping("/ctop/materialInfo")
+public class MaterialInfoController {
+    @Autowired
+    private IMaterialInfoService materialInfoService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param materialInfo
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "素材信息-分页列表查询")
+    @ApiOperation(value = "素材信息-分页列表查询", notes = "素材信息-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<MaterialInfo>> queryPageList(MaterialInfo materialInfo,
+                                                     @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                     HttpServletRequest req) {
+        Result<IPage<MaterialInfo>> result = new Result<IPage<MaterialInfo>>();
+        QueryWrapper<MaterialInfo> queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());
+        Page<MaterialInfo> page = new Page<MaterialInfo>(pageNo, pageSize);
+        IPage<MaterialInfo> pageList = materialInfoService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param materialInfo
+     * @return
+     */
+    @AutoLog(value = "素材信息-添加")
+    @ApiOperation(value = "素材信息-添加", notes = "素材信息-添加")
+    @PostMapping(value = "/add")
+    public Result<MaterialInfo> add(@RequestBody MaterialInfo materialInfo) {
+        Result<MaterialInfo> result = new Result<MaterialInfo>();
+        try {
+            materialInfoService.save(materialInfo);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param materialInfo
+     * @return
+     */
+    @AutoLog(value = "素材信息-编辑")
+    @ApiOperation(value = "素材信息-编辑", notes = "素材信息-编辑")
+    @PutMapping(value = "/edit")
+    public Result<MaterialInfo> edit(@RequestBody MaterialInfo materialInfo) {
+        Result<MaterialInfo> result = new Result<MaterialInfo>();
+        MaterialInfo materialInfoEntity = materialInfoService.getById(materialInfo.getId());
+        if (materialInfoEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = materialInfoService.updateById(materialInfo);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "素材信息-通过id删除")
+    @ApiOperation(value = "素材信息-通过id删除", notes = "素材信息-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            materialInfoService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "素材信息-批量删除")
+    @ApiOperation(value = "素材信息-批量删除", notes = "素材信息-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<MaterialInfo> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<MaterialInfo> result = new Result<MaterialInfo>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.materialInfoService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "素材信息-通过id查询")
+    @ApiOperation(value = "素材信息-通过id查询", notes = "素材信息-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<MaterialInfo> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<MaterialInfo> result = new Result<MaterialInfo>();
+        MaterialInfo materialInfo = materialInfoService.getById(id);
+        if (materialInfo == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(materialInfo);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<MaterialInfo> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                MaterialInfo materialInfo = JSON.parseObject(deString, MaterialInfo.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<MaterialInfo> pageList = materialInfoService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "素材信息列表");
+        mv.addObject(NormalExcelConstants.CLASS, MaterialInfo.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("素材信息列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<MaterialInfo> listMaterialInfos = ExcelImportUtil.importExcel(file.getInputStream(), MaterialInfo.class, params);
+                materialInfoService.saveBatch(listMaterialInfos);
+                return Result.ok("文件导入成功!数据行数:" + listMaterialInfos.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("文件导入失败!");
+    }
+
+}

+ 63 - 0
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/entity/MaterialInfo.java

@@ -0,0 +1,63 @@
+package cn.com.ctop.manage.modules.material.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 2019-10-11
+ */
+@Data
+@TableName("ctop_material_info")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_material_info对象", description = "素材信息")
+public class MaterialInfo {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.UUID)
+    @ApiModelProperty(value = "id")
+    private Integer id;
+    /**
+     * code
+     */
+    @Excel(name = "code", width = 15)
+    @ApiModelProperty(value = "code")
+    private String code;
+    /**
+     * url
+     */
+    @Excel(name = "url", width = 15)
+    @ApiModelProperty(value = "url")
+    private String url;
+    /**
+     * createTime
+     */
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+    /**
+     * status
+     */
+    @Excel(name = "status", width = 15)
+    @ApiModelProperty(value = "status")
+    private Integer status;
+}

+ 15 - 0
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/mapper/MaterialInfoMapper.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.manage.modules.material.mapper;
+
+import cn.com.ctop.manage.modules.material.entity.MaterialInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 素材信息
+ *
+ * @author: jeecg-boot
+ * @date: 2019-10-11
+ * @cersion: V1.0
+ */
+public interface MaterialInfoMapper extends BaseMapper<MaterialInfo> {
+
+}

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

+ 21 - 0
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/IMaterialInfoService.java

@@ -0,0 +1,21 @@
+package cn.com.ctop.manage.modules.material.service;
+
+import cn.com.ctop.manage.modules.material.entity.MaterialInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.Map;
+
+/**
+ * 素材信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-10-11
+ */
+public interface IMaterialInfoService extends IService<MaterialInfo> {
+    MaterialInfo getMaterialInfoByCode(String code);
+
+    Map<String, Object> checkMaterialInfo(String code);
+
+    Map<String, Object> insert(String code, String url);
+}

+ 62 - 0
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialInfoServiceImpl.java

@@ -0,0 +1,62 @@
+package cn.com.ctop.manage.modules.material.service.impl;
+
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
+import cn.com.ctop.manage.modules.material.entity.MaterialInfo;
+import cn.com.ctop.manage.modules.material.mapper.MaterialInfoMapper;
+import cn.com.ctop.manage.modules.material.service.IMaterialInfoService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 素材信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-10-11
+ */
+@Service
+public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, MaterialInfo> implements IMaterialInfoService {
+
+    @Override
+    public MaterialInfo getMaterialInfoByCode(String code) {
+        QueryWrapper<MaterialInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("code", code).orderByDesc("id").last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+
+    @Override
+    public Map<String, Object> checkMaterialInfo(String code) {
+        Map<String, Object> result = new HashMap<>();
+        MaterialInfo info = this.getMaterialInfoByCode(code);
+        if (null != info) {
+            //文件已存在
+            ResultMapUtils.setResultMap(result, StatusCode.FILE_HAS_UPLOAD.getCode());
+            result.put("url", info.getUrl());
+            return result;
+        } else {
+            //文件尚未上传
+            ResultMapUtils.setResultMap(result, StatusCode.FILE_HAS_NOT_UPLOAD.getCode());
+            return result;
+        }
+    }
+
+    @Override
+    public Map<String, Object> insert(String code, String url) {
+        Map<String, Object> resultMap = new HashMap<>();
+        MaterialInfo info = new MaterialInfo();
+        info.setCode(code);
+        info.setUrl(url);
+        info.setStatus(1);
+        info.setCreateTime(new Date());
+        info.setUpdateTime(new Date());
+        this.save(info);
+        ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
+        return resultMap;
+    }
+}

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

@@ -3,8 +3,6 @@ package cn.com.ctop.kuaishou.modules.batch.controller;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
-import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyCampaign;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -198,13 +196,40 @@ public class KuaiShouController {
     }
 
     @RequestMapping("report")
-    public Map<String, Object> getReport(String accountId) {
-        CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
-        String startDate = "2019-08-14";
-        String endDate = "2019-08-14";
-        KuaishouResult<KuaishouReportDailyCampaign> stringObjectMap = kuaishouInterfaceService.getCampaignDailyReport(token.getAccessToken(), token.getAccountId(), startDate, endDate, 1000, 1);
+    public Map<String, Object> getReport(String accountId, String startDate, String endDate, Integer type, String temporalGranularity) {
         Map<String, Object> result = new HashMap<>();
-        result.put("data", stringObjectMap);
+        CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId);
+        if (null != type) {
+            if (type == 1) {
+                //广告主
+                if (null != temporalGranularity && temporalGranularity.equals("hourly")) {
+                    result.put("data", kuaishouInterfaceService.getAccountHourlyReport(token.getAccessToken(), token.getAccountId(), startDate, endDate, 500, 1));
+                } else {
+                    result.put("data", kuaishouInterfaceService.getAccountDailyReport(token.getAccessToken(), token.getAccountId(), startDate, endDate, 500, 1));
+                }
+            } else if (type == 2) {
+                //广告组
+                if (null != temporalGranularity && temporalGranularity.equals("hourly")) {
+                    result.put("data", kuaishouInterfaceService.getGroupHourlyReport(token.getAccessToken(), token.getAccountId(), startDate, endDate, 500, 1));
+                } else {
+                    result.put("data", kuaishouInterfaceService.getGroupDailyReport(token.getAccessToken(), token.getAccountId(), startDate, endDate, 500, 1));
+                }
+            } else if (type == 3) {
+                //广告计划
+                if (null != temporalGranularity && temporalGranularity.equals("hourly")) {
+                    result.put("data", kuaishouInterfaceService.getCampaignHourlyReport(token.getAccessToken(), token.getAccountId(), startDate, endDate, 500, 1));
+                } else {
+                    result.put("data", kuaishouInterfaceService.getCampaignDailyReport(token.getAccessToken(), token.getAccountId(), startDate, endDate, 500, 1));
+                }
+            } else {
+                //广告创意
+                if (null != temporalGranularity && temporalGranularity.equals("hourly")) {
+                    result.put("data", kuaishouInterfaceService.getCreativeHourlyReport(token.getAccessToken(), token.getAccountId(), startDate, endDate, 500, 1));
+                } else {
+                    result.put("data", kuaishouInterfaceService.getCreativeDailyReport(token.getAccessToken(), token.getAccountId(), startDate, endDate, 500, 1));
+                }
+            }
+        }
         return result;
     }
 

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

@@ -92,7 +92,6 @@ public class KuaiShouCreateAppTemplate {
     private Integer uploadType;
 
 
-
     private Long accountId;
 
 

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

@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 /**
  * @Description: 快手修改广告组出价
  * @Author: jeecg-boot
- * @Date:   2019-09-11
+ * @Date: 2019-09-11
  * @Version: V1.0
  */
 public interface KuaiShouGroupBidMapper extends BaseMapper<KuaiShouGroupBid> {

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

@@ -9,7 +9,7 @@ import org.springframework.stereotype.Service;
 /**
  * @Description: 快手修改广告组出价
  * @Author: jeecg-boot
- * @Date:   2019-09-11
+ * @Date: 2019-09-11
  * @Version: V1.0
  */
 @Service

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

@@ -137,6 +137,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             });
             List<KuaishouReportHourlyAccount> hourlyAccounts = kuaishouResult.getData().getDetails();
             hourlyAccounts.forEach((hourlyAccount) -> {
+                hourlyAccount.setAccountId(advertiserId);
+                hourlyAccount.setId("" + hourlyAccount.getAccountId() + hourlyAccount.getStatDate() + hourlyAccount.getStatHour());
                 hourlyAccountService.saveOrUpdate(hourlyAccount);
             });
         } catch (Exception e) {
@@ -166,8 +168,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             kuaishouResult = mapper.readValue(result, new TypeReference<KuaishouResult<KuaishouReportDailyAccount>>() {
             });
             List<KuaishouReportDailyAccount> dailyAccounts = kuaishouResult.getData().getDetails();
-            dailyAccounts.forEach((kuaishouReportDailyAccount -> {
-                dailyAccountService.saveOrUpdate(kuaishouReportDailyAccount);
+            dailyAccounts.forEach((hourlyAccount -> {
+                hourlyAccount.setAccountId(advertiserId);
+                hourlyAccount.setId("" + hourlyAccount.getAccountId() + hourlyAccount.getStatDate());
+                dailyAccountService.saveOrUpdate(hourlyAccount);
             }));
         } catch (Exception e) {
             e.printStackTrace();
@@ -178,10 +182,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     @Override
     public KuaishouResult<KuaishouReportDailyCampaign> getCampaignDailyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_REPORT;
-        Map<String, String> headers = new HashMap<String, String>();
+        Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", "application/json");
         headers.put("Access-Token", accessToken);
-        Map<String, Object> param = new HashMap<String, Object>();
+        Map<String, Object> param = new HashMap<>();
         param.put("start_date", startDate);
         param.put("end_date", endDate);
         param.put("advertiser_id", advertiserId);
@@ -197,8 +201,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             kuaishouResult = mapper.readValue(result, new TypeReference<KuaishouResult<KuaishouReportDailyCampaign>>() {
             });
             List<KuaishouReportDailyCampaign> details = kuaishouResult.getData().getDetails();
-            details.forEach((kuaishouReportDailyCampaign) -> {
-                dailyCampaignService.saveOrUpdate(kuaishouReportDailyCampaign);
+            details.forEach((campaign) -> {
+                campaign.setAccountId(advertiserId);
+                campaign.setId("" + campaign.getAccountId() + campaign.getCampaignId() + campaign.getStatDate());
+                dailyCampaignService.saveOrUpdate(campaign);
             });
         } catch (Exception e) {
             e.printStackTrace();
@@ -212,7 +218,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", "application/json");
         headers.put("Access-Token", accessToken);
-        Map<String, Object> param = new HashMap<String, Object>();
+        Map<String, Object> param = new HashMap<>();
         param.put("start_date", startDate);
         param.put("end_date", endDate);
         param.put("advertiser_id", advertiserId);
@@ -227,8 +233,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             kuaishouResult = mapper.readValue(result, new TypeReference<KuaishouResult<KuaishouReportHourlyCampaign>>() {
             });
             List<KuaishouReportHourlyCampaign> campaigns = kuaishouResult.getData().getDetails();
-            campaigns.forEach((kuaishouReportHourlyCampaign) -> {
-                hourlyCampaignService.saveOrUpdate(kuaishouReportHourlyCampaign);
+            campaigns.forEach((campaign) -> {
+                campaign.setAccountId(advertiserId);
+                campaign.setId("" + campaign.getAccountId() + campaign.getCampaignId() + campaign.getStatDate() + campaign.getStatHour());
+                hourlyCampaignService.saveOrUpdate(campaign);
             });
         } catch (Exception e) {
             e.printStackTrace();
@@ -270,8 +278,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             kuaishouResult = mapper.readValue(result, new TypeReference<KuaishouResult<KuaishouReportDailyGroup>>() {
             });
             List<KuaishouReportDailyGroup> dailyGroups = kuaishouResult.getData().getDetails();
-            dailyGroups.forEach((kuaishouReportDailyGroup) -> {
-                dailyGroupService.saveOrUpdate(kuaishouReportDailyGroup);
+            dailyGroups.forEach((dailyGroup) -> {
+                dailyGroup.setAccountId(advertiserId);
+                dailyGroup.setId("" + dailyGroup.getAccountId() + dailyGroup.getGroupId() + dailyGroup.getStatDate());
+                dailyGroupService.saveOrUpdate(dailyGroup);
             });
         } catch (Exception e) {
             e.printStackTrace();
@@ -300,8 +310,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             kuaishouResult = mapper.readValue(result, new TypeReference<KuaishouResult<KuaishouReportHourlyGroup>>() {
             });
             List<KuaishouReportHourlyGroup> hourlyGroups = kuaishouResult.getData().getDetails();
-            hourlyGroups.forEach((kuaishouReportHourlyGroup) -> {
-                hourlyGroupService.saveOrUpdate(kuaishouReportHourlyGroup);
+            hourlyGroups.forEach((hourlyGroup) -> {
+                hourlyGroup.setAccountId(advertiserId);
+                hourlyGroup.setId("" + hourlyGroup.getAccountId() + hourlyGroup.getGroupId() + hourlyGroup.getStatDate() + hourlyGroup.getStatHour());
+                hourlyGroupService.saveOrUpdate(hourlyGroup);
             });
         } catch (Exception e) {
             e.printStackTrace();
@@ -330,8 +342,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             kuaishouResult = mapper.readValue(result, new TypeReference<KuaishouResult<KuaishouReportDailyCreative>>() {
             });
             List<KuaishouReportDailyCreative> dailyCreatives = kuaishouResult.getData().getDetails();
-            dailyCreatives.forEach((kuaishouReportDailyCreative) -> {
-                dailyCreativeService.saveOrUpdate(kuaishouReportDailyCreative);
+            dailyCreatives.forEach((creative) -> {
+                creative.setAccountId(advertiserId);
+                creative.setId("" + creative.getAccountId() + creative.getCreativeId() + creative.getStatDate());
+                dailyCreativeService.saveOrUpdate(creative);
             });
         } catch (Exception e) {
             e.printStackTrace();
@@ -360,8 +374,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             kuaishouResult = mapper.readValue(result, new TypeReference<KuaishouResult<KuaishouReportHourlyCreative>>() {
             });
             List<KuaishouReportHourlyCreative> hourlyCreatives = kuaishouResult.getData().getDetails();
-            hourlyCreatives.forEach((kuaishouReportHourlyCreative) -> {
-                hourlyCreativeService.saveOrUpdate(kuaishouReportHourlyCreative);
+            hourlyCreatives.forEach((creative) -> {
+                creative.setAccountId(advertiserId);
+                creative.setId("" + creative.getAccountId() + creative.getCreativeId() + creative.getStatDate() + creative.getStatHour());
+                hourlyCreativeService.saveOrUpdate(creative);
             });
         } catch (Exception e) {
             e.printStackTrace();

+ 9 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAccount.java

@@ -1,6 +1,5 @@
 package cn.com.ctop.kuaishou.modules.report.entity;
 
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -15,15 +14,21 @@ import java.math.BigDecimal;
 public class KuaishouReportDailyAccount implements Serializable {
     private static final long serialVersionUID = 1L;
     @TableId
+    private String id;
+
     private Long accountId;
+
     @JsonProperty("stat_date")
-    @TableId
     private String statDate;
+
     @JsonProperty
     private BigDecimal charge;
-    @JsonProperty
-    @TableField("`show`")
+    @TableField("photo_show")
     private Long show;
+    @JsonProperty("photo_click")
+    @TableField("photo_click")
+    private Long photoClick;
+
     @JsonProperty
     private Long aclick;
     @JsonProperty

+ 5 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCampaign.java

@@ -13,18 +13,19 @@ import java.math.BigDecimal;
 public class KuaishouReportDailyCampaign implements Serializable {
     private static final long serialVersionUID = 1L;
     @TableId
+    private String id;
     private Long accountId;
     @JsonProperty("campaign_id")
-    @TableId
     private Long campaignId;
     @JsonProperty("stat_date")
-    @TableId
     private String statDate;
     @JsonProperty
     private BigDecimal charge;
-    @JsonProperty
-    @TableField("`show`")
+    @TableField("photo_show")
     private Long show;
+    @JsonProperty("photo_click")
+    @TableField("photo_click")
+    private Long photoClick;
     @JsonProperty
     private Long aclick;
     @JsonProperty

+ 8 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCreative.java

@@ -13,18 +13,22 @@ import java.math.BigDecimal;
 public class KuaishouReportDailyCreative implements Serializable {
     private static final long serialVersionUID = 1L;
     @TableId
+    private String id;
+
     private Long accountId;
+
     @JsonProperty("creative_id")
-    @TableId
     private Long creativeId;
+
     @JsonProperty("stat_date")
-    @TableId
     private String statDate;
     @JsonProperty
     private BigDecimal charge;
-    @JsonProperty
-    @TableField("`show`")
+    @TableField("photo_show")
     private Long show;
+    @JsonProperty("photo_click")
+    @TableField("photo_click")
+    private Long photoClick;
     @JsonProperty
     private Long aclick;
     @JsonProperty

+ 9 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyGroup.java

@@ -13,18 +13,23 @@ import java.math.BigDecimal;
 public class KuaishouReportDailyGroup implements Serializable {
     private static final long serialVersionUID = 1L;
     @TableId
+    private String id;
+
     private Long accountId;
+
     @JsonProperty("unit_id")
-    @TableId
     private Long groupId;
+
     @JsonProperty("stat_date")
-    @TableId
     private String statDate;
+
     @JsonProperty
     private BigDecimal charge;
-    @JsonProperty
-    @TableField("`show`")
+    @TableField("photo_show")
     private Long show;
+    @JsonProperty("photo_click")
+    @TableField("photo_click")
+    private Long photoClick;
     @JsonProperty
     private Long aclick;
     @JsonProperty

+ 8 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyAccount.java

@@ -1,6 +1,5 @@
 package cn.com.ctop.kuaishou.modules.report.entity;
 
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -14,18 +13,22 @@ import java.math.BigDecimal;
 public class KuaishouReportHourlyAccount implements Serializable {
     private static final long serialVersionUID = 1L;
     @TableId
+    private String id;
+
     private Long accountId;
     @JsonProperty("stat_date")
-    @TableId
     private String statDate;
+
     @JsonProperty("stat_hour")
-    @TableId
     private Integer statHour;
+
     @JsonProperty
     private BigDecimal charge;
-    @JsonProperty
-    @TableField("`show`")
+    @TableField("photo_show")
     private Long show;
+    @JsonProperty("photo_click")
+    @TableField("photo_click")
+    private Long photoClick;
     @JsonProperty
     private Long aclick;
     @JsonProperty

+ 10 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyCampaign.java

@@ -14,21 +14,26 @@ import java.math.BigDecimal;
 public class KuaishouReportHourlyCampaign implements Serializable {
     private static final long serialVersionUID = 1L;
     @TableId
+    private String id;
+
     private Long accountId;
+
     @JsonProperty("campaign_id")
-    @TableId
     private Long campaignId;
+
     @JsonProperty("stat_date")
-    @TableId
     private String statDate;
+
     @JsonProperty("stat_hour")
-    @TableId
     private Integer statHour;
+
     @JsonProperty
     private BigDecimal charge;
-    @JsonProperty
-    @TableField("`show`")
+    @TableField("photo_show")
     private Long show;
+    @JsonProperty("photo_click")
+    @TableField("photo_click")
+    private Long photoClick;
     @JsonProperty
     private Long aclick;
     @JsonProperty

+ 5 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyCreative.java

@@ -14,21 +14,21 @@ import java.math.BigDecimal;
 public class KuaishouReportHourlyCreative implements Serializable {
     private static final long serialVersionUID = 1L;
     @TableId
+    private String id;
     private Long accountId;
     @JsonProperty("creative_id")
-    @TableId
     private Long creativeId;
     @JsonProperty("stat_date")
-    @TableId
     private String statDate;
     @JsonProperty("stat_hour")
-    @TableId
     private Integer statHour;
     @JsonProperty
     private BigDecimal charge;
-    @JsonProperty
-    @TableField("`show`")
+    @TableField("photo_show")
     private Long show;
+    @JsonProperty("photo_click")
+    @TableField("photo_click")
+    private Long photoClick;
     @JsonProperty
     private Long aclick;
     @JsonProperty

+ 5 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyGroup.java

@@ -14,21 +14,21 @@ import java.math.BigDecimal;
 public class KuaishouReportHourlyGroup implements Serializable {
     private static final long serialVersionUID = 1L;
     @TableId
+    private String id;
     private Long accountId;
     @JsonProperty("unit_id")
-    @TableId
     private Long groupId;
     @JsonProperty("stat_date")
-    @TableId
     private String statDate;
     @JsonProperty("stat_hour")
-    @TableId
     private Integer statHour;
     @JsonProperty
     private BigDecimal charge;
-    @JsonProperty
-    @TableField("`show`")
+    @TableField("photo_show")
     private Long show;
+    @JsonProperty("photo_click")
+    @TableField("photo_click")
+    private Long photoClick;
     @JsonProperty
     private Long aclick;
     @JsonProperty

+ 26 - 4
module-report/src/main/java/cn/com/ctop/bytedance/controller/BytedanceReportController.java

@@ -4,9 +4,13 @@ import cn.com.ctop.bytedance.service.IBytedanceReportService;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 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.List;
+
 @Slf4j
 @RestController
 @RequestMapping("/ctop/report")
@@ -19,16 +23,34 @@ public class BytedanceReportController {
      *
      * @return
      */
-    @RequestMapping(value = "/cost")
-    public JSONObject getCost() {
+    @RequestMapping(value = "/accountReport")
+    public JSONObject getAccountReport() {
         /*LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         if (Check.isNull(user)) {
             JSONObject json = bytedanceReportService.getCost(user.getId());
         }*/
 
+        JSONObject json = bytedanceReportService.getAccountReport("e9ca23d68d884d4ebb19d07889727dae");
+        return json;
+
+    }
+
+
+    @PostMapping("/kuaiShou/accountReport")
+    public JSONObject getKuaiShouAccountReport(@RequestBody JSONObject requestJson) {
+        System.err.println(requestJson);
+        JSONObject json = bytedanceReportService.getKuaiShouAccountReport(requestJson);
+        return json;
+
+    }
+
+
+    @PostMapping("/kuaiShou/accountDetailReport")
+    public List<JSONObject> getKuaiShouAccountDetailReport(@RequestBody JSONObject requestJson) {
+        System.err.println(requestJson);
 
-        JSONObject json = bytedanceReportService.getCost("e9ca23d68d884d4ebb19d07889727dae");
-        return null;
+        List<JSONObject> kuaiShouAccounDetailtReport = bytedanceReportService.getKuaiShouAccounDetailtReport(requestJson);
+        return kuaiShouAccounDetailtReport;
 
     }
 

+ 2 - 1
module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceAdvertiserHourlyReport.java

@@ -16,9 +16,10 @@ import java.util.Date;
 
 /**
  * 广告主小时级别报表信息
+ *
  * @author jeecg-boot
- * @date 2019-09-10
  * @version V1.0
+ * @date 2019-09-10
  */
 @Data
 @TableName("ctop_bytedance_report_advertiser_hourly")

+ 110 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/ReportMapper.java

@@ -0,0 +1,110 @@
+package cn.com.ctop.bytedance.mapper;
+
+
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface ReportMapper {
+
+    /**
+     * 今日消耗
+     *
+     * @param date
+     * @return
+     */
+    JSONObject selectDayReport(@Param("date") String date);
+
+    /**
+     * 查询明细
+     *
+     * @param date
+     * @return
+     */
+    List<JSONObject> selectReportDetail(@Param("date") String date);
+
+    /**
+     * 根据开始、结束日期查询消耗
+     *
+     * @param anotherDay
+     * @param endDate
+     * @return
+     */
+    JSONObject selectByDate(@Param("startDate") String anotherDay, @Param("endDate") String endDate);
+
+    /**
+     * 查询全部消耗 包括今日消耗
+     *
+     * @return
+     */
+    JSONObject selectAllAccount();
+
+    /**
+     * 查询 昨日消耗
+     *
+     * @param anotherDay
+     * @return
+     */
+    JSONObject selectYesterday(@Param("date") String anotherDay);
+
+    /**
+     * 根据日期 小时 查询信息
+     *
+     * @param date
+     * @param statHour
+     * @return
+     */
+    JSONObject selectYesterdayByHourAndDate(@Param("date") String date, @Param("statHour") String statHour);
+
+    /**
+     * 查询 七天汇总数据
+     *
+     * @param anotherDay
+     * @param endDate
+     * @return
+     */
+    List<JSONObject> selectDayDetailByDate(@Param("startDate") String anotherDay, @Param("endDate") String endDate);
+
+    /**
+     * 按月 明细
+     *
+     * @param anotherDay
+     * @param endDate
+     * @return
+     */
+    List<JSONObject> selectDayDetailByMonth(@Param("startDate") String anotherDay, @Param("endDate") String endDate);
+
+    /**
+     * 查询所有按月统计数据
+     *
+     * @return
+     */
+    List<JSONObject> selectAllDayDetailByMonth();
+
+
+    /**
+     * 根据月份 查询
+     *
+     * @param date
+     * @return
+     */
+    JSONObject selectMonthReportByDate(@Param("date") String date);
+
+
+    /**
+     * 根据月份查询按日明细
+     *
+     * @param date
+     * @return
+     */
+    List<JSONObject> selectDayDetailsByMonth(@Param("date") String date);
+
+    /**
+     * 根据日期查询汇总数据
+     *
+     * @param statDate
+     * @return
+     */
+    JSONObject selectDayDailyByDate(@Param("statDate") String statDate);
+}

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

@@ -0,0 +1,165 @@
+<?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.bytedance.mapper.ReportMapper">
+
+    <select id="selectDayReport" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       sum(charge) cost,
+       sum(photo_show) photoShow,
+       sum(photo_click) photoClick,
+       sum(aclick) aclick
+     from
+      ctop_kuaishou_report_hourly_account
+      where stat_date = #{date}
+    </select>
+
+    <select id="selectYesterday" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       sum(charge) cost,
+       sum(photo_show) photoShow,
+       sum(photo_click) photoClick,
+       sum(aclick) aclick
+     from
+      ctop_kuaishou_report_hourly_account
+      where stat_date = #{date}
+    </select>
+
+
+    <select id="selectByDate" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       sum(charge) cost,
+       sum(photo_show) photoShow,
+       sum(photo_click) photoClick,
+       sum(aclick) aclick
+     from
+      ctop_kuaishou_report_daily_account
+      where stat_date &lt;= #{startDate}
+      and  stat_date &gt;= #{endDate}
+    </select>
+
+    <select id="selectAllAccount" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       sum(charge) cost,
+       sum(photo_show) photoShow,
+       sum(photo_click) photoClick,
+       sum(aclick) aclick
+     from
+      ctop_kuaishou_report_hourly_account
+    </select>
+
+
+    <select id="selectReportDetail" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       sum(charge) cost,
+       sum(photo_show) photoShow,
+       sum(photo_click) photoClick,
+       sum(aclick) aclick,
+       stat_hour statHour
+     from
+      ctop_kuaishou_report_hourly_account
+      where stat_date = #{date}
+      group by stat_hour
+      order by stat_hour desc
+    </select>
+
+
+    <select id="selectYesterdayByHourAndDate" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       sum(charge) cost,
+       sum(photo_show) photoShow,
+       sum(photo_click) photoClick,
+       sum(aclick) aclick
+     from
+      ctop_kuaishou_report_hourly_account
+      where stat_date = #{date}
+      and stat_hour = #{statHour}
+    </select>
+
+
+    <select id="selectDayDetailByDate" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       charge cost,
+       photo_show photoShow,
+       photo_click photoClick,
+       aclick aclick,
+       stat_date statDate
+     from
+      ctop_kuaishou_report_daily_account
+      where stat_date &lt;= #{startDate}
+      and  stat_date &gt;= #{endDate}
+      order by stat_date desc
+    </select>
+
+
+    <select id="selectDayDetailByMonth" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       sum(charge) cost,
+       sum(photo_show) photoShow,
+       sum(photo_click) photoClick,
+       sum(aclick) aclick,
+       DATE_FORMAT(stat_date,'%Y-%m') statDate
+     from
+      ctop_kuaishou_report_daily_account
+      where stat_date &lt;= #{startDate}
+      and  stat_date &gt;= #{endDate}
+      group by DATE_FORMAT(stat_date,'%Y-%m')
+      order by stat_date desc
+    </select>
+
+    <select id="selectAllDayDetailByMonth" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       sum(charge) cost,
+       sum(photo_show) photoShow,
+       sum(photo_click) photoClick,
+       sum(aclick) aclick,
+       DATE_FORMAT(stat_date,'%Y-%m') statDate
+     from
+      ctop_kuaishou_report_daily_account
+      group by DATE_FORMAT(stat_date,'%Y-%m')
+      order by stat_date desc
+    </select>
+
+
+    <select id="selectMonthReportByDate" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       sum(charge) cost,
+       sum(photo_show) photoShow,
+       sum(photo_click) photoClick,
+       sum(aclick) aclick,
+       DATE_FORMAT(stat_date,'%Y-%m') statDate
+     from
+      ctop_kuaishou_report_daily_account
+      where DATE_FORMAT(stat_date,'%Y-%m') = #{date}
+    </select>
+
+
+    <select id="selectDayDetailsByMonth" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       sum(charge) cost,
+       sum(photo_show) photoShow,
+       sum(photo_click) photoClick,
+       sum(aclick) aclick,
+       stat_date statDate
+     from
+      ctop_kuaishou_report_daily_account
+      where DATE_FORMAT(stat_date,'%Y-%m') = #{date}
+      group by stat_date
+      order by stat_date desc
+    </select>
+
+
+    <select id="selectDayDailyByDate" resultType="com.alibaba.fastjson.JSONObject">
+      select
+       sum(charge) cost,
+       sum(photo_show) photoShow,
+       sum(photo_click) photoClick,
+       sum(aclick) aclick,
+       stat_date statDate
+     from
+      ctop_kuaishou_report_daily_account
+      where stat_date = #{statDate}
+      group by stat_date
+
+    </select>
+
+</mapper>

+ 20 - 1
module-report/src/main/java/cn/com/ctop/bytedance/service/IBytedanceReportService.java

@@ -2,6 +2,25 @@ package cn.com.ctop.bytedance.service;
 
 import com.alibaba.fastjson.JSONObject;
 
+import java.util.List;
+
 public interface IBytedanceReportService {
-    JSONObject getCost(String loginId);
+    JSONObject getAccountReport(String loginId);
+
+    /**
+     * 快手 大盘报表
+     *
+     * @param requestJson
+     * @return
+     */
+    JSONObject getKuaiShouAccountReport(JSONObject requestJson);
+
+
+    /**
+     * 获取明细
+     *
+     * @param
+     * @return
+     */
+    List<JSONObject> getKuaiShouAccounDetailtReport(JSONObject requestJson);
 }

+ 429 - 26
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceReportServiceImpl.java

@@ -2,17 +2,24 @@ package cn.com.ctop.bytedance.service.impl;
 
 import cn.com.ctop.bytedance.entity.BytedanceAdvertiserDailyReport;
 import cn.com.ctop.bytedance.mapper.BytedanceAdvertiserDailyReportMapper;
+import cn.com.ctop.bytedance.mapper.ReportMapper;
 import cn.com.ctop.bytedance.service.IBytedanceReportService;
 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 cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccount;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class BytedanceReportServiceImpl implements IBytedanceReportService {
@@ -22,25 +29,28 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
     @Autowired
     private BytedanceAdvertiserDailyReportMapper bytedanceAdvertiserDailyReportMapper;
 
+    @Autowired
+    private ReportMapper reportMapper;
+
+    @Autowired
+    private KuaishouReportDailyAccountMapper kuaishouReportDailyAccountMapper;
+
     /**
-     * 获取 媒体昨日总消耗
+     * 媒体昨日总消耗
      *
      * @param loginId
      * @return
      */
     @Override
-    public JSONObject getCost(String loginId) {
-
+    public JSONObject getAccountReport(String loginId) {
         JSONObject returnJson = new JSONObject();
-
-
         QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("user_id", loginId);
-        queryWrapper.eq("media_id", 1);
         queryWrapper.isNotNull("account_id");
         queryWrapper.groupBy("account_id");
         List<UserAllocation> userAllocations = userAllocationMapper.selectList(queryWrapper);
         if (!Check.isNull(userAllocations)) {
+            // 头条相关
             JSONObject bytedanceJson = new JSONObject();
             BigDecimal byteDanceCost = new BigDecimal(0);
             Long byteDanceClick = 0L;
@@ -49,26 +59,105 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             Long byteDanceForm = 0L;
             Long byteDanceNextDayOpen = 0L;
             Long byteDanceActive = 0L;
+            JSONArray bytedanceDetail = new JSONArray();
+
+            // 快手相关
+            JSONArray kuaishouDetail = new JSONArray();
+            JSONObject kuaishouJson = new JSONObject();
+            BigDecimal kuaishouCost = new BigDecimal(0);
+
+            Long kuaishouClick = 0L;
+            Long kuaishouShow = 0L;
+            Long kuaishouConvert = 0L;
+            Long kuaishouForm = 0L;
+            Long kuaishouNextDayOpen = 0L;
+            Long kuaishouActive = 0L;
+
+
             for (UserAllocation userAllocation : userAllocations) {
-                QueryWrapper<BytedanceAdvertiserDailyReport> bytedanceAdvertiserDailyReportQueryWrapper = new QueryWrapper<>();
-                bytedanceAdvertiserDailyReportQueryWrapper.eq("advertiser_id", userAllocation.getAccountId());
-                //   Map<String, Object> beforeDate = DateUtils.getBeforeDate();
-                //  bytedanceAdvertiserDailyReportQueryWrapper.between("stat_datetime", beforeDate.get("startDate"), beforeDate.get("endDate"));
-                bytedanceAdvertiserDailyReportQueryWrapper.between("stat_datetime", "2019-07-01 00:00:00", "2019-07-01 23:59:59");
-                bytedanceAdvertiserDailyReportQueryWrapper.orderByDesc("create_time");
-                bytedanceAdvertiserDailyReportQueryWrapper.last("limit 1");
-                BytedanceAdvertiserDailyReport bytedanceAdvertiserDailyReport = bytedanceAdvertiserDailyReportMapper.selectOne(bytedanceAdvertiserDailyReportQueryWrapper);
-
-                if (!Check.isNull(bytedanceAdvertiserDailyReport)) {
-                    byteDanceCost = byteDanceCost.add(bytedanceAdvertiserDailyReport.getCost());
-                    byteDanceClick += bytedanceAdvertiserDailyReport.getClick();
-                    byteDanceShow += bytedanceAdvertiserDailyReport.getShowNum();
-                    byteDanceConvert += bytedanceAdvertiserDailyReport.getConvertNum();
-                    byteDanceForm += bytedanceAdvertiserDailyReport.getForm();
-                    byteDanceNextDayOpen += bytedanceAdvertiserDailyReport.getNextDayOpen();
-                    byteDanceActive += bytedanceAdvertiserDailyReport.getActive();
-                }
+                if ("1".equals(userAllocation.getMediaId())) {
+                    QueryWrapper<BytedanceAdvertiserDailyReport> bytedanceAdvertiserDailyReportQueryWrapper = new QueryWrapper<>();
+                    bytedanceAdvertiserDailyReportQueryWrapper.eq("advertiser_id", userAllocation.getAccountId());
+                    //   Map<String, Object> beforeDate = DateUtils.getBeforeDate();
+                    //  bytedanceAdvertiserDailyReportQueryWrapper.between("stat_datetime", beforeDate.get("startDate"), beforeDate.get("endDate"));
+                    bytedanceAdvertiserDailyReportQueryWrapper.between("stat_datetime", "2019-07-01 00:00:00", "2019-07-01 23:59:59");
+                    bytedanceAdvertiserDailyReportQueryWrapper.orderByDesc("create_time");
+                    bytedanceAdvertiserDailyReportQueryWrapper.last("limit 1");
+                    BytedanceAdvertiserDailyReport bytedanceAdvertiserDailyReport = bytedanceAdvertiserDailyReportMapper.selectOne(bytedanceAdvertiserDailyReportQueryWrapper);
+                    if (!Check.isNull(bytedanceAdvertiserDailyReport)) {
+                        JSONObject bytedanceDetailJson = new JSONObject();
+                        BigDecimal cost = bytedanceAdvertiserDailyReport.getCost();
+                        bytedanceDetailJson.put("cost", cost); // 账号总消耗
+                        byteDanceCost = byteDanceCost.add(cost);
+                        Long click = bytedanceAdvertiserDailyReport.getClick();
+                        bytedanceDetailJson.put("click", click); // 账号总点击
+                        byteDanceClick += click;
+                        Long showNum = bytedanceAdvertiserDailyReport.getShowNum();
+                        bytedanceDetailJson.put("show", showNum); // 账号总展示
+                        byteDanceShow += showNum;
+                        Long convertNum = bytedanceAdvertiserDailyReport.getConvertNum();
+                        bytedanceDetailJson.put("convert", convertNum); // 账号总转化
+                        byteDanceConvert += convertNum;
+                        Long form = bytedanceAdvertiserDailyReport.getForm();
+                        bytedanceDetailJson.put("form", form); // 账号总表单提交
+                        byteDanceForm += form;
+                        Long nextDayOpen = bytedanceAdvertiserDailyReport.getNextDayOpen();
+                        bytedanceDetailJson.put("nextDayOpen", nextDayOpen); // 账号总次日留存
+                        byteDanceNextDayOpen += nextDayOpen;
+                        Long active = bytedanceAdvertiserDailyReport.getActive();
+                        bytedanceDetailJson.put("active", active); // 账号总激活
+                        byteDanceActive += active;
+                        bytedanceDetailJson.put("accountId", userAllocation.getAccountId()); // 账号
+                        bytedanceDetailJson.put("accountName", userAllocation.getAuthName()); // 账号 名称
+                        bytedanceDetail.add(bytedanceDetailJson);
+                    }
+
+                } else if ("2".equals(userAllocation.getMediaId())) {
+                    // 查询快手相关报表数据
+
+                    QueryWrapper<KuaishouReportDailyAccount> kuaishouReportDailyAccountQueryWrapper = new QueryWrapper<>();
+                    kuaishouReportDailyAccountQueryWrapper.eq("account_id", userAllocation.getAccountId());
+                    //  Map<String, Object> beforeDate = DateUtils.getBeforeDate();
+                    //  kuaishouReportDailyAccountQueryWrapper.between("stat_datetime", beforeDate.get("startDate"), beforeDate.get("endDate"));
+                    kuaishouReportDailyAccountQueryWrapper.between("stat_date", "2019-10-08 00:00:00", "2019-10-08 23:59:59");
+                    kuaishouReportDailyAccountQueryWrapper.orderByDesc("create_time");
+                    kuaishouReportDailyAccountQueryWrapper.last("limit 1");
+                    KuaishouReportDailyAccount reportDailyAccount = kuaishouReportDailyAccountMapper.selectOne(kuaishouReportDailyAccountQueryWrapper);
+                    if (!Check.isNull(reportDailyAccount)) {
+                        JSONObject kuaishouDetailJson = new JSONObject();
+                        kuaishouDetailJson.put("accountId", userAllocation.getAccountId());
+                        kuaishouDetailJson.put("accountName", userAllocation.getAuthName());
+
+                        BigDecimal cost = reportDailyAccount.getCharge();// 花费
+                        kuaishouDetailJson.put("cost", cost);
+                        kuaishouCost = kuaishouCost.add(cost);
+
+                        Long click = reportDailyAccount.getAclick();
+                        kuaishouDetailJson.put("click", click);
+                        kuaishouClick += click;
+
+                        Long show = reportDailyAccount.getShow();
+                        kuaishouDetailJson.put("show", show);
+                        kuaishouShow += show;
+
+                        Long convert = reportDailyAccount.getBclick();
+                        kuaishouDetailJson.put("convert", convert);
+                        kuaishouConvert += convert;
+
+                        Long form = reportDailyAccount.getSubmit();
+                        kuaishouDetailJson.put("form", form);
+                        kuaishouForm += form;
+
 
+                        Long active = reportDailyAccount.getActivation();
+                        kuaishouDetailJson.put("active", active);
+                        kuaishouActive += active;
+
+                        kuaishouDetail.add(kuaishouDetailJson);
+
+                    }
+
+                }
             }
             bytedanceJson.put("cost", byteDanceCost); // 总消耗
             bytedanceJson.put("click", byteDanceClick); // 总点击
@@ -78,15 +167,329 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             bytedanceJson.put("nextDayOpen", byteDanceNextDayOpen); // 总次留数
             bytedanceJson.put("active", byteDanceActive); // 总激活
 
-
             returnJson.put("bytedance", bytedanceJson);
+            returnJson.put("bytedanceDetail", bytedanceDetail);
+
+
+            kuaishouJson.put("cost", kuaishouCost);
+            kuaishouJson.put("click", kuaishouClick);
+            kuaishouJson.put("show", kuaishouShow);
+            kuaishouJson.put("convert", kuaishouConvert);
+            kuaishouJson.put("form", kuaishouForm);
+            kuaishouJson.put("nextDayOpen", 0);
+            kuaishouJson.put("active", kuaishouActive);
+            returnJson.put("kuaishou", kuaishouJson);
+            returnJson.put("kuaishouDetail", kuaishouDetail);
             System.err.println(returnJson);
 
         }
 
 
-        return null;
+        return returnJson;
+    }
+
+    /**
+     * 快手-大盘报表
+     *
+     * @param requestJson
+     * @return
+     */
+    @Override
+    public JSONObject getKuaiShouAccountReport(JSONObject requestJson) {
+        Integer type = requestJson.getInteger("type");
+        JSONObject accountJson = new JSONObject();
+
+        try {
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd"); // 当前日期
+            String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1); // 当前日期-1
+            if (type == 1) { // 今日总消耗
+                accountJson = reportMapper.selectDayReport(nowDate);
+                JSONObject yesterJson = reportMapper.selectYesterday(anotherDay);
+                if (!Check.isNull(yesterJson)) {
+                    BigDecimal cost = accountJson.getBigDecimal("cost"); // 今日消耗
+                    BigDecimal yesterCost = yesterJson.getBigDecimal("cost");// 昨日消耗
+                    BigDecimal compareBigDecima = new BigDecimal(0);
+                    if (yesterCost.compareTo(compareBigDecima) != 0) {
+                        BigDecimal costProportion = (cost.subtract(yesterCost)).divide(yesterCost, BigDecimal.ROUND_HALF_UP);
+                        accountJson.put("costProportion", costProportion); // 较昨日增加比例
+                    } else {
+                        accountJson.put("costProportion", 0); // 较昨日增加比例
+                    }
+
+                    Long photoShow = accountJson.getLong("photoShow");// 今日封面展示
+                    Long yesterPhotoShow = yesterJson.getLong("photoShow");// 昨日封面展示
+                    if (yesterPhotoShow != 0L) {
+                        double showProportion = (photoShow.doubleValue() - yesterPhotoShow.doubleValue()) / yesterPhotoShow.doubleValue();
+                        accountJson.put("showProportion", showProportion); // 较昨日增加比例
+                    } else {
+                        accountJson.put("showProportion", 0); // 较昨日增加比例
+                    }
+
+                    Long photoClick = accountJson.getLong("photoClick");// 今日封面展示
+                    Long yesterphotoClick = yesterJson.getLong("photoShow");// 昨日封面展示
+                    if (yesterPhotoShow != 0L) {
+                        double photoClickProportion = (photoClick.doubleValue() - yesterphotoClick.doubleValue()) / yesterphotoClick.doubleValue();
+                        accountJson.put("photoClickProportion", photoClickProportion); // 较昨日增加比例
+                    } else {
+                        accountJson.put("photoClickProportion", 0); // 较昨日增加比例
+                    }
+
+                    Long aclick = accountJson.getLong("aclick");// 今日封面展示
+                    Long yesterAclick = yesterJson.getLong("photoShow");// 昨日封面展示
+                    if (yesterPhotoShow != 0L) {
+                        double aClickProportion = (aclick.doubleValue() - yesterAclick.doubleValue()) / yesterAclick.doubleValue();
+                        accountJson.put("aClickProportion", aClickProportion); // 较昨日增加比例
+                    } else {
+                        accountJson.put("aClickProportion", 0); // 较昨日增加比例
+                    }
+
+                }
+
+            } else if (type == 2) { // 昨日总消耗
+                accountJson = reportMapper.selectYesterday(anotherDay);
+
+            } else if (type == 3) { // 近七天
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
+                accountJson = reportMapper.selectByDate(anotherDay, endDate);
+
+            } else if (type == 4) { // 近15天
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
+                accountJson = reportMapper.selectByDate(anotherDay, endDate);
+
+            } else if (type == 5) {// 近一个月
+                String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
+                accountJson = reportMapper.selectByDate(anotherDay, endDate);
+
+            } else if (type == 6) {// 近三个月
+                String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -3);
+                accountJson = reportMapper.selectByDate(anotherDay, endDate);
+
+            } else if (type == 7) {// 近六个月
+                String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -6);
+                accountJson = reportMapper.selectByDate(anotherDay, endDate);
+
+            } else if (type == 8) {  // 所有
+                accountJson = reportMapper.selectAllAccount();
+
+            } else if (type == 9) {  // 自定义查询日期
+                String startDate = requestJson.getString("startDate");
+                String endDate = requestJson.getString("endDate");
+                accountJson = reportMapper.selectByDate(startDate, endDate);
+            } else if (type == 10) {
+                String sign = requestJson.getString("sign");
+                String bigDate = requestJson.getString("bigDate");
+                String smallDate = requestJson.getString("smallDate");
+                if ("month".equals(sign)) {
+                    Map<String, Object> dateMap = DateUtils.compare_date("yyyy-MM", bigDate, smallDate);
+                    JSONObject beComparedJson = reportMapper.selectMonthReportByDate((String) dateMap.get("smallDate"));   // 被除数数据
+                    JSONObject comparedJson = reportMapper.selectMonthReportByDate((String) dateMap.get("bigDate"));   // 除数数据
+                    BigDecimal cost = comparedJson.getBigDecimal("cost");
+                    BigDecimal comparedCost = beComparedJson.getBigDecimal("cost");
+
+                    if (comparedCost.compareTo(new BigDecimal(0)) != 0) {
+                        BigDecimal costProportion = (cost.subtract(comparedCost)).divide(comparedCost, BigDecimal.ROUND_HALF_UP);
+                        comparedJson.put("costProportion", costProportion);
+                    } else {
+                        comparedJson.put("costProportion", 0);
+                    }
+
+                    Long photoClick = comparedJson.getLong("photoClick");
+                    Long comparedPhotoClick = beComparedJson.getLong("photoShow");
+                    if (comparedPhotoClick != 0L) {
+                        double photoClickProportion = (photoClick.doubleValue() - comparedPhotoClick.doubleValue()) / comparedPhotoClick.doubleValue();
+                        comparedJson.put("photoClickProportion", photoClickProportion);
+                    } else {
+                        comparedJson.put("photoClickProportion", 0);
+                    }
+                    Long comparedPhotoShow = beComparedJson.getLong("photoShow");
+                    Long photoShow = comparedJson.getLong("photoShow");
+                    if (comparedPhotoShow != 0L) {
+                        double showProportion = (photoShow.doubleValue() - comparedPhotoShow.doubleValue()) / comparedPhotoShow.doubleValue();
+                        comparedJson.put("showProportion", showProportion);
+                    } else {
+                        comparedJson.put("showProportion", 0);
+                    }
+                    Long aClick = comparedJson.getLong("aclick");
+                    Long comparedAclick = beComparedJson.getLong("photoShow");
+                    if (comparedAclick != 0L) {
+                        double aClickProportion = (aClick.doubleValue() - comparedAclick.doubleValue()) / comparedAclick.doubleValue();
+                        comparedJson.put("comparedAclick", aClickProportion);
+                    } else {
+                        comparedJson.put("comparedAclick", 0);
+                    }
+                    accountJson.put("beCompared", beComparedJson);
+                    accountJson.put("compared", comparedJson);
+                }
+
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return accountJson;
     }
 
+    @Override
+    public List<JSONObject> getKuaiShouAccounDetailtReport(JSONObject requestJson) {
+        Integer type = requestJson.getInteger("type");
+        List<JSONObject> detail = new ArrayList<>();
+        try {
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+            if (type == 1) { //  今日明细
+                List<JSONObject> dayDetail = reportMapper.selectReportDetail(nowDate);
+                for (int i = 0; i < dayDetail.size(); i++) {
+                    JSONObject detailJson = dayDetail.get(i);
+                    String statHour = detailJson.getString("statHour");
+
+                    JSONObject yesterDayJson = reportMapper.selectYesterdayByHourAndDate(anotherDay, statHour);
+                    if (!Check.isNull(yesterDayJson)) {
+                        BigDecimal cost = detailJson.getBigDecimal("cost"); // 今日消耗
+                        BigDecimal yesterCost = yesterDayJson.getBigDecimal("cost");// 昨日消耗
+                        BigDecimal compareBigDecima = new BigDecimal(0);
+                        if (yesterCost.compareTo(compareBigDecima) != 0) {
+                            BigDecimal costProportion = (cost.subtract(yesterCost)).divide(yesterCost, BigDecimal.ROUND_HALF_UP);
+                            detailJson.put("proportion", costProportion); // 较昨日增加比例
+                        } else {
+                            detailJson.put("proportion", 0); // 较昨日增加比例
+                        }
+                        Long photoShow = detailJson.getLong("photoShow");// 今日封面展示
+                        Long yesterPhotoShow = yesterDayJson.getLong("photoShow");// 昨日封面展示
+                        if (yesterPhotoShow != 0L) {
+                            double showProportion = (photoShow.doubleValue() - yesterPhotoShow.doubleValue()) / yesterPhotoShow.doubleValue();
+                            detailJson.put("proportion", showProportion); // 较昨日增加比例
+                        } else {
+                            detailJson.put("proportion", 0); // 较昨日增加比例
+                        }
 
+                        Long photoClick = detailJson.getLong("photoClick");// 今日封面展示
+                        Long yesterphotoClick = yesterDayJson.getLong("photoShow");// 昨日封面展示
+                        if (yesterPhotoShow != 0L) {
+                            double photoClickroportion = (photoClick.doubleValue() - yesterphotoClick.doubleValue()) / yesterphotoClick.doubleValue();
+                            detailJson.put("proportion", photoClickroportion); // 较昨日增加比例
+                        } else {
+                            detailJson.put("proportion", 0); // 较昨日增加比例
+                        }
+                        Long aclick = detailJson.getLong("aclick");// 今日封面展示
+                        Long yesterAclick = yesterDayJson.getLong("photoShow");// 昨日封面展示
+                        if (yesterPhotoShow != 0L) {
+                            double aClickProportion = (aclick.doubleValue() - yesterAclick.doubleValue()) / yesterAclick.doubleValue();
+                            detailJson.put("proportion", aClickProportion); // 较昨日增加比例
+                        } else {
+                            detailJson.put("proportion", 0); // 较昨日增加比例
+                        }
+                        detail.add(detailJson);
+                    }
+
+                }
+                System.err.println(detail);
+            } else if (type == 2) { // 昨日明细
+                detail = reportMapper.selectReportDetail(anotherDay);
+                System.err.println(detail);
+            } else if (type == 3) { // 近七天明细
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
+                detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
+
+            } else if (type == 4) { // 近十五天明细
+                String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -15);
+                detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
+            } else if (type == 5) { // 近1个月明细
+                String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -1);
+                detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
+            } else if (type == 6) { // 近三个月明细
+                String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -3);
+                detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
+            } else if (type == 7) { // 近半年明细
+                String endDate = DateUtils.getMonthBefore("yyyy-MM-dd", anotherDay, -6);
+                detail = reportMapper.selectDayDetailByMonth(anotherDay, endDate);
+            } else if (type == 8) {
+                detail = reportMapper.selectAllDayDetailByMonth();
+            } else if (type == 9) {
+                String startDate = requestJson.getString("startDate");
+                String endDate = requestJson.getString("endDate");
+                detail = reportMapper.selectDayDetailByDate(startDate, endDate);
+            } else if (type == 10) {
+                String sign = requestJson.getString("sign");
+                String bigDate = requestJson.getString("bigDate");
+                String smallDate = requestJson.getString("smallDate");
+                if ("month".equals(sign)) {
+                    Map<String, Object> dateMap = DateUtils.compare_date("yyyy-MM", bigDate, smallDate);
+                    List<JSONObject> comparedArr = reportMapper.selectDayDetailsByMonth((String) dateMap.get("bigDate"));   // 除数数据
+                    String comparedDate = (String) dateMap.get("bigDate");
+                    for (int i = 0; i < comparedArr.size(); i++) {
+                        JSONObject comparedJson = comparedArr.get(i);
+                        if (!Check.isNull(comparedJson)) {
+                            String statDate = comparedJson.getString("statDate");
+                            String day = DateUtils.getDay("yyyy-MM-dd", statDate);
+                            String beComparedDate = comparedDate + "-" + day;
+                            JSONObject beComparedJson = reportMapper.selectDayDailyByDate(beComparedDate);
+                            if (!Check.isNull(beComparedJson)) {
+                                JSONObject json = new JSONObject();
+                                BigDecimal cost = comparedJson.getBigDecimal("cost");
+                                Long photoShow = comparedJson.getLong("photoShow");
+                                Long photoClick = comparedJson.getLong("photoClick");
+                                Long aClick = comparedJson.getLong("aclick");
+                                json.put("cost", cost);
+                                json.put("photoShow", photoShow);
+                                json.put("photoClick", photoClick);
+                                json.put("aClick", aClick);
+                                json.put("statDate", statDate);
+
+                                BigDecimal comparedCost = beComparedJson.getBigDecimal("cost");
+                                Long comparedPhotoShow = beComparedJson.getLong("photoShow");
+                                Long comparedPhotoClick = beComparedJson.getLong("photoClick");
+                                Long comparedAClick = beComparedJson.getLong("aclick");
+                                json.put("beComparedCost", comparedCost);
+                                json.put("beComparedPhotoShow", comparedPhotoShow);
+                                json.put("beComparedPhotoClick", comparedPhotoClick);
+                                json.put("beComparedAClick", comparedAClick);
+                                json.put("beComparedDate", beComparedDate);
+                                if (comparedCost.compareTo(new BigDecimal(0)) != 0) {
+                                    BigDecimal costProportion = (cost.subtract(comparedCost)).divide(comparedCost, BigDecimal.ROUND_HALF_UP);
+                                    json.put("costProportion", costProportion);
+                                } else {
+                                    json.put("costProportion", 0);
+                                }
+
+                                if (comparedPhotoClick != 0L) {
+                                    double photoClickProportion = (photoClick.doubleValue() - comparedPhotoClick.doubleValue()) / comparedPhotoClick.doubleValue();
+                                    json.put("photoClickProportion", photoClickProportion);
+                                } else {
+                                    json.put("photoClickProportion", 0);
+                                }
+
+                                if (comparedPhotoShow != 0L) {
+                                    double showProportion = (photoShow.doubleValue() - comparedPhotoShow.doubleValue()) / comparedPhotoShow.doubleValue();
+                                    json.put("showProportion", showProportion);
+                                } else {
+                                    json.put("showProportion", 0);
+                                }
+
+                                if (comparedAClick != 0L) {
+                                    double aClickProportion = (aClick.doubleValue() - comparedAClick.doubleValue()) / comparedAClick.doubleValue();
+                                    json.put("comparedAclick", aClickProportion);
+                                } else {
+                                    json.put("comparedAclick", 0);
+                                }
+
+                                detail.add(json);
+
+                            }
+
+                        }
+
+                    }
+
+
+                }
+
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+
+        }
+
+
+        return detail;
+    }
 }

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/controller/ByteDanceBudgetTemplateController.java

@@ -247,6 +247,6 @@ public class ByteDanceBudgetTemplateController {
             }
         }
         return Result.ok("文件导入失败!");
- }
+    }
 
 }

+ 175 - 110
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceAdvertisePlan.java

@@ -14,9 +14,10 @@ import java.math.BigDecimal;
 
 /**
  * 今日头条广告计划信息
+ *
  * @author jeecg-boot
- * @date 2019-07-22
  * @version V1.0
+ * @date 2019-07-22
  */
 @Data
 @TableName("ctop_bytedance_advertise_plan")
@@ -25,160 +26,224 @@ import java.math.BigDecimal;
 @ApiModel(value = "ctop_bytedance_advertise_plan对象", description = "今日头条广告计划信息")
 public class ByteDanceAdvertisePlan {
 
-    /**头条平台广告计划id*/
+    /**
+     * 头条平台广告计划id
+     */
     @TableId
     @ApiModelProperty(value = "头条平台广告计划id")
-	private Long id;
-	/**平台广告主id*/
-	@Excel(name = "平台广告主id", width = 15)
+    private Long id;
+    /**
+     * 平台广告主id
+     */
+    @Excel(name = "平台广告主id", width = 15)
     @ApiModelProperty(value = "平台广告主id")
-	private String advertiserId;
-	/**头条广告主id*/
-	@Excel(name = "头条广告主id", width = 15)
+    private String advertiserId;
+    /**
+     * 头条广告主id
+     */
+    @Excel(name = "头条广告主id", width = 15)
     @ApiModelProperty(value = "头条广告主id")
-	private Long toutiaoId;
-	/**计划名称*/
-	@Excel(name = "计划名称", width = 15)
+    private Long toutiaoId;
+    /**
+     * 计划名称
+     */
+    @Excel(name = "计划名称", width = 15)
     @ApiModelProperty(value = "计划名称")
-	private String name;
-	/**广告组id*/
-	@Excel(name = "广告组id", width = 15)
+    private String name;
+    /**
+     * 广告组id
+     */
+    @Excel(name = "广告组id", width = 15)
     @ApiModelProperty(value = "广告组id")
-	private Long campaignId;
-	/**上次修改时间戳(用于更新时提交,服务端判断是否基于最新信息修改)*/
-	@Excel(name = "上次修改时间戳(用于更新时提交,服务端判断是否基于最新信息修改)", width = 15)
+    private Long campaignId;
+    /**
+     * 上次修改时间戳(用于更新时提交,服务端判断是否基于最新信息修改)
+     */
+    @Excel(name = "上次修改时间戳(用于更新时提交,服务端判断是否基于最新信息修改)", width = 15)
     @ApiModelProperty(value = "上次修改时间戳(用于更新时提交,服务端判断是否基于最新信息修改)")
-	private String planModifyTime;
-	/**投放范围*/
-	@Excel(name = "投放范围", width = 15)
+    private String planModifyTime;
+    /**
+     * 投放范围
+     */
+    @Excel(name = "投放范围", width = 15)
     @ApiModelProperty(value = "投放范围")
-	private String deliveryRange;
-	/**计划上次修改时间*/
-	@Excel(name = "计划上次修改时间", width = 15)
+    private String deliveryRange;
+    /**
+     * 计划上次修改时间
+     */
+    @Excel(name = "计划上次修改时间", width = 15)
     @ApiModelProperty(value = "计划上次修改时间")
-	private String adModifyTime;
-	/**计划创建时间*/
-	@Excel(name = "计划创建时间", width = 15)
+    private String adModifyTime;
+    /**
+     * 计划创建时间
+     */
+    @Excel(name = "计划创建时间", width = 15)
     @ApiModelProperty(value = "计划创建时间")
-	private String adCreateTime;
-	/**广告预算类型*/
-	@Excel(name = "广告预算类型", width = 15)
+    private String adCreateTime;
+    /**
+     * 广告预算类型
+     */
+    @Excel(name = "广告预算类型", width = 15)
     @ApiModelProperty(value = "广告预算类型")
-	private String budgetMode;
-	/**广告预算*/
-	@Excel(name = "广告预算", width = 15)
+    private String budgetMode;
+    /**
+     * 广告预算
+     */
+    @Excel(name = "广告预算", width = 15)
     @ApiModelProperty(value = "广告预算")
     private BigDecimal budget;
-	/**广告计划投放状态*/
-	@Excel(name = "广告计划投放状态", width = 15)
+    /**
+     * 广告计划投放状态
+     */
+    @Excel(name = "广告计划投放状态", width = 15)
     @ApiModelProperty(value = "广告计划投放状态")
-	private String toutiaoStatus;
-	/**广告计划操作状态*/
-	@Excel(name = "广告计划操作状态", width = 15)
+    private String toutiaoStatus;
+    /**
+     * 广告计划操作状态
+     */
+    @Excel(name = "广告计划操作状态", width = 15)
     @ApiModelProperty(value = "广告计划操作状态")
-	private String optStatus;
-	/**广告投放起始时间*/
-	@Excel(name = "广告投放起始时间", width = 15)
+    private String optStatus;
+    /**
+     * 广告投放起始时间
+     */
+    @Excel(name = "广告投放起始时间", width = 15)
     @ApiModelProperty(value = "广告投放起始时间")
-	private String startTime;
-	/**广告投放结束时间*/
-	@Excel(name = "广告投放结束时间", width = 15)
+    private String startTime;
+    /**
+     * 广告投放结束时间
+     */
+    @Excel(name = "广告投放结束时间", width = 15)
     @ApiModelProperty(value = "广告投放结束时间")
-	private String endTime;
-	/**广告出价*/
-	@Excel(name = "广告出价", width = 15)
+    private String endTime;
+    /**
+     * 广告出价
+     */
+    @Excel(name = "广告出价", width = 15)
     @ApiModelProperty(value = "广告出价")
     private BigDecimal bid;
-	/**广告出价类型*/
-	@Excel(name = "广告出价类型", width = 15)
+    /**
+     * 广告出价类型
+     */
+    @Excel(name = "广告出价类型", width = 15)
     @ApiModelProperty(value = "广告出价类型")
-	private String pricing;
-	/**广告投放时间类型*/
-	@Excel(name = "广告投放时间类型", width = 15)
+    private String pricing;
+    /**
+     * 广告投放时间类型
+     */
+    @Excel(name = "广告投放时间类型", width = 15)
     @ApiModelProperty(value = "广告投放时间类型")
-	private String scheduleType;
-	/**广告投放时段*/
-	@Excel(name = "广告投放时段", width = 15)
+    private String scheduleType;
+    /**
+     * 广告投放时段
+     */
+    @Excel(name = "广告投放时段", width = 15)
     @ApiModelProperty(value = "广告投放时段")
-	private String scheduleTime;
-	/**广告投放速度类型*/
-	@Excel(name = "广告投放速度类型", width = 15)
+    private String scheduleTime;
+    /**
+     * 广告投放速度类型
+     */
+    @Excel(name = "广告投放速度类型", width = 15)
     @ApiModelProperty(value = "广告投放速度类型")
-	private String flowControlMode;
-	/**应用直达链接*/
-	@Excel(name = "应用直达链接", width = 15)
+    private String flowControlMode;
+    /**
+     * 应用直达链接
+     */
+    @Excel(name = "应用直达链接", width = 15)
     @ApiModelProperty(value = "应用直达链接")
-	private String openUrl;
-	/**应用下载方式*/
-	@Excel(name = "应用下载方式", width = 15)
+    private String openUrl;
+    /**
+     * 应用下载方式
+     */
+    @Excel(name = "应用下载方式", width = 15)
     @ApiModelProperty(value = "应用下载方式")
-	private String downloadType;
-	/**广告落地页链接*/
-	@Excel(name = "广告落地页链接", width = 15)
+    private String downloadType;
+    /**
+     * 广告落地页链接
+     */
+    @Excel(name = "广告落地页链接", width = 15)
     @ApiModelProperty(value = "广告落地页链接")
-	private String externalUrl;
-	/**广告应用下载包名*/
-	@Excel(name = "广告应用下载包名", width = 15)
+    private String externalUrl;
+    /**
+     * 广告应用下载包名
+     */
+    @Excel(name = "广告应用下载包名", width = 15)
     @ApiModelProperty(value = "广告应用下载包名")
-	private String toutiaoPackage;
-	/**广告应用下载类型*/
-	@Excel(name = "广告应用下载类型", width = 15)
+    private String toutiaoPackage;
+    /**
+     * 广告应用下载类型
+     */
+    @Excel(name = "广告应用下载类型", width = 15)
     @ApiModelProperty(value = "广告应用下载类型")
-	private String appType;
-	/**广告计划审核不通过原因*/
-	@Excel(name = "广告计划审核不通过原因", width = 15)
+    private String appType;
+    /**
+     * 广告计划审核不通过原因
+     */
+    @Excel(name = "广告计划审核不通过原因", width = 15)
     @ApiModelProperty(value = "广告计划审核不通过原因")
-	private String auditRejectReason;
-	/**ocpc广告转化出价*/
-	@Excel(name = "ocpc广告转化出价", width = 15)
+    private String auditRejectReason;
+    /**
+     * ocpc广告转化出价
+     */
+    @Excel(name = "ocpc广告转化出价", width = 15)
     @ApiModelProperty(value = "ocpc广告转化出价")
     private BigDecimal cpaBid;
-	/**ocpc广告是否跳过第一阶段*/
-	@Excel(name = "ocpc广告是否跳过第一阶段", width = 15)
+    /**
+     * ocpc广告是否跳过第一阶段
+     */
+    @Excel(name = "ocpc广告是否跳过第一阶段", width = 15)
     @ApiModelProperty(value = "ocpc广告是否跳过第一阶段")
-	private Integer cpaSkipFirstPhrase;
-	/**转化类型广告的转化工具id*/
-	@Excel(name = "转化类型广告的转化工具id", width = 15)
+    private Integer cpaSkipFirstPhrase;
+    /**
+     * 转化类型广告的转化工具id
+     */
+    @Excel(name = "转化类型广告的转化工具id", width = 15)
     @ApiModelProperty(value = "转化类型广告的转化工具id")
-	private Long convertId;
-	/**过滤已转化用户类型字段*/
-	@Excel(name = "过滤已转化用户类型字段", width = 15)
+    private Long convertId;
+    /**
+     * 过滤已转化用户类型字段
+     */
+    @Excel(name = "过滤已转化用户类型字段", width = 15)
     @ApiModelProperty(value = "过滤已转化用户类型字段")
-	private String hideIfConverted;
-	/**过滤已安装,当推广目标为安卓应用下载时可填*/
-	@Excel(name = "过滤已安装,当推广目标为安卓应用下载时可填", width = 15)
+    private String hideIfConverted;
+    /**
+     * 过滤已安装,当推广目标为安卓应用下载时可填
+     */
+    @Excel(name = "过滤已安装,当推广目标为安卓应用下载时可填", width = 15)
     @ApiModelProperty(value = "过滤已安装,当推广目标为安卓应用下载时可填")
-	private Integer hideIfExists;
-	/**audience*/
-	@Excel(name = "audience", width = 15)
+    private Integer hideIfExists;
+    /**
+     * audience
+     */
+    @Excel(name = "audience", width = 15)
     @ApiModelProperty(value = "audience")
-	private Object audience;
+    private Object audience;
     @Excel(name = "上次修改时间", width = 15)
     @ApiModelProperty(value = "上次修改时间")
     private String modifyTime;
 
     public ByteDanceAdvertisePlan(JSONObject dataObject, String accountId) {
-		Long id = dataObject.getLong("id");
-		this.id=id;
-		this.advertiserId = accountId;
-		String name = dataObject.getString("name");
-		if (null!=name&&!"".equals(name.trim())){
-			this.name =name;
-		}
-
-		Long advertiserId = dataObject.getLong("advertiser_id");
-		if (null!=advertiserId){
-			this.toutiaoId =advertiserId;
-		}
-		Long campaignId = dataObject.getLong("campaign_id");
-		if (null!=campaignId){
-			this.campaignId =campaignId;
-		}
+        Long id = dataObject.getLong("id");
+        this.id = id;
+        this.advertiserId = accountId;
+        String name = dataObject.getString("name");
+        if (null != name && !"".equals(name.trim())) {
+            this.name = name;
+        }
+
+        Long advertiserId = dataObject.getLong("advertiser_id");
+        if (null != advertiserId) {
+            this.toutiaoId = advertiserId;
+        }
+        Long campaignId = dataObject.getLong("campaign_id");
+        if (null != campaignId) {
+            this.campaignId = campaignId;
+        }
 
         String budgetMode = dataObject.getString("budget_mode");
         if (null != budgetMode && !"".equals(budgetMode.trim())) {
             this.budgetMode = budgetMode;
-		}
+        }
         String modifyTime = dataObject.getString("modify_time");
         if (null != modifyTime && !"".equals(modifyTime.trim())) {
             this.modifyTime = modifyTime;

+ 213 - 160
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceAdvertiser.java

@@ -15,9 +15,10 @@ import java.util.Date;
 
 /**
  * 今日头条广告主信息
+ *
  * @author jeecg-boot
- * @date 2019-07-22
  * @version V1.0
+ * @date 2019-07-22
  */
 @Data
 @TableName("ctop_bytedance_advertiser")
@@ -26,217 +27,269 @@ import java.util.Date;
 @ApiModel(value = "ctop_bytedance_advertiser对象", description = "今日头条广告主信息")
 public class ByteDanceAdvertiser {
 
-    /**外部平台头条id*/
+    /**
+     * 外部平台头条id
+     */
     @TableId
     @ApiModelProperty(value = "外部平台头条id")
-	private Long id;
-	/**本平台id*/
-	@Excel(name = "本平台id", width = 15)
+    private Long id;
+    /**
+     * 本平台id
+     */
+    @Excel(name = "本平台id", width = 15)
     @ApiModelProperty(value = "本平台id")
-	private String advertiserId;
-	/**头条账户名*/
-	@Excel(name = "头条账户名", width = 15)
+    private String advertiserId;
+    /**
+     * 头条账户名
+     */
+    @Excel(name = "头条账户名", width = 15)
     @ApiModelProperty(value = "头条账户名")
-	private String name;
-	/**品牌描述,即推广内容*/
-	@Excel(name = "品牌描述,即推广内容", width = 15)
+    private String name;
+    /**
+     * 品牌描述,即推广内容
+     */
+    @Excel(name = "品牌描述,即推广内容", width = 15)
     @ApiModelProperty(value = "品牌描述,即推广内容")
-	private String description;
-	/**邮箱*/
-	@Excel(name = "邮箱", width = 15)
+    private String description;
+    /**
+     * 邮箱
+     */
+    @Excel(name = "邮箱", width = 15)
     @ApiModelProperty(value = "邮箱")
-	private String email;
-	/**联系人*/
-	@Excel(name = "联系人", width = 15)
+    private String email;
+    /**
+     * 联系人
+     */
+    @Excel(name = "联系人", width = 15)
     @ApiModelProperty(value = "联系人")
-	private String contacter;
-	/**手机号*/
-	@Excel(name = "手机号", width = 15)
+    private String contacter;
+    /**
+     * 手机号
+     */
+    @Excel(name = "手机号", width = 15)
     @ApiModelProperty(value = "手机号")
-	private String phonenumber;
-	@Excel(name = "角色", width = 15)
+    private String phonenumber;
+    @Excel(name = "角色", width = 15)
     @ApiModelProperty(value = "角色")
     private String role;
-	@Excel(name = "广告主状态", width = 15)
+    @Excel(name = "广告主状态", width = 15)
     @ApiModelProperty(value = "广告主状态")
     private String toutiaoStatus;
-	/**固定电话*/
-	@Excel(name = "固定电话", width = 15)
+    /**
+     * 固定电话
+     */
+    @Excel(name = "固定电话", width = 15)
     @ApiModelProperty(value = "固定电话")
     private String telephone;
-	/**地址*/
-	@Excel(name = "地址", width = 15)
+    /**
+     * 地址
+     */
+    @Excel(name = "地址", width = 15)
     @ApiModelProperty(value = "地址")
     private String address;
-	/**执照预览地址(链接默认1小时内有效)*/
-	@Excel(name = "执照预览地址(链接默认1小时内有效)", width = 15)
+    /**
+     * 执照预览地址(链接默认1小时内有效)
+     */
+    @Excel(name = "执照预览地址(链接默认1小时内有效)", width = 15)
     @ApiModelProperty(value = "执照预览地址(链接默认1小时内有效)")
     private String licenseUrl;
-	/**执照编号*/
-	@Excel(name = "执照编号", width = 15)
+    /**
+     * 执照编号
+     */
+    @Excel(name = "执照编号", width = 15)
     @ApiModelProperty(value = "执照编号")
     private String licenseNo;
-	/**执照省份*/
-	@Excel(name = "执照省份", width = 15)
+    /**
+     * 执照省份
+     */
+    @Excel(name = "执照省份", width = 15)
     @ApiModelProperty(value = "执照省份")
     private String licenseProvince;
-	/**执照城市*/
-	@Excel(name = "执照城市", width = 15)
+    /**
+     * 执照城市
+     */
+    @Excel(name = "执照城市", width = 15)
     @ApiModelProperty(value = "执照城市")
     private String licenseCity;
-	/**公司名称*/
-	@Excel(name = "公司名称", width = 15)
+    /**
+     * 公司名称
+     */
+    @Excel(name = "公司名称", width = 15)
     @ApiModelProperty(value = "公司名称")
     private String company;
-	/**经营类别*/
-	@Excel(name = "经营类别", width = 15)
+    /**
+     * 经营类别
+     */
+    @Excel(name = "经营类别", width = 15)
     @ApiModelProperty(value = "经营类别")
     private String brand;
-	/**运营区域*/
-	@Excel(name = "运营区域", width = 15)
+    /**
+     * 运营区域
+     */
+    @Excel(name = "运营区域", width = 15)
     @ApiModelProperty(value = "运营区域")
     private String promotionArea;
-	/**运营省份*/
-	@Excel(name = "运营省份", width = 15)
+    /**
+     * 运营省份
+     */
+    @Excel(name = "运营省份", width = 15)
     @ApiModelProperty(value = "运营省份")
     private String promotionCenterProvince;
-	/**运营城市*/
-	@Excel(name = "运营城市", width = 15)
+    /**
+     * 运营城市
+     */
+    @Excel(name = "运营城市", width = 15)
     @ApiModelProperty(value = "运营城市")
     private String promotionCenterCity;
-	/**一级行业名称*/
-	@Excel(name = "一级行业名称", width = 15)
+    /**
+     * 一级行业名称
+     */
+    @Excel(name = "一级行业名称", width = 15)
     @ApiModelProperty(value = "一级行业名称")
     private String firstIndustryName;
-	/**二级行业名称*/
-	@Excel(name = "二级行业名称", width = 15)
+    /**
+     * 二级行业名称
+     */
+    @Excel(name = "二级行业名称", width = 15)
     @ApiModelProperty(value = "二级行业名称")
     private String secondIndustryName;
-	/**审核拒绝原因*/
-	@Excel(name = "审核拒绝原因", width = 15)
+    /**
+     * 审核拒绝原因
+     */
+    @Excel(name = "审核拒绝原因", width = 15)
     @ApiModelProperty(value = "审核拒绝原因")
     private String reason;
-	/**账户总余额,单位元*/
-	@Excel(name = "账户总余额,单位元", width = 15)
+    /**
+     * 账户总余额,单位元
+     */
+    @Excel(name = "账户总余额,单位元", width = 15)
     @ApiModelProperty(value = "账户总余额,单位元")
     private BigDecimal balance;
-	/**头条平台中广告主创建时间*/
-	@Excel(name = "头条平台中广告主创建时间", width = 15)
+    /**
+     * 头条平台中广告主创建时间
+     */
+    @Excel(name = "头条平台中广告主创建时间", width = 15)
     @ApiModelProperty(value = "头条平台中广告主创建时间")
     private String toutiaoCreateTime;
-	/**数据状态*/
-	@Excel(name = "数据状态", width = 15)
+    /**
+     * 数据状态
+     */
+    @Excel(name = "数据状态", width = 15)
     @ApiModelProperty(value = "数据状态")
     private Integer status;
-	/**createTime*/
+    /**
+     * createTime
+     */
     @ApiModelProperty(value = "createTime")
     private Date createTime;
-	/**updateTime*/
+    /**
+     * updateTime
+     */
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
 
     public ByteDanceAdvertiser(JSONObject dataObject, String accountId) {
-		Long id = dataObject.getLong("id");
-		this.id=id;
-		this.advertiserId = accountId;
-		String name = dataObject.getString("name");
-		if (null!=name&&!"".equals(name.trim())){
-			this.name =name;
-		}
-		String description = dataObject.getString("description");
-		if (null!=description&&!"".equals(description.trim())){
-			this.description = description;
-		}
-		String email = dataObject.getString("email");
-		if (null!=email&&!"".equals(email.trim())){
-			this.email = email;
-		}
-		String contacter = dataObject.getString("contacter");
-		if (null!=contacter&&!"".equals(contacter.trim())){
-			this.contacter = contacter;
-		}
-		String phonenumber = dataObject.getString("phonenumber");
-		if (null!=phonenumber&&!"".equals(phonenumber.trim())){
-			this.phonenumber = phonenumber;
-		}
-		String role = dataObject.getString("role");
-		if (null!=role&&!"".equals(role.trim())){
-			this.role = role;
-		}
-		String status = dataObject.getString("status");
-		if (null!=status&&!"".equals(status.trim())){
-			this.toutiaoStatus = status;
-		}
-		String telephone = dataObject.getString("telephone");
-		if (null!=telephone&&!"".equals(telephone.trim())){
-			this.telephone = telephone;
-		}
-		String address = dataObject.getString("address");
-		if (null!=address&&!"".equals(address.trim())){
-			this.address = address;
-		}
-		String licenseUrl = dataObject.getString("license_url");
-		if (null!=licenseUrl&&!"".equals(licenseUrl.trim())){
-			this.licenseUrl = licenseUrl;
-		}
-		String licenseNo = dataObject.getString("license_no");
-		if (null!=licenseNo&&!"".equals(licenseNo.trim())){
-			this.licenseNo = licenseNo;
-		}
-		String licenseProvince = dataObject.getString("license_province");
-		if (null!=licenseProvince&&!"".equals(licenseProvince.trim())){
-			this.licenseProvince = licenseProvince;
-		}
-		String licenseCity  = dataObject.getString("license_city ");
-		if (null!=licenseCity&&!"".equals(licenseCity.trim())){
-			this.licenseCity = licenseCity;
-		}
-		String company = dataObject.getString("company");
-		if (null!=company&&!"".equals(company.trim())){
-			this.company = company;
-		}
-		String brand = dataObject.getString("brand");
-		if (null!=brand&&!"".equals(brand.trim())){
-			this.brand = brand;
-		}
-		String promotionArea = dataObject.getString("promotion_area");
-		if (null!=promotionArea&&!"".equals(promotionArea.trim())){
-			this.promotionArea = promotionArea;
-		}
-		String promotionCenterProvince  = dataObject.getString("promotion_center_province ");
-		if (null!=promotionCenterProvince&&!"".equals(promotionCenterProvince.trim())){
-			this.promotionCenterProvince = promotionCenterProvince;
-		}
-		String promotionCenterCity = dataObject.getString("promotion_center_city");
-		if (null!=promotionCenterCity&&!"".equals(promotionCenterCity.trim())){
-			this.promotionCenterCity = promotionCenterCity;
-		}
-		String firstIndustryName  = dataObject.getString("first_industry_name ");
-		if (null!=firstIndustryName&&!"".equals(firstIndustryName.trim())){
-			this.firstIndustryName = firstIndustryName;
-		}
-		String secondIndustryName = dataObject.getString("second_industry_name");
-		if (null!=secondIndustryName&&!"".equals(secondIndustryName.trim())){
-			this.secondIndustryName = secondIndustryName;
-		}
-		String reason = dataObject.getString("reason");
-		if (null!=reason&&!"".equals(reason.trim())){
-			this.reason = reason;
-		}
-		BigDecimal balance = dataObject.getBigDecimal("balance");
-		if (null!=balance){
-			this.balance = balance;
-		}
-		String createTime  = dataObject.getString("create_time ");
-		if (null!=createTime &&!"".equals(createTime .trim())){
-			this.toutiaoCreateTime = createTime;
-		}
-		Date now = new Date();
-		this.createTime = now;
-		this.updateTime = now;
-	}
+        Long id = dataObject.getLong("id");
+        this.id = id;
+        this.advertiserId = accountId;
+        String name = dataObject.getString("name");
+        if (null != name && !"".equals(name.trim())) {
+            this.name = name;
+        }
+        String description = dataObject.getString("description");
+        if (null != description && !"".equals(description.trim())) {
+            this.description = description;
+        }
+        String email = dataObject.getString("email");
+        if (null != email && !"".equals(email.trim())) {
+            this.email = email;
+        }
+        String contacter = dataObject.getString("contacter");
+        if (null != contacter && !"".equals(contacter.trim())) {
+            this.contacter = contacter;
+        }
+        String phonenumber = dataObject.getString("phonenumber");
+        if (null != phonenumber && !"".equals(phonenumber.trim())) {
+            this.phonenumber = phonenumber;
+        }
+        String role = dataObject.getString("role");
+        if (null != role && !"".equals(role.trim())) {
+            this.role = role;
+        }
+        String status = dataObject.getString("status");
+        if (null != status && !"".equals(status.trim())) {
+            this.toutiaoStatus = status;
+        }
+        String telephone = dataObject.getString("telephone");
+        if (null != telephone && !"".equals(telephone.trim())) {
+            this.telephone = telephone;
+        }
+        String address = dataObject.getString("address");
+        if (null != address && !"".equals(address.trim())) {
+            this.address = address;
+        }
+        String licenseUrl = dataObject.getString("license_url");
+        if (null != licenseUrl && !"".equals(licenseUrl.trim())) {
+            this.licenseUrl = licenseUrl;
+        }
+        String licenseNo = dataObject.getString("license_no");
+        if (null != licenseNo && !"".equals(licenseNo.trim())) {
+            this.licenseNo = licenseNo;
+        }
+        String licenseProvince = dataObject.getString("license_province");
+        if (null != licenseProvince && !"".equals(licenseProvince.trim())) {
+            this.licenseProvince = licenseProvince;
+        }
+        String licenseCity = dataObject.getString("license_city ");
+        if (null != licenseCity && !"".equals(licenseCity.trim())) {
+            this.licenseCity = licenseCity;
+        }
+        String company = dataObject.getString("company");
+        if (null != company && !"".equals(company.trim())) {
+            this.company = company;
+        }
+        String brand = dataObject.getString("brand");
+        if (null != brand && !"".equals(brand.trim())) {
+            this.brand = brand;
+        }
+        String promotionArea = dataObject.getString("promotion_area");
+        if (null != promotionArea && !"".equals(promotionArea.trim())) {
+            this.promotionArea = promotionArea;
+        }
+        String promotionCenterProvince = dataObject.getString("promotion_center_province ");
+        if (null != promotionCenterProvince && !"".equals(promotionCenterProvince.trim())) {
+            this.promotionCenterProvince = promotionCenterProvince;
+        }
+        String promotionCenterCity = dataObject.getString("promotion_center_city");
+        if (null != promotionCenterCity && !"".equals(promotionCenterCity.trim())) {
+            this.promotionCenterCity = promotionCenterCity;
+        }
+        String firstIndustryName = dataObject.getString("first_industry_name ");
+        if (null != firstIndustryName && !"".equals(firstIndustryName.trim())) {
+            this.firstIndustryName = firstIndustryName;
+        }
+        String secondIndustryName = dataObject.getString("second_industry_name");
+        if (null != secondIndustryName && !"".equals(secondIndustryName.trim())) {
+            this.secondIndustryName = secondIndustryName;
+        }
+        String reason = dataObject.getString("reason");
+        if (null != reason && !"".equals(reason.trim())) {
+            this.reason = reason;
+        }
+        BigDecimal balance = dataObject.getBigDecimal("balance");
+        if (null != balance) {
+            this.balance = balance;
+        }
+        String createTime = dataObject.getString("create_time ");
+        if (null != createTime && !"".equals(createTime.trim())) {
+            this.toutiaoCreateTime = createTime;
+        }
+        Date now = new Date();
+        this.createTime = now;
+        this.updateTime = now;
+    }
 
-	public ByteDanceAdvertiser() {
+    public ByteDanceAdvertiser() {
 
-	}
+    }
 }

+ 29 - 20
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceAdvertiserBudget.java

@@ -15,9 +15,10 @@ import java.util.Date;
 
 /**
  * 今日头条广告主预算信息
+ *
  * @author jeecg-boot
- * @date 2019-07-22
  * @version V1.0
+ * @date 2019-07-22
  */
 @Data
 @TableName("ctop_bytedance_advertiser_budget")
@@ -26,23 +27,31 @@ import java.util.Date;
 @ApiModel(value = "ctop_bytedance_advertiser_budget对象", description = "今日头条广告主预算信息")
 public class ByteDanceAdvertiserBudget {
 
-    /**头条广告主id*/
+    /**
+     * 头条广告主id
+     */
     @TableId
     @ApiModelProperty(value = "头条广告主id")
-	private Long id;
-	/**平台账号id*/
-	@Excel(name = "平台账号id", width = 15)
+    private Long id;
+    /**
+     * 平台账号id
+     */
+    @Excel(name = "平台账号id", width = 15)
     @ApiModelProperty(value = "平台账号id")
-	private String advertiserId;
+    private String advertiserId;
     @Excel(name = "预算类型")
     private String budgetMode;
-	@Excel(name = "预算数量", width = 15)
+    @Excel(name = "预算数量", width = 15)
     @ApiModelProperty(value = "预算数量")
     private BigDecimal budget;
-	/**createTime*/
+    /**
+     * createTime
+     */
     @ApiModelProperty(value = "createTime")
     private Date createTime;
-	/**updateTime*/
+    /**
+     * updateTime
+     */
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
 
@@ -50,19 +59,19 @@ public class ByteDanceAdvertiserBudget {
     }
 
     public ByteDanceAdvertiserBudget(JSONObject dataObject, String accountId) {
-		Long advertiserId = dataObject.getLong("advertiser_id");
-		this.id = advertiserId;
-		this.advertiserId = accountId;
+        Long advertiserId = dataObject.getLong("advertiser_id");
+        this.id = advertiserId;
+        this.advertiserId = accountId;
         String budgetMode = dataObject.getString("budget_mode");
         if (null != budgetMode && !"".equals(budgetMode.trim())) {
             this.budgetMode = budgetMode;
-		}
+        }
         BigDecimal budget = dataObject.getBigDecimal("budget");
-		if (null!=budget){
-			this.budget =budget;
-		}
-		Date now = new Date();
-		this.createTime = now;
-		this.updateTime = now;
-	}
+        if (null != budget) {
+            this.budget = budget;
+        }
+        Date now = new Date();
+        this.createTime = now;
+        this.updateTime = now;
+    }
 }

+ 2 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceBudgetTemplate.java

@@ -14,9 +14,10 @@ import java.util.Date;
 
 /**
  * 今日头条预算模板信息
+ *
  * @author jeecg-boot
- * @date 2019-07-22
  * @version V1.0
+ * @date 2019-07-22
  */
 @Data
 @TableName("ctop_bytedance_budget_template")

+ 135 - 110
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceCampaign.java

@@ -16,9 +16,10 @@ import java.util.Date;
 
 /**
  * 今日头条广告组信息
+ *
  * @author jeecg-boot
- * @date 2019-07-22
  * @version V1.0
+ * @date 2019-07-22
  */
 @Data
 @TableName("ctop_bytedance_campaign")
@@ -27,45 +28,61 @@ import java.util.Date;
 @ApiModel(value = "ctop_bytedance_campaign对象", description = "今日头条广告组信息")
 public class ByteDanceCampaign {
 
-    /**今日头条广告组id*/
-	@TableId
+    /**
+     * 今日头条广告组id
+     */
+    @TableId
     @ApiModelProperty(value = "今日头条广告组id")
-	private Long id;
-	/**平台用户id*/
-	@Excel(name = "平台用户id", width = 15)
+    private Long id;
+    /**
+     * 平台用户id
+     */
+    @Excel(name = "平台用户id", width = 15)
     @ApiModelProperty(value = "平台用户id")
-	private String advertiserId;
-	/**头条账号id*/
-	@Excel(name = "头条账号id", width = 15)
+    private String advertiserId;
+    /**
+     * 头条账号id
+     */
+    @Excel(name = "头条账号id", width = 15)
     @ApiModelProperty(value = "头条账号id")
-	private Long toutiaoId;
-	/**
-	 * 头条账号id
-	 */
-	@Excel(name = "模板id", width = 15)
-	@ApiModelProperty(value = "模板id")
-	private Long templateId;
-	/**广告组名称*/
-	@Excel(name = "广告组名称", width = 15)
+    private Long toutiaoId;
+    /**
+     * 头条账号id
+     */
+    @Excel(name = "模板id", width = 15)
+    @ApiModelProperty(value = "模板id")
+    private Long templateId;
+    /**
+     * 广告组名称
+     */
+    @Excel(name = "广告组名称", width = 15)
     @ApiModelProperty(value = "广告组名称")
-	private String name;
-	/**广告组预算*/
-	@Excel(name = "广告组预算", width = 15)
+    private String name;
+    /**
+     * 广告组预算
+     */
+    @Excel(name = "广告组预算", width = 15)
     @ApiModelProperty(value = "广告组预算")
     private BigDecimal budget;
-	/**广告组预算类型*/
-	@Excel(name = "广告组预算类型", width = 15)
+    /**
+     * 广告组预算类型
+     */
+    @Excel(name = "广告组预算类型", width = 15)
     @ApiModelProperty(value = "广告组预算类型")
-	private String budgetMode;
-	/**广告组推广目的*/
-	@Excel(name = "广告组推广目的", width = 15)
+    private String budgetMode;
+    /**
+     * 广告组推广目的
+     */
+    @Excel(name = "广告组推广目的", width = 15)
     @ApiModelProperty(value = "广告组推广目的")
-	private String landingType;
-	/**广告组时间戳,用于更新时提交,服务端判断是否基于最新信息修改*/
-	@Excel(name = "广告组时间戳,用于更新时提交,服务端判断是否基于最新信息修改", width = 15)
+    private String landingType;
+    /**
+     * 广告组时间戳,用于更新时提交,服务端判断是否基于最新信息修改
+     */
+    @Excel(name = "广告组时间戳,用于更新时提交,服务端判断是否基于最新信息修改", width = 15)
     @ApiModelProperty(value = "广告组时间戳,用于更新时提交,服务端判断是否基于最新信息修改")
-	private String modifyTime;
-	@Excel(name = "广告组状态", width = 15)
+    private String modifyTime;
+    @Excel(name = "广告组状态", width = 15)
     @ApiModelProperty(value = "广告组状态")
     private String status;
     /**
@@ -74,77 +91,85 @@ public class ByteDanceCampaign {
     @Excel(name = "optStatus", width = 15)
     @ApiModelProperty(value = "optStatus")
     private String optStatus;
-	/**广告组创建时间*/
-	@Excel(name = "广告组创建时间", width = 15)
+    /**
+     * 广告组创建时间
+     */
+    @Excel(name = "广告组创建时间", width = 15)
     @ApiModelProperty(value = "广告组创建时间")
     private String campaignCreateTime;
-	/**广告组修改时间*/
-	@Excel(name = "广告组修改时间", width = 15)
+    /**
+     * 广告组修改时间
+     */
+    @Excel(name = "广告组修改时间", width = 15)
     @ApiModelProperty(value = "广告组修改时间")
     private String campaignModifyTime;
-	/**createTime*/
+    /**
+     * createTime
+     */
     @ApiModelProperty(value = "createTime")
-	private Date createTime;
-	/**updateTime*/
+    private Date createTime;
+    /**
+     * updateTime
+     */
     @ApiModelProperty(value = "updateTime")
-	private Date updateTime;
+    private Date updateTime;
 
     public ByteDanceCampaign() {
     }
 
     public ByteDanceCampaign(Long id, String advertiserId, Long toutiaoId, String name, BigDecimal budget, String budgetMode, String landingType, String modifyTime, String status, String optStatus, String campaignCreateTime, String campaignModifyTime, Date createTime, Date updateTime) {
-		this.id = id;
-		this.advertiserId = advertiserId;
-		this.toutiaoId = toutiaoId;
-		this.name = name;
-		this.budget = budget;
-		this.budgetMode = budgetMode;
-		this.landingType = landingType;
-		this.modifyTime = modifyTime;
-		this.status = status;
-		this.optStatus = optStatus;
-		this.campaignCreateTime = campaignCreateTime;
-		this.campaignModifyTime = campaignModifyTime;
-		this.createTime = createTime;
-		this.updateTime = updateTime;
+        this.id = id;
+        this.advertiserId = advertiserId;
+        this.toutiaoId = toutiaoId;
+        this.name = name;
+        this.budget = budget;
+        this.budgetMode = budgetMode;
+        this.landingType = landingType;
+        this.modifyTime = modifyTime;
+        this.status = status;
+        this.optStatus = optStatus;
+        this.campaignCreateTime = campaignCreateTime;
+        this.campaignModifyTime = campaignModifyTime;
+        this.createTime = createTime;
+        this.updateTime = updateTime;
     }
 
     public ByteDanceCampaign(JSONObject dataObject, String accountId) {
-		Long id = dataObject.getLong("id");
-		this.id = id;
-		this.advertiserId = accountId;
-		Long toutiaoId = dataObject.getLong("advertiser_id");
-		if (null!=toutiaoId){
-			this.toutiaoId =toutiaoId;
-		}
-		String name = dataObject.getString("name");
-		if (null!=name&&!"".equals(name.trim())){
-			this.name =name;
-		}
-		BigDecimal budget = dataObject.getBigDecimal("budget");
-		if (null!=budget){
-			this.budget =budget;
-		}
-		String budgetMode = dataObject.getString("budget_mode");
-		if (null!=budgetMode&&!"".equals(budgetMode.trim())){
-			this.budgetMode =budgetMode;
-		}
-		String landingType = dataObject.getString("landing_type");
-		if (null!=landingType&&!"".equals(landingType.trim())){
-			this.landingType =landingType;
-		}
+        Long id = dataObject.getLong("id");
+        this.id = id;
+        this.advertiserId = accountId;
+        Long toutiaoId = dataObject.getLong("advertiser_id");
+        if (null != toutiaoId) {
+            this.toutiaoId = toutiaoId;
+        }
+        String name = dataObject.getString("name");
+        if (null != name && !"".equals(name.trim())) {
+            this.name = name;
+        }
+        BigDecimal budget = dataObject.getBigDecimal("budget");
+        if (null != budget) {
+            this.budget = budget;
+        }
+        String budgetMode = dataObject.getString("budget_mode");
+        if (null != budgetMode && !"".equals(budgetMode.trim())) {
+            this.budgetMode = budgetMode;
+        }
+        String landingType = dataObject.getString("landing_type");
+        if (null != landingType && !"".equals(landingType.trim())) {
+            this.landingType = landingType;
+        }
         String modifyTime = dataObject.getString("modify_time");
         if (null != modifyTime && !"".equals(modifyTime.trim())) {
             this.modifyTime = modifyTime;
-		}
-		String status = dataObject.getString("status");
-		if (null!=status&&!"".equals(status.trim())){
-			this.status =status;
-		}
-		String optStatus = dataObject.getString("opt_status");
-		if (null!=optStatus&&!"".equals(optStatus.trim())){
-			this.optStatus =optStatus;
-		}
+        }
+        String status = dataObject.getString("status");
+        if (null != status && !"".equals(status.trim())) {
+            this.status = status;
+        }
+        String optStatus = dataObject.getString("opt_status");
+        if (null != optStatus && !"".equals(optStatus.trim())) {
+            this.optStatus = optStatus;
+        }
         String campaignCreateTime = dataObject.getString("campaign_create_time ");
         if (null != campaignCreateTime && !"".equals(campaignCreateTime.trim())) {
             this.campaignCreateTime = campaignCreateTime;
@@ -153,35 +178,35 @@ public class ByteDanceCampaign {
         if (null != campaignModifyTime && !"".equals(campaignModifyTime.trim())) {
             this.campaignModifyTime = campaignModifyTime;
         }
-		Date now = new Date();
-		this.createTime = now;
-		this.updateTime = now;
+        Date now = new Date();
+        this.createTime = now;
+        this.updateTime = now;
     }
 
     public ByteDanceCampaign(Long id, CtopOauthToken oauthToken, String campaignName, String budgetMode, Integer budget, String landingType) {
-		this.id = id;
-		this.advertiserId = oauthToken.getAdvertiserId();
-		this.name = campaignName;
-		this.budgetMode = budgetMode;
-		this.budget = BigDecimal.valueOf(budget);
-		this.landingType = landingType;
-		this.toutiaoId = oauthToken.getAccountId();
-		Date now = new Date();
-		this.createTime = now;
-		this.updateTime = now;
-	}
+        this.id = id;
+        this.advertiserId = oauthToken.getAdvertiserId();
+        this.name = campaignName;
+        this.budgetMode = budgetMode;
+        this.budget = BigDecimal.valueOf(budget);
+        this.landingType = landingType;
+        this.toutiaoId = oauthToken.getAccountId();
+        Date now = new Date();
+        this.createTime = now;
+        this.updateTime = now;
+    }
 
     public ByteDanceCampaign(Long id, CtopOauthToken token, ByteDanceCampaignTemplate template) {
-		this.id = id;
-		this.advertiserId = token.getAdvertiserId();
-		this.name = template.getCampaignName();
-		this.budgetMode = template.getCampaignBudget();
-		this.budget = new BigDecimal(template.getBudgetDaily());
+        this.id = id;
+        this.advertiserId = token.getAdvertiserId();
+        this.name = template.getCampaignName();
+        this.budgetMode = template.getCampaignBudget();
+        this.budget = new BigDecimal(template.getBudgetDaily());
         this.landingType = template.getPromotionPurpose();
-		this.toutiaoId = token.getAccountId();
-		this.templateId = template.getId();
-		Date now = new Date();
-		this.createTime = now;
-		this.updateTime = now;
-	}
+        this.toutiaoId = token.getAccountId();
+        this.templateId = template.getId();
+        Date now = new Date();
+        this.createTime = now;
+        this.updateTime = now;
+    }
 }

+ 2 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceCampaignTemplate.java

@@ -15,9 +15,10 @@ import java.util.Date;
 
 /**
  * 今日头条广告组模板信息
+ *
  * @author jeecg-boot
- * @date 2019-07-22
  * @version V1.0
+ * @date 2019-07-22
  */
 @Data
 @TableName("ctop_bytedance_campaign_template")

+ 105 - 69
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceCreative.java

@@ -25,94 +25,130 @@ import java.util.Date;
 @ApiModel(value = "ctop_bytedance_creative对象", description = "今日头条创意信息")
 public class ByteDanceCreative {
 
-    /**创意id*/
+    /**
+     * 创意id
+     */
     @TableId
     @ApiModelProperty(value = "创意id")
-	private Long id;
-	/**广告计划id*/
-	@Excel(name = "广告计划id", width = 15)
+    private Long id;
+    /**
+     * 广告计划id
+     */
+    @Excel(name = "广告计划id", width = 15)
     @ApiModelProperty(value = "广告计划id")
-	private Long planId;
-	/**头条平台id*/
-	@Excel(name = "头条平台id", width = 15)
+    private Long planId;
+    /**
+     * 头条平台id
+     */
+    @Excel(name = "头条平台id", width = 15)
     @ApiModelProperty(value = "头条平台id")
-	private Long toutiaoId;
-	/**本平台广告主id*/
-	@Excel(name = "本平台广告主id", width = 15)
+    private Long toutiaoId;
+    /**
+     * 本平台广告主id
+     */
+    @Excel(name = "本平台广告主id", width = 15)
     @ApiModelProperty(value = "本平台广告主id")
-	private String accountId;
-	/**创意素材标题*/
-	@Excel(name = "创意素材标题", width = 15)
+    private String accountId;
+    /**
+     * 创意素材标题
+     */
+    @Excel(name = "创意素材标题", width = 15)
     @ApiModelProperty(value = "创意素材标题")
-	private String title;
-	/**动态词包列表*/
-	@Excel(name = "动态词包列表", width = 15)
+    private String title;
+    /**
+     * 动态词包列表
+     */
+    @Excel(name = "动态词包列表", width = 15)
     @ApiModelProperty(value = "动态词包列表")
-	private String creativeWordIds;
-	/**创意素材状态*/
-	@Excel(name = "创意素材状态", width = 15)
+    private String creativeWordIds;
+    /**
+     * 创意素材状态
+     */
+    @Excel(name = "创意素材状态", width = 15)
     @ApiModelProperty(value = "创意素材状态")
-	private String status;
-	/**创意素材创作状态*/
-	@Excel(name = "创意素材创作状态", width = 15)
+    private String status;
+    /**
+     * 创意素材创作状态
+     */
+    @Excel(name = "创意素材创作状态", width = 15)
     @ApiModelProperty(value = "创意素材创作状态")
-	private String optStatus;
-	/**创意素材类型*/
-	@Excel(name = "创意素材类型", width = 15)
+    private String optStatus;
+    /**
+     * 创意素材类型
+     */
+    @Excel(name = "创意素材类型", width = 15)
     @ApiModelProperty(value = "创意素材类型")
-	private String imageMode;
-	/**图片素材id列表*/
-	@Excel(name = "图片素材id列表", width = 15)
+    private String imageMode;
+    /**
+     * 图片素材id列表
+     */
+    @Excel(name = "图片素材id列表", width = 15)
     @ApiModelProperty(value = "图片素材id列表")
-	private String imageIds;
-	/**视频素材封面*/
-	@Excel(name = "视频素材封面", width = 15)
+    private String imageIds;
+    /**
+     * 视频素材封面
+     */
+    @Excel(name = "视频素材封面", width = 15)
     @ApiModelProperty(value = "视频素材封面")
-	private String imageId;
-	/**视频id*/
-	@Excel(name = "视频id", width = 15)
+    private String imageId;
+    /**
+     * 视频id
+     */
+    @Excel(name = "视频id", width = 15)
     @ApiModelProperty(value = "视频id")
-	private String videoId;
-	/**创意审核信息*/
-	@Excel(name = "创意审核信息", width = 15)
+    private String videoId;
+    /**
+     * 创意审核信息
+     */
+    @Excel(name = "创意审核信息", width = 15)
     @ApiModelProperty(value = "创意审核信息")
-	private String auditRejectReason;
-	/**第三方id*/
-	@Excel(name = "第三方id", width = 15)
+    private String auditRejectReason;
+    /**
+     * 第三方id
+     */
+    @Excel(name = "第三方id", width = 15)
     @ApiModelProperty(value = "第三方id")
-	private String thirdPartyId;
-	/**广告创意创建时间*/
-	@Excel(name = "广告创意创建时间", width = 15)
+    private String thirdPartyId;
+    /**
+     * 广告创意创建时间
+     */
+    @Excel(name = "广告创意创建时间", width = 15)
     @ApiModelProperty(value = "广告创意创建时间")
-	private String creativeCreateTime;
-	/**广告创意更新时间*/
-	@Excel(name = "广告创意更新时间", width = 15)
+    private String creativeCreateTime;
+    /**
+     * 广告创意更新时间
+     */
+    @Excel(name = "广告创意更新时间", width = 15)
     @ApiModelProperty(value = "广告创意更新时间")
-	private String creativeModifyTime;
-	/**createTime*/
+    private String creativeModifyTime;
+    /**
+     * createTime
+     */
     @ApiModelProperty(value = "createTime")
-	private Date createTime;
-	/**updateTime*/
+    private Date createTime;
+    /**
+     * updateTime
+     */
     @ApiModelProperty(value = "updateTime")
-	private Date updateTime;
+    private Date updateTime;
 
     public ByteDanceCreative(JSONObject dataObject, String accountId) {
-		this.id = dataObject.getLong("creative_id");
-		this.planId = dataObject.getLong("ad_id");
-		this.toutiaoId = dataObject.getLong("advertiser_id");
-		this.accountId = accountId;
-		String title = dataObject.getString("title");
-		if (null!=title&&!"".equals(title.trim())){
-			this.title = title;
-		}
+        this.id = dataObject.getLong("creative_id");
+        this.planId = dataObject.getLong("ad_id");
+        this.toutiaoId = dataObject.getLong("advertiser_id");
+        this.accountId = accountId;
+        String title = dataObject.getString("title");
+        if (null != title && !"".equals(title.trim())) {
+            this.title = title;
+        }
         String creativeWordIds = dataObject.getString("creative_word_ids");
         if (null != creativeWordIds && !"".equals(creativeWordIds.trim())) {
             this.creativeWordIds = creativeWordIds;
-		}
-		String status = dataObject.getString("status");
-		if (null!=status&&!"".equals(status.trim())){
-			this.status = status;
-		}
+        }
+        String status = dataObject.getString("status");
+        if (null != status && !"".equals(status.trim())) {
+            this.status = status;
+        }
         String optStatus = dataObject.getString("opt_status");
         if (null != optStatus && !"".equals(optStatus.trim())) {
             this.optStatus = optStatus;
@@ -148,10 +184,10 @@ public class ByteDanceCreative {
         String creativeModifyTime = dataObject.getString("creative_modify_time");
         if (null != creativeModifyTime && !"".equals(creativeModifyTime.trim())) {
             this.creativeModifyTime = creativeModifyTime;
-		}
-		Date now = new Date();
-		this.createTime = now;
-		this.updateTime = now;
-	}
+        }
+        Date now = new Date();
+        this.createTime = now;
+        this.updateTime = now;
+    }
 
 }

+ 63 - 43
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceCreativeMaterial.java

@@ -25,86 +25,106 @@ import java.util.Date;
 @ApiModel(value = "ctop_bytedance_creative_material对象", description = "今日头条创意素材信息")
 public class ByteDanceCreativeMaterial {
 
-    /**素材id*/
+    /**
+     * 素材id
+     */
     @TableId
     @ApiModelProperty(value = "素材id")
-	private Long id;
-	/**平台广告主id*/
-	@Excel(name = "平台广告主id", width = 15)
+    private Long id;
+    /**
+     * 平台广告主id
+     */
+    @Excel(name = "平台广告主id", width = 15)
     @ApiModelProperty(value = "平台广告主id")
-	private String advertiserId;
-	/**广告id*/
-	@Excel(name = "广告id", width = 15)
+    private String advertiserId;
+    /**
+     * 广告id
+     */
+    @Excel(name = "广告id", width = 15)
     @ApiModelProperty(value = "广告id")
-	private Long adId;
-	/**头天广告主id*/
-	@Excel(name = "头天广告主id", width = 15)
+    private Long adId;
+    /**
+     * 头天广告主id
+     */
+    @Excel(name = "头天广告主id", width = 15)
     @ApiModelProperty(value = "头天广告主id")
-	private Long toutiaoId;
-	/**创意标题*/
-	@Excel(name = "创意标题", width = 15)
+    private Long toutiaoId;
+    /**
+     * 创意标题
+     */
+    @Excel(name = "创意标题", width = 15)
     @ApiModelProperty(value = "创意标题")
-	private String title;
-	/**创意状态*/
-	@Excel(name = "创意状态", width = 15)
+    private String title;
+    /**
+     * 创意状态
+     */
+    @Excel(name = "创意状态", width = 15)
     @ApiModelProperty(value = "创意状态")
     private String status;
     /**
      * 创意状态
      */
-	@Excel(name = "创意状态", width = 15)
-	@ApiModelProperty(value = "创意状态")
+    @Excel(name = "创意状态", width = 15)
+    @ApiModelProperty(value = "创意状态")
     private String optStatus;
-	/**创意类型*/
-	@Excel(name = "创意类型", width = 15)
+    /**
+     * 创意类型
+     */
+    @Excel(name = "创意类型", width = 15)
     @ApiModelProperty(value = "创意类型")
-	private String imageMode;
-	/**图片素材信息*/
-	@Excel(name = "图片素材信息", width = 15)
+    private String imageMode;
+    /**
+     * 图片素材信息
+     */
+    @Excel(name = "图片素材信息", width = 15)
     @ApiModelProperty(value = "图片素材信息")
-	private String imageInfo;
-	/**createTime*/
+    private String imageInfo;
+    /**
+     * createTime
+     */
     @ApiModelProperty(value = "createTime")
-	private Date createTime;
-	/**updateTime*/
+    private Date createTime;
+    /**
+     * updateTime
+     */
     @ApiModelProperty(value = "updateTime")
-	private Date updateTime;
+    private Date updateTime;
 
     public ByteDanceCreativeMaterial() {
     }
 
     public ByteDanceCreativeMaterial(JSONObject dataObject, String accountId) {
-		this.id = dataObject.getLong("id");
-		this.toutiaoId = dataObject.getLong("advertiser_id");
+        this.id = dataObject.getLong("id");
+        this.toutiaoId = dataObject.getLong("advertiser_id");
 
-		String status = dataObject.getString("status");
-		if (null!=status&&!"".equals(status.trim())){
-			this.status = status;
-		}
+        String status = dataObject.getString("status");
+        if (null != status && !"".equals(status.trim())) {
+            this.status = status;
+        }
 
         Long adId = dataObject.getLong("ad_id");
         if (null != adId) {
             this.adId = adId;
-		}
+        }
 
-		String title = dataObject.getString("title");
-		if (null!=title&&!"".equals(title.trim())){
-			this.title = title;
-		}
+        String title = dataObject.getString("title");
+        if (null != title && !"".equals(title.trim())) {
+            this.title = title;
+        }
 
         String imageMode = dataObject.getString("image_mode");
         if (null != imageMode && !"".equals(imageMode.trim())) {
             this.imageMode = imageMode;
-		}
+        }
 
         String imageInfo = dataObject.getString("image_info");
         if (null != imageInfo && !"".equals(imageInfo.trim())) {
             this.imageInfo = imageInfo;
-		}
+        }
 
         String optStatus = dataObject.getString("opt_status");
         if (null != optStatus && !"".equals(optStatus.trim())) {
             this.optStatus = optStatus;
-		}
-	}
+        }
+    }
 }

+ 2 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceUserOrientationTemplate.java

@@ -16,9 +16,10 @@ import java.util.Date;
 
 /**
  * 今日头条受众模板信息
+ *
  * @author jeecg-boot
- * @date 2019-07-23
  * @version V1.0
+ * @date 2019-07-23
  */
 @Data
 @TableName("ctop_bytedance_user_orientation_template")

+ 2 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/BytedanceAdvertisePlanTemplate.java

@@ -15,9 +15,10 @@ import java.util.Date;
 
 /**
  * 广告计划模板信息
+ *
  * @author jeecg-boot
- * @date 2019-07-28
  * @version V1.0
+ * @date 2019-07-28
  */
 @Data
 @TableName("ctop_bytedance_advertise_plan_template")

+ 4 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/service/IByteDanceAdvertiserDataService.java

@@ -38,9 +38,11 @@ public interface IByteDanceAdvertiserDataService {
 
     Map<String, Object> advertiserAdUpdate(String accountId, Long adId, ByteDanceUserOrientationTemplate template);
 
-    JSONObject updateAd(CtopOauthToken token, Long adId, ByteDanceUserOrientationTemplate template);
+    JSONObject updateAd(CtopOauthToken token, Long adId, ByteDanceUserOrientationTemplate template, JSONObject requestJson);
 
-    JSONObject setUserOrentationData(JSONObject data, ByteDanceUserOrientationTemplate template, Long adId);
+    JSONObject setUserOrentationData(JSONObject data, ByteDanceUserOrientationTemplate template, Long adId, JSONObject requestJson);
 
     JSONObject setUserOrentationData(JSONObject data, ByteDanceUserOrientationTemplate template);
+
+    Map<String, Object> getAdvertiserCampaignList(String accountId);
 }

+ 36 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertisePlanServiceImpl.java

@@ -9,6 +9,7 @@ import cn.com.ctop.toutiao.mapper.ByteDanceAdvertisePlanMapper;
 import cn.com.ctop.toutiao.mapper.BytedanceDeliveryTargetTemplateMapper;
 import cn.com.ctop.toutiao.mapper.BytedanceUrlInfoMapper;
 import cn.com.ctop.toutiao.service.IByteDanceAdvertisePlanService;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
@@ -110,7 +111,24 @@ public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdve
         if ("IOS".equals(urlInfo.getType())) {
             params.put("itunes_url", urlInfo.getUrl());
         }
-        return HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, params);
+
+        JSONObject result = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, params);
+        JSONArray activeConvertList = result.getJSONObject("data").getJSONArray("active_convert_list");
+        result.remove("data");
+        JSONArray resultList = new JSONArray();
+        if (null != activeConvertList && activeConvertList.size() > 0) {
+            for (int i = 0; i < activeConvertList.size(); i++) {
+                JSONObject covert = activeConvertList.getJSONObject(i);
+                String name = covert.getString("name");
+                if (!"下载完成".equals(name.trim()) && !"安装完成".equals(name)) {
+                    resultList.add(covert);
+                }
+            }
+        }
+        JSONObject dataObject = new JSONObject();
+        dataObject.put("active_convert_list", resultList);
+        result.put("data", dataObject);
+        return result;
     }
 
     public JSONObject getAdConvert(CtopOauthToken token, BytedanceDeliveryTargetTemplate targetTemplate) {
@@ -133,7 +151,23 @@ public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdve
                 params.put("package_name", targetTemplate.getPackageName());
             }
         }
-        return HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, params);
+        JSONObject result = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, params);
+        result.remove("data");
+        JSONArray activeConvertList = result.getJSONObject("data").getJSONArray("active_convert_list");
+        JSONArray resultList = new JSONArray();
+        if (null != activeConvertList && activeConvertList.size() > 0) {
+            for (int i = 0; i < activeConvertList.size(); i++) {
+                JSONObject covert = activeConvertList.getJSONObject(i);
+                String name = covert.getString("name");
+                if (!"下载完成".equals(name.trim()) && !"安装完成".equals(name)) {
+                    resultList.add(covert);
+                }
+            }
+        }
+        JSONObject dataObject = new JSONObject();
+        dataObject.put("active_convert_list", resultList);
+        result.put("data", dataObject);
+        return result;
     }
 
 

+ 68 - 16
module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -2,6 +2,8 @@ package cn.com.ctop.toutiao.service.impl;
 
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.toutiao.entity.*;
 import cn.com.ctop.toutiao.mapper.*;
 import cn.com.ctop.toutiao.service.IByteDanceAdvertisePlanService;
@@ -596,13 +598,6 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
             resultMap.put("code", -1);
             return resultMap;
         }
-//        for (int i = 0; i < data.size(); i++) {
-//            JSONObject dataObject = data.getJSONObject(i);
-//            ByteDanceCustomAudience audience = new ByteDanceCustomAudience(token, dataObject);
-//            audienceMapper.deleteById(audience.getId());
-//            audienceMapper.insert(audience);
-//        }
-
         resultMap.put("success", true);
         resultMap.put("message", "人群包信息获取成功");
         resultMap.put("data", data);
@@ -617,7 +612,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
     }
 
     @Override
-    public JSONObject updateAd(CtopOauthToken token, Long adId, ByteDanceUserOrientationTemplate template) {
+    public JSONObject updateAd(CtopOauthToken token, Long adId, ByteDanceUserOrientationTemplate template, JSONObject requestJson) {
 
         // 请求地址
         String url = "https://ad.toutiao.com/open_api/2/ad/update/";
@@ -625,7 +620,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         JSONObject data = new JSONObject();
         data.put("advertiser_id", token.getAccountId());
         data.put("ad_id", adId);
-        data = setUserOrentationData(data, template, adId);
+        data = setUserOrentationData(data, template, adId, requestJson);
         return HttpUtils.bytedancePostRequest(token.getAccessToken(), url, data);
     }
 
@@ -633,10 +628,28 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
     private IByteDanceAdvertisePlanService advertisePlanService;
 
     @Override
-    public JSONObject setUserOrentationData(JSONObject data, ByteDanceUserOrientationTemplate template, Long adId) {
+    public JSONObject setUserOrentationData(JSONObject data, ByteDanceUserOrientationTemplate template, Long adId, JSONObject requestJson) {
         //根据adId获取公告计划信息
         ByteDanceAdvertisePlan advertisePlan = advertisePlanService.getById(adId);
         data.put("modify_time", advertisePlan.getModifyTime());
+        JSONArray retargetingTagsExclude = requestJson.getJSONArray("retargetingTagsExclude");
+        JSONArray retargetingTagsInclude = requestJson.getJSONArray("retargetingTagsInclude");
+        if (null != retargetingTagsExclude && retargetingTagsExclude.size() > 0) {
+            JSONArray getRetargetingTagsExclude = new JSONArray();
+            for (int i = 0; i < retargetingTagsExclude.size(); i++) {
+                String exclude = retargetingTagsExclude.getString(i);
+                getRetargetingTagsExclude.add(Long.parseLong(exclude));
+            }
+            data.put("retargeting_tags_exclude", getRetargetingTagsExclude);
+        }
+        if (null != retargetingTagsInclude && retargetingTagsInclude.size() > 0) {
+            JSONArray getRetargetingTagsInclude = new JSONArray();
+            for (int i = 0; i < retargetingTagsInclude.size(); i++) {
+                String include = retargetingTagsInclude.getString(i);
+                getRetargetingTagsInclude.add(Long.parseLong(include));
+            }
+            data.put("retargeting_tags_include", getRetargetingTagsInclude);
+        }
         data = setUserOrentationData(data, template);
         System.out.println(data.toJSONString());
         return data;
@@ -683,17 +696,22 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
             platformArray.add(template.getPlatform());
             data.put("platform", platformArray);
         }
-        if (null != template.getCity() && !"".equals(template.getCity().trim())) {
-            JSONArray cityArray = JSONArray.parseArray(template.getCity());
-            data.put("city", cityArray);
-        }
         if (null != template.getBusinessIds() && !"".equals(template.getBusinessIds().trim())) {
             JSONArray bussinessIdArray = JSONArray.parseArray(template.getBusinessIds());
             data.put("business_ids", bussinessIdArray);
         }
-        if (null != template.getDistrict() && !"".equals(template.getDistrict().trim())) {
-            data.put("district", template.getDistrict());
+        if (null != template.getAreaType() && !"".equals(template.getAreaType().trim())) {
+            data.put("district", template.getAreaType());
+            if ("CITY".equals(template.getAreaType())) {
+                JSONArray cityArray = JSONArray.parseArray(template.getCity());
+                data.put("city", cityArray);
+            } else if ("COUNTY".equals(template.getAreaType())) {
+                JSONArray countyArray = JSONArray.parseArray(template.getDistrict());
+                data.put("city", countyArray);
+            }
+
         }
+
         if (null != template.getLocationType() && !"".equals(template.getLocationType().trim())) {
             data.put("location_type", template.getLocationType());
         }
@@ -753,6 +771,40 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         return data;
     }
 
+    @Override
+    public Map<String, Object> getAdvertiserCampaignList(String accountId) {
+        Map<String, Object> resultMap = new HashMap<>();
+        CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
+        String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_campaign_get");
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", cTopOauthToken.getAccessToken());
+
+        TreeMap<String, Object> params = new TreeMap<>();
+        params.put("advertiser_id", cTopOauthToken.getAccountId());
+        params.put("page", 1);
+        String result = HttpUtils.httpGetRequest(url, headers, params);
+        JSONObject jsonObject = JSONObject.parseObject(result);
+        Integer code = jsonObject.getInteger("code");
+
+        if (null == code || !code.equals(0)) {
+            log.error("获取广告组信息接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
+            resultMap.put("code", code);
+            resultMap.put("message", jsonObject.getString("message"));
+            return resultMap;
+        }
+        JSONArray data = jsonObject.getJSONObject("data").getJSONArray("list");
+        if (null == data || data.size() <= 0) {
+            log.info("获取广告组信息为空==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
+            resultMap.put("code", code);
+            resultMap.put("message", "获取广告组信息为空");
+            return resultMap;
+        }
+        ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
+        resultMap.put("data", data);
+        return resultMap;
+    }
+
 
     private void getAdvertiserCreativeByPageNumber(String accountId, Integer pageNumber, String ids) {
         CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);

+ 1 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceCampaignTemplateServiceImpl.java

@@ -45,6 +45,7 @@ public class ByteDanceCampaignTemplateServiceImpl extends ServiceImpl<ByteDanceC
     private ICtopOauthTokenService tokenService;
     @Autowired
     private ByteDanceCampaignMapper campaignMapper;
+
     @Override
     public Map<String, Object> insertTemplate(ByteDanceCampaignTemplate template) {
         Map<String, Object> resultMap = new HashMap<>();

+ 1 - 6
pom.xml

@@ -319,11 +319,6 @@
             <artifactId>htmlunit</artifactId>
             <version>2.36.0</version>
         </dependency>
-        <!--        <dependency>-->
-        <!--            <groupId>io.aexp.nodes.graphql</groupId>-->
-        <!--            <artifactId>nodes</artifactId>-->
-        <!--            <version>0.5.0</version>-->
-        <!--        </dependency>-->
         <dependency>
             <groupId>io.aexp.nodes.graphql</groupId>
             <artifactId>nodes</artifactId>
@@ -425,4 +420,4 @@
             </resource>
         </resources>
     </build>
-</project>
+</project>