Bladeren bron

Merge branch 'test'

# Conflicts:
#	jeecg-boot-module-system/src/main/java/org/jeecg/modules/industry/controller/IndustryController.java
syh 5 jaren geleden
bovenliggende
commit
a9ceff0093
36 gewijzigde bestanden met toevoegingen van 859 en 146 verwijderingen
  1. 6 6
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 0 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CreateInternalServiceImpl.java
  3. 4 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/controller/FileController.java
  4. 13 10
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/industry/controller/IndustryController.java
  5. 18 18
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/media/controller/MediaController.java
  6. 2 1
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml
  7. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/service/IFileInfoService.java
  8. 17 4
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  9. 1 4
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/FileInfoServiceImpl.java
  10. 6 3
      module-common/src/main/java/cn/com/ctop/common/module/utils/HttpClientUtils.java
  11. 248 0
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/controller/MaterialInfoController.java
  12. 63 0
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/entity/MaterialInfo.java
  13. 15 0
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/mapper/MaterialInfoMapper.java
  14. 5 0
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/mapper/xml/MaterialInfoMapper.xml
  15. 21 0
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/IMaterialInfoService.java
  16. 62 0
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialInfoServiceImpl.java
  17. 33 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java
  18. 33 17
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  19. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/controller/KuaishouWebController.java
  20. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/service/IKuaishouWebInterfaceService.java
  21. 79 14
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/service/impl/KuaishouWebInterfaceServiceImpl.java
  22. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/vo/KuaishouAcceptVO.java
  23. 4 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAccount.java
  24. 1 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCampaign.java
  25. 4 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyCreative.java
  26. 5 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyGroup.java
  27. 4 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyAccount.java
  28. 6 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyCampaign.java
  29. 1 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyCreative.java
  30. 1 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyGroup.java
  31. 4 5
      module-report/src/main/java/cn/com/ctop/bytedance/controller/BytedanceReportController.java
  32. 6 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/BytedanceReportMapper.java
  33. 5 0
      module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/BytedanceReportMapper.xml
  34. 1 1
      module-report/src/main/java/cn/com/ctop/bytedance/service/IBytedanceReportService.java
  35. 123 26
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceReportServiceImpl.java
  36. 36 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertisePlanServiceImpl.java

+ 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");

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

@@ -79,7 +79,6 @@ 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) {

+ 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);
     }
 }

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

@@ -76,9 +76,12 @@ public class IndustryController {
 				 ids.add(industry.getId());
 			 }
 			 getTreeList(treeList,list,null);
-			 Map<String, Object> resMap = new HashMap<String, Object>();
-             resMap.put("treeList", treeList);
-             resMap.put("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) {
@@ -114,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("添加成功!");
@@ -134,7 +137,7 @@ 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("未找到对应实体");
@@ -156,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("未找到对应实体");
@@ -178,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 {
@@ -197,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("未找到对应实体");
@@ -252,7 +255,8 @@ public class IndustryController {
       Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
       for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
           MultipartFile file = entity.getValue();
-          ImportParams params = new ImportParams();
+
+		  ImportParams params = new ImportParams();
           params.setTitleRows(2);
           params.setHeadRows(1);
           params.setNeedSave(true);
@@ -275,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("未找到对应实体");

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

@@ -15,7 +15,7 @@
         <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
     </resultMap>
 
-    <sql id="Base_Column_List">
+    <sql id="Base_Column_List">selectAll
         id,media_id,advertiser_id,account_id,access_token,refresh_token,access_token_expires_in,refresh_token_expires_in,create_time,update_time
    </sql>
 
@@ -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");

+ 6 - 3
module-common/src/main/java/cn/com/ctop/common/module/utils/HttpClientUtils.java

@@ -83,7 +83,7 @@ public class HttpClientUtils {
                 }
                 result = builder.toString();
             }
-
+            log.info(httpClientEntity.getResult());
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -92,6 +92,7 @@ public class HttpClientUtils {
     }
 
     public HttpClientEntity httpPostParamRequest(HttpClientEntity httpClientEntity) {
+        String result = "";
         try {
             CookieStore cs = httpClientEntity.getCookieStore();
             if (cs != null) {
@@ -118,17 +119,18 @@ public class HttpClientUtils {
             if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
                 String newUrl = response.getFirstHeader("Location").getValue();
                 httpClientEntity.setUrl(newUrl);
+                result = EntityUtils.toString(response.getEntity());
                 return httpPostParamRequest(httpClientEntity);
             } else if (statusCode == HttpStatus.SC_OK) {
-                String result = EntityUtils.toString(response.getEntity());
+                result = EntityUtils.toString(response.getEntity());
                 log.info(result);
-                httpClientEntity.setResult(result);
                 httpClientEntity.setCloseableHttpClient(httpClient);
             }
         } catch (Exception e) {
             e.printStackTrace();
             log.error(e.getMessage());
         }
+        httpClientEntity.setResult(result);
         System.out.println(new Gson().toJson(cookieStore.getCookies()));
         httpClientEntity.setCookieStore(cookieStore);
         return httpClientEntity;
@@ -161,6 +163,7 @@ public class HttpClientUtils {
                 builder.append(line);
             }
             httpClientEntity.setResult(builder.toString());
+            log.info(httpClientEntity.getResult());
         } catch (Exception e) {
             e.printStackTrace();
         }

+ 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;
     }
 

+ 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();

+ 14 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/controller/KuaishouWebController.java

@@ -116,6 +116,20 @@ public class KuaishouWebController {
         return result;
     }
 
+    @PostMapping(value = "/comment/add")
+    public Result<Map<String, Object>> commentAdd(String ksid, String photoId, String principalId, String content, Long replyToCommentId, Long repltTo) {
+        Result<Map<String, Object>> result = new Result<Map<String, Object>>();
+        try {
+            Map<String, Object> statusMap = kuaishouWebInterfaceService.commentAdd(ksid, photoId, principalId, content, replyToCommentId, repltTo);
+            result.setSuccess(true);
+            result.setResult(statusMap);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+    }
+
     @PostMapping(value = "/subcomment/list")
     public Result<Map<String, Object>> subCommentList(String ksid, String photoId, Long rootCommentId, String pcursor) {
         Result<Map<String, Object>> result = new Result<Map<String, Object>>();

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

@@ -28,5 +28,7 @@ public interface IKuaishouWebInterfaceService {
 
     public Map<String, Object> commentList(String ksid, String photoId, String pcursor);
 
+    public Map<String, Object> commentAdd(String ksid, String photoId, String principalId, String content, Long replyToCommentId, Long replyTo);
+
     public Map<String, Object> subCommentList(String ksid, String photoId, Long rootCommentId, String pcursor);
 }

+ 79 - 14
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/service/impl/KuaishouWebInterfaceServiceImpl.java

@@ -316,13 +316,71 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
             params.put("photoId", photoId);
             params.put("commentId", commentId);
             System.out.println(new Gson().toJson(params));
+            Map<String, String> headers = getHeaders();
+            headers.put("Content-Type", "application/x-www-form-urlencoded");
+            headers.put("kpn", "GAME_ZONE");
+            headers.put("kpf", "PC_WEB");
             HttpClientEntity httpClientEntity = new HttpClientEntity();
             HttpClientUtils httpClientUtils = new HttpClientUtils();
             httpClientEntity.setCloseableHttpClient(httpClientUtils.createSSLClientDefault());
-            httpClientEntity.setUrl("https://id.kuaishou.com/pass/kuaishou/login/qr/callback");
+            httpClientEntity.setUrl("https://live.kuaishou.com/rest/wd/comment/delete");
             httpClientEntity.setResult("");
             httpClientEntity.setCookieStore(cookieTransfer(kuaishouUserCookie.getCookie()));
-            httpClientEntity.setHeaders(getHeaders());
+            List<Cookie> list = httpClientEntity.getCookieStore().getCookies();
+            String did = "";
+            for (Cookie ck : list) {
+                if (ck.getName().equals("did")) {
+                    did = ck.getValue();
+                }
+            }
+            headers.put("Referer", "https://live.kuaishou.com/u/" + kuaishouUserCookie.getEid() + "/" + photoId + "?did=" + did);
+            httpClientEntity.setHeaders(headers);
+            httpClientEntity.setParams(params);
+            httpClientEntity = httpClientUtils.httpPostParamRequest(httpClientEntity);
+            try {
+                ObjectMapper mapper = new ObjectMapper();
+                resultMap = mapper.readValue(httpClientEntity.getResult(), new TypeReference<Map<String, Object>>() {
+                });
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return resultMap;
+    }
+
+    public Map<String, Object> commentAdd(String ksid, String photoId, String principalId, String content, Long replyToCommentId, Long replyTo) {
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        QueryWrapper<KuaishouUserCookie> queryWrapper = new QueryWrapper<KuaishouUserCookie>();
+        Map<String, Object> resultMap = new HashMap<>();
+        queryWrapper.eq("user_id", user.getId());
+        queryWrapper.eq("ksid", ksid);
+        KuaishouUserCookie kuaishouUserCookie = kuaishouUserCookieService.getOne(queryWrapper);
+        if (kuaishouUserCookie != null) {
+            Map<String, Object> params = new HashMap<String, Object>();
+            params.put("photoId", photoId);
+            params.put("principalId", principalId);
+            params.put("content", content);
+            params.put("replyToCommentId", replyToCommentId);
+            params.put("replyTo", replyTo);
+            Map<String, String> headers = getHeaders();
+            headers.put("Content-Type", "application/x-www-form-urlencoded");
+            headers.put("kpn", "GAME_ZONE");
+            headers.put("kpf", "PC_WEB");
+            System.out.println(new Gson().toJson(params));
+            HttpClientEntity httpClientEntity = new HttpClientEntity();
+            HttpClientUtils httpClientUtils = new HttpClientUtils();
+            httpClientEntity.setCloseableHttpClient(httpClientUtils.createSSLClientDefault());
+            httpClientEntity.setUrl("https://live.kuaishou.com/rest/wd/photo/comment/add");
+            httpClientEntity.setResult("");
+            List<Cookie> list = httpClientEntity.getCookieStore().getCookies();
+            String did = "";
+            for (Cookie ck : list) {
+                if (ck.getName().equals("did")) {
+                    did = ck.getValue();
+                }
+            }
+            headers.put("Referer", "https://live.kuaishou.com/u/" + kuaishouUserCookie.getEid() + "/" + photoId + "?did=" + did);
+            httpClientEntity.setHeaders(headers);
             httpClientEntity.setParams(params);
             httpClientEntity = httpClientUtils.httpPostParamRequest(httpClientEntity);
             try {
@@ -341,7 +399,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
         try {
             ObjectMapper mapper = new ObjectMapper();
             JsonNode jsonNode = mapper.readTree(json);
-            SimpleDateFormat sdf = new SimpleDateFormat("MMM d, yyyy H:m:s aaa");
+            SimpleDateFormat sdf = new SimpleDateFormat("MMM d, yyyy h:m:s aa", Locale.ENGLISH);
             if (jsonNode != null) {
                 JsonNode cookiesNode = jsonNode.get("cookies");
                 if (cookiesNode != null && cookiesNode.isArray()) {
@@ -996,18 +1054,25 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
                         System.out.println(threadHttpClientEntity.getResult());
                         threadHttpClientEntity = httpClientUtils.callingGraph(threadHttpClientEntity, userInfoQuery());
                         System.out.println(threadHttpClientEntity.getResult());
-                        KuaishouUserCookie kuaishouUserCookie = new KuaishouUserCookie();
-                        kuaishouUserCookie.setCookie(new Gson().toJson(threadHttpClientEntity.getCookieStore()));
-                        kuaishouUserCookie.setKsid(String.valueOf(kuaishouUserVO.getUserId()));
-                        kuaishouUserCookie.setEid(kuaishouUserVO.getEid());
-                        kuaishouUserCookie.setUserName(kuaishouUserVO.getUserName());
                         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-//                        if(user == null){
-//                            user = new LoginUser();
-//                            user.setId("xxa");
-//                        }
-                        kuaishouUserCookie.setUserId(user.getId());
-                        kuaishouUserCookieService.saveOrUpdate(kuaishouUserCookie);
+                        QueryWrapper<KuaishouUserCookie> queryWrapper = new QueryWrapper<>();
+                        queryWrapper.eq("user_id", user.getId());
+                        queryWrapper.eq("ksid", kuaishouUserVO.getUserId());
+                        KuaishouUserCookie kuaishouUserCookie = kuaishouUserCookieService.getOne(queryWrapper);
+                        if (kuaishouUserCookie == null) {
+                            kuaishouUserCookie = new KuaishouUserCookie();
+                            kuaishouUserCookie.setCookie(new Gson().toJson(threadHttpClientEntity.getCookieStore()));
+                            kuaishouUserCookie.setKsid(String.valueOf(kuaishouUserVO.getUserId()));
+                            kuaishouUserCookie.setEid(kuaishouUserVO.getEid());
+                            kuaishouUserCookie.setUserName(kuaishouUserVO.getUserName());
+                            kuaishouUserCookie.setUserId(user.getId());
+                            kuaishouUserCookieService.save(kuaishouUserCookie);
+                        } else {
+                            kuaishouUserCookie.setCookie(new Gson().toJson(threadHttpClientEntity.getCookieStore()));
+                            kuaishouUserCookie.setUserName(kuaishouUserVO.getUserName());
+                            kuaishouUserCookieService.update(kuaishouUserCookie, queryWrapper);
+                        }
+
                     } catch (Exception e) {
                         e.printStackTrace();
                     }

+ 15 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/graphql/vo/KuaishouAcceptVO.java

@@ -2,10 +2,25 @@ package cn.com.ctop.kuaishou.modules.graphql.vo;
 
 import lombok.Data;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
 @Data
 public class KuaishouAcceptVO {
     private Integer result;
     private String qrToken;
     private String callback;
     private String sid;
+
+    public static void main(String[] args) {
+        SimpleDateFormat sdf = new SimpleDateFormat("MMM d, yyyy h:m:s aa", Locale.ENGLISH);
+        try {
+            Date d = sdf.parse("Oct 10, 2019 7:49:30 PM");
+            System.out.println(d.toLocaleString());
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+    }
 }

+ 4 - 2
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,10 +14,13 @@ 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

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

@@ -13,12 +13,11 @@ 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;

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

@@ -13,12 +13,14 @@ 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;

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

@@ -13,13 +13,16 @@ 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

+ 4 - 3
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,13 +13,15 @@ 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

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

@@ -14,16 +14,19 @@ 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

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

@@ -14,15 +14,13 @@ 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;

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

@@ -14,15 +14,13 @@ 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;

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

@@ -19,16 +19,15 @@ 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.getCost("e9ca23d68d884d4ebb19d07889727dae");
-        return null;
+        JSONObject json = bytedanceReportService.getAccountReport("e9ca23d68d884d4ebb19d07889727dae");
+        return json;
 
     }
 

+ 6 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/BytedanceReportMapper.java

@@ -0,0 +1,6 @@
+package cn.com.ctop.bytedance.mapper;
+
+
+public interface BytedanceReportMapper {
+
+}

+ 5 - 0
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/BytedanceReportMapper.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.bytedance.mapper.BytedanceReportMapper">
+
+</mapper>

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

@@ -3,5 +3,5 @@ package cn.com.ctop.bytedance.service;
 import com.alibaba.fastjson.JSONObject;
 
 public interface IBytedanceReportService {
-    JSONObject getCost(String loginId);
+    JSONObject getAccountReport(String loginId);
 }

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

@@ -2,10 +2,14 @@ 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.BytedanceReportMapper;
 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.springframework.beans.factory.annotation.Autowired;
@@ -22,25 +26,28 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
     @Autowired
     private BytedanceAdvertiserDailyReportMapper bytedanceAdvertiserDailyReportMapper;
 
+    @Autowired
+    private BytedanceReportMapper bytedanceReportMapper;
+
+    @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 +56,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,14 +164,25 @@ 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;
     }
 
 

+ 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);
+        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;
     }
 
     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;
     }