Ver Fonte

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

# Conflicts:
#	jeecg-boot-module-system/pom.xml
jiequan.bi há 4 anos atrás
pai
commit
d3d028e6ff
32 ficheiros alterados com 963 adições e 489 exclusões
  1. 28 0
      jeecg-boot-module-system/pom.xml
  2. 60 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/RuleEngineConfig.java
  3. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  4. 8 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  5. 9 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IRuleEngineService.java
  6. 21 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/RuleEngineServiceImpl.java
  7. 9 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vo/QueryParam.java
  8. 8 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vo/RuleResult.java
  9. 0 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysDictServiceImpl.java
  10. 17 0
      jeecg-boot-module-system/src/main/resources/drools/rule.drl
  11. 17 0
      jeecg-boot-module-system/src/main/resources/drools/rule2.drl
  12. 28 0
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  13. 39 10
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouController.java
  14. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouInfoDTO.java
  15. 16 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java
  16. 234 218
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml
  17. 8 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyAccountService.java
  18. 95 86
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAccountServiceImpl.java
  19. 140 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/controller/ByteDanceBatchController.java
  20. 12 10
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceCampaignController.java
  21. 37 15
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceCreativeController.java
  22. 0 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceAdvertisePlan.java
  23. 1 17
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceVideoInfo.java
  24. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceCreativeService.java
  25. 1 6
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertisePlanServiceImpl.java
  26. 31 16
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceCreativeServiceImpl.java
  27. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/BytedanceInfoDTO.java
  28. 2 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceReportController.java
  29. 10 4
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceAccountReportMapper.java
  30. 102 26
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceAccountReportMapper.xml
  31. 2 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceAccountReportService.java
  32. 24 53
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAccountReportServiceImpl.java

+ 28 - 0
jeecg-boot-module-system/pom.xml

@@ -151,6 +151,34 @@
             <artifactId>pagehelper</artifactId>
             <version>5.1.11</version>
         </dependency>
+
+        <!--drools规则引擎-->
+        <dependency>
+            <groupId>org.drools</groupId>
+            <artifactId>drools-core</artifactId>
+            <version>7.6.0.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.drools</groupId>
+            <artifactId>drools-compiler</artifactId>
+            <version>7.6.0.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.drools</groupId>
+            <artifactId>drools-templates</artifactId>
+            <version>7.6.0.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.kie</groupId>
+            <artifactId>kie-api</artifactId>
+            <version>7.6.0.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.kie</groupId>
+            <artifactId>kie-spring</artifactId>
+            <version>7.6.0.Final</version>
+        </dependency>
+
         <!--drools规则引擎-->
         <dependency>
             <groupId>org.drools</groupId>

+ 60 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/config/RuleEngineConfig.java

@@ -0,0 +1,60 @@
+package org.jeecg.config;
+
+import org.kie.api.KieBase;
+import org.kie.api.KieServices;
+import org.kie.api.builder.KieBuilder;
+import org.kie.api.builder.KieFileSystem;
+import org.kie.api.builder.KieRepository;
+import org.kie.api.runtime.KieContainer;
+import org.kie.api.runtime.KieSession;
+import org.kie.internal.io.ResourceFactory;
+import org.kie.spring.KModuleBeanFactoryPostProcessor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.core.io.support.ResourcePatternResolver;
+
+import java.io.IOException;
+
+@Configuration
+public class RuleEngineConfig {
+    private static final Logger LOGGER = LoggerFactory.getLogger(RuleEngineConfig.class) ;
+    private static final String RULES_PATH = "drools/";
+    private final KieServices kieServices = KieServices.Factory.get();
+    @Bean
+    public KieFileSystem kieFileSystem() throws IOException {
+        KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
+        ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
+        Resource[] files = resourcePatternResolver.getResources("classpath*:" + RULES_PATH + "*.*");
+        String path = null;
+        for (Resource file : files) {
+            path = RULES_PATH + file.getFilename();
+            LOGGER.info("path="+path);
+            kieFileSystem.write(ResourceFactory.newClassPathResource(path, "UTF-8"));
+        }
+        return kieFileSystem;
+    }
+    @Bean
+    public KieContainer kieContainer() throws IOException {
+        KieRepository kieRepository = kieServices.getRepository();
+        kieRepository.addKieModule(kieRepository::getDefaultReleaseId);
+        KieBuilder kieBuilder = kieServices.newKieBuilder(kieFileSystem());
+        kieBuilder.buildAll();
+        return kieServices.newKieContainer(kieRepository.getDefaultReleaseId());
+    }
+    @Bean
+    public KieBase kieBase() throws IOException {
+        return kieContainer().getKieBase();
+    }
+    @Bean
+    public KieSession kieSession() throws IOException {
+        return kieContainer().newKieSession();
+    }
+    @Bean
+    public KModuleBeanFactoryPostProcessor kiePostProcessor() {
+        return new KModuleBeanFactoryPostProcessor();
+    }
+}

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

@@ -144,6 +144,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ks/web/test", "anon");
         filterChainDefinitionMap.put("/ureport/**", "anon");
         filterChainDefinitionMap.put("/job/test/*", "anon");
+        //filterChainDefinitionMap.put("/kuaishou/**", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

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

@@ -347,9 +347,16 @@ public class ProjectMemberController {
      * @return
      */
     @PostMapping(value = "/getSaleOwnProjects")
-    public Result<List<ProjectMember>> getSaleOwnProjects(@RequestParam(required = true ,name = "mediaIds") List<Integer> mediaIds) {
+    public Result<List<ProjectMember>> getSaleOwnProjects(@RequestBody JSONObject data) {
         Result<List<ProjectMember>> result = new Result<>();
 
+        JSONArray ids = data.getJSONArray("mediaIds");
+        List<Integer> mediaIds = new ArrayList<>();
+        if(null!=ids&&!ids.isEmpty()){
+            for(int i=0;i<ids.size();i++){
+                mediaIds.add(ids.getIntValue(i));
+            }
+        }
         List<ProjectMember> projectMemberList = projectMemberService.getSaleOwnProjects(mediaIds);
         if (projectMemberList == null) {
             result.error500("未找到对应实体");

+ 9 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IRuleEngineService.java

@@ -0,0 +1,9 @@
+package org.jeecg.modules.ctop.service;
+
+import org.jeecg.modules.ctop.vo.QueryParam;
+
+public interface IRuleEngineService {
+    void executeAddRule(QueryParam param);
+
+    void executeRemoveRule(QueryParam param);
+}

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

@@ -0,0 +1,21 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.ctop.service.IRuleEngineService;
+import org.jeecg.modules.ctop.vo.QueryParam;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+public class RuleEngineServiceImpl implements IRuleEngineService {
+    @Override
+    public void executeAddRule(QueryParam param) {
+        log.info("参数数据:"+param.getParamId()+";"+param.getParamSign());
+        System.out.println("add success");
+    }
+    @Override
+    public void executeRemoveRule(QueryParam param) {
+        log.info("参数数据:"+param.getParamId()+";"+param.getParamSign());
+        System.out.println("remove success");
+    }
+}

+ 9 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vo/QueryParam.java

@@ -0,0 +1,9 @@
+package org.jeecg.modules.ctop.vo;
+
+import lombok.Data;
+
+@Data
+public class QueryParam {
+    private String paramId;
+    private String paramSign;
+}

+ 8 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vo/RuleResult.java

@@ -0,0 +1,8 @@
+package org.jeecg.modules.ctop.vo;
+
+import lombok.Data;
+
+@Data
+public class RuleResult {
+    private boolean postCodeResult;
+}

+ 0 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysDictServiceImpl.java

@@ -43,7 +43,6 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
 	@Override
 	@Cacheable(value = CacheConstant.DICT_CACHE,key = "#code")
 	public List<DictModel> queryDictItemsByCode(String code) {
-		log.info("无缓存dictCache的时候调用这里!");
 		return sysDictMapper.queryDictItemsByCode(code);
 	}
 
@@ -57,7 +56,6 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
 	@Override
 	@Cacheable(value = CacheConstant.DICT_CACHE)
 	public String queryDictTextByKey(String code, String key,String extendsKey,String extendsValue) {
-		log.info("无缓存dictText的时候调用这里!");
 		if(null == extendsKey||extendsKey.trim().equals("")){
 			extendsKey = null;
 		}
@@ -77,13 +75,11 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
 	 */
 	@Override
 	public List<DictModel> queryTableDictItemsByCode(String table, String text, String code) {
-		log.info("无缓存dictTableList的时候调用这里!");
 		return sysDictMapper.queryTableDictItemsByCode(table,text,code);
 	}
 
 	@Override
 	public List<DictModel> queryTableDictItemsByCodeAndFilter(String table, String text, String code, String filterSql) {
-		log.info("无缓存dictTableList的时候调用这里!");
 		return sysDictMapper.queryTableDictItemsByCodeAndFilter(table,text,code,filterSql);
 	}
 
@@ -99,7 +95,6 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
 	@Override
 	@Cacheable(value = "dictTableCache")
 	public String queryTableDictTextByKey(String table,String text,String code, String key,String extendsKey,String extendsValue) {
-		log.info("无缓存dictTable的时候调用这里!");
 		if(null == extendsKey||extendsKey.trim().equals("")){
 			extendsKey = null;
 		}
@@ -121,7 +116,6 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
     @Override
     @Transactional
     public void saveMain(SysDict sysDict, List<SysDictItem> sysDictItemList) {
-
         sysDictMapper.insert(sysDict);
         if (sysDictItemList != null) {
             for (SysDictItem entity : sysDictItemList) {

+ 17 - 0
jeecg-boot-module-system/src/main/resources/drools/rule.drl

@@ -0,0 +1,17 @@
+import org.jeecg.modules.ctop.service.impl.RuleEngineServiceImpl
+import org.slf4j.LoggerFactory
+import org.slf4j.Logger
+import org.jeecg.modules.ctop.vo.QueryParam;
+import org.jeecg.modules.ctop.vo.RuleResult;
+dialect  "java"
+rule "paramcheck1"
+    salience 99
+    when queryParam : QueryParam(paramId != null && paramSign.equals("+"))
+        resultParam : RuleResult()
+    then
+        final Logger LOGGER = LoggerFactory.getLogger("param-check-one 规则引擎") ;
+        LOGGER.info("参数:getParamId="+queryParam.getParamId()+";getParamSign="+queryParam.getParamSign());
+        RuleEngineServiceImpl ruleEngineService = new RuleEngineServiceImpl() ;
+        ruleEngineService.executeAddRule(queryParam);
+        resultParam.setPostCodeResult(true);
+end

+ 17 - 0
jeecg-boot-module-system/src/main/resources/drools/rule2.drl

@@ -0,0 +1,17 @@
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.jeecg.modules.ctop.service.impl.RuleEngineServiceImpl
+import org.jeecg.modules.ctop.vo.QueryParam;
+import org.jeecg.modules.ctop.vo.RuleResult;
+dialect  "java"
+rule "paramcheck2"
+    salience 88
+    when queryParam : QueryParam(paramId != null && paramSign.equals("-"))
+        resultParam : RuleResult()
+    then
+        final Logger LOGGER = LoggerFactory.getLogger("param-check-two 规则引擎") ;
+        LOGGER.info("参数:getParamId="+queryParam.getParamId()+";getParamSign="+queryParam.getParamSign());
+        RuleEngineServiceImpl ruleEngineService = new RuleEngineServiceImpl() ;
+        ruleEngineService.executeRemoveRule(queryParam);
+        resultParam.setPostCodeResult(true);
+end

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

@@ -21,12 +21,17 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.entity.KuaishouEffectVideoInfo;
 import org.jeecg.modules.ctop.service.IKuaishouEffectVideoInfoService;
+import org.jeecg.modules.ctop.service.IRuleEngineService;
+import org.jeecg.modules.ctop.vo.QueryParam;
+import org.jeecg.modules.ctop.vo.RuleResult;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.kie.api.runtime.KieSession;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import javax.annotation.Resource;
 import java.util.HashMap;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
@@ -192,6 +197,29 @@ public class SampleTest {
             Thread.sleep(1000L);
         }
     }
+
+    @Resource
+    private KieSession kieSession;
+    @Autowired
+    private IRuleEngineService ruleEngineService ;
+
+    @Test
+    public void testEngine(){
+        QueryParam queryParam1 = new QueryParam() ;
+        queryParam1.setParamId("1");
+        queryParam1.setParamSign("+");
+        QueryParam queryParam2 = new QueryParam() ;
+        queryParam2.setParamId("2");
+        queryParam2.setParamSign("-");
+        // 入参
+        kieSession.insert(queryParam1);
+        kieSession.insert(queryParam2);
+        kieSession.insert(this.ruleEngineService);
+        // 返参
+        RuleResult resultParam = new RuleResult();
+        kieSession.insert(resultParam);
+        kieSession.fireAllRules();
+    }
 }
 
 

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

@@ -86,7 +86,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<ProjectAccountDTO> projectAccountDTOList = accountService.getKuaishouProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageSize(),dto.getPageNum(), "");
+            PageInfo<ProjectAccountDTO> projectAccountDTOList = accountService.getKuaishouProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageSize(),dto.getPageNum(), "", dto.getYn());
             result.setResult(projectAccountDTOList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -114,7 +114,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<ProjectAccountDTO> projectAccountDTOList = accountService.getKuaishouSaleProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageSize(),dto.getPageNum(), "");
+            PageInfo<ProjectAccountDTO> projectAccountDTOList = accountService.getKuaishouSaleProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageSize(),dto.getPageNum(), "",dto.getYn());
             result.setResult(projectAccountDTOList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -133,7 +133,36 @@ public class KuaiShouController {
         Result<PageInfo<KuaishouReportDailyAccountDTO>> result = new Result<>();
         result.setSuccess(true);
 
-        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null || dto.getProjectId()==null){
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null){
+            result.setSuccess(false);
+            result.setMessage("参数有误");
+            return result;
+        }
+
+        if(dto.getPageSize() == 0){
+            dto.setPageSize(20);
+        }
+
+        try{
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouReportDailyAccountDTOList = accountService.getKuaishouAccountInfoByProjectId(dto.getProjectId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
+            result.setResult(kuaishouReportDailyAccountDTOList);
+        }catch(Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("执行出错");
+        }finally {
+        }
+
+        return result;
+    }
+
+    @ResponseBody
+    @RequestMapping("/getKuaishouSaleAccountInfoByProjectId")
+    public Result<PageInfo<KuaishouReportDailyAccountDTO>> getKuaishouSaleAccountInfoByProjectId(@RequestBody KuaishouInfoDTO dto) {
+        Result<PageInfo<KuaishouReportDailyAccountDTO>> result = new Result<>();
+        result.setSuccess(true);
+
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null){
             result.setSuccess(false);
             result.setMessage("参数有误");
             return result;
@@ -144,7 +173,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouReportDailyAccountDTOList = accountService.getKuaishouAccountInfoByProjectId(dto.getProjectId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouReportDailyAccountDTOList = accountService.getKuaishouSaleAccountInfoByProjectId(dto.getProjectId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouReportDailyAccountDTOList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -162,7 +191,7 @@ public class KuaiShouController {
         Result<PageInfo<KuaishouReportDailyAccountDTO>> result = new Result<>();
         result.setSuccess(true);
 
-        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null || dto.getAccountId()==null){
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null){
             result.setSuccess(false);
             result.setMessage("参数有误");
             return result;
@@ -173,7 +202,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCampaignInfoByAccountId(dto.getAccountId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCampaignInfoByAccountId(dto.getAccountId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouCampaignInfoList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -192,7 +221,7 @@ public class KuaiShouController {
         Result<PageInfo<KuaishouReportDailyAccountDTO>> result = new Result<>();
         result.setSuccess(true);
 
-        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null || dto.getCampaignId()==null){
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null){
             result.setSuccess(false);
             result.setMessage("参数有误");
             return result;
@@ -202,7 +231,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouUnitInfoByCampaignId(dto.getCampaignId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouUnitInfoByCampaignId(dto.getCampaignId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouCampaignInfoList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -220,7 +249,7 @@ public class KuaiShouController {
         Result<PageInfo<KuaishouReportDailyAccountDTO>> result = new Result<>();
         result.setSuccess(true);
 
-        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null || dto.getUnitId()==null){
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null){
             result.setSuccess(false);
             result.setMessage("参数有误");
             return result;
@@ -230,7 +259,7 @@ public class KuaiShouController {
         }
 
         try{
-            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCreativeInfoByUnitId(dto.getUnitId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum());
+            PageInfo<KuaishouReportDailyAccountDTO> kuaishouCampaignInfoList = accountService.getKuaishouCreativeInfoByUnitId(dto.getUnitId(), dto.getStartDate(), dto.getEndDate(),dto.getPageSize(),dto.getPageNum(),dto.getYn());
             result.setResult(kuaishouCampaignInfoList);
         }catch(Exception e){
             log.error(e.getMessage());

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

@@ -18,5 +18,6 @@ public class KuaishouInfoDTO extends PageInfo implements Serializable {
     private Long accountId;  //广告主名称
     private Long campaignId;
     private Long projectId;
+    private Integer yn;
 
 }

+ 16 - 8
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyAccountMapper.java

@@ -18,27 +18,35 @@ public interface KuaishouReportDailyAccountMapper extends BaseMapper<KuaishouRep
 
     List<JSONObject> selectCost(@Param("accountId") Long accountId, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
-    ProjectAccountDTO getKuaishouProjectInfo(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId);
+    List<ProjectAccountDTO> getKuaishouProjectInfo(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectList")List<Long> projectList, @Param("yn")Integer yn);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId);
+    List<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("accountId")Long accountId);
+    List<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("accountId")Long accountId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("campaignId")Long campaignId);
+    List<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("campaignId")Long campaignId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
 
-    List<ProjectAccountDTO> queryProjectMemberByUserId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
+    List<Long> queryProjectMemberByUserId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
 
-    List<ProjectAccountDTO> queryProjectInfoBySaleId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
+    List<Long> queryProjectInfoBySaleId(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
 
     List<ProjectAccountDTO> queryProjectMemberByIds(@Param("projectIds")List<Long> projectIds);
 
     String getRoleCodeByUserId(@Param("userId")String userId);
 
-    List<ProjectAccountDTO> queryProjectMemberByAdmins(@Param("mediaIds")List<Long> mediaIds);
+    List<Long> queryProjectMemberByAdmins(@Param("mediaIds")List<Long> mediaIds);
 
-    List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("unitId")Long unitId);
+    List<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("unitId")Long unitId, @Param("accountIds") List<Long> accoundIds, @Param("yn")Integer yn);
 
     KuaishouVideoInfoDTO getVideoUrl(@Param("photoId")Long photoId);
 
     List<Long> getUserProjectAccountIds(@Param("userId")String userId);
+
+    List<Long> getUserProjectAccountIdsByAdmin();
+
+
+
+    List<Long> getSaleProjectAccountIds(@Param("userId")String userId);
+
+
 }

+ 234 - 218
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml

@@ -531,24 +531,28 @@
     </select>
 
     <select id="getKuaishouAccountInfoByProjectId" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO">
+        select * from
+        (
         select
+        #{yn} as 'yn',
         concat(#{startDate}, '~' ,#{endDate}) as 'statDate',
         a.account_id as 'accountId',
         b.auth_name as 'authName',
         b.project_id as 'projectId',
         b.project_name as 'projectName',
         round(sum(a.charge),2) as 'charge',
-        sum(a.photo_show) as 'photoShow',  -- 封面曝光数
+        sum(a.photo_show) as 'photoShow', -- 封面曝光数
         sum(a.photo_click) as 'photoClick', -- 封面点击数
-        sum(a.aclick) as 'aclick',  -- 素材曝光数
-        sum(a.bclick) as 'bclick',  -- 行为数
-        sum(a.activation) as 'activation',  -- 激活数
-        sum(a.submit) as 'submit',   -- 提交按钮点击数
-        sum(a.event_register) as 'eventRegister',   -- 注册数
-        sum(a.event_next_day_stay) as 'eventNextDayStay',  -- 次日留存数
-        ROUND(IFNULL(sum(a.charge)/sum(a.activation),0),2) as 'activationCost',   -- 激活成本
-        case when photo_show!=0 then concat(round(sum(a.photo_click)/sum(a.photo_show) * 100 ,2),'%') else 0 end as 'photoClickRatio',   -- 封面点击率
-        case when aclick!=0 then concat(round(sum(a.bclick)/sum(a.aclick) * 100 ,2),'%') else 0 end as 'actionRate',  -- 行为率
+        sum(a.aclick) as 'aclick', -- 素材曝光数
+        sum(a.bclick) as 'bclick', -- 行为数
+        sum(a.activation) as 'activation', -- 激活数
+        sum(a.submit) as 'submit', -- 提交按钮点击数
+        sum(a.event_register) as 'eventRegister', -- 注册数
+        sum(a.event_next_day_stay) as 'eventNextDayStay', -- 次日留存数
+        ROUND(IFNULL(sum(a.charge)/sum(a.activation),0),2) as 'activationCost', -- 激活成本
+        case when photo_show!=0 then concat(round(sum(a.photo_click)/sum(a.photo_show) * 100 ,2),'%') else 0 end as
+        'photoClickRatio', -- 封面点击率
+        case when aclick!=0 then concat(round(sum(a.bclick)/sum(a.aclick) * 100 ,2),'%') else 0 end as 'actionRate', -- 行为率
         (case
         when sum(a.photo_show) != 0
         then round((sum(a.charge) / sum(a.photo_show)) * 1000,2)
@@ -567,7 +571,7 @@
         ELSE 0
         end
         ) as 'actionCost', -- 平均行为单价
-        sum(a.photo_share) as 'photoShare',  -- 分享数
+        sum(a.photo_share) as 'photoShare', -- 分享数
         sum(a.photo_comment) as 'photoComment', -- 评论数
         sum(a.photo_like) as 'photoLike', -- 点赞数
         sum(a.follow) as 'follow', -- 新增关注数
@@ -575,14 +579,14 @@
         sum(a.cancel_follow) as 'cancelFollow', -- 取消关注数
         sum(a.block) as 'block', -- 拉黑数
         sum(a.negative) as 'nagative', -- 减少此类作品数
-        sum(a.download_started) as 'downloadStarted',  -- 应用下载数据-安卓下载开始数
-        sum(a.download_completed) as 'downloadCompleted',  -- 应用下载数据-安卓下载完成数
+        sum(a.download_started) as 'downloadStarted', -- 应用下载数据-安卓下载开始数
+        sum(a.download_completed) as 'downloadCompleted', -- 应用下载数据-安卓下载完成数
         (CASE
         WHEN sum(a.event_next_day_stay) != 0
         THEN round(sum(a.charge) / sum(a.event_next_day_stay),2)
         ELSE 0
         end
-        ) as 'eventNextDayStayCost'  -- 次日留存成本
+        ) as 'eventNextDayStayCost' -- 次日留存成本
         from
         ctop_kuaishou_report_daily_account a
         left join (select * from ctop_user_allocation group by account_id) b on a.account_id = b.account_id
@@ -590,93 +594,115 @@
         a.stat_date &gt;= #{startDate}
         and
         a.stat_date &lt;= #{endDate}
+
         <if test="projectId!=null and projectId != '' ">
             and
             b.project_id = #{projectId}
-        </if>>
+        </if>
+        <if test="accountIds !=null">
+            and a.account_id in
+            <foreach collection="accountIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
         group by a.account_id
         order by sum(a.charge) desc
+        )m
+        <if test="yn=1">
+            where
+            m.charge != 0
+        </if>
     </select>
 
     <select id="getKuaishouProjectInfo" resultType="cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO">
-        select
-        concat(#{startDate}, '~' , #{endDate}) as 'statDate',
-        (select project_id from ctop_user_allocation where account_id = a.account_id limit 1) as 'projectId',
-        (select project_name from ctop_user_allocation where account_id = a.account_id limit 1) as 'projectName',
-        (select advertiser_name from ctop_project where id = (select project_id from ctop_user_allocation where
-         					account_id = a.account_id limit 1
-					)) as 'advertiserName',
-        (select responsible_name from ctop_project where id = (select project_id from ctop_user_allocation where
-        					account_id = a.account_id limit 1
-					)) as 'responsibleName',
-        (select design_responsible_name from ctop_project where id = (select project_id from ctop_user_allocation where 					account_id = a.account_id limit 1
-					)) as 'designResponsibleName',
-        ifnull(round(sum(a.charge),2),0) as 'charge',
-        ifnull(sum(a.photo_show),0) as 'photoShow',  -- 封面曝光数
-        ifnull(sum(a.photo_click),0) as 'photoClick', -- 封面点击数
-        ifnull(sum(a.aclick),0) as 'aclick',  -- 素材曝光数
-        ifnull(sum(a.bclick),0) as 'bclick',  -- 行为数
-        ifnull(sum(a.activation),0) as 'activation',  -- 激活数
-        ifnull(sum(a.submit),0) as 'submit',   -- 提交按钮点击数
-        ifnull(sum(a.event_register),0) as 'eventRegister',   -- 注册数
-        ifnull(sum(event_next_day_stay),0) as 'eventNextDayStay',  -- 次日留存数
-        ROUND(IFNULL(sum(a.charge)/sum(a.activation),0),2) as 'activationCost',   -- 激活成本
-        case when (sum(a.photo_show) is not null and sum(a.photo_show)!=0) then concat(round(ifnull(sum(a.photo_click),0)/sum(a.photo_show) * 100 ,2),'%') else 0 end as 'photoClickRate',   -- 封面点击率
-        case when (sum(a.aclick) is not null and sum(a.aclick)!=0) then concat(round(ifnull(sum(a.bclick),0)/sum(a.aclick) * 100 ,2),'%') else 0 end as 'bclickRate',  -- 行为率
-        (case
-        when (sum(a.photo_show) is not null and sum(a.photo_show) != 0)
-        then round((ifnull(sum(a.charge),0) / sum(a.photo_show)) * 1000,2)
-        else 0
-        end
-        ) as 'impression1kCost', -- 均千次封面曝光花费
-        (case
-        when (sum(a.photo_click) is not null and sum(a.photo_click) != 0)
-        then round( ifnull(sum(a.charge),0) / sum(a.photo_click),2)
-        else 0
-        end
-        ) as 'photoClickCost', -- 平均封面点击单价
-        (CASE
-        WHEN ( sum(a.photo_click) is not null and sum(a.photo_click) != 0)
-        THEN round(sum(a.charge) / sum(a.photo_click),2)
-        ELSE 0
-        end
-        ) as 'actionCost', -- 平均行为单价
-        ifnull(sum(a.photo_share),0) as 'photoShare',  -- 分享数
-        ifnull(sum(a.photo_comment),0) as 'photoComment', -- 评论数
-        ifnull(sum(a.photo_like),0) as 'photoLike', -- 点赞数
-        ifnull(sum(a.follow),0) as 'follow', -- 新增关注数
-        ifnull(sum(a.report),0) as 'report', -- 举报数
-        ifnull(sum(a.cancel_follow),0) as 'cancelFollow', -- 取消关注数
-        ifnull(sum(a.block),0) as 'block', -- 拉黑数
-        ifnull(sum(a.negative),0) as 'nagative', -- 减少此类作品数
-        ifnull(sum(a.download_started),0) as 'downloadStarted',  -- 应用下载数据-安卓下载开始数
-        ifnull(sum(a.download_completed),0) as 'downloadCompleted',  -- 应用下载数据-安卓下载完成数
-        (CASE
-        WHEN ( sum(a.event_next_day_stay) is not null and sum(a.event_next_day_stay) != 0)
-        THEN round(  ifnull(sum(a.charge),0) / sum(a.event_next_day_stay)  ,2)
-        ELSE 0
-        end
-        ) as 'eventNextDayStayCost'  -- 次日留存成本
-        from
-        ctop_kuaishou_report_daily_account a
-        left join  (select * from ctop_user_allocation group by account_id) b on a.account_id = b.account_id
-        -- left join ctop_project c on b.project_id = c.id
+        select* from (
+             select
+        #{yn} as 'yn',
+            concat(#{startDate}, '~' , #{endDate}) as 'statDate',
+            (select project_id from ctop_user_allocation where account_id = a.account_id limit 1) as 'projectId',
+            (select project_name from ctop_user_allocation where account_id = a.account_id limit 1) as 'projectName',
+            (select advertiser_name from ctop_project where id = (select project_id from ctop_user_allocation where
+                                account_id = a.account_id limit 1
+                        )) as 'advertiserName',
+            (select responsible_name from ctop_project where id = (select project_id from ctop_user_allocation where
+                                account_id = a.account_id limit 1
+                        )) as 'responsibleName',
+            (select design_responsible_name from ctop_project where id = (select project_id from ctop_user_allocation where account_id = a.account_id limit 1
+                        )) as 'designResponsibleName',
+            ifnull(round(sum(a.charge),2),0) as 'charge',
+            ifnull(sum(a.photo_show),0) as 'photoShow',  -- 封面曝光数
+            ifnull(sum(a.photo_click),0) as 'photoClick', -- 封面点击数
+            ifnull(sum(a.aclick),0) as 'aclick',  -- 素材曝光数
+            ifnull(sum(a.bclick),0) as 'bclick',  -- 行为数
+            ifnull(sum(a.activation),0) as 'activation',  -- 激活数
+            ifnull(sum(a.submit),0) as 'submit',   -- 提交按钮点击数
+            ifnull(sum(a.event_register),0) as 'eventRegister',   -- 注册数
+            ifnull(sum(event_next_day_stay),0) as 'eventNextDayStay',  -- 次日留存数
+            ROUND(IFNULL(sum(a.charge)/sum(a.activation),0),2) as 'activationCost',   -- 激活成本
+            case when (sum(a.photo_show) is not null and sum(a.photo_show)!=0) then concat(round(ifnull(sum(a.photo_click),0)/sum(a.photo_show) * 100 ,2),'%') else 0 end as 'photoClickRate',   -- 封面点击率
+            case when (sum(a.aclick) is not null and sum(a.aclick)!=0) then concat(round(ifnull(sum(a.bclick),0)/sum(a.aclick) * 100 ,2),'%') else 0 end as 'bclickRate',  -- 行为率
+            (case
+            when (sum(a.photo_show) is not null and sum(a.photo_show) != 0)
+            then round((ifnull(sum(a.charge),0) / sum(a.photo_show)) * 1000,2)
+            else 0
+            end
+            ) as 'impression1kCost', -- 均千次封面曝光花费
+            (case
+            when (sum(a.photo_click) is not null and sum(a.photo_click) != 0)
+            then round( ifnull(sum(a.charge),0) / sum(a.photo_click),2)
+            else 0
+            end
+            ) as 'photoClickCost', -- 平均封面点击单价
+            (CASE
+            WHEN ( sum(a.photo_click) is not null and sum(a.photo_click) != 0)
+            THEN round(sum(a.charge) / sum(a.photo_click),2)
+            ELSE 0
+            end
+            ) as 'actionCost', -- 平均行为单价
+            ifnull(sum(a.photo_share),0) as 'photoShare',  -- 分享数
+            ifnull(sum(a.photo_comment),0) as 'photoComment', -- 评论数
+            ifnull(sum(a.photo_like),0) as 'photoLike', -- 点赞数
+            ifnull(sum(a.follow),0) as 'follow', -- 新增关注数
+            ifnull(sum(a.report),0) as 'report', -- 举报数
+            ifnull(sum(a.cancel_follow),0) as 'cancelFollow', -- 取消关注数
+            ifnull(sum(a.block),0) as 'block', -- 拉黑数
+            ifnull(sum(a.negative),0) as 'nagative', -- 减少此类作品数
+            ifnull(sum(a.download_started),0) as 'downloadStarted',  -- 应用下载数据-安卓下载开始数
+            ifnull(sum(a.download_completed),0) as 'downloadCompleted',  -- 应用下载数据-安卓下载完成数
+            (CASE
+            WHEN ( sum(a.event_next_day_stay) is not null and sum(a.event_next_day_stay) != 0)
+            THEN round(  ifnull(sum(a.charge),0) / sum(a.event_next_day_stay)  ,2)
+            ELSE 0
+            end
+            ) as 'eventNextDayStayCost'  -- 次日留存成本
+            from
+            ctop_kuaishou_report_daily_account a
+            left join  (select * from ctop_user_allocation group by account_id) b on a.account_id = b.account_id
+            -- left join ctop_project c on b.project_id = c.id
+            where
+            a.stat_date &gt;= #{startDate}
+            and
+            a.stat_date &lt;= #{endDate}
+            and
+            b.project_id in
+            <foreach collection="projectList" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+            group by b.project_id
+        ) m
+        <if test="yn = 1">
         where
-        a.stat_date &gt;= #{startDate}
-        and
-        a.stat_date &lt;= #{endDate}
-        and
-        b.project_id = #{projectId}
-<!--        <foreach collection="projectList" item="item" separator=","-->
-<!--                 open="(" close=")">-->
-<!--            #{item}-->
-<!--        </foreach>-->
-<!--        group by b.project_id-->
+            m.charge != 0
+        </if>
     </select>
 
     <!-- 计划汇总 -->
     <select id="getKuaishouCampaignInfoByAccountId" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO">
-        select
+        select * from
+        (select
+        #{yn} as 'yn',
         concat(#{startDate}, '~' ,#{endDate}) as 'statDate',
         b.project_id as 'projectId',
         b.project_name as 'projectName',
@@ -741,33 +767,50 @@
             and
             a.account_id = #{accountId}
         </if>
+        <if test="accountIds !=null">
+            and a.account_id in
+            <foreach collection="accountIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+
         group by a.campaign_id
+        ) m
+
+        <if test="yn = 1">
+            where
+            m.charge != 0
+        </if>
     </select>
 
     <!-- 根据计划id获取组信息 -->
     <select id="getKuaishouUnitInfoByCampaignId" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO">
+        select * from (
         select
+        #{yn} as 'yn',
         concat(#{startDate}, '~' ,#{endDate}) as 'statDate',
         b.project_id as 'projectId',
         b.project_name as 'projectName',
         a.account_id as 'accountId',
         b.auth_name as 'authName',
-        a.campaign_id as 'campaignId',  -- 计划id
-        a.campaign_name as 'campaignName',  -- 计划名称
-        a.unit_id as 'unitId',  -- 组id,
-        a.unit_name as 'unitName',  -- 组名称
+        a.campaign_id as 'campaignId', -- 计划id
+        a.campaign_name as 'campaignName', -- 计划名称
+        a.unit_id as 'unitId', -- 组id,
+        a.unit_name as 'unitName', -- 组名称
         round(sum(a.charge),2) as 'charge',
-        sum(a.photo_show) as 'photoShow',  -- 封面曝光数
+        sum(a.photo_show) as 'photoShow', -- 封面曝光数
         sum(a.photo_click) as 'photoClick', -- 封面点击数
-        sum(a.aclick) as 'aclick',  -- 素材曝光数
-        sum(a.bclick) as 'bclick',  -- 行为数
-        sum(a.activation) as 'activation',  -- 激活数
-        sum(a.submit) as 'submit',   -- 提交按钮点击数
-        sum(a.event_register) as 'eventRegister',   -- 注册数
-        sum(event_next_day_stay) as 'eventNextDayStay',  -- 次日留存数
-        ROUND(IFNULL(sum(a.charge)/sum(a.activation),0),2) as 'activationCost',   -- 激活成本
-        case when photo_show!=0 then concat(round(sum(a.photo_click)/sum(a.photo_show) * 100 ,2),'%') else 0 end as 'photoClickRatio',   -- 封面点击率
-        case when aclick!=0 then concat(round(sum(a.bclick)/sum(a.aclick) * 100 ,2),'%') else 0 end as 'actionRate',  -- 行为率
+        sum(a.aclick) as 'aclick', -- 素材曝光数
+        sum(a.bclick) as 'bclick', -- 行为数
+        sum(a.activation) as 'activation', -- 激活数
+        sum(a.submit) as 'submit', -- 提交按钮点击数
+        sum(a.event_register) as 'eventRegister', -- 注册数
+        sum(event_next_day_stay) as 'eventNextDayStay', -- 次日留存数
+        ROUND(IFNULL(sum(a.charge)/sum(a.activation),0),2) as 'activationCost', -- 激活成本
+        case when photo_show!=0 then concat(round(sum(a.photo_click)/sum(a.photo_show) * 100 ,2),'%') else 0 end as
+        'photoClickRatio', -- 封面点击率
+        case when aclick!=0 then concat(round(sum(a.bclick)/sum(a.aclick) * 100 ,2),'%') else 0 end as 'actionRate', -- 行为率
         (case
         when sum(a.photo_show) != 0
         then round((sum(a.charge) / sum(a.photo_show)) * 1000,2)
@@ -786,7 +829,7 @@
         ELSE 0
         end
         ) as 'actionCost', -- 平均行为单价
-        sum(a.photo_share) as 'photoShare',  -- 分享数
+        sum(a.photo_share) as 'photoShare', -- 分享数
         sum(a.photo_comment) as 'photoComment', -- 评论数
         sum(a.photo_like) as 'photoLike', -- 点赞数
         sum(a.follow) as 'follow', -- 新增关注数
@@ -794,38 +837,49 @@
         sum(a.cancel_follow) as 'cancelFollow', -- 取消关注数
         sum(a.block) as 'block', -- 拉黑数
         sum(a.negative) as 'nagative', -- 减少此类作品数
-        sum(a.download_started) as 'downloadStarted',  -- 应用下载数据-安卓下载开始数
-        sum(a.download_completed) as 'downloadCompleted',  -- 应用下载数据-安卓下载完成数
+        sum(a.download_started) as 'downloadStarted', -- 应用下载数据-安卓下载开始数
+        sum(a.download_completed) as 'downloadCompleted', -- 应用下载数据-安卓下载完成数
         (CASE
         WHEN sum(a.event_next_day_stay) != 0
         THEN round(sum(a.charge) / sum(a.event_next_day_stay),2)
         ELSE 0
         end
-        ) as 'eventNextDayStayCost'  -- 次日留存成本
+        ) as 'eventNextDayStayCost' -- 次日留存成本
         from
         ctop_kuaishou_report_daily_group a
         left join (select * from ctop_user_allocation group by account_id) b on a.account_id = b.account_id
+        -- left join ctop_kuaishou_campaign c on a.campaign_id = c.campaign_id
         where
         a.stat_date &gt;= #{startDate}
         and
         a.stat_date &lt;= #{endDate}
-        <if test="campaignId != null and campaignId != ''">
-            and
-            a.campaign_id = #{campaignId}
+            <if test="campaignId != null and campaignId != ''">and
+                a.campaign_id = #{campaignId}
+            </if>
+            <if test="accountIds !=null">
+                and a.account_id in
+                <foreach collection="accountIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            group by unit_id
+            ) m
+        <if test="yn = 1">
+            where
+            m.charge != 0
         </if>
-        group by unit_id
     </select>
 
-    <select id="queryProjectMemberByUserId" resultType="cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO">
+    <select id="queryProjectMemberByUserId" resultType="long">
         select
-        distinct a.project_id as projectId,
-        a.project_name as projectName,
+        distinct a.project_id as projectId
+       -- a.project_name as projectName,
 --         a.advertiser_id as advertiserId,
-        a.advertiser_name as advertiserName,
+       -- a.advertiser_name as advertiserName,
 --         (SELECT media_id from ctop_project c where c.id=a.project_id limit 1) as mediaId,
-        c.responsible_name as responsibleName,
-        c.design_responsible_name as designResponsibleName
+       -- c.responsible_name as responsibleName,
+       -- c.design_responsible_name as designResponsibleName
         from
         ctop_user_allocation a
         left join ctop_project_member b on a.project_id = b.project_id
@@ -839,17 +893,17 @@
         order by c.create_time desc
     </select>
 
-    <select id="queryProjectInfoBySaleId" resultType="cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO">
+    <select id="queryProjectInfoBySaleId" resultType="long">
         select
-        distinct c.id as projectId,
-        c.project_name as projectName,
+        distinct c.id as projectId
+        -- c.project_name as projectName,
         --         a.advertiser_id as advertiserId,
-        c.advertiser_name as advertiserName,
+        -- c.advertiser_name as advertiserName,
         --         (SELECT media_id from ctop_project c where c.id=a.project_id limit 1) as mediaId,
-        c.responsible_name as responsibleName,
-        c.design_responsible_name as designResponsibleName,
-        c.sale_id as saleId,
-        u.realname as saleName
+        -- c.responsible_name as responsibleName,
+        -- c.design_responsible_name as designResponsibleName,
+        -- c.sale_id as saleId,
+        -- u.realname as saleName
         from
         ctop_project c
         left join sys_user u on c.sale_id = u.id
@@ -891,13 +945,13 @@
     </select>
 
     <!-- 设计师展示所有自己的角色下制作的视频 -->
-    <select id="queryProjectMemberByAdmins" resultType="cn.com.ctop.kuaishou.modules.report.entity.ProjectAccountDTO">
+    <select id="queryProjectMemberByAdmins" resultType="long">
         select
-        id as projectId,
-        project_name as projectName,
-        advertiser_name as advertiserName ,
-        responsible_name as responsibleName,
-        design_responsible_name as designResponsibleName
+        id as projectId
+        -- project_name as projectName,
+        -- advertiser_name as advertiserName ,
+        -- responsible_name as responsibleName,
+        -- design_responsible_name as designResponsibleName
         from
         ctop_project
         where
@@ -909,13 +963,10 @@
         order by create_time desc
     </select>
 
-    <select id="getKuaishouCreativeInfoByUnitId2" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO">
-        select
-        a.*,
-        b.photo_id as 'photoId'
-        from
-        (
+    <select id="getKuaishouCreativeInfoByUnitId" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO">
+        select * from (
             select
+        #{yn} as 'yn',
             concat(#{startDate}, '~' ,#{endDate}) as 'statDate',
             b.project_id as 'projectId',
             b.project_name as 'projectName',
@@ -972,99 +1023,37 @@
             THEN round(sum(a.charge) / sum(a.event_next_day_stay),2)
             ELSE 0
             end
-            ) as 'eventNextDayStayCost'  -- 次日留存成本
+            ) as 'eventNextDayStayCost',  -- 次日留存成本
+            (select url from ctop_kuaishou_video_get where photo_id = c.photo_id limit 1) as url,
+            (select cover_url from ctop_kuaishou_video_get where photo_id = c.photo_id limit 1) as coverUrl
             from
             ctop_kuaishou_report_daily_creative a
             left join (select * from ctop_user_allocation group by account_id) b on a.account_id = b.account_id
+            left join ctop_kuaishou_creative c on a.creative_id = c.creative_id
             where
             a.stat_date &gt;= #{startDate}
             and
             a.stat_date &lt;= #{endDate}
+
             <if test="unitId != null and unitId !='' ">
                 and
                 a.unit_id = #{unitId}
             </if>
-            group by creative_id
-        ) a
-        left join  ctop_kuaishou_creative b on a.creativeId = b.creative_id
-    </select>
-
-    <select id="getKuaishouCreativeInfoByUnitId" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAccountDTO">
-        select
-        concat(#{startDate}, '~' ,#{endDate}) as 'statDate',
-        b.project_id as 'projectId',
-        b.project_name as 'projectName',
-        a.account_id as 'accountId',
-        b.auth_name as 'authName',
-        a.creative_id as 'creativeId',
-        a.creative_name as 'creativeName',
-        a.campaign_id as 'campaignId',  -- 计划id
-        a.campaign_name as 'campaignName',  -- 计划名称
-        a.unit_id as 'unitId',  -- 组id,
-        a.unit_name as 'unitName',  -- 组名称
-        round(sum(a.charge),2) as 'charge',
-        sum(a.photo_show) as 'photoShow',  -- 封面曝光数
-        sum(a.photo_click) as 'photoClick', -- 封面点击数
-        sum(a.aclick) as 'aclick',  -- 素材曝光数
-        sum(a.bclick) as 'bclick',  -- 行为数
-        sum(a.activation) as 'activation',  -- 激活数
-        sum(a.submit) as 'submit',   -- 提交按钮点击数
-        sum(a.event_register) as 'eventRegister',   -- 注册数
-        sum(event_next_day_stay) as 'eventNextDayStay',  -- 次日留存数
-        ROUND(IFNULL(sum(a.charge)/sum(a.activation),0),2) as 'activationCost',   -- 激活成本
-        case when photo_show!=0 then concat(round(sum(a.photo_click)/sum(a.photo_show) * 100 ,2),'%') else 0 end as 'photoClickRatio',   -- 封面点击率
-        case when aclick!=0 then concat(round(sum(a.bclick)/sum(a.aclick) * 100 ,2),'%') else 0 end as 'actionRate',  -- 行为率
-        (case
-        when sum(a.photo_show) != 0 and sum(a.photo_show) is not null
-        then round((sum(a.charge) / sum(a.photo_show)) * 1000,2)
-        else 0
-        end
-        ) as 'impression1kCost', -- 均千次封面曝光花费
-        (case
-        when sum(a.photo_click) != 0
-        then round(sum(a.charge) / sum(a.photo_click),2)
-        else 0
-        end
-        ) as 'photoClickCost', -- 平均封面点击单价
-        (CASE
-        WHEN sum(a.photo_click) != 0
-        THEN round(sum(a.charge) / sum(a.photo_click),2)
-        ELSE 0
-        end
-        ) as 'actionCost', -- 平均行为单价
-        sum(a.photo_share) as 'photoShare',  -- 分享数
-        sum(a.photo_comment) as 'photoComment', -- 评论数
-        sum(a.photo_like) as 'photoLike', -- 点赞数
-        sum(a.follow) as 'follow', -- 新增关注数
-        sum(a.report) as 'report', -- 举报数
-        sum(a.cancel_follow) as 'cancelFollow', -- 取消关注数
-        sum(a.block) as 'block', -- 拉黑数
-        sum(a.negative) as 'nagative', -- 减少此类作品数
-        sum(a.download_started) as 'downloadStarted',  -- 应用下载数据-安卓下载开始数
-        sum(a.download_completed) as 'downloadCompleted',  -- 应用下载数据-安卓下载完成数
-        (CASE
-        WHEN sum(a.event_next_day_stay) != 0
-        THEN round(sum(a.charge) / sum(a.event_next_day_stay),2)
-        ELSE 0
-        end
-        ) as 'eventNextDayStayCost',  -- 次日留存成本
-        (select url from ctop_kuaishou_video_get where photo_id = c.photo_id limit 1) as url,
-        (select cover_url from ctop_kuaishou_video_get where photo_id = c.photo_id limit 1) as coverUrl
-        from
-        ctop_kuaishou_report_daily_creative a
-        left join (select * from ctop_user_allocation group by account_id) b on a.account_id = b.account_id
-        left join ctop_kuaishou_creative c on a.creative_id = c.creative_id
-        where
-        a.stat_date &gt;= #{startDate}
-        and
-        a.stat_date &lt;= #{endDate}
-        <if test="unitId != null and unitId !='' ">
-            and
-            a.unit_id = #{unitId}
+            <if test="accountIds !=null">
+                and a.account_id in
+                <foreach collection="accountIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
+            group by a.creative_id
+        )m
+        <if test="yn=1">
+            where m.charge != 0
         </if>
-        group by a.creative_id
     </select>
 
+    <!-- 获取项目成员所在所有项目下的所有账户id -->
     <select id="getVideoUrl" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouVideoInfoDTO">
         select
         url as url,
@@ -1075,14 +1064,40 @@
         limit 1
     </select>
 
-    <!-- 获取项目成员所在所有项目下的所有账户id -->
     <select id="getUserProjectAccountIds" resultType="long">
         select
         a.account_id
         from
-        (select * from ctop_user_allocation  group by account_id) a
+        (select project_id,account_id,media_id from ctop_user_allocation  group by account_id) a
         left join ctop_project_member b on a.project_id=b.project_id
-        where b.user_id = #{userId}
+        where
+        and a.media_id in (2,4)
+        order by a.create_time desc
+        limit 50
+    </select>
+
+    <select id="getUserProjectAccountIdsByAdmin" resultType="long">
+        select
+        a.account_id
+        from
+        ctop_user_allocation a
+        left join ctop_project b on a.project_id = b.id
+        where
+        b.media_id in (2,4)
+        limit 50
+    </select>
+
+    <select id="getSaleProjectAccountIds" resultType="long">
+        select
+        a.account_id
+        from
+        (select project_id,account_id,media_id,create_time from ctop_user_allocation  group by account_id) a
+        left join ctop_project b on a.project_id=b.id
+        where
+        b.sale_id = #{userId}
+        and b.media_id in (1,3)
+        order by a.create_time desc
+        limit 50
     </select>
 
 </mapper>

+ 8 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouReportDailyAccountService.java

@@ -16,16 +16,18 @@ public interface IKuaishouReportDailyAccountService extends IService<KuaishouRep
 
     List<JSONObject> selectCost(Long accountId, String startDate, String endDate);
 
-    PageInfo<ProjectAccountDTO> getKuaishouProjectInfo(String startDate, String endDate, List<Long> projectList , Integer pageSize, Integer pageNum, String sort );
+    PageInfo<ProjectAccountDTO> getKuaishouProjectInfo(String startDate, String endDate, List<Long> projectList , Integer pageSize, Integer pageNum, String sort, Integer yn );
 
-    PageInfo<ProjectAccountDTO> getKuaishouSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort);
+    PageInfo<ProjectAccountDTO> getKuaishouSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort, Integer yn);
 
-    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum);
+    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouSaleAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
 
-    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum);
+    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
 
-    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(Long campaignId, String startDate, String endDate, Integer pageSize, Integer pageNum);
+    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
 
-    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum);
+    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(Long campaignId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
+
+    PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn);
 
 }

+ 95 - 86
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAccountServiceImpl.java

@@ -31,8 +31,9 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
         return dailyAccountMapper.selectCost(accountId, startDate, endDate);
     }
 
+    //获取快手参与的项目的信息
     @Override
-    public PageInfo<ProjectAccountDTO> getKuaishouProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort ){
+    public PageInfo<ProjectAccountDTO> getKuaishouProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort ,Integer yn){
         List<ProjectAccountDTO> projectAccountDTOList = new ArrayList<>();
 
         if(projectList==null || projectList.size()==0){
@@ -46,53 +47,18 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
             mediaIds.add(4L);
 
             if("admin".equals(roleCode)){
-                PageHelper.startPage(pageNum,pageSize);
-                projectAccountDTOList = dailyAccountMapper.queryProjectMemberByAdmins(mediaIds);
+                projectList = dailyAccountMapper.queryProjectMemberByAdmins(mediaIds);
             }else{
-                PageHelper.startPage(pageNum,pageSize);
-                projectAccountDTOList = dailyAccountMapper.queryProjectMemberByUserId(userId,mediaIds);
+                projectList = dailyAccountMapper.queryProjectMemberByUserId(userId,mediaIds);
             }
-        }else{
-            PageHelper.startPage(pageNum,pageSize);
-            projectAccountDTOList = dailyAccountMapper.queryProjectMemberByIds(projectList);
         }
 
-        for(ProjectAccountDTO project:projectAccountDTOList){
-            ProjectAccountDTO project2 = dailyAccountMapper.getKuaishouProjectInfo(startDate, endDate, project.getProjectId());
-            project.setCharge(project2.getCharge());
-            project.setPhotoShow(project2.getPhotoShow());
-            project.setPhotoClick(project2.getPhotoClick());
-            project.setAclick(project2.getAclick());
-            project.setBclick(project2.getBclick());
-            project.setActivation(project2.getActivation());
-            project.setSubmit(project2.getSubmit());
-            project.setEventRegister(project2.getEventRegister());
-            project.setEventNextDayStay(project2.getEventNextDayStay());
-            project.setActivationCost(project2.getActivationCost());
-            project.setPhotoClickRate(project2.getPhotoClickRate());
-            project.setBclickRate(project2.getBclickRate());
-            project.setImpression1kCost(project2.getImpression1kCost());
-            project.setPhotoClickCost(project2.getPhotoClickCost());
-            project.setPhotoShare(project2.getPhotoShare());
-            project.setActionCost(project2.getActionCost());
-            project.setPhotoComment(project2.getPhotoComment());
-            project.setPhotoLike(project2.getPhotoLike());
-            project.setFollow(project2.getFollow());
-            project.setReport(project2.getReport());
-            project.setCancelFollow(project2.getCancelFollow());
-            project.setBlock(project2.getBlock());
-            project.setNagative(project2.getNagative());
-            project.setDownloadStarted(project2.getDownloadStarted());
-            project.setDownloadCompleted(project2.getDownloadCompleted());
-            project.setEventNextDayStayCost(project2.getEventNextDayStayCost());
-            project.setStatDate(startDate + "~" + endDate);
-        }
-
-        return new PageInfo<>(projectAccountDTOList);
+        PageHelper.startPage(pageNum,pageSize);
+        return new PageInfo<>(dailyAccountMapper.getKuaishouProjectInfo(startDate, endDate, projectList, yn));
     }
 
     @Override
-    public PageInfo<ProjectAccountDTO> getKuaishouSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort ){
+    public PageInfo<ProjectAccountDTO> getKuaishouSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageSize, Integer pageNum, String sort,Integer yn ){
         List<ProjectAccountDTO> projectAccountDTOList = new ArrayList<>();
 
         if(projectList==null || projectList.size()==0){
@@ -106,74 +72,117 @@ public class KuaishouReportDailyAccountServiceImpl extends ServiceImpl<KuaishouR
             mediaIds.add(4L);
 
             if("admin".equals(roleCode)){
-                PageHelper.startPage(pageNum,pageSize);
-                projectAccountDTOList = dailyAccountMapper.queryProjectMemberByAdmins(mediaIds);
+                projectList = dailyAccountMapper.queryProjectMemberByAdmins(mediaIds);
             }else{
-                PageHelper.startPage(pageNum,pageSize);
-                projectAccountDTOList = dailyAccountMapper.queryProjectInfoBySaleId(userId,mediaIds);
+
+                projectList = dailyAccountMapper.queryProjectInfoBySaleId(userId,mediaIds);
             }
-        }else{
-            PageHelper.startPage(pageNum,pageSize);
-            projectAccountDTOList = dailyAccountMapper.queryProjectMemberByIds(projectList);
         }
 
-        for(ProjectAccountDTO project:projectAccountDTOList){
-            ProjectAccountDTO project2 = dailyAccountMapper.getKuaishouProjectInfo(startDate, endDate, project.getProjectId());
-            project.setCharge(project2.getCharge());
-            project.setPhotoShow(project2.getPhotoShow());
-            project.setPhotoClick(project2.getPhotoClick());
-            project.setAclick(project2.getAclick());
-            project.setBclick(project2.getBclick());
-            project.setActivation(project2.getActivation());
-            project.setSubmit(project2.getSubmit());
-            project.setEventRegister(project2.getEventRegister());
-            project.setEventNextDayStay(project2.getEventNextDayStay());
-            project.setActivationCost(project2.getActivationCost());
-            project.setPhotoClickRate(project2.getPhotoClickRate());
-            project.setBclickRate(project2.getBclickRate());
-            project.setImpression1kCost(project2.getImpression1kCost());
-            project.setPhotoClickCost(project2.getPhotoClickCost());
-            project.setPhotoShare(project2.getPhotoShare());
-            project.setActionCost(project2.getActionCost());
-            project.setPhotoComment(project2.getPhotoComment());
-            project.setPhotoLike(project2.getPhotoLike());
-            project.setFollow(project2.getFollow());
-            project.setReport(project2.getReport());
-            project.setCancelFollow(project2.getCancelFollow());
-            project.setBlock(project2.getBlock());
-            project.setNagative(project2.getNagative());
-            project.setDownloadStarted(project2.getDownloadStarted());
-            project.setDownloadCompleted(project2.getDownloadCompleted());
-            project.setEventNextDayStayCost(project2.getEventNextDayStayCost());
-            project.setStatDate(startDate + "~" + endDate);
+        PageHelper.startPage(pageNum,pageSize);
+        return new PageInfo<>(dailyAccountMapper.getKuaishouProjectInfo(startDate,endDate,projectList,yn));
+    }
+
+    @Override
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouSaleAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //String userId = "e9ca23d68d884d4ebb19d07889727dae";
+        String userId = sysUser.getId();
+        String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
+
+        List<Long> accountIds = null;
+        if(projectId == null){
+            if("admin".equals(roleCode)){
+                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin();
+            }else {
+                accountIds = dailyAccountMapper.getSaleProjectAccountIds(userId);
+            }
         }
 
-        return new PageInfo<>(projectAccountDTOList);
+        PageHelper.startPage(pageNum,pageSize);
+        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(startDate, endDate, projectId, accountIds, yn));
     }
 
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouAccountInfoByProjectId(Long projectId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //String userId = "e9ca23d68d884d4ebb19d07889727dae";
+        String userId = sysUser.getId();
+        String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
+
+        List<Long> accountIds = null;
+        if(projectId == null){
+            if("admin".equals(roleCode)){
+                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin();
+            }else {
+                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId);
+            }
+        }
+
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(startDate, endDate, projectId));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouAccountInfoByProjectId(startDate, endDate, projectId, accountIds, yn));
     }
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCampaignInfoByAccountId(Long accountId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //String userId = "e9ca23d68d884d4ebb19d07889727dae";
+        String userId = sysUser.getId();
+        String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
+
+        List<Long> accountIds = null;
+        if(accountId == null){
+            if("admin".equals(roleCode)){
+                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin();
+            }else {
+                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId);
+            }
+        }
+
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouCampaignInfoByAccountId(startDate, endDate, accountId));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouCampaignInfoByAccountId(startDate, endDate, accountId,accountIds,yn));
     }
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(Long campaignId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouUnitInfoByCampaignId(Long campaignId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
+
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //String userId = "e9ca23d68d884d4ebb19d07889727dae";
+        String userId = sysUser.getId();
+        String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
+
+        List<Long> accountIds = null;
+        if(campaignId == null){
+            if("admin".equals(roleCode)){
+                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin();
+            }else {
+                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId);
+            }
+        }
+
         PageHelper.startPage(pageNum,pageSize);
-        return new PageInfo<>(dailyAccountMapper.getKuaishouUnitInfoByCampaignId(startDate, endDate, campaignId));
+        return new PageInfo<>(dailyAccountMapper.getKuaishouUnitInfoByCampaignId(startDate, endDate, campaignId,accountIds, yn));
     }
 
     @Override
-    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum){
+    public PageInfo<KuaishouReportDailyAccountDTO> getKuaishouCreativeInfoByUnitId(Long unitId, String startDate, String endDate, Integer pageSize, Integer pageNum, Integer yn){
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //String userId = "e9ca23d68d884d4ebb19d07889727dae";
+        String userId = sysUser.getId();
+        String roleCode = dailyAccountMapper.getRoleCodeByUserId(userId);
+
+        List<Long> accountIds = null;
+        if(unitId == null){
+            if("admin".equals(roleCode)){
+                accountIds = dailyAccountMapper.getUserProjectAccountIdsByAdmin();
+            }else {
+                accountIds = dailyAccountMapper.getUserProjectAccountIds(userId);
+            }
+        }
+
         PageHelper.startPage(pageNum,pageSize);
-        List<KuaishouReportDailyAccountDTO> kuaishouCreativeInfoList = dailyAccountMapper.getKuaishouCreativeInfoByUnitId(startDate, endDate, unitId);
+        List<KuaishouReportDailyAccountDTO> kuaishouCreativeInfoList = dailyAccountMapper.getKuaishouCreativeInfoByUnitId(startDate, endDate, unitId,accountIds, yn);
         //for(KuaishouReportDailyAccountDTO creativeInfo:kuaishouCreativeInfoList){
         //    KuaishouVideoInfoDTO videoInfo = dailyAccountMapper.getVideoUrl(creativeInfo.getPhotoId());
         //    creativeInfo.setUrl(videoInfo.getUrl());

+ 140 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/controller/ByteDanceBatchController.java

@@ -0,0 +1,140 @@
+package cn.com.ctop.toutiao.modules.batch.controller;
+
+import cn.com.ctop.common.module.service.IFileInfoService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.toutiao.modules.batch.service.IBytedanceIndustryInfoService;
+import cn.com.ctop.toutiao.modules.material.entity.ByteDanceVideoInfo;
+import cn.com.ctop.toutiao.modules.material.entity.BytedanceImageInfo;
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceVideoInfoService;
+import cn.com.ctop.toutiao.modules.material.service.IBytedanceImageInfoService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+
+
+@Slf4j
+@RestController
+@RequestMapping("/bytedance/batch")
+public class ByteDanceBatchController {
+    @Autowired
+    IByteDanceAdvertisePlanService byteDanceAdvertisePlanService;
+    @Autowired
+    private IBytedanceIndustryInfoService bytedanceIndustryInfoService;
+    @Autowired
+    private IFileInfoService fileInfoService;
+    @Autowired
+    private IByteDanceCreativeService creativeService;
+    @Autowired
+    private IByteDanceVideoInfoService videoInfoService;
+
+    /**
+     * 获取动态词包信息
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping("creative/words/get")
+    public Map<String, Object> getCreativeWords(Long accountId) {
+        return fileInfoService.getCreativeWords(accountId);
+    }
+
+    @GetMapping("action/text")
+    public Map<String,Object>getActionText(Long accountId,String landType){
+        return fileInfoService.getActionText(accountId,landType);
+    }
+
+    @GetMapping("industry/list")
+    public Map<String,Object>getIndustryList(){
+        return bytedanceIndustryInfoService.getIndustryList();
+    }
+    @GetMapping("load/industry")
+    public Map<String,Object>loadIndustryList(Long accountId,Integer level){
+        return bytedanceIndustryInfoService.getBytedanceIndustryList(accountId,level);
+    }
+
+    @GetMapping(value = "/getVideoList")
+    public Result<IPage<ByteDanceVideoInfo>> getBytedqanceVideoList(
+            @RequestParam(name = "type") Integer type,
+            @RequestParam(name = "accountId") Long accountId,
+            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+            @RequestParam(name = "startDate", defaultValue = "") String startDate,
+            @RequestParam(name = "endDate", defaultValue = "") String endDate) {
+        Result<IPage<ByteDanceVideoInfo>> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("账户id不能为空");
+            }
+
+            QueryWrapper<ByteDanceVideoInfo> queryWrapper = new QueryWrapper<>();
+            if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
+                queryWrapper.between("create_time", startDate+" 00:00:00", endDate+" 23:59:59");
+            }
+            if(null!=type&&type!=0){
+                queryWrapper.eq("type",type);
+            }
+            queryWrapper.eq("account_id",accountId);
+            queryWrapper.orderByDesc("material_upload_time");
+            queryWrapper.groupBy("signature");
+            Page<ByteDanceVideoInfo> page = new Page<>(pageNo, pageSize);
+            IPage<ByteDanceVideoInfo> pageList = videoInfoService.page(page, queryWrapper);
+            result.setSuccess(true);
+            result.setResult(pageList);
+            return result;
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+    }
+    @Autowired
+    private IBytedanceImageInfoService imageInfoService;
+
+    @GetMapping(value = "/getImageList")
+    public Result<IPage<BytedanceImageInfo>> getBytedqanceVideoList(@RequestParam(name = "accountId")Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                    @RequestParam(name = "startDate", defaultValue = "") String startDate,
+                                                                    @RequestParam(name = "endDate", defaultValue = "") String endDate, HttpServletRequest req) {
+        Result<IPage<BytedanceImageInfo>> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("账户id不能为空");
+            }
+            QueryWrapper<BytedanceImageInfo> queryWrapper = new QueryWrapper<>();
+            if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
+                queryWrapper.between("image_create_time", startDate+" 00:00:00", endDate+" 23:59:59");
+            }
+            queryWrapper.eq("account_id",accountId);
+            queryWrapper.orderByDesc("image_create_time");
+            queryWrapper.groupBy("signature");
+            Page<BytedanceImageInfo> page = new Page<>(pageNo, pageSize);
+            IPage<BytedanceImageInfo> pageList = imageInfoService.page(page, queryWrapper);
+            result.setSuccess(true);
+            result.setResult(pageList);
+            return result;
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+    }
+
+    /**
+     *  批量创建创意
+     */
+    @PostMapping("/create/creative")
+    public Map<String,Object>addCreative(@RequestBody JSONObject data){
+        return creativeService.batchCreate(data);
+    }
+}
+

+ 12 - 10
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceCampaignController.java

@@ -14,7 +14,6 @@ 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.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -51,19 +50,22 @@ public class ByteDanceCampaignController {
     @AutoLog(value = "今日头条广告组信息-分页列表查询")
     @ApiOperation(value = "今日头条广告组信息-分页列表查询", notes = "今日头条广告组信息-分页列表查询")
     @GetMapping(value = "/list")
-    public Result<IPage<ByteDanceCampaign>> queryPageList(ByteDanceCampaign byteDanceCampaign,
-                                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-                                                          @RequestParam(name="startDate",defaultValue = "")String startDate,
-                                                          @RequestParam(name="endDate",defaultValue = "")String endDate,
-                                                          HttpServletRequest req) {
+    public Result<IPage<ByteDanceCampaign>> queryPageList(
+            @RequestParam(name = "name",defaultValue = "")String name,
+            @RequestParam(name = "status",defaultValue = "")String status,
+            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+            @RequestParam(name="startDate",defaultValue = "")String startDate,
+            @RequestParam(name="endDate",defaultValue = "")String endDate,
+            HttpServletRequest req) {
         Result<IPage<ByteDanceCampaign>> result = new Result<>();
-        String name = byteDanceCampaign.getName();
-        byteDanceCampaign.setName(null);
-        QueryWrapper<ByteDanceCampaign> queryWrapper = QueryGenerator.initQueryWrapper(byteDanceCampaign, req.getParameterMap());
+        QueryWrapper<ByteDanceCampaign> queryWrapper = new QueryWrapper<>();
         if(null!=name&&!"".equalsIgnoreCase(name)){
             queryWrapper.like("name",name);
         }
+        if(null!=status&&!"".equals(status.trim())){
+            queryWrapper.eq("status","CAMPAIGN_STATUS_"+status);
+        }
         if(null!=startDate&&!"".equals(startDate)){
             queryWrapper.ge("campaign_create_time",startDate+" 00:00:00");
         }

+ 37 - 15
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceCreativeController.java

@@ -1,6 +1,8 @@
 package cn.com.ctop.toutiao.modules.material.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.common.module.utils.StringUtils;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceCreative;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
@@ -11,13 +13,13 @@ 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.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -37,33 +39,37 @@ public class ByteDanceCreativeController {
     /**
      * 分页列表查询
      *
-     * @param byteDanceCreative
      * @param pageNo
      * @param pageSize
-     * @param req
      * @return
      */
     @AutoLog(value = "今日头条创意信息-分页列表查询")
     @ApiOperation(value = "今日头条创意信息-分页列表查询", notes = "今日头条创意信息-分页列表查询")
     @GetMapping(value = "/list")
-    public Result<IPage<ByteDanceCreative>> queryPageList(ByteDanceCreative byteDanceCreative,
-                                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-                                                          @RequestParam(name="startDate",defaultValue = "")String startDate,
-                                                          @RequestParam(name="endDate",defaultValue = "")String endDate,
-                                                          HttpServletRequest req) {
+    public Result<IPage<ByteDanceCreative>> queryPageList(
+            @RequestParam(name = "accountId", defaultValue = "0") Long accountId,
+            @RequestParam(name = "status",required = false) String status,
+            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+            @RequestParam(name="startDate",defaultValue = "",required = false)String startDate,
+            @RequestParam(name="endDate",defaultValue = "",required = false)String endDate,
+            @RequestParam(name = "name",defaultValue = "",required = false)String name) {
         Result<IPage<ByteDanceCreative>> result = new Result<>();
-        String title = byteDanceCreative.getTitle();
-        byteDanceCreative.setTitle(null);
-        QueryWrapper<ByteDanceCreative> queryWrapper = QueryGenerator.initQueryWrapper(byteDanceCreative, req.getParameterMap());
+        QueryWrapper<ByteDanceCreative> queryWrapper = new QueryWrapper<>();
         if(null!=startDate&&!startDate.trim().equals("")){
             queryWrapper.ge("",startDate+" 00:00:00");
         }
+        if(null!=accountId){
+            queryWrapper.eq("account_id",accountId);
+        }
         if(null!=endDate&&!endDate.trim().equals("")){
             queryWrapper.le("",startDate+" 23:59:59");
         }
-        if(null!=title&&!"".equals(title.trim())){
-            queryWrapper.like("title",title);
+        if(null!=name&&!"".equals(name.trim())){
+            queryWrapper.like("title",name);
+        }
+        if(null!=status&&!status.trim().equals("")){
+            queryWrapper.eq("status","CREATIVE_STATUS_AD_"+status);
         }
         Page<ByteDanceCreative> page = new Page<>(pageNo, pageSize);
         IPage<ByteDanceCreative> pageList = byteDanceCreativeService.page(page, queryWrapper);
@@ -99,6 +105,22 @@ public class ByteDanceCreativeController {
     }
 
     /**
+     * 修改广告组状态
+     * @return
+     */
+    @PostMapping("/editStatus")
+    public Map<String,Object> editStatus(@RequestParam(name = "accountId",defaultValue = "0")Long accountId,
+                                         @RequestParam(name = "ids") String ids,
+                                         @RequestParam(name = "status")String status){
+        Map<String,Object>result = new HashMap();
+        if(null == accountId||accountId==0||null == ids||ids.trim().equals("")||null==status||status.trim().equals("")){
+            ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
+            return result;
+        }
+        return byteDanceCreativeService.advertiserCreativeUpdateStatus(accountId,ids,status);
+    }
+
+    /**
      * 编辑
      *
      * @param byteDanceCreative

+ 0 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceAdvertisePlan.java

@@ -12,7 +12,6 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import org.jeecgframework.poi.excel.annotation.Excel;
 
 import java.math.BigDecimal;
 import java.util.Date;

+ 1 - 17
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceVideoInfo.java

@@ -59,48 +59,32 @@ public class ByteDanceVideoInfo {
     /**
      * 视频高度
      */
-    @Excel(name = "视频高度", width = 15)
-    @ApiModelProperty(value = "视频高度")
     private Integer height;
     /**
      * 视频时长
      */
-    @Excel(name = "视频时长", width = 15)
-    @ApiModelProperty(value = "视频时长")
     private Double duration;
     /**
      * 视频大小
      */
-    @Excel(name = "视频大小", width = 15)
-    @ApiModelProperty(value = "视频大小")
     private Long size;
     /**
      * 视频地址
      */
-    @ApiModelProperty(value = "视频地址")
     private String videoUrl;
-    @ApiModelProperty(value = "md5码")
     private String signature;
     private Integer status;
     private Date createTime;
-
     private Date updateTime;
-
     private String url;
-
     private String format;
-
     private String posterUrl;
-
     private Long bitRate;
-
     private Long materialId;
-
     private String source;
-
     private Date materialUploadTime;
-
     private String filename;
+    private Integer type;
 
     public ByteDanceVideoInfo(JSONObject data, CtopOauthToken token) {
         this.id = data.getString("id");

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceCreativeService.java

@@ -20,7 +20,7 @@ public interface IByteDanceCreativeService extends IService<ByteDanceCreative> {
 
     Map<String, Object> getAdvertiserCreative(CtopOauthToken token, String ids, String date);
 
-    Map<String, Object> advertiserCreativeUpdateStatus(String accountId, String creativeIds, String optStatus);
+    Map<String, Object> advertiserCreativeUpdateStatus(Long accountId, String creativeIds, String optStatus);
 
     void replaceBatch(List<ByteDanceCreative> creatives);
 

+ 1 - 6
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertisePlanServiceImpl.java

@@ -7,7 +7,6 @@ import cn.com.ctop.common.module.utils.StringUtils;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
 import cn.com.ctop.toutiao.modules.material.mapper.ByteDanceAdvertisePlanMapper;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
-import cn.com.ctop.toutiao.modules.tool.service.IByteDanceConvertToolService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -24,13 +23,8 @@ import java.util.Map;
 @Slf4j
 @Service
 public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdvertisePlanMapper, ByteDanceAdvertisePlan> implements IByteDanceAdvertisePlanService {
-
     @Autowired
     private ByteDanceAdvertisePlanMapper byteDanceAdvertisePlanMapper;
-
-    @Autowired
-    private IByteDanceConvertToolService byteDanceConvertToolService;
-
     @Override
     public Map<String, Object> getAdvertiserPlan(CtopOauthToken token, String ids, String date, String updateDate) {
         getAd(token, 1, ids, date, updateDate);
@@ -253,6 +247,7 @@ public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdve
         return resultMap;
     }
 
+    @Override
     public Map<String, Object> updateAdvertiserPlanBudget(CtopOauthToken token, JSONArray adIds, JSONArray budgets) {
         JSONArray data = new JSONArray();
         if (adIds.size() > 0) {

+ 31 - 16
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceCreativeServiceImpl.java

@@ -42,7 +42,7 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
      * @return
      */
     @Override
-    public Map<String, Object> advertiserCreativeUpdateStatus(String accountId, String creativeIds, String optStatus) {
+    public Map<String, Object> advertiserCreativeUpdateStatus(Long accountId, String creativeIds, String optStatus) {
         Map<String, Object> resultMap = new HashMap<>();
         JSONArray ids = new JSONArray();
         String[] getCreativeIds = creativeIds.split(StringUtils.COMMA);
@@ -51,7 +51,7 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
                 ids.add(Long.parseLong(getCreativeIds[i]));
             }
         }
-        CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
+        CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId+"");
         //2: 根据token以及用户id获取用户信息数据
         String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_creative_update_status");
         Map<String, String> headers = new HashMap<>();
@@ -65,24 +65,27 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
         String result = HttpUtils.httpPostRequest(url, params, headers);
         JSONObject jsonObject = JSONObject.parseObject(result);
         Integer code = jsonObject.getInteger("code");
-
+        String message = jsonObject.getString("message");
         if (null == code || !code.equals(0)) {
-            log.info("修改创意状态接口异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
+            log.info("修改创意状态接口异常==》accountId:{},message:{}", accountId, message);
+            resultMap.put("success", false);
             resultMap.put("code", -1);
-            resultMap.put("message", "修改创意状态接口异常");
+            resultMap.put("message", message);
             return resultMap;
         }
         JSONObject data = jsonObject.getJSONObject("data");
         if (null == data) {
-            log.info("修改创意状态异常==》accountId:{},message:{}", accountId, jsonObject.getString("message"));
+            log.info("修改创意状态异常==》accountId:{},message:{}", accountId, message);
+            resultMap.put("success", false);
             resultMap.put("code", -1);
-            resultMap.put("message", "修改创意状态异常");
+            resultMap.put("message", message);
             return resultMap;
         }
         JSONArray returnCreativeIds = data.getJSONArray("creative_ids");
         if (null != returnCreativeIds && !returnCreativeIds.isEmpty()) {
             getAdvertiserCreative(cTopOauthToken, creativeIds, null);
         }
+        resultMap.put("success", true);
         resultMap.put("code", 0);
         resultMap.put("message", "广告创意状态修改成功");
         return resultMap;
@@ -170,6 +173,7 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
         data.put("ad_id", adId);
         String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_creative_create_v2");
         JSONObject result = HttpUtils.bytedancePostRequest(token.getAccessToken(),url,data);
+        System.out.println(result);
         Integer code = result.getInteger("code");
         String message = result.getString("message");
         if (null == code || code != 0) {
@@ -272,7 +276,7 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
     public Map<String, Object> batchCreate(JSONObject data) {
         log.info(data.toJSONString());
         Map<String,Object>result = new HashMap<>();
-        Long accountId = data.getLong("advertiserId");
+        Long accountId = data.getLong("accountId");
         CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
         if(null == token){
             ResultMapUtils.setResultMap(result,StatusCode.COMMON_PARAM_ERROR);
@@ -285,8 +289,13 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
         }
         //拼接参数
         JSONObject params  = initParams(data);
-
-        return null;
+        JSONArray array = new JSONArray();
+        for(int i=0;i<planIds.size();i++){
+            Map<String,Object> getData = creativeCreate(accountId+"",planIds.getLong(i),params);
+            array.add(getData);
+        }
+        result.put("data",array);
+        return result;
     }
 
     private JSONObject initParams(JSONObject data) {
@@ -294,14 +303,17 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
         String creativeWay = data.getString("creativeWay");
         params.put("advertiser_id",data.getLong("accountId"));
         //###############公共参数开始################################
-        JSONArray inventoryType = data.getJSONArray("inventoryType");
-        if(null!=inventoryType){
-            params.put("inventory_type",inventoryType);
-        }
+        //优选广告位
         Integer smartInventory = data.getInteger("smartInventory");
         if(null!=smartInventory){
             params.put("smart_inventory",smartInventory);
         }
+        //媒体指定位置
+        JSONArray inventoryType = data.getJSONArray("inventoryType");
+        if(null!=inventoryType){
+            params.put("inventory_type",inventoryType);
+        }
+        //场景指定位置
         String sceneInventory = data.getString("sceneInventory");
         if(null!=sceneInventory&&!sceneInventory.trim().equals("")){
             params.put("scene_inventory",sceneInventory);
@@ -315,6 +327,9 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
             params.put("third_industry_id",thirdIndustryId);
         }
 
+        /**
+         * 创意展现方式
+         */
         String creativeDisplayMode = data.getString("creativeDisplayMode");
         if(null!=creativeDisplayMode&&creativeDisplayMode.trim().equals("")){
             params.put("creative_display_mode",creativeDisplayMode);
@@ -351,12 +366,12 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
         if(null!=generateDerivedAd&&generateDerivedAd!=0){
             params.put("generate_derived_ad",generateDerivedAd);
         }
-        String playableUrl = data.getString("playable_url");
+        String playableUrl = data.getString("playableUrl");
         if(null!=playableUrl&&!"".equals(playableUrl.trim())){
             params.put("playable_url",playableUrl);
         }
         Long isPresentedVideo = data.getLong("isPresentedVideo");
-        if(null!=isCommentDisable&&isPresentedVideo!=0){
+        if(null!=isPresentedVideo&&isPresentedVideo!=0){
             params.put("is_presented_video",isPresentedVideo);
         }
         Long creativeAutoGenerateSwitch = data.getLong("creativeAutoGenerateSwitch");

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/BytedanceInfoDTO.java

@@ -17,5 +17,5 @@ public class BytedanceInfoDTO extends PageInfo implements Serializable{
     private Long campaignId;
     private Long projectId;
     private String sort;
-
+    private Integer yn;
 }

+ 2 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceReportController.java

@@ -408,7 +408,7 @@ public class BytedanceReportController {
         }
 
         try{
-            PageInfo<ByteDanceReportAccountDailyDTO> byteDanceReportAccountDailyDTOList = bytedanceAccountReportService.getBytedanceAccountInfoByProjectId(dto.getStartDate(), dto.getEndDate(), dto.getProjectId(),dto.getPageNum(),dto.getPageSize(),dto.getSort());
+            PageInfo<ByteDanceReportAccountDailyDTO> byteDanceReportAccountDailyDTOList = bytedanceAccountReportService.getBytedanceAccountInfoByProjectId(dto.getStartDate(), dto.getEndDate(), dto.getProjectId(),dto.getPageNum(),dto.getPageSize(),dto.getSort(), dto.getYn());
             result.setResult(byteDanceReportAccountDailyDTOList);
         }catch(Exception e){
             log.error(e.getMessage());
@@ -445,7 +445,7 @@ public class BytedanceReportController {
         }
 
         try{
-            PageInfo<ByteDanceReportAccountDailyDTO> byteDanceReportAccountDailyDTOList = bytedanceAccountReportService.getBytedanceSaleProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageNum(),dto.getPageSize(),dto.getSort());
+            PageInfo<ByteDanceReportAccountDailyDTO> byteDanceReportAccountDailyDTOList = bytedanceAccountReportService.getBytedanceSaleProjectInfo(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageNum(),dto.getPageSize(),dto.getSort(), dto.getYn());
             result.setResult(byteDanceReportAccountDailyDTOList);
         }catch(Exception e){
             log.error(e.getMessage());

+ 10 - 4
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceAccountReportMapper.java

@@ -45,18 +45,24 @@ public interface BytedanceAccountReportMapper {
     //查询固定月的明细数据
     List<JSONObject> queryDetailGroupDayByMonth(@Param("month") String month);
 
-    List<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId);
+    List<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId, @Param("accountIds")List<Long> accountIds, @Param("yn")Integer yn);
 
-    ByteDanceReportAccountDailyDTO getBytedanceProjectInfo(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectId")Long projectId);
+    List<ByteDanceReportAccountDailyDTO> getBytedanceProjectInfo(@Param("startDate")String startDate, @Param("endDate")String endDate, @Param("projectList")List<Long> projectList, @Param("yn")Integer yn);
 
     String getRoleCodeByUserId(@Param("userId")String userId);
 
     //List<Long> queryProjectInfoByAdmin(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
 
-    List<ByteDanceReportAccountDailyDTO> getSaleProjects(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
+    List<Long> getSaleProjects(@Param("userId")String userId, @Param("mediaIds")List<Long> mediaIds);
 
-    List<ByteDanceReportAccountDailyDTO> queryProjectInfoByAdmin(@Param("mediaIds")List<Long> mediaIds);
+    List<Long> queryProjectInfoByAdmin(@Param("mediaIds")List<Long> mediaIds);
 
     List<ByteDanceReportAccountDailyDTO> queryProjectMemberByIds(@Param("projectIds")List<Long> projectIds);
 
+    List<Long> getUserProjectAccountIds(@Param("userId")String userId);
+
+    List<Long> getSaleProjectAccountIds(@Param("userId")String userId);
+
+    List<Long> getUserProjectAccountIdsByAdmin();
+
 }

+ 102 - 26
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceAccountReportMapper.xml

@@ -287,16 +287,23 @@
     </sql>
 
     <select id="getBytedanceAccountInfoByProjectId" resultType="cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO">
-            select
-            concat(#{startDate}, '~' ,#{endDate}) as 'statDate',
-            a.advertiser_id as 'accountId',
-            b.auth_name as 'authName',
-            b.project_id as 'projectId',
-            b.project_name as 'projectName',
-            <include refid="selectSql"></include>
+        select * from (
+        select
+        concat(#{startDate},'~',#{endDate}) as statDate,
+        a.advertiser_id as 'accountId',
+        c.advertiser_id as 'advertiserId',
+        c.advertiser_name as 'advertiserName',
+        c.responsible_name as 'responsibleName',
+        c.design_responsible_name as 'designResponsibleName',
+        b.auth_name as 'authName',
+        b.project_id as 'projectId',
+        b.project_name as 'projectName',
+        c.media_id as 'mediaId',
+        <include refid="selectSql"></include>
         from
         ctop_bytedance_report_advertiser_daily a
         left join (select * from ctop_user_allocation group by account_id) b on a.advertiser_id = b.account_id
+        left join ctop_project c on b.project_id = c.id
         where
         date_format(a.stat_datetime,'%Y-%m-%d') &gt;= #{startDate}
         and
@@ -305,13 +312,36 @@
             and
             b.project_id = #{projectId}
         </if>
+        <if test="accountIds !=null">
+            and a.advertiser_id in
+            <foreach collection="accountIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
         group by a.advertiser_id
-        -- order by sum(a.cost) desc
+        order by sum(a.cost) desc
+        )m
+        <if test="yn =1">
+            where
+            m.cost != 0
+        </if>
     </select>
 
     <select id="getBytedanceProjectInfo" resultType="cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO">
-            select
-            <include refid="selectSql"></include>
+        select * from (
+        select
+        concat(#{startDate},'~',#{endDate}) as statDate,
+        a.advertiser_id as 'accountId',
+        c.advertiser_id as 'advertiserId',
+        c.advertiser_name as 'advertiserName',
+        c.responsible_name as 'responsibleName',
+        c.design_responsible_name as 'designResponsibleName',
+        b.auth_name as 'authName',
+        b.project_id as 'projectId',
+        b.project_name as 'projectName',
+        c.media_id as 'mediaId',
+        <include refid="selectSql"></include>
         from
         ctop_bytedance_report_advertiser_daily a
         left join (select * from ctop_user_allocation group by account_id) b on a.advertiser_id = b.account_id
@@ -321,7 +351,17 @@
         and
         date_format(a.stat_datetime, '%Y-%m-%d') &lt;= #{endDate}
         and
-        b.project_id = #{projectId}
+        b.project_id in
+        <foreach collection="projectList" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+        group by b.project_id
+        )m
+        <if test="yn = 1">
+            where
+            m.cost != 0
+        </if>
     </select>
 
     <select id="getRoleCodeByUserId" resultType="string">
@@ -333,14 +373,14 @@
         where a.user_id = #{userId}
     </select>
 
-    <select id="queryProjectInfoByAdmin" resultType="cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO">
+    <select id="queryProjectInfoByAdmin" resultType="long">
         select
-        id as projectId,
-        project_name as projectName,
-        advertiser_id as advertiserId,
-        advertiser_name as advertiserName,
-        responsible_name as responsibleName,
-        media_id as mediaId
+        id as projectId
+        -- project_name as projectName,
+        -- advertiser_id as advertiserId,
+        -- advertiser_name as advertiserName,
+        -- responsible_name as responsibleName,
+        -- media_id as mediaId
         from
         ctop_project
         where
@@ -351,15 +391,15 @@
         </foreach>
     </select>
 
-    <select id="getSaleProjects" resultType="cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO">
+    <select id="getSaleProjects" resultType="long">
         select
-        distinct a.id as projectId,
-        a.project_name as projectName,
-        a.advertiser_id as advertiserId,
-        a.advertiser_name as advertiserName,
-        a.media_id as mediaId,
-        a.sale_id as saleId,
-        b.realname as saleName
+        distinct a.id as projectId
+        -- a.project_name as projectName,
+        -- a.advertiser_id as advertiserId,
+        -- a.advertiser_name as advertiserName,
+        -- a.media_id as mediaId,
+        -- a.sale_id as saleId,
+        -- b.realname as saleName
         from
         ctop_project a
         left join sys_user b on a.sale_id = b.id
@@ -391,6 +431,42 @@
         order by create_time desc
     </select>
 
+    <select id="getUserProjectAccountIds" resultType="long">
+        select
+        a.account_id
+        from
+        (select project_id,account_id,media_id,create_time from ctop_user_allocation  group by account_id) a
+        left join ctop_project_member b on a.project_id=b.project_id
+        where
+        a.user_id = #{userId}
+        and a.media_id in (1,3)
+        order by a.create_time desc
+        limit 50
+    </select>
+
 
+    <select id="getSaleProjectAccountIds" resultType="long">
+        select
+        a.account_id
+        from
+        (select project_id,account_id,media_id,create_time from ctop_user_allocation  group by account_id) a
+        left join ctop_project b on a.project_id=b.id
+        where
+        b.sale_id = #{userId}
+        and b.media_id in (1,3)
+        order by a.create_time desc
+        limit 50
+    </select>
+
+    <select id="getUserProjectAccountIdsByAdmin" resultType="long">
+        select
+        a.account_id
+        from
+        ctop_user_allocation a
+        left join ctop_project b on a.project_id = b.id
+        where
+        b.media_id in (1,3)
+        limit 50
+    </select>
 
 </mapper>

+ 2 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceAccountReportService.java

@@ -21,9 +21,9 @@ public interface IBytedanceAccountReportService {
 
     //List<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList);
 
-    PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId, Integer pageNo, Integer pageSize, String sort);
+    PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId, Integer pageNo, Integer pageSize, String sort, Integer yn);
 
-    PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort);
+    PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort, Integer yn);
 
     //List<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, Long projectId, int pageNum, int pageSize, String sort);
 }

+ 24 - 53
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAccountReportServiceImpl.java

@@ -188,8 +188,8 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
     }
 
     @Override
-    public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort){
-        List<ByteDanceReportAccountDailyDTO> list = new ArrayList<>();
+    public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort, Integer yn){
+        //List<ByteDanceReportAccountDailyDTO> list = new ArrayList<>();
 
         if(projectList==null || projectList.size()==0){
             LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
@@ -202,71 +202,42 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
             mediaIds.add(3L);
 
             if("admin".equals(roleCode)){
-                PageHelper.startPage(pageNum,pageSize);
-                list = bytedanceAccountReportMapper.queryProjectInfoByAdmin(mediaIds);
+                projectList = bytedanceAccountReportMapper.queryProjectInfoByAdmin(mediaIds);
             }else{
-                PageHelper.startPage(pageNum,pageSize);
-                list = bytedanceAccountReportMapper.getSaleProjects(userId,mediaIds);
+                projectList = bytedanceAccountReportMapper.getSaleProjects(userId,mediaIds);
             }
-        }else{
-            PageHelper.startPage(pageNum,pageSize);
-            list = bytedanceAccountReportMapper.queryProjectMemberByIds(projectList);
         }
 
-        //List<ByteDanceReportAccountDailyDTO> projectAccountDTOList = new ArrayList<>();
+        PageHelper.startPage(pageNum,pageSize);
+        List<ByteDanceReportAccountDailyDTO> p = bytedanceAccountReportMapper.getBytedanceProjectInfo(startDate, endDate, projectList, yn);
 
-        for(ByteDanceReportAccountDailyDTO project:list){
-            ByteDanceReportAccountDailyDTO p = bytedanceAccountReportMapper.getBytedanceProjectInfo(startDate, endDate, project.getProjectId());
-
-            project.setShowMaterial(p.getShowMaterial());
-            project.setClickMaterial(p.getClickMaterial());
-            project.setConvertMaterial(p.getConvertMaterial());
-            project.setCost(p.getCost());
-            project.setActive(p.getActive());
-            project.setDownloadFinish(p.getDownloadFinish());
-            project.setDownloadStart(p.getDownloadStart());
-            project.setClickInstall(p.getClickInstall());
-            project.setInstallFinish(p.getInstallFinish());
-            project.setRegister(p.getRegister());
-            project.setPayCount(p.getPayCount());
-            project.setForm(p.getForm());
-            project.setTotalPlay(p.getTotalPlay());
-            project.setValidPlay(p.getValidPlay());
-            project.setWifiPlay(p.getWifiPlay());
-            project.setPlay25FeedBreak(p.getPlay25FeedBreak());
-            project.setPlay50FeedBreak(p.getPlay50FeedBreak());
-            project.setPlay75FeedBreak(p.getPlay75FeedBreak());
-            project.setPlay100FeedBreak(p.getPlay100FeedBreak());
-            project.setShareMaterial(p.getShareMaterial());
-            project.setLikeMaterial(p.getLikeMaterial());
-            project.setPlay25FeedBreakRate(p.getPlay25FeedBreakRate());
-            project.setConvertRate(p.getConvertRate());
-            project.setConvertCost(p.getConvertCost());
-            project.setFollow(p.getFollow());
-            project.setNextDayOpen(p.getNextDayOpen());
-            project.setNextDayOpenRate(p.getNextDayOpenRate());
-            project.setNextDayOpenCost(p.getNextDayOpenCost());
-            project.setCpc(p.getCpc());
-            project.setCtr(p.getCtr());
-            project.setCpm(p.getCpm());
-            project.setActiveCost(p.getActiveCost());
-            project.setActiveRate(p.getActiveRate());
-            project.setActiveRegisterRate(p.getActiveRegisterRate());
-            project.setActiveRegisterCost(p.getActiveRegisterCost());
-        }
-
-        return new PageInfo<>(list);
+        return new PageInfo<>(p);
     }
 
     @Override
-    public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId, Integer pageNo, Integer pageSize, String sort){
+    public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId, Integer pageNo, Integer pageSize, String sort, Integer yn){
+
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //String userId = "e9ca23d68d884d4ebb19d07889727dae";
+        String userId = sysUser.getId();
+        String roleCode = bytedanceAccountReportMapper.getRoleCodeByUserId(userId);
+
+        List<Long> accountIds = null;
+        if(projectId == null){
+            if("admin".equals(roleCode)){
+                accountIds = bytedanceAccountReportMapper.getUserProjectAccountIdsByAdmin();
+            }else {
+                accountIds = bytedanceAccountReportMapper.getSaleProjectAccountIds(userId);
+            }
+        }
+
         if(StringUtils.isBlank(sort)){
             sort = "cost-";
         }
         sort = sort.replace("-", " desc,").replace("+", " asc,");  //sort=id-name+age+
         sort = sort.substring(0, sort.length() - 1);
         PageHelper.startPage(pageNo,pageSize,sort);
-        return new PageInfo<>(bytedanceAccountReportMapper.getBytedanceAccountInfoByProjectId(startDate,endDate,projectId));
+        return new PageInfo<>(bytedanceAccountReportMapper.getBytedanceAccountInfoByProjectId(startDate,endDate,projectId,accountIds,yn));
     }